summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyungKyu Song <hk76.song@samsung.com>2013-02-16 00:55:29 +0900
committerHyungKyu Song <hk76.song@samsung.com>2013-02-16 00:55:29 +0900
commit4043c48868b1eafa7701ac19b4f93bc90ce79c99 (patch)
tree6f3bda67c8725cb999c8fe93c4c3846c83074be8
parent2505051c83d63da1cac1e0ca958574cf98e164d9 (diff)
downloadoma-dm-agent-4043c48868b1eafa7701ac19b4f93bc90ce79c99.tar.gz
oma-dm-agent-4043c48868b1eafa7701ac19b4f93bc90ce79c99.tar.bz2
oma-dm-agent-4043c48868b1eafa7701ac19b4f93bc90ce79c99.zip
-rwxr-xr-xAUTHORS4
-rw-r--r--BuildFlags.cmake31
-rw-r--r--CMakeLists.txt25
-rwxr-xr-xLICENSE.APLv2202
-rwxr-xr-xNOTICE3
-rwxr-xr-xcom.samsung.omadmagent.service3
-rw-r--r--debian/changelog31
-rwxr-xr-xdebian/control23
-rw-r--r--debian/postinst1
-rwxr-xr-xdebian/rules102
-rw-r--r--dm-private-plugins.manifest5
-rw-r--r--dm-public-plugins.manifest5
-rwxr-xr-xinclude/common/dm-status/oma_dm_status_db.h460
-rwxr-xr-xinclude/common/dm-status/oma_dm_status_db_common.h99
-rwxr-xr-xinclude/common/dm-status/oma_dm_status_db_handler.h531
-rwxr-xr-xinclude/common/dm_common.h1075
-rwxr-xr-xinclude/common/dm_common_def.h266
-rwxr-xr-xinclude/common/dm_error.h158
-rwxr-xr-xinclude/common/util/util.h347
-rwxr-xr-xinclude/dm-engine/bootstrap/factory_bootstrap.h76
-rwxr-xr-xinclude/dm-engine/cp/dm_cp_error.h27
-rwxr-xr-xinclude/dm-engine/cp/dm_cp_parser.h61
-rwxr-xr-xinclude/dm-engine/cp/dm_cp_processor.h567
-rwxr-xr-xinclude/dm-engine/cp/dm_cp_security.h40
-rwxr-xr-xinclude/dm-engine/cp/dm_cp_struct.h201
-rwxr-xr-xinclude/dm-engine/dl-manager/dd_object.h53
-rwxr-xr-xinclude/dm-engine/dl-manager/dd_parser.h53
-rwxr-xr-xinclude/dm-engine/dl-manager/fw_downloader.h175
-rwxr-xr-xinclude/dm-engine/dl-manager/na_fw_dl_binder.h54
-rwxr-xr-xinclude/dm-engine/dl-manager/sa_fw_downloader.h177
-rwxr-xr-xinclude/dm-engine/dm_common_engine.h272
-rwxr-xr-xinclude/dm-engine/fumo/fumo_account.h57
-rwxr-xr-xinclude/dm-engine/fumo/fumo_engine.h244
-rwxr-xr-xinclude/dm-engine/fumo/fumo_engine_internal.h91
-rwxr-xr-xinclude/dm-engine/lawmo/lawmo_account.h83
-rwxr-xr-xinclude/dm-engine/lawmo/lawmo_engine.h107
-rwxr-xr-xinclude/dm-engine/lawmo/lawmo_engine_internal.h45
-rwxr-xr-xinclude/framework/platform-event-handler/dm_platform_event_handler.h286
-rwxr-xr-xinclude/framework/platform-event-handler/dm_platform_event_handler_internal.h43
-rwxr-xr-xinclude/framework/san-parser/pm_sanparser.h165
-rwxr-xr-xinclude/framework/task/oma_dm_task_register.h49
-rwxr-xr-xinclude/framework/task/oma_dm_task_request.h308
-rwxr-xr-xinclude/framework/task/oma_dm_task_spec.h580
-rwxr-xr-xinclude/framework/ui-event-handler/ipc_agent.h426
-rwxr-xr-xinclude/framework/ui-event-handler/ipc_common.h176
-rwxr-xr-xinclude/framework/ui-event-handler/user-interaction/user_interaction.h268
-rwxr-xr-xinclude/mo-handler/dm_mo_common.h635
-rwxr-xr-xinclude/mo-handler/dm_mo_common_internal.h258
-rwxr-xr-xinclude/mo-handler/dm_mo_handler.h718
-rwxr-xr-xinclude/serviceadapter/dm-phase-handler/dm_phase_handler.h200
-rwxr-xr-xinclude/serviceadapter/networkbinder/na_binder.h93
-rwxr-xr-xinclude/serviceadapter/protocolbinder/syncml_def.h153
-rwxr-xr-xinclude/serviceadapter/protocolbinder/syncml_protocol_binder.h310
-rwxr-xr-xinclude/serviceadapter/sa_command.h659
-rwxr-xr-xinclude/serviceadapter/sa_command_internal.h94
-rwxr-xr-xinclude/serviceadapter/sa_define.h212
-rwxr-xr-xinclude/serviceadapter/sa_elements.h775
-rwxr-xr-xinclude/serviceadapter/sa_elements_internal.h90
-rwxr-xr-xinclude/serviceadapter/sa_session.h331
-rwxr-xr-xinclude/serviceadapter/sa_session_internal.h78
-rwxr-xr-xinclude/serviceadapter/sa_syncml_binders.h83
-rwxr-xr-xinclude/serviceadapter/sa_util.h171
-rwxr-xr-xoma-dm73
-rwxr-xr-xoma-dm-agent.manifest37
-rwxr-xr-xoma-dm-cfg/csc-setting/change_csc_value.sh16
-rw-r--r--oma-dm-cfg/ddf/slp/slp_devdetail_ddf.xml281
-rw-r--r--oma-dm-cfg/ddf/slp/slp_devinfo_ddf.xml169
-rwxr-xr-xoma-dm-cfg/ddf/slp/slp_fumo_ddf.xml270
-rwxr-xr-xoma-dm-cfg/ddf/slp/slp_gcf_dmacc_ddf_1.2.xml652
-rwxr-xr-xoma-dm-cfg/ddf/slp/slp_lawmo_pcw_ddf.xml1389
-rw-r--r--oma-dm-cfg/ddf/slp/slp_multi_apps.xml681
-rwxr-xr-xoma-dm-cfg/ddf/slp_ddfs.txt6
-rwxr-xr-xoma-dm-cfg/ddf/slp_gcf_dmacc_ddf.txt1
-rw-r--r--oma-dm-cfg/delta_size/max_size.txt1
-rwxr-xr-xoma-dm-cfg/fw-init/omadm_fw_config.xml138
-rw-r--r--oma-dm-cfg/fw-init/omadmadminui_fw_config.xml13
-rw-r--r--oma-dm-cfg/fw-init/omadmalertui_fw_config.xml13
-rw-r--r--oma-dm-cfg/fw-init/omadmcpui_fw_config.xml13
-rw-r--r--oma-dm-cfg/fw-init/omadmdmaccui_fw_config.xml9
-rw-r--r--oma-dm-cfg/fw-init/omadmfotaui_fw_config.xml13
-rw-r--r--oma-dm-cfg/fw-init/omadmnotiui_fw_config.xml13
-rwxr-xr-xoma-dm-cfg/imei-setting/change_imei_callnum.sh3
-rw-r--r--oma-dm-cfg/ipc/eventconfig_omadm15
-rw-r--r--oma-dm-cfg/ipc/noticonfig_omadm14
-rwxr-xr-xpackaging/oma-dm-agent.spec163
-rwxr-xr-xsrc/agent/CMakeLists.txt84
-rw-r--r--src/agent/common/dm-status/oma_dm_status_db.c961
-rwxr-xr-xsrc/agent/common/dm-status/oma_dm_status_db_handler.c638
-rwxr-xr-xsrc/agent/common/dm_common.c1480
-rw-r--r--src/agent/common/util/util.c490
-rwxr-xr-xsrc/agent/dm-engine/bootstrap/factory_bootstrap.c317
-rwxr-xr-xsrc/agent/dm-engine/cp/dm_cp_parser.c1591
-rwxr-xr-xsrc/agent/dm-engine/cp/dm_cp_processor.c2000
-rw-r--r--src/agent/dm-engine/dl-manager/dd_parser.c220
-rw-r--r--src/agent/dm-engine/dl-manager/fw_downloader.c455
-rw-r--r--src/agent/dm-engine/dl-manager/na_fw_dl_binder.c52
-rwxr-xr-xsrc/agent/dm-engine/dl-manager/sa_fw_downloader.c666
-rwxr-xr-xsrc/agent/dm-engine/dm_common_engine.c605
-rw-r--r--src/agent/dm-engine/fumo/fumo_account.c83
-rw-r--r--src/agent/dm-engine/fumo/fumo_engine.c1280
-rw-r--r--src/agent/dm-engine/lawmo/lawmo_account.c101
-rw-r--r--src/agent/dm-engine/lawmo/lawmo_engine.c352
-rwxr-xr-xsrc/agent/framework/platform-event-handler/dm_platform_event_handler.c973
-rw-r--r--src/agent/framework/san-parser/pm_sanparser.c363
-rw-r--r--src/agent/framework/task/oma_dm_task_register.c101
-rw-r--r--src/agent/framework/task/oma_dm_task_request.c265
-rw-r--r--src/agent/framework/task/oma_dm_task_spec.c934
-rwxr-xr-xsrc/agent/framework/ui-event-handler/ipc_agent.c1948
-rw-r--r--src/agent/framework/ui-event-handler/user-interaction/user_interaction.c407
-rwxr-xr-xsrc/agent/main.c264
-rwxr-xr-xsrc/agent/mo-handler/dm_mo_common.c1522
-rwxr-xr-xsrc/agent/mo-handler/dm_mo_handler.c1778
-rwxr-xr-xsrc/agent/serviceadapter/dm-phase-handler/dm_phase_handler.c1451
-rw-r--r--src/agent/serviceadapter/networkbinder/na_binder.c213
-rwxr-xr-xsrc/agent/serviceadapter/protocolbinder/syncml_protocol_binder.c3062
-rw-r--r--src/agent/serviceadapter/sa_command.c944
-rw-r--r--src/agent/serviceadapter/sa_elements.c766
-rw-r--r--src/agent/serviceadapter/sa_session.c2193
-rw-r--r--src/agent/serviceadapter/sa_syncml_binders.c321
-rwxr-xr-xsrc/agent/serviceadapter/sa_util.c394
-rw-r--r--src/plugins/CMakeLists.sub57
-rw-r--r--src/plugins/CMakeLists.txt4
-rwxr-xr-xsrc/plugins/dm-private/CMakeLists.txt13
-rwxr-xr-xsrc/plugins/dm-private/dmacc-gcf/CMakeLists.txt43
-rwxr-xr-xsrc/plugins/dm-private/dmacc-gcf/include/des.h25
-rwxr-xr-xsrc/plugins/dm-private/dmacc-gcf/include/password_generator.h29
-rwxr-xr-xsrc/plugins/dm-private/dmacc-gcf/src/password_generator.c74
-rwxr-xr-xsrc/plugins/dm-private/dmacc-gcf/src/plugin_interface.c511
-rwxr-xr-xsrc/plugins/dm-private/fumo/CMakeLists.txt47
-rwxr-xr-xsrc/plugins/dm-private/fumo/src/plugin_interface.c234
-rwxr-xr-xsrc/plugins/dm-private/lawmo/CMakeLists.txt49
-rwxr-xr-xsrc/plugins/dm-private/lawmo/include/plugin_devexe_error.h107
-rwxr-xr-xsrc/plugins/dm-private/lawmo/src/plugin_interface.c687
-rwxr-xr-xsrc/plugins/dm-private/multiapps/CMakeLists.txt43
-rwxr-xr-xsrc/plugins/dm-private/multiapps/src/plugin_interface.c192
-rwxr-xr-xsrc/plugins/dm-private/slp-device-dm/CMakeLists.txt48
-rwxr-xr-xsrc/plugins/dm-private/slp-device-dm/include/plugin_devexe_error.h47
-rwxr-xr-xsrc/plugins/dm-private/slp-device-dm/include/plugin_slp_device_ctrl.h29
-rwxr-xr-xsrc/plugins/dm-private/slp-device-dm/include/plugin_slp_device_dm.h81
-rwxr-xr-xsrc/plugins/dm-private/slp-device-dm/include/plugin_slp_device_info.h36
-rwxr-xr-xsrc/plugins/dm-private/slp-device-dm/src/plugin_interface_devexe.c572
-rwxr-xr-xsrc/plugins/dm-private/slp-device-dm/src/plugin_interface_devinfo.c455
-rwxr-xr-xsrc/plugins/dm-private/slp-device-dm/src/plugin_slp_device_ctrl.c474
-rwxr-xr-xsrc/plugins/dm-private/slp-device-dm/src/plugin_slp_device_info.c365
-rwxr-xr-xsrc/plugins/dm-private/slp-sysnoti-telephony/CMakeLists.txt45
-rwxr-xr-xsrc/plugins/dm-private/slp-sysnoti-telephony/src/plugin_interface.c298
-rwxr-xr-xsrc/plugins/dm-public/CMakeLists.txt10
-rwxr-xr-xsrc/plugins/dm-public/devdetail/CMakeLists.txt43
-rwxr-xr-xsrc/plugins/dm-public/devdetail/src/plugin_interface.c251
-rwxr-xr-xsrc/plugins/dm-public/devinfo/CMakeLists.txt43
-rwxr-xr-xsrc/plugins/dm-public/devinfo/src/.gitignore1
-rwxr-xr-xsrc/plugins/dm-public/devinfo/src/plugin_interface.c247
152 files changed, 51332 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..92b9c72
--- /dev/null
+++ b/BuildFlags.cmake
@@ -0,0 +1,31 @@
+# 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..72e5495
--- /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("-DOMADM_AGENT_LOG")
+ADD_DEFINITIONS("-DLOG_TAG=\"OMA_DM_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.omadmagent.service b/com.samsung.omadmagent.service
new file mode 100755
index 0000000..e5d8851
--- /dev/null
+++ b/com.samsung.omadmagent.service
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=com.samsung.omadmagent
+Exec=/usr/bin/oma-dm-agent
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..52b9339
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,31 @@
+oma-dm-agent (0.1.4) unstable; urgency=low
+
+ * 1. Prevent defects fixed, license file update.
+ * Git: framework/system/oma-dm-agent
+ * Tag: oma-dm-agent_0.1.4
+
+ -- Juhaki Park <juhaki.park@samsung.com> Mon, 21 Jan 2012 22:03:02 +0900
+
+oma-dm-agent (0.1.3) unstable; urgency=low
+
+ * 1. Prevent defects fixed.
+ * Git: framework/system/oma-dm-agent
+ * Tag: oma-dm-agent_0.1.3
+
+ -- Juhaki Park <juhaki.park@samsung.com> Wed, 09 Jan 2012 18:14:02 +0900
+
+oma-dm-agent (0.1.2) unstable; urgency=low
+
+ * 1. Internal: build error & dependency patch
+ * Git: framework/system/oma-dm-agent
+ * Tag: oma-dm-agent_0.1.2
+
+ -- WooJin Yun <suhoangel9@samsung.com> Fri, 28 Dec 2012 22:54:02 +0900
+
+oma-dm-agent (0.1.1) unstable; urgency=low
+
+ * Initial update
+ * Git: framework/system/oma-dm-agent
+ * Tag: oma-dm-agent_0.1.1
+
+ -- WooJin Yun <suhoangel9@samsung.com> Wed, 01 Feb 2012 21:16:27 +0900
diff --git a/debian/control b/debian/control
new file mode 100755
index 0000000..9e6c785
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,23 @@
+Source: oma-dm-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, libsoup2.4-dev, libsqlite3-dev, check, libexpat1-dev, libxml2-dev, libaul-1-dev, libwbxml2-dev, libsync-agent-framework-dev, liboauth-dev, libappsvc-dev
+Standards-Version: 0.1.1
+
+
+Package: oma-dm-agent
+Section: embedded
+Architecture: any
+Priority: optional
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: oma-dm-agent pkg
+
+Package: oma-dm-agent-dbg
+Section: embedded
+Architecture: any
+Priority: optional
+Depends: ${misc:Depends} oma-dm-agent (= ${Source-Version})
+Description: oma-dm-agent pkg (dbg)
+
diff --git a/debian/postinst b/debian/postinst
new file mode 100644
index 0000000..1a24852
--- /dev/null
+++ b/debian/postinst
@@ -0,0 +1 @@
+#!/bin/sh
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..d456192
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,102 @@
+#!/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 $(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)/syncmldm_mgr $(CURDIR)/debian/tmp/etc/rc.d/init.d
+
+ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc3.d
+ ln -s ../init.d/syncmldm_mgr $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/S91oma-dm-agent
+
+ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc5.d
+ ln -s ../init.d/syncmldm_mgr $(CURDIR)/debian/tmp/etc/rc.d/rc5.d/S91oma-dm-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-dm-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/dm-private-plugins.manifest b/dm-private-plugins.manifest
new file mode 100644
index 0000000..97e8c31
--- /dev/null
+++ b/dm-private-plugins.manifest
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
diff --git a/dm-public-plugins.manifest b/dm-public-plugins.manifest
new file mode 100644
index 0000000..97e8c31
--- /dev/null
+++ b/dm-public-plugins.manifest
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
diff --git a/include/common/dm-status/oma_dm_status_db.h b/include/common/dm-status/oma_dm_status_db.h
new file mode 100755
index 0000000..783df38
--- /dev/null
+++ b/include/common/dm-status/oma_dm_status_db.h
@@ -0,0 +1,460 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMA_DM_STATUS_DB_H_
+#define OMA_DM_STATUS_DB_H_
+
+/*dm-agent*/
+#include "common/dm_error.h"
+#include "common/dm-status/oma_dm_status_db_common.h"
+
+/*
+ * =============================================================================================================================
+ * Database Open & Close & Create table
+ * =============================================================================================================================
+ *
+ */
+
+/**
+ * @par Description: API to dm open agent db handler
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[out] db handler
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_open_agent(DB_HANDLER ** db_handler);
+
+/**
+ * @par Description: API to dm close agent db handler
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] db handler
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_close_agent(DB_HANDLER * db_handler);
+
+/**
+ * @par Description: API to create dm service db table
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] db handler
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_create_table(DB_HANDLER * db_handler);
+
+/**
+ * @par Description: API to delete dm service db table
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] db handler
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_delete_table(DB_HANDLER * db_handler);
+
+/**
+ * @par Description: API to reset dm service db table
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] db handler
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_reset_table(DB_HANDLER * db_handler);
+
+/*
+ * =============================================================================================================================
+ * Control Transaction
+ * =============================================================================================================================
+ */
+
+/**
+ * @par Description: API to begin transaction dm service db table
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] db handler
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_begin_transaction(DB_HANDLER * db_handler);
+
+/**
+ * @par Description: API to end transaction dm service db table
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] db handler
+ * @param[in] DB_TRANSACTION (commit, rollback)
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_end_transaction(DB_HANDLER * db_handler, DB_TRANSACTION transaction);
+
+/*
+ * =============================================================================================================================
+ * engine_status table
+ * =============================================================================================================================
+ */
+
+/**
+ * @par Description: API to init dm service db table
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] db handler
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_init_engine_status(DB_HANDLER * db_handler);
+
+/**
+ * @par Description: API to add engine status structure in dm service db table
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] db handler
+ * @param[in] engine status structure
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_add_engine_status(DB_HANDLER * db_handler, engine_status * status);
+
+/**
+ * @par Description: API to delete engine status structure in dm service db table
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] db handler
+ * @param[in] engine status id
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_delete_engine_status(DB_HANDLER * db_handler, int engine_id);
+
+/**
+ * @par Description: API to update engine status structure in dm service db table
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] db handler
+ * @param[in] engine status structure
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_update_engine_status(DB_HANDLER * db_handler, engine_status * status);
+
+/**
+ * @par Description: API to update engine status column in dm service db table
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] db handler
+ * @param[in] engine status key
+ * @param[in] engine status value
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_update_engine_status_column(DB_HANDLER * db_handler, int engine_id, ENGINE_STATUS_VALUE engine_status_value, void *value);
+
+/**
+ * @par Description: API to get engine status structure in dm service db table
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] db handler
+ * @param[in] engine status id
+ * @param[out] engine status structure
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_get_engine_status(DB_HANDLER * db_handler, int engine_id, engine_status ** status);
+
+/**
+ * @par Description: API to get all engine status structure in dm service db table
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] db handler
+ * @param[out] engine status structures
+ * @param[out] engine status count
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_get_aII_engine_status(DB_HANDLER * db_handler, engine_status ** status_list, int *count);
+
+/**
+ * @par Description: API to check exist engine status in dm service db table
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] db handler
+ * @param[in] engine status id
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int dm_isExist_engine_id(DB_HANDLER * db_handler, int engine_id);
+
+#endif /* OMA_DM_STATUS_DB_H_ */
diff --git a/include/common/dm-status/oma_dm_status_db_common.h b/include/common/dm-status/oma_dm_status_db_common.h
new file mode 100755
index 0000000..0462cf9
--- /dev/null
+++ b/include/common/dm-status/oma_dm_status_db_common.h
@@ -0,0 +1,99 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMA_DM_STATUS_DB_COMMON_H_
+#define OMA_DM_STATUS_DB_COMMON_H_
+
+/*lib*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <malloc.h>
+#include <glib.h>
+#include <time.h>
+#include <sqlite3.h>
+#include <pthread.h>
+
+#define DB_HANDLER sqlite3
+
+#define GET_THREAD_ID pthread_self()
+
+#define RETRY_COUNT 10
+
+#define MAX_QUERY_LENGTH 1024
+
+#define STRDUP(src) (src == NULL) ? NULL : strdup(src);
+
+#define ATOI(src) (src == NULL) ? 0 : atoi(src);
+
+#define MEMORY_FREE(src) \
+ if (src != NULL) { \
+ free(src); \
+ src = NULL; \
+ } \
+
+typedef sqlite3_stmt(*db_stmt);
+
+/* define enum & structure */
+typedef enum {
+ ENGINE_STATUS_TBL,
+
+ DB_TABLE_NAME_MAX
+} DB_TABLE_NAME;
+
+typedef enum {
+ TRANSACTION_COMMIT_ = 0,
+ TRANSACTION_ROLLBACK_
+} DB_TRANSACTION;
+
+typedef enum {
+ VALUE_ENGINE_ID,
+ VALUE_ENGINE_STATUS,
+ VALUE_SERVER_ID,
+ VALUE_SERVER_URL,
+ VALUE_CORRELATOR,
+ VALUE_MO_PATH,
+ VALUE_RESULT_STATUS,
+ VALUE_UI_MODE,
+ VALUE_TASK_ID,
+ VALUE_UI_NOTI_TYPE,
+ VALUE_DOWNLOAD_CLICK,
+ VALUE_UPDATE_TIME
+} ENGINE_STATUS_VALUE;
+
+typedef struct {
+ GHashTable *db_handlerTable; /* db handler hash table */
+ pthread_mutex_t *db_handlerTable_mutex; /* mutex for db handler hash table */
+} db_handler_mgr;
+
+typedef struct {
+ int engine_id;
+ int engine_status;
+ char *server_id;
+ char *server_url;
+ char *correlator;
+ char *mo_path;
+ int result_status;
+ char *ui_mode;
+ int task_id;
+ int ui_noti_type;
+ int download_click;
+ time_t update_time;
+
+} engine_status;
+
+#endif /* OMA_DM_STATUS_DB_COMMON_H_ */
diff --git a/include/common/dm-status/oma_dm_status_db_handler.h b/include/common/dm-status/oma_dm_status_db_handler.h
new file mode 100755
index 0000000..d5ded22
--- /dev/null
+++ b/include/common/dm-status/oma_dm_status_db_handler.h
@@ -0,0 +1,531 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMA_DM_STATUS_DB_HANDLER_H_
+#define OMA_DM_STATUS_DB_HANDLER_H_
+
+/*dm-agent*/
+#include "common/dm_error.h"
+#include "common/dm-status/oma_dm_status_db_common.h"
+
+/*
+ * ==================================
+ * external API (1. about db handler mgr)
+ * ==================================
+ */
+
+/**
+ * @par Description: API to alloc the db handler manager
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR Alloc_DB_Handler_Mgr();
+
+/**
+ * @par Description: API to free the db handler manager
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR Free_DB_Handler_Mgr();
+
+/**
+ * @par Description: API to free engine structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] free structure count
+ * @param[in] engine_status structure
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void Free_Memory_Engine_Status(engine_status ** status, int count);
+
+/*
+ * ==================================
+ * external API (2. about agent db )
+ * ==================================
+ */
+/*
+ * =============================================================================================================================
+ * Database Open & Close & Create table
+ * =============================================================================================================================
+ *
+ */
+/**
+ * @par Description: API to dm_service db open
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR DB_Open();
+
+/**
+ * @par Description: API to dm_service db close
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return
+ *
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void DB_Close();
+
+/**
+ * @par Description: API to create dm_service db
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR DB_Create_Table();
+
+/**
+ * @par Description: API to delete dm_service db
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR DB_Delete_Table();
+
+/**
+ * @par Description: API to reset dm_service db
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR DB_Reset_Table();
+
+/*
+ * =============================================================================================================================
+ * Control Transaction
+ * =============================================================================================================================
+ */
+/**
+ * @par Description: API to begin transaction dm_service db
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR DB_Begin_Transaction();
+
+/**
+ * @par Description: API to end transaction dm_service db
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] DB_TRANSACTION ( commit, rollback)
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN on error
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR DB_End_Transaction(DB_TRANSACTION transaction);
+
+/*
+ * =============================================================================================================================
+ * engine_status table
+ * =============================================================================================================================
+ */
+/**
+ * @par Description: API to init engine status
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR Init_Engine_Status();
+
+/**
+ * @par Description: API to add engine status row in db
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] engine_status structure
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR Add_Engine_Status(engine_status * status);
+
+/**
+ * @par Description: API to delete engine status in db
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] engine_status id
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR Delete_Engine_Status(int engine_id);
+
+/**
+ * @par Description: API to update engine status in db
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] engine_status structure
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR Update_Engine_Status(engine_status * status);
+
+/**
+ * @par Description: API to update engine status column in db
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] engine_status id
+ * @param[in] engine_status key
+ * @param[in] engine_status value
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR Update_Engine_Status_Column(int engine_id, ENGINE_STATUS_VALUE engine_status_value, void *value);
+
+/**
+ * @par Description: API to get engine status structure in db
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] engine_status id
+ * @param[out] engine_status structure
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR Get_Engine_Status(int engine_id, engine_status ** status);
+
+/**
+ * @par Description: API to get engine status structure in db
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[out] engine_status structure list
+ * @param[out] engine_status structure count
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR Get_AII_Engine_Status(engine_status ** status_list, int *count);
+
+/**
+ * @par Description: API to check exist engine status structure in db
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] engine_status id
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int IsExist_Engine_id(int engine_id);
+
+#endif /* OMA_DM_STATUS_DB_HANDLER_H_ */
diff --git a/include/common/dm_common.h b/include/common/dm_common.h
new file mode 100755
index 0000000..56ef319
--- /dev/null
+++ b/include/common/dm_common.h
@@ -0,0 +1,1075 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @DM_Common.h
+ * @version 0.1
+ * @brief This file is the header file of defined common interface for using oma-dm-agent
+ */
+
+#ifndef OMA_DM_COMMON_H_
+#define OMA_DM_COMMON_H_
+
+/*lib*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+/*dm-agent*/
+#include "common/dm-status/oma_dm_status_db_common.h"
+#include "common/dm-status/oma_dm_status_db_handler.h"
+#include "common/dm-status/oma_dm_status_db.h"
+#include "common/dm_common_def.h"
+#include "common/dm_error.h"
+#include "framework/platform-event-handler/dm_platform_event_handler.h"
+
+/**
+ * @par Description: API to initiate dm-service
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK on success
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR init_dm();
+
+/**
+ * @par Description: API to end dm-service
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK on success
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR end_dm();
+
+/**
+ * @par Description: API to reset dm-service
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK on success
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR reset_dm();
+
+/**
+ * @par Description: API to operate service engine (fumo, lawmo) by dm status db query API
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK on success
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR auto_operate_service_engine();
+
+/**
+ * @par Description: API to register scheduler(alarm)
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ *
+ * @return 1 on success
+ * 0 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int register_scheduler();
+
+/**
+ * @par Description: API to register wap push module
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ *
+ * @return 1 on success
+ * 0 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int register_wap_push();
+
+/**
+ * @par Description: API to register fumo ip push module
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ *
+ * @return 1 on success
+ * 0 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int register_fumo_ip_push();
+
+/**
+ * @par Description: API to register lawmo samsung account
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ *
+ * @return 1 on success
+ * 0 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int register_lawmo_samsung_account();
+
+/**
+ * @par Description: API to register telephony module
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ *
+ * @return 1 on success
+ * 0 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int register_telephony();
+
+/**
+ * @par Description: API to register network
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ *
+ * @return 1 on success
+ * 0 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int register_network();
+
+/**
+ * @par Description: API to cancel network callback function
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] user data(network session id)
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void network_cancel_callback(void *user_data);
+
+/**
+ * @par Description: API to delay network connection
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void network_connection_delay();
+
+/**
+ *@par Description: API to set account registration alarm
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] alarm type string(fumo, fmm)
+ * @param[in] alarm type(fumo, fmm)
+ *
+ * @return DM_OK on success
+ * DM_ERROR on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR set_account_registration_alarm(char *alarm_str, CONFIG_TYPE alarm_type);
+
+/**
+ * @par Description: API to delete fota account registration alarm
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] alarm type string
+ * @param[in] alarm type
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void delete_account_registration_alarm(char *alarm_str, CONFIG_TYPE alarm_type);
+
+/**
+ * @par Description: API to set alarm schedule
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] reminder interval
+ * @param[in] alarm type
+ * @param[in] config type
+ *
+ * @return DM_OK on success
+ * DM_ERROR on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR add_alarm_item(Reminder_Interval interval, char *alarm_type, CONFIG_TYPE conf_type);
+
+/**
+ * @par Description: API to delete alarm schedule
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] alarm type
+ * @param[in] config type
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void delete_alarm_item(char *alarm_type, CONFIG_TYPE conf_type);
+
+/**
+ * @par Description: API to start fumo service
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] event contents
+ *
+ * @return DM_OK on success
+ * DM_ERROR on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR fumo_service_start(Event_Contents * pEvent_data);
+
+/**
+ * @par Description: API to get service engine type
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] service engine type string
+ *
+ * @return SAMSUNG_FUMO_TYPE
+ * SAMSUNG_FMM_TYPE
+ * GCF_TYPE
+ * NO_ENGINE_TYPE
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+SERVICE_SERVER_TYPE get_service_engine_type(const char *service_engine_type);
+
+/**
+ * @par Description: API to get server information
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] Event contents
+ * @param[out] server id
+ * @param[out] session id
+ * @param[out] session type
+ *
+ * @return DM_OK on success
+ * DM_ERRORS on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_server_info(Event_Contents * pEvent_data, char **server_id, char **session_id, int *session_type);
+
+/**
+ * @par Description: API to get fumo ui mode
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[out] ui mode
+ *
+ * @return DM_OK on success
+ * DM_ERRORS on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_fumo_ui_mode(char **ui_mode);
+
+/**
+ * @par Description: API to check existed fumo remind interval
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ *
+ * @return 1 on success
+ * 0 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int check_existed_fumo_reminder_interval();
+
+/**
+ * @par Description: API to init defult fumo configuration
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ *
+ * @return 1 success
+ * -1 error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int init_default_fumo_config();
+
+/**
+ * @par Description: API to set configuration int value
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] config_type
+ * @param[in] key
+ * @param[in] value
+ * @param[in] accessName
+ * @param[in] isFirst
+ *
+ * @return 1 success
+ * -1 error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int set_config_int(CONFIG_TYPE config_type, char *key, int value, char *accessName, int isFirst);
+
+/**
+ * @par Description: API to set alarm configuration int value
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] config_type
+ * @param[in] key
+ * @param[in] value
+ * @param[in] accessName
+ *
+ * @return 1 success
+ * 0 error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int set_alarm_config_int(CONFIG_TYPE config_type, char *key, int value, char *accessName);
+
+/**
+ * @par Description: API to get configuration int value
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] config id
+ * @param[in] key
+ *
+ * @return 1 success
+ * 0 error
+ * 0
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int get_config_int(CONFIG_TYPE config_id, char *key);
+
+/**
+ * @par Description: API to get wifi only config
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ *
+ * @return 1 on success
+ * -1 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int get_wifi_only_config();
+
+/**
+ * @par Description: API to set wifi only config
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] value
+ *
+ * @return 1 on success
+ * -1 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int set_wifi_only_config(int value);
+
+/**
+ * @par Description: API to get battery state
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[out] battery value
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+
+DM_ERROR get_battery_state(char **battery_level);
+
+/**
+ * @par Description: API to check existed sd card memory
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[out] existed sd
+ *
+ * @return DM_OK on success
+ * DM_SD_CARD_ERROR on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR existed_sd_card_memory(int *existed_sd);
+
+/**
+ * @par Description: API to get telephony state
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[out] now calling
+ *
+ * @return DM_OK on success
+ * DM_TELEPHONY_ERROR on errorS
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_telephony_state(int *now_calling);
+
+/**
+ * @par Description: API to get compare memory space
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] memory_type
+ * @param[in] file_size
+ *
+ * @return DM_OK on success
+ * DM_MEMORY_ERROR, DM_OVER_MEMORY_ERROR on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR compare_memory_space(char *memory_type, long double file_size);
+
+/**
+ * @par Description: API to get roaming state
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] roaming_state
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void get_roaming_state(int *roaming_state);
+
+/**
+ * @par Description: API to get call state
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] call_state
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void get_call_sate(int *call_state);
+
+/**
+ * @par Description: API to get mmc state
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[out] mmc_state
+ *
+ * @return 1 on success
+ * 0 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int get_mmc_state(int *mmc_state);
+
+/**
+ * @par Description: API to get fota download_dir
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] memory type
+ * @param[out] download folder path
+ *
+ * @return DM_OK on success
+ * DM_MEMORY_ERROR on fail
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_fota_download_dir(MEMORY_TYPE type, char **download_folder);
+
+/**
+ * @par Description: API to get fota save dir
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] memory type
+ * @param[out] save folder path
+ *
+ * @return DM_OK on success
+ * DM_MEMORY_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_fota_save_dir(MEMORY_TYPE type, char **save_folder);
+
+/**
+ * @par Description: API to delete fumo contents
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] memory type
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void delete_fumo_contents(MEMORY_TYPE memory_type);
+
+/**
+ * @par Description: API to the first server bootstrap
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] server id
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void first_server_bootstrap(char *server_id);
+
+/**
+ * @par Description: API to get default noti type
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] ui mode
+ * @param[in] noti type
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int get_default_noti_type(char *ui_mode, NotI_Type noti_type);
+
+/**
+ * @par Description: API to get new url
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] uri
+ * @param[out] new uri
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+char *get_new_uri(char *old_object_uri);
+
+#endif /* OMA_DM_COMMON_H_ */
diff --git a/include/common/dm_common_def.h b/include/common/dm_common_def.h
new file mode 100755
index 0000000..dcd0fff
--- /dev/null
+++ b/include/common/dm_common_def.h
@@ -0,0 +1,266 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @DM_Common_Def.h
+ * @version 0.1
+ * @brief This file is the header file of defined common define and common enum type for using oma-dm-serice
+ */
+
+#ifndef OMA_DM_COMMON_DEF_H_
+#define OMA_DM_COMMON_DEF_H_
+
+/*#define _OMA_DM_V11_*/
+#define _OMA_DM_V12_
+
+#define _OMA_DM_DEBUG_
+#ifdef _OMA_DM_DEBUG_
+#define _OMA_DM_TEST_DEBUG
+#endif
+
+/*log tag define*/
+/*
+#define OMA_DM_LOG
+#ifdef OMA_DM_LOG
+ #define LOG_TAG "OMA_DM"
+#endif
+*/
+
+//#define _DM_SCORE_TEST
+#ifdef _DM_SCORE_TEST
+#define _DM_BUNDANG_TEST
+#endif
+
+#define _SLP_SAMSUNG_DM_MO
+
+/*
+ * ==============================================
+ * OMA DM APP ID
+ * ==============================================
+ */
+/*for bada*/
+/*#define OMA_DM_FUMO_APPID "3b74c3e0075a630e"*/
+/*for slp fota*/
+
+/*
+#define OMA_DM_FUMO_APPID "bc2d5906ebefbb66"
+#define OMA_DM_FUMO_APPSECRETID "rLIrPQYjzNOgkSU6gQME+b2J8Ro="
+
+#define OMA_DM_LAWMO_APPID "ed7b8510eb22050e"
+#define OMA_DM_LAWMO_APPSECRETID "OHlxuLBrlM25AQlN6ZN05GFowk8="
+*/
+
+/*
+ * ==============================================
+ * OMA DM PKG DEFINE
+ * ==============================================
+ */
+#define OMA_DM_AGENT_PKG "oma-dm-agent"
+#define OMA_DM_FUMO_UI_PKG "com.samsung.oma-dm"
+#define OMA_DM_FUMO_NOTI_UI_PKG "com.samsung.oma-dm-noti"
+#define OMA_DM_ADMIN_UI_PKG "com.samsung.oma-dm-admin"
+#define OMA_DM_ALERT_UI_PKG "com.samsung.oma-dm-alert"
+#define OMA_DM_CP_UI_PKG "com.samsung.oma-dm-cp"
+
+/*
+ * ==============================================
+ * OMA DM MSG
+ * ==============================================
+ */
+
+#define OMA_DM_MSG_PATH "/tmp/dm.txt"
+
+/*
+ * ==============================================
+ * FUMO ENGINE DEFINE
+ * ==============================================
+ */
+#define FUMO "fumo"
+#define OMADM_FUMO_UI_TYPE "omadm_fota_ui"
+#define OMADM_FUMO_NOTI_UI_TYPE "omadm_noti_ui"
+#define OMADM_FUMO_BACKGROUND_UI_TYPE "omadm_background_ui"
+#define OMADM_ADMIN_UI_TYPE "omadm_admin_ui"
+#define OMADM_ALERT_UI_TYPE "omadm_alert_ui"
+#define OMADM_CP_UI_TYPE "omadm_cp_ui"
+
+#define FUMO_ACCOUNT_FLAG "fumo_account_flag"
+#define FUMO_ACCOUNT_ALARM "fumo_account_alarm"
+#define FUMO_ENGINE "fumo_engine"
+#define FUMO_INTERVAL "fumo_interval"
+#define FUMO_WIFI_ONLY_CONFIG "fumo_wifi_only_config"
+
+#define LAWMO_ENGINE "lawmo_engine"
+#define LAWMO_ACCOUNT_FLAG "lawmo_account_flag"
+#define LAWMO_ACCOUNT_ALARM "lawmo_account_alarm"
+
+#define IPC_DS "/tmp/agent_fw_event_omads"
+#define FOTA_DELTA_INTERNAL_STORAGE "/opt/data/fota"
+#define FOTA_DELTA_SD_INTERNAL_STORAGE "/opt/media"
+#define FOTA_DELTA_SD_EXTERNAL_STORAGE "/opt/storage/sdcard"
+
+typedef enum {
+ //INTERVAL_NONE =0,
+ INTERVAL_1HOUR = 1,
+ INTERVAL_3HOURS = 2,
+ INTERVAL_6HOURS = 3,
+ INTERVAL_12HOURS = 4,
+ INTERVAL_1DAY = 5,
+ //INTERVAL_7DAYS = 5,
+ INTERVAL_CANCEL = 6,
+ INTERVAL_1MONTH = 7
+} Reminder_Interval;
+
+typedef enum {
+ FUMO_INTERVAL_TYPE = 0, //alarm
+ FUMO_WIFI_ONLY_TYPE = 1,
+ FUMO_ACCOUNT_FLAG_TYPE = 2,
+ FUMO_ACCOUNT_ALARM_TYPE = 3, //alarm
+ LAWMO_ACCOUNT_FLAG_TYPE = 4,
+ LAWMO_ACCOUNT_ALARM_TYPE = 5 //alarm
+} CONFIG_TYPE;
+
+/*
+ * ==============================================
+ * OMA DM ENGINE STATUS
+ * ==============================================
+*/
+
+typedef enum {
+ DM_IDLE = 0,
+ DM_BEFORE_BOOTSTRAP = 1,
+ DM_COMMON_PROCESSING = 2,
+ DM_GENERIC_ALERT = 3,
+ DM_SERVICE_ENGINE_PROCESSING = 4,
+
+ /*todo */
+ /*DM_FUMO_ENGINE_PROCESSING = 4,
+ DM_LAWMO_ENGINE_PROCESSING = 5,
+ DM_COMPLETE_FIRMWARE_UPDATE_WITH_GENERICALERT, */
+
+ /*after 50 */
+ DM_UI_DISPLAY,
+ DM_UI_CONFIRMATION,
+ DM_UI_USER_INPUT,
+ DM_UI_USER_CHOISE,
+ DM_UI_PROGRESS_BAR,
+
+} ENGINE_STATUS;
+
+/*
+ * ==============================================
+ * SERVICE ENGINE STATUS
+ * ==============================================
+*/
+
+typedef enum {
+ DM_SERVICE_UNKNOWN = 0,
+ DM_SERVICE_ING = 1,
+ DM_GENERICALERT_ING = 2
+/* DM_SERVICE_ALARM = 3,
+ DM_SERVICE_OTHER = 4*/
+} SERVICE_ENGINE_STATUS;
+
+/*
+ * ==============================================
+ * ENGINE ID
+ * ==============================================
+*/
+
+typedef enum {
+ IDLE_ENGINE = 0,
+ BOOTSTRAP = 1,
+ COMMON_ENGINE = 2,
+ GENERICALERT = 3,
+ //SERVICE_ENGINE = 4,
+
+ //sync_agent_dm_mo_type_e MAPPING
+ FUMO_SERVICE_ENGINE = 4,
+ LAWMO_SERVICE_ENGINE = 8,
+ //SCOMO_SERVICE_ENGINE = 16,
+ NO_SERVICE_ENGINE = 32
+} ENGINE_ID;
+
+/*
+ * ==============================================
+ * ENGINE TYPE
+ * ==============================================
+*/
+
+typedef enum {
+ SAMSUNG_FUMO_TYPE = 4,
+ SAMSUNG_FMM_TYPE = 8,
+ GCF_TYPE = 16,
+ NO_ENGINE_TYPE = 32
+} SERVICE_SERVER_TYPE;
+
+/*
+ * ==============================================
+ * DM OPERATION MODE
+ * ==============================================
+*/
+
+typedef enum {
+ OPER_UNKNOWN,
+ OPER_SERVER_INITIATION_FROM_WAP,
+ OPER_SERVER_INITIATION_FROM_IP,
+ OPER_USER_INITIATION,
+ OPER_SCHEDULER
+} OPER_MODE;
+
+/*
+ * ==============================================
+ * MEMORY TYPE
+ * ==============================================
+*/
+typedef enum {
+ MEMORY_INTERNAL,
+ MEMORY_SD_CARD
+} MEMORY_TYPE;
+
+/*
+ * ==============================================
+ * USER INTERACTION OPTION
+ * ==============================================
+*/
+
+#define UI_OP_MINDT "MINDT="
+#define UI_OP_MAXDT "MAXDT="
+#define UI_OP_DR "DR="
+#define UI_OP_MAXLEN "MAXLEN="
+#define UI_OP_IT "IT="
+#define UI_OP_ET "ET="
+#define UI_OP_SEPARATOR "&"
+#define UI_OP_EQUAL "="
+
+/*
+ * ==============================================
+ * RESUME STATES DOWNLOAD, INSTALL, LATER
+ * ==============================================
+*/
+
+typedef enum {
+ RESUME_STATUS_DONWLOAD_BEFORE = 0,
+ RESUME_STATUS_DOWNLOAD,
+ RESUME_STATUS_DOWNLOAD_LATER,
+ RESUME_STATUS_DOWNLOAD_IDLE,
+ RESUME_STATUS_INSTALL_BEFORE,
+ RESUME_STATUS_INSTALL,
+ RESUME_STATUS_INSTALL_LATER,
+ RESUME_STATUS_INSTALL_IDLE
+} RESUME_STATUS;
+
+#endif /* OMA_DM_COMMON_DEF_H_ */
diff --git a/include/common/dm_error.h b/include/common/dm_error.h
new file mode 100755
index 0000000..109e6ce
--- /dev/null
+++ b/include/common/dm_error.h
@@ -0,0 +1,158 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @DM_Error.h
+ * @version 0.1
+ * @brief This file is the header file of defined common error
+ */
+
+#ifndef OMA_DM_ERROR_H_
+#define OMA_DM_ERROR_H_
+
+typedef enum {
+ DM_ERR_UNKNOWN = 0,
+ DM_OK = 200,
+
+ /*dm spec */
+ DM_ERR_ACCEPTED_FOR_PROCESSING = 202,
+ DM_ERR_AUTH_ACCEPTED = 212,
+ DM_ERR_CHUNKED_ITEM_ACCEPTED = 213,
+ DM_ERR_OPERATION_CANCELLED = 214,
+ DM_ERR_NOT_EXECUTED = 215,
+ DM_ERR_ATOMIC_ROLL_BACK_OK = 216,
+
+ DM_ERR_NOT_MODIFIED = 304,
+
+ DM_ERR_UNAUTHORIZED = 401,
+ DM_ERR_FORBIDDEN = 403,
+ DM_ERR_NOT_FOUND = 404,
+ DM_ERR_COMMAND_NOT_ALLOWED = 405,
+ DM_ERR_OPTIONAL_FEATURE_NOT_SUPPORTED = 406,
+ DM_ERR_AUTHENTICATION_REQUIRED = 407,
+ DM_ERR_REQUEST_TIMEOUT = 408,
+ DM_ERR_SIZE_REQUIRED = 411,
+ DM_ERR_INCOMPLETE_COMMAND = 412,
+ DM_ERR_REQUEST_ENTITY_TOO_LARGE = 413,
+ DM_ERR_URI_TOO_LONG = 414,
+ DM_ERR_UNSUPPORTED_MEDIA_TYPE_OR_FORMAT = 415,
+ DM_ERR_REQUESTED_SIZE_TOO_BIG = 416,
+ DM_ERR_ALEADY_EXISTS = 418,
+ DM_ERR_DEVICE_FULL = 420,
+ DM_ERR_SIZE_MISMATCH = 424,
+ DM_ERR_PERMISSION_DENIED = 425,
+ DM_ERR_NOT_EXEC_FOTA_FLAG = 426,
+
+ /*dm command */
+ DM_ERR_COMMAND_FAILED = 500,
+ DM_ERR_ATOMIC_FAILED = 507,
+ DM_ERR_REQUIRE_REFRESH = 508,
+ DM_ERR_SERVER_FAILURE = 509,
+ DM_ERR_ATOMIC_ROLL_BACK_FAILED = 516,
+ DM_ERR_ATOMIC_RESPONSE_TOO_LARGE_TO_FIT = 517,
+
+ /*common error */
+ COMMON_ERR_CAN_NOT_BOOTSTRAP = 549,
+ COMMON_ERR_BOOTSTRAP = 550,
+ COMMON_ERR_INTERNAL_NO_MEMORY = 551,
+ COMMON_ERR_INTERNAL_NOT_DEFINED = 552,
+ COMMON_ERR_INTERNAL_BINDER_ERROR = 553,
+ COMMON_ERR_INTERNAL_CONNECTION_ERROR = 554,
+ COMMON_ERR_GENERIC = 555,
+ COMMON_ERR_MO_NOT_FOUND_IN_DB = 556,
+ COMMON_ERR_GET_TYPE_NOT_FOUND = 557,
+ COMMON_ERR_DELETE = 558,
+ COMMON_ERR_NOT_FOUND = 559,
+ COMMON_ERR_IS_NULL = 560,
+ COMMON_ERR_IS_NOT_NULL = 561,
+ COMMON_ERR_NET_CANCEL = 562,
+ COMMON_ERR_IPC = 563,
+ COMMON_ERR_BUFFER_OVERFLOW = 564,
+ COMMON_ERR_ALLOC = 565,
+ COMMON_ERR_FW_CONFIG = 566,
+
+ /*ddf error */
+ DM_ERR_DDF_PROCCESS = 601,
+ DM_ERR_TNDS = 602,
+
+ /*fumo error */
+ DM_ERR_FUMO_CAN_NOT_PROCCESS = 701,
+ DM_ERR_FUMO_CAN_NOT_FOUND_SERVICE = 702,
+ DM_ERR_FUMO_INTERNAL_SCHEDULER_ERROR = 703,
+ DM_ERR_FUMO_SCHEDULER_ERROR = 704,
+
+ /* data download err */
+ DM_DD_SUCCESS = 900,
+ DM_ERR_INSUFFICIENT_MEMORY = 901,
+ DM_ERR_USER_CANDELLED = 902,
+ DM_ERR_LOSS_OF_SERVICE = 903,
+ DM_ERR_ATTR_MISMATCH = 905,
+ DM_ERR_INVALID_DESCRIPTOR = 906,
+ DM_ERR_INVALID_DDVERSION = 951,
+ DM_ERR_DEVICE_ABORTED = 952,
+ DM_ERR_NON_ACCEPTABLE_CONTENT = 953,
+ DM_ERR_REMINDER_INTERVAL = 954,
+ DM_ERR_LOADER_ERROR = 955,
+ DM_ERR_DOWNLOAD_INFO = 956,
+ DM_DOWNLOAD_POPUP = 957,
+ DM_INSTALL_POPUP = 958,
+ DM_RESUME_IDLE = 959,
+
+ /*bootstrap err */
+ DM_ERR_BOOTSTRAP = 1001,
+
+ /* database err */
+ DM_ERR_MORE_DATA = 1101,
+
+ /*ui inteval setting */
+ DM_DOWNLOAD_LATER_SETTING = 1201,
+ DM_DOWNLOAD_LATER_CANCEL = 1201,
+ DM_INSTALL_LATER_SETTING = 1202,
+ DM_INSTALL_LATER_CANCEL = 1203,
+
+ /*ETC */
+ DM_GET_BATTERY_ERROR = 1301,
+ DM_LOW_BATTERY_ERROR = 1302,
+ /*telephony */
+ DM_TELEPHONY_ERROR = 1311,
+ /*wifi */
+ DM_WIFI_ONLY_ERROR = 1321,
+ /*sd card */
+ DM_SD_CARD_ERROR = 1331,
+ DM_MEMORY_ERROR = 1332,
+ DM_OVER_MEMORY_ERROR = 1333,
+ /*roaming */
+ DM_ROAMING_ERROR = 1334,
+ /*account */
+ DM_ERR_FOTA_ACCOUNT_REGISTRATION = 1335,
+ DM_ERR_LAWMO_ACCOUNT_REGISTRATION = 1336,
+
+ /*cp */
+ DM_ERR_EVENT_DS = 1400,
+
+ /*ui launch */
+ DM_FOTA_UI_LAUNCH_ERROR = 1501,
+ DM_NOTI_UI_LAUNCH_ERROR = 1502,
+ DM_ALERT_UI_LAUNCH_ERROR = 1503,
+ DM_CP_UI_LAUNCH_ERROR = 1504,
+
+ /*task */
+ DM_ERR_ASYNC_TASK = 1601,
+ DM_ERR_SYNC_TASK = 1602
+} DM_ERROR;
+
+#endif /* OMA_DM_ERROR_H_ */
diff --git a/include/common/util/util.h b/include/common/util/util.h
new file mode 100755
index 0000000..ad341f5
--- /dev/null
+++ b/include/common/util/util.h
@@ -0,0 +1,347 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UTIL_H_
+#define UTIL_H_
+
+/*lib*/
+#include <stdio.h>
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+#include <stdbool.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+
+#define errno_abort(text) do {\
+ fprintf(stderr, "%s at \"%s\":%d: %s\n", text, __FILE__, __LINE__, strerror(errno));\
+ abort();\
+ } while(0)
+
+#define assert_condition(condition) do{\
+ if (!(condition)) {\
+ fprintf(stderr, "assert at \"%s\":%d: %s\n", __FILE__, __LINE__, strerror(errno));\
+ abort();\
+ }\
+ } while(0)
+
+/**
+ * @par Description: API to free string
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void str_free(char **str);
+
+/**
+ * @par Description: API to exchange char to int
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string
+ * @param[out] int
+ *
+ * @return 1 success
+ * 0 error
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int chartoint(char *data, int *value);
+
+/**
+ * @par Description: API to launch oma dm fumo ui
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return 1 success
+ * 0 error
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int launch_oma_dm_fumo_ui();
+
+/**
+ * @par Description: API to launch oma dm fumo noti ui
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] noti type ( user interaction, imformative, background )
+ * @param[in] session id
+ * @param[in] server id
+ *
+ * @return 1 success
+ * 0 error
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int launch_om_dm_fumo_noti_ui(int noti_data, char *session_id, char *server_id);
+
+/**
+ * @par Description: API to launch oma dm alert ui
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return 1 success
+ * 0 error
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int launch_om_dm_fumo_alert_ui();
+
+/**
+ * @par Description: API to launch oma dm cp ui
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] pin type
+ * @param[in] ext id
+ *
+ * @return 1 success
+ * 0 error
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int launch_oma_dm_cp_ui(int sec_type, int ext_id);
+
+/**
+ * @par Description: API to terminate oma dm ui
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] return result
+ * @param[in] service engine id
+ *
+ * @return
+ *
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void terminate_oma_dm_ui(int ret, ENGINE_ID service_engine_id);
+
+/**
+ * @par Description: API to terminate ui status
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] noty type
+ * @param[in] ui mode
+ * @param[in] return result
+ *
+ * @return
+ *
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void terminate_ui_status(int noti_type, char *ui_mode, int ret);
+
+/**
+ * @par Description: API to terminate ui status
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return 1 success
+ * 0 error
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int check_csc();
+
+/**
+ * @par Description: API to get wifi state
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return 1 success
+ *
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int get_wifi_state();
+
+/**
+ * @par Description: API to nonce decode
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] nextNonce
+ * @param[out] nextNonceDecode
+ * @param[out] out_len
+ *
+ * @return DM_OK success
+ *
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR nonce_decode(char *nextNonce, unsigned char **nextNonceDecode, unsigned int *out_len);
+
+/* hex2char*/
+/*bool hex2char(char const* szHex, unsigned char* rch);*/
+
+#endif /* UTIL_H_ */
diff --git a/include/dm-engine/bootstrap/factory_bootstrap.h b/include/dm-engine/bootstrap/factory_bootstrap.h
new file mode 100755
index 0000000..9d9b09d
--- /dev/null
+++ b/include/dm-engine/bootstrap/factory_bootstrap.h
@@ -0,0 +1,76 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @DM_Error.h
+ * @version 0.1
+ * @brief This file is the header file of defined factory bootstrap
+ */
+
+#ifndef FACTORY_BOOTSTRAP_H_
+#define FACTORY_BOOTSTRAP_H_
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_error.h"
+#include "common/dm_common_def.h"
+
+#define DDF_FILES "/usr/share/oma-dm-cfg/ddf/slp_ddfs.txt"
+#define DDF_MSCFUMO_DMACC_FILE "/usr/share/oma-dm-cfg/ddf/slp_msctestserver_dmacc_ddf.txt"
+#define DDF_MSCLAWMO_DMACC_FILE "/usr/share/oma-dm-cfg/ddf/slp_mscserver_dmacc_ddf.txt"
+#define DDF_GCF_DMACC_FILE "/usr/share/oma-dm-cfg/ddf/slp_gcf_dmacc_ddf.txt"
+
+#define DDF_SPEC_COUNT 10
+#define MAX_FILE_PATH 100
+#define MAX_SERVICE_NAME 50
+
+typedef struct {
+ sync_agent_dm_mo_type_e mo_type; /**< mo_type : SYNC_AGENT_DM_MO_TYPE_DMACC, SYNC_AGENT_DM_MO_TYPE_DEVINFO, SYNC_AGENT_DM_MO_TYPE_DEVDETAIL, SYNC_AGENT_DM_MO_TYPE_FUMO, SYNC_AGENT_DM_MO_TYPE_LAWMO, SYNC_AGENT_DM_MO_TYPE_SCOMO, SYNC_AGENT_DM_MO_TYPE_NO_TYPE */
+ char schema_file[MAX_FILE_PATH]; /**< schema_file : schema_file paht*/
+ int service_ddf; /**< service_ddf : 1,2,3,4,5,6,7*/
+ int server_type; /**< service_type : 4, 8, 16*/
+} ddf_spec;
+
+/**
+ * @par Description: API to start factory bootstrap
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] file size
+ *
+ * @return DM_OK on success
+ * DM_ERROR, DM_ERR_DDF_PROCCESS on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR factory_bootstrap(SERVICE_SERVER_TYPE server_type);
+
+#endif /* FACTORY_BOOTSTRAP_H_ */
diff --git a/include/dm-engine/cp/dm_cp_error.h b/include/dm-engine/cp/dm_cp_error.h
new file mode 100755
index 0000000..8ae3457
--- /dev/null
+++ b/include/dm-engine/cp/dm_cp_error.h
@@ -0,0 +1,27 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_CP_ERROR_H_
+#define DM_CP_ERROR_H_
+
+typedef enum {
+ CP_ERROR_SUCCESS = 1,
+ CP_ERROR_FAIL,
+ CP_NOT_EXIST_PIN
+} CP_ERROR;
+
+#endif /* DM_CP_ERROR_H_ */
diff --git a/include/dm-engine/cp/dm_cp_parser.h b/include/dm-engine/cp/dm_cp_parser.h
new file mode 100755
index 0000000..9947f4a
--- /dev/null
+++ b/include/dm-engine/cp/dm_cp_parser.h
@@ -0,0 +1,61 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_CP_PARSER_H_
+#define DM_CP_PARSER_H_
+
+/*dm-agent*/
+#include "dm_cp_struct.h"
+
+typedef enum {
+ CP_TYPE_XML = 1,
+ CP_TYPE_WBXML,
+ CP_TYPE_NONE
+} CP_TYPE;
+
+typedef enum {
+ TNDS_TAG_CHARACTERISTIC_START
+} CP_TAG;
+
+/**
+ * @par Description: API to parsing cp stream
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] cp type
+ * @param[in] wbxml
+ * @param[in] msg size
+ *
+ * @return DM_CP (cp structure)
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_CP *parsing_cp_stream(CP_TYPE cp_type, const char *wbxml_stream, unsigned int msgSize);
+
+#endif /* DM_CP_PARSER_H_ */
diff --git a/include/dm-engine/cp/dm_cp_processor.h b/include/dm-engine/cp/dm_cp_processor.h
new file mode 100755
index 0000000..4726d24
--- /dev/null
+++ b/include/dm-engine/cp/dm_cp_processor.h
@@ -0,0 +1,567 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_CP_PROCESSOR_H_
+#define DM_CP_PROCESSOR_H_
+
+/*dm-agent*/
+#include "dm_cp_error.h"
+#include "dm-engine/cp/dm_cp_struct.h"
+
+typedef enum {
+ ADD_MESSAGE,
+ REMOVE_MESSAGE,
+} SENDMSG_TYPE;
+
+/**
+ * @par Description: API to recieve cp wbxml
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] msg body
+ * @param[in] msg size
+ * @param[in] ext id
+ *
+ * @return CP_ERROR 1 on success
+ * 2 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+CP_ERROR process_Recieved_CP_WBXML(const char *msgBody, unsigned int msgSize, int ext_id);
+
+/**
+ * @par Description: API to recieve cp xml
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] msg body
+ * @param[in] msg size
+ * @param[in] ext id
+ *
+ * @return CP_ERROR 1 on success
+ * 2 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+CP_ERROR process_Recieved_CP_XML(const char *msgBody, unsigned int msgSize, int ext_id);
+
+/**
+ * @par Description: API to check pincode
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] initial or not (0,1)
+ * @param[in] user data
+ * @param[out] correct (0,1)
+ * @param[in] ext id
+ *
+ * @return CP_ERROR 1 on success
+ * 2 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+CP_ERROR process_Check_Pincode(int is_initial, char *user_data, int *is_correct, int ext_id);
+
+/**
+ * @par Description: API to invalid pincode
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] ext id
+ *
+ * @return CP_ERROR 1 on success
+ * 2 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+CP_ERROR process_Invalid_Pincode(int ext_id); /* invalid PIN code ==> send delete message to MF and delete CP data */
+
+/**
+ * @par Description: API to setting cp
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] ext id
+ *
+ * @return CP_ERROR 1 on success
+ * 2 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+CP_ERROR process_Setting_CP(int ext_id);
+
+/**
+ * @par Description: API to delete all cp
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ *
+ * @return CP_ERROR 1 on success
+ * 2 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+CP_ERROR process_Delete_All_CP_Data(); /* delete all CP data */
+
+/**
+ * @par Description: API to delete cp data
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] ext id
+ *
+ * @return CP_ERROR 1 on success
+ * 2 on error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+CP_ERROR process_Delete_CP_Data(int ext_id); /* delete 1 CP data about specific extId */
+
+/**
+ * @par Description: API to set msgid
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] msg id
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void process_Set_msgId(int msgId);
+
+/**
+ * @par Description: API to free application struct
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] app
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_cp_application(DM_CP_Application * app);
+/**
+ * @par Description: API to free application addr struct
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] app_addr appaddr
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_cp_application_app_addr(DM_CP_Application_AppAddr * app_addr);
+
+/**
+ * @par Description: API to free application resource struct
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] resource
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_cp_application_resource(DM_CP_Application_Resource * resource);
+
+/**
+ * @par Description: API to free application auth struct
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] appauth
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_cp_application_app_auth(DM_CP_Application_AppAuth * appAuth);
+
+/**
+ * @par Description: API to free port struct
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] port
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_cp_port(DM_CP_Port * port);
+
+/**
+ * @par Description: API to free string struct
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] service
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_string_node(String_Node * service);
+
+/**
+ * @par Description: API to free napdef struct
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] napdef
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_cp_napdef(DM_CP_Napdef * napdef);
+
+/**
+ * @par Description: API to free auth info struct
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] auth_info
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_cp_napdef_authinfo(DM_CP_Napdef_AuthInfo * auth_info);
+
+/**
+ * @par Description: API to free validity struct
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] validity
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_cp_napdef_validity(DM_CP_Napdef_validity * validity);
+
+/**
+ * @par Description: API to free bootstraps struct
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] bootstraps
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_cp_bootstrap(DM_CP_Bootstrap * bootstraps);
+
+/**
+ * @par Description: API to free pxLogical struct
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] pxLogical
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_cp_pxlogical(DM_CP_PxLogical * pxLogical);
+
+/**
+ * @par Description: API to free pxAuthInfo struct
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] pxAuthInfo
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_cp_pxlogical_pxauthinfo(DM_CP_PxLogical_PxAuthInfo * pxAuthInfo);
+
+/**
+ * @par Description: API to free pxPhysical struct
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] pxPhysical
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_cp_pxLogical_pxphsical(DM_CP_PxLogical_PxPhysical * pxPhysical);
+
+#endif /* DM_CP_PROCESSOR_H_ */
diff --git a/include/dm-engine/cp/dm_cp_security.h b/include/dm-engine/cp/dm_cp_security.h
new file mode 100755
index 0000000..c891d69
--- /dev/null
+++ b/include/dm-engine/cp/dm_cp_security.h
@@ -0,0 +1,40 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_CP_SECURITY_H_
+#define DM_CP_SECURITY_H_
+
+#define CP_MAC_LEN 40
+
+#define CP_IS_EXIST_MAC 0x92
+
+#define CP_SEC 0x91
+
+#define CP_SEC_TYPE_NETWPIN 0x80
+#define CP_SEC_TYPE_USERPIN 0x81
+#define CP_SEC_TYPE_USERNETWPIN 0x82
+
+#define CP_DATA_REPOSITORY_PATH "/opt/data/oma-dm-cfg/cp"
+#define CP_SEC_FILE_NAME "cp_pin_info"
+#define CP_WBXML_FILE_NAME "wbxml_cp"
+#define CP_TYPE_FILE_NAME "cp_type"
+
+#define CP_SEC_REPOSITORY_PATH "/opt/data/oma-dm-cfg/cp_pin_info"
+#define CP_WBXML_REPOSITORY_PATH "/opt/data/oma-dm-cfg/wbxml_cp"
+#define CP_TYPE_REPOSITORY_PATH "/opt/data/oma-dm-cfg/cp_type"
+
+#endif /* DM_CP_SECURITY_H_ */
diff --git a/include/dm-engine/cp/dm_cp_struct.h b/include/dm-engine/cp/dm_cp_struct.h
new file mode 100755
index 0000000..679a23b
--- /dev/null
+++ b/include/dm-engine/cp/dm_cp_struct.h
@@ -0,0 +1,201 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_CP_STRUCT_H_
+#define DM_CP_STRUCT_H_
+
+typedef enum {
+ DM_CP_APP_OMADS = 1
+} DM_CP_APP_ID;
+
+typedef struct string_node {
+ char *data;
+ struct string_node *next;
+} String_Node;
+
+typedef struct dm_cp_port {
+ char *portnbr;
+ String_Node *service; /* * */
+ struct dm_cp_port *next;
+} DM_CP_Port;
+
+/************************ PXLOGICAL *****************************/
+
+typedef struct dm_cp_pxlogical_pxauthinfo {
+ char *pxAuth_type;
+ char *pxAuth_id; /* ? */
+ char *pxAuth_pw; /* ? */
+ struct dm_cp_pxlogical_pxauthinfo *next;
+} DM_CP_PxLogical_PxAuthInfo;
+
+typedef struct dm_cp_pxlogical_pxphysical {
+ char *physical_proxy_id;
+ String_Node *domain; /* * */
+ char *pxAddr;
+ char *pxAddrType; /* ? */
+ char *pxAddr_FQDN; /* ? */
+ char *wsp_version; /* ? */
+ char *push_enabled; /* ? */
+ char *pull_enabled; /* ? */
+ String_Node *to_napid; /* + */
+ DM_CP_Port *port; /* * */
+ struct dm_cp_pxlogical_pxphysical *next;
+} DM_CP_PxLogical_PxPhysical;
+
+typedef struct dm_cp_pxlogical {
+ char *proxy_id;
+ char *proxy_pw; /* ? */
+ char *ppg_auth_type; /* ? */
+ char *proxy_provider_id; /* ? */
+ char *name;
+ String_Node *domain; /* * */
+ char *trust; /* ? */
+ char *master; /* ? */
+ char *start_page; /* ? */
+ char *bas_auth_id; /* ? */
+ char *bas_auth_pw; /* ? */
+ char *wsp_version; /* ? */
+ char *push_enabled; /* ? */
+ char *pull_enabled; /* ? */
+ DM_CP_PxLogical_PxAuthInfo *pxAuthInfo; /* * */
+ DM_CP_Port *port; /* * */
+ DM_CP_PxLogical_PxPhysical *pxPhysical; /* + */
+ struct dm_cp_pxlogical *next;
+} DM_CP_PxLogical;
+
+/************************ BOOTSTRAP *****************************/
+
+typedef struct dm_cp_bootstrap {
+ char *name;
+ String_Node *network;
+ char *country;
+ String_Node *proxy_id;
+ char *provurl;
+ char *context_allow;
+ struct dm_cp_bootstrap *next;
+} DM_CP_Bootstrap;
+
+/************************ APPLICATION *****************************/
+
+typedef struct dm_cp_application_appaddr {
+ char *addr;
+ char *addr_type; /* ? */
+ DM_CP_Port *port; /* * */
+ struct dm_cp_application_appaddr *next;
+} DM_CP_Application_AppAddr;
+
+typedef struct dm_cp_application_appauth {
+ char *auth_level; /* ? */
+ char *auth_type; /* ? */
+ char *auth_name; /* ? */
+ char *auth_secret; /* ? */
+ char *auth_data; /* ? */
+ struct dm_cp_application_appauth *next;
+} DM_CP_Application_AppAuth;
+
+typedef struct dm_cp_application_resource {
+ char *uri;
+ char *name; /* ? */
+ char *accept; /* ? */
+ char *auth_type; /* ? */
+ char *auth_name; /* ? */
+ char *auth_secret; /* ? */
+ char *auth_data; /* ? */
+ char *start_page; /* ? */
+ struct dm_cp_application_resource *next;
+} DM_CP_Application_Resource;
+
+typedef struct dm_cp_application {
+ char *app_ID;
+ char *provider_ID; /* ? */
+ char *name; /* ? */
+ char *accept; /* ? */
+ char *protocol; /* ? */
+ String_Node *to_proxy; /* * */
+ String_Node *to_napid; /* * */
+ String_Node *addr; /* * */
+ DM_CP_Application_AppAddr *appAddr; /* * */
+ DM_CP_Application_AppAuth *appAuth; /* * */
+ DM_CP_Application_Resource *resource; /* * */
+ struct dm_cp_application *next;
+} DM_CP_Application;
+
+/************************ NAPDEF *****************************/
+
+typedef struct dm_cp_napdef_napauthinfo {
+ char *auth_type;
+ char *auth_name; /* ? */
+ char *auth_secret; /* ? */
+ String_Node *auth_entity; /* * */
+ char *spi; /* ? */
+ struct dm_cp_napdef_napauthinfo *next;
+} DM_CP_Napdef_AuthInfo;
+
+typedef struct dm_cp_napdef_validity {
+ char *country; /* ? */
+ char *network; /* ? */
+ char *sid; /* ? */
+ char *soc; /* ? */
+ char *validuntil; /* ? */
+ struct dm_cp_napdef_validity *next;
+} DM_CP_Napdef_validity;
+
+typedef struct dm_cp_napdef {
+ char *nap_ID;
+ String_Node *bearer; /* * */
+ char *name;
+ char *internet; /* ? */
+ char *nap_address;
+ char *nap_addr_type; /* ? */
+ String_Node *dns_addr; /* * */
+ char *call_type; /* ? */
+ char *local_addr; /* ? */
+ char *local_addr_type; /* ? */
+ char *link_speed; /* ? */
+ char *dn_link_speed; /* ? */
+ char *linger; /* ? */
+ char *delivery_err_sdu; /* ? */
+ char *delivery_order; /* ? */
+ char *traffic_class; /* ? */
+ char *max_sdu_size; /* ? */
+ char *max_bitrate_uplink; /* ? */
+ char *max_bitrate_dnlink; /* ? */
+ char *residual_ber; /* ? */
+ char *sdu_error_ratio; /* ? */
+ char *traffic_handl_prio; /* ? */
+ char *transfer_delay; /* ? */
+ char *guaranteed_bitrate_uplink; /* ? */
+ char *guaranteed_bitrate_dnlink; /* ? */
+ char *max_num_retry; /* ? */
+ char *first_retry_timeout; /* ? */
+ char *rereg_threshold; /* ? */
+ char *t_bit; /* ? */
+ DM_CP_Napdef_AuthInfo *auth_info;
+ DM_CP_Napdef_validity *validity;
+ struct dm_cp_napdef *next;
+} DM_CP_Napdef;
+
+/************************ CP *****************************/
+
+typedef struct {
+ DM_CP_Bootstrap *bootstraps;
+ DM_CP_Napdef *napdefs;
+ DM_CP_Application *applications;
+ DM_CP_PxLogical *pxLogical;
+} DM_CP;
+
+#endif /* DM_CP_STRUCT_H_ */
diff --git a/include/dm-engine/dl-manager/dd_object.h b/include/dm-engine/dl-manager/dd_object.h
new file mode 100755
index 0000000..6564e77
--- /dev/null
+++ b/include/dm-engine/dl-manager/dd_object.h
@@ -0,0 +1,53 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DD_OBJECT_H_
+#define DD_OBJECT_H_
+
+//typedef enum {
+// OBJECT_NO_TYPE = 0,
+// APPLICATION_OCTECT_STREAM,
+// APPLICATION_MSWORD,
+// APPLICATION_PDF,
+// APPLICATION_ZIP,
+// TEXT_HTML,
+// TEXT_PLAIN,
+// TEXT_CSS,
+// IMAGE_GIF,
+// IMAGE_JPEG,
+// VIDEO_MPEG
+//
+//} OBJECT_TYPE;
+
+typedef struct {
+ int object_size; /* media object size */
+ char *object_type; /* media object type */
+ char *object_name;
+ char *object_description; /* media object description */
+ char *object_uri; /* URI from which the media object can be loaded */
+ char *next_uri;
+ char *install_notify_uri; /* URI to which a installation status report is to be sent */
+ char *info_uri;
+ char *icon_uri;
+ char *object_vender;
+ char *DD_version;
+ char *install_param;
+ char *medea_object;
+
+} Download_Descriptor;
+
+#endif /* DD_OBJECT_H_ */
diff --git a/include/dm-engine/dl-manager/dd_parser.h b/include/dm-engine/dl-manager/dd_parser.h
new file mode 100755
index 0000000..83afea4
--- /dev/null
+++ b/include/dm-engine/dl-manager/dd_parser.h
@@ -0,0 +1,53 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DD_PARSER_H_
+#define DD_PARSER_H_
+
+/*dm-agent*/
+#include "common/dm_error.h"
+#include "dm-engine/dl-manager/dd_object.h"
+
+/**
+ * @par Description: API to convert xml to dd object
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] dd xml
+ * @param[in] dd xml size
+ * @param[out] download descriptor structure
+ *
+ * @return DM_OK
+ * DM_ERROR
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR convert_xml_to_DD_object(const char *dd_xml, unsigned int dd_xml_length, Download_Descriptor ** dd_object);
+
+#endif /* DD_PARSER_H_ */
diff --git a/include/dm-engine/dl-manager/fw_downloader.h b/include/dm-engine/dl-manager/fw_downloader.h
new file mode 100755
index 0000000..f21f9d8
--- /dev/null
+++ b/include/dm-engine/dl-manager/fw_downloader.h
@@ -0,0 +1,175 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FW_DOWNLOADER_H_
+#define FW_DOWNLOADER_H_
+
+/*dm-agent*/
+#include "common/dm_error.h"
+#include "dm-engine/dl-manager/dd_object.h"
+
+typedef enum {
+ EXIST_PARTIAL_FILE = 1,
+ EXIST_COMPLETED_FILE,
+ NOT_EXIST_FILE
+} DOWNLOAD_FILE_STATUS;
+
+typedef struct {
+ int current_data_size;
+ int total_data_size;
+ char *file_path;
+} Data_Resume_Infomation;
+
+/**
+ * @par Description: API to get object information from dd_server_uri
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] dd_server_uri dd server uri
+ * @param[out] download_descriptor download_descriptor
+ * @param[out] dd_object_information dd object information
+ *
+ * @return DM_OK
+ * DM_ERROR
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_object_information(char *dd_server_uri, int *file_size, Download_Descriptor ** download_descriptor, DM_ERROR * download_status);
+
+/**
+ * @par Description: API to check file resume
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] checked_download_folder folder path
+ * @param[in] download_descriptor download_descriptor
+ * @param[out] file_status file status
+ *
+ * @return DM_OK
+ * DM_ERROR
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR check_file_resume(const char *checked_download_folder, DOWNLOAD_FILE_STATUS * file_status, Download_Descriptor * download_descriptor, Data_Resume_Infomation ** data_resume_info);
+
+/**
+ * @par Description: API to download object for object path
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] download_folder downloaded folder path
+ * @parma[in] config wifi config
+ * @param[in] download_descriptor download_descriptor
+ * @param[out] object_downloaded_path downloaded file path
+ *
+ *
+ * @return DM_OK
+ * DM_ERROR
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR download_object(const char *download_folder, char **object_downloaded_path, Data_Resume_Infomation * data_resume_info, int config, Download_Descriptor * download_descriptor, DM_ERROR * downoad_status);
+
+/**
+ * @par Description: API to send download status to server
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] download_status DM_ERROR
+ * @param[in] download_descriptor download_descriptor
+ *
+ * @return DM_OK
+ * DM_ERROR
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR send_donwload_status(DM_ERROR download_status, Download_Descriptor * download_descriptor);
+
+/**
+ * @par Description: API to free download descriptor
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] download_descriptor download_descriptor
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_Download_Descriptor(Download_Descriptor ** download_descriptor);
+
+#endif /* FW_DOWNLOADER_H_ */
diff --git a/include/dm-engine/dl-manager/na_fw_dl_binder.h b/include/dm-engine/dl-manager/na_fw_dl_binder.h
new file mode 100755
index 0000000..51c009b
--- /dev/null
+++ b/include/dm-engine/dl-manager/na_fw_dl_binder.h
@@ -0,0 +1,54 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NA_FW_DL_BINDER_H_
+#define NA_FW_DL_BINDER_H_
+
+/*lib*/
+#include <glib.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/**
+ * @par Description: API to add http header element
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[out] header element
+ * @param[in] header element key
+ * @param[in] header element value
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void add_header_info(GList ** header_info_list, char *key, char *value);
+
+#endif /* NA_FW_DL_BINDER_H_ */
diff --git a/include/dm-engine/dl-manager/sa_fw_downloader.h b/include/dm-engine/dl-manager/sa_fw_downloader.h
new file mode 100755
index 0000000..3940af1
--- /dev/null
+++ b/include/dm-engine/dl-manager/sa_fw_downloader.h
@@ -0,0 +1,177 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SA_FW_DOWNLOADER_H_
+#define SA_FW_DOWNLOADER_H_
+
+/*lib*/
+#include <glib.h>
+
+/*dm-agent*/
+#include "common/dm_error.h"
+
+typedef enum {
+ DD_DOWNLOAD = 1,
+ GET_FILE_NAME,
+ DATA_DOWNLOAD,
+ SEND_DOWNLOAD_STATUS
+} DL_SEND_MSG_TYPE;
+
+/**
+ * @par Description: API to send msg about DL
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] send_dl_type send msg type for dl
+ * @param[in] local_uri uri information
+ * @param[in] content_type content type
+ * @param[in] header_info header info g_list
+ * @param[in] sendMsg send msg
+ * @param[in] sendMsg_length send msg length
+ * @param[out] recv_header recv msg header info g_list
+ * @param[out] recvMsg recv msg
+ * @param[out] recvMsg_length recv msg length
+ *
+ * @return DM_OK
+ * DM_ERROR
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR send_download_msg(DL_SEND_MSG_TYPE send_dl_type, char *local_uri, char *content_type, GList * header_info, char *sendMsg, unsigned int sendMsg_length, GList ** recv_header, char **recvMsg, unsigned int *recvMsg_length);
+
+/**
+ * @par Description: API to download data to server
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] local_uri uri information
+ * @param[in] content_type content type
+ * @param[in] header_info header info g_list
+ * @param[in] current_file_download_size current file download size
+ * @param[in] download_folder download folder path
+ * @param[in] config wifi config
+ * @param[out] download_path download file path
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR download_data(char *local_uri, char *content_type, GList * header_info, int current_file_download_size, char *download_folder, int config, char **download_path);
+
+/**
+ * @par Description: API to get file name
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] recieve http header
+ * @param[out] file name
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+char *get_file_name(GList * recv_header, char *file_name);
+
+/**
+ * @par Description: API to get file name for header info
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] header_info header info g_list
+ *
+ * @return file name
+ * 0 error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+char *get_file_name_from_http_header(GList * header_info);
+
+/**
+ * @par Description: API to free header info g_list
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par par Method of function operation:
+ * @par Important notes:
+ * @param[in] header_info header info g_list
+ *
+ * @return file name
+ * 0 error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_header_info(GList * header_info);
+
+#endif /* SA_FW_DOWNLOADER_H_ */
diff --git a/include/dm-engine/dm_common_engine.h b/include/dm-engine/dm_common_engine.h
new file mode 100755
index 0000000..0a8f0a1
--- /dev/null
+++ b/include/dm-engine/dm_common_engine.h
@@ -0,0 +1,272 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_COMMON_ENGINE_H_
+#define DM_COMMON_ENGINE_H_
+
+/*dm-agent*/
+#include "common/dm_error.h"
+#include "common/dm_common_def.h"
+#include "common/dm_common.h"
+#include "framework/san-parser/pm_sanparser.h"
+#include "framework/platform-event-handler/dm_platform_event_handler_internal.h"
+#include "framework/platform-event-handler/dm_platform_event_handler.h"
+
+#define CHECK_OPERATION 1
+#define NON_CHECK_OPERATION 0
+
+/**
+ * @par Description: API to get service engine id
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[out] engine_id engine id
+ * @param[in] ui mode ui mode
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void get_service_engine_id(ENGINE_ID * service_engine_id, char *ui_mode);
+
+/**
+ * @par Description: API to init dm engine
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[out] engine_id engine id
+ * @param[in] ui mode ui mode
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void init_Dm_Engine();
+
+/**
+ * @par Description: API to engine Start
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] server id server id
+ * @param[in] full_path full path
+ * @param[in] correlator correlator
+ * @param[in] resultCode resultCode
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR engine_start(char *server_id, char *full_path, char *correlator, ENGINE_ID * service_engine_id, int *resultCode);
+
+/**
+ * @par Description: API to service_engine_Start
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] service engine id service engine id
+ * @param[out] service_ret service_ret
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR service_engine_start(ENGINE_ID service_engine_id, DM_ERROR * service_ret);
+
+/**
+ * @par Description: API to set_engine_status_idle
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] service engine id service engine id
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR set_engine_status_idle(ENGINE_ID service_engine_id);
+
+/**
+ * @par Description: API to set_end_engine_status_idle
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] service engine id service engine id
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR set_end_engine_status_idle();
+
+/**
+ * @par Description: API to dm_common_start
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Event_Contents Event_Contents
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_common_start(Event_Contents * pEvent_data);
+
+/**
+ * @par Description: API to dm common operation (called by task)
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Event_Contents Event_Contents
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_common_operation(Event_Contents * pEvent_data);
+
+/**
+ * @par Description: API to genericAelrt_operation
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session session
+ * @param[in] isFinish isFinish
+ * @param[in] service engine id service engine id
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR genericalert_operation(void **session, int *isFinish, ENGINE_ID service_engine_id);
+
+#endif /* DM_COMMON_ENGINE_H_ */
diff --git a/include/dm-engine/fumo/fumo_account.h b/include/dm-engine/fumo/fumo_account.h
new file mode 100755
index 0000000..17ccf9c
--- /dev/null
+++ b/include/dm-engine/fumo/fumo_account.h
@@ -0,0 +1,57 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @DM_Error.h
+ * @version 0.1
+ * @brief This file is the header file of defined fota account
+ */
+
+#ifndef FOTA_ACCOUNT_H_
+#define FOTA_ACCOUNT_H_
+
+/*dm-agent*/
+#include "common/dm_error.h"
+
+/**
+ * @par Description: API to register fota account
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in]
+ * @param[out]
+ *
+ * @return 1 success
+ * 0 error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int register_fota_account();
+
+#endif /* FOTA_ACCOUNT_H_ */
diff --git a/include/dm-engine/fumo/fumo_engine.h b/include/dm-engine/fumo/fumo_engine.h
new file mode 100755
index 0000000..147d5d9
--- /dev/null
+++ b/include/dm-engine/fumo/fumo_engine.h
@@ -0,0 +1,244 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FUMO_ENGINE_H_
+#define FUMO_ENGINE_H_
+
+/*dm-agent*/
+#include "common/dm_error.h"
+#include "dm-engine/fumo/fumo_engine_internal.h"
+
+/**
+ * @par Description: API to execute fumo operation
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] full_path mo full path
+ * @param[in] value value
+ * @param[out] fumo_return fumo return value
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR fumo_exec(char *full_path, char *value, FUMO_Error * fumo_return);
+
+/**
+ * @par Description: API to operate firmware download
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] full_path mo full path
+ * @param[out] fumo_return fumo return value
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR firmware_download_opeartion(char *full_path, FUMO_Error * fumo_return);
+
+/**
+ * @par Description: API to operate firmware update
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] full_path mo full path
+ * @param[out] fumo_return fumo return value
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR firmware_update_operation(char *full_path, FUMO_Error * fumo_return);
+
+/**
+ * @par Description: API to operate firmware download&update
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] full_path mo full path
+ * @param[out] fumo_return fumo return value
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR firmware_downloadupdate_operation(char *full_path, FUMO_Error * fumo_return);
+
+/**
+ * @par Description: API to operate firmware EXT
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] full_path mo full path
+ * @param[out] fumo_return fumo return value
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR vendor_dependency_firmware_operation(char *full_path, FUMO_Error * fumo_return);
+
+/**
+ * @par Description: API to fumo engine operation (engine state flow)
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] full_path mo full path
+ * @param[in] down_server down server url
+ * @param[in] fumo_state fumo state
+ * @param[out] fumo_return fumo return value
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR fumo_engine_state_operation(char *full_path, char *down_server, FUMO_Error * fumo_return);
+
+/**
+ * @par Description: API to get current fumo state
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] full_path mo full path
+ * @param[out] fumo_state_data fumo state data
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_current_fumo_state(char *full_path, char **fumo_state_data);
+
+/**
+ * @par Description: API to set current fumo state
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] full_path mo full path
+ * @param[in] fumo_state_data fumo state data
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR set_current_fumo_state(char *full_path, FUMO_State fumo_status);
+
+#endif /* FUMO_ENGINE_H_ */
diff --git a/include/dm-engine/fumo/fumo_engine_internal.h b/include/dm-engine/fumo/fumo_engine_internal.h
new file mode 100755
index 0000000..41aaffd
--- /dev/null
+++ b/include/dm-engine/fumo/fumo_engine_internal.h
@@ -0,0 +1,91 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FUMO_ENGINE_INTERNAL_H_
+#define FUMO_ENGINE_INTERNAL_H_
+
+ /*
+ * 1. DevInfo
+ * - DevID : device id
+ * - Man : manufacture
+ * - Mod : model id or model number
+ * - DmV : OMA DM client version
+ * - Lang : current setting language
+ * - Bearer : bearer
+ *
+ * 2. DevDetail
+ * - KernelV : kernel version
+ * - SwV : software version
+ * - HwV : hardware version
+ * - FwV : firmware version
+ * - ModemV : modem version
+ * - PDAV : PDA version
+ * - OEM : original equipment manufacturer
+ * - DevType : device type
+ * - Bearer : bearer
+ * - FOTADownDir: firmware download directory
+ * - FOTASaveDir: firmware save directory
+ */
+/*
+sync_agent_dev_return_e sync_agent_get_devinfo(const char *platform, char *info_name, char **value);
+
+sync_agent_dev_return_e sync_agent_execute_dev_function(2, "fota_flag", 1, memory_type);
+sync_agent_dev_return_e sync_agent_execute_dev_function(2, "fota_result", 1, (int *)error);
+*/
+
+#define MAX_DELTA_FILE_SIZE "/usr/share/oma-dm-cfg/delta_size/max_size.txt"
+
+typedef enum {
+ UNKNOWN = 0,
+ IDLE_START = 10, /*No pending operation */
+ DOWNLOAD_FAILED = 20, /*Download failed */
+ DOWNLOAD_PROGRESSING = 30, /*Download has stared */
+ DOWNLOAD_COMPLETE = 40, /*Download has been completed successfully */
+ READY_TO_UPDATE = 50, /*Have data and awaiting command to start update */
+ UPDATE_PROGRESSING = 60, /*Update has stared */
+ UPDATE_FAILED_HAVE_DATA = 70, /*Update failed but have update package */
+ UPDATE_FAILED_NO_DATA = 80, /*Update failed and no update package available */
+ UPDATE_SUCCESSFUL_HAVE_DATA = 90, /*Update complete and data still available */
+ UPDATE_SUCCESSFUL_NO_DATA = 100 /*Data deleted or removed after a successful Update */
+} FUMO_State;
+
+typedef enum {
+ FUMO_SUCCESS = 200,
+ /* 250~299 VENDOR */
+ FUMO_MANAGEMENT_CLIENT_ERROR = 400,
+ FUMO_USER_CANCELLED = 401,
+ FUMO_CORRUPTED_FIRMWARE_UPDATE = 402,
+ DEVICE_MISMATCH = 403,
+ FUMO_FAILED_VALIDATION = 404,
+ FUMO_NOT_ACCEPTABLE = 405,
+ FUMO_ALTERNATED_DOWNLOAD_AUTHENTICATION_FAILED = 406,
+ FUMO_ALTERANTED_DOWNLOAD_REQUEST_TIME_OUT = 407,
+ FUMO_NOT_IMPLEMENTED = 408,
+ FUMO_UNDEFINED_ERROR = 409,
+ FUMO_UPDATE_FAILED = 410,
+ FUMO_MALFORMED_OR_BAD_URL = 411,
+ FUMO_ALTERNATED_DOWNLOAD_SERVER_UNABAILABLE = 412,
+ /* 450~499 VENDOR */
+ FUMO_ALTERNATE_DOWNLOAD_SERVER_ERROR = 500,
+ FUMO_DOWNLOAD_FAILS_DUE_TO_DEVICE_OUT_OF_MEMORY = 501,
+ FUMO_UPDATE_FAILS_DUE_TO_DEVICE_OUT_OF_MEMORY = 502,
+ FUMO_DOWNLOAD_FAILS_DUE_TO_NETWORK_ISSUES = 503,
+ /*550~599 */
+
+} FUMO_Error;
+
+#endif /* FUMO_ENGINE_INTERNAL_H_ */
diff --git a/include/dm-engine/lawmo/lawmo_account.h b/include/dm-engine/lawmo/lawmo_account.h
new file mode 100755
index 0000000..19eadf6
--- /dev/null
+++ b/include/dm-engine/lawmo/lawmo_account.h
@@ -0,0 +1,83 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @DM_Error.h
+ * @version 0.1
+ * @brief This file is the header file of defined lawmo account
+ */
+#ifndef LAWMO_ACCOUNT_H_
+#define LAWMO_ACCOUNT_H_
+
+/*dm-agent*/
+#include "common/dm_error.h"
+
+/**
+ * @par Description: API to register lawmo account
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] item id
+ * @param[in] user data
+ *
+ * @return 1 success
+ * 0 error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int register_lawmo_account(int item_id, void *user_data);
+
+/**
+ * @par Description: API to deregister lawmo account
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] item id
+ * @param[in] user data
+ *
+ * @return 1 success
+ * 0 error
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int deregister_lawmo_account(int item_id, void *user_data);
+
+#endif /* LAWMO_ACCOUNT_H_ */
diff --git a/include/dm-engine/lawmo/lawmo_engine.h b/include/dm-engine/lawmo/lawmo_engine.h
new file mode 100755
index 0000000..b411985
--- /dev/null
+++ b/include/dm-engine/lawmo/lawmo_engine.h
@@ -0,0 +1,107 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LAWMO_ENGINE_H_
+#define LAWMO_ENGINE_H_
+
+/*dm-agent*/
+#include "common/dm_error.h"
+#include "dm-engine/lawmo/lawmo_engine_internal.h"
+
+/**
+ * @par Description: API to execute lawmo operation
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] full_path mo full path
+ * @param[in] value value
+ * @param[in] check operation check operation
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR lawmo_exec(char *full_path, char *correlator, LAWMO_Result_code * lawmo_return, int check_operation);
+
+/**
+ * @par Description: API to execute lawmo operation
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] full_path mo full path
+ * @param[out] lawmo state data lawmo state data
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_current_lawmo_state(char *full_path, char **lawmo_state_data);
+
+/**
+ * @par Description: API to execute lawmo operation
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] full_path mo full path
+ * @param[in] lawmo state lawmo state
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR set_current_lawmo_state(char *full_path, LAWMO_State lawmo_state);
+
+#endif /* LAWMO_ENGINE_H_ */
diff --git a/include/dm-engine/lawmo/lawmo_engine_internal.h b/include/dm-engine/lawmo/lawmo_engine_internal.h
new file mode 100755
index 0000000..bd52aeb
--- /dev/null
+++ b/include/dm-engine/lawmo/lawmo_engine_internal.h
@@ -0,0 +1,45 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LAWMO_ENGINE_INTERNAL_H_
+#define LAWMO_ENGINE_INTERNAL_H_
+
+typedef enum {
+
+ FULLY_LOCKED, //the device is in Fully Locked state.
+ PARTIALLY_LOCKED, //The device is in Partially Locked state.
+ UNLOCKED //The device is in Unlocked state.
+} LAWMO_State;
+
+typedef enum {
+ OPERATION_SUCCEEDED = 1200,
+ WIPE_OPEARTION_SUCCEEDED_WITH_DATA_WIPED = 1201,
+ WIPE_OPERATION_SUCCEEDED_WITH_BOTH_DATA_AND_ASSOCIATED_WIPE_LIST_WITHIN_MANAGEMENT_TREE_WIPED = 1202,
+
+ /*SUCCESSFUL = VENDOR SPECIFIED */
+
+ CLIENT_ERROR = 1400,
+ USER_CANCELLED = 1401,
+ FULLY_LOCK_DEVICE_FAILED = 1402,
+ PARTIALLY_LOCK_DEVICE_FAILED = 1403,
+ UNLOCK_DEVICE_FAILED = 1404,
+ WIPE_DEVICES_DATA_FAILED = 1405,
+ WIPE_OPERATION_NOT_PERFORMED = 1406
+ /*CLIENT ERROR = VENDOR SPECIFIED */
+} LAWMO_Result_code;
+
+#endif /* LAWMO_ENGINE_INTERNAL_H_ */
diff --git a/include/framework/platform-event-handler/dm_platform_event_handler.h b/include/framework/platform-event-handler/dm_platform_event_handler.h
new file mode 100755
index 0000000..33d31f2
--- /dev/null
+++ b/include/framework/platform-event-handler/dm_platform_event_handler.h
@@ -0,0 +1,286 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_PLATFORM_EVENT_HANDLER_H_
+#define DM_PLATFORM_EVENT_HANDLER_H_
+
+/*dm-agent*/
+#include "framework/platform-event-handler/dm_platform_event_handler_internal.h"
+
+/**
+ * @par Description: API to dm wap push incomming callback
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] item id
+ * @param[in] user data
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int dm_wap_push_incomming_callback(int item_id, void *user_data);
+
+/**
+ * @par Description: API to dm wap push operation callback
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] item id
+ * @param[in] user data
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int dm_wap_push_operation_callback(int item_id, void *user_data);
+
+/**
+ * @par Description: API to dm ip push callback
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] item id
+ * @param[in] user data
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int dm_ip_push_callback(int item_id, void *user_data);
+
+/**
+ * @par Description: API to telephony incomming callback
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] item id
+ * @param[in] user data
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int dm_telephony_incomming_callback(int item_id, void *user_data);
+
+/**
+ * @par Description: API to telephony end callback
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] item id
+ * @param[in] user data
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int dm_telephony_end_callback(int item_id, void *user_data);
+
+/**
+ * @par Description: API to network on callback
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int network_on_callback();
+
+/**
+ * @par Description: API to network off callback
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return 1 success
+ * 0 fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int network_off_callback();
+
+/**
+ * @par Description: API to network change callback
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return 1 success
+ * 0 fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int network_change_callback();
+
+/**
+ * @par Description: API to alarm_callback
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return 1 success
+ * 0 fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int alarm_callback(int item_id, void *user_data);
+
+/**
+ * @par Description: API to event_data_free
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @param[in] event data
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void event_data_free(void *pEvent_data);
+
+#endif /* DM_PLATFORM_EVENT_HANDLER_H_ */
diff --git a/include/framework/platform-event-handler/dm_platform_event_handler_internal.h b/include/framework/platform-event-handler/dm_platform_event_handler_internal.h
new file mode 100755
index 0000000..d0e79ff
--- /dev/null
+++ b/include/framework/platform-event-handler/dm_platform_event_handler_internal.h
@@ -0,0 +1,43 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_PLATFORM_EVENT_HANDLER_INTERNAL_H_
+#define DM_PLATFORM_EVENT_HANDLER_INTERNAL_H_
+
+typedef enum {
+ IP_PUSH_EVENT = 0,
+ WAP_PUSH_EVENT,
+ UI_EVENT,
+ SERVER_BOOTSTRAP_EVENT
+} Event_Type;
+
+typedef enum {
+ NOTI_TYPE_NOT_SPECIFIED = 0,
+ NOTI_TYPE_BACKGRUOUND,
+ NOTI_TYPE_INFOMATIVE,
+ NOTI_TYPE_USERINTERACTION
+} NotI_Type;
+
+typedef struct {
+ Event_Type type;
+ char *session_id;
+ char *server_id;
+ NotI_Type noti_type;
+ char *ui_mode;
+} Event_Contents;
+
+#endif /* DM_PLATFORM_EVENT_HANDLER_INTERNAL_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..c293bf6
--- /dev/null
+++ b/include/framework/san-parser/pm_sanparser.h
@@ -0,0 +1,165 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_
+
+typedef enum {
+ SAN_UIMODE_UNSPECIFIED = 0,
+ SAN_UIMODE_BACKGROUND = 1,
+ SAN_UIMODE_INFORMATIVE = 2,
+ SAN_UIMODE_USER = 3
+} SanUIMode;
+
+typedef enum {
+ SAN_INITIATOR_USER = 0,
+ SAN_INITIATOR_SERVER = 1
+} SanInitiator;
+
+typedef struct SanCred SanCred;
+struct SanCred {
+ char *credFormat;
+ char *credAuth;
+ char *credData;
+};
+
+typedef struct SanPackage SanPackage;
+struct SanPackage {
+ char *msgBodyWithoutDigest;
+ unsigned int msgBodyWithoutDigestLength;
+ char *digest;
+ unsigned int version;
+ SanUIMode uiMode;
+ SanInitiator initiator;
+ unsigned char *sessionID;
+ SanCred *cred;
+ char *serverID;
+};
+
+/**
+ * @par Description: API to sanpackage_noti_parser
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] msgBody msgBody
+ * @param[in] msgSize msgSize
+ *
+ * @return SanPackage structure
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+SanPackage *sanpackage_noti_parser(const char *msgBody, unsigned int msgSize);
+
+/**
+ * @par Description: API to sanpackage_xml_parser
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] msgBody msgBody
+ * @param[in] msgSize msgSize
+ *
+ * @return SanPackage structure
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+SanPackage *sanpackage_xml_parser(const char *msgBody, unsigned int msgSize);
+
+/**
+ * @par Description: API to free_sanpackageparser
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] SanPackage
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_sanpackageparser(SanPackage * san);
+
+/**
+ * @par Description: API to san_printmsg
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] SanPackage
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void san_printmsg(SanPackage * san);
+
+#endif /* PM_SANPARSER_H_ */
diff --git a/include/framework/task/oma_dm_task_register.h b/include/framework/task/oma_dm_task_register.h
new file mode 100755
index 0000000..f12bf38
--- /dev/null
+++ b/include/framework/task/oma_dm_task_register.h
@@ -0,0 +1,49 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMA_DM_TASK_REGISTER_H_
+#define OMA_DM_TASK_REGISTER_H_
+
+/*dm-agent*/
+#include "common/dm_error.h"
+
+/**
+ * @par Description: API to dm task register
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR task_register();
+
+#endif /* OMA_DM_TASK_REGISTER_H_ */
diff --git a/include/framework/task/oma_dm_task_request.h b/include/framework/task/oma_dm_task_request.h
new file mode 100755
index 0000000..09a32d6
--- /dev/null
+++ b/include/framework/task/oma_dm_task_request.h
@@ -0,0 +1,308 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMA_DM_TASK_ENABLE_H_
+#define OMA_DM_TASK_ENABLE_H_
+
+/*dm-agent*/
+#include "common/dm_error.h"
+#include "common/dm_common.h"
+#include "framework/platform-event-handler/dm_platform_event_handler.h"
+#include "dm-engine/fumo/fumo_engine.h"
+#include "dm-engine/lawmo/lawmo_engine.h"
+
+/**
+ * @par Description: API to init dm task request
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_init_task_request();
+
+/**
+ * @par Description: API to reset dm task request
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_reset_task_request();
+
+/**
+ * @par Description: API to bootstrap task request
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR bootstrap_task_request();
+
+/**
+ * @par Description: API to dm common task request
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] event_data Event_data
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_fumo_common_task_request(Event_Contents * pEvent_data);
+
+/**
+ * @par Description: API to dm common task request
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] event_data Event_data
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_fumo_ui_task_request(Event_Contents * pEvent_data);
+
+/**
+ * @par Description: API to dm common task request
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] event_data Event_data
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR dm_lawmo_common_task_request(Event_Contents * pEvent_data);
+
+/**
+ * @par Description: API to gemericalert task request
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR genericAlert_task_request();
+
+/**
+ * @par Description: API to fumo serviceengine task request
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR fumo_serviceEngine_task_request();
+
+/**
+ * @par Description: API to lawmo serviceengine task request
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR lawmo_serviceEngine_task_request();
+
+/**
+ * @par Description: API to service engine task request
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Reminder_Interval Reminder Interval
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR fumo_schedule_task_request(Reminder_Interval remider_interval_type);
+
+/**
+ * @par Description: API to cancel task
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] task id
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void cancel_task(int task_id);
+
+#endif /* OMA_DM_TASK_ENABLE_H_ */
diff --git a/include/framework/task/oma_dm_task_spec.h b/include/framework/task/oma_dm_task_spec.h
new file mode 100755
index 0000000..cd4562b
--- /dev/null
+++ b/include/framework/task/oma_dm_task_spec.h
@@ -0,0 +1,580 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMA_DM_TASK_SPEC_H_
+#define OMA_DM_TASK_SPEC_H_
+
+/*lib*/
+#include <stdio.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+#define EC_MSG_TYPE_DM_INIT_CONTAINER_TASK_REQUEST 0
+#define EC_MSG_TYPE_NAME_DM_INIT_CONTAINER_TASK_REQUEST "dm_init_contatiner"
+
+#define EC_MSG_TYPE_DM_INIT_TASK_REQUEST 1
+#define EC_MSG_TYPE_NAME_DM_INIT_TASK_REQUEST "dm_init"
+
+#define EC_MSG_TYPE_DM_RESET_TASK_REQUEST 2
+#define EC_MSG_TYPE_NAME_DM_RESET_TASK_REQUEST "dm_reset"
+
+#define EC_MSG_TYPE_BOOTSTRAP_TASK_REQUEST 3
+#define EC_MSG_TYPE_NAME_BOOTSTRAP_TASK_REQUEST "dm_bootstrap"
+
+#define EC_MSG_TYPE_DM_FUMO_COMMON_TASK_REQUEST 4
+#define EC_MSG_TYPE_NAME_DM_FUMO_COMMON_TASK_REQUEST "dm_ fumo_common"
+
+#define EC_MSG_TYPE_DM_FUMO_UI_TASK_REQUEST 5
+#define EC_MSG_TYPE_NAME_DM_FUMO_UI_TASK_REQUEST "dm_ fumo_ui"
+
+#define EC_MSG_TYPE_DM_LAWMO_COMMON_TASK_REQUEST 6
+#define EC_MSG_TYPE_NAME_DM_LAWMO_COMMON_TASK_REQUEST "dm_lawmo_common"
+
+#define EC_MSG_TYPE_GENERICALERT_TASK_REQUEST 7
+#define EC_MSG_TYPE_NAME_GENERICALERT_TASK_REQUEST "dm_genericalert"
+
+#define EC_MSG_TYPE_FUMO_SERVICE_ENGINE_TASK_REQUEST 8
+#define EC_MSG_TYPE_NAME_FUMO_SERVICE_ENGINE_TASK_REQUEST "dm_fumo_service_engine"
+
+#define EC_MSG_TYPE_LAWMO_SERVICE_ENGINE_TASK_REQUEST 9
+#define EC_MSG_TYPE_NAME_LAWMO_SERVICE_ENGINE_TASK_REQUEST "dm_lawmo_service_engine"
+
+#define EC_MSG_TYPE_FUMO_SCHEDULE_TASK_REQUEST 10
+#define EC_MSG_TYPE_NAME_FUMO_SCHEDULE_TASK_REQUEST "dm_fumo_schedule"
+
+/**
+ * @par Description: API to make_dm_init_task_spec
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return sync_agent_ec_task_spec_s
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_dm_init_task_spec();
+
+/**
+ * @par Description: API to start_dm_init_process
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] param count count
+ * @param[out] sync_agent_ec_param_param_s param array
+ *
+ * @return sync_agent_ec_task_error_e
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+//sync_agent_ec_task_error_e start_dm_init_process(unsigned int param_cnt, sync_agent_ec_param_param_s** param_array);
+
+/**
+ * @par Description: API to make_dm_reset_task_spec
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return sync_agent_ec_task_spec_s
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_dm_reset_task_spec();
+
+/**
+ * @par Description: API to start_dm_reset_process
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] param count count
+ * @param[out] sync_agent_ec_param_param_s param array
+ *
+ * @return sync_agent_ec_task_error_e
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+//sync_agent_ec_task_error_e start_dm_reset_process( unsigned int param_cnt, sync_agent_ec_param_param_s** param_array);
+
+/**
+ * @par Description: API to make_bootstrap_task_spec
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return sync_agent_ec_task_spec_s
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_bootstrap_task_spec();
+
+/**
+ * @par Description: API to start_bootstrap_process
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] param count count
+ * @param[out] sync_agent_ec_param_param_s param array
+ *
+ * @return sync_agent_ec_task_error_e
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+//sync_agent_ec_task_error_e start_bootstrap_process( unsigned int param_cnt, sync_agent_ec_param_param_s** param_array);
+
+/**
+ * @par Description: API to make_dm_fumo_common_process_task_spec
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return sync_agent_ec_task_spec_s
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_dm_fumo_common_process_task_spec();
+
+/**
+ * @par Description: API to start_dm_fumo_common_process
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] param count count
+ * @param[out] sync_agent_ec_param_param_s param array
+ *
+ * @return sync_agent_ec_task_error_e
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+//sync_agent_ec_task_error_e start_dm_fumo_common_process( unsigned int param_cnt, sync_agent_ec_param_param_s** param_array);
+
+/**
+ * @par Description: API to make_dm_fumo_ui_process_task_spec
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return sync_agent_ec_task_spec_s
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_dm_fumo_ui_process_task_spec();
+
+/**
+ * @par Description: API to start_dm_fumo_ui_process
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] param count count
+ * @param[out] sync_agent_ec_param_param_s param array
+ *
+ * @return sync_agent_ec_task_error_e
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+//sync_agent_ec_task_error_e start_dm_fumo_ui_process(unsigned int param_cnt, sync_agent_ec_param_param_s** param_array);
+
+/**
+ * @par Description: API to make_dm_lawmo_common_process_task_spec
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return sync_agent_ec_task_spec_s
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_dm_lawmo_common_process_task_spec();
+
+/**
+ * @par Description: API to start_dm_lawmo_common_process
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] param count count
+ * @param[out] sync_agent_ec_param_param_s param array
+ *
+ * @return sync_agent_ec_task_error_e
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+//sync_agent_ec_task_error_e start_dm_lawmo_common_process( unsigned int param_cnt, sync_agent_ec_param_param_s** param_array);
+
+/**
+ * @par Description: API to make_genericAlert_process_task_spec
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return sync_agent_ec_task_spec_s
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_genericAlert_process_task_spec();
+
+/**
+ * @par Description: API to start_genericAlert_process
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] param count count
+ * @param[out] sync_agent_ec_param_param_s param array
+ *
+ * @return sync_agent_ec_task_error_e
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+//sync_agent_ec_task_error_e start_genericAlert_process( unsigned int param_cnt, sync_agent_ec_param_param_s** param_array);
+
+/**
+ * @par Description: API to make_fumo_serviceEngine_process_task_spec
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return sync_agent_ec_task_spec_s
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_fumo_serviceEngine_process_task_spec();
+
+/**
+ * @par Description: API to start_fumo_serviceEngine_process
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] param count count
+ * @param[out] sync_agent_ec_param_param_s param array
+ *
+ * @return sync_agent_ec_task_error_e
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+//sync_agent_ec_task_error_e start_fumo_serviceEngine_process( unsigned int param_cnt, sync_agent_ec_param_param_s** param_array);
+
+/**
+ * @par Description: API to make_lawmo_serviceEngine_process_task_spec
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return sync_agent_ec_task_spec_s
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_lawmo_serviceEngine_process_task_spec();
+
+/**
+ * @par Description: API to start_lawmo_serviceEngine_process
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] param count count
+ * @param[out] sync_agent_ec_param_param_s param array
+ *
+ * @return sync_agent_ec_task_error_e
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+//sync_agent_ec_task_error_e start_lawmo_serviceEngine_process( unsigned int param_cnt, sync_agent_ec_param_param_s** param_array);
+
+/**
+ * @par Description: API to make_fumo_schedule_process_task_spec
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return sync_agent_ec_task_spec_s
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+sync_agent_ec_task_spec_s *make_fumo_schedule_process_task_spec();
+
+/**
+ * @par Description: API to start_fumo_schedule_process
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] param count count
+ * @param[out] sync_agent_ec_param_param_s param array
+ *
+ * @return sync_agent_ec_task_error_e
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+//sync_agent_ec_task_error_e start_fumo_schedule_process(unsigned int param_cnt, sync_agent_ec_param_param_s** param_array);
+
+#endif /* DM_TASK_SPEC_H_ */
diff --git a/include/framework/ui-event-handler/ipc_agent.h b/include/framework/ui-event-handler/ipc_agent.h
new file mode 100755
index 0000000..5f155b2
--- /dev/null
+++ b/include/framework/ui-event-handler/ipc_agent.h
@@ -0,0 +1,426 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IPC_AGENT_H_
+#define IPC_AGENT_H_
+
+/*dm-agent*/
+#include "user-interaction/user_interaction.h"
+
+/**
+ * @par Description: API to set ipc
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return SYNC_AGENT_EVENT_SUCCESS success
+ SYNC_AGENT_EVENT_FAIL fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int set_IPC();
+
+/**
+ * @par Description: API to noti start
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] ui mode
+ *
+ * @return RESPONSE_TYPE_OK success
+ RESPONSE_TYPE_NONE , RESPONSE_TYPE_CANCEL, RESPONSE_TYPE_TIMEOVER fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int noti_start(char *ui_mode);
+
+/**
+ * @par Description: API to noti connect to server
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return RESPONSE_TYPE_OK success
+ RESPONSE_TYPE_NONE , RESPONSE_TYPE_CANCEL, RESPONSE_TYPE_TIMEOVER fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int noti_download();
+
+/**
+ * @par Description: API to noti install
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return RESPONSE_TYPE_OK success
+ RESPONSE_TYPE_NONE , RESPONSE_TYPE_CANCEL, RESPONSE_TYPE_TIMEOVER fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int noti_install();
+
+/**
+ * @par Description: API to noti send download info
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] filesize
+ * @param[in] file path
+ *
+ * @return RESPONSE_TYPE_OK success
+ RESPONSE_TYPE_NONE , RESPONSE_TYPE_CANCEL, RESPONSE_TYPE_TIMEOVER fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int noti_send_download_info(int filesize, char *path);
+
+/**
+ * @par Description: API to noti low batter
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] battery level
+ *
+ * @return RESPONSE_TYPE_OK success
+ RESPONSE_TYPE_NONE , RESPONSE_TYPE_CANCEL, RESPONSE_TYPE_TIMEOVER fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int noti_low_battery(char *battery_level);
+
+/**
+ * @par Description: API to alert uic display
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] uic_data
+ *
+ * @return RESPONSE_TYPE_OK success
+ RESPONSE_TYPE_NONE , RESPONSE_TYPE_CANCEL, RESPONSE_TYPE_TIMEOVER fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int alert_uic_display(uic_data * uic_value);
+
+/**
+ * @par Description: API to alert uic confirm
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] uic_data
+ *
+ * @return RESPONSE_TYPE_OK success
+ RESPONSE_TYPE_NONE , RESPONSE_TYPE_CANCEL, RESPONSE_TYPE_TIMEOVER fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int alert_uic_confirmation(uic_data * uic_value);
+
+/**
+ * @par Description: API to alert uic input
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] uic_data
+ *
+ * @return RESPONSE_TYPE_OK success
+ RESPONSE_TYPE_NONE , RESPONSE_TYPE_CANCEL, RESPONSE_TYPE_TIMEOVER fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int alert_uic_inputText(uic_data * uic_value);
+
+/**
+ * @par Description: API to alert single choice
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] uic_data
+ *
+ * @return RESPONSE_TYPE_OK success
+ RESPONSE_TYPE_NONE , RESPONSE_TYPE_CANCEL, RESPONSE_TYPE_TIMEOVER fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int alert_uic_single_choice(uic_data * uic_value);
+
+/**
+ * @par Description: API to alert multiple choice
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] uic_data
+ *
+ * @return RESPONSE_TYPE_OK success
+ RESPONSE_TYPE_NONE , RESPONSE_TYPE_CANCEL, RESPONSE_TYPE_TIMEOVER fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int alert_uic_multiple_choice(uic_data * uic_value);
+
+/**
+ * @par Description: API to noti engine fail
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] previous noti id
+ * @param[in] fail type
+ *
+ * @return RESPONSE_TYPE_OK success
+ RESPONSE_TYPE_NONE , RESPONSE_TYPE_CANCEL, RESPONSE_TYPE_TIMEOVER fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int noti_engine_fail(int prev_noti_id, int fail_type);
+
+/**
+ * @par Description: API to noti wifi only download fail
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return RESPONSE_TYPE_OK success
+ RESPONSE_TYPE_NONE , RESPONSE_TYPE_CANCEL, RESPONSE_TYPE_TIMEOVER fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int noti_wifi_only_download_fail();
+
+/**
+ * @par Description: API to noti memory full
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, file size
+ *
+ * @return RESPONSE_TYPE_OK success
+ RESPONSE_TYPE_NONE , RESPONSE_TYPE_CANCEL, RESPONSE_TYPE_TIMEOVER fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int noti_memory_full(int file_size);
+
+/**
+ * @par Description: API to noti over max file size
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return RESPONSE_TYPE_OK success
+ RESPONSE_TYPE_NONE , RESPONSE_TYPE_CANCEL, RESPONSE_TYPE_TIMEOVER fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int noti_over_max_file_size();
+
+#endif /* IPC_AGENT_H_ */
diff --git a/include/framework/ui-event-handler/ipc_common.h b/include/framework/ui-event-handler/ipc_common.h
new file mode 100755
index 0000000..55e37fd
--- /dev/null
+++ b/include/framework/ui-event-handler/ipc_common.h
@@ -0,0 +1,176 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef IPC_COMMON_H_
+#define IPC_COMMON_H_
+
+typedef enum {
+ EVENT_UNKNOWN = 0,
+ /* Fumo, Noti UI Event */
+ EVENT_SOFTWARE_UPDATE = 1, // Type 1, sync
+ EVENT_CANCEL, // Type 1, sync
+ EVENT_DOWNLOAD, // Type 1, sync
+ EVENT_INSTALL, // Type 1, sync
+ EVENT_SET_INTERVAL, // Type 1, sync
+ EVENT_ACCOUNT_REGISTRATION, // Type 1, sync
+
+ EVENT_GET_FUMO_CONFIG = 7, // Type 1, sync
+ EVENT_SET_FUMO_CONFIG, // Type 1, sync
+
+ /* Admin UI Event */
+ EVENT_GET_PROFILE = 9, // Type 1, sync
+ EVENT_SET_PROFILE, // Type 1, sync
+ EVENT_SET_RESET_PROFILE, // Type 1, sync
+
+ /*ALERT UI */
+ EVENT_UIC_ALERT = 12, // Type 3, response of noti
+
+ /* CP UI Event */
+ EVENT_CHECK_PIN_CODE, // Type 1
+
+ EVENT_ADD_DMACC,
+ EVENT_REMOVE_DMACC,
+
+ EVENT_NUM
+} EVENT_ID;
+
+typedef enum {
+ NOTI_UNKNOWN = 0,
+ NOTI_DOWNLOAD = 1, // Type 0
+ NOTI_INSTALL, // Type 0
+ NOTI_DOWNLOAD_INFO, // Type 0
+
+ NOTI_ENGINE_START = 4, // Type 0
+ NOTI_ENGINE_FAIL, // Type 0
+ NOTI_WIFI_ONLY_DOWNLOAD_FAIL, // Type 0
+ NOTI_MEMORY_FULL, // Type 0
+ NOTI_OVER_BIG_SIZE, // Type 0
+ NOTI_LOW_BATTERY, // Type 0
+
+ NOTI_ALERT_DISPLAY = 10, // Type 0, response event
+ NOTI_ALERT_CONFIRMATION, // Type 0, response event
+ NOTI_ALERT_INPUTTEXT, // Type 0, response event
+ NOTI_ALERT_SINGLE_CHOICE, // Type 0, response event
+ NOTI_ALERT_MULTIPLE_CHOICE, // Type 0, response event
+
+ NOTI_NUM
+} NOTI_ID;
+
+typedef enum {
+ PUSH_TYPE_NONE = -1,
+ PUSH_NOT_SPECIFIED = 0,
+ PUSH_BACKGROUND,
+ PUSH_INFORMATIVE,
+ PUSH_INTERACTION
+} PUSH_TYPE;
+
+typedef enum {
+ IPC_EVENT_TYPE_0 = 0,
+ IPC_EVENT_TYPE_1,
+ IPC_EVENT_TYPE_2,
+ IPC_EVENT_TYPE_3,
+
+} IPC_EVENT_TYPE;
+
+typedef enum {
+ IPC_NOTI_TYPE_0 = 0,
+ IPC_NOTI_TYPE_1,
+ IPC_NOTI_TYPE_2,
+
+} IPC_NOTI_TYPE;
+
+typedef enum {
+ PARAM_TYPE_NULL,
+ PARAM_TYPE_INT,
+ PARAM_TYPE_STR,
+} PARAM_TYPE;
+
+typedef enum {
+ CONNECTION_STATUS_FAILURE,
+ CONNECTION_STATUS_SUCCESS,
+ CONNECTION_STATUS_UPTODATA,
+ CONNECTION_STATUS_FAILURE_AUTHENTICATION
+} CONNECTION_STATUS;
+
+typedef enum {
+ RESPONSE_TYPE_NONE = 0,
+ RESPONSE_TYPE_OK,
+ RESPONSE_TYPE_CANCEL,
+ RESPONSE_TYPE_TIMEOVER,
+ //Todo: add the response type if U need
+
+ //RESPONSE_TYPE_REMINDER_INTERVAL_NONE,
+ RESPONSE_TYPE_REMINDER_INTERVAL_1_HOUR,
+ RESPONSE_TYPE_REMINDER_INTERVAL_3_HOURS,
+ RESPONSE_TYPE_REMINDER_INTERVAL_6_HOURS,
+ RESPONSE_TYPE_REMINDER_INTERVAL_12_HOURS,
+ RESPONSE_TYPE_REMINDER_INTERVAL_1_DAY,
+ //RESPONSE_TYPE_REMINDER_INTERVAL_7_DAYS,
+
+ RESPONSE_TYPE_NUM
+} RESPONSE_TYPE;
+
+typedef enum {
+
+ /*for EVENT_CONNECT_TO_SERVER */
+
+ NO_REPLY_SUCCESS = 0, // success in the case of no reply
+ NO_REPLY_FAILURE, // failusre in the case of no reply
+
+ REPLY_FAIL_TO_CONNECT, // failure to connect
+
+ REPLY_SUCCESS_TO_CONNECT, // success to connect
+
+ REPLY_NEW_UPDATE_EXISTS, // success to connect
+ REPLY_NO_UPDATE_EXISTS, // success to connect
+
+ REPLY_POSTPONE_STATUS, // success to connect
+ REPLY_NO_POSTPONE_STATUS, // success to connect
+
+ REPLY_ALL_MEMORYCARD_FULL, // success to connect
+ REPLY_NOT_ALL_MEMORYCARD_FULL, // success to connect
+
+ //Todo Other replies...
+
+} REPLY_TYPE;
+
+typedef enum {
+ FOTA_COMMON_UI,
+ FOTA_NOTI_UI,
+ FOTA_BACKGROUND_UI,
+ ADMIN_UI,
+ ALERT_UI,
+ CP_UI
+} UI_TYPE;
+
+//2012.11.20
+typedef enum {
+ EVENT_RESPONSE_FAIL = 0,
+ EVENT_RESPONSE_OK = 1
+} EVENT_RESPONSE;
+
+//2012.11.29
+typedef enum _uic_type {
+ UIC_NONE_TYPE,
+ UIC_DISPLAY_TYPE,
+ UIC_CONFIRMATION_TYPE,
+ UIC_INPUT_TEXT_TYPE,
+ UIC_SINGLE_CHOICE_TYPE,
+ UIC_MULTIPLE_CHOICE_TYPE
+} uic_type;
+
+#endif /* IPC_COMMON_H_ */
diff --git a/include/framework/ui-event-handler/user-interaction/user_interaction.h b/include/framework/ui-event-handler/user-interaction/user_interaction.h
new file mode 100755
index 0000000..77c9f91
--- /dev/null
+++ b/include/framework/ui-event-handler/user-interaction/user_interaction.h
@@ -0,0 +1,268 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SA_USERINTERACTION_H_
+#define SA_USERINTERACTION_H_
+
+/*lib*/
+#include <glib.h>
+
+/*dm-agent*/
+#include "common/dm_error.h"
+#include "serviceadapter/sa_define.h"
+#include "ipc_common.h"
+
+typedef struct _uic_option {
+ char *min_t;
+ char *max_t;
+ char *default_data;
+ char *maxlen;
+ char *input_type;
+ char *echo_type;
+} uic_option;
+
+typedef struct _uic_res_data {
+ uic_type type;
+ int status;
+ char *input_text;
+ GList *res_multi_data;
+} uic_res_data;
+
+typedef struct _uic_data {
+ uic_option *pUic_option;
+ char *display;
+ GList *multi_data;
+ uic_res_data *res_data;
+} uic_data;
+
+/**
+ * @par Description: API to free uic data
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] uic_data
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_uic_value(uic_data ** uic_value);
+
+/**
+ * @par Description: API to free uic res data
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] res_data
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_res_data(uic_res_data * res_data);
+/**
+ * @par Description: API to execute user interaction option
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] data
+ * @param[in] uic_option
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR exec_userinteration_option(char *data, uic_option ** uic_value);
+
+/**
+ * @par Description: API to display uic
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] uic_data
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR ui_display(uic_data * uic_value);
+
+/**
+ * @par Description: API to confirm uic
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] uic_data
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR ui_confirm_or_reject(uic_data * uic_value);
+
+/**
+ * @par Description: API to input uic
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] uic_data
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR ui_text_input(uic_data * uic_value, char **result_data);
+
+/**
+ * @par Description: API to single choice uic
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] uic_data
+ * @param[in] response item
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR ui_single_choice(uic_data * uic_value, GList ** responseItems);
+
+/**
+ * @par Description: API to multiple choice uic
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] uic_data
+ * @param[in] response item
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR ui_multiple_choice(uic_data * uic_value, GList ** responseItems);
+
+#endif /* SA_USERINTERACTION_H_ */
diff --git a/include/mo-handler/dm_mo_common.h b/include/mo-handler/dm_mo_common.h
new file mode 100755
index 0000000..42dbe0d
--- /dev/null
+++ b/include/mo-handler/dm_mo_common.h
@@ -0,0 +1,635 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_MO_COMMON_H_
+#define DM_MO_COMMON_H_
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "dm_mo_common_internal.h"
+#include "serviceadapter/sa_define.h"
+
+/*=================================================================
+ * DM MO COMMON
+ * =================================================================
+ */
+
+/**
+ * @par Description: API to free dm acc
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] dm_acc structure
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_dm_acc(dm_acc * dmaccount);
+
+/**
+ * @par Description: API to get_client_dmacc
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] server id server id
+ * @param[out] client id client id
+ * @param[out] client pw client pw
+ * @param[out] source url source url
+ * @param[out] target url targer url
+ * @param[out] base64 base64
+ * @param[out] nextnonce nextnonce
+ * @param[out] authType authType
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_client_dmacc(char *pServer_id, char **client_id, char **client_pwd, char **sourceUrl, char **targetUrl, int *isBase64, char **nextNonce, char **authType);
+
+/**
+ * @par Description: API to get_server_dmacc
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] server id server id
+ * @param[out] client id client id
+ * @param[out] client pw client pw
+ * @param[out] source url source url
+ * @param[out] target url targer url
+ * @param[out] base64 base64
+ * @param[out] nextnonce nextnonce
+ * @param[out] authType authType
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_server_dmacc(char *pServer_id, char **server_id, char **server_pwd, char **sourceUrl, char **targetUrl, int *isBase64, char **nextNonce, char **authType);
+
+/**
+ * @par Description: API to update dm acc
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] server id server id
+ * @param[out] dm_acc structure
+ *
+ * @return 1 success
+ * 0 fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int update_dmacc(char *pServer_id, dm_acc * dmaccount);
+
+/**
+ * @par Description: API to get dm acc auth type
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] server id server id
+ * @param[out] AuthType Auth type
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_dmacc_authType(char *pServer_id, AuthType * pAuthType);
+
+/**
+ * @par Description: API to get_format
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] mo format mo format
+ * @param[out] format format
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_format(sync_agent_dm_mo_format_e format_enum, char **format);
+
+/**
+ * @par Description: API to get_format_enum
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] format format
+ * @param[out] format_enum format_enum
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_format_enum(char *format, sync_agent_dm_mo_format_e * format_enum);
+
+/**
+ * @par Description: API to get_contenttype
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] mo contenttype mo contenttype
+ * @param[out] contenttype contenttype
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+
+DM_ERROR get_contenttype(sync_agent_dm_mo_df_type_e contenttype_enum, char **contenttype);
+*/
+
+/**
+ * @par Description: API to reset dmacc mscserver
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void reset_dmacc_mscserver();
+
+/**
+ * @par Description: API to reset dmacc msctestserver
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void reset_dmacc_msctestserver();
+
+/**
+ * @par Description: API to get_format
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void reset_dmacc_gcf();
+
+/**
+ * @par Description: API to reset_devinfo
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void reset_devinfo();
+
+/**
+ * @par Description: API to reset_devdetail
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void reset_devdetail();
+
+/**
+ * @par Description: API to get_mo_root_path
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] mo full path
+ * @param[in] root path
+ *
+ * @return DM_OK success
+ * DM_ERROR fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_mo_root_path(const char *mo_full_path, char **root_path);
+
+/**
+ * @par Description: API to get_engine_type_by_serverid
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] server id
+ *
+ * @return SERVICE_SERVER_TYPE
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+SERVICE_SERVER_TYPE get_engine_type_by_serverid(const char *server_id);
+
+/**
+ * @par Description: API to get_engine_type_by_serverid
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] mo full path
+ *
+ * @return SERVICE_SERVER_TYPE
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+SERVICE_SERVER_TYPE get_service_type(const char *mo_full_path);
+
+/**
+ * @par Description: API to get server id
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] server type
+ * @param[out] server id
+ *
+ * @return SERVICE_SERVER_TYPE
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_Serverid(SERVICE_SERVER_TYPE mo_type, char **server_id);
+
+/**
+ * @par Description: API to get server type
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] server_id
+ * @param[out] mo_type
+ *
+ * @return SERVICE_SERVER_TYPE
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_server_type(char *server_id, int *mo_type);
+
+/**
+ * @par Description: API to add dm acc
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] server_type server type
+ *
+ * @return DM_OK
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR add_dm_acc(SERVICE_SERVER_TYPE server_type);
+
+/**
+ * @par Description: API to remove dm acc
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] mo_path mo full path
+ *
+ * @return DM_OK
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR remove_dm_acc(char *mo_path);
+
+/**
+ * @par Description: API to check dm acc
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] dmacc_type dm acc type
+ * @param[out] is_exist check exist flag
+ *
+ * @return DM_OK
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR is_exist_dmacc(SERVICE_SERVER_TYPE dmacc_type, int *is_exist);
+
+/*=================================================================
+ * FOR TEST
+ * =================================================================
+ */
+/**
+ * @par Description: API to this code is temp code fo test
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+/*
+void dmacc_define_fumo();
+void dmacc_define_lawmo();
+void devinfo_define();
+void devdetail_define();
+void fumo_define();
+void lawmo_define();
+*/
+
+#endif /* DM_MO_COMMON_H_ */
diff --git a/include/mo-handler/dm_mo_common_internal.h b/include/mo-handler/dm_mo_common_internal.h
new file mode 100755
index 0000000..7f4d835
--- /dev/null
+++ b/include/mo-handler/dm_mo_common_internal.h
@@ -0,0 +1,258 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_MO_GENERATER_INTERNAL_H_
+#define DM_MO_GENERATER_INTERNAL_H_
+
+/*dm-agent*/
+#include "common/dm_common_def.h"
+
+#define MO_ROOT "."
+#define MO_SEPERATOR "/"
+
+#define DM_ACC_SERVICE "DMAcc"
+#define DEVINFO_SERVICE "DevInfo"
+#define DEVDETAIL_SERVIC "DevDetail"
+#define FUMO_SERVICE "FUMO"
+#define LAWMO_SERVICE "LAWMO"
+#define SCOMO_SERVICE "SCOMO"
+
+#define DM_DEVINFO "./DevInfo"
+#define DM_DEVDETAIL "./DevDetail"
+#define DM_DMACC_MSCSERVER "./DMAcc/MSCserver"
+#define DM_DMACC_MSCTESTSERVER "./DMAcc/MSCTestserver"
+#define DM_DMACC_GCF "./DMAcc/gcf"
+
+#define DM_FUMO_DOWNLOAD_OP "/Download"
+#define DM_FUMO_UPDATE_OP "/Update"
+#define DM_FUMO_DOWNLOADAND_UPDATE_OP "/DownloadAndUpdate"
+#define DM_FUMO_DWONLOAD_OP_PKGURL "/PkgURL"
+#define DM_FUMO_UPDATE_PKG_OP_DATA "/PkgData"
+#define DM_FUMO_DOWNLOADAND_UPDATE_OP_PKGURL "/PkgURL"
+#define DM_FUMO_STATE_OP "/State"
+#define DM_FUMO_EXT_OP "/Ext"
+
+#define DM_LAWMO_STATE_OP "/State"
+#define DM_LAWMO_AVAILABLEWIPELIST_LISTITEMNAME "/AvailableWipeList/omadm/ListItemName"
+#define DM_LAWMO_AVAILABLEWIPELIST_TOBEWIPED "/AvailableWipeList/omadm/ToBeWipe"
+#define DM_LAWMO_LAWMOCONFIG_NOTIFYUSER "/Operations/LAWMOConfig/NotifyUser"
+#define DM_LAWMO_OPERATIONS_FULLYLOCK_OP "/Operations/FullllyLock"
+#define DM_LAWMO_OPERATIONS_PARTIALLYLOCK_OP "/Operations/PartiallyLock"
+#define DM_LAWMO_OPERATIONS_UNLOCK_OP "/Operations/UnLock"
+#define DM_LAWMO_OPERATIONS_FACTORYRESET_OP "/Operations/FactoryReset"
+#define DM_LAWMO_OPERATIONS_WIPE_OP "/Operations/Wipe"
+#define DM_LAWMO_EXT "/Ext"
+
+typedef struct _dm_acc {
+ char *profile_name;
+ char *server_url;
+ char *server_id;
+ char *server_pw;
+ char *user_id;
+ char *user_pw;
+ char *user_auth_type;
+ char *server_auth_type;
+ int base64;
+ char *user_nextNonce;
+ char *server_nextNonce;
+} dm_acc;
+
+/* this is temp code for test */
+#ifndef _SLP_SAMSUNG_DM_MO
+
+#define FUMO_DM_ACC "./DMAcc"
+#define FUMO_DM_ACC_FUMO "./DMAcc/fumo"
+#define FUMO_DM_ACC_APPID "./DMAcc/fumo/AppID"
+#define FUMO_DM_ACC_SERVERID "./DMAcc/fumo/ServerID"
+#define FUMO_DM_ACC_NAME "./DMAcc/fumo/Name"
+#define FUMO_DM_ACC_PRECONREF "./DMAcc/fumo/PreConRef"
+#define FUMO_DM_ACC_TOCONREF "./DMAcc/fumo/ToConRef"
+#define FUMO_DM_ACC_TOCONREF_X "./DMAcc/fumo/ToConRef/MSC"
+#define FUMO_DM_ACC_TOCONREF_X_CONREF "./DMAcc/fumo/ToConRef/MSC/ConRef"
+#define FUMO_DM_ACC_APPADDR "./DMAcc/fumo/AppAddr"
+#define FUMO_DM_ACC_APPADDR_X "./DMAcc/fumo/AppAddr/MSC"
+#define FUMO_DM_ACC_APPADDR_X_ADDR "./DMAcc/fumo/AppAddr/MSC/Addr"
+#define FUMO_DM_ACC_APPADDR_X_ADDRTYPE "./DMAcc/fumo/AppAddr/MSC/AddrType"
+#define FUMO_DM_ACC_APPADDR_X_PORT "./DMAcc/fumo/AppAddr/MSC/Port"
+#define FUMO_DM_ACC_APPADDR_X_PORT_X "./DMAcc/fumo/AppAddr/MSC/Port/MSC"
+#define FUMO_DM_ACC_APPADDR_X_PORT_X_PORTNBR "./DMAcc/fumo/AppAddr/MSC/Port/MSC/PortNbr"
+#define FUMO_DM_ACC_AAUTHPREF "./DMAcc/fumo/AAuthPref"
+#define FUMO_DM_ACC_APPAUTH "./DMAcc/fumo/AppAuth"
+#define FUMO_DM_ACC_APPAUTH_X1 "./DMAcc/fumo/AppAuth/ClientAppAuth"
+#define FUMO_DM_ACC_APPAUTH_X1_AAUTHLEVEL "./DMAcc/fumo/AppAuth/ClientAppAuth/AAuthLevel"
+#define FUMO_DM_ACC_APPAUTH_X1_AAUTHTYPE "./DMAcc/fumo/AppAuth/ClientAppAuth/AAuthType"
+#define FUMO_DM_ACC_APPAUTH_X1_AAUTHNAME "./DMAcc/fumo/AppAuth/ClientAppAuth/AAuthName"
+#define FUMO_DM_ACC_APPAUTH_X1_SECRET "./DMAcc/fumo/AppAuth/ClientAppAuth/AAuthSecret"
+#define FUMO_DM_ACC_APPAUTH_X1_AAUTHDATA "./DMAcc/fumo/AppAuth/ClientAppAuth/AAuthData"
+#define FUMO_DM_ACC_APPAUTH_X2 "./DMAcc/fumo/AppAuth/ServerAppAuth"
+#define FUMO_DM_ACC_APPAUTH_X2_AAUTHLEVEL "./DMAcc/fumo/AppAuth/ServerAppAuth/AAuthLevel"
+#define FUMO_DM_ACC_APPAUTH_X2_AAUTHTYPE "./DMAcc/fumo/AppAuth/ServerAppAuth/AAuthType"
+#define FUMO_DM_ACC_APPAUTH_X2_AAUTHNAME "./DMAcc/fumo/AppAuth/ServerAppAuth/AAuthName"
+#define FUMO_DM_ACC_APPAUTH_X2_SECRET "./DMAcc/fumo/AppAuth/ServerAppAuth/AAuthSecret"
+#define FUMO_DM_ACC_APPAUTH_X2_AAUTHDATA "./DMAcc/fumo/AppAuth/ServerAppAuth/AAuthData"
+#define FUMO_DM_ACC_EXT "./DMAcc/fumo/Ext"
+
+#define LAWMO_DM_ACC "./DMAcc"
+#define LAWMO_DM_ACC_LAWMO "./DMAcc/lawmo"
+#define LAWMO_DM_ACC_APPID "./DMAcc/lawmo/AppID"
+#define LAWMO_DM_ACC_SERVERID "./DMAcc/lawmo/ServerID"
+#define LAWMO_DM_ACC_NAME "./DMAcc/lawmo/Name"
+#define LAWMO_DM_ACC_PRECONREF "./DMAcc/lawmo/PreConRef"
+#define LAWMO_DM_ACC_TOCONREF "./DMAcc/lawmo/ToConRef"
+#define LAWMO_DM_ACC_TOCONREF_X "./DMAcc/lawmo/ToConRef/MSC"
+#define LAWMO_DM_ACC_TOCONREF_X_CONREF "./DMAcc/lawmo/ToConRef/MSC/ConRef"
+#define LAWMO_DM_ACC_APPADDR "./DMAcc/lawmo/AppAddr"
+#define LAWMO_DM_ACC_APPADDR_X "./DMAcc/lawmo/AppAddr/MSC"
+#define LAWMO_DM_ACC_APPADDR_X_ADDR "./DMAcc/lawmo/AppAddr/MSC/Addr"
+#define LAWMO_DM_ACC_APPADDR_X_ADDRTYPE "./DMAcc/lawmo/AppAddr/MSC/AddrType"
+#define LAWMO_DM_ACC_APPADDR_X_PORT "./DMAcc/lawmo/AppAddr/MSC/Port"
+#define LAWMO_DM_ACC_APPADDR_X_PORT_X "./DMAcc/lawmo/AppAddr/MSC/Port/MSC"
+#define LAWMO_DM_ACC_APPADDR_X_PORT_X_PORTNBR "./DMAcc/lawmo/AppAddr/MSC/Port/MSC/PortNbr"
+#define LAWMO_DM_ACC_AAUTHPREF "./DMAcc/lawmo/AAuthPref"
+#define LAWMO_DM_ACC_APPAUTH "./DMAcc/lawmo/AppAuth"
+#define LAWMO_DM_ACC_APPAUTH_X1 "./DMAcc/lawmo/AppAuth/ClientAppAuth"
+#define LAWMO_DM_ACC_APPAUTH_X1_AAUTHLEVEL "./DMAcc/lawmo/AppAuth/ClientAppAuth/AAuthLevel"
+#define LAWMO_DM_ACC_APPAUTH_X1_AAUTHTYPE "./DMAcc/lawmo/AppAuth/ClientAppAuth/AAuthType"
+#define LAWMO_DM_ACC_APPAUTH_X1_AAUTHNAME "./DMAcc/lawmo/AppAuth/ClientAppAuth/AAuthName"
+#define LAWMO_DM_ACC_APPAUTH_X1_SECRET "./DMAcc/lawmo/AppAuth/ClientAppAuth/AAuthSecret"
+#define LAWMO_DM_ACC_APPAUTH_X1_AAUTHDATA "./DMAcc/lawmo/AppAuth/ClientAppAuth/AAuthData"
+#define LAWMO_DM_ACC_APPAUTH_X2 "./DMAcc/lawmo/AppAuth/ServerAppAuth"
+#define LAWMO_DM_ACC_APPAUTH_X2_AAUTHLEVEL "./DMAcc/lawmo/AppAuth/ServerAppAuth/AAuthLevel"
+#define LAWMO_DM_ACC_APPAUTH_X2_AAUTHTYPE "./DMAcc/lawmo/AppAuth/ServerAppAuth/AAuthType"
+#define LAWMO_DM_ACC_APPAUTH_X2_AAUTHNAME "./DMAcc/lawmo/AppAuth/ServerAppAuth/AAuthName"
+#define LAWMO_DM_ACC_APPAUTH_X2_SECRET "./DMAcc/lawmo/AppAuth/ServerAppAuth/AAuthSecret"
+#define LAWMO_DM_ACC_APPAUTH_X2_AAUTHDATA "./DMAcc/lawmo/AppAuth/ServerAppAuth/AAuthData"
+#define LAWMO_DM_ACC_EXT "./DMAcc/lawmo/Ext"
+
+#define DM_DEVINFO "./DevInfo"
+#define DM_DEVINFO_BEARER "./DevInfo/Bearer"
+#define DM_DEVINFO_DEVID "./DevInfo/DevId"
+#define DM_DEVINFO_MAN "./DevInfo/Man"
+#define DM_DEVINFO_MOD "./DevInfo/Mod"
+#define DM_DEVINFO_DMV "./DevInfo/DmV"
+#define DM_DEVINFO_LANG "./DevInfo/Lang"
+#define DM_DEVINFO_EXT "./DevInfo/Ext"
+
+#define DM_DEVDETAIL "./DevDetail"
+#define DM_DEVDETAIL_BEARER "./DevDetail/Bearer"
+#define DM_DEVINFO_URI "./DevDetail/URI"
+#define DM_DEVINFO_URI_MAXDEPTH "./DevDetail/URI/MaxDepth"
+#define DM_DEVINFO_URI_MAXTOTLEN "./DevDetail/URI/MaxTotLen"
+#define DM_DEVINFO_URI_MAXSEGLEN "./DevDetail/URI/MaxSegLen"
+#define DM_DEVINFO_DEVTYP "./DevDetail/DevTyp"
+#define DM_DEVINFO_OEM "./DevDetail/OEM"
+#define DM_DEVINFO_FWV "./DevDetail/FwV"
+#define DM_DEVINFO_SWV "./DevDetail/SwV"
+#define DM_DEVINFO_HWV "./DevDetail/HwV"
+#define DM_DEVINFO_LRGOBJ "./DevDetail/LrgObj"
+
+/*temp length*/
+#define MO_MAX_LEN 100
+
+#define DM_FUMO "./FUMO"
+#define DM_FUMO_PKGNAME "./FUMO/PkgName"
+#define DM_FUMO_VERSION "./FUMO/PkgVersion"
+#define DM_FUMO_DOWNLOAD "./FUMO/Download"
+#define DM_FUMO_DWONLOAD_PKGURL "./FUMO/Download/PkgURL"
+#define DM_FUMO_UPDATE "./FUMO/Update"
+#define DM_FUMO_UPDATE_PKG_DATA "./FUMO/Update/PkgData"
+#define DM_FUMO_DOWNLOADAND_UPDATE "./FUMO/DownloadAndUpdate"
+#define DM_FUMO_DOWNLOADAND_UPDATE_PKGURL "./FUMO/DownloadAndUpdate/PkgURL"
+#define DM_FUMO_STATE "./FUMO/State"
+#define DM_FUMO_EXT "./FUMO/Ext"
+
+#define DM_LAWMO "./LAWMO"
+#define DM_LAWMO_STATE "./LAWMO/State"
+#define DM_LAWMO_AVAILABLEWIPELIST "./LAWMO/AvailableWipeList"
+#define DM_LAWMO_AVAILABLEWIPELIST_x1 "./LAWMO/AvailableWipeList/x1"
+#define DM_LAWMO_AVAILABLEWIPELIST_x1_LISTITEMNAME "./LAWMO/AvailableWipeList/x1/ListItemName"
+#define DM_LAWMO_AVAILABLEWIPELIST_x1_TOBEWIPED "./LAWMO/AvailableWipeList/x1/ToBeWiped"
+#define DM_LAWMO_LAWMOCONFIG "./LAWMO/LAWMOConfig"
+#define DM_LAWMO_LAWMOCONFIG_NOFITYUSER "./LAWMO/LAWMOConfig/NotifyUser"
+#define DM_LAWMO_OPERATIONS "./LAWMO/Operations"
+#define DM_LAWMO_OPERATIONS_FULLYLOCK "./LAWMO/Operations/FullyLock"
+#define DM_LAWMO_OPERATIONS_PARTIALLYLOCK "./LAWMO/Operations/PartiallyLock"
+#define DM_LAWMO_OPERATIONS_UNLOCK "./LAWMO/Operations/UnLock"
+#define DM_LAWMO_OPERATIONS_FACTORYRESET "./LAWMO/Operations/FactoryReset"
+#define DM_LAWMO_OPERATIONS_WIPE "./LAWMO/Operations/Wipe"
+#define DM_LAWMO_EXT "./LAWMO/Ext"
+
+#define DM_LAWMO_EXT_OSPS "./Ext/OSPS"
+#define DM_LAWMO_EXT_OSPS_LAWMO "./Ext/OSPS/LAWMO"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP "./Ext/OSPS/LAWMO/OSP"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_STATE "./Ext/OSPS/LAWMO/OSP/State"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_X "./Ext/OSPS/LAWMO/OSP/<x>"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_LAWMOCONFIG "./Ext/OSPS/LAWMO/OSP/LAWMOConfig"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_NOTIFYUSER "./Ext/OSPS/LAWMO/OSP/NotifyUser"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_OPERATIONS "./Ext/OSPS/LAWMO/OSP/Operations"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_OPERATIONS_FULLYLOCK "./Ext/OSPS/LAWMO/OSP/Operations/FullyLock"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_OPERATIONS_PARTIALLYLOCK "./Ext/OSPS/LAWMO/OSP/Operations/PartiallyLock"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_OPERATIONS_UNLOCK "./Ext/OSPS/LAWMO/OSP/Operations/UnLock"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_OPERATIONS_FACTORYRESET "./Ext/OSPS/LAWMO/OSP/Operations/FactoryReset"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_OPERATIONS_WIPE "./Ext/OSPS/LAWMO/OSP/Operations/Wipe"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_EXT "./Ext/OSPS/LAWMO/OSP/Ext"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_EXT_AMT "./Ext/OSPS/LAWMO/OSP/Ext/AMT"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_EXT_STATUS "./Ext/OSPS/LAWMO/OSP/Ext/AMT/Status"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_EXT_LOCKMYPHONE_MESSAGES "./Ext/OSPS/LAWMO/OSP/Ext/LockMyPhone/Messages"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_EXT_CALLRESTRICTION_PHONENUMBER "./Ext/OSPS/LAWMO/OSP/Ext/CallRestriction/PhoneNumber"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_EXT_PASSWORD "./Ext/OSPS/LAWMO/OSP/Ext/Password"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_AVAILABLEWIPELIST "./Ext/OSPS/LAWMO/OSP/AvailableWipeList"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_AVAILABLEWIPELIST_EXTERNAL_LISTITEMNAME "./Ext/OSPS/LAWMO/OSP/AvailableWipeList/External/ListItemName"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_AVAILABLEWIPELIST_EXTERNAL_TOBEWIPED "./Ext/OSPS/LAWMO/OSP/AvailableWipeList/External/ToBeWiped"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_AVAILABLEWIPELIST_SIM_LISTITEMNAME "./Ext/OSPS/LAWMO/OSP/AvailableWipeList/SIM/ListItemName"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_AVAILABLEWIPELIST_SIM_TOBEWIPED "./Ext/OSPS/LAWMO/OSP/AvailableWipeList/SIM/ToBeWiped"
+
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_EXT_RINGMYPHONE_OPERATIONS_START "./Ext/OSPS/LAWMO/OSP/Ext/RingMyPhone/Operations/Start"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_EXT_RINGMYPHONE_OPERATIONS_STOP "./Ext/OSPS/LAWMO/OSP/Ext/RingMyPhone/Operations/Stop"
+#define DM_LAWMO_EXT_OSPS_LAWMO_OSP_EXT_RINGMYPHONE_STATUS "./Ext/OSPS/LAWMO/OSP/Ext/RingMyPhone/Status"
+
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_GPS_ISVALID "./Ext/OSPS/MobileTraking/GPS/isValid"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_GPS_LATITUDE "./Ext/OSPS/MobileTraking/GPS/latitude"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_GPS_LONGITUDE "./Ext/OSPS/MobileTraking/GPS/longitude"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_GPS_HORIZONTALUNCERTAINTY "./Ext/OSPS/MobileTraking/GPS/horizontalUncertainty"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_GPS_VERTICALUNCERTAINTY "./Ext/OSPS/MobileTraking/GPS/verticalUncertainty"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_GPS_DATE "./Ext/OSPS/MobileTraking/GPS/Date"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_NONGPS "./Ext/OSPS/MobileTraking/NonGPS"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_NONGPS_ISVALID "./Ext/OSPS/MobileTraking/NonGPS/isValid"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_NONGPS_CELLID "./Ext/OSPS/MobileTraking/NonGPS/CellId"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_NONGPS_LAC "./Ext/OSPS/MobileTraking/NonGPS/LAC"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_NONGPS_MNC "./Ext/OSPS/MobileTraking/NonGPS/MNC"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_NONGPS_MCC "./Ext/OSPS/MobileTraking/NonGPS/MCC"
+
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_OPERATION "./Ext/OSPS/MobileTraking/Operation"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_OPERATION_GET "./Ext/OSPS/MobileTraking/Operation/Get"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_OPERATION_GET_LOCATION "./Ext/OSPS/MobileTraking/Operation/Get/Location"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_OPERATION_STOP "./Ext/OSPS/MobileTracking/Operations/Stop"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_OPERATION_TRACKING "./Ext/OSPS/MobileTracking/Operations/Tracking"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_STATUS "./Ext/OSPS/MobileTracking/Status"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_POLICY "./Ext/OSPS/MobileTracking/Policy"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_POLICY_STARTDATE "./Ext/OSPS/MobileTracking/Policy/StartDate"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_POLICY_ENDDATE "./Ext/OSPS/MobileTracking/Policy/EndDate"
+#define DM_LAWMO_EXT_OSPS_MOBILETRAKING_POLICY_INTERVAL "./Ext/OSPS/MobileTracking/Policy/Interval"
+
+#define DM_LAWMO_EXT_OSPS_FORWARDING "./Ext/OSPS/Forwarding"
+#define DM_LAWMO_EXT_OSPS_FORWARDING_NUMBERS_CALLFORWARDING "./Ext/OSPS/Forwarding/Numbers/CallForwarding"
+#define DM_LAWMO_EXT_OSPS_FORWARDING_ENABLEDSERVICES_CALLFORWARDING "./Ext/OSPS/Forwarding/EnabledServices/CallForwarding"
+#define DM_LAWMO_EXT_OSPS_FORWARDING_NUMBERS_SMSFORWARDING "./Ext/OSPS/Forwarding/Numbers/SMSForwarding"
+#define DM_LAWMO_EXT_OSPS_FORWARDING_ENABLEDSERVICES_SMSFORWARDING "./Ext/OSPS/Forwarding/EnabledServices/SMSForwarding"
+#define DM_LAWMO_EXT_OSPS_FORWARDING_OPERATIONS_DIVERTREQUEST "./Ext/OSPS/Forwarding/Operations/DivertRequest"
+#define DM_LAWMO_EXT_OSPS_MASTERKEY_OPERATIONS "./Ext/OSPS/MasterKey/Operations"
+#define DM_LAWMO_EXT_OSPS_MASTERKEY_OPERATIONS_LOCKRELEASE "./Ext/OSPS/MasterKey/Operations/LockRelease"
+
+#endif
+
+#endif /* DM_MO_GENERATER_INTERNAL_H_ */
diff --git a/include/mo-handler/dm_mo_handler.h b/include/mo-handler/dm_mo_handler.h
new file mode 100755
index 0000000..993633e
--- /dev/null
+++ b/include/mo-handler/dm_mo_handler.h
@@ -0,0 +1,718 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DM_MO_GENERATER_H_
+#define DM_MO_GENERATER_H_
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_error.h"
+#include "serviceadapter/sa_define.h"
+#include "dm_mo_common.h"
+
+/**
+ * @par Description: API to clean mo db for reset or delete dm
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR clean_dm_mo();
+
+/**
+ * @par Description: API to add item to mo with add cmd
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] item
+ * @param[in] server_id
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR add_itemtomo(Item * item, char *server_id);
+
+/**
+ * @par Description: API to replace item to mo with replace cmd (update)
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] item
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR replace_itemtomo(Item * item);
+
+/**
+ * @par Description: API to replace mo data
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * param[in] mo_full_path mo full path
+ * param[in] value value
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR replace_mo_data(char *mo_full_path, char *value);
+
+/**
+ * @par Description: API to replace mo acl property
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * param[in] mo_full_path mo full path
+ * param[in] value value
+ * param[in] acl acl
+ * param[in] contenttype contenttype
+ * param[in] format format
+ * param[in] prop_type prop_type
+ *
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR replace_mo_property(char *mo_full_path, char *value, char *acl, char *contenttype, char *format, GetType prop_type);
+
+/**
+ * @par Description: API to add mo
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * param[in] server type server type
+ * param[in] mo_full_path mo full path
+ * param[in] value value
+ * param[in] node_type node type
+ * param[in] contenttype contenttype
+ * param[in] format format
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR add_mo(int server_type, char *mo_full_path, char *value, sync_agent_dm_mo_node_type_e node_type, char *contenttype, char *format);
+
+/**
+ * @par Description: API to delete item to mo
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * param[in] item
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR delete_itemtomo(Item * item);
+
+/**
+ * @par Description: API to replace mo (update)
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * param[in] mo_full_path mo full path
+ * param[in] value value
+ * param[in] prop_value prop_value
+ * param[in] contenttype contenttype
+ * param[in] format format
+ * parma[in] prop_type prop_type
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR replace_mo(char *mo_full_path, char *value, char *acl, char *contenttype, char *format, GetType prop_type);
+
+/**
+ * @par Description: API to delete mo
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * param[in] mo_full_path mo full path
+ * param[in] value value
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR delete_mo(char *mo_full_path);
+
+/**
+ * @par Description: API to get mo data
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * param[in] mo_full_path mo full path
+ * param[in] data data
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_mo_data(char *full_path, char **data);
+
+/**
+ * @par Description: API to get mo child list
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] mo_full_path mo full path
+ * @param[out pItems child mo liste
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_child_mo_list(char *mo_full_path, GList ** pItems);
+
+/**
+ * @par Description: API to get mo data
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] mo_full_path mo full path
+ * @param[in] get_type get type
+ * @param[out] real_full_path real full path
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_type_mo_tree(char *mo_full_path, GetType * get_type, char **real_full_path);
+
+/**
+ * @par Description: API to get Struct
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] mo_full_path mo full path
+ * @param[out pItems child mo list with get type Struct
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_struct(char *mo_full_path, GList ** pItems);
+
+/**
+ * @par Description: API to get StructData
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] mo_full_path mo full path
+ * @param[out] pItems child mo list with get type StructData
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_structdata(char *mo_full_path, GList ** pItems);
+
+/**
+ * @par Description: API to get TNDS
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] contenttype contenttype
+ * @param[in] mo_full_path mo full path
+ * @param[out] stream_size stream_size
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_tnds(char *contenttype, char *mo_full_path, char **tnds, unsigned int *stream_size);
+
+/**
+ * @par Description: API to set_client_nextnonce
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] server id
+ * @param[in] next nonce
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR set_client_nextnonce(char *pServer_id, char *next_nonce);
+
+/**
+ * @par Description: API to set_client_authtype
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] server id
+ * @param[in] AuthType
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR set_client_authtype(char *pServer_id, AuthType auth_type);
+
+/**
+ * @par Description: API to check_mo_scope
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] full_path
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR check_mo_scope(char *full_path);
+
+/**
+ * @par Description: API to copy_itemtomo
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] item
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR copy_itemtomo(Item * item);
+
+/**
+ * @par Description: API to copy_itemtomo
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] target url
+ * @param[in] source url
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR copy_mo_data(char *target_url, char *source_url);
+
+/**
+ * @par Description: API to copy_mo
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] source url
+ * @param[in] target url
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR copy_mo(char *target_url, char *source_url);
+
+/**
+ * @par Description: API to get Operation Type
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] mo_full_path mo full path
+ * @param[out] result_oper_type result oper type
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_mo_operationtype(char *full_path, char **result_oper_type);
+
+/**
+ * @par Description: API to get_mo_node_format_contenttype
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] mo_full_path mo full path
+ * @param[in] format format
+ * @param[in] contenttype contenttype
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_mo_node_format_contenttype(const char *mo_path, char **format, char **contenttype);
+
+/**
+ * @par Description: API to get_mo_node_property
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] mo_full_path mo full path
+ * @param[in] pr_type pr_type
+ * @param[out] property property
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_mo_node_property(const char *mo_path, propoerty_type pr_type, char **property);
+
+/*=================================================================
+ * FOR TEST
+ * =================================================================
+ */
+/**
+ * @par Description: API to this code is temp code for test
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] mo_full_path mo full path
+ * @param[in] acl acl
+ *
+ * @return DM_OK success
+ * DM_ERRORS fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR pre_define_mo();
+
+#endif /* DM_MO_GENERATER_H_ */
diff --git a/include/serviceadapter/dm-phase-handler/dm_phase_handler.h b/include/serviceadapter/dm-phase-handler/dm_phase_handler.h
new file mode 100755
index 0000000..9f0c2ce
--- /dev/null
+++ b/include/serviceadapter/dm-phase-handler/dm_phase_handler.h
@@ -0,0 +1,200 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ @file SyncSA_plugin_interface.h
+ @brief common interface for Sync Service Plug-in's
+
+ Define common interface that all sync service plugin have to define\n
+
+ */
+#ifndef SA_COMMON_INTERFACE_H_
+#define SA_COMMON_INTERFACE_H_
+
+/*dm-agent*/
+#include "common/dm_error.h"
+#include "serviceadapter/sa_command_internal.h"
+
+/**
+ * @par Description: API to Pkg1 and Pkg2 in OMA DM
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] transport Type (obex, http ...)
+ * @param[in] session session structure
+ * @param[in] pServer_id server id
+ * @param[in] pSession_id session id
+ * @param[in] pSession_type pSession type
+ * @param[in] Engine id service engine id
+ * @param[in] isFinish is Finish
+ * @param[in] isgeneicAlert is generic alert
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR setup_phase(int transportType, Session ** session, char *pServer_id, char *pSession_id, int session_type, ENGINE_ID * service_engine_id, int *isFinish, int isgenericAlert);
+
+/**
+ * @par Description: API to Pkg3 and Pkg4 in OMA DM
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] transport Type (obex, http ...)
+ * @param[in] session session structure
+ * @param[in] pSession_id session id
+ * @param[in] Engine id engine id
+ * @param[in] isFinish is Finish
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR management_phase(int transportType, Session ** session, char *pSession_id, ENGINE_ID * service_engine_id, int *isFinish);
+
+ /**
+ * @par Description: API to generic alert
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] transport Type (obex, http ...)
+ * @param[in] session session structure
+ * @param[in] pServer id server id
+ * @param[in] pSession_id session id
+ * @param[in] isFinish is Finish
+ * @param[in] isgeneticAlert isgeneticAlert
+ * @param[in] Engine id engine id
+ * @param[in] result is result
+ *
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR generic_alert(int transportType, Session ** session, char *pServer_id, char *session_id, int *isFinish, int isgeneticAlert, ENGINE_ID service_engine_status, int result);
+
+ /**
+ * @par Description: API to send msg oma sepc, syncml sepc
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] accType (obex, http ...)
+ * @param[in] transportType transportType
+ * @param[in] session session structure
+ * @param[in] header_info header_info
+ * @param[in] sendMsg sendMsg
+ * @param[in] sendMsg_length sendMsg_length
+ * @param[in] recvMsg recvMsg
+ * @param[in] recvMsg_length recvMsg_length
+ *
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR send_msg(char *accType, int transportType, Session ** session, GList * header_info, char *sendMsg, unsigned int sendMsg_length, GList ** recv_header, char **recvMsg, unsigned int *recvMsg_length);
+
+/**
+ * @par Description: API to receive msg form server
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session session structure
+ * @param[in] recvMsg recvMsg
+ * @param[in] recvMsg_length recvMsg_length
+ * @param[in] syncReturnObj syncReturnObj
+ * @param[in] isFinish isFinish
+ * @param[in] isgeneticAlert isgeneticAlert
+ *
+ *
+ * @return DM_OK on success
+ * DM_ERR_UNKNOWN or Other DM_ERROR
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR recv_msg(Session ** session, char *recvMsg, unsigned int recvMsg_length, ENGINE_ID * service_engine_id, int *isFinish, int isgeneticAlert);
+
+#endif /* SA_COMMON_INTERFACE_H_ */
diff --git a/include/serviceadapter/networkbinder/na_binder.h b/include/serviceadapter/networkbinder/na_binder.h
new file mode 100755
index 0000000..dd84869
--- /dev/null
+++ b/include/serviceadapter/networkbinder/na_binder.h
@@ -0,0 +1,93 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef NA_BINDER_H_
+#define NA_BINDER_H_
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "serviceadapter/sa_define.h"
+
+#define HTTP_X_SYNCML_HMAC "x-syncml-hmac"
+#define HTTP_COOKIE "cookie"
+
+/**
+ * @par Description: API to send msg oma sepc, syncml sepc
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] accType (obex, http ...)
+ * @param[in] loc_uri server url
+ * @param[in] sesion id session id
+ * @param[in] is_hmac is hmac
+ * @param[in] username username
+ * @param[in] list header list
+ *
+ *
+ * @return 1 success
+ * o fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int NA_http_header_binder(char *accType, char *loc_uri, char *sessionid, int isHMAC, char *username, char *mac, GList ** list);
+
+/**
+ * @par Description: API to send msg oma sepc, syncml sepc
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @param[in] receive header receive header
+ * @param[in] temp jsessionid temp jsession id
+ * @param[out] real jsession id real jsession id
+ * @param[out] other cookie other cookie (not use)
+ *
+ *
+ * @return 1 success
+ * o fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+int add_jsession_in_httpheader(GList * recv_header, char *temp_jsessionid, char **real_jsessionid, char **real_other_cookie);
+
+#endif /* NA_BINDER_H_ */
diff --git a/include/serviceadapter/protocolbinder/syncml_def.h b/include/serviceadapter/protocolbinder/syncml_def.h
new file mode 100755
index 0000000..195d1a4
--- /dev/null
+++ b/include/serviceadapter/protocolbinder/syncml_def.h
@@ -0,0 +1,153 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYNCML_DEFIINE_H_
+#define SYNCML_DEFIINE_H_
+
+/*
+ * Common Use Elements
+ */
+#define ELEMENT_CHAL "Chal"
+#define ELEMENT_CMD "Cmd"
+#define ELEMENT_CMDID "CmdID"
+#define ELEMENT_CMDREF "CmdRef"
+#define ELEMENT_CRED "Cred"
+#define ELEMENT_FINAL "Final"
+#define ELEMENT_LOCNAME "LocName"
+#define ELEMENT_LOCURI "LocURI"
+#define ELEMENT_MOREDATA "MoreData"
+#define ELEMENT_MSGID "MsgID"
+#define ELEMENT_MSGREF "MsgRef"
+#define ELEMENT_RESPURI "RespURI"
+#define ELEMENT_SESSIONID "SessionID"
+#define ELEMENT_SOURCE "Source"
+#define ELEMENT_SOURCEREF "SourceRef"
+#define ELEMENT_TARGET "Target"
+#define ELEMENT_TARGETREF "TargetRef"
+#define ELEMENT_VERDTD "VerDTD"
+#define ELEMENT_VERPROTO "VerProto"
+/*
+ * Msg Container Elements
+ */
+#define ELEMENT_SYNCML "SyncML"
+#define ELEMENT_SYNCHDR "SyncHdr"
+#define ELEMENT_SYNCBODY "SyncBody"
+/*
+ * Data Description Elements
+ */
+#define ELEMENT_DATA "Data"
+#define ELEMENT_ITEM "Item"
+#define ELEMENT_META "Meta"
+#define ELEMENT_CORRELATOR "Correlator"
+/*
+ * Meta Infomation Elements
+ */
+#define ELEMENT_EMI "EMI"
+#define ELEMENT_FORMAT "Format"
+#define ELEMENT_MAXMSGSIZE "MaxMsgSize"
+#define ELEMENT_MAXOBJSIZE "MaxObjSize"
+#define ELEMENT_METAINF "MetaInf"
+#define ELEMENT_NEXTNONCE "NextNonce"
+#define ELEMENT_SIZE "Size"
+#define ELEMENT_TYPE "Type"
+/*
+ * Protocol Mangement Elements
+ */
+#define ELEMENT_STATUS "Status"
+/*
+ * Protocol Command Elements
+ */
+#define ELEMENT_ADD "Add"
+#define ELEMENT_ATOMIC "Atomic"
+#define ELEMENT_COPY "Copy"
+#define ELEMENT_DELETE "Delete"
+#define ELEMENT_EXEC "Exec"
+#define ELEMENT_GET "Get"
+#define ELEMENT_REPLACE "Replace"
+#define ELEMENT_SEQUENCE "Sequence"
+#define ELEMENT_ALERT "Alert"
+#define ELEMENT_RESULTS "Results"
+/*
+ * VERDTD
+ * VERProto
+ */
+#define ELEMENT_VERDTD_10 "1.0"
+#define ELEMENT_VERDTD_11 "1.1"
+#define ELEMENT_VERDTD_12 "1.2"
+#define ELEMENT_VERPROTO_10 "DM/1.0"
+#define ELEMENT_VERPROTO_11 "DM/1.1"
+#define ELEMENT_VERPROTO_12 "DM/1.2"
+/*
+ *Authentication
+ */
+#define ELEMENT_AUTH_BASIC "syncml:auth-basic"
+#define ELEMENT_AUTH_MD5 "syncml:auth-md5"
+#define ELEMENT_AUTH_HMAC "syncml:auth-MAC"
+#define ELEMENT_FORMAT_BASE64 "b64"
+/*
+ * will delete
+ */
+#define ELEMENT_NUMBEROFCHANGES "NumberOfChanges"
+#define ELEMENT_LAST "Last"
+#define ELEMENT_NEXT "Next"
+
+#define ELEMENT_B64 "b64"
+#define ELEMENT_BIN "bin"
+#define ELEMENT_BOOL "bool"
+#define ELEMENT_CHR "chr"
+#define ELEMENT_INT "int"
+#define ELEMENT_NULL "null"
+#define ELEMENT_XML "xml"
+#define ELEMENT_DATE "date"
+#define ELEMENT_TIME "time"
+#define ELEMENT_FLOAT "float"
+#define ELEMENT_NODE "node"
+
+#define ELEMENT_TEXT_PLAIN "text/plain"
+
+typedef enum {
+ PE_UNDEF = 0,
+ PE_ERROR = 1,
+ PE_ADD = 2,
+ PE_ALERT = 3,
+ PE_ATOMIC_START = 4,
+ PE_ATOMIC_END = 5,
+ PE_COPY = 6,
+ PE_DELETE = 7,
+ PE_EXEC = 8,
+ PE_GET = 9,
+ PE_RESULTS_END = 10,
+ PE_RESULTS_START = 11,
+ PE_SEARCH = 12,
+ PE_SEQUENCE_START = 13,
+ PE_SEQUENCE_END = 14,
+ PE_STATUS = 15,
+ PE_SYNC_START = 16,
+ PE_SYNC_END = 17,
+ PE_REPLACE = 18,
+ PE_HEADER = 19,
+ PE_GENERIC = 20,
+ PE_FINAL = 21,
+ PE_SYNCML_START = 22,
+ PE_SYNCML_END = 23,
+ PE_BODY_START = 24,
+ PE_BODY_END = 25,
+ PE_SEQUENCE = 26,
+ PE_ATOMIC = 27
+} OMA_DM_Protocol_Element;
+
+#endif /* SYNCML_DEFIINE_H_ */
diff --git a/include/serviceadapter/protocolbinder/syncml_protocol_binder.h b/include/serviceadapter/protocolbinder/syncml_protocol_binder.h
new file mode 100755
index 0000000..22d4471
--- /dev/null
+++ b/include/serviceadapter/protocolbinder/syncml_protocol_binder.h
@@ -0,0 +1,310 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OMA_DS_PROTOCOL_BINDER_H_
+#define OMA_DS_PROTOCOL_BINDER_H_
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "serviceadapter/protocolbinder/syncml_def.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_syncml_binder_function_set(sync_agent_pb_protocol_binder_function_set_s ** pBinder_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_syncml_binder_function_set(sync_agent_pb_protocol_binder_function_set_s * pBinder_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 *syncml_binder_init(sync_agent_pb_protocol_binder_info_s * pBinder, sync_agent_pb_encoding_e enc, bool use_strtbl, bool use_flow_mode, sync_agent_pb_protocol_binder_function_set_s * pBinder_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 syncml_binder_append(sync_agent_pb_protocol_binder_info_s * pBinder, OMA_DM_Protocol_Element protocol_element, Content_Ptr pContent);
+
+/**
+ * @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 syncml_binder_terminate(sync_agent_pb_protocol_binder_info_s * pBinder);
+
+/**
+ * @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 syncml_binder_get_stream(sync_agent_pb_protocol_binder_info_s * pBinder, 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 syncml_binder_get_stream_size(sync_agent_pb_protocol_binder_info_s * pBinder, 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 syncml_binder_get_encoding(sync_agent_pb_protocol_binder_info_s * pBinder, 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_syncml_binder_init(char *byte_stream,
+ unsigned int byte_stream_len, sync_agent_pb_decoding_e dec, sync_agent_pb_protocol_binder_function_set_s * pBinder_function_set, void *user_data, sync_agent_pb_protocol_binder_reverse_info_s ** ppBinder);
+
+/**
+ * @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_syncml_binder_next(sync_agent_pb_protocol_binder_reverse_info_s * pBinder, Protocol_Element * protocol_element, char **protocol_element_name, Content_Ptr * pContent);
+
+#endif /* OMA_DS_PROTOCOL_BINDER_H_ */
diff --git a/include/serviceadapter/sa_command.h b/include/serviceadapter/sa_command.h
new file mode 100755
index 0000000..4d2f7bb
--- /dev/null
+++ b/include/serviceadapter/sa_command.h
@@ -0,0 +1,659 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SA_COMMAND_H_
+#define SA_COMMAND_H_
+
+/*dm-agent*/
+#include "common/dm_error.h"
+#include "serviceadapter/sa_define.h"
+
+/**
+ * @par Description: API to create add command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Session structure
+ * @param[in] Location structure(about source info)
+ * @param[in] string type, content type
+ * @param[in] string type, data value
+ * @param[in] int type, size
+ * @param[in] int type, moreData
+ * @param[out] Command 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
+ */
+DM_ERROR create_add_cmd(Session * session, char *luid, const char *contenttype, char *data, unsigned int size, int moreData, Command ** pCommand);
+
+/**
+ * @par Description: API to create delete command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Session structure
+ * @param[in] Location structure(about source info)
+ * @param[in] string type, content type
+ * @param[out] Command 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
+ */
+DM_ERROR create_delete_cmd(Session * session, char *luid, const char *contenttype, Command ** pCommand);
+
+/**
+ * @par Description: API to create alert command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Session structure
+ * @param[in] enum type, alert type
+ * @param[out] Command structure
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR create_alert_cmd(Session * session, AlertType syncType, Command ** pCommand);
+
+/**
+ * @par Description: API to create replace command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Session structure
+ * @param[out] Command structure
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR create_replace_cmd(Session * session, Command ** pCommand);
+
+/**
+ * @par Description: API to create result command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Session structure
+ * @param[out] Command structure
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR create_results_cmd(Session * session, Command ** pCommand);
+
+/**
+ * @par Description: API to create duplicate command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] source
+ * @param[out] target
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR duplicate_command(Command * source, Command ** target);
+
+/**
+ * @par Description: API to free commands
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] commnads
+ *
+ * @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
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Command structure
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_command(Command * pCommand);
+
+/**
+ * @par Description: API to free command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Command structure
+ * @param[in] string type, correlator
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR set_correlator(Command ** pAlertCommand, char *pCorrelator);
+
+/**
+ * @par Description: API to set result command msg ref
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Command structure
+ * @param[in] msg ref
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR set_resultscommand_msgref(Command * pCommand, unsigned int msgRef);
+
+/**
+ * @par Description: API to set result command cmd ref
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Command structure
+ * @param[in] msg ref
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR set_resultscommand_cmdref(Command * pCommand, unsigned int cmdRef);
+
+/**
+ * @par Description: API to set result command cmd ref
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Command structure
+ * @param[in] location target uri
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR set_resultscommand_targetref(Command * pCommand, Location * pLocation);
+
+/**
+ * @par Description: API to create new status location
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session structure
+ * @param[in] enum type, dm error
+ * @param[in] command structure
+ * @param[in] string type, loaction source uri
+ * @param[in] string type, location target uri
+ * @param[in] enum type, command type
+ * @param[out] status structure
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR create_newstatuslocation(Session * session, DM_ERROR data, Command * command, Location * sourceref, Location * targetref, CommandType type, Status ** pStatus);
+
+/**
+ * @par Description: API to create new status
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session structure
+ * @param[in] enum type, dm error
+ * @param[in] command structure
+ * @param[in] string type, loaction source uri
+ * @param[in] string type, location target uri
+ * @param[in] enum type, command type
+ * @param[in] status structure
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR create_newstatus(Session * session, DM_ERROR data, Command * command, Location * sourceref, Location * targetref, CommandType type, Status ** pStatus);
+
+/**
+ * @par Description: API to create new status location
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes: *
+ * @param[in] enum type, dm error
+ * @param[in] int type, cmd id
+ * @param[in] int type, msg ref
+ * @param[in] int type, cmd ref
+ * @param[in] string type, location source ref
+ * @param[in] string type, location target ref
+ * @param[in] chalenge structure
+ * @param[in] enum type, commadn type
+ * @param[out] status structure
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR create_status(DM_ERROR data, unsigned int cmdID, unsigned int msgref, unsigned int cmdref, Location * sourceref, Location * targetref, Chal * pChal, CommandType type, Status ** pStatus);
+
+/**
+ * @par Description: API to create new status location
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes: *
+ * @param[in] session structure
+ * @param[in] command structure
+ * @param[in] item structure
+ * @param[in] enum type, dm error
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR set_status_data(Session * session, Command * pCommand, Item * item, DM_ERROR data);
+
+/**
+ * @par Description: API to free status list
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes: *
+ * @param[in] status list
+ *
+ * @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
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes: *
+ * @param[in] status
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_status(Status * status);
+
+/**
+ * @par Description: API to get status code
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes: *
+ * @param[out] status
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR get_statuscode(Status * status);
+
+/**
+ * @par Description: API to convert int type to change type
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes: *
+ * @param[in] type
+ *
+ * @return enum type, ChangeType
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+ChangeType converttochangetype(unsigned int type);
+
+/**
+ * @par Description: API to convert change type to int type
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes: *
+ * @param[in] type
+ *
+ * @return int type, int
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+unsigned int convertfromchangetype(ChangeType changeType);
+
+/**
+ * @par Description: API to convert string type to command type
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes: *
+ * @param[in] string type, type
+ *
+ * @return CommandType
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+CommandType converttocommandtype(char *type);
+
+/**
+ * @par Description: API to convert command type to string
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes: *
+ * @param[in] string type, type
+ *
+ * @return string type, string
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+char *convertfromcommandtype(CommandType type);
+
+#endif /* SA_COMMAND_H_ */
diff --git a/include/serviceadapter/sa_command_internal.h b/include/serviceadapter/sa_command_internal.h
new file mode 100755
index 0000000..2c38ffb
--- /dev/null
+++ b/include/serviceadapter/sa_command_internal.h
@@ -0,0 +1,94 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SA_COMMAND_INTERNAL_H_
+#define SA_COMMAND_INTERNAL_H_
+
+/*dm-agent*/
+#include "serviceadapter/sa_define.h"
+
+typedef struct CommandAlertPrivate {
+ AlertType type;
+ unsigned int maxObjSize;
+ /*Item *item; */
+ GList *items;
+ char *Correlator;
+} CommandAlertPrivate;
+
+typedef struct CommandAccessPrivate {
+ char *type;
+ GList *items;
+} CommandAccessPrivate;
+
+typedef struct CommandChangePrivate {
+ GList *items;
+ ChangeType type;
+} CommandChangePrivate;
+
+typedef struct CommandResultsPrivate {
+ unsigned int msgRef;
+ unsigned int cmdRef;
+ Location *targetRef;
+ char *type;
+ GList *items;
+} CommandResultsPrivate;
+
+typedef struct CommandExecPrivate {
+ char *correlator;
+ Item *item;
+} CommandExecPrivate;
+
+typedef struct CommandSequence_AtomicPrivate {
+ GList *commands;
+} CommandSequence_AtomicPrivate;
+
+typedef union CommandPrivate {
+ CommandAlertPrivate alert;
+ CommandAccessPrivate access; /*get */
+ CommandChangePrivate change; /*add, delete, replace */
+ CommandResultsPrivate results;
+ CommandExecPrivate exec;
+ CommandSequence_AtomicPrivate sequence_atomic;
+
+} CommandPrivate;
+
+struct Command {
+ int refCount;
+ CommandType type;
+ unsigned int cmdID;
+ unsigned int msgID;
+ CommandPrivate private;
+ Location *source;
+ Location *target;
+ int noResp;
+};
+
+struct Status {
+ unsigned int cmdID;
+ unsigned int msgRef;
+ unsigned int cmdRef;
+ CommandType type;
+ char *data;
+ Location *sourceRef;
+ Location *targetRef;
+ Cred *cred;
+ Chal *chal;
+ GList *items;
+ //Item *item;
+};
+
+#endif /* SA_COMMAND_INTERNAL_H_ */
diff --git a/include/serviceadapter/sa_define.h b/include/serviceadapter/sa_define.h
new file mode 100755
index 0000000..d5b6d67
--- /dev/null
+++ b/include/serviceadapter/sa_define.h
@@ -0,0 +1,212 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SA_DEFINE_H_
+#define SA_DEFINE_H_
+
+/*lib*/
+#include <malloc.h>
+#include <glib.h>
+#include <assert.h>
+#include <string.h>
+#include <stdbool.h>
+
+#define ELEMENT_WBXML "wbxml"
+#define ELEMENT_XML "xml"
+
+#define ELEMENT_DM_WBXML "application/vnd.syncml.dm+wbxml"
+#define ELEMENT_DM_XML "application/vnd.syncml.dm+xml"
+
+#define ELEMENT_DMTNDS_WBXML "application/vnd.syncml.dmtnds+wbxml"
+#define ELEMENT_DMTNDS_XML "application/vnd.syncml.dmtnds+xml"
+
+/*
+#define ELEMENT_AUTH_BASIC "syncml:auth-basic"
+#define ELEMENT_AUTH_MD5 "syncml:auth-md5"
+#define ELEMENT_FORMAT_BASE64 "b64"
+*/
+
+#define ELEMENT_HTTP_BASIC "HTTP_BASIC"
+#define ELEMENT_HTTP_DIGEST "HTTP_DIGEST"
+#define ELEMENT_BASIC "BASIC"
+#define ELEMENT_DIGEST "DIGEST"
+#define ELEMENT_HMAC "HMAC"
+#define ELEMENT_X509 "X509"
+#define ELEMENT_SECURID "SECURID"
+#define ELEMENT_SAFEWORD "SAFEWORD"
+#define ELEMENT_DIGIPASS "DIGIPASS"
+#define ELEMENT_TRANSPORT "TRANSPORT"
+
+#define ELEMENT_DEFAULT_CLIENT_NONCE "MTIzNDU="
+
+#define ELEMENT_STRUCT "?list=Struct"
+#define ELEMENT_STRUCTDATA "?list=StructData"
+#define ELEMENT_TNDS "?list=TNDS"
+#define ELEMENT_PROPERTY "?prop"
+
+#define ELEMENT_PROP_ACL "?prop=ACL"
+#define ELEMENT_PROP_SIZE "?prop=Size"
+#define ELEMENT_PROP_TYPE "?prop=Type"
+#define ELEMENT_PROP_NAME "?prop=Name"
+#define ELEMENT_PROP_FORMAT "?prop=Format"
+
+#define ELEMENT_TEXTPLAIN "text/plain"
+
+#define DEFAULT_MAX_MSG_SIZE 1024*12
+#define DEFAULT_MAX_OBJ_SIZE 1024*1024
+
+#define DEFAULT_REST_SIZE 300
+#define DEFAULT_MORE_REST_SIZE 500
+
+typedef struct Item Item;
+typedef struct Status Status;
+typedef struct Command Command;
+typedef struct Location Location;
+typedef struct Cred Cred;
+typedef struct SyncML SyncML;
+typedef struct SyncHdr SyncHdr;
+typedef struct Chal Chal;
+typedef struct Hmac Hmac;
+typedef struct Session Session;
+typedef struct PendingStatus PendingStatus;
+
+typedef enum {
+ VERSION_UNKNOWN = 0,
+ VERSION_10 = 1,
+ VERSION_11 = 2,
+ VERSION_12 = 3
+} ProtocolVersion;
+
+typedef enum {
+ PROTOCOL_TYPE_UNKNOWN = 0,
+ PROTOCOL_TYPE_DS = 1,
+ PROTOCOL_TYPE_DM = 2
+} ProtocolType;
+
+typedef enum {
+ COMMAND_TYPE_UNKNOWN = 0,
+ COMMAND_TYPE_ALERT = 1,
+ COMMAND_TYPE_HEADER = 2,
+ COMMAND_TYPE_ADD = 3,
+ COMMAND_TYPE_REPLACE = 4,
+ COMMAND_TYPE_DELETE = 5,
+ COMMAND_TYPE_GET = 6,
+ COMMAND_TYPE_RESULTS = 7,
+ COMMAND_TYPE_EXEC = 8,
+ COMMAND_TYPE_SEQUENCE = 9,
+ COMMAND_TYPE_ATOMIC = 10,
+ COMMAND_TYPE_COPY = 11
+} CommandType;
+
+typedef enum {
+ GET_TYPE_NOMAL,
+ GET_TYPE_STRUCT,
+ GET_TYPE_STRUCTDATA,
+ GET_TYPE_TNDS,
+ GET_PROPERTY,
+ GET_TYPE_ACL_PROP,
+ GET_TYPE_SIZE_PROP,
+ GET_TYPE_TYPE_PROP,
+ GET_TYPE_FORMAT_PROP,
+ GET_TYPE_NAME_PROP
+} GetType;
+
+typedef enum {
+ PROP_TYPE_ACL,
+ PROP_TYPE_SIZE,
+ PROP_TYPE_TYPE,
+ PROP_TYPE_FORMAT,
+ PROP_TYPE_NAME
+} propoerty_type;
+
+typedef enum {
+ AUTH_TYPE_UNKNOWN = 0,
+ AUTH_TYPE_HTTP_BASIC,
+ AUTH_TYPE_HTTP_DIGEST,
+ AUTH_TYPE_BASIC,
+ AUTH_TYPE_MD5,
+ AUTH_TYPE_HMAC,
+ AUTH_TYPE_X509,
+ AUTH_TYPE_SECURID,
+ AUTH_TYPE_SAFEWORD,
+ AUTH_TYPE_DIGIPASS,
+ AUTH_TYPE_TRANSPORT
+} AuthType;
+
+#if defined (_OMA_DM_V12_)
+
+typedef enum {
+ AUTH_LEVEL_NONE,
+ AUTH_LEVEL_CLCRED,
+ AUTH_LEVEL_SRVCRED,
+ AUTH_LEVEL_OBEX,
+ AUTH_LEVEL_HTTP
+} AAUTHLEVEL;
+
+#endif
+
+typedef enum {
+ FORMAT_TYPE_UNKNOWN = 0,
+ FORMAT_TYPE_BASE64 = 1
+} FormatType;
+
+typedef enum {
+ SYNCML_PKG_1 = 1,
+ SYNCML_PKG_2 = 2,
+ SYNCML_PKG_3 = 3,
+ SYNCML_PKG_4 = 4
+} PkgStatus;
+
+typedef enum {
+ ITEM_UNKNOWN = 0,
+ ITEM_DATA = 1
+} ItemDataType;
+
+typedef enum {
+ ALERT_UNKNOWN = 0,
+
+ /*User interaction alert codes */
+ DM_ALERT_DISPLAY = 1100,
+ DM_ALERT_CONFIRM_OR_REJECT = 1101,
+ DM_ALERT_TEXT_INPUT = 1102,
+ DM_ALERT_SINGLE_CHOICE = 1103,
+ DM_ALERT_MULTIPLE_CHOICE = 1104,
+ /*reversed syncml 1105~1199 */
+
+ /*Device management session alert codes */
+ DM_ALERT_SERVER_INITIATED_MGMT = 1200,
+ DM_ALERT_CLIENT_INITIATED_MGMT = 1201,
+ /*reversed syncml 1202~1220 */
+
+ /*Special device management alert codes */
+ DM_ALERT_NEXT_MESSAGE = 1222,
+ DM_ALERT_SESSION_ABORT = 1223,
+ DM_ALERT_CLIENT_EVENT = 1224,
+ DM_ALERT_NO_END_OF_DATA = 1225,
+ DM_ALERT_GENERIC_ALERT = 1226
+ /*reversed syncml 1227~1299 */
+} AlertType;
+
+typedef enum {
+ CHANGE_UNKNOWN = 0,
+ CHANGE_ADD = 1,
+ CHANGE_REPLACE = 2,
+ CHANGE_DELETE = 3,
+ CHANGE_COPY = 4
+} ChangeType;
+
+#endif /* SA_DEFINE_H_ */
diff --git a/include/serviceadapter/sa_elements.h b/include/serviceadapter/sa_elements.h
new file mode 100755
index 0000000..9bb4757
--- /dev/null
+++ b/include/serviceadapter/sa_elements.h
@@ -0,0 +1,775 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SA_ELEMENTS_H_
+#define SA_ELEMENTS_H_
+
+/*dm-agent*/
+#include "common/dm_error.h"
+#include "serviceadapter/sa_define.h"
+
+/**
+ * @par Description: API to create hmac
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, auth name
+ * @param[in] string type, auth type
+ * @param[out] session structure
+ *
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR create_hmac(char *auth_name, char *auth_type, char *mac, Session ** session);
+
+/**
+ * @par Description: API to create location
+ *
+ *
+ * @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 structure
+ *
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR create_location(const char *locURI, const char *locName, Location ** pLocation);
+
+/**
+ * @par Description: API to duplicate location
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[out] location structure
+ *
+ *
+ * @return location structure
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+Location *dup_location(Location * pLocation);
+
+/**
+ * @par Description: API to get location name
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[out] location structure
+ *
+ *
+ * @return location name
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+char *get_location_locname(Location * location);
+
+/**
+ * @par Description: API to get location uri
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[out] location structure
+ *
+ *
+ * @return location uri
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+char *get_location_locuri(Location * location);
+
+/**
+ * @par Description: API to free location
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] location structure
+ *
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_location(Location * loc);
+
+/**
+ * @par Description: API to free cred
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[out] cred structure
+ *
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_cred(Cred * cred);
+
+/**
+ * @par Description: API to create auth cred
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, user name
+ * @param[in] enum type, AuthType
+ * @param[in] enum type, FormatType
+ * @param[in] string type, data
+ * @param[out] cred structure
+ *
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR create_auth_cred(char *userName, char *pwd, AuthType authType, FormatType formatType, char *data, Cred ** cred);
+
+/**
+ * @par Description: API to create cred with data
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] enum type, AuthType
+ * @param[in] string type, data
+ *
+ *
+ * @return Cred structure
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+Cred *create_credwithdata(AuthType authType, char *data);
+
+/**
+ * @par Description: API to set cred format type
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Cred structure
+ * @param[in] enum type, format type
+ *
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_credformattype(Cred * cred, FormatType formatType);
+
+/**
+ * @par Description: API to check server cred
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Cred structure
+ * @param[in] session structure
+ *
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fial
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR check_server_cred(Cred * hdrCred, Session * session); // Cred *sessionCred);
+
+/**
+ * @par Description: API to create challenge
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] enum type, format type
+ * @param[in] enum type, auth type
+ * @param[in] string type, next nonce
+ * @param[in] chanlenge stturcture
+ *
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fial
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR create_chal(FormatType format, AuthType type, char *nextnonce, Chal ** pChal);
+
+/**
+ * @par Description: API to free challenge
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] challenge structure
+ *
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_chal(Chal * pChal);
+
+/**
+ * @par Description: API to duplicate chalenge
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] challenge structure
+ *
+ *
+ * @return challenge structure
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+Chal *dup_chal(Chal * pChal);
+
+/**
+ * @par Description: API to free challenge
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] challenge structure
+ *
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_hmac(Hmac * hmac);
+
+/**
+ * @par Description: API to convert to string to auth type
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, auth type
+ *
+ *
+ * @return AuthType
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+AuthType converttoauthtype(char *authType);
+
+/**
+ * @par Description: API to convert to string to format type
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, format type
+ *
+ *
+ * @return FormatType
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+FormatType converttoformattype(char *formatType);
+
+/**
+ * @par Description: API to construct item
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, source uri
+ * @param[in] string type, source uri
+ * @param[in] string type, format
+ * @param[in] string type, contenttype
+ * @param[in] string type, data
+ * @param[in] int type, size
+ * @param[in] int type, moredata
+ * @param[out] item structure
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR construct_Item(char *sourceUrl, const char *format, const char *contenttype, const char *data, unsigned int size, int moreData, Item ** pItem);
+
+/**
+ * @par Description: API to construct item
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ *
+ * @return item structure
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+Item *create_Item();
+
+/**
+ * @par Description: API to construct item
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, data
+ * @param[in] int type, size
+ * @param[out] item structure
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR create_item_data(char *data, unsigned int size, Item ** pItem);
+
+/**
+ * @par Description: API to set item target uri
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] item structure
+ * @param[in] location structure
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_itemtarget(Item * item, Location * target);
+
+/**
+ * @par Description: API to set item source uri
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] item structure
+ * @param[in] location structure
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_itemsource(Item * item, Location * source);
+
+/**
+ * @par Description: API to free item
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] item structure
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_Item(Item * item);
+
+/**
+ * @par Description: API to create syncml
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync header structure
+ * @param[in] status list
+ * @param[in] command list
+ * @param[in] int type is final
+ * @param[out] syncml structure
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR create_syncml(SyncHdr * syncHdr, GList * status, GList * commands, int isFinal, SyncML ** pSyncML);
+
+/**
+ * @par Description: API to free syncml
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] syncml structure
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_syncml(SyncML * syncML);
+
+/**
+ * @par Description: API to create syncml header
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session structure
+ * @param[out] sync header
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR create_syncml_hdr(Session * session, SyncHdr ** pSyncHdr);
+
+/**
+ * @par Description: API to free syncml header
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] sync header
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_synchdr(SyncHdr * syncHdr);
+
+#endif /* SA_ELEMENTS_H_ */
diff --git a/include/serviceadapter/sa_elements_internal.h b/include/serviceadapter/sa_elements_internal.h
new file mode 100755
index 0000000..f4cb496
--- /dev/null
+++ b/include/serviceadapter/sa_elements_internal.h
@@ -0,0 +1,90 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SA_ELEMENTS_INTERNAL_H_
+#define SA_ELEMENTS_INTERNAL_H_
+
+/*dm-agent*/
+#include "serviceadapter/sa_define.h"
+
+typedef union ItemData {
+ char *data;
+} ItemData;
+
+struct Hmac {
+ char *authtype;
+ char *username;
+ char *mac;
+};
+
+struct Chal {
+ FormatType format;
+ AuthType type;
+ char *nonce_plain;
+ unsigned int nonce_length;
+ char *nonce_b64;
+};
+
+struct Item {
+ ItemDataType dataType;
+ ItemData private;
+ Location *source;
+ Location *target;
+
+ unsigned int size; //-> for data
+ char *contenttype; //-> for data
+ char *format;
+ int moreData; //-> for moredata
+};
+
+struct Location {
+ char *locURI;
+ char *locName;
+};
+
+struct Cred {
+ FormatType format;
+ AuthType type;
+ char *data;
+ char *username;
+ char *password;
+};
+
+struct SyncHdr {
+ char *sessionID;
+ ProtocolVersion version;
+ ProtocolType protocol;
+ Location *source;
+ Location *target;
+ Cred *cred;
+ char *responseURI;
+ unsigned int messageID;
+
+ //in meta element
+ unsigned int maxmsgsize;
+ unsigned int maxobjsize;
+ //char *emi;(?) // Experimental Meta Information
+};
+
+struct SyncML {
+ SyncHdr *hdr;
+ GList *status; /**< containing Status struct */
+ GList *commands; /**< containing Command struct */
+ int final;
+};
+
+#endif /* SA_ELEMENTS_INTERNAL_H_ */
diff --git a/include/serviceadapter/sa_session.h b/include/serviceadapter/sa_session.h
new file mode 100755
index 0000000..84dd166
--- /dev/null
+++ b/include/serviceadapter/sa_session.h
@@ -0,0 +1,331 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SA_SESSION_H_
+#define SA_SESSION_H_
+
+/*dm-agent*/
+#include "common/dm_error.h"
+#include "serviceadapter/sa_define.h"
+
+/**
+ * @par Description: API to create Session structure
+ * This API can be used to create Session 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_DM)
+ * @param[in] string type, server id
+ * @param[in] string type, client id
+ * @param[in] string type, session id
+ * @param[in] string type, source uri(server ip)
+ * @param[in] string type, target uri(client identifer)
+ * @param[out] Session structure
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR create_syncml_session(ProtocolVersion protocolVersion, ProtocolType protocolType, char *server_id, char *client_id, char *pSession_id, char *sourceUrl, char *targetUrl, Session ** pSession);
+
+/**
+ * @par Description: API to free Session structure
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Session structure
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void free_session(Session * session);
+
+/**
+ * @par Description: API to receivce header
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Session structure
+ * @param[in] syncml header structure
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR receive_header(Session * session, SyncHdr * header);
+
+/**
+ * @par Description: API to receivce header
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Session structure
+ * @param[in] receive status list
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR receive_statuses(Session * session, GList * receiveStatus);
+
+/**
+ * @par Description: API to receivce command
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Session structure
+ * @param[in] receive command list
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR receive_cmd(Session * session, GList * receiveCommand);
+
+/**
+ * @par Description: API to create prepending status
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] int type, msg id
+ * @param[in] int type, command id
+ * @param[out] pending status structure
+ *
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR create_prependingstatus(unsigned int msgID, unsigned int cmdID, PendingStatus ** pPendingStatus);
+
+/**
+ * @par Description: API to set auth cred
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session structure
+ * @param[in] cred structure
+ *
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR set_session_authcred(Session * session, Cred * cred);
+
+/**
+ * @par Description: API to reset command id
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session structure
+ *
+ *
+ * @return
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void reset_cmdid_session(Session * session);
+
+/**
+ * @par Description: API to add response hmac info
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] session structure
+ * @param[in] string type, temp hmac
+ *
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR add_response_hmacinfo(Session ** session, char *temp_hmac);
+/*DM_ERROR get_session_clientauthtype(Session * session, AuthType * authType);
+DM_ERROR get_session_serverauthtype(Session * session, AuthType * authType);*/
+
+/**
+ * @par Description: API to get session authtype
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, auth data
+ *
+ *
+ * @return Auth type
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+AuthType __get_Session_AuthType_enum(char *data);
+
+/**
+ * @par Description: API to get session authname
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] enum type, Auth type
+ * @param[out] string type, auth name
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void __set_Session_AuthType_name(AuthType authType, char **authname);
+
+#endif /* SE_SESSION_H_ */
diff --git a/include/serviceadapter/sa_session_internal.h b/include/serviceadapter/sa_session_internal.h
new file mode 100755
index 0000000..69022a9
--- /dev/null
+++ b/include/serviceadapter/sa_session_internal.h
@@ -0,0 +1,78 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SA_SESSION_INTERNAL_H_
+#define SA_SESSION_INTERNAL_H_
+
+/*dm-agent*/
+#include "common/dm_common_def.h"
+#include "serviceadapter/sa_define.h"
+
+struct Session {
+ ProtocolVersion protocolVersion;
+ ProtocolType protocolType;
+
+ char *sessionID;
+ unsigned int msgID;
+ unsigned int lastRecievedMsgID;
+ unsigned int cmdID;
+ int isSendingfinal;
+ int isReceivingFinal;
+
+ GList *status; //status to return to server
+ GList *tempStatus; //temp status for sync add, replace, delete command(it does not have data element value)
+
+ Location *target;
+ Location *source;
+ Location *orgTarget;
+
+ unsigned int sourceMaxMsgSize;
+ unsigned int sourceMaxObjSize;
+
+ unsigned int targetMaxMsgSize;
+ unsigned int targetMaxObjSize;
+
+ int accountId;
+
+ char *pServer_id; //server id
+ ENGINE_ID service_engine_id; //service engine id
+
+ Cred *cred; //account info
+ Chal *res_chal; //res_chal from server to client
+ Chal *req_chal; //req_chal from clinet to server
+
+ int isHMAC; //using HMAC authentication
+ Hmac *reqhmacinfo; //hmac info for http header
+ Hmac *resphmacinfo; //hmac info for http header
+
+ char *jsessionid; //lawmo jsession
+ char *other_cookie;
+ GList *pendingStatus; //containing pendingStatus structure ->msgid and cmd id that sent to server
+
+ Command *pLargeObjCmd; //for incomming large Command
+ GList *alertCommand; //containing alert command that have to send to server
+ GList *resultsCommand; //containing results command
+
+};
+
+struct PendingStatus {
+ unsigned int cmdID;
+ unsigned int msgID;
+ // callback;
+ //userdata;
+};
+#endif /* SA_SESSION_INTERNAL_H_ */
diff --git a/include/serviceadapter/sa_syncml_binders.h b/include/serviceadapter/sa_syncml_binders.h
new file mode 100755
index 0000000..b3721e4
--- /dev/null
+++ b/include/serviceadapter/sa_syncml_binders.h
@@ -0,0 +1,83 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SA_BINDERS_H_
+#define SA_BINDERS_H_
+
+/*dm-agent*/
+#include "common/dm_error.h"
+#include "serviceadapter/sa_define.h"
+
+/**
+ * @par Description: API to create syncml object binder
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] Syncml structure
+ * @param[out] string type, msg
+ * @param[out] msg size
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR syncml_objectbinder(SyncML * pSyncML, char **msg, unsigned int *msg_size);
+
+/**
+ * @par Description: API to reverse syncml object binder
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[out] Syncml structure
+ * @param[out] string type, recieve msg
+ * @param[out] int type, recieve msg size
+ * @param[out] string type, xml
+ * @param[out] int type, xml size
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR reverse_syncml_objectbinder(SyncML ** pSyncML, char *recv_msg, unsigned int recv_msg_length, char **xml, unsigned int *xml_len);
+
+#endif /* SA_BINDERS_H_ */
diff --git a/include/serviceadapter/sa_util.h b/include/serviceadapter/sa_util.h
new file mode 100755
index 0000000..55d9f79
--- /dev/null
+++ b/include/serviceadapter/sa_util.h
@@ -0,0 +1,171 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SA_UTIL_H_
+#define SA_UTIL_H_
+
+/*dm-agent*/
+#include "common/dm_error.h"
+#include "serviceadapter/sa_define.h"
+
+/**
+ * @par Description: API to create auth credstring
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] command list
+ * @param[in] command last list value
+ * @param[in] command structure
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void putCmdIntoList(GList ** commands, GList ** commands_last, void *pCommand);
+
+/**
+ * @par Description: API to create auth credstring
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] enum type, auth type
+ * @param[in] string type, user name
+ * @param[in] string type, password
+ * @param[in] string type, nonce
+ * @param[in] int type, nonce size
+ * @param[out] string type, cred string
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR create_auth_credString(AuthType type, const char *username, const char *password, const unsigned char *nonce, const unsigned int nonce_size, char **pCred);
+
+/**
+ * @par Description: API to generate hmac
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, user name
+ * @param[in] string type, password
+ * @param[in] string type, nonce
+ * @param[in] string type, msg
+ * @param[in] int type, msg size
+ * @param[out] string type, hmac
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR gemerate_hmac(char *username, char *password, unsigned char *nonce, unsigned int nonce_size, char *msg, unsigned int msg_size, char **mac);
+
+/**
+ * @par Description: API to find string value
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, original string
+ * @param[in] string type, find param
+ * @param[in] string type, find seperator
+ * @param[out] string type, find value
+ *
+ * @return DM_OK on success
+ * DM_ERROR on fail
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+DM_ERROR findStgringValue(char *original, char *findParam, char *findSep, char **findValue);
+
+/**
+ * @par Description: API to set xml to file
+ *
+ *
+ * @par Purpose:
+ * @par Typical use case:
+ * @par Method of function operation:
+ * @par Important notes:
+ * @param[in] string type, xml
+ * @param[in] string type, path
+ *
+ * @return
+ *
+ *
+ * @par Errors:
+ *
+ * @pre None.
+ * @post
+ * @see
+ * @remarks None.
+ *
+ * @par Sample Code:
+ * @code
+ * @endcode
+ */
+void set_xml_to_file(char *xml, const char *path);
+
+#endif /* SA_UTIL_H_ */
diff --git a/oma-dm b/oma-dm
new file mode 100755
index 0000000..da98b8f
--- /dev/null
+++ b/oma-dm
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+DESC="OMA DM agent daemon"
+NAME=oma-dm-agent
+DAEMON=/usr/bin/$NAME
+SCRIPTNAME=/etc/init.d/oma-dm
+
+[ -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/data/fota/oma-dm/.oma-dm-agent-enabled ]; then
+ do_start
+ prt_res $?
+ else
+ echo "don't exist oma-dm-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-dm-agent.manifest b/oma-dm-agent.manifest
new file mode 100755
index 0000000..cc890d2
--- /dev/null
+++ b/oma-dm-agent.manifest
@@ -0,0 +1,37 @@
+<manifest>
+ <define>
+ <domain name="oma-dm-agent" />
+ <provide>
+ <label name="oma-dm-agent::cfg" />
+ <label name="oma-dm-agent::ddf" />
+ <label name="oma-dm-agent::db" />
+ </provide>
+ </define>
+ <assign>
+ <filesystem path="/usr/share/oma_dm_cfg/csc_setting/change_csc_value.sh" label="oma-dm-agent::cfg"/>
+ <filesystem path="/usr/share/oma_dm_cfg/fw_init/omadmAdminUI_fw_config.xml" label="oma-dm-agent::cfg"/>
+ <filesystem path="/usr/share/oma_dm_cfg/fw_init/omadmAlertUI_fw_config.xml" label="oma-dm-agent::cfg"/>
+ <filesystem path="/usr/share/oma_dm_cfg/fw_init/omadmCPUI_fw_config.xml" label="oma-dm-agent::cfg"/>
+ <filesystem path="/usr/share/oma_dm_cfg/fw_init/omadmFotaUI_fw_config.xml" label="oma-dm-agent::cfg"/>
+ <filesystem path="/usr/share/oma_dm_cfg/fw_init/omadmNotiUI_fw_config.xml" label="oma-dm-agent::cfg"/>
+ <filesystem path="/usr/share/oma_dm_cfg/fw_init/omadmDmaccUI_fw_config.xml" label="oma-dm-agent::cfg"/>
+ <filesystem path="/usr/share/oma_dm_cfg/fw_init/omadm_fw_config.xml" label="oma-dm-agent::cfg"/>
+ <filesystem path="/usr/share/oma_dm_cfg/imei_setting/change_imei_callnum.sh" label="oma-dm-agent::cfg"/>
+ <filesystem path="/usr/share/oma_dm_cfg/ipc/eventconfig_omadm" label="oma-dm-agent::cfg"/>
+ <filesystem path="/usr/share/oma_dm_cfg/ipc/noticonfig_omadm" label="oma-dm-agent::cfg"/>
+ <filesystem path="/usr/share/oma_dm_cfg/ddf/slp/slp_DEVDETAIL_DDF.xml" label="oma-dm-agent::ddf"/>
+ <filesystem path="/usr/share/oma_dm_cfg/ddf/slp/slp_DEVINFO_DDF.xml" label="oma-dm-agent::ddf"/>
+ <filesystem path="/usr/share/oma_dm_cfg/ddf/slp/slp_FUMO_DDF.xml" label="oma-dm-agent::ddf"/>
+ <filesystem path="/usr/share/oma_dm_cfg/ddf/slp/slp_LAWMO_PCW_DDF.xml" label="oma-dm-agent::ddf"/>
+ <filesystem path="/usr/share/oma_dm_cfg/ddf/slp/slp_MSCTestserver_DMACC_DDF_1.2.xml" label="oma-dm-agent::ddf"/>
+ <filesystem path="/usr/share/oma_dm_cfg/ddf/slp/slp_MSCserver_DMACC_DDF_1.2.xml" label="oma-dm-agent::ddf"/>
+ <filesystem path="/usr/share/oma_dm_cfg/ddf/slp/slp_gcf_DMACC_DDF_1.2.xml" label="oma-dm-agent::ddf"/>
+ <filesystem path="/usr/share/oma_dm_cfg/ddf/slp_gcf_dmacc_ddf.txt" label="oma-dm-agent::ddf"/>
+ <filesystem path="/usr/share/oma_dm_cfg/ddf/slp_mscserver_dmacc_ddf.txt" label="oma-dm-agent::ddf"/>
+ <filesystem path="/usr/share/oma_dm_cfg/ddf/slp_msctestserver_dmacc_ddf.txt" label="oma-dm-agent::ddf"/>
+ <filesystem path="/usr/share/oma_dm_cfg/ddf/slp_ddfs.txt" label="oma-dm-agent::ddf"/>
+ </assign>
+ <request>
+ <domain name="oma-dm-agent" />
+ </request>
+</manifest>
diff --git a/oma-dm-cfg/csc-setting/change_csc_value.sh b/oma-dm-cfg/csc-setting/change_csc_value.sh
new file mode 100755
index 0000000..7ae0391
--- /dev/null
+++ b/oma-dm-cfg/csc-setting/change_csc_value.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+
+vconftool set -t int -f db/SyncML/oma-dm-service/DevManagement/NbDevManagement 1
+
+
+##gcf test server
+vconftool set -t string -f db/SyncML/oma-dm-service/DevManagement/1/AccName "gcf"
+vconftool set -t string -f db/SyncML/oma-dm-service/DevManagement/1/ServID "RSate"
+vconftool set -t string -f db/SyncML/oma-dm-service/DevManagement/1/ServAddr "http://192.168.168.169/dm"
+vconftool set -t string -f db/SyncML/oma-dm-service/DevManagement/1/ServPwd "RSatepass"
+vconftool set -t string -f db/SyncML/oma-dm-service/DevManagement/1/ServNonce ""
+vconftool set -t string -f db/SyncML/oma-dm-service/DevManagement/1/ClientNonce ""
+vconftool set -t int -f db/SyncML/oma-dm-service/DevManagement/1/AuthType 1
+vconftool set -t int -f db/SyncML/oma-dm-service/DevManagement/1/Port 80
+
diff --git a/oma-dm-cfg/ddf/slp/slp_devdetail_ddf.xml b/oma-dm-cfg/ddf/slp/slp_devdetail_ddf.xml
new file mode 100644
index 0000000..293fd19
--- /dev/null
+++ b/oma-dm-cfg/ddf/slp/slp_devdetail_ddf.xml
@@ -0,0 +1,281 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--DOCTYPE MgmtTree PUBLIC "-//OMA//DTD-DM-DDF 1.2//EN" http://www.openmobilealliance.org/tech/DTD/OMA-TS-DM-DDF-V1_2_0.dtd -->
+<MgmtTree>
+ <VerDTD>1.2</VerDTD>
+ <Man>Samsung Electronics</Man>
+ <Mod>GT-I9500</Mod>
+ <Node>
+ <NodeName>DevDetail</NodeName>
+ <!--The '.' shows that this node is located immediately under the root.-->
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>The interior node holding all DevDetail nodes</DFTitle>
+ <DFType>
+ <DDFName></DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>Ext</NodeName>
+ <!--There are no further items here at the moment.-->
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>The extendable DevDetail branch.</DFTitle>
+ <DFType>
+ <DDFName></DDFName>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Bearer</NodeName>
+ <!--There are no further items here at the moment.-->
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>The bearer specific DevDetail branch.</DFTitle>
+ <DFType>
+ <DDFName></DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>GSM</NodeName>
+ <!--There are no further items here at the moment.-->
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <char/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>The bearer specific DevInfo branch.</DFTitle>
+ <DFType>
+ <DDFName></DDFName>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>URI</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>The tree limitations branch.</DFTitle>
+ <DFType>
+ <DDFName></DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>MaxDepth</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <Description>Maximum tree depth supported by the device.</Description>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Maximum tree depth</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MaxTotLen</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <Description>Maximum total URI length supported by the device.</Description>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Maximum URI length</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MaxSegLen</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <Description>Maximum URI segment length supported by the device.</Description>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Maximum URI segment length</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>DevTyp</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <!--Here the manufacturer must fill in the type of the device.-->
+ <DefaultValue>MobilePhone</DefaultValue>
+ <Description>The type of the device.</Description>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>The device type.</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>OEM</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <Description>Name of OEM</Description>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>The OEM for the device.</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>FwV</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <!--Here the manufacturer must fill in the firmware revision of the device.-->
+ <Description>The firmware revision of the device.</Description>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>The current firmware revision of the device.</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SwV</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <!--Here the manufacturer must fill in the software revision of the device.-->
+ <Description>The software revision of the device.</Description>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>The current software revision of the device.</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>HwV</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <!--Here the manufacturer must fill in the hardware revision of the device.-->
+ <DefaultValue/>
+ <Description>The hardware revision of the device.</Description>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>The current hardware revision of the device.</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>LrgObj</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <!--Here the manufacturer must fill in whether the device supports large object handling Typically, this is a property of the SyncML management agent.-->
+ <DefaultValue/>
+ <Description>Large object handling supported if value is true.</Description>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Large object handling flag.</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+</MgmtTree>
diff --git a/oma-dm-cfg/ddf/slp/slp_devinfo_ddf.xml b/oma-dm-cfg/ddf/slp/slp_devinfo_ddf.xml
new file mode 100644
index 0000000..c9e0015
--- /dev/null
+++ b/oma-dm-cfg/ddf/slp/slp_devinfo_ddf.xml
@@ -0,0 +1,169 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--DOCTYPE MgmtTree PUBLIC "-//OMA//DTD-DM-DDF 1.2//EN" http://www.openmobilealliance.org/tech/DTD/OMA-TS-DM-DDF-V1_2_0.dtd -->
+<MgmtTree>
+ <VerDTD>1.2</VerDTD>
+ <Man>Samsung Electronics</Man>
+ <Mod>GT-I9500</Mod>
+ <Node>
+ <NodeName>DevInfo</NodeName>
+ <!--The '.' shows that this node is located immediately under the root.-->
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>The interior node holding all devinfo objects</DFTitle>
+ <DFType>
+ <DDFName></DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>Ext</NodeName>
+ <!--There are no further items here at the moment.-->
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>The extendable DevInfo branch.</DFTitle>
+ <DFType>
+ <DDFName></DDFName>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Bearer</NodeName>
+ <!--There are no further items here at the moment.-->
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>The bearer specific DevInfo branch.</DFTitle>
+ <DFType>
+ <DDFName></DDFName>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>DevId</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Delete/>
+ </AccessType>
+ <!--Here the manufacturer must fill in the device ID (serial number) of the device.-->
+ <DefaultValue/>
+ <Description>A unique device identifier.</Description>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>The unique device identifier.</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Man</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Delete/>
+ </AccessType>
+ <!--Here the manufacturer must fill in their name. -->
+ <DefaultValue/>
+ <Description>The name of the device manufacturer </Description>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>The name of the device manufacturer.</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Mod</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Delete/>
+ </AccessType>
+ <!--Here the manufacturer must fill in the model name of the device.-->
+ <DefaultValue/>
+ <Description>The name of the device model</Description>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Model name</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>DmV</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Delete/>
+ </AccessType>
+ <!--Here the manufacturer must fill in the management client revision of the device.-->
+ <DefaultValue/>
+ <Description>The management client revision of the device.</Description>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>The current management client revision of the device.</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Lang</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Delete/>
+ </AccessType>
+ <DefaultValue/>
+ <Description>The current language setting of the device.</Description>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Current language.</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+</MgmtTree>
diff --git a/oma-dm-cfg/ddf/slp/slp_fumo_ddf.xml b/oma-dm-cfg/ddf/slp/slp_fumo_ddf.xml
new file mode 100755
index 0000000..71d6857
--- /dev/null
+++ b/oma-dm-cfg/ddf/slp/slp_fumo_ddf.xml
@@ -0,0 +1,270 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--DOCTYPE MgmtTree PUBLIC "-//OMA//DTD-DM-DDF 1.2//EN" http://www.openmobilealliance.org/tech/DTD/OMA-TS-DM-DDF-V1_2_0.dtd -->
+<MgmtTree>
+ <VerDTD>1.2</VerDTD>
+ <Man>Samsung Electronics</Man>
+ <Mod>GT-I9500</Mod>
+ <Node>
+ <NodeName>FUMO</NodeName>
+ <!--The node is located in a location specified below in the Path element -->
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>A firmware update package</DFTitle>
+ <DFType>
+ <DDFName></DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>PkgName</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Name of Update Package</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PkgVersion</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Version of Update Package</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Download</NodeName>
+ <!--This node is used for downloading an update package -->
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>A node that can be used to Download a firmware update package</DFTitle>
+ <DFType>
+ <MIME>org.openmobilealliance.dm.firmwareupdate.download</MIME>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>PkgURL</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrOne/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle> URL for downloading an update package</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>DownloadAndUpdate</NodeName>
+ <!--This node is used for downloading an update package -->
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>A node that can be used to Download and immediately invoke an Update to update a firmware using an update package</DFTitle>
+ <DFType>
+ <MIME>org.openmobilealliance.dm.firmwareupdate.downloadandupdate</MIME>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>PkgURL</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrOne/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle> URL for downloading an update package </DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Update</NodeName>
+ <!--This node is used for Updating the device using an update package -->
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>A node that can be used to conduct firmware update using an update package</DFTitle>
+ <DFType>
+ <MIME>org.openmobilealliance.dm.firmwareupdate.update</MIME>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>PkgData</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrOne/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Opaque/binary firmware upgrade package</DFTitle>
+ <DFType>
+ <MIME>application/octet-stream</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>State</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <Int/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>State set by Client can be retrieved by Server</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Ext</NodeName>
+ <!--This node is used for Vendor specific extensions -->
+ <DFProperties>
+ <AccessType>
+ <Get/><Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>A node that can be used to provide vendor-specific extensions </DFTitle>
+ <DFType>
+ <DDFName></DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>SvcState</NodeName>
+ <!--This node is used for Vendor specific extensions -->
+ <DFProperties>
+ <AccessType>
+ <Get/><Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>A node that can be used to provide vendor-specific extensions </DFTitle>
+ <DFType>
+ <DDFName></DDFName>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+</MgmtTree>
+
+
diff --git a/oma-dm-cfg/ddf/slp/slp_gcf_dmacc_ddf_1.2.xml b/oma-dm-cfg/ddf/slp/slp_gcf_dmacc_ddf_1.2.xml
new file mode 100755
index 0000000..5679736
--- /dev/null
+++ b/oma-dm-cfg/ddf/slp/slp_gcf_dmacc_ddf_1.2.xml
@@ -0,0 +1,652 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--DOCTYPE MgmtTree PUBLIC "-//OMA//DTD-DM-DDF 1.2//EN" http://www.openmobilealliance.org/tech/DTD/OMA-TS-DM-DDF-V1_2_0.dtd -->
+<MgmtTree>
+ <VerDTD>1.2</VerDTD>
+ <Man>Samsung Electronics</Man>
+ <Mod>GT-I9500</Mod>
+ <Node>
+ <NodeName>DMAcc</NodeName>
+ <!--The Path element must be used here so that the SyncML management object can be correctly positioned in the management tree.-->
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>A collection of all SyncML DM accounts</DFTitle>
+ <DFType>
+ <DDFName/>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>gcf</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Delete/>
+ <Get/><Add/><Replace/><Delete/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrMore/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>The "name" node for a management account sub tree</DFTitle>
+ <DFType>
+ <DDFName/>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>AppID</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Application ID for DM Account MO.</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>ServerID</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Server Identifier.</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Name</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrOne/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Displayable name for the Management Server.</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PrefConRef</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrOne/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Reference to preferred connectivity</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>ToConRef</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrOne/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>A collection of references to connectivity definitions</DFTitle>
+ <DFType/>
+ </DFProperties>
+ <Node>
+ <NodeName>gcf_ConRef</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <OneOrMore/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>The "name" node for a management account sub tree</DFTitle>
+ <DFType>
+ <DDFName/>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>ConRef</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>>Linkage to connectivity parameters</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>AppAddr</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>A collection of all references to AppAddr objects</DFTitle>
+ <DFType/>
+ </DFProperties>
+ <Node>
+ <NodeName>gcf_AppAddr</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <OneOrMore/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>The "name" node for a management account sub tree</DFTitle>
+ <DFType>
+ <DDFName/>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>Addr</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Management Server Address</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AddrType</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Management Server Address Type</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Port</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrOne/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>A collection of all Port objects</DFTitle>
+ <DFType/>
+ </DFProperties>
+ <Node>
+ <NodeName>gcf_Port</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <OneOrMore/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle/>
+ <DFType/>
+ </DFProperties>
+ <Node>
+ <NodeName>PortNbr</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Port.</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>AAuthPref</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrOne/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>AApplication Authentication Type preference</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AppAuth</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrOne/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>A collection of all references to multiple Application Authentication objects.</DFTitle>
+ <DFType/>
+ </DFProperties>
+ <Node>
+ <NodeName>ServerAppAuth</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <OneOrMore/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle/>
+ <DFType>
+ <DDFName/>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>AAuthLevel</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Application Authentication level </DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AAuthType</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Application Authentication Type</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AAuthName</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrOne/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Application Authentication Name</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AAuthSecret</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrOne/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Application Authentication Secret</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AAuthData</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrOne/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Application Authentication Data</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>ClientAppAuth</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <OneOrMore/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle/>
+ <DFType>
+ <DDFName/>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>AAuthLevel</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Application Authentication level </DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AAuthType</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Application Authentication Type</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AAuthName</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrOne/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Application Authentication Name</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AAuthSecret</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrOne/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Application Authentication Secret</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>AAuthData</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ </AccessType>
+ <DFFormat>
+ <bin/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrOne/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Application Authentication Data</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Ext</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/><Add/><Replace/><Delete/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <ZeroOrOne/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFType>
+ <DDFName/>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+</MgmtTree>
diff --git a/oma-dm-cfg/ddf/slp/slp_lawmo_pcw_ddf.xml b/oma-dm-cfg/ddf/slp/slp_lawmo_pcw_ddf.xml
new file mode 100755
index 0000000..b2b38db
--- /dev/null
+++ b/oma-dm-cfg/ddf/slp/slp_lawmo_pcw_ddf.xml
@@ -0,0 +1,1389 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--DOCTYPE MgmtTree PUBLIC "-//OMA//DTD-DM-DDF 1.2//EN" http://www.openmobilealliance.org/tech/DTD/OMA-TS-DM-DDF-V1_2_0.dtd -->
+<MgmtTree>
+ <VerDTD>1.2</VerDTD>
+ <Man>Samsung Electronics</Man>
+ <Mod>GT-I9500</Mod>
+ <Node>
+ <NodeName>Ext</NodeName>
+ <!--The node is located in a location specified below in the Path element -->
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>OSPS Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>OSPS</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>OSPS Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>LAWMO</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>LWAMO Service(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>OSP</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>OSP Server(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>Ext</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Extend Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>AMT</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>AMT Check Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>Status</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Current AMT Status Information</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>LockMyPhone</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>LockMyPhone Servie Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>Messages</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>LockMyPhone When Message Display</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>CallRestriction</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>CallRestriction Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>PhoneNumber</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>LockMyPhone When Message Display</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Password</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <b64/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>UnLock The Device</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>RingMyPhone</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>RingMyPhone Service Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>Operations</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Operations Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>Start</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ </AccessType>
+ <DFFormat>
+ <null/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>RingMyPhone Service Start</DFTitle>
+ <DFType>
+ <MIME>urn:oma:at:lawmo:1.0:OperationComplete</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Stop</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ </AccessType>
+ <DFFormat>
+ <null/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>RingMyPhone Service Stop</DFTitle>
+ <DFType>
+ <MIME>urn:oma:at:lawmo:1.0:OperationComplete</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Status</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Current RingMyPhone Status Information</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>AvailableWipeList</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>AvailableWipeList Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>External</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>External Memory Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>ToBeWiped</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>External Memory Wipe Execution Value</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>SIM</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>SIM Memory Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>ToBeWiped</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>SIM Memory Wipe Execution Value</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>State</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Lawmo State</DFTitle>
+ <DFType>
+ <DDFName>text/plain</DDFName>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Operations</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Operations Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>Wipe</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ </AccessType>
+ <DFFormat>
+ <null/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Execution External Memory Data Wipe</DFTitle>
+ <DFType>
+ <MIME>urn:oma:at:lawmo:1.0:OperationComplete</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>FullyLock</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ </AccessType>
+ <DFFormat>
+ <null/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Fullylock Device</DFTitle>
+ <DFType>
+ <MIME>urn:oma:at:lawmo:1.0:OperationComplete</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PartiallyLock</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ </AccessType>
+ <DFFormat>
+ <null/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>PartiallyLock Device</DFTitle>
+ <DFType>
+ <MIME>urn:oma:at:lawmo:1.0:OperationComplete</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>UnLock</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ </AccessType>
+ <DFFormat>
+ <null/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>UnLock Device</DFTitle>
+ <DFType>
+ <MIME>urn:oma:at:lawmo:1.0:OperationComplete</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>FactoryReset</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ </AccessType>
+ <DFFormat>
+ <null/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>FactoryReset Device</DFTitle>
+ <DFType>
+ <MIME>urn:oma:at:lawmo:1.0:OperationComplete</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>MobileTraking</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>MobileTraking Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>GPS</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>GPS Informations</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>isValid</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Availability of GPS Information</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>latitude</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>GPS Value(Latitude)</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>longitude</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>GPS Value(Longitude)</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>horizontalUncertainty</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>GPS Value(HorizontalUncertainty)</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>verticalUncertainty</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>GPS Value(VerticalUncertainty)</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Date</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>GPS Value(Date)</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>NonGPS</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>NonGPS Informations</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>isValid</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Availability of NonGPS Information</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>CellId</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>NonGPS Value(CellId)</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>LAC</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>NonGPS Value(Location Area Code)</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MNC</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>NonGPS Value(Mobile Network Code)</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MCC</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>NonGPS Value(Mobile Country Code)</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Operation</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Operaion Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>Get</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Get Node(Placeholder)</DFTitle>
+ <DFType>
+ <MIME>urn:oma:at:lawmo:1.0:OperationComplete</MIME>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>Location</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ </AccessType>
+ <DFFormat>
+ <null/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Execution Get My Location Service</DFTitle>
+ <DFType>
+ <MIME>urn:oma:at:lawmo:1.0:OperationComplete</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Stop</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ </AccessType>
+ <DFFormat>
+ <null/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Stop Get My Location Service</DFTitle>
+ <DFType>
+ <MIME>urn:oma:at:lawmo:1.0:OperationComplete</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Tracking</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ </AccessType>
+ <DFFormat>
+ <null/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Tracking Get My Location Service</DFTitle>
+ <DFType>
+ <MIME>urn:oma:at:lawmo:1.0:OperationComplete</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Status</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Status of MobileTraking Service</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Policy</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Policy Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>StartDate</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <date/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Tracking Value(Start Date)</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>EndDate</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <date/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Tracking Value(End Date)</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Interval</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <int/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Tracking Value(Interval Time)</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Forwarding</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Forwarding Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>Numbers</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Numbers Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>CallForwarding</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Call Forwarding Number</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SMSForwarding</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>SMS Forwarding Number</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>ToBeEnabled</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>ToBeEnabled Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>CallForwarding</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Call Forwarding Service Set Value</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SMSForwarding</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>SMS Forwarding Service Set Value</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>ToBeDisabled</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>ToBeDisabled Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>CallForwarding</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Call Forwarding Service Release Value</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>SMSForwarding</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <bool/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>SMS Forwarding Service Release Value</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>Operations</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Operations Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>DivertRequest</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ </AccessType>
+ <DFFormat>
+ <null/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Execution of Forwarding Service</DFTitle>
+ <DFType>
+ <MIME>urn:oma:at:lawmo:1.0:OperationComplete</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>MasterKey</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>MasterKey Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>Operations</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Operations Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>LockRelease</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Exec/>
+ </AccessType>
+ <DFFormat>
+ <null/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Execution of MasterKey Service</DFTitle>
+ <DFType>
+ <MIME>urn:oma:at:lawmo:1.0:OperationComplete</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>devInfo</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Device Information Node(Placeholder)</DFTitle>
+ <DFType>
+ <DDFName>null</DDFName>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>SIM</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <null/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Alert For Sim Chainge</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ <Node>
+ <NodeName>MNC</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <char/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Chainge Sim Value(Mobile Network Code)</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MCC</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <char/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Chainge Sim Value(Mobile Country Code)</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>MSISDN</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <char/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Chainge Sim Value(Mobile Station International ISDN Number)</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>date</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Chainge Sim Value(Date)</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+</MgmtTree>
+
diff --git a/oma-dm-cfg/ddf/slp/slp_multi_apps.xml b/oma-dm-cfg/ddf/slp/slp_multi_apps.xml
new file mode 100644
index 0000000..bec4476
--- /dev/null
+++ b/oma-dm-cfg/ddf/slp/slp_multi_apps.xml
@@ -0,0 +1,681 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<MgmtTree>
+ <VerDTD>1.2</VerDTD>
+ <Man>Samsung Electronics</Man>
+ <Mod>SGH-I717</Mod>
+ <Node>
+ <NodeName>Application</NodeName>
+ <Path>.</Path>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <Description>Application settings</Description>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Application object</DFTitle>
+ </DFProperties>
+ <Node>
+ <NodeName>PXLOGICAL</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>A collection of all connectivity objects</DFTitle>
+ </DFProperties>
+ <Node>
+ <NodeName>Internet</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>The "name" node for a connectivity object</DFTitle>
+ </DFProperties>
+ <Node>
+ <NodeName>NAPDEF</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>A collection of NAP objects</DFTitle>
+ </DFProperties>
+ <Node>
+ <NodeName>gprs</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>A GPRS NAP object</DFTitle>
+ </DFProperties>
+ <Node>
+ <NodeName>Name</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>User displayable name for the node</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Addr</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>GPRS APN Address</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>UserName</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>User Name</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PassWD</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Password</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>PXPHYSICAL</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle></DFTitle>
+ </DFProperties>
+ <Node>
+ <NodeName>phyproxy1</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle></DFTitle>
+ </DFProperties>
+ <Node>
+ <NodeName>Addr</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle></DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PortNbr</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Port Number</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>MMS</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Delete/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>The "name" node for a connectivity object</DFTitle>
+ </DFProperties>
+ <Node>
+ <NodeName>NAPDEF</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>A collection of NAP objects</DFTitle>
+ </DFProperties>
+ <Node>
+ <NodeName>gprs</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>A GPRS NAP object</DFTitle>
+ </DFProperties>
+ <Node>
+ <NodeName>Name</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>User displayable name for the node</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Addr</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>GPRS APN Address</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>UserName</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>User Name</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PassWD</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Password</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>PXPHYSICAL</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Add/>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle></DFTitle>
+ </DFProperties>
+ <Node>
+ <NodeName>phyproxy1</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle></DFTitle>
+ </DFProperties>
+ <Node>
+ <NodeName>Addr</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle></DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PortNbr</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Port Number</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>BROWSER</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <Description>Browser Objects</Description>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Broswer object</DFTitle>
+ </DFProperties>
+ <Node>
+ <NodeName>URI</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DefaultValue>http://www.att.com</DefaultValue>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Browser start page URL</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>MMS</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <Description>MMS Objects</Description>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>MMS object</DFTitle>
+ </DFProperties>
+ <Node>
+ <NodeName>URI</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DefaultValue>http://mmsc.cingular.com</DefaultValue>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>MMSC URL</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>Proxy</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Proxy Address</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ <Node>
+ <NodeName>PxPort</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Proxy Port Number</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ <Node>
+ <NodeName>UNKNOWNSRC</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ </AccessType>
+ <Description>Unknown Source Objects</Description>
+ <DFFormat>
+ <node/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Permanent/>
+ </Scope>
+ <DFTitle>Unknown Source object</DFTitle>
+ </DFProperties>
+ <Node>
+ <NodeName>Status</NodeName>
+ <DFProperties>
+ <AccessType>
+ <Get/>
+ <Replace/>
+ </AccessType>
+ <DefaultValue>false</DefaultValue>
+ <DFFormat>
+ <chr/>
+ </DFFormat>
+ <Occurrence>
+ <One/>
+ </Occurrence>
+ <Scope>
+ <Dynamic/>
+ </Scope>
+ <DFTitle>Unknown source status</DFTitle>
+ <DFType>
+ <MIME>text/plain</MIME>
+ </DFType>
+ </DFProperties>
+ </Node>
+ </Node>
+ </Node>
+</MgmtTree> \ No newline at end of file
diff --git a/oma-dm-cfg/ddf/slp_ddfs.txt b/oma-dm-cfg/ddf/slp_ddfs.txt
new file mode 100755
index 0000000..b3e24ff
--- /dev/null
+++ b/oma-dm-cfg/ddf/slp_ddfs.txt
@@ -0,0 +1,6 @@
+0 /usr/share/oma-dm-cfg/ddf/slp/slp_gcf_dmacc_ddf_1.2.xml 4 16
+1 /usr/share/oma-dm-cfg/ddf/slp/slp_devinfo_ddf.xml 2 1
+2 /usr/share/oma-dm-cfg/ddf/slp/slp_devdetail_ddf.xml 1 2
+4 /usr/share/oma-dm-cfg/ddf/slp/slp_fumo_ddf.xml 3 4
+8 /usr/share/oma-dm-cfg/ddf/slp/slp_lawmo_pcw_ddf.xml 7 8
+16 /usr/share/oma-dm-cfg/ddf/slp/slp_multi_apps.xml 8 16
diff --git a/oma-dm-cfg/ddf/slp_gcf_dmacc_ddf.txt b/oma-dm-cfg/ddf/slp_gcf_dmacc_ddf.txt
new file mode 100755
index 0000000..47d5180
--- /dev/null
+++ b/oma-dm-cfg/ddf/slp_gcf_dmacc_ddf.txt
@@ -0,0 +1 @@
+0 /usr/share/oma-dm-cfg/ddf/slp/slp_gcf_dmacc_ddf_1.2.xml 4 16 \ No newline at end of file
diff --git a/oma-dm-cfg/delta_size/max_size.txt b/oma-dm-cfg/delta_size/max_size.txt
new file mode 100644
index 0000000..354b252
--- /dev/null
+++ b/oma-dm-cfg/delta_size/max_size.txt
@@ -0,0 +1 @@
+500000
diff --git a/oma-dm-cfg/fw-init/omadm_fw_config.xml b/oma-dm-cfg/fw-init/omadm_fw_config.xml
new file mode 100755
index 0000000..4cfaeee
--- /dev/null
+++ b/oma-dm-cfg/fw-init/omadm_fw_config.xml
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<INIT>
+ <Agent-Key>omadm</Agent-Key>
+ <MainLoop>1</MainLoop>
+ <Event>
+ <Event-Key>omadm</Event-Key>
+ <Event-Config>/usr/share/oma-dm-cfg/ipc/eventconfig_omadm</Event-Config>
+ <RunEventHandler>1</RunEventHandler>
+ </Event>
+ <Noti>
+ <Noti-Key>omadm_fota_ui</Noti-Key>
+ <Noti-Config>/usr/share/oma-dm-cfg/ipc/noticonfig_omadm</Noti-Config>
+ </Noti>
+ <Noti>
+ <Noti-Key>omadm_noti_ui</Noti-Key>
+ <Noti-Config>/usr/share/oma-dm-cfg/ipc/noticonfig_omadm</Noti-Config>
+ </Noti>
+ <Noti>
+ <Noti-Key>omadm_alert_ui</Noti-Key>
+ <Noti-Config>/usr/share/oma-dm-cfg/ipc/noticonfig_omadm</Noti-Config>
+ </Noti>
+ <EngineController>
+ <Max-Thread>5</Max-Thread>
+ </EngineController>
+ <FrameworkDB use="1">
+ <Path>/opt/dbspace/.omadmagent.db</Path>
+ </FrameworkDB>
+ <ID-Provider>
+ <Code>1</Code>
+ <MaxID>500000</MaxID>
+ <PageSize>5</PageSize>
+ </ID-Provider>
+ <PlugIn-Mgr>
+ <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="2">
+ <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>
+ <Plug-In>
+ <ID>2</ID>
+ <Path>/usr/lib/sync-agent/dm-private/libplugin-di-slp-device-dm.so</Path>
+ <Description>SLP Device Accessor for DM</Description>
+ <DependsOn>1</DependsOn>
+ </Plug-In>
+ </Domain>
+ <Domain name="MO" count="6">
+ <Plug-In>
+ <ID>1</ID>
+ <Path>/usr/lib/sync-agent/dm-public/libplugin-mo-devdetail.so</Path>
+ <Description>about device detail information</Description>
+ <Type>DEVDETAIL</Type>
+ </Plug-In>
+ <Plug-In>
+ <ID>2</ID>
+ <Path>/usr/lib/sync-agent/dm-public/libplugin-mo-devinfo.so</Path>
+ <Description>about device information</Description>
+ <Type>DEVINFO</Type>
+ </Plug-In>
+ <Plug-In>
+ <ID>3</ID>
+ <Path>/usr/lib/sync-agent/dm-private/libplugin-mo-fumo.so</Path>
+ <Description>Firmware Update</Description>
+ <Type>FUMO</Type>
+ </Plug-In>
+ <Plug-In>
+ <ID>4</ID>
+ <Path>/usr/lib/sync-agent/dm-private/libplugin-mo-dmacc-gcf.so</Path>
+ <Description>gcf Server</Description>
+ <Type>DMACC</Type>
+ </Plug-In>
+ <Plug-In>
+ <ID>7</ID>
+ <Path>/usr/lib/sync-agent/dm-private/libplugin-mo-lawmo.so</Path>
+ <Description>Lock and Wipe</Description>
+ <Type>LAWMO</Type>
+ </Plug-In>
+ <Plug-In>
+ <ID>8</ID>
+ <Path>/usr/lib/sync-agent/dm-private/libplugin-mo-multiapps.so</Path>
+ <Description>Multiple Applications</Description>
+ <Type>MULTIAPPS</Type>
+ </Plug-In>
+ </Domain>
+ <Domain name="PlatformMonitor" count="4">
+ <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-dm-agent</Pkg-Name>
+ <Additional-Data>-</Additional-Data>
+ </Data>
+ </Register-Data>
+ </Plug-In>
+ <Plug-In>
+ <ID>3</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>5</ID>
+ <Path>/usr/lib/sync-agent/dm-private/libplugin-pm-slp-sysnoti-telephony.so</Path>
+ <Description>monitoring Telephony Event from SLP Platform</Description>
+ <Use-MainLoop>1</Use-MainLoop>
+ <Register-Data count="1">
+ <Data>
+ <Pkg-Name>oma-dm-agent</Pkg-Name>
+ <Additional-Data>-</Additional-Data>
+ </Data>
+ </Register-Data>
+ </Plug-In>
+ <Plug-In>
+ <ID>6</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>
+ <DeviceManage>
+ <MO-DB-Path>/opt/dbspace/.momanager.db</MO-DB-Path>
+ <DependentDevInfoID>2</DependentDevInfoID>
+ </DeviceManage>
+</INIT>
diff --git a/oma-dm-cfg/fw-init/omadmadminui_fw_config.xml b/oma-dm-cfg/fw-init/omadmadminui_fw_config.xml
new file mode 100644
index 0000000..ffe0c61
--- /dev/null
+++ b/oma-dm-cfg/fw-init/omadmadminui_fw_config.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<INIT>
+ <Agent-Key>omadm_admin_ui</Agent-Key>
+ <Event>
+ <Event-Key>omadm</Event-Key>
+ <Event-Config>/usr/share/oma-dm-cfg/ipc/eventconfig_omadm</Event-Config>
+ <RunEventHandler>0</RunEventHandler>
+ </Event>
+ <Noti>
+ <Noti-Key>omadm_admin_ui</Noti-Key>
+ <Noti-Config>/usr/share/oma-dm-cfg/ipc/noticonfig_omadm</Noti-Config>
+ </Noti>
+</INIT>
diff --git a/oma-dm-cfg/fw-init/omadmalertui_fw_config.xml b/oma-dm-cfg/fw-init/omadmalertui_fw_config.xml
new file mode 100644
index 0000000..9731d7a
--- /dev/null
+++ b/oma-dm-cfg/fw-init/omadmalertui_fw_config.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<INIT>
+ <Agent-Key>omadm_alert_ui</Agent-Key>
+ <Event>
+ <Event-Key>omadm</Event-Key>
+ <Event-Config>/usr/share/oma-dm-cfg/ipc/eventconfig_omadm</Event-Config>
+ <RunEventHandler>0</RunEventHandler>
+ </Event>
+ <Noti>
+ <Noti-Key>omadm_alert_ui</Noti-Key>
+ <Noti-Config>/usr/share/oma-dm-cfg/ipc/noticonfig_omadm</Noti-Config>
+ </Noti>
+</INIT>
diff --git a/oma-dm-cfg/fw-init/omadmcpui_fw_config.xml b/oma-dm-cfg/fw-init/omadmcpui_fw_config.xml
new file mode 100644
index 0000000..8ce58b6
--- /dev/null
+++ b/oma-dm-cfg/fw-init/omadmcpui_fw_config.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<INIT>
+ <Agent-Key>omadm_cp_ui</Agent-Key>
+ <Event>
+ <Event-Key>omadm</Event-Key>
+ <Event-Config>/usr/share/oma-dm-cfg/ipc/eventconfig_omadm</Event-Config>
+ <RunEventHandler>0</RunEventHandler>
+ </Event>
+ <Noti>
+ <Noti-Key>omadm_cp_ui</Noti-Key>
+ <Noti-Config>/usr/share/oma-dm-cfg/ipc/noticonfig_omadm</Noti-Config>
+ </Noti>
+</INIT>
diff --git a/oma-dm-cfg/fw-init/omadmdmaccui_fw_config.xml b/oma-dm-cfg/fw-init/omadmdmaccui_fw_config.xml
new file mode 100644
index 0000000..012f97f
--- /dev/null
+++ b/oma-dm-cfg/fw-init/omadmdmaccui_fw_config.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<INIT>
+ <Agent-Key>omadm_dmacc_ui</Agent-Key>
+ <Event>
+ <Event-Key>omadm</Event-Key>
+ <Event-Config>/usr/share/oma-dm-cfg/ipc/eventconfig_omadm</Event-Config>
+ <RunEventHandler>0</RunEventHandler>
+ </Event>
+</INIT>
diff --git a/oma-dm-cfg/fw-init/omadmfotaui_fw_config.xml b/oma-dm-cfg/fw-init/omadmfotaui_fw_config.xml
new file mode 100644
index 0000000..760bb7f
--- /dev/null
+++ b/oma-dm-cfg/fw-init/omadmfotaui_fw_config.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<INIT>
+ <Agent-Key>omadm_fota_ui</Agent-Key>
+ <Event>
+ <Event-Key>omadm</Event-Key>
+ <Event-Config>/usr/share/oma-dm-cfg/ipc/eventconfig_omadm</Event-Config>
+ <RunEventHandler>0</RunEventHandler>
+ </Event>
+ <Noti>
+ <Noti-Key>omadm_fota_ui</Noti-Key>
+ <Noti-Config>/usr/share/oma-dm-cfg/ipc/noticonfig_omadm</Noti-Config>
+ </Noti>
+</INIT>
diff --git a/oma-dm-cfg/fw-init/omadmnotiui_fw_config.xml b/oma-dm-cfg/fw-init/omadmnotiui_fw_config.xml
new file mode 100644
index 0000000..6652b5e
--- /dev/null
+++ b/oma-dm-cfg/fw-init/omadmnotiui_fw_config.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<INIT>
+ <Agent-Key>omadm_noti_ui</Agent-Key>
+ <Event>
+ <Event-Key>omadm</Event-Key>
+ <Event-Config>/usr/share/oma-dm-cfg/ipc/eventconfig_omadm</Event-Config>
+ <RunEventHandler>0</RunEventHandler>
+ </Event>
+ <Noti>
+ <Noti-Key>omadm_noti_ui</Noti-Key>
+ <Noti-Config>/usr/share/oma-dm-cfg/ipc/noticonfig_omadm</Noti-Config>
+ </Noti>
+</INIT>
diff --git a/oma-dm-cfg/imei-setting/change_imei_callnum.sh b/oma-dm-cfg/imei-setting/change_imei_callnum.sh
new file mode 100755
index 0000000..9bec05c
--- /dev/null
+++ b/oma-dm-cfg/imei-setting/change_imei_callnum.sh
@@ -0,0 +1,3 @@
+vconftool set -t string memory/telephony/imei "357584040054001"
+#vconftool set -t string memory/telephony/imei "004401055493403"
+vconftool set -t string memory/telephony/szSubscriberNumber "01733458636"
diff --git a/oma-dm-cfg/ipc/eventconfig_omadm b/oma-dm-cfg/ipc/eventconfig_omadm
new file mode 100644
index 0000000..17284ff
--- /dev/null
+++ b/oma-dm-cfg/ipc/eventconfig_omadm
@@ -0,0 +1,15 @@
+1, 1, 0, 30, EVENT_SOFTWARE_UPDATE
+2, 1, 0, 30, EVENT_CANCEL
+3, 1, 0, 30, EVENT_DOWNLOAD
+4, 1, 0, 30, EVENT_INSTALL
+5, 1, 0, 30, EVENT_SET_INTERVAL
+6, 1, 0, 30, EVENT_ACCOUNT_REGISTRATION
+7, 1, 0, 30, EVENT_GET_FUMO_CONFIG
+8, 1, 0, 30, EVENT_SET_FUMO_CONFIG
+9, 1, 0, 30, EVENT_GET_PROFILE
+10, 1, 0, 30, EVENT_SET_PROFILE
+11, 1, 0, 30, EVENT_RESET_PROFILE
+12, 1, 0, 30, EVENT_UIC_ALERT
+13, 1, 0, 30, EVENT_CHECK_PIN_CODE
+14, 1, 0, 30, EVENT_ADD_DMACC
+15, 1, 0, 30, EVENT_REMOVE_DMACC
diff --git a/oma-dm-cfg/ipc/noticonfig_omadm b/oma-dm-cfg/ipc/noticonfig_omadm
new file mode 100644
index 0000000..e18abf2
--- /dev/null
+++ b/oma-dm-cfg/ipc/noticonfig_omadm
@@ -0,0 +1,14 @@
+1, 0, 3, 30, NOTI_DOWNLOAD
+2, 0, 3, 30, NOTI_INSTALL
+3, 0, 0, 30, NOTI_DOWNLOAD_INFO
+4, 0, 3, 30, NOTI_ENGINE_START
+5, 0, 0, 30, NOTI_ENGINE_FAIL
+6, 0, 0, 30, NOTI_WIFI_ONLY_DOWNLOAD_FAIL
+7, 0, 0, 30, NOTI_MEMORY_FULL
+8, 0, 3, 30, NOTI_OVER_BIG_SIZE
+9, 0, 0, 30, NOTI_LOW_BATTERY
+10, 0, 3, 30, NOTI_ALERT_DISPLAY
+11, 0, 3, 30, NOTI_ALERT_CONFIRMATION
+12, 0, 3, 30, NOTI_ALERT_INPUTEXT
+13, 0, 3, 30, NOTI_ALERT_SINGLE_CHOICE
+14, 0, 3, 30, NOTI_ALERT_MULTIPLE_CHOICE \ No newline at end of file
diff --git a/packaging/oma-dm-agent.spec b/packaging/oma-dm-agent.spec
new file mode 100755
index 0000000..66602c8
--- /dev/null
+++ b/packaging/oma-dm-agent.spec
@@ -0,0 +1,163 @@
+Name: oma-dm-agent
+Summary: oma-dm-agent daemon for FOTA,DM,CP,FMM Service
+Version: 0.1.4
+Release: 1
+Group: TO_BE/FILLED_IN
+License: Apache License, Version 2.0
+Source0: oma-dm-agent-%{version}.tar.gz
+
+#Requires(post): /sbin/ldconfig
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(sqlite3)
+BuildRequires: pkgconfig(libsoup-2.4)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(libwbxml2)
+BuildRequires: pkgconfig(libxml-2.0)
+BuildRequires: pkgconfig(check)
+BuildRequires: pkgconfig(sync-agent)
+BuildRequires: pkgconfig(aul)
+BuildRequires: pkgconfig(appsvc)
+BuildRequires: pkgconfig(push)
+BuildRequires: pkgconfig(sysman)
+BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(location)
+BuildRequires: pkgconfig(tapi)
+BuildRequires: pkgconfig(pmapi)
+BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(capi-telephony-sim)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(dbus-glib-1)
+#BuildRequires: pkgconfig(oauth)
+#BuildRequires: pkgconfig(samsung-sso-svc)
+
+#BuildRequires: pkgconfig(appcore-efl)
+#BuildRequires: pkgconfig(appcore-common)
+BuildRequires: libgcrypt-devel
+BuildRequires: expat-devel
+BuildRequires: cmake
+
+
+%description
+oma-dm-agent Daemon servcie
+
+%package -n dm-private-plugins
+Summary: DM Private Plugins
+Group: TO_BE_FILLED
+
+%description -n dm-private-plugins
+dm private plugins for sync-agent
+
+%package -n dm-public-plugins
+Summary: DM Public Plugins
+Group: TO_BE_FILLED
+
+%description -n dm-public-plugins
+dm 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-dm /etc/rc.d/rc3.d/S91oma-dm-agent
+ln -s /etc/init.d/oma-dm /etc/rc.d/rc5.d/S91oma-dm-agent
+
+sqlite3 /opt/dbspace/.dm_service.db "PRAGMA journal_mode = PERSIST; create table a(a); drop table a;" > /dev/null
+sqlite3 /opt/dbspace/.omadmagent.db "PRAGMA journal_mode = PERSIST; create table a(a); drop table a;" > /dev/null
+sqlite3 /opt/dbspace/.momanager.db "PRAGMA journal_mode = PERSIST; create table a(a); drop table a;" > /dev/null
+
+chmod 600 /opt/dbspace/.dm_service.db
+chmod 600 /opt/dbspace/.dm_service.db-journal
+chmod 600 /opt/dbspace/.omadmagent.db
+chmod 600 /opt/dbspace/.omadmagent.db-journal
+chmod 600 /opt/dbspace/.momanager.db
+chmod 600 /opt/dbspace/.momanager.db-journal
+
+if [ -f /usr/lib/rpm-plugins/msm.so ]
+then
+ chsmack -a oma-dm-agent::db /opt/dbspace/.dm_service.db
+ chsmack -a oma-dm-agent::db /opt/dbspace/.dm_service.db-journal
+ chsmack -a oma-dm-agent::db /opt/dbspace/.omadmagent.db
+ chsmack -a oma-dm-agent::db /opt/dbspace/.omadmagent.db-journal
+ chsmack -a oma-dm-agent::db /opt/dbspace/.momanager.db
+ chsmack -a oma-dm-agent::db /opt/dbspace/.momanager.db-journal
+fi
+
+#/etc/init.d/oma-dm start
+
+
+%preun
+/etc/init.d/oma-dm stop
+
+
+%postun
+
+rm -f /tmp/agent_fw_event_omadm*
+rm -f /tmp/agent_fw_noti_reply_omadm*
+
+rm -f /etc/rc.d/rc3.d/S91oma-dm-agent
+rm -f /etc/rc.d/rc5.d/S91oma-dm-agent
+
+rm -f /opt/dbspace/.dm_service.db /opt/dbspace/.dm_service.db-journal
+rm -f /opt/dbspace/.omadmagent.db /opt/dbspace/.omadmagent.db-journal
+rm -f /opt/dbspace/.momanager.db /opt/dbspace/.momanager.db-journal
+
+rm -rf /usr/share/oma-dm-cfg
+
+
+%files
+%manifest oma-dm-agent.manifest
+%defattr(-,root,root,-)
+/usr/share/dbus-1/services/*
+/usr/bin/oma-dm-agent
+
+/usr/share/oma-dm-cfg/*
+/usr/share/oma-dm-cfg/ddf/*
+/usr/share/oma-dm-cfg/ddf/slp/*
+/usr/share/oma-dm-cfg/ipc/*
+
+%defattr(700,root,root)
+/usr/share/oma-dm-cfg/csc-setting/change_csc_value.sh
+/usr/share/oma-dm-cfg/imei-setting/change_imei_callnum.sh
+
+/etc/init.d/oma-dm
+
+%files -n dm-private-plugins
+%manifest dm-private-plugins.manifest
+%defattr(-,root,root,-)
+/usr/lib/sync-agent/dm-private/*
+/usr/include/sync-agent/plugin/plugin_slp_device_dm.h
+
+%files -n dm-public-plugins
+%manifest dm-public-plugins.manifest
+%defattr(-,root,root,-)
+/usr/lib/sync-agent/dm-public/*
+
diff --git a/src/agent/CMakeLists.txt b/src/agent/CMakeLists.txt
new file mode 100755
index 0000000..0e9ea0f
--- /dev/null
+++ b/src/agent/CMakeLists.txt
@@ -0,0 +1,84 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set a name for the entire project
+PROJECT(oma-dm)
+
+# set variables
+SET(EXENAME "${PROJECT_NAME}-agent")
+SET(BINDIR "${PREFIX}/bin")
+SET(OMADM_SRC_DIR "${CMAKE_SOURCE_DIR}/src/agent")
+SET(OMADM_COMPONETS "common;common/dm-status;common/util;framework;framework/task;framework/ui-event-handler;framework/ui-event-handler/user-interaction;framework/platform-event-handler;framework/san-parser;dm-engine;dm-engine/fumo;dm-engine/lawmo;dm-engine/bootstrap;dm-engine/cp;dm-engine/dl-manager;mo-handler;serviceadapter;serviceadapter/dm-phase-handler;serviceadapter/protocolbinder;serviceadapter/networkbinder")
+
+# 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
+ libxml-2.0
+ aul
+ libwbxml2
+# oauth
+ appsvc
+ dlog
+ dbus-glib-1
+# appcore-efl
+ )
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+STRING(REPLACE ";" " " EXTRA_CFLAGS "${LPKGS_CFLAGS}")
+
+# find all source files in a directory.
+AUX_SOURCE_DIRECTORY(${OMADM_SRC_DIR} SRCS)
+FOREACH(OMADM_COMPONET ${OMADM_COMPONETS})
+ AUX_SOURCE_DIRECTORY(${OMADM_SRC_DIR}/${OMADM_COMPONET} SRCS)
+ENDFOREACH(OMADM_COMPONET)
+
+# add internal include directories to the build.
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/framework/ui-event-handler)
+
+# 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 dm configuration files
+INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/oma-dm-cfg DESTINATION /usr/share)
+
+# install oma ds dbus file
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/com.samsung.omadmagent.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/dm-status/oma_dm_status_db.c b/src/agent/common/dm-status/oma_dm_status_db.c
new file mode 100644
index 0000000..d63f22f
--- /dev/null
+++ b/src/agent/common/dm-status/oma_dm_status_db.c
@@ -0,0 +1,961 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <unistd.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm-status/oma_dm_status_db.h"
+#include "common/dm_common.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_DB"
+#endif
+
+/* static function define */
+static int _busy_handler(void *pData, int count);
+static DM_ERROR _query_exec(DB_HANDLER * db_handler, char *query, char *errMsg);
+static db_stmt __query_prepare(DB_HANDLER * db_handler, char *query, int size);
+static DM_ERROR __stmt_bind_text(DB_HANDLER * db_handler, db_stmt stmt, int index, const char *value);
+static DM_ERROR _stmt_bind_int(DB_HANDLER * db_handler, db_stmt stmt, int index, const int value);
+static DM_ERROR ___stmt_bind_null(DB_HANDLER * db_handler, db_stmt stmt, int index);
+static DM_ERROR __stmt_step(DB_HANDLER * db_handler, db_stmt stmt);
+/*static DM_ERROR __stmt_reset(DB_HANDLER *db_handler, db_stmt stmt);*/
+static DM_ERROR __stmt_finalize(DB_HANDLER * db_handler, db_stmt stmt);
+static char *_stmt_column_text(db_stmt stmt, int index);
+static int __stmt_column_int(db_stmt stmt, int index);
+static DM_ERROR _get_table(DB_HANDLER * db_handler, char *query, char ***result, int *row_count, int *col_count);
+static void __free_table(char **result);
+
+static int _exist_table(DB_HANDLER * db_handler, const char *table_name);
+static int _get_data_count(DB_HANDLER * db_handler, char *query, int size);
+static char *_replace_engine_status_value(ENGINE_STATUS_VALUE engine_status_value);
+
+static char *__create_table[] = {
+ /* 1. create engine_status_tbl */
+ "create table engine_status_tbl "
+ "( "
+ "engine_id integer, "
+ "engine_status integer default null, "
+ "server_id varchar(100) default null, "
+ "server_url varchar(100) default null, "
+ "correlator varchar(100) default null, "
+ "mo_path varchar(200) default null, "
+ "result_status integer not null, "
+ "ui_mode varchar(100) default null, " "task_id integer not null, " "ui_noti_type integer, " "download_click integer, " "update_time integer not null, " "constraint engine_status_tbl_pk primary key(engine_id)" ");",
+};
+
+static char *__delete_table[] = {
+ /* 1. delete engine_status_tbl */
+ "delete from engine_status_tbl",
+
+};
+
+DM_ERROR dm_open_agent(DB_HANDLER ** db_handler)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = 0;
+ char *errMsg = 0;
+
+ if (*db_handler == NULL) {
+ ret = sqlite3_open("/opt/dbspace/.dm_service.db", db_handler);
+ if (ret != SQLITE_OK)
+ goto FINISH;
+
+ /* register busy handler */
+ ret = sqlite3_busy_handler(*db_handler, _busy_handler, 0);
+ if (ret != SQLITE_OK) {
+ _DEBUG_INFO("fail to register busy handler", errMsg);
+ goto FINISH;
+ }
+
+ /* enable persist journal mode */
+ ret = sqlite3_exec(*db_handler, "PRAGMA journal_mode = PERSIST", 0, 0, &errMsg);
+ if (ret != SQLITE_OK) {
+ _DEBUG_INFO("fail to change journal mode: %s", errMsg);
+ goto FINISH;
+ }
+ _DEBUG_INFO("db_open success");
+ } else {
+ _DEBUG_INFO("db_already opened");
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+
+ FINISH:
+
+ _DEBUG_INFO("db_open failed(%d) : %s", ret, sqlite3_errmsg(*db_handler));
+
+ if (errMsg != NULL)
+ sqlite3_free(errMsg);
+
+ sqlite3_close(*db_handler);
+ *db_handler = 0;
+
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+}
+
+DM_ERROR dm_close_agent(DB_HANDLER * db_handler)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = 0;
+ ret = sqlite3_close(db_handler);
+ db_handler = 0;
+
+ if (ret != SQLITE_OK) {
+ _DEBUG_INFO("db_close failed(%d) : %s", ret, sqlite3_errmsg(db_handler));
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+
+ _DEBUG_INFO("db_close success");
+
+ _EXTERN_FUNC_EXIT;
+
+ return DM_OK;
+}
+
+DM_ERROR dm_create_table(DB_HANDLER * db_handler)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if(db_handler == NULL, DM_ERR_UNKNOWN, "db handler is NULL !!");
+
+ if ((dm_begin_transaction(db_handler) != DM_OK)) {
+ _DEBUG_INFO("mo_db_default_tbl_create failed");
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+
+ /* 1. create engine_status_tbl */
+ if (_exist_table(db_handler, "engine_status_tbl") == 0) {
+ ret = _query_exec(db_handler, __create_table[0], "engine_status_tbl_create failed");
+ if (ret != DM_OK)
+ goto FINISH;
+ }
+
+ /* add normal engine */
+ if (dm_isExist_engine_id(db_handler, 0) == 0) {
+ engine_status status;
+ memset(&status, 0x00, sizeof(engine_status));
+ status.engine_id = 0;
+ status.engine_status = 1;
+ status.result_status = 0;
+ status.task_id = 0;
+ status.ui_noti_type = 0;
+ status.download_click = 0;
+ ret = dm_add_engine_status(db_handler, &status);
+ _DEBUG_INFO("create dm service tbl : %d", ret);
+ }
+
+ FINISH:
+
+ if (ret != DM_OK) {
+ dm_end_transaction(db_handler, TRANSACTION_ROLLBACK_);
+ ret = DM_ERR_UNKNOWN;
+ } else {
+ ret = dm_end_transaction(db_handler, TRANSACTION_COMMIT_);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR dm_delete_table(DB_HANDLER * db_handler)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ int i = 0;
+ retvm_if(db_handler == NULL, DM_ERR_UNKNOWN, "db handler is NULL !!");
+
+ if ((dm_begin_transaction(db_handler) != DM_OK)) {
+ _DEBUG_INFO("default_tbl_delete failed");
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+
+ /* delete all default table */
+ for (i = 0; i < DB_TABLE_NAME_MAX; i++) {
+ ret = _query_exec(db_handler, __delete_table[i], "default_tbl_delete failed");
+ if (ret != DM_OK)
+ goto FINISH;
+ }
+
+ FINISH:
+
+ if (ret != DM_OK) {
+ dm_end_transaction(db_handler, TRANSACTION_ROLLBACK_);
+ ret = DM_ERR_UNKNOWN;
+ } else {
+ ret = dm_end_transaction(db_handler, TRANSACTION_COMMIT_);
+ _DEBUG_INFO("end transaction : %d", ret);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR dm_reset_table(DB_HANDLER * db_handler)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if(db_handler == NULL, DM_ERR_UNKNOWN, "db handler is NULL !!");
+
+ if ((dm_begin_transaction(db_handler) != DM_OK)) {
+ _DEBUG_INFO("default_tbl_delete failed");
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+
+ /*ret = dm_delete_table(db_handler);
+ if (ret != DM_OK)
+ goto FINISH; */
+
+ /* delete all default table */
+ int i = 0;
+ for (i = 0; i < DB_TABLE_NAME_MAX; i++) {
+ ret = _query_exec(db_handler, __delete_table[i], "default_tbl_delete failed");
+ if (ret != DM_OK)
+ goto FINISH;
+ }
+
+ ret = dm_init_engine_status(db_handler);
+ if (ret != DM_OK)
+ goto FINISH;
+
+ FINISH:
+
+ if (ret != DM_OK) {
+ dm_end_transaction(db_handler, TRANSACTION_ROLLBACK_);
+ ret = DM_ERR_UNKNOWN;
+ } else {
+ ret = dm_end_transaction(db_handler, TRANSACTION_COMMIT_);
+ _DEBUG_INFO("end transaction : %d", ret);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR dm_begin_transaction(DB_HANDLER * db_handler)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = _query_exec(db_handler, "begin immediate", "begin_transaction failed");
+ _DEBUG_INFO("begin transaction : %d", ret);
+/* if (ret == SYNC_AGENT_DA_ERR_QUERY_FAILED)
+ ret = SYNC_AGENT_DA_ERR_TRANSACTION_FAILED;*/
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR dm_end_transaction(DB_HANDLER * db_handler, DB_TRANSACTION transaction)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ char *query = 0;
+ char *errMsg = 0;
+
+ if (transaction == TRANSACTION_COMMIT_) {
+ query = "commit transaction";
+ errMsg = "commit_transaction failed";
+ } else if (transaction == TRANSACTION_ROLLBACK_) {
+ query = "rollback transaction";
+ errMsg = "rollback_transaction failed";
+ }
+
+ ret = _query_exec(db_handler, query, errMsg);
+ if (ret == DM_ERR_UNKNOWN) {
+ if (transaction == TRANSACTION_COMMIT_) {
+ query = "rollback transaction";
+ errMsg = "rollback_transaction failed";
+ ret = _query_exec(db_handler, query, errMsg);
+ if (ret == DM_OK)
+ _DEBUG_INFO("rollback_transaction success");
+ }
+ ret = DM_ERR_UNKNOWN;
+ _DEBUG_INFO("end transaction error : %d", ret);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR dm_init_engine_status(DB_HANDLER * db_handler)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_ERR_UNKNOWN;
+
+ retvm_if(db_handler == NULL, DM_ERR_UNKNOWN, "db handler is NULL !!");
+
+ /* add normal engine */
+ if (dm_isExist_engine_id(db_handler, 0) == 0) {
+ engine_status status;
+ memset(&status, 0x00, sizeof(engine_status));
+ status.engine_id = 0;
+ status.engine_status = 1;
+ status.result_status = 0;
+ status.task_id = 0;
+ status.ui_noti_type = 0;
+ status.download_click = 0;
+ ret = dm_add_engine_status(db_handler, &status);
+ _DEBUG_INFO("dm add engine status : %d", ret);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR dm_add_engine_status(DB_HANDLER * db_handler, engine_status * status)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ db_stmt stmt = 0;
+
+ retvm_if(db_handler == NULL, DM_ERR_UNKNOWN, "db handler is NULL !!");
+ retvm_if(status == NULL, DM_ERR_UNKNOWN, "db status is NULL !!");
+
+ char *query = "insert into engine_status_tbl (engine_id, engine_status, server_id, server_url, correlator, mo_path, result_status, ui_mode, task_id, ui_noti_type, download_click, update_time) " "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+
+ stmt = __query_prepare(db_handler, query, strlen(query));
+ if (stmt == NULL) {
+ ret = DM_ERR_UNKNOWN;
+ _DEBUG_INFO("ERROR DB");
+ goto FINISH;
+ }
+
+ _stmt_bind_int(db_handler, stmt, 1, status->engine_id);
+ _stmt_bind_int(db_handler, stmt, 2, status->engine_status);
+ __stmt_bind_text(db_handler, stmt, 3, status->server_id);
+ __stmt_bind_text(db_handler, stmt, 4, status->server_url);
+ __stmt_bind_text(db_handler, stmt, 5, status->correlator);
+ __stmt_bind_text(db_handler, stmt, 6, status->mo_path);
+ _stmt_bind_int(db_handler, stmt, 7, status->result_status);
+ __stmt_bind_text(db_handler, stmt, 8, status->ui_mode);
+ _stmt_bind_int(db_handler, stmt, 9, status->task_id);
+ _stmt_bind_int(db_handler, stmt, 10, status->ui_noti_type);
+ _stmt_bind_int(db_handler, stmt, 11, status->download_click);
+ _stmt_bind_int(db_handler, stmt, 12, (int)(time(&status->update_time)));
+
+ ret = __stmt_step(db_handler, stmt);
+ if (ret != DM_OK)
+ ret = DM_ERR_UNKNOWN;
+
+ FINISH:
+
+ if (stmt != NULL)
+ __stmt_finalize(db_handler, stmt);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR dm_delete_engine_status(DB_HANDLER * db_handler, int engine_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ db_stmt stmt = 0;
+
+ retvm_if(db_handler == NULL, DM_ERR_UNKNOWN, "db handler is NULL !!");
+
+ char *query = "delete from engine_status_tbl where engine_id = ?";
+
+ stmt = __query_prepare(db_handler, query, strlen(query));
+ if (stmt == NULL) {
+ ret = DM_ERR_UNKNOWN;
+ goto FINISH;
+ }
+
+ _stmt_bind_int(db_handler, stmt, 1, engine_id);
+ ret = __stmt_step(db_handler, stmt);
+
+ FINISH:
+
+ if (stmt != NULL)
+ __stmt_finalize(db_handler, stmt);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR dm_update_engine_status(DB_HANDLER * db_handler, engine_status * status)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ db_stmt stmt = 0;
+
+ retvm_if(db_handler == NULL, DM_ERR_UNKNOWN, "db handler is NULL !!");
+ retvm_if(status == NULL, DM_ERR_UNKNOWN, "db status is NULL !!");
+
+ char *query = "update engine_status_tbl "
+ "set engine_status = ?, server_id = ?, server_url = ?, correlator = ?, mo_path = ?, result_status = ?, ui_mode = ?, task_id = ?, ui_noti_type = ?, download_click = ?, update_time = ? " "where engine_id = ?";
+
+ stmt = __query_prepare(db_handler, query, strlen(query));
+ if (stmt == NULL) {
+ ret = DM_ERR_UNKNOWN;
+ goto FINISH;
+ }
+
+ _stmt_bind_int(db_handler, stmt, 1, status->engine_status);
+ __stmt_bind_text(db_handler, stmt, 2, status->server_id);
+ __stmt_bind_text(db_handler, stmt, 3, status->server_url);
+ __stmt_bind_text(db_handler, stmt, 4, status->correlator);
+ __stmt_bind_text(db_handler, stmt, 5, status->mo_path);
+ _stmt_bind_int(db_handler, stmt, 6, status->result_status);
+ __stmt_bind_text(db_handler, stmt, 7, status->ui_mode);
+ _stmt_bind_int(db_handler, stmt, 8, status->task_id);
+ _stmt_bind_int(db_handler, stmt, 9, status->ui_noti_type);
+ _stmt_bind_int(db_handler, stmt, 10, status->download_click);
+ _stmt_bind_int(db_handler, stmt, 11, (int)(time(&status->update_time)));
+ _stmt_bind_int(db_handler, stmt, 12, status->engine_id);
+
+ ret = __stmt_step(db_handler, stmt);
+ if (ret != DM_OK)
+ ret = DM_ERR_UNKNOWN;
+
+ FINISH:
+
+ if (stmt != NULL)
+ __stmt_finalize(db_handler, stmt);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR dm_update_engine_status_column(DB_HANDLER * db_handler, int engine_id, ENGINE_STATUS_VALUE engine_status_value, void *value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ db_stmt stmt = 0;
+ char query[MAX_QUERY_LENGTH] = { 0, };
+ char *column_name = _replace_engine_status_value(engine_status_value);
+ time_t update_time;
+
+ retvm_if(db_handler == NULL, DM_ERR_UNKNOWN, "db handler is NULL !!");
+
+ snprintf(query, sizeof(query), "update engine_status_tbl set %s = ?, update_time= %d where engine_id = %d", column_name, (int)(time(&update_time)), engine_id);
+
+ stmt = __query_prepare(db_handler, query, strlen(query));
+ if (stmt == NULL) {
+ ret = DM_ERR_UNKNOWN;
+ goto FINISH;
+ }
+
+ if (engine_status_value == VALUE_ENGINE_STATUS || engine_status_value == VALUE_RESULT_STATUS || engine_status_value == VALUE_TASK_ID || engine_status_value == VALUE_UI_NOTI_TYPE || engine_status_value == VALUE_DOWNLOAD_CLICK) {
+ int *engine_status = (int *)value;
+ _stmt_bind_int(db_handler, stmt, 1, *engine_status);
+ } else {
+ char *str = (char *)value;
+ __stmt_bind_text(db_handler, stmt, 1, str);
+ }
+
+ ret = __stmt_step(db_handler, stmt);
+ if (ret != DM_OK)
+ ret = DM_ERR_UNKNOWN;
+
+ FINISH:
+
+ if (stmt != NULL)
+ __stmt_finalize(db_handler, stmt);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR dm_get_engine_status(DB_HANDLER * db_handler, int engine_id, engine_status ** status)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ db_stmt stmt = 0;
+ char *query = "select * from engine_status_tbl where engine_id = ?";
+ engine_status *temp_status = 0;
+
+ retvm_if(db_handler == NULL, DM_ERR_UNKNOWN, "db handler is NULL !!");
+
+ stmt = __query_prepare(db_handler, query, strlen(query));
+ if (stmt != NULL) {
+ _stmt_bind_int(db_handler, stmt, 1, engine_id);
+
+ if (__stmt_step(db_handler, stmt) == DM_ERR_MORE_DATA) {
+ temp_status = (engine_status *) calloc(1, sizeof(engine_status));
+ if (temp_status == NULL) {
+ _DEBUG_INFO("alloc fail");
+ _EXTERN_FUNC_EXIT;
+ return COMMON_ERR_ALLOC;
+ }
+ temp_status->engine_id = __stmt_column_int(stmt, 0);
+ temp_status->engine_status = __stmt_column_int(stmt, 1);
+ temp_status->server_id = _stmt_column_text(stmt, 2);
+ temp_status->server_url = _stmt_column_text(stmt, 3);
+ temp_status->correlator = _stmt_column_text(stmt, 4);
+ temp_status->mo_path = _stmt_column_text(stmt, 5);
+ temp_status->result_status = __stmt_column_int(stmt, 6);
+ temp_status->ui_mode = _stmt_column_text(stmt, 7);
+ temp_status->task_id = __stmt_column_int(stmt, 8);
+ temp_status->ui_noti_type = __stmt_column_int(stmt, 9);
+ temp_status->download_click = __stmt_column_int(stmt, 10);
+ temp_status->update_time = __stmt_column_int(stmt, 11);
+ }
+ ret = __stmt_finalize(db_handler, stmt);
+ } else {
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+
+ (*status) = temp_status;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR dm_get_aII_engine_status(DB_HANDLER * db_handler, engine_status ** status_list, int *count)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ engine_status *temp_status = 0;
+ char **result = 0;
+ int row_count = 0;
+ int col_count = 0;
+ int index = 6;
+ int i = 0;
+ char query[MAX_QUERY_LENGTH] = { 0, };
+
+ retvm_if(db_handler == NULL, DM_ERR_UNKNOWN, "db handler is NULL !!");
+
+ snprintf(query, sizeof(query), "select * from engine_status_tbl");
+
+ ret = _get_table(db_handler, query, &result, &row_count, &col_count);
+ if ((ret == DM_OK) && (row_count != 0) && (result != NULL)) {
+ *count = row_count;
+ temp_status = (engine_status *) calloc(row_count, sizeof(engine_status));
+ if (temp_status == NULL) {
+ _DEBUG_INFO("memory_allocation failed");
+ ret = COMMON_ERR_ALLOC;
+ goto FINISH;
+ }
+
+ for (i = 0; i < row_count; i++) {
+ temp_status[i].engine_id = ATOI(result[index]);
+ index++;
+ temp_status[i].engine_status = ATOI(result[index]);
+ index++;
+ temp_status[i].server_id = STRDUP(result[index]);
+ index++;
+ temp_status[i].server_url = STRDUP(result[index]);
+ index++;
+ temp_status[i].correlator = STRDUP(result[index]);
+ index++;
+ temp_status[i].mo_path = STRDUP(result[index]);
+ index++;
+ temp_status[i].result_status = ATOI(result[index]);
+ index++;
+ temp_status[i].ui_mode = STRDUP(result[index]);
+ index++;
+ temp_status[i].task_id = ATOI(result[index]);
+ index++;
+ temp_status[i].ui_noti_type = ATOI(result[index]);
+ index++;
+ temp_status[i].download_click = ATOI(result[index]);
+ index++;
+ temp_status[i].update_time = ATOI(result[index]);
+ index++;
+ }
+ }
+
+ FINISH:
+
+ if (result != NULL)
+ __free_table(result);
+
+ *status_list = temp_status;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+int dm_isExist_engine_id(DB_HANDLER * db_handler, int engine_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = 1;
+ int dataCount = 0;
+ char query[MAX_QUERY_LENGTH] = { 0, };
+
+ retvm_if(db_handler == NULL, DM_ERR_UNKNOWN, "db handler is NULL !!");
+
+ snprintf(query, sizeof(query), "select count(*) from engine_status_tbl where engine_id = %d", engine_id);
+
+ dataCount = _get_data_count(db_handler, query, strlen(query));
+
+ if (dataCount == 0)
+ ret = 0;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+int _busy_handler(void *pData, int count)
+{
+ _INNER_FUNC_ENTER;
+
+ _DEBUG_TRACE("__busy_handler %d called", count);
+
+ /* sleep time when SQLITE_LOCK */
+ usleep(100000);
+
+ _INNER_FUNC_EXIT;
+ /* retry will be stopped if busy handler return 0 */
+ return RETRY_COUNT - count;
+}
+
+DM_ERROR _query_exec(DB_HANDLER * db_handler, char *query, char *errMsg)
+{
+ _INNER_FUNC_ENTER;
+
+ char *queryMsg = 0;
+ int ret = 0;
+
+ retvm_if(db_handler == NULL, DM_ERR_UNKNOWN, "db handler is NULL !!");
+
+ ret = sqlite3_exec(db_handler, query, 0, 0, &queryMsg);
+ if (ret != SQLITE_OK) {
+ _DEBUG_TRACE("%s(%d) : %s", errMsg, ret, queryMsg);
+
+ if (queryMsg != NULL)
+ sqlite3_free(queryMsg);
+
+/*
+ if (ret == SQLITE_BUSY)
+ return DM_ERR_UNKNOWN;
+*/
+ _INNER_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+ return DM_OK;
+ _INNER_FUNC_EXIT;
+}
+
+db_stmt __query_prepare(DB_HANDLER * db_handler, char *query, int size)
+{
+ _INNER_FUNC_ENTER;
+
+ int ret = 0;
+ db_stmt stmt = 0;
+
+ ret = sqlite3_prepare_v2(db_handler, query, size, &stmt, 0);
+ if (ret != SQLITE_OK)
+ _DEBUG_VERBOSE("sqlite3_query_prepare failed(%d) : %s ", ret, sqlite3_errmsg(db_handler));
+
+ _INNER_FUNC_EXIT;
+
+ return stmt;
+}
+
+DM_ERROR __stmt_bind_text(DB_HANDLER * db_handler, db_stmt stmt, int index, const char *value)
+{
+ _INNER_FUNC_ENTER;
+
+ int ret = 0;
+
+ if (value != NULL) {
+ ret = sqlite3_bind_text(stmt, index, value, strlen(value), SQLITE_STATIC);
+ } else {
+ ret = ___stmt_bind_null(db_handler, stmt, index);
+ if (ret == DM_OK) {
+ ret = SQLITE_OK;
+ }
+ }
+
+ if (ret != SQLITE_OK) {
+ _DEBUG_VERBOSE("sqlite3_stmt_bind_text failed(%d) : %s ", ret, sqlite3_errmsg(db_handler));
+ _INNER_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+ _INNER_FUNC_EXIT;
+ return DM_OK;
+}
+
+DM_ERROR _stmt_bind_int(DB_HANDLER * db_handler, db_stmt stmt, int index, const int value)
+{
+ _INNER_FUNC_ENTER;
+
+ int ret = 0;
+
+ ret = sqlite3_bind_int(stmt, index, value);
+ if (ret != SQLITE_OK) {
+ _DEBUG_TRACE("sqlite3_stmt_bind_int failed(%d) : %s \n", ret, sqlite3_errmsg(db_handler));
+ _INNER_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return DM_OK;
+}
+
+DM_ERROR ___stmt_bind_null(DB_HANDLER * db_handler, db_stmt stmt, int index)
+{
+ _INNER_FUNC_ENTER;
+
+ int ret = 0;
+
+ ret = sqlite3_bind_null(stmt, index);
+ if (ret != SQLITE_OK) {
+ _DEBUG_VERBOSE("sqlite3_stmt_bind_null failed(%d) : %s", ret, sqlite3_errmsg(db_handler));
+ _INNER_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+
+ _INNER_FUNC_EXIT;
+ return DM_OK;
+}
+
+DM_ERROR __stmt_step(DB_HANDLER * db_handler, db_stmt stmt)
+{
+ _INNER_FUNC_ENTER;
+ int ret = 0;
+
+ ret = sqlite3_step(stmt);
+
+ if (ret == SQLITE_ROW) {
+ _INNER_FUNC_EXIT;
+ return DM_ERR_MORE_DATA;
+ }
+
+ if (ret != SQLITE_DONE) {
+ _DEBUG_VERBOSE("sqlite3_stmt_step failed(%d) : %s", ret, sqlite3_errmsg(db_handler));
+
+/* if (ret == SQLITE_BUSY)
+ return DM_ERR_UNKNOWN;*/
+ _INNER_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+
+ _INNER_FUNC_EXIT;
+ return DM_OK;
+}
+
+/*DM_ERROR __stmt_reset(DB_HANDLER *db_handler, db_stmt stmt)
+{
+ int ret = 0;
+
+ if (sqlite3_reset(stmt) != SQLITE_OK) {
+ _DEBUG_INFO("sqlite3_stmt_reset failed(%d) : %s", ret, sqlite3_errmsg(db_handler));
+ return DM_ERR_UNKNOWN;
+ }
+
+ return DM_OK;
+}*/
+
+DM_ERROR __stmt_finalize(DB_HANDLER * db_handler, db_stmt stmt)
+{
+ _INNER_FUNC_ENTER;
+ int ret = 0;
+
+ if (sqlite3_finalize(stmt) != SQLITE_OK) {
+ _DEBUG_VERBOSE("sqlite3_stmt_finalize failed(%d) : %s", ret, sqlite3_errmsg(db_handler));
+ _INNER_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+
+ _INNER_FUNC_EXIT;
+ return DM_OK;
+}
+
+char *_stmt_column_text(db_stmt stmt, int index)
+{
+ _EXTERN_FUNC_ENTER;
+
+ char *temp = 0;
+ temp = (char *)sqlite3_column_text(stmt, index);
+
+ _EXTERN_FUNC_EXIT;
+
+ return STRDUP(temp);
+}
+
+int __stmt_column_int(db_stmt stmt, int index)
+{
+ _INNER_FUNC_ENTER;
+
+ _INNER_FUNC_EXIT;
+ return (int)sqlite3_column_int(stmt, index);
+}
+
+DM_ERROR _get_table(DB_HANDLER * db_handler, char *query, char ***result, int *row_count, int *col_count)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = 0;
+ char *errMsg;
+
+ if (db_handler == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+
+ ret = sqlite3_get_table(db_handler, query, result, row_count, col_count, &errMsg);
+
+ if (ret != SQLITE_OK) {
+ _DEBUG_TRACE("sqlite3_get_table failed(%d) : %s", ret, errMsg);
+
+ __free_table(*result);
+
+ if (errMsg != NULL)
+ sqlite3_free(errMsg);
+
+ _EXTERN_FUNC_EXIT;
+
+ return DM_ERR_UNKNOWN;
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return DM_OK;
+}
+
+void __free_table(char **result)
+{
+ _INNER_FUNC_ENTER;
+
+ if (result != NULL)
+ sqlite3_free_table(result);
+
+ _INNER_FUNC_EXIT;
+
+}
+
+int _exist_table(DB_HANDLER * db_handler, const char *table_name)
+{
+ _INNER_FUNC_ENTER;
+
+ db_stmt stmt = 0;
+ int table_count = 0;
+ char *query = "select count(*) from sqlite_master where tbl_name= ?";
+
+ stmt = __query_prepare(db_handler, query, strlen(query));
+ if ((stmt != NULL) && (__stmt_bind_text(db_handler, stmt, 1, table_name) == DM_ERR_MORE_DATA)) {
+
+ if (__stmt_step(db_handler, stmt) == DM_ERR_MORE_DATA)
+ table_count = __stmt_column_int(stmt, 0);
+
+ __stmt_finalize(db_handler, stmt);
+
+ if (table_count > 0) {
+ _INNER_FUNC_EXIT;
+ return 1;
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return 0;
+}
+
+int _get_data_count(DB_HANDLER * db_handler, char *query, int size)
+{
+ _INNER_FUNC_ENTER;
+
+ db_stmt stmt = 0;
+ int data_count = 0;
+
+ stmt = __query_prepare(db_handler, query, size);
+ if (stmt != NULL) {
+ if (__stmt_step(db_handler, stmt) == DM_ERR_MORE_DATA)
+ data_count = __stmt_column_int(stmt, 0);
+
+ __stmt_finalize(db_handler, stmt);
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return data_count;
+}
+
+static char *_replace_engine_status_value(ENGINE_STATUS_VALUE engine_status_value)
+{
+ _INNER_FUNC_ENTER;
+
+ char *temp = 0;
+
+ switch (engine_status_value) {
+ case VALUE_ENGINE_ID:
+ temp = "engine_id";
+ break;
+ case VALUE_ENGINE_STATUS:
+ temp = "engine_status";
+ break;
+ case VALUE_SERVER_ID:
+ temp = "server_id";
+ break;
+ case VALUE_SERVER_URL:
+ temp = "server_url";
+ break;
+ case VALUE_CORRELATOR:
+ temp = "correlator";
+ break;
+ case VALUE_MO_PATH:
+ temp = "mo_path";
+ break;
+ case VALUE_RESULT_STATUS:
+ temp = "result_status";
+ break;
+ case VALUE_UI_MODE:
+ temp = "ui_mode";
+ break;
+ case VALUE_TASK_ID:
+ temp = "task_id";
+ break;
+ case VALUE_UI_NOTI_TYPE:
+ temp = "ui_noti_type";
+ break;
+ case VALUE_DOWNLOAD_CLICK:
+ temp = "download_click";
+ break;
+ case VALUE_UPDATE_TIME:
+ temp = "update_time";
+ break;
+ default:
+ temp = 0;
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return temp;
+}
diff --git a/src/agent/common/dm-status/oma_dm_status_db_handler.c b/src/agent/common/dm-status/oma_dm_status_db_handler.c
new file mode 100755
index 0000000..378da1c
--- /dev/null
+++ b/src/agent/common/dm-status/oma_dm_status_db_handler.c
@@ -0,0 +1,638 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm-status/oma_dm_status_db_handler.h"
+#include "common/dm-status/oma_dm_status_db.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_DB"
+#endif
+
+static db_handler_mgr *pDBHandlerMgr = 0;
+
+/* static function define */
+static DM_ERROR _add_agent_handler(unsigned int key, DB_HANDLER * pHandler);
+static DM_ERROR _remove_agent_handler(unsigned int key);
+static DB_HANDLER *_get_agent_handler(unsigned int key);
+static DM_ERROR __alloc_agent_dc_handlerTable();
+static DM_ERROR __alloc_agent_dc_handlerTable_mutex();
+static DM_ERROR _free_agent_dc_handlerTable();
+static DM_ERROR _free_agent_dc_handlerTable_mutex();
+static DM_ERROR _create_agentDBHandlerMgrInfo();
+static void ___destroy_agentDBHashTableValue(void *pHandler);
+static void ___destory_agentDBHashTableKey(void *key);
+
+/* test function define*/
+/*static void __print_agentDBHashTableLog();*/
+
+/* general function implementation */
+/*
+ * ==================================
+ * external API (1. about db handler mgr)
+ * ==================================
+ */
+DM_ERROR Alloc_DB_Handler_Mgr()
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ /* alloc the agentDBHandlerMgr */
+ pDBHandlerMgr = (db_handler_mgr *) calloc(1, sizeof(db_handler_mgr));
+ if (pDBHandlerMgr == NULL) {
+ _DEBUG_INFO("alloc fail");
+ _EXTERN_FUNC_EXIT;
+ return COMMON_ERR_ALLOC;
+ }
+ _DEBUG_INFO("[%s] pMoDBHandlerMgr alloc success !\n", __func__);
+
+ /* alloc the agentDBHandlerMgr information */
+ ret = _create_agentDBHandlerMgrInfo();
+ if (ret != DM_OK)
+ _DEBUG_INFO("[%s] __create_agentDBHandlerMgrInfo alloc fail !\n", __func__);
+ else
+ _DEBUG_INFO("[%s] __create_agentDBHandlerMgrInfo alloc success !\n", __func__);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR Free_DB_Handler_Mgr()
+{
+ _EXTERN_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+ if (pDBHandlerMgr != NULL) {
+
+ ret = _free_agent_dc_handlerTable_mutex();
+ if (ret != DM_OK) {
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+
+ ret = _free_agent_dc_handlerTable();
+ if (ret != DM_OK) {
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+void Free_Memory_Engine_Status(engine_status ** status, int count)
+{
+ _EXTERN_FUNC_ENTER;
+ engine_status *temp_status = *status;
+
+ int i;
+ for (i = 0; i < count; i++) {
+ MEMORY_FREE(temp_status[i].server_id);
+ MEMORY_FREE(temp_status[i].server_url);
+ MEMORY_FREE(temp_status[i].correlator);
+ MEMORY_FREE(temp_status[i].ui_mode);
+ MEMORY_FREE(temp_status[i].mo_path);
+ }
+
+ MEMORY_FREE(temp_status);
+ *status = 0;
+ _EXTERN_FUNC_EXIT;
+}
+
+/*
+ * ==================================
+ * external API (2. about agent db )
+ * ==================================
+ */
+DM_ERROR DB_Open()
+{
+ _EXTERN_FUNC_ENTER;
+ int ret = 0;
+
+ DB_HANDLER *db_handler = _get_agent_handler(GET_THREAD_ID);
+ if (db_handler == NULL) {
+
+ _DEBUG_INFO("db_handler is 0");
+ _DEBUG_INFO("should register db_handler to db_handler_hash_table");
+ ret = dm_open_agent(&db_handler);
+ if (ret != DM_OK) {
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ }
+
+ if (db_handler != NULL) {
+ /* add agentDB handler to agentDBHandleMgr */
+ ret = _add_agent_handler(GET_THREAD_ID, db_handler);
+ if (ret != DM_OK) {
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ }
+ }
+ } else {
+ _DEBUG_INFO("db_handler is not null");
+ _DEBUG_INFO("should not register db_handler to db_handler_hash_table");
+ }
+
+ _DEBUG_INFO("agent_db_agent_open_success");
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+}
+
+void DB_Close()
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ DB_HANDLER *db_handler = _get_agent_handler(GET_THREAD_ID);
+ if (db_handler != NULL) {
+
+ /* remove agentDB handler to agentDBHandleMgr */
+ ret = _remove_agent_handler(GET_THREAD_ID);
+ if (ret != DM_OK) {
+ _DEBUG_INFO("agent_db_agent_close_fail");
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+ _DEBUG_INFO("agent_db_agent_close_success");
+ }
+ _EXTERN_FUNC_EXIT;
+}
+
+DM_ERROR DB_Create_Table()
+{
+ _EXTERN_FUNC_ENTER;
+
+ DB_HANDLER *db_handler = _get_agent_handler(GET_THREAD_ID);
+ if (db_handler == NULL) {
+ _DEBUG_INFO("[%s] no handler for key\n", __func__);
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+ _EXTERN_FUNC_EXIT;
+ return dm_create_table(db_handler);
+}
+
+DM_ERROR DB_Delete_Table()
+{
+ _EXTERN_FUNC_ENTER;
+
+ DB_HANDLER *db_handler = _get_agent_handler(GET_THREAD_ID);
+ if (db_handler == NULL) {
+ _DEBUG_INFO("[%s] no handler for key\n", __func__);
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+ _EXTERN_FUNC_EXIT;
+ return dm_delete_table(db_handler);
+}
+
+DM_ERROR DB_Reset_Table()
+{
+ _EXTERN_FUNC_ENTER;
+
+ DB_HANDLER *db_handler = _get_agent_handler(GET_THREAD_ID);
+ if (db_handler == NULL) {
+ _DEBUG_INFO("[%s] no handler for key\n", __func__);
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+ _EXTERN_FUNC_EXIT;
+ return dm_reset_table(db_handler);
+}
+
+DM_ERROR DB_Begin_Transaction()
+{
+ _EXTERN_FUNC_ENTER;
+
+ DB_HANDLER *db_handler = _get_agent_handler(GET_THREAD_ID);
+ if (db_handler == NULL) {
+ _DEBUG_INFO("[%s] no handler for key\n", __func__);
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+ _EXTERN_FUNC_EXIT;
+ return dm_begin_transaction(db_handler);
+}
+
+DM_ERROR DB_End_Transaction(DB_TRANSACTION transaction)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DB_HANDLER *db_handler = _get_agent_handler(GET_THREAD_ID);
+ if (db_handler == NULL) {
+ _DEBUG_INFO("[%s] no handler for key\n", __func__);
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+ _EXTERN_FUNC_EXIT;
+ return dm_end_transaction(db_handler, transaction);
+}
+
+DM_ERROR Init_Engine_Status()
+{
+ _EXTERN_FUNC_ENTER;
+
+ DB_HANDLER *db_handler = _get_agent_handler(GET_THREAD_ID);
+ if (db_handler == NULL) {
+ _DEBUG_INFO("[%s] no handler for key\n", __func__);
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+ _EXTERN_FUNC_EXIT;
+ return dm_init_engine_status(db_handler);
+}
+
+DM_ERROR Add_Engine_Status(engine_status * status)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DB_HANDLER *db_handler = _get_agent_handler(GET_THREAD_ID);
+ if (db_handler == NULL) {
+ _DEBUG_INFO("[%s] no handler for key\n", __func__);
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+ _EXTERN_FUNC_EXIT;
+ return dm_add_engine_status(db_handler, status);
+}
+
+DM_ERROR Delete_Engine_Status(int engine_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DB_HANDLER *db_handler = _get_agent_handler(GET_THREAD_ID);
+ if (db_handler == NULL) {
+ _DEBUG_INFO("[%s] no handler for key\n", __func__);
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return dm_delete_engine_status(db_handler, engine_id);
+}
+
+DM_ERROR Update_Engine_Status(engine_status * status)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(status == NULL, DM_ERR_UNKNOWN, "engine status is NULL !!");
+
+ DB_HANDLER *db_handler = _get_agent_handler(GET_THREAD_ID);
+ if (db_handler == NULL) {
+ _DEBUG_INFO("[%s] no handler for key\n", __func__);
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+
+ int ret = dm_isExist_engine_id(db_handler, status->engine_id);
+ if (ret == 0) {
+ _EXTERN_FUNC_EXIT;
+ return dm_add_engine_status(db_handler, status);
+ } else {
+ _EXTERN_FUNC_EXIT;
+ return dm_update_engine_status(db_handler, status);
+ }
+}
+
+DM_ERROR Update_Engine_Status_Column(int engine_id, ENGINE_STATUS_VALUE engine_status_value, void *value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DB_HANDLER *db_handler = _get_agent_handler(GET_THREAD_ID);
+ if (db_handler == NULL) {
+ _DEBUG_INFO("[%s] no handler for key\n", __func__);
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+ _EXTERN_FUNC_EXIT;
+ return dm_update_engine_status_column(db_handler, engine_id, engine_status_value, value);
+}
+
+DM_ERROR Get_Engine_Status(int engine_id, engine_status ** status)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DB_HANDLER *db_handler = _get_agent_handler(GET_THREAD_ID);
+ if (db_handler == NULL) {
+ _DEBUG_INFO("[%s] no handler for key\n", __func__);
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+ _EXTERN_FUNC_EXIT;
+ return dm_get_engine_status(db_handler, engine_id, status);
+}
+
+DM_ERROR Get_AII_Engine_Status(engine_status ** status_list, int *count)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DB_HANDLER *db_handler = _get_agent_handler(GET_THREAD_ID);
+ if (db_handler == NULL) {
+ _DEBUG_INFO("[%s] no handler for key\n", __func__);
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return dm_get_aII_engine_status(db_handler, status_list, count);
+}
+
+int IsExist_Engine_id(int engine_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DB_HANDLER *db_handler = _get_agent_handler(GET_THREAD_ID);
+ if (db_handler == NULL) {
+ _DEBUG_INFO("[%s] no handler for key\n", __func__);
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return dm_isExist_engine_id(db_handler, engine_id);
+}
+
+/*
+ * ==================================
+ * DB module internal API
+ * ==================================
+ */
+DM_ERROR _add_agent_handler(unsigned int key, DB_HANDLER * pHandler)
+{
+ _INNER_FUNC_ENTER;
+
+ if (pDBHandlerMgr == NULL || pDBHandlerMgr->db_handlerTable_mutex == NULL) {
+ return DM_ERR_UNKNOWN;
+ }
+
+ DM_ERROR ret = DM_OK;
+
+ unsigned int *pKey_copy = (unsigned int *)calloc(1, sizeof(unsigned int));
+ if (pKey_copy == NULL) {
+ _INNER_FUNC_EXIT;
+ return COMMON_ERR_ALLOC;
+ }
+
+ *pKey_copy = key;
+
+ pthread_mutex_lock(pDBHandlerMgr->db_handlerTable_mutex);
+ if (pDBHandlerMgr->db_handlerTable == NULL) {
+ ret = __alloc_agent_dc_handlerTable();
+ if (ret != DM_OK)
+ goto addagentHandler;
+ }
+
+ /* insert to handler */
+ _DEBUG_TRACE("[%s] Key = %d, Handler = %p !\n", __func__, key, pHandler);
+ g_hash_table_insert(pDBHandlerMgr->db_handlerTable, pKey_copy, pHandler);
+
+#ifdef DC_PRINT
+ /* For test log */
+ __print_agentDBHashTableLog();
+#endif
+ pthread_mutex_unlock(pDBHandlerMgr->db_handlerTable_mutex);
+ if(pKey_copy != NULL) {
+ free(pKey_copy);
+ }
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ addagentHandler:
+ pthread_mutex_unlock(pDBHandlerMgr->db_handlerTable_mutex);
+ if(pKey_copy != NULL) {
+ free(pKey_copy);
+ }
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR _remove_agent_handler(unsigned int key)
+{
+ _INNER_FUNC_ENTER;
+
+ if (pDBHandlerMgr == NULL || pDBHandlerMgr->db_handlerTable_mutex == NULL || pDBHandlerMgr->db_handlerTable == NULL) {
+ _INNER_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+
+ /* remove the handler to hash table */
+ pthread_mutex_lock(pDBHandlerMgr->db_handlerTable_mutex);
+ int isSuccess = g_hash_table_remove(pDBHandlerMgr->db_handlerTable, &key);
+ pthread_mutex_unlock(pDBHandlerMgr->db_handlerTable_mutex);
+
+#ifdef DC_PRINT
+ /* for test log */
+ __print_agentDBHashTableLog();
+#endif
+
+ _DEBUG_TRACE("[%s] end !\n", __func__);
+ if (isSuccess == 1) {
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return DM_ERR_UNKNOWN;
+}
+
+DB_HANDLER *_get_agent_handler(unsigned int key)
+{
+ _INNER_FUNC_ENTER;
+
+ if (pDBHandlerMgr == NULL || pDBHandlerMgr->db_handlerTable_mutex == NULL || pDBHandlerMgr->db_handlerTable == NULL) {
+ _DEBUG_TRACE("[%s] DM_ERR_UNKNOWN !\n", __func__);
+ _INNER_FUNC_EXIT;
+
+ return 0;
+ }
+
+ /* get the handler to hash table */
+ pthread_mutex_lock(pDBHandlerMgr->db_handlerTable_mutex);
+ DB_HANDLER *pHandler = g_hash_table_lookup(pDBHandlerMgr->db_handlerTable, &key);
+ pthread_mutex_unlock(pDBHandlerMgr->db_handlerTable_mutex);
+
+#ifdef DC_PRINT
+ if (pHandler != NULL) {
+ _DEBUG_TRACE("[%s] ######### > Value Search Success(key = %d, handler = %p)\n", __func__, key, pHandler);
+ } else {
+ _DEBUG_TRACE("[%s] ######### > Value Search Fail(key = %d, handler = %p)\n", __func__, key, pHandler);
+ }
+#endif
+ _INNER_FUNC_EXIT;
+
+ return pHandler;
+}
+
+/* static function implementation */
+static DM_ERROR __alloc_agent_dc_handlerTable()
+{
+ _INNER_FUNC_ENTER;
+
+ if (pDBHandlerMgr != NULL) {
+ pDBHandlerMgr->db_handlerTable = g_hash_table_new_full(g_int_hash, g_int_equal, ___destory_agentDBHashTableKey, ___destroy_agentDBHashTableValue);
+ if (pDBHandlerMgr->db_handlerTable == NULL) {
+ _DEBUG_TRACE("[%s] Not Create agent dc handler hash table \n", __func__);
+ _INNER_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ } else {
+ _DEBUG_TRACE("[%s] create agent dc handler hash table \n", __func__);
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return DM_OK;
+}
+
+static DM_ERROR __alloc_agent_dc_handlerTable_mutex()
+{
+ _INNER_FUNC_ENTER;
+
+ if (pDBHandlerMgr != NULL) {
+
+ pDBHandlerMgr->db_handlerTable_mutex = (pthread_mutex_t *) calloc(1, sizeof(pthread_mutex_t));
+ if (pDBHandlerMgr->db_handlerTable_mutex == NULL) {
+ _DEBUG_TRACE("[%s] Not Create agent dc handler hash table mutex \n", __func__);
+ _INNER_FUNC_EXIT;
+ return COMMON_ERR_ALLOC;
+ } else {
+
+ if (pthread_mutex_init(pDBHandlerMgr->db_handlerTable_mutex, 0) != 0) {
+ _DEBUG_TRACE("[%s] Not init agent dc handler hash table mutex\n", __func__);
+ _INNER_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+ }
+ _DEBUG_TRACE("[%s] Init agent dc handler hash table mutex\n", __func__);
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return DM_OK;
+}
+
+static DM_ERROR _free_agent_dc_handlerTable()
+{
+ _INNER_FUNC_ENTER;
+
+ if (pDBHandlerMgr != NULL && pDBHandlerMgr->db_handlerTable != NULL) {
+ g_hash_table_destroy(pDBHandlerMgr->db_handlerTable);
+ _DEBUG_TRACE("[%s] db_handlerTable free success !\n", __func__);
+ pDBHandlerMgr->db_handlerTable = 0;;
+ }
+ _INNER_FUNC_EXIT;
+
+ return DM_OK;
+}
+
+static DM_ERROR _free_agent_dc_handlerTable_mutex()
+{
+ _INNER_FUNC_ENTER;
+
+ if (pDBHandlerMgr != NULL && pDBHandlerMgr->db_handlerTable_mutex != NULL) {
+
+ int ret = pthread_mutex_destroy(pDBHandlerMgr->db_handlerTable_mutex);
+ if (ret != 0) {
+ _DEBUG_TRACE("[%s] db_handlerTable_mutex free error !\n", __func__);
+ return DM_ERR_UNKNOWN;
+ } else {
+ free(pDBHandlerMgr->db_handlerTable_mutex);
+ pDBHandlerMgr->db_handlerTable_mutex = 0;
+ _DEBUG_TRACE("[%s] db_handlerTable_mutex free success !\n", __func__);
+ }
+ }
+ _INNER_FUNC_EXIT;
+
+ return DM_OK;
+}
+
+static DM_ERROR _create_agentDBHandlerMgrInfo()
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ if (pDBHandlerMgr != NULL) {
+
+ /* alloc agent db hander hash table */
+ ret = __alloc_agent_dc_handlerTable();
+ if (ret != DM_OK)
+ goto allocAgentDBHandlerMgrInfoErr;
+
+ /* alloc agent db hander hash table mutex */
+ ret = __alloc_agent_dc_handlerTable_mutex();
+ if (ret != DM_OK)
+ goto allocAgentDBHandlerMgrInfoErr;
+ }
+ _INNER_FUNC_EXIT;
+
+ return DM_OK;
+
+ allocAgentDBHandlerMgrInfoErr:
+ Free_DB_Handler_Mgr();
+
+ _INNER_FUNC_EXIT;
+ return DM_ERR_UNKNOWN;
+}
+
+static void ___destroy_agentDBHashTableValue(void *pHandler)
+{
+ _INNER_FUNC_ENTER;
+
+ _DEBUG_VERBOSE("[%s] start \n", __func__);
+ if ((DB_HANDLER *) pHandler != 0) {
+ dm_close_agent((DB_HANDLER *) pHandler);
+ }
+
+ _INNER_FUNC_EXIT;
+}
+
+static void ___destory_agentDBHashTableKey(void *key)
+{
+ _INNER_FUNC_ENTER;
+
+ _DEBUG_VERBOSE("[%s] start \n", __func__);
+ if ((unsigned int *)key != 0) {
+ free((unsigned int *)key);
+ }
+ _INNER_FUNC_EXIT;
+
+}
+
+/*
+static void __print_agentDBHashTableLog()
+{
+ _DEBUG_VERBOSE("[%s] ---------HashKeyList --------\n", __func__);
+ int size = g_hash_table_size(pDBHandlerMgr->db_handlerTable);
+ _DEBUG_VERBOSE("[%s] pDBHandlerMgr->db_handlerTable Size is %d\n", __func__, size);
+ _DEBUG_VERBOSE("[%s] ----------------------------------------\n", __func__);
+ GList *iter = 0;
+ GList *keyList = g_hash_table_get_keys(pDBHandlerMgr->db_handlerTable);
+ for (iter = keyList; iter != 0; iter = g_list_next(iter))
+ _DEBUG_VERBOSE("[%s] Handler Key %d\n", __func__, *((unsigned int *)(iter->data)));
+ _DEBUG_VERBOSE("[%s] ----------------------------------------\n", __func__);
+}
+*/
diff --git a/src/agent/common/dm_common.c b/src/agent/common/dm_common.c
new file mode 100755
index 0000000..029c0bd
--- /dev/null
+++ b/src/agent/common/dm_common.c
@@ -0,0 +1,1480 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <unistd.h>
+
+/*lib*/
+#include <vconf.h>
+#include <vconf-keys.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+#include <plugin/plugin_slp_sysnoti_alarm.h>
+
+/*dm-agent*/
+#include "framework/platform-event-handler/dm_platform_event_handler.h"
+#include "framework/platform-event-handler/dm_platform_event_handler_internal.h"
+#include "framework/task/oma_dm_task_register.h"
+#include "framework/task/oma_dm_task_request.h"
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "mo-handler/dm_mo_common.h"
+#include "mo-handler/dm_mo_handler.h"
+#include "dm-engine/bootstrap/factory_bootstrap.h"
+#include "dm-engine/fumo/fumo_account.h"
+#include "dm-engine/lawmo/lawmo_account.h"
+#include "dm-engine/cp/dm_cp_security.h"
+#include "ipc_common.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "DM_COMMON"
+#endif
+
+#define MAX_TRY 3
+
+static DM_ERROR _create_engine_status_db();
+
+char *get_new_uri(char *old_object_uri)
+{
+ _EXTERN_FUNC_ENTER;
+
+ char *new_object_uri = NULL;
+ retvm_if(old_object_uri == NULL, NULL, "old_object_uri is NULL!!");
+ _DEBUG_INFO(" old_object_uri = %s ", old_object_uri);
+ new_object_uri = g_strdup_printf("%s", old_object_uri);
+
+ _EXTERN_FUNC_EXIT;
+ return new_object_uri;
+}
+
+static DM_ERROR _create_engine_status_db()
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ ret = Alloc_DB_Handler_Mgr();
+ _DEBUG_TRACE(" Alloc DB Handler Mgr : %d\n", ret);
+
+ ret = DB_Open();
+ _DEBUG_TRACE(" Done Open DB : %d\n", ret);
+
+ ret = DB_Create_Table();
+ _DEBUG_TRACE(" Done Create_Table : %d\n", ret);
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+}
+
+DM_ERROR init_dm()
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ ret = _create_engine_status_db();
+ _DEBUG_INFO(" Done Create_engine_status_db : %d\n", ret);
+
+ ret = task_register();
+ if (ret != DM_OK) {
+ goto error;
+ }
+ /* will delete */
+ ret = register_scheduler();
+ if (ret == -1) {
+ _DEBUG_INFO("fail register alarm : %d ", ret);
+ } else {
+ _DEBUG_INFO("success register alarm : %d ", ret);
+ }
+
+ ret = register_network();
+ if (ret == -1) {
+ _DEBUG_INFO("fail register network : %d ", ret);
+ } else {
+ _DEBUG_INFO("success register network : %d ", ret);
+ }
+
+ ret = register_wap_push();
+ if (ret == -1) {
+ _DEBUG_INFO("fail register wap push : %d ", ret);
+ } else {
+ _DEBUG_INFO("success register wap push : %d ", ret);
+ }
+
+ ret = register_fumo_ip_push();
+ if (ret == -1) {
+ _DEBUG_INFO("fail register fumo ip push : %d ", ret);
+ } else {
+ _DEBUG_INFO("success register fumo ip push : %d ", ret);
+
+ /*todo temp code
+ * will integrate notification UI */
+ /*ret = register_fota_account();
+
+ if (ret == -1) {
+ _DEBUG_INFO("fail register fota account : %d ", ret);
+ } else {
+ _DEBUG_INFO("success register fota account : %d ", ret);
+ } */
+ }
+
+ ret = register_lawmo_samsung_account();
+ if (ret == -1) {
+ _DEBUG_INFO("fail register fmm server : %d ", ret);
+ } else {
+ _DEBUG_INFO("success register fmm server : %d ", ret);
+ }
+
+ ret = register_telephony();
+ if (ret == -1) {
+ _DEBUG_INFO("fail register telephony : %d ", ret);
+ } else {
+ _DEBUG_INFO("success register telephony : %d ", ret);
+ }
+
+ init_default_fumo_config();
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _EXTERN_FUNC_EXIT;
+ _DEBUG_INFO(" end error : %d \n", ret);
+ return ret;
+}
+
+DM_ERROR end_dm()
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR reset_dm()
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ _DEBUG_INFO("--------------------------------------------------------------------------------------------");
+ /* ddf mo db reset */
+ ret = clean_dm_mo();
+ if (ret != DM_OK)
+ goto error;
+
+ /* engine status db reset */
+ //ret = DB_Delete_Table();
+ ret = DB_Reset_Table();
+ if (ret != DM_OK)
+ goto error;
+
+ /* omadm db */
+ sync_agent_empty_agent_default_table(SYNC_AGENT_DA_TABLE_NAME_CONFIG);
+ //sync_agent_empty_all_agent_table()
+
+ /*fumo, lawmo data in alarm db */
+ _DEBUG_INFO("--------------------------------------------------------------------------------------------");
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _EXTERN_FUNC_EXIT;
+ _DEBUG_INFO(" end error : %d \n", ret);
+ return ret;
+}
+
+DM_ERROR auto_operate_service_engine()
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ engine_status *status = NULL;
+
+ if (IsExist_Engine_id(FUMO_SERVICE_ENGINE) != 0) {
+ printf("engine id VALUE : %d ", FUMO_SERVICE_ENGINE);
+ _DEBUG_INFO("engine id VALUE : %d ", FUMO_SERVICE_ENGINE);
+
+ ret = Get_Engine_Status(FUMO_SERVICE_ENGINE, &status);
+ if (ret != DM_OK || status == NULL)
+ goto error;
+
+ if (status->engine_status == 0) {
+ ret = Delete_Engine_Status(FUMO_SERVICE_ENGINE);
+ if (ret != DM_OK)
+ goto error;
+ } else {
+ ret = fumo_serviceEngine_task_request();
+ _DEBUG_INFO("fumo server engine task request : %d", ret);
+ }
+ if (status != NULL) {
+ Free_Memory_Engine_Status(&status, 1);
+ }
+ }
+
+ if (IsExist_Engine_id(LAWMO_SERVICE_ENGINE) != 0) {
+ printf("engine id VALUE : %d ", LAWMO_SERVICE_ENGINE);
+ _DEBUG_INFO("engine id VALUE : %d ", LAWMO_SERVICE_ENGINE);
+
+ ret = Get_Engine_Status(LAWMO_SERVICE_ENGINE, &status);
+ if (ret != DM_OK || status == NULL)
+ goto error;
+
+ if (status->engine_status == 0) {
+ ret = Delete_Engine_Status(LAWMO_SERVICE_ENGINE);
+ if (ret != DM_OK)
+ goto error;
+ } else {
+ ret = lawmo_serviceEngine_task_request();
+ }
+ if (status != NULL)
+ Free_Memory_Engine_Status(&status, 1);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+
+ if (status != NULL)
+ Free_Memory_Engine_Status(&status, 1);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+int register_wap_push()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = 1;
+ int i = 0;
+
+ for (i = 0; i < MAX_TRY; ++i) {
+ sync_agent_pm_return_e err_wappush = sync_agnet_register_user_callback(6, NULL, 2, dm_wap_push_incomming_callback, dm_wap_push_operation_callback);
+
+ if (err_wappush != SYNC_AGENT_PM_SUCCESS) {
+ _DEBUG_INFO("failed set_WAP-PUSH_Callback()");
+ ret = -1;
+ sleep(1);
+ } else {
+ _DEBUG_INFO("WAP-PUSH SUCCESS");
+ break;
+ }
+ }
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
+
+int register_fumo_ip_push()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = 1;
+ int i = 0;
+
+ for (i = 0; i < MAX_TRY; ++i) {
+ sync_agent_pm_return_e err_ippush = sync_agnet_register_user_callback(2, NULL, 1, dm_ip_push_callback);
+ if (err_ippush != SYNC_AGENT_PM_SUCCESS) {
+// if (err_ippush == PMCI_CONNECTION_FAIL) {
+// _DEBUG_INFO("failed set_IP-PUSH_Callback() : connection failed !!");
+//
+// } else if (err_ippush == PMCI_REGISTRATION_FAIL) {
+// _DEBUG_INFO("failed set_IP-PUSH_Callback() : registration failed !!");
+// } else {
+ _DEBUG_INFO("failed set_IP-PUSH_Callback()");
+// }
+
+ sleep(1);
+ ret = -1;
+ } else {
+ _DEBUG_INFO("IP-PUSH SUCCESS");
+ ret = 1;
+ break;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+int register_lawmo_samsung_account()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = 1;
+ int i = 0;
+
+ for (i = 0; i < MAX_TRY; ++i) {
+ sync_agent_pm_return_e err_samsung_account = sync_agnet_register_user_callback(4, NULL, 2, register_lawmo_account, deregister_lawmo_account);
+ if (err_samsung_account != SYNC_AGENT_PM_SUCCESS) {
+// if (err_samsung_account == PMCI_CONNECTION_FAIL) {
+// _DEBUG_INFO("failed set_SAMSUNG_ACCOUNT_Callback() : connection failed !!");
+//
+// } else if (err_samsung_account == PMCI_REGISTRATION_FAIL) {
+// _DEBUG_INFO("failed set_SAMSUNG_ACCOUNT_Callback() : registration failed !!");
+// } else {
+ _DEBUG_INFO("failed set_SAMSUNG_ACCOUNT_Callback()");
+// }
+
+ sleep(1);
+ ret = -1;
+ } else {
+ _DEBUG_INFO("SAMSUNG_ACCOUNT SUCCESS");
+ ret = 1;
+ break;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+int register_telephony()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = 1;
+ int i = 0;
+
+ for (i = 0; i < MAX_TRY; ++i) {
+ sync_agent_pm_return_e err_telephony = sync_agnet_register_user_callback(5, NULL, 2, dm_telephony_incomming_callback, dm_telephony_end_callback);
+ if (err_telephony != SYNC_AGENT_PM_SUCCESS) {
+ _DEBUG_INFO("failed set_TELEPHONY_Callback()");
+
+ ret = -1;
+ sleep(1);
+ } else {
+ _DEBUG_INFO("TELEPHONY_SUCCESS");
+ ret = 1;
+ break;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+int register_network()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = 1;
+ int i = 0;
+
+ for (i = 0; i < MAX_TRY; ++i) {
+ sync_agent_pm_return_e err_network = sync_agnet_register_user_callback(3, NULL, 2, network_on_callback, network_off_callback, network_change_callback);
+ if (err_network != SYNC_AGENT_PM_SUCCESS) {
+ _DEBUG_INFO("failed set_network_Callback()");
+ ret = -1;
+ sleep(1);
+ } else {
+ _DEBUG_INFO("NETWORK_SUCCESS");
+ ret = 1;
+ break;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+int register_scheduler()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = 0;
+ int i = 0;
+
+ for (i = 0; i < MAX_TRY; ++i) {
+ sync_agent_pm_return_e err_alarm = sync_agnet_register_user_callback(1, NULL, 1, alarm_callback);
+ if (err_alarm != SYNC_AGENT_PM_SUCCESS) {
+ _DEBUG_INFO("Fail PMCI_Init_Specific_Type\n");
+ ret = -1;
+ sleep(1);
+ } else {
+ _DEBUG_INFO("Success PMCI_Init_Specific_Type\n");
+ ret = 1;
+ break;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+void network_cancel_callback(void *user_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int *net_session_id = (int *)(user_data);
+ sync_agent_na_result_e error;
+ error = sync_agent_cancel_msg(1, (*net_session_id));
+ _DEBUG_INFO("naci cancel msg status : %d\n", error);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void network_connection_delay()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int network_status = 0;
+ int interval = 1; //(seconds)
+ int retry_cnt = 3;
+
+ char file_name[256] = { 0, };
+ char *net_status;
+ int snd_size;
+ FILE *send_fp = NULL;
+ _DEBUG_INFO("start");
+ sleep(2);
+
+ network_status = sync_agent_check_network_status(interval, retry_cnt);
+
+ net_status = g_strdup_printf("%d", network_status);
+ snprintf(file_name, 256, "%s", "/opt/data/network_connect_status.txt");
+ send_fp = fopen(file_name, "w");
+ if (send_fp != NULL) {
+ snd_size = fwrite(net_status, strlen(net_status), 1, send_fp);
+ fclose(send_fp);
+ } else {
+ _DEBUG_INFO("fopen - network_connect_status - fail");
+ }
+
+ if (network_status != 1) {
+ _DEBUG_INFO("------------------------------------------NETOWKR CONNECT FAIL------------------------------------------");
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+DM_ERROR set_account_registration_alarm(char *alarm_str, CONFIG_TYPE alarm_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ sync_agent_da_return_e result = SYNC_AGENT_DA_SUCCESS;
+
+ int count = 0;
+ GList *list = NULL;
+
+ result = sync_agent_get_config_list(alarm_type, &list);
+ if (result != SYNC_AGENT_DA_SUCCESS) {
+ _EXTERN_FUNC_EXIT;
+ return COMMON_ERR_FW_CONFIG;
+ }
+
+ count = g_list_length(list);
+
+ _DEBUG_INFO("alarm count: %d\n", count);
+ if (count > 0 && list != NULL) {
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ } else {
+ ret = add_alarm_item(INTERVAL_1DAY, alarm_str, alarm_type);
+ if (ret != DM_OK)
+ goto error;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+void delete_account_registration_alarm(char *alarm_str, CONFIG_TYPE alarm_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ delete_alarm_item(alarm_str, alarm_type);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+DM_ERROR add_alarm_item(Reminder_Interval interval, char *alarm_type, CONFIG_TYPE conf_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ /*int week[] = {DAY_SUN, DAY_MON, DAY_TUE, DAY_WED, DAY_THU, DAY_FRI, DAY_SAT}; */
+
+ time_t current_time;
+ struct tm *struct_time;
+ time(&current_time);
+ struct_time = localtime(&current_time);
+
+ pmci_alarm_s *alarm_info = (pmci_alarm_s *) calloc(1, sizeof(pmci_alarm_s));
+ if (alarm_info == NULL) {
+ _DEBUG_INFO("alloc fail");
+ _EXTERN_FUNC_EXIT;
+ return COMMON_ERR_ALLOC;
+ }
+
+ alarm_info->start_alarm_time = g_strdup_printf("%02d-%02d-%02dT%02d:%02d:%02dZ", struct_time->tm_year + 1900, struct_time->tm_mon + 1, struct_time->tm_mday, struct_time->tm_hour, struct_time->tm_min, struct_time->tm_sec);
+
+ //REALE
+ alarm_info->is_disposable = 0;
+
+ // TEST
+ //alarm_info->is_disposable = 1;
+
+ switch (interval) {
+ /*
+ case INTERVAL_NONE :
+ {
+ // 1minute
+ alarm_info->repeat_type = REPEAT ;
+ //alarm_info->repeat_value = ((1*60)*60);
+ alarm_info->repeat_value = ((1*60)*1);
+ }
+ break;
+ */
+ case INTERVAL_1HOUR:
+ {
+ /* 1 hour */
+ alarm_info->repeat_type = REPEAT;
+ alarm_info->repeat_value = ((1 * 60) * 60);
+ //alarm_info->repeat_value = ((1*60)*1);
+ }
+ break;
+ case INTERVAL_3HOURS:
+ {
+ /* 4 hour */
+ alarm_info->repeat_type = REPEAT;
+ alarm_info->repeat_value = ((3 * 60) * 60);
+ }
+ break;
+ case INTERVAL_6HOURS:
+ {
+ /* 6 hour */
+ alarm_info->repeat_type = REPEAT;
+ alarm_info->repeat_value = ((6 * 60) * 60);
+
+ }
+ break;
+ case INTERVAL_12HOURS:
+ {
+ /* 12 hour */
+ alarm_info->repeat_type = REPEAT;
+ alarm_info->repeat_value = ((12 * 60) * 60);
+
+ }
+ break;
+ case INTERVAL_1DAY:
+ {
+ /* 1 day */
+ alarm_info->repeat_type = REPEAT;
+ alarm_info->repeat_value = ((24 * 60) * 60);
+ }
+ break;
+ /*
+ case INTERVAL_7DAYS:
+ {
+ // 1 week
+ alarm_info->repeat_type = REPEAT_WEEKLY ;
+ alarm_info->repeat_value = week[struct_time->tm_wday];
+ }
+ break;
+ */
+ case INTERVAL_1MONTH:
+ {
+ alarm_info->repeat_type = REPEAT_MONTHLY;
+ alarm_info->repeat_value = 0;
+ }
+ case INTERVAL_CANCEL:
+ goto return_part;
+ break;
+ default:
+ break;
+ }
+
+ _DEBUG_INFO("######### Alarm Info #####################\n");
+ _DEBUG_INFO("time = %s\n", alarm_info->start_alarm_time);
+ _DEBUG_INFO("repeat_mode = %d, repeat_value = %d\n", alarm_info->repeat_type, alarm_info->repeat_value);
+ _DEBUG_INFO("is_disposable = %d\n", alarm_info->is_disposable);
+
+/* if(conf_type == FUMO_INTERVAL_TYPE)
+ delete_alarm_item(FUMO_INTERVAL, FUMO_INTERVAL_TYPE);*/
+
+ int alarm_id = 0;
+ int alarm_ret = 0;
+ sync_agent_pm_return_e err = SYNC_AGENT_PM_SUCCESS;
+
+ /*add alarm service */
+ err = sync_agent_add_service_data(1, alarm_info, &alarm_id);
+ if (err != SYNC_AGENT_PM_SUCCESS) {
+ _DEBUG_INFO("Fail PMCI_Add_Item_To_Specific_Type\n");
+ ret = DM_ERR_FUMO_INTERNAL_SCHEDULER_ERROR;
+ } else {
+ /*add framework config db */
+ alarm_ret = set_alarm_config_int(conf_type, alarm_type, alarm_id, alarm_type);
+ if (alarm_ret == 0) {
+ ret = DM_ERR_FUMO_INTERNAL_SCHEDULER_ERROR;
+ }
+ }
+
+ if (alarm_info != NULL) {
+ str_free(&(alarm_info->start_alarm_time));
+ free(alarm_info);
+ alarm_info = NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ return_part:
+
+ if (alarm_info != NULL) {
+ str_free(&(alarm_info->start_alarm_time));
+ free(alarm_info);
+ alarm_info = NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ _DEBUG_INFO("end error : %d ", ret);
+ return ret;
+}
+
+void delete_alarm_item(char *alarm_type, CONFIG_TYPE conf_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int count = 0;
+ int before_alarm_id;
+ int ret = 0;
+ sync_agent_da_return_e result = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_pm_return_e pm_result = SYNC_AGENT_PM_SUCCESS;
+
+ sync_agent_da_config_s *config = NULL;
+
+ GList *list = NULL;
+
+ result = sync_agent_get_config_list(conf_type, &list);
+ count = g_list_length(list);
+
+ _DEBUG_INFO("alarm count: %d\n", count);
+ if (count > 0 && list != 0) {
+ config = (sync_agent_da_config_s *) g_list_nth_data(list, 0);
+ _DEBUG_INFO("------------------------------------------alarm id : %s----------------------------------------------\n", config->value);
+ ret = chartoint(config->value, &before_alarm_id);
+ if (ret == 1) {
+ pm_result = sync_agent_remove_service_data(1, before_alarm_id);
+ _DEBUG_INFO("delete alarm %d", result);
+
+ if (pm_result == SYNC_AGENT_PM_SUCCESS) {
+ result = sync_agent_delete_config(conf_type, alarm_type);
+ _DEBUG_INFO("delete alarm config %d", result);
+ }
+ } else {
+ _DEBUG_INFO("fail get alarm id");
+ }
+ }
+
+ sync_agent_free_config_list(list);
+ _EXTERN_FUNC_EXIT;
+
+}
+
+SERVICE_SERVER_TYPE get_service_engine_type(const char *server_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(server_id == NULL, NO_ENGINE_TYPE, "server_id is NULL!!");
+
+ _DEBUG_INFO("get- service engine type by server id : %s", server_id);
+ _EXTERN_FUNC_EXIT;
+ return get_engine_type_by_serverid(server_id);
+}
+
+DM_ERROR get_server_info(Event_Contents * pEvent_data, char **server_id, char **session_id, int *session_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((pEvent_data) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "pEvent_data is NULL!!");
+ retvm_if((pEvent_data->server_id) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "server_id is NULL!!");
+
+ (*server_id) = strdup(pEvent_data->server_id);
+ _DEBUG_INFO(" server id : %s\n", *server_id);
+
+ if (pEvent_data->session_id != NULL) {
+ (*session_id) = strdup(pEvent_data->session_id);
+ _DEBUG_INFO(" session_id : %s\n", *session_id);
+ }
+
+ (*session_type) = pEvent_data->type;
+ _DEBUG_INFO("session type : %d\n", *session_type);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+void get_service_engine_id(ENGINE_ID * service_engine_id, char *ui_mode)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (ui_mode == NULL)
+ return;
+
+ if (!strcmp(ui_mode, OMADM_FUMO_UI_TYPE) || !strcmp(ui_mode, OMADM_FUMO_NOTI_UI_TYPE)) {
+ *service_engine_id = FUMO_SERVICE_ENGINE;
+ _DEBUG_INFO("fumo service");
+ } else {
+ _DEBUG_INFO("other service");
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+DM_ERROR fumo_service_start(Event_Contents * pEvent_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((pEvent_data) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "pEvent_data is NULL!!");
+
+ switch (pEvent_data->noti_type) {
+ case NOTI_TYPE_NOT_SPECIFIED:
+ _DEBUG_INFO("NOTI_TYPE_NOT_SPECIFIED");
+ //temp version for gcf test
+ pEvent_data->ui_mode = strdup(OMADM_FUMO_BACKGROUND_UI_TYPE);
+ pEvent_data->noti_type = NOTI_TYPE_BACKGRUOUND;
+ ret = dm_fumo_common_task_request(pEvent_data);
+ _DEBUG_INFO("NOTI NOTI_TYPE_BACKGRUOUND : %d", ret);
+ if (ret != DM_OK) {
+ goto error;
+ }
+ break;
+ case NOTI_TYPE_BACKGRUOUND:
+ pEvent_data->ui_mode = strdup(OMADM_FUMO_BACKGROUND_UI_TYPE);
+ ret = dm_fumo_common_task_request(pEvent_data);
+ _DEBUG_INFO("NOTI NOTI_TYPE_BACKGRUOUND : %d", ret);
+ if (ret != DM_OK) {
+ goto error;
+ }
+ break;
+ case NOTI_TYPE_INFOMATIVE:
+ pEvent_data->ui_mode = strdup(OMADM_FUMO_BACKGROUND_UI_TYPE);
+ ret = dm_fumo_common_task_request(pEvent_data);
+ _DEBUG_INFO("NOTI NOTI_TYPE_INFOMATIVE : %d", ret);
+ if (ret != DM_OK) {
+ goto error;
+ }
+ break;
+ case NOTI_TYPE_USERINTERACTION:
+ pEvent_data->ui_mode = strdup(OMADM_FUMO_NOTI_UI_TYPE);
+ ret = dm_fumo_ui_task_request(pEvent_data);
+ _DEBUG_INFO("NOTI NOTI_TYPE_USERINTERACTION : %d ", ret);
+ if (ret != DM_OK) {
+ goto error;
+ }
+ break;
+ default:
+ break;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+ error:
+ event_data_free((void *)pEvent_data);
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+
+}
+
+DM_ERROR get_fumo_ui_mode(char **ui_mode)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ engine_status *status = NULL;
+ ret = Get_Engine_Status(FUMO_SERVICE_ENGINE, &status);
+ if (ret != DM_OK) {
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ }
+
+ if (status != NULL) {
+
+ if (status->ui_mode != NULL) {
+ (*ui_mode) = strdup(status->ui_mode);
+
+ _DEBUG_INFO("==================Fumo ui : %s==================\n", *ui_mode);
+ } else {
+ _DEBUG_INFO("ui mode null");
+ }
+
+ Free_Memory_Engine_Status(&status, 1);
+
+ } else {
+ _DEBUG_INFO("status is null");
+ }
+
+ _DEBUG_INFO("end");
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+int check_existed_fumo_reminder_interval()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int exist = 0;
+ sync_agent_da_return_e result = SYNC_AGENT_DA_SUCCESS;
+ result = sync_agent_is_exist_config(FUMO_INTERVAL_TYPE, FUMO_INTERVAL, &exist);
+ _DEBUG_INFO("agent is exist result : %d", result);
+
+ _EXTERN_FUNC_EXIT;
+ return exist;
+}
+
+int init_default_fumo_config()
+{
+ _EXTERN_FUNC_ENTER;
+
+ _EXTERN_FUNC_EXIT;
+ return set_config_int(FUMO_WIFI_ONLY_TYPE, FUMO_WIFI_ONLY_CONFIG, 0, FUMO, 1);
+}
+
+int set_config_int(CONFIG_TYPE config_type, char *key, int value, char *accessName, int isFirst)
+{
+ _EXTERN_FUNC_ENTER;
+ int ret = 1;
+ sync_agent_da_return_e result;
+ sync_agent_da_config_s config;
+ int exist = 0;
+
+ config.access_name = accessName;
+ config.config_id = config_type;
+ config.key = key;
+ config.value = g_strdup_printf("%d", value);
+ config.type = "int";
+
+ result = sync_agent_is_exist_config(config_type, key, &exist);
+ if (result != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_INFO("exist config fail : %d", result);
+ ret = -1;
+ } else {
+ if (exist == 0 && isFirst == 1) {
+ _DEBUG_INFO("default add config : %s\n", key);
+ result = sync_agent_add_config(&config);
+ if (result != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_INFO("fail add : %d", result);
+ ret = -1;
+ } else {
+ _DEBUG_INFO("Success add config : %s, : %d\n", key, value);
+ }
+ } else {
+ result = sync_agent_update_config(&config);
+ //free config
+ if (result != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_INFO("fail update : %d", result);
+ ret = -1;
+ } else {
+ _DEBUG_INFO("Success update config : %s, : %d\n", key, value);
+ }
+ }
+ }
+
+ str_free(&(config.value));
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
+
+int get_config_int(CONFIG_TYPE config_id, char *key)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_da_return_e result = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_config_s *config = NULL;
+ int value = 1;
+ int ret = -1;
+
+ result = sync_agent_create_config(&config);
+ if (result != SYNC_AGENT_DA_SUCCESS) {
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+
+ result = sync_agent_get_config(config_id, key, &config);
+ _DEBUG_INFO("---------------------------result : %d-------------------------\n", result);
+ if (result == 1) {
+ _DEBUG_INFO("Success get config value");
+
+ ret = chartoint(config->value, &value);
+ _DEBUG_INFO("result : %d , key : %s value : %d\n", result, key, value);
+
+ if (ret == 0) {
+ _DEBUG_INFO("fail get config value");
+ ret = -1;
+ goto return_part;
+ } else {
+ _DEBUG_INFO("success get config value");
+ ret = value;
+ }
+ } else {
+ _DEBUG_INFO("fail get config value");
+ }
+
+ return_part:
+
+ sync_agent_free_config(config);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+int set_alarm_config_int(CONFIG_TYPE config_type, char *key, int value, char *accessName)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = 0;
+ sync_agent_da_return_e result;
+ sync_agent_da_config_s config;
+ int exist = 0;
+
+ config.access_name = accessName;
+ config.config_id = config_type;
+ config.key = key;
+ config.value = g_strdup_printf("%d", value);
+ config.type = "int";
+
+ result = sync_agent_is_exist_config(config_type, key, &exist);
+ if (result != SYNC_AGENT_DA_SUCCESS)
+ ret = 0;
+
+ if (exist == 0) {
+ _DEBUG_INFO("default add config : %s\n", key);
+ result = sync_agent_add_config(&config);
+
+ if (result != SYNC_AGENT_DA_SUCCESS)
+ ret = 0;
+ } else {
+ result = sync_agent_update_config(&config);
+ _DEBUG_INFO("update alarm config db ");
+ }
+
+ ret = 1;
+ str_free(&(config.value));
+ _DEBUG_INFO("end : %d", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+int get_wifi_only_config()
+{
+ _EXTERN_FUNC_ENTER;
+
+ _EXTERN_FUNC_EXIT;
+ return get_config_int(FUMO_WIFI_ONLY_TYPE, FUMO_WIFI_ONLY_CONFIG);
+}
+
+int set_wifi_only_config(int value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _EXTERN_FUNC_EXIT;
+ return set_config_int(FUMO_WIFI_ONLY_TYPE, FUMO_WIFI_ONLY_CONFIG, value, FUMO, 0);
+}
+
+DM_ERROR get_battery_state(char **battery_level)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ sync_agent_dev_return_e err = SYNC_AGENT_DEV_RETURN_SUCCESS;
+
+ err = sync_agent_get_devinfo(2, "Battery", battery_level);
+ if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ goto error;
+ }
+ if ((*battery_level) == NULL) {
+ goto error;
+ }
+
+ _DEBUG_INFO("\n========battery ======== %s\n", *battery_level);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _EXTERN_FUNC_EXIT;
+ return DM_GET_BATTERY_ERROR;
+}
+
+DM_ERROR get_telephony_state(int *now_calling)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+/*
+ * vconf( framework )
+ */
+ int tel_value;
+ if (vconf_get_int(VCONFKEY_CALL_STATE, &tel_value) != 0)
+ goto error;
+
+ switch (tel_value) {
+ case VCONFKEY_CALL_VOICE_CONNECTING:
+ case VCONFKEY_CALL_VOICE_ACTIVE:
+ case VCONFKEY_CALL_VIDEO_CONNECTING:
+ case VCONFKEY_CALL_VIDEO_ACTIVE:
+ (*now_calling) = 1;
+ break;
+ case VCONFKEY_CALL_OFF:
+ (*now_calling) = 0;
+ break;
+ default:
+ break;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _EXTERN_FUNC_EXIT;
+ return DM_TELEPHONY_ERROR;
+
+}
+
+void network_state_callback()
+{
+ _EXTERN_FUNC_ENTER;
+
+ /*typedef enum {
+ NETWORK_NONE, initial network type
+ NETWORK_3G_ON, network UMTS on
+ NETWORK_3G_OFF, network UMTS off
+ NETWORK_WIFI_ON, network WIFI on
+ NETWORK_WIFI_ON_NOT_CONNECTED, network WIFI on but not connected
+ NETWORK_WIFI_OFF, network WIFI off
+ NETWORK_WIFI_3G_ON, network UMTS and WIFI on
+ } FW_NETWORK_TYPE;
+ #endif
+ */
+
+ /*sync_agent_na_result_e err;
+ int net_type;
+ err = NACI_Get_Network_Type(&net_type);
+ if(err != SYNC_AGENT_NA_SUCCESS)
+ goto error;
+
+ switch(net_type)
+ {
+ case 1:
+ case 3:
+
+ * search db
+ * generic alert
+ * fumo (not alarm)
+ * lawmo( not alarm)
+ * deregister vconf callback
+
+ break;
+ case 0:
+ case 2:
+ case 5:
+ case 6:
+ break;
+ default:
+ break;
+ }
+
+ error: */
+ _EXTERN_FUNC_EXIT;
+ return;
+}
+
+DM_ERROR existed_sd_card_memory(int *existed_sd)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+/*
+ * vconf( framework )
+ * //only one sd card
+ */
+ int mmc_value = 0;
+ int err = 0;
+
+ err = get_mmc_state(&mmc_value);
+ if (err == 0) {
+ (*existed_sd) = 0;
+ goto error;
+ } else {
+ if (mmc_value == 1) {
+ (*existed_sd) = 1;
+
+ /*for make empty folder */
+ char *downlaod_folder = NULL;
+ char *save_folder = NULL;
+ ret = get_fota_download_dir(MEMORY_SD_CARD, &downlaod_folder);
+ if (ret != DM_OK) {
+ goto error;
+ }
+ ret = get_fota_save_dir(MEMORY_SD_CARD, &save_folder);
+ if (ret != DM_OK) {
+ goto error;
+ }
+
+ str_free(&downlaod_folder);
+ str_free(&save_folder);
+ } else {
+ (*existed_sd) = 0;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+
+ _EXTERN_FUNC_EXIT;
+ return DM_SD_CARD_ERROR;
+}
+
+void get_roaming_state(int *roaming_state)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int roaming_config = 0;
+
+ if (vconf_get_int(VCONFKEY_TELEPHONY_SVC_ROAM, roaming_state) != 0) {
+ *roaming_state = -1;
+ _DEBUG_INFO("end , roaming state : %d", *roaming_state);
+ } else {
+ if (*roaming_state == 0) {
+ /*not roaming svc area */
+ _DEBUG_INFO("end , roaming state : %d", *roaming_state);
+ _EXTERN_FUNC_EXIT;
+ return;
+ } else {
+ /*roaming svc area */
+ if (vconf_get_bool(VCONFKEY_SETAPPL_STATE_DATA_ROAMING_BOOL, &roaming_config) != 0) {
+ *roaming_state = -1;
+ _DEBUG_INFO("end , roaming state : %d", *roaming_state);
+ } else {
+ if (roaming_config == 1) {
+ /*
+ * do service roaming service
+ * check wifi
+ */
+ _DEBUG_INFO("end , roaming state : %d", *roaming_state);
+ return;
+ } else {
+ /*don not service at roaming svc */
+ *roaming_state = -1;
+ _DEBUG_INFO("end , roaming state : %d", *roaming_state);
+ }
+ }
+ }
+ }
+ _EXTERN_FUNC_EXIT;
+}
+
+void get_call_sate(int *call_state)
+{
+ _EXTERN_FUNC_ENTER;
+ /*0 : do service
+ * 1 : dont service
+ * 2 : ?
+ */
+ if (vconf_get_int(VCONFKEY_TELEPHONY_CALL_STATE, call_state) != 0) {
+ *call_state = -1;
+ _DEBUG_INFO("end, call state : %d", *call_state);
+ _EXTERN_FUNC_EXIT;
+ return;
+ } else {
+ if (*call_state == 0) {
+ _DEBUG_INFO("end, call state : %d", *call_state);
+ _EXTERN_FUNC_EXIT;
+ return;
+ } else {
+ *call_state = -1;
+ _DEBUG_INFO("end, call state : %d", *call_state);
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+ }
+}
+
+int get_mmc_state(int *mmc_state)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (vconf_get_int(VCONFKEY_SYSMAN_MMC_STATUS, mmc_state) != 0)
+ goto error;
+
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ error:
+ _EXTERN_FUNC_EXIT;
+ _DEBUG_INFO("end error");
+ return 0;
+}
+
+DM_ERROR compare_memory_space(char *memory_type, long double file_size)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int err;
+ long double sizeFree;
+ long double sizeTotal;
+
+ retvm_if((memory_type) == NULL, COMMON_ERR_IS_NULL, "memory_type is NULL!!");
+
+ err = sync_agent_get_fs_mem_size(memory_type, &sizeFree, &sizeTotal);
+ if (err == 0) {
+ _EXTERN_FUNC_EXIT;
+ return DM_MEMORY_ERROR;
+ }
+
+ _DEBUG_INFO("memory free size : %f, total size : %f ", sizeFree, sizeTotal);
+ if (file_size > sizeFree) {
+ _EXTERN_FUNC_EXIT;
+ return DM_OVER_MEMORY_ERROR;
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return DM_OK;
+}
+
+DM_ERROR get_fota_download_dir(MEMORY_TYPE type, char **download_folder)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_dev_return_e dci_down_ret = SYNC_AGENT_DEV_RETURN_SUCCESS;
+
+ switch (type) {
+ case MEMORY_INTERNAL:
+ _DEBUG_INFO("internal memory");
+ dci_down_ret = sync_agent_get_devinfo(2, "FOTADownDir", download_folder);
+ break;
+ case MEMORY_SD_CARD:
+ _DEBUG_INFO("sd card memory");
+ dci_down_ret = sync_agent_get_devinfo(2, "FOTA_SD_DownDir", download_folder);
+ break;
+ default:
+ _DEBUG_INFO("ERROR NOT USE MEMORY");
+ break;
+ }
+
+ if (dci_down_ret == SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ _DEBUG_INFO(" download : %s", *download_folder);
+
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+ }
+ _DEBUG_INFO("end error : %d ", DM_MEMORY_ERROR);
+ _EXTERN_FUNC_EXIT;
+ return DM_MEMORY_ERROR;
+}
+
+DM_ERROR get_fota_save_dir(MEMORY_TYPE type, char **save_folder)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_dev_return_e dci_down_ret = SYNC_AGENT_DEV_RETURN_SUCCESS;
+
+ switch (type) {
+ case MEMORY_INTERNAL:
+ dci_down_ret = sync_agent_get_devinfo(2, "FOTASaveDir", save_folder);
+ break;
+ case MEMORY_SD_CARD:
+ dci_down_ret = sync_agent_get_devinfo(2, "FOTA_SD_SaveDir", save_folder);
+ break;
+ default:
+ _DEBUG_INFO("ERROR NOT USE MEMORY");
+ break;
+ }
+
+ if (dci_down_ret == SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ _DEBUG_INFO(" save_folder : %s", *save_folder);
+
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+ }
+ _DEBUG_INFO("end error : %d ", DM_MEMORY_ERROR);
+ _EXTERN_FUNC_EXIT;
+ return DM_MEMORY_ERROR;
+}
+
+void delete_fumo_contents(MEMORY_TYPE memory_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO("----------------------------------------------------------firmware update fail delete files-----------------------------------------------------------");
+ char *download_folder = NULL;
+ char *save_folder = NULL;
+
+ //FOTASaveDir //FOTADownDir
+ //dci_save_ret = sync_agent_get_devinfo(2 , "FOTADownDir" , &download_folder);
+ get_fota_download_dir(memory_type, &download_folder);
+ sync_agent_empty_directory_contents(download_folder);
+ //dci_save_ret = sync_agent_get_devinfo(2 , "FOTASaveDir" , &save_folder);
+ get_fota_save_dir(memory_type, &save_folder);
+
+ sync_agent_empty_directory_contents(save_folder);
+ _DEBUG_INFO("delete save folder ");
+
+ str_free(&save_folder);
+ str_free(&download_folder);
+
+ _EXTERN_FUNC_EXIT;
+
+}
+
+void first_server_bootstrap(char *server_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ if (server_id == NULL) {
+ _DEBUG_INFO("server id null");
+ return;
+ }
+
+ Event_Contents *ev_data = (Event_Contents *) calloc(1, sizeof(Event_Contents) + 1);
+ if (ev_data == NULL) {
+ _DEBUG_INFO("alloc fail");
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+ ev_data->server_id = strdup(server_id);
+ ev_data->session_id = NULL;
+ ev_data->type = SERVER_BOOTSTRAP_EVENT;
+ ev_data->ui_mode = NULL;
+
+ _DEBUG_INFO("event type server bootstrap : %d", ev_data->type);
+ _DEBUG_INFO("session id : %s", ev_data->session_id);
+ _DEBUG_INFO("server id : %s", ev_data->server_id);
+
+ /* UI CONFIRM */
+ SERVICE_SERVER_TYPE engine_type;
+ engine_type = get_service_engine_type(ev_data->server_id);
+
+ switch (engine_type) {
+ case SAMSUNG_FUMO_TYPE:
+ case GCF_TYPE:
+ {
+ //when using telephony
+ //DM_ERROR get_telephony_state(int *now_calling);
+ _DEBUG_INFO("engine type : %d", engine_type);
+ ev_data->noti_type = NOTI_TYPE_BACKGRUOUND;
+ ev_data->ui_mode = strdup(OMADM_FUMO_BACKGROUND_UI_TYPE);
+
+ _DEBUG_INFO("noti type : %d", ev_data->noti_type);
+ _DEBUG_INFO("ui mode : %s", ev_data->ui_mode);
+
+ ret = dm_fumo_common_task_request(ev_data);
+ _DEBUG_INFO("dm fumo conmmon task : %d ", ret);
+ if (ret != DM_OK) {
+ goto error;
+ }
+ }
+ break;
+ case SAMSUNG_FMM_TYPE:
+
+ _DEBUG_INFO("engine type : %d", engine_type);
+ ret = dm_lawmo_common_task_request(ev_data);
+ _DEBUG_INFO("dm lawmo conmmon task : %d ", ret);
+ if (ret != DM_OK) {
+ goto error;
+ }
+ break;
+ default:
+ _DEBUG_INFO("dm non engine ", ret);
+ break;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return;
+
+ error:
+ event_data_free((void *)ev_data);
+ _EXTERN_FUNC_EXIT;
+}
+
+int get_default_noti_type(char *ui_mode, NotI_Type noti_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((ui_mode) == NULL, COMMON_ERR_IS_NULL, "ui_mode is NULL!!");
+
+ if (strcmp(OMADM_FUMO_UI_TYPE, ui_mode) == 0) {
+ _EXTERN_FUNC_EXIT;
+ return NOTI_UNKNOWN; //none type
+ } else if (strcmp(OMADM_FUMO_NOTI_UI_TYPE, ui_mode) == 0) {
+ switch (noti_type) {
+ case NOTI_TYPE_NOT_SPECIFIED:
+ case NOTI_TYPE_BACKGRUOUND:
+ case NOTI_TYPE_USERINTERACTION:
+ _EXTERN_FUNC_EXIT;
+ return NOTI_DOWNLOAD; //none type
+ break;
+ case NOTI_TYPE_INFOMATIVE:
+ _EXTERN_FUNC_EXIT;
+ return NOTI_DOWNLOAD; //connect to server
+ break;
+ default:
+ return NOTI_UNKNOWN; //none type
+ break;
+ }
+ } else if (strcmp(OMADM_FUMO_BACKGROUND_UI_TYPE, ui_mode) == 0) {
+ _EXTERN_FUNC_EXIT;
+ return NOTI_UNKNOWN; //none type
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return NOTI_UNKNOWN;
+}
+
+int wifi_only_config(char *config)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((config) == NULL, COMMON_ERR_IS_NULL, "config is NULL!!");
+
+ if (config != NULL) {
+ if (strcmp(config, "1") == 0) {
+ _DEBUG_INFO("wifi on config");
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ } else if (strcmp(config, "0") == 0) {
+ _DEBUG_INFO("wifi off config");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ } else {
+ _DEBUG_INFO("wifi config error");
+ }
+ } else {
+ _DEBUG_INFO("wifi config error");
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return 0;
+}
diff --git a/src/agent/common/util/util.c b/src/agent/common/util/util.c
new file mode 100644
index 0000000..0623576
--- /dev/null
+++ b/src/agent/common/util/util.c
@@ -0,0 +1,490 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <aul.h>
+#include <unistd.h>
+#include <appsvc.h>
+#include <glib.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "ipc_agent.h"
+#include "ipc_common.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_UTIL"
+#endif
+
+static void _update_csc();
+
+void str_free(char **str)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (*str == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return;
+ } else {
+ free(*str);
+ *str = NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+int chartoint(char *data, int *value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if(data == NULL, 0, "data is NULL!!");
+
+ if (data == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ } else {
+ (*value) = atoi(data);
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+int launch_oma_dm_fumo_ui()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int result = 0;
+ _DEBUG_INFO("\n---------------------------------------------------: %d\n", result);
+ _DEBUG_INFO("\n is launch oma fumo dm ui : %d ?\n", result);
+ result = aul_app_is_running(OMA_DM_FUMO_UI_PKG);
+ _DEBUG_INFO("\n Is launch oma fumo dm ui , result : %d\n", result);
+ _DEBUG_INFO("\n---------------------------------------------------: %d \n", result);
+
+ if (result == 0) {
+ bundle *pBundle = NULL;
+ pBundle = bundle_create();
+ if (pBundle == NULL) {
+ _DEBUG_INFO("bundle_create fail\n");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ result = bundle_add(pBundle, "FOTA_UI", "3");
+ if (result == -1) {
+ bundle_free(pBundle);
+ _DEBUG_INFO("bundle_add fail\n");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+
+ result = aul_launch_app(OMA_DM_FUMO_UI_PKG, pBundle);
+ _DEBUG_INFO("result : %d\n", result);
+ if (result == -1) {
+ bundle_free(pBundle);
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ bundle_free(pBundle);
+ sleep(2);
+ } else {
+ _DEBUG_INFO("---------------------------------------------------------------------------------------------------------------------------------");
+ _DEBUG_INFO("existed oma dm ui\n");
+ _DEBUG_INFO("---------------------------------------------------------------------------------------------------------------------------------");
+ }
+ _EXTERN_FUNC_EXIT;
+ return 1;
+}
+
+int launch_om_dm_fumo_noti_ui(int noti_data, char *session_id, char *server_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int result = 0;
+ _DEBUG_INFO("\n---------------------------------------------------: %d\n", result);
+ _DEBUG_INFO("\n is launch oma noti dm ui ? : %d\n", result);
+ result = aul_app_is_running(OMA_DM_FUMO_NOTI_UI_PKG);
+ _DEBUG_INFO("\n Is launch oma noti dm ui , result : %d\n", result);
+ _DEBUG_INFO("\n---------------------------------------------------: %d\n", result);
+
+ if (result == 0) {
+ char *noti_type = NULL;
+ noti_type = g_strdup_printf("%d", noti_data);
+
+ bundle *pBundle = NULL;
+ pBundle = bundle_create();
+ if (pBundle == NULL) {
+ _DEBUG_INFO("bundle_create fail\n");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+
+ result = bundle_add(pBundle, "FOTA_NOTI", noti_type);
+ result = bundle_add(pBundle, "FOTA_SESSIONID", session_id);
+ result = bundle_add(pBundle, "FOTA_SERVERID", server_id);
+
+ if (session_id == NULL) {
+ /*if engine stoped by battery off or other exceptions */
+ result = bundle_add(pBundle, "FOTA_SESSIONID", "1111");
+ }
+ if (server_id == NULL) {
+ result = bundle_add(pBundle, "FOTA_SERVERID", "1111");
+ }
+ if (result == -1) {
+ _DEBUG_INFO("bundle_add fail\n");
+ bundle_free(pBundle);
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+
+ result = aul_launch_app(OMA_DM_FUMO_NOTI_UI_PKG, pBundle);
+ _DEBUG_INFO("result : %d\n", result);
+
+ if (result == -1) {
+ bundle_free(pBundle);
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+
+ str_free(&noti_type);
+ bundle_free(pBundle);
+ sleep(2);
+ } else {
+ _DEBUG_INFO("---------------------------------------------------------------------------------------------------------------------------------");
+ _DEBUG_INFO("existed oma dm noti ui\n");
+ _DEBUG_INFO("---------------------------------------------------------------------------------------------------------------------------------");
+ }
+ _EXTERN_FUNC_EXIT;
+ return 1;
+}
+
+int launch_om_dm_fumo_alert_ui()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = 0;
+ _DEBUG_INFO("OMA_DM_ALERT_UI_PKG : %s", OMA_DM_ALERT_UI_PKG);
+ ret = aul_app_is_running(OMA_DM_ALERT_UI_PKG);
+ _DEBUG_INFO("aul_app_is_running(%s) [%d] ", OMA_DM_ALERT_UI_PKG, ret);
+ if (ret == 0) {
+ bundle *b = bundle_create();
+ //appsvc_set_operation(b, APPSVC_OPERATION_DEFAULT);
+ //appsvc_set_pkgname(b, OMA_DM_ALERT_UI_PKG);
+
+ //ret = appsvc_run_service(b, 0, NULL, NULL);
+ ret = aul_launch_app(OMA_DM_ALERT_UI_PKG, b);
+ _DEBUG_INFO("result : %d\n", ret);
+
+ _DEBUG_INFO("oma dm alert ui run : %d\n", ret);
+ bundle_free(b);
+ if (ret >= 0) {
+ sleep(2);
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ } else {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ } else {
+ return 1;
+ }
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+int launch_oma_dm_cp_ui(int sec_type, int ext_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO("Start !!");
+ int result = 0;
+ _DEBUG_INFO("OMA_DM_CP_UI_PKG : %s", OMA_DM_CP_UI_PKG);
+ _DEBUG_INFO("\n---------------------------------------------------\n");
+ _DEBUG_INFO("\n is launch oma dm cp ui ?\n");
+ result = aul_app_is_running(OMA_DM_CP_UI_PKG);
+ _DEBUG_INFO("\n Is launch oma dm cp ui, result : %d\n", result);
+ _DEBUG_INFO("\n---------------------------------------------------\n");
+
+ if (result == 0) {
+ char *pin_type = NULL;
+ pin_type = g_strdup_printf("%d", sec_type);
+ char *extId = NULL;
+ extId = g_strdup_printf("%d", ext_id);
+
+ bundle *pBundle = NULL;
+ pBundle = bundle_create();
+ if (pBundle == NULL) {
+ _DEBUG_INFO("bundle_create fail\n");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+
+ result = bundle_add(pBundle, "PIN_TYPE", pin_type);
+ if (result == -1) {
+ _DEBUG_INFO("bundle_add fail\n");
+ bundle_free(pBundle);
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+
+ result = bundle_add(pBundle, "EXT_ID", extId);
+ if (result == -1) {
+ _DEBUG_INFO("bundle_add fail\n");
+ bundle_free(pBundle);
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+
+ result = aul_launch_app(OMA_DM_CP_UI_PKG, pBundle);
+ _DEBUG_INFO("result : %d\n", result);
+
+ if (result == -1) {
+ _EXTERN_FUNC_EXIT;
+ bundle_free(pBundle);
+ return 0;
+ }
+
+ str_free(&pin_type);
+ bundle_free(pBundle);
+ sleep(2);
+ } else {
+ _DEBUG_INFO("---------------------------------------------------------------------------------------------------------------------------------");
+ _DEBUG_INFO("existed oma dm cp ui\n");
+ _DEBUG_INFO("---------------------------------------------------------------------------------------------------------------------------------");
+ }
+ _EXTERN_FUNC_EXIT;
+ return 1;
+}
+
+void terminate_oma_dm_ui(int result_status, ENGINE_ID service_engine_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (result_status == DM_ERR_REMINDER_INTERVAL || result_status == DM_DOWNLOAD_POPUP || result_status == DM_INSTALL_POPUP || result_status == DM_RESUME_IDLE) {
+ _DEBUG_INFO("result status : %d", result_status);
+ return;
+ }
+
+ _DEBUG_INFO("start");
+
+ DM_ERROR ret = DM_OK;
+ int isfumo_engine = 0;
+ engine_status *status = NULL;
+ int result = 0;
+ bool cancel_flag = 0;
+
+ cancel_flag = sync_agent_check_cancel_flag();
+ if (cancel_flag) {
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+ isfumo_engine = IsExist_Engine_id(FUMO_SERVICE_ENGINE);
+
+ if (isfumo_engine == 1) {
+ if (service_engine_id == FUMO_SERVICE_ENGINE) {
+ _DEBUG_INFO("existed engine id in db");
+ ret = Get_Engine_Status(FUMO_SERVICE_ENGINE, &status);
+ _DEBUG_INFO("get fumo service engine : %d", ret);
+
+ if (status != NULL && status->ui_mode != NULL) {
+ result = aul_app_is_running(OMA_DM_FUMO_NOTI_UI_PKG);
+ if (result == 1) {
+ terminate_ui_status(status->ui_noti_type, status->ui_mode, result_status);
+ }
+ result = aul_app_is_running(OMA_DM_FUMO_UI_PKG);
+ if (result == 1) {
+ terminate_ui_status(status->ui_noti_type, status->ui_mode, result_status);
+ }
+ } else {
+ _DEBUG_INFO("fumo service ui mode not existed");
+ }
+
+ if (status != NULL)
+ Free_Memory_Engine_Status(&status, 1);
+
+ ret = Delete_Engine_Status(FUMO_SERVICE_ENGINE);
+ _DEBUG_INFO("delete engine status : %d", ret);
+ } else {
+ _DEBUG_INFO("fumo service not existed");
+ }
+ } else {
+ _DEBUG_INFO("fumo service not existed");
+ }
+ _EXTERN_FUNC_EXIT;
+
+}
+
+void terminate_ui_status(int noti_type, char *ui_mode, int result_status)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int noti_res = 0;
+
+ _DEBUG_INFO("noti type : %d", noti_type);
+ /*noti_res = noti_engine_fail(noti_type, fail_type); */
+
+ switch (noti_type) {
+ case NOTI_ENGINE_START:
+ _DEBUG_INFO("connect to sever ui ");
+ if (result_status != DM_OK) {
+ if (result_status == DM_ERR_UNAUTHORIZED || result_status == DM_ERR_AUTHENTICATION_REQUIRED) {
+ noti_res = noti_engine_fail(noti_type, CONNECTION_STATUS_FAILURE_AUTHENTICATION);
+ } else {
+ noti_res = noti_engine_fail(noti_type, CONNECTION_STATUS_FAILURE);
+ }
+ } else {
+ noti_res = noti_engine_fail(noti_type, CONNECTION_STATUS_UPTODATA);
+ }
+ _DEBUG_INFO("connect to sever ui : %d", noti_res);
+ break;
+ case NOTI_UNKNOWN:
+ case NOTI_DOWNLOAD:
+ case NOTI_DOWNLOAD_INFO:
+ case NOTI_INSTALL:
+ //case NOTI_WIFI_ONLY_DOWNLOAD_FAIL:
+ //case NOTI_MEMORY_FULL:
+ noti_res = noti_engine_fail(noti_type, 0);
+ break;
+ case NOTI_LOW_BATTERY:
+ case NOTI_ALERT_DISPLAY:
+ case NOTI_ALERT_CONFIRMATION:
+ case NOTI_ALERT_INPUTTEXT:
+ case NOTI_ALERT_SINGLE_CHOICE:
+ case NOTI_ALERT_MULTIPLE_CHOICE:
+ break;
+ default:
+ break;
+ }
+
+ _DEBUG_INFO("cancel ui : %d", noti_res);
+ _EXTERN_FUNC_EXIT;
+
+}
+
+int check_csc()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int exist = 0;
+
+ /*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(CSC_CHECK_PATH); */
+ /*temp value */
+ exist = 1;
+
+/*for prevent*/
+ /*if(exist == 0 ) {
+ _update_csc();
+ } */
+
+ _update_csc();
+
+ _DEBUG_INFO("update = %d", exist);
+ _EXTERN_FUNC_EXIT;
+ return exist;
+}
+
+static void _update_csc()
+{
+ _INNER_FUNC_ENTER;
+
+ //dmacc mo db update
+ /*sync_agent_write_whole_file(OMA_DS_CSC_CHECK_PATH, contents, strlen(contents), false); */
+
+ _INNER_FUNC_EXIT;
+}
+
+int get_wifi_state()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+ sync_agent_na_network_connection_type_e con_type = SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_UNKNOWN;
+ sync_agent_na_network_connection_state_e con_state = SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_NONE;
+
+ ret = sync_agent_get_connection_type(&con_type);
+ if (ret != SYNC_AGENT_NA_SUCCESS) {
+ _DEBUG_INFO("get connection type");
+ ret = SYNC_AGENT_NA_DOWNLOAD_DATA_FAIL;
+ goto return_part;
+ }
+ _DEBUG_INFO("get connection type : %d", con_type);
+
+ ret = sync_agent_get_connection_state(&con_state);
+ _DEBUG_INFO("get connection state : %d", con_state);
+ if (ret != SYNC_AGENT_NA_SUCCESS) {
+ _DEBUG_INFO("get connection state");
+ ret = SYNC_AGENT_NA_NETWORK_UNAVAILABLE;
+ goto return_part;
+ }
+
+ if (con_type != SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_WIFI || (con_type == SYNC_AGENT_NA_NETWORK_CONNECTION_TYPE_WIFI && con_state != SYNC_AGENT_NA_NETWORK_CONNECTION_STATE_WIFI_CONNECTED)) {
+ _DEBUG_INFO("wifi only on mode download fail");
+ ret = SYNC_AGENT_NA_NETWORK_UNAVAILABLE;
+ goto return_part;
+ } else {
+ _DEBUG_INFO("wifi on mode download");
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ return_part:
+ _DEBUG_INFO("error end %d : ", ret);
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
+
+DM_ERROR nonce_decode(char *nextNonce, unsigned char **nextNonceDecode, unsigned int *out_len)
+{
+ _EXTERN_FUNC_ENTER;
+
+ unsigned char *tempnextNonceDecode = NULL;
+ tempnextNonceDecode = g_base64_decode(nextNonce, (unsigned int *)(out_len));
+
+ if (tempnextNonceDecode == NULL && *out_len != 0) {
+ _DEBUG_INFO("tempnextNonceDecode = NULL , out len : %d", *out_len);
+ int i = 0;
+ char *zero = "0";
+ *nextNonceDecode = (unsigned char *)calloc(1, (*out_len) + 1);
+ for (i = 0; i < (*out_len); ++i) {
+ g_strlcat((char *)(*nextNonceDecode), zero, *out_len);
+ }
+
+ } else {
+
+ _DEBUG_INFO("tempnextNonceDecode = %s, out_len = %d", tempnextNonceDecode, *out_len);
+ /**nextNonceDecode = (char *)strdup(tempnextNonceDecode);
+ str_free((char **)(&tempnextNonceDecode));*/
+ *nextNonceDecode = tempnextNonceDecode;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+
+}
diff --git a/src/agent/dm-engine/bootstrap/factory_bootstrap.c b/src/agent/dm-engine/bootstrap/factory_bootstrap.c
new file mode 100755
index 0000000..7633b6d
--- /dev/null
+++ b/src/agent/dm-engine/bootstrap/factory_bootstrap.c
@@ -0,0 +1,317 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "mo-handler/dm_mo_handler.h"
+#include "mo-handler/dm_mo_common.h"
+#include "dm-engine/bootstrap/factory_bootstrap.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_BOOTSTRAP"
+#endif
+
+static DM_ERROR _completed_bootstrap();
+static DM_ERROR _start_ddf_mo(GSList * seg_list);
+
+static DM_ERROR _completed_bootstrap()
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ ENGINE_STATUS status = DM_IDLE;
+
+ ret = Update_Engine_Status_Column(IDLE_ENGINE, VALUE_ENGINE_STATUS, &status);
+ _DEBUG_TRACE("update engine status : %d", ret);
+ if (ret != DM_OK)
+ goto error;
+
+ _INNER_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_TRACE(" end!! error : %d \n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static DM_ERROR _start_ddf_mo(GSList * seg_list)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ GSList *ddf_iter = NULL;
+ sync_agent_dm_mo_error_e err_code;
+ ddf_spec *ddf_content;
+
+ retvm_if((seg_list) == NULL, COMMON_ERR_IS_NULL, "seg_list is NULL!!");
+
+ for (ddf_iter = seg_list; ddf_iter != NULL; ddf_iter = g_slist_next(ddf_iter)) {
+ ddf_content = (ddf_spec *) (ddf_iter->data);
+
+ _DEBUG_TRACE(" mo_type : %d schema : %s sevice_ddf : %d server_type : %d\n", ddf_content->mo_type, ddf_content->schema_file, ddf_content->service_ddf, ddf_content->server_type);
+ err_code = sync_agent_construct_mo_table(ddf_content->mo_type, ddf_content->schema_file, ddf_content->service_ddf, ddf_content->server_type);
+
+ if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_TRACE("Success to sync_agent_construct_mo_table()\n");
+ } else {
+ _DEBUG_TRACE("Failed to sync_agent_construct_mo_table()\n");
+ ret = DM_ERR_DDF_PROCCESS;
+ goto error;
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_TRACE(" end!! error : %d \n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR factory_bootstrap(SERVICE_SERVER_TYPE server_type)
+{
+ _INNER_FUNC_EXIT;
+
+ DM_ERROR ret = DM_OK;
+
+ /*dm acc */
+ //pre_define_mo();
+
+ /*change css value for test */
+ int file_ret = 0;
+ char *file_path = NULL;
+ unsigned long required_length = 0;
+ char *required_contents = NULL;
+ int is_exist = 0;
+
+ switch (server_type) {
+ case SAMSUNG_FUMO_TYPE:
+ {
+ ret = is_exist_dmacc(SAMSUNG_FUMO_TYPE, &is_exist);
+ if (ret != DM_OK) {
+ _DEBUG_TRACE("is exist dmacc error : %d or not exist dm acc : %d", ret, is_exist);
+ goto error;
+ }
+ if (is_exist == 1) {
+ ret = remove_dm_acc(DM_DMACC_MSCTESTSERVER);
+ if (ret != DM_OK) {
+ _DEBUG_VERBOSE("remove dm acc error :%d", ret);
+ goto error;
+ } else {
+ _DEBUG_VERBOSE("remove fumo dm acc");
+ }
+ } else {
+ _DEBUG_VERBOSE("samsung fumo dm acc");
+ }
+
+ file_path = DDF_MSCFUMO_DMACC_FILE;
+ }
+ break;
+ case SAMSUNG_FMM_TYPE:
+ {
+ ret = is_exist_dmacc(SAMSUNG_FMM_TYPE, &is_exist);
+ if (ret != DM_OK) {
+ _DEBUG_TRACE("is exist dmacc error : %d or not exist dm acc : %d", ret, is_exist);
+ goto error;
+ }
+ if (is_exist == 1) {
+ ret = remove_dm_acc(DM_DMACC_MSCSERVER);
+ if (ret != DM_OK) {
+ _DEBUG_VERBOSE("remove dm acc error :%d", ret);
+ goto error;
+ } else {
+ _DEBUG_VERBOSE("remove fumo dm acc");
+ }
+ } else {
+ _DEBUG_VERBOSE("samsung fmm dm acc");
+ }
+
+ file_path = DDF_MSCLAWMO_DMACC_FILE;
+ }
+ break;
+ case GCF_TYPE:
+ {
+ ret = is_exist_dmacc(GCF_TYPE, &is_exist);
+ if (ret != DM_OK) {
+ _DEBUG_TRACE("is exist dmacc error : %d or not exist dm acc : %d", ret, is_exist);
+ goto error;
+ }
+ if (is_exist == 1) {
+ ret = remove_dm_acc(DM_DMACC_MSCSERVER);
+ if (ret != DM_OK) {
+ _DEBUG_VERBOSE("remove dm acc error :%d", ret);
+ goto error;
+ } else {
+ _DEBUG_VERBOSE("remove fumo dm acc");
+ }
+ } else {
+ _DEBUG_VERBOSE("product dm acc");
+ }
+ file_path = DDF_GCF_DMACC_FILE;
+ }
+ break;
+ default:
+ {
+ file_path = DDF_FILES;
+ _DEBUG_INFO("the first factory bootstrap");
+ }
+ break;
+ }
+
+ file_ret = sync_agent_read_whole_file(file_path, &required_contents, &required_length);
+ if (file_ret != 1) {
+ ret = DM_ERR_DDF_PROCCESS;
+ goto error;
+ }
+ _DEBUG_INFO(" file read is %d, required_length is %d \n", ret, required_length);
+
+ GSList *seg_list = NULL;
+ char *check_segment = NULL;
+ ddf_spec ddf_contents[DDF_SPEC_COUNT] = { {0}, };
+ int i = 0;
+ if (required_contents != NULL) {
+ check_segment = strtok(required_contents, "\n");
+ _DEBUG_INFO(" check_segment : %s\n", check_segment);
+ } else {
+ ret = DM_ERR_DDF_PROCCESS;
+ goto error;
+ }
+
+ if (check_segment != NULL) {
+ sscanf(check_segment, "%d %s %d %d", (int *)(&(ddf_contents[i].mo_type)), (ddf_contents[i].schema_file), &(ddf_contents[i].service_ddf), &(ddf_contents[i].server_type));
+ seg_list = g_slist_append(seg_list, &(ddf_contents[i]));
+
+ _DEBUG_INFO(" mo_type: %d\n", ddf_contents[i].mo_type);
+ _DEBUG_INFO(" schema_file : %s\n", ddf_contents[i].schema_file);
+ _DEBUG_INFO(" service_ddf : %d\n", ddf_contents[i].service_ddf);
+ _DEBUG_INFO(" server_type : %d\n", ddf_contents[i].server_type);
+ ++i;
+
+ while (check_segment != NULL) {
+ check_segment = strtok(NULL, "\n");
+ if (check_segment == NULL)
+ break;
+ _DEBUG_INFO(" check_segment : %s\n", check_segment);
+
+ sscanf(check_segment, "%d %s %d %d", (int *)(&(ddf_contents[i].mo_type)), (ddf_contents[i].schema_file), &(ddf_contents[i].service_ddf), &(ddf_contents[i].server_type));
+ seg_list = g_slist_append(seg_list, &(ddf_contents[i]));
+
+ _DEBUG_INFO(" mo_type: %d\n", ddf_contents[i].mo_type);
+ _DEBUG_INFO(" schema_file : %s\n", ddf_contents[i].schema_file);
+ _DEBUG_INFO(" service_ddf : %d\n", ddf_contents[i].service_ddf);
+ _DEBUG_INFO(" server_type : %d\n", ddf_contents[i].server_type);
+ ++i;
+ }
+
+ ret = _start_ddf_mo(seg_list);
+ if (ret != DM_OK)
+ goto error;
+
+ file_ret = sync_agent_free_file(&required_contents);
+ required_contents = NULL;
+ if (file_ret != 1) {
+ ret = DM_ERR_DDF_PROCCESS;
+ goto error;
+ }
+
+ ret = _completed_bootstrap();
+ if (ret != DM_OK) {
+ goto error;
+ }
+
+ } else {
+ ret = DM_ERR_DDF_PROCCESS;
+ goto error;
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+ error:
+
+ file_ret = sync_agent_free_file(&required_contents);
+ if (file_ret != 1) {
+ ret = DM_ERR_DDF_PROCCESS;
+ }
+
+ _DEBUG_INFO(" end!! error : %d \n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+/*
+void ddf_parser() {
+
+ sync_agent_dm_mo_type_e mo_type_devdetail = SYNC_AGENT_DM_MO_TYPE_DEVDETAIL;
+ sync_agent_dm_mo_type_e mo_type_devinfo = SYNC_AGENT_DM_MO_TYPE_DEVINFO;
+ sync_agent_dm_mo_type_e mo_type_fumo = SYNC_AGENT_DM_MO_TYPE_FUMO;
+ sync_agent_dm_mo_type_e mo_type_gcf = SYNC_AGENT_DM_MO_TYPE_DMACC;
+ sync_agent_dm_mo_type_e mo_type_mscserver = SYNC_AGENT_DM_MO_TYPE_DMACC;
+ sync_agent_dm_mo_type_e mo_type_msctestserver = SYNC_AGENT_DM_MO_TYPE_DMACC;
+
+ const char *schema_file_devdetail = "/usr/share/oma-dm/ddf/slp/slp_DEVDETAIL_DDF.xml";
+ const char *schema_file_devinfo = "/usr/share/oma-dm/ddf/slp/slp_DEVINF_DDF.xml";
+ const char *schema_file_fumo = "/usr/share/oma-dm/ddf/slp/slp_FUMO_DDF.xml";
+ const char *schema_file_gcf = "/usr/share/oma-dm/ddf/slp/slp_gcf_DMACC_DDF_1.2.xml";
+ const char *schema_file_mscserver = "/usr/share/oma-dm/ddf/slp/slp_MSCserver_DMACC_DDF_1.2.xml";
+ const char *schema_file_msctestserver = "/usr/share/oma-dm/ddf/slp/slp_MSCTestserver_DMACC_DDF_1.2.xml";
+
+ sync_agent_dm_mo_error_e err_code = sync_agent_construct_mo_table(mo_type_devdetail, schema_file_devdetail , "devdetail");
+ if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
+ printf("Success to sync_agent_construct_mo_table()\n");
+ } else {
+ printf("Failed to sync_agent_construct_mo_table()\n");
+ }
+
+ err_code = sync_agent_construct_mo_table(mo_type_devinfo, schema_file_devinfo , "devinf");
+ if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
+ printf("Success to sync_agent_construct_mo_table()\n");
+ } else {
+ printf("Failed to sync_agent_construct_mo_table()\n");
+ }
+
+ err_code = sync_agent_construct_mo_table(mo_type_fumo, schema_file_fumo , "fumo");
+ if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
+ printf("Success to sync_agent_construct_mo_table()\n");
+ } else {
+ printf("Failed to sync_agent_construct_mo_table()\n");
+ }
+ err_code = sync_agent_construct_mo_table(mo_type_gcf, schema_file_gcf , "dmacc_gcf");
+ if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
+ printf("Success to sync_agent_construct_mo_table()\n");
+ } else {
+ printf("Failed to sync_agent_construct_mo_table()\n");
+ }
+ err_code = sync_agent_construct_mo_table(mo_type_mscserver, schema_file_mscserver , "dmacc_MSCserver");
+ if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
+ printf("Success to sync_agent_construct_mo_table()\n");
+ } else {
+ printf("Failed to sync_agent_construct_mo_table()\n");
+ }
+ err_code = sync_agent_construct_mo_table(mo_type_msctestserver, schema_file_msctestserver , "dmacc_MSCTestserver");
+ if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
+ printf("Success to sync_agent_construct_mo_table()\n");
+ } else {
+ printf("Failed to sync_agent_construct_mo_table()\n");
+ }
+*/
diff --git a/src/agent/dm-engine/cp/dm_cp_parser.c b/src/agent/dm-engine/cp/dm_cp_parser.c
new file mode 100755
index 0000000..b54425c
--- /dev/null
+++ b/src/agent/dm-engine/cp/dm_cp_parser.c
@@ -0,0 +1,1591 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <glib.h>
+#include <glib/gprintf.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "dm-engine/cp/dm_cp_struct.h"
+#include "dm-engine/cp/dm_cp_parser.h"
+#include "dm-engine/cp/dm_cp_processor.h"
+#include "serviceadapter/protocolbinder/syncml_protocol_binder.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_CP"
+#endif
+
+static String_Node *___get_Last_String_Node(String_Node * node);
+static DM_CP_Bootstrap *__parse_Bootstrap(WBXMLTreeNode * wbxml_dom_node);
+static DM_CP_Napdef *__parse_Napdef(WBXMLTreeNode * wbxml_dom_node);
+static DM_CP_Application *__parse_Application(WBXMLTreeNode * wbxml_dom_node);
+static DM_CP_PxLogical *__parse_PxLogical(WBXMLTreeNode * wbxml_dom_node);
+static void ___set_Param(WBXMLTreeNode * wbxml_dom_node, char **set_value);
+static sync_agent_pb_error_e _characteristic_start_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
+
+const sync_agent_pb_function_info_s cp_binder_function_info[] = {
+ {TNDS_TAG_CHARACTERISTIC_START, "characteristic", NULL, _characteristic_start_reverse_converter_function, false},
+};
+
+DM_CP *parsing_cp_stream(CP_TYPE cp_type, const char *wbxml_stream, unsigned int msgSize)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((wbxml_stream) == NULL, NULL, "wbxml_stream is NULL!!");
+
+ sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ sync_agent_pb_error_e pb_error = sync_agent_init_binder_function_set(sizeof(cp_binder_function_info) / sizeof(sync_agent_pb_function_info_s),
+ (sync_agent_pb_function_info_s *) cp_binder_function_info, &pBinder_function_set);
+
+ if (pb_error != SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_INFO("Failed to sync_agent_init_binder_function_set()");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+
+ /*
+ * reverse protocol binder initialization
+ */
+ sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_PROV10;
+ sync_agent_pb_protocol_binder_reverse_info_s *pBinder = 0;
+ DM_CP *dm_cp = (DM_CP *) calloc(1, sizeof(DM_CP));
+ if (dm_cp == NULL) {
+ _DEBUG_INFO("alloc fail");
+ free_syncml_binder_function_set(pBinder_function_set);
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+
+ switch (cp_type) {
+ case CP_TYPE_WBXML:
+ pb_error = sync_agent_init_reverse_protocol_binder((char *)wbxml_stream, msgSize, SYNC_AGENT_PB_DECODING_WBXML, &protocol, pBinder_function_set, dm_cp, &pBinder);
+ break;
+ case CP_TYPE_XML:
+ pb_error = sync_agent_init_reverse_protocol_binder((char *)wbxml_stream, msgSize, SYNC_AGENT_PB_DECODING_XML, &protocol, pBinder_function_set, dm_cp, &pBinder);
+ break;
+ case CP_TYPE_NONE:
+ break;
+ default:
+ break;
+ }
+
+ if (pb_error != SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_INFO("Failed to call sync_agent_init_reverse_protocol_binder() - [%d]", pb_error);
+ }
+
+ Protocol_Element protocol_element;
+ char *protocol_element_name = 0;
+ Content_Ptr content = 0;
+
+ while (1) {
+ pb_error = sync_agent_next_element(pBinder, &protocol_element, &protocol_element_name, &content);
+
+ if (pb_error == SYNC_AGENT_PB_RETURN_HAS_NO_MORE_ELEMENT) {
+ break;
+ } else if (pb_error != SYNC_AGENT_PB_RETURN_OK) {
+ /*
+ * process error code
+ */
+ }
+ }
+ _EXTERN_FUNC_EXIT;
+
+ return dm_cp;
+}
+
+static sync_agent_pb_error_e _characteristic_start_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_pb_error_e pb_error = SYNC_AGENT_PB_RETURN_OK;
+
+ retvm_if((pReverse_binder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pReverse_binder is NULL!!");
+ retvm_if((wbxml_dom_node) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "wbxml_dom_node is NULL!!");
+
+ void *user_data = sync_agent_get_user_data_from_reverse_protocol_binder(pReverse_binder);
+ DM_CP *dm_cp = (DM_CP *) user_data;
+
+ WBXMLList *attrs = wbxml_dom_node->attrs;
+ WB_ULONG index = 0;
+ WB_ULONG nb_attrs = wbxml_list_len(attrs);
+
+ while (index < nb_attrs) {
+ WBXMLAttribute *attr = (WBXMLAttribute *) wbxml_list_get(attrs, index);
+
+ if (WBXML_STRCMP("type", wbxml_attribute_get_xml_name(attr)) == 0) {
+ if (WBXML_STRCMP("APPLICATION", wbxml_attribute_get_xml_value(attr)) == 0) {
+ DM_CP_Application *application = __parse_Application(wbxml_dom_node);
+ if (application == NULL) {
+ index++;
+ continue;
+ }
+ if (dm_cp->applications == NULL) {
+ dm_cp->applications = application;
+ } else {
+ DM_CP_Application *cursor_ptr = dm_cp->applications;
+ while (cursor_ptr != 0) {
+ if (cursor_ptr->next == NULL) {
+ cursor_ptr->next = application;
+ break;
+ }
+ cursor_ptr = cursor_ptr->next;
+ }
+ }
+ } else if (WBXML_STRCMP("BOOTSTRAP", wbxml_attribute_get_xml_value(attr)) == 0) {
+ DM_CP_Bootstrap *bootstrap = __parse_Bootstrap(wbxml_dom_node);
+ if (bootstrap == NULL) {
+ index++;
+ continue;
+ }
+ if (dm_cp->bootstraps == NULL) {
+ dm_cp->bootstraps = bootstrap;
+ } else {
+ DM_CP_Bootstrap *cursor_ptr = dm_cp->bootstraps;
+ while (cursor_ptr != NULL) {
+ if (cursor_ptr->next == NULL) {
+ cursor_ptr->next = bootstrap;
+ break;
+ }
+ cursor_ptr = cursor_ptr->next;
+ }
+ }
+ } else if (WBXML_STRCMP("NAPDEF", wbxml_attribute_get_xml_value(attr)) == 0) {
+ DM_CP_Napdef *napdef = __parse_Napdef(wbxml_dom_node);
+ if (napdef == NULL) {
+ index++;
+ continue;
+ }
+ if (dm_cp->napdefs == NULL) {
+ dm_cp->napdefs = napdef;
+ } else {
+ DM_CP_Napdef *cursor_ptr = dm_cp->napdefs;
+ while (cursor_ptr != NULL) {
+ if (cursor_ptr->next == NULL) {
+ cursor_ptr->next = napdef;
+ break;
+ }
+ cursor_ptr = cursor_ptr->next;
+ }
+ }
+ } else if (WBXML_STRCMP("PXLOGICAL", wbxml_attribute_get_xml_value(attr)) == 0) {
+ DM_CP_PxLogical *pxLogical = __parse_PxLogical(wbxml_dom_node);
+ if (pxLogical == NULL) {
+ index++;
+ continue;
+ }
+ if (dm_cp->pxLogical == NULL) {
+ dm_cp->pxLogical = pxLogical;
+ } else {
+ DM_CP_PxLogical *cursor_ptr = dm_cp->pxLogical;
+ while (cursor_ptr != NULL) {
+ if (cursor_ptr->next == NULL) {
+ cursor_ptr->next = pxLogical;
+ break;
+ }
+ cursor_ptr = cursor_ptr->next;
+ }
+ }
+ }
+ }
+
+ index++;
+ }
+
+ _INNER_FUNC_EXIT;
+ return pb_error;
+}
+
+static String_Node *___get_Last_String_Node(String_Node * node)
+{
+ _INNER_FUNC_ENTER;
+
+ String_Node *new_node = (String_Node *) calloc(1, sizeof(String_Node));
+ if (new_node == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ new_node->next = NULL;
+
+ String_Node *cursor_ptr = node;
+ while (cursor_ptr != NULL) {
+ if (cursor_ptr->next == NULL) {
+ cursor_ptr->next = new_node;
+ break;
+ }
+
+ cursor_ptr = cursor_ptr->next;
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return new_node;
+}
+
+static DM_CP_Bootstrap *__parse_Bootstrap(WBXMLTreeNode * wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((wbxml_dom_node) == NULL, NULL, "wbxml_dom_node is NULL!!");
+
+ DM_CP_Bootstrap *bootstrap = (DM_CP_Bootstrap *) calloc(1, sizeof(DM_CP_Bootstrap));
+ if (bootstrap == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+
+ WBXMLTreeNode *pCursor = wbxml_dom_node->children;
+
+ while (pCursor != NULL) {
+ if (pCursor->type == WBXML_TREE_ELEMENT_NODE) {
+ const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor->name);
+ if (!strcmp((const char *)tag_name, "parm")) {
+ WBXMLList *param_attrs = pCursor->attrs;
+ WB_ULONG param_index = 0;
+ WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
+ while (param_index < param_nb_attrs) {
+ WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
+ if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
+ if (WBXML_STRCMP("NAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(bootstrap->name));
+ if(bootstrap->name != NULL) {
+ _DEBUG_VERBOSE("NAME : %s", bootstrap->name);
+ }
+ } else if (WBXML_STRCMP("NETWORK", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ String_Node *target_ptr = ___get_Last_String_Node(bootstrap->network);
+ if (target_ptr == NULL) {
+ _DEBUG_VERBOSE("bootstrap network get null");
+ param_index++;
+ continue;
+ }
+ ___set_Param(pCursor, &(target_ptr->data));
+ if(target_ptr->data != NULL) {
+ _DEBUG_VERBOSE("NETWORK : %s", target_ptr->data);
+ }
+ if (bootstrap->network == NULL) {
+ bootstrap->network = target_ptr;
+ } else {
+ _DEBUG_VERBOSE("free network");
+ free_string_node(target_ptr);
+ }
+ } else if (WBXML_STRCMP("COUNTRY", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(bootstrap->country));
+ if(bootstrap->country != NULL) {
+ _DEBUG_VERBOSE("COUNTRY : %s", bootstrap->country);
+ }
+ } else if (WBXML_STRCMP("PROXY-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ String_Node *target_ptr = ___get_Last_String_Node(bootstrap->proxy_id);
+ if (target_ptr == NULL) {
+ _DEBUG_VERBOSE("boot strap PROXY-ID get null");
+ param_index++;
+ continue;
+ }
+ ___set_Param(pCursor, &(target_ptr->data));
+ if(target_ptr->data != NULL) {
+ _DEBUG_VERBOSE("PROXY-ID : %s", target_ptr->data);
+ }
+ if (bootstrap->proxy_id == NULL) {
+ bootstrap->proxy_id = target_ptr;
+ } else {
+ _DEBUG_VERBOSE("free proxy id");
+ free_string_node(target_ptr);
+ }
+ } else if (WBXML_STRCMP("PROVURL", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(bootstrap->provurl));
+ if(bootstrap->provurl != NULL) {
+ _DEBUG_VERBOSE("PROVURL : %s", bootstrap->provurl);
+ }
+ } else if (WBXML_STRCMP("CONTEXT-ALLOW", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(bootstrap->context_allow));
+ if(bootstrap->context_allow != NULL) {
+ _DEBUG_VERBOSE("CONTEXT-ALLOW : %s", bootstrap->context_allow);
+ }
+ }
+ }
+ param_index++;
+ }
+ }
+ }
+ pCursor = pCursor->next;
+ }
+
+ _INNER_FUNC_EXIT;
+ return bootstrap;
+}
+
+static DM_CP_Napdef *__parse_Napdef(WBXMLTreeNode * wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((wbxml_dom_node) == NULL, NULL, "wbxml_dom_node is NULL!!");
+
+ DM_CP_Napdef *napdef = (DM_CP_Napdef *) calloc(1, sizeof(DM_CP_Napdef));
+ if (napdef == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ WBXMLTreeNode *pCursor = wbxml_dom_node->children;
+
+ while (pCursor != 0) {
+ if (pCursor->type == WBXML_TREE_ELEMENT_NODE) {
+ const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor->name);
+ if (!strcmp((const char *)tag_name, "parm")) {
+ WBXMLList *param_attrs = pCursor->attrs;
+ WB_ULONG param_index = 0;
+ WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
+ while (param_index < param_nb_attrs) {
+ WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
+ if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
+ if (WBXML_STRCMP("NAPID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->nap_ID));
+ if(napdef->nap_ID != NULL) {
+ _DEBUG_VERBOSE("NAPID : %s", napdef->nap_ID);
+ }
+ } else if (WBXML_STRCMP("BEARER", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ String_Node *target_ptr = ___get_Last_String_Node(napdef->bearer);
+ if(target_ptr == NULL) {
+ _DEBUG_VERBOSE("___get_Last_String_Node fail");
+ free_cp_napdef(napdef);
+ napdef = NULL;
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ ___set_Param(pCursor, &(target_ptr->data));
+ if(target_ptr->data != NULL) {
+ _DEBUG_VERBOSE("BEARER : %s", target_ptr->data);
+ }
+ if (napdef->bearer == NULL) {
+ napdef->bearer = target_ptr;
+ } else {
+ _DEBUG_VERBOSE("free BEARER ");
+ free_string_node(target_ptr);
+ }
+ } else if (WBXML_STRCMP("NAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->name));
+ if(napdef->name != NULL) {
+ _DEBUG_VERBOSE("NAME : %s", napdef->name);
+ }
+ } else if (WBXML_STRCMP("INTERNET", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->internet));
+ if(napdef->internet != NULL) {
+ _DEBUG_VERBOSE("INTERNET : %s", napdef->internet);
+ }
+ } else if (WBXML_STRCMP("NAP-ADDRESS", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->nap_address));
+ if(napdef->nap_address != NULL) {
+ _DEBUG_VERBOSE("NAP-ADDRESS : %s", napdef->nap_address);
+ }
+ } else if (WBXML_STRCMP("NAP-ADDRTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->nap_addr_type));
+ if(napdef->nap_addr_type != NULL) {
+ _DEBUG_VERBOSE("NAP-ADDRTYPE : %s", napdef->nap_addr_type);
+ }
+ } else if (WBXML_STRCMP("DNS-ADDR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ String_Node *target_ptr = ___get_Last_String_Node(napdef->dns_addr);
+ if (target_ptr == NULL) {
+ _DEBUG_VERBOSE("DNS-ADDR is NULL");
+ param_index++;
+ continue;
+ }
+
+ ___set_Param(pCursor, &(target_ptr->data));
+ if(target_ptr->data != NULL) {
+ _DEBUG_VERBOSE("DNS-ADDR : %s", target_ptr->data);
+ }
+ if (napdef->dns_addr == NULL) {
+ napdef->dns_addr = target_ptr;
+ } else {
+ _DEBUG_VERBOSE("free DNS-ADDR ");
+ free_string_node(target_ptr);
+ }
+ } else if (WBXML_STRCMP("CALLTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->call_type));
+ if(napdef->call_type != NULL) {
+ _DEBUG_VERBOSE("CALLTYPE : %s", napdef->call_type);
+ }
+ } else if (WBXML_STRCMP("LOCAL-ADDR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->local_addr));
+ if(napdef->local_addr != NULL) {
+ _DEBUG_VERBOSE("LOCAL-ADDR : %s", napdef->local_addr);
+ }
+ } else if (WBXML_STRCMP("LOCAL-ADDRTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->local_addr_type));
+ if(napdef->local_addr_type != NULL) {
+ _DEBUG_VERBOSE("LOCAL-ADDRTYPE : %s", napdef->local_addr_type);
+ }
+ } else if (WBXML_STRCMP("LINKSPEED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->link_speed));
+ if(napdef->link_speed != NULL) {
+ _DEBUG_VERBOSE("LINKSPEED : %s", napdef->link_speed);
+ }
+ } else if (WBXML_STRCMP("DNLINKSPEED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->dn_link_speed));
+ if(napdef->dn_link_speed != NULL) {
+ _DEBUG_VERBOSE("DNLINKSPEED : %s", napdef->dn_link_speed);
+ }
+ } else if (WBXML_STRCMP("LINGER", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->linger));
+ if(napdef->linger != NULL) {
+ _DEBUG_VERBOSE("LINGER : %s", napdef->linger);
+ }
+ } else if (WBXML_STRCMP("DELIVERY-ERR-SDU", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->delivery_err_sdu));
+ if(napdef->delivery_err_sdu != NULL) {
+ _DEBUG_VERBOSE("DELIVERY-ERR-SDU : %s", napdef->delivery_err_sdu);
+ }
+ } else if (WBXML_STRCMP("DELIVERY-ORDER", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->delivery_order));
+ if(napdef->delivery_order != NULL) {
+ _DEBUG_VERBOSE("DELIVERY-ORDER : %s", napdef->delivery_order);
+ }
+ } else if (WBXML_STRCMP("TRAFFIC-CLASS", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->traffic_class));
+ if(napdef->traffic_class != NULL) {
+ _DEBUG_VERBOSE("TRAFFIC-CLASS : %s", napdef->traffic_class);
+ }
+ } else if (WBXML_STRCMP("MAX-SDU-SIZE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->max_sdu_size));
+ if(napdef->max_sdu_size != NULL) {
+ _DEBUG_VERBOSE("MAX-SDU-SIZE : %s", napdef->max_sdu_size);
+ }
+ } else if (WBXML_STRCMP("MAX-BITRATE-UPLINK", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->max_bitrate_uplink));
+ if(napdef->max_bitrate_uplink != NULL) {
+ _DEBUG_VERBOSE("MAX-BITRATE-UPLINK : %s", napdef->max_bitrate_uplink);
+ }
+ } else if (WBXML_STRCMP("MAX-BITRATE-DNLINK", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->max_bitrate_dnlink));
+ if(napdef->max_bitrate_dnlink != NULL) {
+ _DEBUG_VERBOSE("MAX-BITRATE-DNLINK : %s", napdef->max_bitrate_dnlink);
+ }
+ } else if (WBXML_STRCMP("RESIDUAL-BER", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->residual_ber));
+ if(napdef->residual_ber != NULL) {
+ _DEBUG_VERBOSE("RESIDUAL-BER : %s", napdef->residual_ber);
+ }
+ } else if (WBXML_STRCMP("SDU-ERROR-RATIO", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->sdu_error_ratio));
+ if(napdef->sdu_error_ratio != NULL) {
+ _DEBUG_VERBOSE("SDU-ERROR-RATIO : %s", napdef->sdu_error_ratio);
+ }
+ } else if (WBXML_STRCMP("TRAFFIC-HANDL-PRIO", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->traffic_handl_prio));
+ if(napdef->traffic_handl_prio != NULL) {
+ _DEBUG_VERBOSE("TRAFFIC-HANDL-PRIO : %s", napdef->traffic_handl_prio);
+ }
+ } else if (WBXML_STRCMP("TRANSFER-DELAY", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->transfer_delay));
+ if(napdef->transfer_delay != NULL) {
+ _DEBUG_VERBOSE("TRANSFER-DELAY : %s", napdef->transfer_delay);
+ }
+ } else if (WBXML_STRCMP("GUARANTEED-BITRATE-UPLINK", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->guaranteed_bitrate_uplink));
+ if(napdef->guaranteed_bitrate_uplink != NULL) {
+ _DEBUG_VERBOSE("GUARANTEED-BITRATE-UPLINK : %s", napdef->guaranteed_bitrate_uplink);
+ }
+ } else if (WBXML_STRCMP("GUARANTEED-BITRATE-DNLINK", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->guaranteed_bitrate_dnlink));
+ if(napdef->guaranteed_bitrate_dnlink != NULL) {
+ _DEBUG_VERBOSE("GUARANTEED-BITRATE-DNLINK : %s", napdef->guaranteed_bitrate_dnlink);
+ }
+ } else if (WBXML_STRCMP("MAX-NUM-RETRY", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->max_num_retry));
+ if(napdef->max_num_retry != NULL) {
+ _DEBUG_VERBOSE("MAX-NUM-RETRY : %s", napdef->max_num_retry);
+ }
+ } else if (WBXML_STRCMP("FIRST-RETRY-TIMEOUT", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->first_retry_timeout));
+ if(napdef->first_retry_timeout != NULL) {
+ _DEBUG_VERBOSE("FIRST-RETRY-TIMEOUT : %s", napdef->first_retry_timeout);
+ }
+ } else if (WBXML_STRCMP("REREG-THRESHOLD", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->rereg_threshold));
+ if(napdef->rereg_threshold != NULL) {
+ _DEBUG_VERBOSE("REREG-THRESHOLD : %s", napdef->rereg_threshold);
+ }
+ } else if (WBXML_STRCMP("T-BIT", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(napdef->t_bit));
+ if(napdef->t_bit != NULL) {
+ _DEBUG_VERBOSE("T-BIT : %s", napdef->t_bit);
+ }
+ }
+ }
+ param_index++;
+ }
+ } else if (!strcmp((const char *)tag_name, "characteristic")) {
+ WBXMLList *attrs = pCursor->attrs;
+ WB_ULONG index = 0;
+ WB_ULONG nb_attrs = wbxml_list_len(attrs);
+
+ while (index < nb_attrs) {
+ WBXMLAttribute *attr = (WBXMLAttribute *) wbxml_list_get(attrs, index);
+ if (WBXML_STRCMP("type", wbxml_attribute_get_xml_name(attr)) == 0) {
+ if (WBXML_STRCMP("NAPAUTHINFO", wbxml_attribute_get_xml_value(attr)) == 0) {
+ DM_CP_Napdef_AuthInfo *auth_info = (DM_CP_Napdef_AuthInfo *) calloc(1, sizeof(DM_CP_Napdef_AuthInfo));
+ if (auth_info == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ free_cp_napdef(napdef);
+ napdef = NULL;
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ if (napdef->auth_info == NULL) {
+ napdef->auth_info = auth_info;
+ } else {
+ DM_CP_Napdef_AuthInfo *cursor_ptr = napdef->auth_info;
+ while (cursor_ptr != NULL) {
+ if (cursor_ptr->next == NULL) {
+ cursor_ptr->next = auth_info;
+ break;
+ }
+ cursor_ptr = cursor_ptr->next;
+ }
+ }
+ WBXMLTreeNode *pCursor_AuthInfo = pCursor->children;
+ while (pCursor_AuthInfo != 0) {
+ if (pCursor_AuthInfo->type == WBXML_TREE_ELEMENT_NODE) {
+ const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_AuthInfo->name);
+ if (strcmp((const char *)tag_name, "parm") == 0) {
+ WBXMLList *param_attrs = pCursor_AuthInfo->attrs;
+ WB_ULONG param_index = 0;
+ WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
+ while (param_index < param_nb_attrs) {
+ WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
+ if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
+ if (WBXML_STRCMP("AUTHTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_AuthInfo, &(auth_info->auth_type));
+ if(auth_info->auth_type != NULL) {
+ _DEBUG_VERBOSE("AUTHTYPE : %s", auth_info->auth_type);
+ }
+ } else if (WBXML_STRCMP("AUTHNAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_AuthInfo, &(auth_info->auth_name));
+ if(auth_info->auth_name != NULL) {
+ _DEBUG_VERBOSE("AUTHNAME : %s", auth_info->auth_name);
+ }
+ } else if (WBXML_STRCMP("AUTHSECRET", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_AuthInfo, &(auth_info->auth_secret));
+ if(auth_info->auth_secret != NULL) {
+ _DEBUG_VERBOSE("AUTHSECRET : %s", auth_info->auth_secret);
+ }
+ } else if (WBXML_STRCMP("AUTH-ENTITY", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ String_Node *target_ptr = ___get_Last_String_Node(auth_info->auth_entity);
+ if (target_ptr == NULL) {
+ _DEBUG_VERBOSE("auth entity is NULL");
+ param_index++;
+ continue;
+ }
+ ___set_Param(pCursor_AuthInfo, &(target_ptr->data));
+ if(target_ptr->data != NULL) {
+ _DEBUG_VERBOSE("AUTH-ENTITY : %s", target_ptr->data);
+ }
+ if (auth_info->auth_entity == NULL) {
+ auth_info->auth_entity = target_ptr;
+ } else {
+ _DEBUG_VERBOSE("free auth entity");
+ free_string_node(target_ptr);
+ }
+ } else if (WBXML_STRCMP("SPI", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_AuthInfo, &(auth_info->spi));
+ if(auth_info->spi != NULL ) {
+ _DEBUG_VERBOSE("SPI : %s", auth_info->spi);
+ }
+ }
+ break;
+ }
+ param_index++;
+ }
+ }
+ }
+ pCursor_AuthInfo = pCursor_AuthInfo->next;
+ }
+ } else if (WBXML_STRCMP("VALIDITY", wbxml_attribute_get_xml_value(attr)) == 0) {
+ DM_CP_Napdef_validity *validity = (DM_CP_Napdef_validity *) calloc(1, sizeof(DM_CP_Napdef_validity));
+ if (validity == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ free_cp_napdef(napdef);
+ napdef = NULL;
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ if (napdef->validity == NULL) {
+ napdef->validity = validity;
+ } else {
+ DM_CP_Napdef_validity *cursor_ptr = napdef->validity;
+ while (cursor_ptr != NULL) {
+ if (cursor_ptr->next == NULL) {
+ cursor_ptr->next = validity;
+ break;
+ }
+ cursor_ptr = cursor_ptr->next;
+ }
+ }
+ WBXMLTreeNode *pCursor_Validity = pCursor->children;
+ while (pCursor_Validity != 0) {
+ if (pCursor_Validity->type == WBXML_TREE_ELEMENT_NODE) {
+ const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_Validity->name);
+ if (!strcmp((const char *)tag_name, "parm")) {
+ WBXMLList *param_attrs = pCursor_Validity->attrs;
+ WB_ULONG param_index = 0;
+ WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
+ while (param_index < param_nb_attrs) {
+ WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
+ if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
+ if (WBXML_STRCMP("COUNTRY", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_Validity, &(validity->country));
+ if(validity->country != NULL) {
+ _DEBUG_VERBOSE("COUNTRY : %s", validity->country);
+ }
+ } else if (WBXML_STRCMP("NETWORK", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_Validity, &(validity->network));
+ if(validity->network != NULL) {
+ _DEBUG_VERBOSE("NETWORK : %s", validity->network);
+ }
+ } else if (WBXML_STRCMP("SID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_Validity, &(validity->sid));
+ if(validity->sid != NULL) {
+ _DEBUG_VERBOSE("SID : %s", validity->sid);
+ }
+ } else if (WBXML_STRCMP("SOC", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_Validity, &(validity->soc));
+ if(validity->soc != NULL) {
+ _DEBUG_VERBOSE("SOC : %s", validity->soc);
+ }
+ } else if (WBXML_STRCMP("VALIDUNTIL", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_Validity, &(validity->validuntil));
+ if(validity->validuntil != NULL) {
+ _DEBUG_VERBOSE("VALIDUNTIL : %s", validity->validuntil);
+ }
+ }
+ break;
+ }
+ param_index++;
+ }
+ }
+ }
+ pCursor_Validity = pCursor_Validity->next;
+ }
+ }
+ }
+ index++;
+ }
+ }
+ }
+ pCursor = pCursor->next;
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return napdef;
+}
+
+static DM_CP_Application *__parse_Application(WBXMLTreeNode * wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((wbxml_dom_node) == NULL, NULL, "wbxml_dom_node is NULL!!");
+
+ DM_CP_Application *application = (DM_CP_Application *) calloc(1, sizeof(DM_CP_Application));
+ if (application == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ WBXMLTreeNode *pCursor = wbxml_dom_node->children;
+
+ while (pCursor != 0) {
+ if (pCursor->type == WBXML_TREE_ELEMENT_NODE) {
+ const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor->name);
+ if (strcmp((const char *)tag_name, "parm") == 0) {
+ WBXMLList *param_attrs = pCursor->attrs;
+ WB_ULONG param_index = 0;
+ WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
+ while (param_index < param_nb_attrs) {
+ WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
+ if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
+ if (WBXML_STRCMP("APPID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(application->app_ID));
+ if(application->app_ID != NULL) {
+ _DEBUG_VERBOSE("APPID : %s", application->app_ID);
+ }
+ } else if (WBXML_STRCMP("PROVIDER-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(application->provider_ID));
+ if(application->provider_ID != NULL) {
+ _DEBUG_VERBOSE("PROVIDER-ID : %s", application->provider_ID);
+ }
+ } else if (WBXML_STRCMP("NAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(application->name));
+ if(application->name != NULL) {
+ _DEBUG_VERBOSE("NAME : %s", application->name);
+ }
+ } else if (WBXML_STRCMP("AACCEPT", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(application->accept));
+ if(application->accept != NULL) {
+ _DEBUG_VERBOSE("AACCEPT : %s", application->accept);
+ }
+ } else if (WBXML_STRCMP("APROTOCOL", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(application->protocol));
+ if(application->protocol != NULL) {
+ _DEBUG_VERBOSE("APROTOCOL : %s", application->protocol);
+ }
+ } else if (WBXML_STRCMP("TO-PROXY", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ String_Node *target_ptr = ___get_Last_String_Node(application->to_proxy);
+ if (target_ptr == NULL) {
+ _DEBUG_VERBOSE("TO-PROXY is NULL");
+ param_index++;
+ continue;
+ }
+
+ ___set_Param(pCursor, &(target_ptr->data));
+ if(target_ptr->data != NULL) {
+ _DEBUG_VERBOSE("PROXY : %s", target_ptr->data);
+ }
+
+ if (application->to_proxy == NULL) {
+ application->to_proxy = target_ptr;
+ } else {
+ _DEBUG_VERBOSE("free PROXY ");
+ free_string_node(target_ptr);
+ }
+ } else if (WBXML_STRCMP("TO-NAPID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ String_Node *target_ptr = ___get_Last_String_Node(application->to_napid);
+ if (target_ptr == NULL) {
+ _DEBUG_VERBOSE("TO-NAPID is NULL");
+ param_index++;
+ continue;
+ }
+
+ ___set_Param(pCursor, &(target_ptr->data));
+ if(target_ptr->data != NULL) {
+ _DEBUG_VERBOSE("NAPID : %s", target_ptr->data);
+ }
+ if (application->to_napid == NULL) {
+ application->to_napid = target_ptr;
+ } else {
+ _DEBUG_VERBOSE("free NAPID ");
+ free_string_node(target_ptr);
+ }
+ } else if (WBXML_STRCMP("ADDR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ String_Node *target_ptr = ___get_Last_String_Node(application->addr);
+ if (target_ptr == NULL) {
+ _DEBUG_VERBOSE("ADDR is NULL");
+ param_index++;
+ continue;
+ }
+
+ ___set_Param(pCursor, &(target_ptr->data));
+ if(target_ptr->data != NULL) {
+ _DEBUG_VERBOSE("ADDR : %s", target_ptr->data);
+ }
+ if (application->addr == NULL) {
+ application->addr = target_ptr;
+ } else {
+ _DEBUG_VERBOSE("free ADDR ");
+ free_string_node(target_ptr);
+ }
+ }
+ break;
+ }
+ param_index++;
+ }
+ } else if (!strcmp((const char *)tag_name, "characteristic")) {
+ WBXMLList *attrs = pCursor->attrs;
+ WB_ULONG index = 0;
+ WB_ULONG nb_attrs = wbxml_list_len(attrs);
+
+ while (index < nb_attrs) {
+ WBXMLAttribute *attr = (WBXMLAttribute *) wbxml_list_get(attrs, index);
+
+ if (WBXML_STRCMP("type", wbxml_attribute_get_xml_name(attr)) == 0) {
+
+ if (WBXML_STRCMP("APPADDR", wbxml_attribute_get_xml_value(attr)) == 0) {
+ DM_CP_Application_AppAddr *app_addr = (DM_CP_Application_AppAddr *) calloc(1, sizeof(DM_CP_Application_AppAddr));
+ if (app_addr == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ free_cp_application(application);
+ application = NULL;
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ if (application->appAddr == NULL) {
+ application->appAddr = app_addr;
+ } else {
+ DM_CP_Application_AppAddr *cursor_ptr = application->appAddr;
+ while (cursor_ptr != NULL) {
+ if (cursor_ptr->next == NULL) {
+ cursor_ptr->next = app_addr;
+ break;
+ }
+ cursor_ptr = cursor_ptr->next;
+ }
+ }
+ WBXMLTreeNode *pCursor_AppAddr = pCursor->children;
+ while (pCursor_AppAddr != 0) {
+ if (pCursor_AppAddr->type == WBXML_TREE_ELEMENT_NODE) {
+ const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_AppAddr->name);
+ if (strcmp((const char *)tag_name, "parm") == 0) {
+ WBXMLList *param_attrs = pCursor_AppAddr->attrs;
+ WB_ULONG param_index = 0;
+ WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
+ while (param_index < param_nb_attrs) {
+ WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
+ if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
+ if (WBXML_STRCMP("ADDR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_AppAddr, &(app_addr->addr));
+ if(app_addr->addr != NULL) {
+ _DEBUG_VERBOSE("ADDR : %s", app_addr->addr);
+ }
+ } else if (WBXML_STRCMP("ADDRTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_AppAddr, &(app_addr->addr_type));
+ if(app_addr->addr_type != NULL) {
+ _DEBUG_VERBOSE("ADDRTYPE : %s", app_addr->addr_type);
+ }
+ }
+ break;
+ }
+ param_index++;
+ }
+ } else if (strcmp((const char *)tag_name, "characteristic") == 0) {
+ WBXMLList *addr_attrs = pCursor_AppAddr->attrs;
+ WB_ULONG addr_index = 0;
+ WB_ULONG addr_nb_attrs = wbxml_list_len(addr_attrs);
+
+ while (addr_index < addr_nb_attrs) {
+ WBXMLAttribute *addr_attr = (WBXMLAttribute *) wbxml_list_get(addr_attrs, addr_index);
+ if (WBXML_STRCMP("type", wbxml_attribute_get_xml_name(addr_attr)) == 0) {
+ if (WBXML_STRCMP("PORT", wbxml_attribute_get_xml_value(addr_attr)) == 0) {
+ DM_CP_Port *port = (DM_CP_Port *) calloc(1, sizeof(DM_CP_Port));
+ if (port == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ free_cp_application(application);
+ application = NULL;
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ if (app_addr->port == NULL) {
+ app_addr->port = port;
+ } else {
+ DM_CP_Port *cursor_ptr = app_addr->port;
+ while (cursor_ptr != NULL) {
+ if (cursor_ptr->next == NULL) {
+ cursor_ptr->next = port;
+ break;
+ }
+ cursor_ptr = cursor_ptr->next;
+ }
+ }
+ WBXMLTreeNode *pCursor_Port = pCursor_AppAddr->children;
+ while (pCursor_Port != 0) {
+ if (pCursor_Port->type == WBXML_TREE_ELEMENT_NODE) {
+ const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_Port->name);
+ if (strcmp((const char *)tag_name, "parm") == 0) {
+ WBXMLList *_param_attrs = pCursor_Port->attrs;
+ WB_ULONG _param_index = 0;
+ WB_ULONG _param_nb_attrs = wbxml_list_len(_param_attrs);
+ while (_param_index < _param_nb_attrs) {
+ WBXMLAttribute *_param_attr = (WBXMLAttribute *) wbxml_list_get(_param_attrs, _param_index);
+ if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(_param_attr)) == 0) {
+ if (WBXML_STRCMP("PORTNBR", wbxml_attribute_get_xml_value(_param_attr)) == 0) {
+ ___set_Param(pCursor_Port, &(port->portnbr));
+ if(port->portnbr != NULL) {
+ _DEBUG_VERBOSE("[%d] PORTNBR : %s", _param_index, port->portnbr);
+ }
+ } else if (WBXML_STRCMP("SERVICE", wbxml_attribute_get_xml_value(_param_attr)) == 0) {
+ String_Node *target_ptr = ___get_Last_String_Node(port->service);
+ if (target_ptr == NULL) {
+ _DEBUG_VERBOSE("SERVICE is NULL");
+ _param_index++;
+ continue;
+ }
+
+ ___set_Param(pCursor_Port, &(target_ptr->data));
+ if(target_ptr->data != NULL) {
+ _DEBUG_VERBOSE("SERVICE : %s", target_ptr->data);
+ }
+ if (port->service == NULL) {
+ port->service = target_ptr;
+ } else {
+ _DEBUG_VERBOSE("free port service");
+ free_string_node(target_ptr);
+ }
+ }
+ break;
+ }
+ _param_index++;
+ _DEBUG_VERBOSE("param_index : %d", _param_index);
+ }
+ }
+ }
+ pCursor_Port = pCursor_Port->next;
+ }
+ }
+ }
+ addr_index++;
+ }
+ }
+ }
+
+ pCursor_AppAddr = pCursor_AppAddr->next;
+ }
+ } else if (WBXML_STRCMP("APPAUTH", wbxml_attribute_get_xml_value(attr)) == 0) {
+ DM_CP_Application_AppAuth *app_auth = (DM_CP_Application_AppAuth *) calloc(1, sizeof(DM_CP_Application_AppAuth));
+ if (app_auth == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ free_cp_application(application);
+ application = NULL;
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ if (application->appAuth == NULL) {
+ application->appAuth = app_auth;
+ } else {
+ DM_CP_Application_AppAuth *cursor_ptr = application->appAuth;
+ while (cursor_ptr != NULL) {
+ if (cursor_ptr->next == NULL) {
+ cursor_ptr->next = app_auth;
+ break;
+ }
+ cursor_ptr = cursor_ptr->next;
+ }
+ }
+ WBXMLTreeNode *pCursor_AppAuth = pCursor->children;
+ while (pCursor_AppAuth != 0) {
+ if (pCursor_AppAuth->type == WBXML_TREE_ELEMENT_NODE) {
+ const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_AppAuth->name);
+ if (strcmp((const char *)tag_name, "parm") == 0) {
+ WBXMLList *param_attrs = pCursor_AppAuth->attrs;
+ WB_ULONG param_index = 0;
+ WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
+ while (param_index < param_nb_attrs) {
+ WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
+ if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
+ if (WBXML_STRCMP("AAUTHLEVEL", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_AppAuth, &(app_auth->auth_level));
+ if(app_auth->auth_level != NULL) {
+ _DEBUG_VERBOSE("AAUTHLEVEL : %s", app_auth->auth_level);
+ }
+ } else if (WBXML_STRCMP("AAUTHTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_AppAuth, &(app_auth->auth_type));
+ if(app_auth->auth_type != NULL) {
+ _DEBUG_VERBOSE("AAUTHTYPE : %s", app_auth->auth_type);
+ }
+ } else if (WBXML_STRCMP("AAUTHNAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_AppAuth, &(app_auth->auth_name));
+ if(app_auth->auth_name != NULL) {
+ _DEBUG_VERBOSE("AAUTHNAME : %s", app_auth->auth_name);
+ }
+ } else if (WBXML_STRCMP("AAUTHSECRET", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_AppAuth, &(app_auth->auth_secret));
+ if(app_auth->auth_secret != NULL) {
+ _DEBUG_VERBOSE("AAUTHSECRET : %s", app_auth->auth_secret);
+ }
+ } else if (WBXML_STRCMP("AAUTHDATA", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_AppAuth, &(app_auth->auth_data));
+ if(app_auth->auth_data != NULL) {
+ _DEBUG_VERBOSE("AAUTHDATA : %s", app_auth->auth_data);
+ }
+ }
+ break;
+ }
+ param_index++;
+ }
+ }
+ }
+ pCursor_AppAuth = pCursor_AppAuth->next;
+ }
+ } else if (WBXML_STRCMP("RESOURCE", wbxml_attribute_get_xml_value(attr)) == 0) {
+ DM_CP_Application_Resource *app_resource = (DM_CP_Application_Resource *) calloc(1, sizeof(DM_CP_Application_Resource));
+ if (app_resource == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ free_cp_application(application);
+ application = NULL;
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ if (application->resource == NULL) {
+ application->resource = app_resource;
+ } else {
+ DM_CP_Application_Resource *cursor_ptr = application->resource;
+ while (cursor_ptr != NULL) {
+ if (cursor_ptr->next == NULL) {
+ cursor_ptr->next = app_resource;
+ break;
+ }
+ cursor_ptr = cursor_ptr->next;
+ }
+ }
+ WBXMLTreeNode *pCursor_Resource = pCursor->children;
+ while (pCursor_Resource != 0) {
+ if (pCursor_Resource->type == WBXML_TREE_ELEMENT_NODE) {
+ const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_Resource->name);
+ if (strcmp((const char *)tag_name, "parm") == 0) {
+ WBXMLList *param_attrs = pCursor_Resource->attrs;
+ WB_ULONG param_index = 0;
+ WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
+ while (param_index < param_nb_attrs) {
+ WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
+ if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
+ if (WBXML_STRCMP("URI", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_Resource, &(app_resource->uri));
+ if(app_resource->uri != NULL) {
+ _DEBUG_VERBOSE("URI : %s", app_resource->uri);
+ }
+ } else if (WBXML_STRCMP("NAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_Resource, &(app_resource->name));
+ if(app_resource->name != NULL) {
+ _DEBUG_VERBOSE("NAME : %s", app_resource->name);
+ }
+ } else if (WBXML_STRCMP("AACCEPT", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_Resource, &(app_resource->accept));
+ if(app_resource->accept != NULL) {
+ _DEBUG_VERBOSE("AACCEPT : %s", app_resource->accept);
+ }
+ } else if (WBXML_STRCMP("AAUTHTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_Resource, &(app_resource->auth_type));
+ if(app_resource->auth_type != NULL) {
+ _DEBUG_VERBOSE("AAUTHTYPE : %s", app_resource->auth_type);
+ }
+ } else if (WBXML_STRCMP("AAUTHNAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_Resource, &(app_resource->auth_name));
+ if(app_resource->auth_name != NULL) {
+ _DEBUG_VERBOSE("AAUTHNAME : %s", app_resource->auth_name);
+ }
+ } else if (WBXML_STRCMP("AAUTHSECRET", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_Resource, &(app_resource->auth_secret));
+ if(app_resource->auth_secret != NULL) {
+ _DEBUG_VERBOSE("AAUTHSECRET : %s", app_resource->auth_secret);
+ }
+ } else if (WBXML_STRCMP("AAUTHDATA", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_Resource, &(app_resource->auth_data));
+ if(app_resource->auth_data != NULL) {
+ _DEBUG_VERBOSE("AAUTHDATA : %s", app_resource->auth_data);
+ }
+ } else if (WBXML_STRCMP("STARTPAGE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_Resource, &(app_resource->start_page));
+ if(app_resource->start_page != NULL) {
+ _DEBUG_VERBOSE("STARTPAGE : %s", app_resource->start_page);
+ }
+ }
+ break;
+ }
+ param_index++;
+ }
+ }
+ }
+ pCursor_Resource = pCursor_Resource->next;
+ }
+ }
+ }
+
+ index++;
+ }
+ }
+ }
+
+ pCursor = pCursor->next;
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return application;
+}
+
+static DM_CP_PxLogical *__parse_PxLogical(WBXMLTreeNode * wbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((wbxml_dom_node) == NULL, NULL, "wbxml_dom_node is NULL!!");
+
+ DM_CP_PxLogical *pxLogical = (DM_CP_PxLogical *) calloc(1, sizeof(DM_CP_PxLogical));
+ if (pxLogical == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ WBXMLTreeNode *pCursor = wbxml_dom_node->children;
+
+ while (pCursor != 0) {
+ if (pCursor->type == WBXML_TREE_ELEMENT_NODE) {
+ const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor->name);
+ if (strcmp((const char *)tag_name, "parm") == 0) {
+ WBXMLList *param_attrs = pCursor->attrs;
+ WB_ULONG param_index = 0;
+ WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
+ while (param_index < param_nb_attrs) {
+ WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
+ if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
+ if (WBXML_STRCMP("PROXY-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(pxLogical->proxy_id));
+ if(pxLogical->proxy_id != NULL) {
+ _DEBUG_VERBOSE("PROXY-ID : %s", pxLogical->proxy_id);
+ }
+ } else if (WBXML_STRCMP("PROXY-PW", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(pxLogical->proxy_pw));
+ if(pxLogical->proxy_pw != NULL) {
+ _DEBUG_VERBOSE("PROXY-PW : %s", pxLogical->proxy_pw);
+ }
+ } else if (WBXML_STRCMP("PPGAUTH-TYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(pxLogical->ppg_auth_type));
+ if(pxLogical->ppg_auth_type != NULL) {
+ _DEBUG_VERBOSE("PPGAUTH-TYPE : %s", pxLogical->ppg_auth_type);
+ }
+ } else if (WBXML_STRCMP("PROXY-PROVIDER-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(pxLogical->proxy_provider_id));
+ if(pxLogical->proxy_provider_id != NULL) {
+ _DEBUG_VERBOSE("PROXY-PROVIDER-ID : %s", pxLogical->proxy_provider_id);
+ }
+ } else if (WBXML_STRCMP("NAME", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(pxLogical->name));
+ if(pxLogical->name != NULL) {
+ _DEBUG_VERBOSE("NAME : %s", pxLogical->name);
+ }
+ } else if (WBXML_STRCMP("DOMAIN", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ String_Node *target_ptr = ___get_Last_String_Node(pxLogical->domain);
+ if(target_ptr == NULL) {
+ _DEBUG_VERBOSE("___get_Last_String_Node fail");
+ free_cp_pxlogical(pxLogical);
+ pxLogical = NULL;
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ ___set_Param(pCursor, &(target_ptr->data));
+ if(target_ptr->data != NULL) {
+ _DEBUG_VERBOSE("DOMAIN : %s", target_ptr->data);
+ }
+ if (pxLogical->domain == 0) {
+ pxLogical->domain = target_ptr;
+ } else {
+ _DEBUG_VERBOSE("free DOMAIN ");
+ free_string_node(target_ptr);
+ }
+ } else if (WBXML_STRCMP("TRUST", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(pxLogical->trust));
+ if(pxLogical->trust != NULL) {
+ _DEBUG_VERBOSE("TRUST : %s", pxLogical->trust);
+ }
+ } else if (WBXML_STRCMP("MASTER", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(pxLogical->master));
+ if(pxLogical->master != NULL) {
+ _DEBUG_VERBOSE("MASTER : %s", pxLogical->master);
+ }
+ } else if (WBXML_STRCMP("STARTPAGE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(pxLogical->start_page));
+ if(pxLogical->start_page != NULL) {
+ _DEBUG_VERBOSE("STARTPAGE : %s", pxLogical->start_page);
+ }
+ } else if (WBXML_STRCMP("BASAUTH-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(pxLogical->bas_auth_id));
+ if(pxLogical->bas_auth_id != NULL) {
+ _DEBUG_VERBOSE("BASAUTH-ID : %s", pxLogical->bas_auth_id);
+ }
+ } else if (WBXML_STRCMP("BASAUTH-PW", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(pxLogical->bas_auth_pw));
+ if(pxLogical->bas_auth_pw != NULL) {
+ _DEBUG_VERBOSE("BASAUTH-PW : %s", pxLogical->bas_auth_pw);
+ }
+ } else if (WBXML_STRCMP("WSP-VERSION", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(pxLogical->wsp_version));
+ if(pxLogical->wsp_version != NULL) {
+ _DEBUG_VERBOSE("WSP-VERSION : %s", pxLogical->wsp_version);
+ }
+ } else if (WBXML_STRCMP("PUSHENABLED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(pxLogical->push_enabled));
+ if(pxLogical->push_enabled != NULL) {
+ _DEBUG_VERBOSE("PUSHENABLED : %s", pxLogical->push_enabled);
+ }
+ } else if (WBXML_STRCMP("PULLENABLED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor, &(pxLogical->pull_enabled));
+ if(pxLogical->pull_enabled != NULL) {
+ _DEBUG_VERBOSE("PULLENABLED : %s", pxLogical->pull_enabled);
+ }
+ }
+ break;
+ }
+ param_index++;
+ }
+ } else if (!strcmp((const char *)tag_name, "characteristic")) {
+ WBXMLList *attrs = pCursor->attrs;
+ WB_ULONG index = 0;
+ WB_ULONG nb_attrs = wbxml_list_len(attrs);
+
+ while (index < nb_attrs) {
+ WBXMLAttribute *attr = (WBXMLAttribute *) wbxml_list_get(attrs, index);
+
+ if (WBXML_STRCMP("type", wbxml_attribute_get_xml_name(attr)) == 0) {
+
+ if (WBXML_STRCMP("PXAUTHINFO", wbxml_attribute_get_xml_value(attr)) == 0) {
+ DM_CP_PxLogical_PxAuthInfo *pxAuthInfo = (DM_CP_PxLogical_PxAuthInfo *) calloc(1, sizeof(DM_CP_PxLogical_PxAuthInfo));
+ if (pxAuthInfo == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ free_cp_pxlogical(pxLogical);
+ pxLogical = NULL;
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ if (pxLogical->pxAuthInfo == NULL) {
+ pxLogical->pxAuthInfo = pxAuthInfo;
+ } else {
+ DM_CP_PxLogical_PxAuthInfo *cursor_ptr = pxLogical->pxAuthInfo;
+ while (cursor_ptr != NULL) {
+ if (cursor_ptr->next == NULL) {
+ cursor_ptr->next = pxAuthInfo;
+ break;
+ }
+ cursor_ptr = cursor_ptr->next;
+ }
+ }
+ WBXMLTreeNode *pCursor_PxAuthInfo = pCursor->children;
+ while (pCursor_PxAuthInfo != 0) {
+ if (pCursor_PxAuthInfo->type == WBXML_TREE_ELEMENT_NODE) {
+ const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_PxAuthInfo->name);
+ if (strcmp((const char *)tag_name, "parm") == 0) {
+ WBXMLList *param_attrs = pCursor_PxAuthInfo->attrs;
+ WB_ULONG param_index = 0;
+ WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
+ while (param_index < param_nb_attrs) {
+ WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
+ if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
+ if (WBXML_STRCMP("PXAUTH-TYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_PxAuthInfo, &(pxAuthInfo->pxAuth_type));
+ if(pxAuthInfo->pxAuth_type != NULL) {
+ _DEBUG_VERBOSE("PXAUTH-TYPE : %s", pxAuthInfo->pxAuth_type);
+ }
+ } else if (WBXML_STRCMP("PXAUTH-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_PxAuthInfo, &(pxAuthInfo->pxAuth_id));
+ if(pxAuthInfo->pxAuth_id != NULL) {
+ _DEBUG_VERBOSE("PXAUTH-ID : %s", pxAuthInfo->pxAuth_id);
+ }
+ } else if (WBXML_STRCMP("PXAUTH-PW", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_PxAuthInfo, &(pxAuthInfo->pxAuth_pw));
+ if(pxAuthInfo->pxAuth_pw != NULL) {
+ _DEBUG_VERBOSE("PXAUTH-PW : %s", pxAuthInfo->pxAuth_pw);
+ }
+ }
+ break;
+ }
+ param_index++;
+ }
+ }
+ }
+ pCursor_PxAuthInfo = pCursor_PxAuthInfo->next;
+ }
+ } else if (WBXML_STRCMP("PORT", wbxml_attribute_get_xml_value(attr)) == 0) {
+ DM_CP_Port *port = (DM_CP_Port *) calloc(1, sizeof(DM_CP_Port));
+ if (port == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ free_cp_pxlogical(pxLogical);
+ pxLogical = NULL;
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ if (pxLogical->port == NULL) {
+ pxLogical->port = port;
+ } else {
+ DM_CP_Port *cursor_ptr = pxLogical->port;
+ while (cursor_ptr != NULL) {
+ if (cursor_ptr->next == NULL) {
+ cursor_ptr->next = port;
+ break;
+ }
+ cursor_ptr = cursor_ptr->next;
+ }
+ }
+ WBXMLTreeNode *pCursor_Port = pCursor->children;
+ while (pCursor_Port != 0) {
+ if (pCursor_Port->type == WBXML_TREE_ELEMENT_NODE) {
+ const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_Port->name);
+ if (strcmp((const char *)tag_name, "parm") == 0) {
+ WBXMLList *param_attrs = pCursor_Port->attrs;
+ WB_ULONG param_index = 0;
+ WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
+ while (param_index < param_nb_attrs) {
+ WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
+ if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
+ if (WBXML_STRCMP("PORTNBR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_Port, &(port->portnbr));
+ if(port->portnbr != NULL) {
+ _DEBUG_VERBOSE("AAUTHLEVEL : %s", port->portnbr);
+ }
+ } else if (WBXML_STRCMP("SERVICE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ String_Node *target_ptr = ___get_Last_String_Node(port->service);
+ ___set_Param(pCursor_Port, &(target_ptr->data));
+ if(target_ptr->data != NULL) {
+ _DEBUG_VERBOSE("SERVICE : %s", target_ptr->data);
+ }
+ if (port->service == NULL) {
+ port->service = target_ptr;
+ } else {
+ _DEBUG_VERBOSE("free SERVICE ");
+ free_string_node(target_ptr);
+ }
+ }
+ break;
+ }
+ param_index++;
+ }
+ }
+ }
+ pCursor_Port = pCursor_Port->next;
+ }
+ } else if (WBXML_STRCMP("PXPHYSICAL", wbxml_attribute_get_xml_value(attr)) == 0) {
+ DM_CP_PxLogical_PxPhysical *pxPhysical = (DM_CP_PxLogical_PxPhysical *) calloc(1, sizeof(DM_CP_PxLogical_PxPhysical));
+ if (pxPhysical == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ free_cp_pxlogical(pxLogical);
+ pxLogical = NULL;
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ if (pxLogical->pxPhysical == NULL) {
+ pxLogical->pxPhysical = pxPhysical;
+ } else {
+ DM_CP_PxLogical_PxPhysical *cursor_ptr = pxLogical->pxPhysical;
+ while (cursor_ptr != NULL) {
+ if (cursor_ptr->next == NULL) {
+ cursor_ptr->next = pxPhysical;
+ break;
+ }
+ cursor_ptr = cursor_ptr->next;
+ }
+ }
+ WBXMLTreeNode *pCursor_PxPhysical = pCursor->children;
+ while (pCursor_PxPhysical != 0) {
+ if (pCursor_PxPhysical->type == WBXML_TREE_ELEMENT_NODE) {
+ const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_PxPhysical->name);
+ if (strcmp((const char *)tag_name, "parm") == 0) {
+ WBXMLList *param_attrs = pCursor_PxPhysical->attrs;
+ WB_ULONG param_index = 0;
+ WB_ULONG param_nb_attrs = wbxml_list_len(param_attrs);
+ while (param_index < param_nb_attrs) {
+ WBXMLAttribute *param_attr = (WBXMLAttribute *) wbxml_list_get(param_attrs, param_index);
+ if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(param_attr)) == 0) {
+ if (WBXML_STRCMP("PHYSICAL-PROXY-ID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_PxPhysical, &(pxPhysical->physical_proxy_id));
+ if(pxPhysical->physical_proxy_id != NULL) {
+ _DEBUG_VERBOSE("PHYSICAL-PROXY-ID : %s", pxPhysical->physical_proxy_id);
+ }
+ } else if (WBXML_STRCMP("DOMAIN", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ String_Node *target_ptr = ___get_Last_String_Node(pxPhysical->domain);
+ if(target_ptr == NULL) {
+ _DEBUG_VERBOSE("___get_Last_String_Node fail");
+ free_cp_pxlogical(pxLogical);
+ pxLogical = NULL;
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ ___set_Param(pCursor_PxPhysical, &(target_ptr->data));
+ if(target_ptr->data != NULL) {
+ _DEBUG_VERBOSE("DOMAIN : %s", target_ptr->data);
+ }
+ if (pxPhysical->domain == NULL) {
+ pxPhysical->domain = target_ptr;
+ } else {
+ _DEBUG_VERBOSE("free DOMAIN ");
+ free_string_node(target_ptr);
+ }
+ } else if (WBXML_STRCMP("PXADDR", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_PxPhysical, &(pxPhysical->pxAddr));
+ if(pxPhysical->pxAddr != NULL) {
+ _DEBUG_VERBOSE("PXADDR : %s", pxPhysical->pxAddr);
+ }
+ } else if (WBXML_STRCMP("PXADDRTYPE", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_PxPhysical, &(pxPhysical->pxAddrType));
+ if(pxPhysical->pxAddrType != NULL) {
+ _DEBUG_VERBOSE("PXADDRTYPE : %s", pxPhysical->pxAddrType);
+ }
+ } else if (WBXML_STRCMP("PXADDR-FQDN", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_PxPhysical, &(pxPhysical->pxAddr_FQDN));
+ if(pxPhysical->pxAddr_FQDN != NULL) {
+ _DEBUG_VERBOSE("PXADDR-FQDN : %s", pxPhysical->pxAddr_FQDN);
+ }
+ } else if (WBXML_STRCMP("WSP-VERSION", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_PxPhysical, &(pxPhysical->wsp_version));
+ if(pxPhysical->wsp_version != NULL) {
+ _DEBUG_VERBOSE("WSP-VERSION : %s", pxPhysical->wsp_version);
+ }
+ } else if (WBXML_STRCMP("PUSHENABLED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_PxPhysical, &(pxPhysical->push_enabled));
+ if(pxPhysical->push_enabled != NULL) {
+ _DEBUG_VERBOSE("PUSHENABLED : %s", pxPhysical->push_enabled);
+ }
+ } else if (WBXML_STRCMP("PULLENABLED", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ ___set_Param(pCursor_PxPhysical, &(pxPhysical->pull_enabled));
+ if(pxPhysical->pull_enabled != NULL) {
+ _DEBUG_VERBOSE("PULLENABLED : %s", pxPhysical->pull_enabled);
+ }
+ } else if (WBXML_STRCMP("TO-NAPID", wbxml_attribute_get_xml_value(param_attr)) == 0) {
+ String_Node *target_ptr = ___get_Last_String_Node(pxPhysical->to_napid);
+ if(target_ptr == NULL) {
+ _DEBUG_VERBOSE("___get_Last_String_Node fail");
+ free_cp_pxlogical(pxLogical);
+ pxLogical = NULL;
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ ___set_Param(pCursor_PxPhysical, &(target_ptr->data));
+ if(target_ptr->data != NULL) {
+ _DEBUG_VERBOSE("TO-NAPID : %s", target_ptr->data);
+ }
+ if (pxPhysical->to_napid == NULL) {
+ pxPhysical->to_napid = target_ptr;
+ } else {
+ _DEBUG_VERBOSE("free TO-NAPID ");
+ free_string_node(target_ptr);
+ }
+ }
+ break;
+ }
+ param_index++;
+ }
+ } else if (strcmp((const char *)tag_name, "characteristic") == 0) {
+ WBXMLList *addr_attrs = pCursor_PxPhysical->attrs;
+ WB_ULONG addr_index = 0;
+ WB_ULONG addr_nb_attrs = wbxml_list_len(addr_attrs);
+
+ while (addr_index < addr_nb_attrs) {
+ WBXMLAttribute *addr_attr = (WBXMLAttribute *) wbxml_list_get(addr_attrs, addr_index);
+ if (WBXML_STRCMP("type", wbxml_attribute_get_xml_name(addr_attr)) == 0) {
+ if (WBXML_STRCMP("PORT", wbxml_attribute_get_xml_value(addr_attr)) == 0) {
+ DM_CP_Port *port = (DM_CP_Port *) calloc(1, sizeof(DM_CP_Port));
+ if (port == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ free_cp_pxlogical(pxLogical);
+ pxLogical = NULL;
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ if (pxPhysical->port == NULL) {
+ pxPhysical->port = port;
+ } else {
+ DM_CP_Port *cursor_ptr = pxPhysical->port;
+ while (cursor_ptr != NULL) {
+ if (cursor_ptr->next == NULL) {
+ cursor_ptr->next = port;
+ break;
+ }
+ cursor_ptr = cursor_ptr->next;
+ }
+ }
+ WBXMLTreeNode *pCursor_Port = pCursor_PxPhysical->children;
+ while (pCursor_Port != 0) {
+ if (pCursor_Port->type == WBXML_TREE_ELEMENT_NODE) {
+ const WB_UTINY *tag_name = wbxml_tag_get_xml_name(pCursor_Port->name);
+ if (strcmp((const char *)tag_name, "parm") == 0) {
+ WBXMLList *_param_attrs = pCursor_Port->attrs;
+ WB_ULONG _param_index = 0;
+ WB_ULONG _param_nb_attrs = wbxml_list_len(_param_attrs);
+ while (_param_index < _param_nb_attrs) {
+ WBXMLAttribute *_param_attr = (WBXMLAttribute *) wbxml_list_get(_param_attrs, _param_index);
+ if (WBXML_STRCMP("name", wbxml_attribute_get_xml_name(_param_attr)) == 0) {
+ if (WBXML_STRCMP("PORTNBR", wbxml_attribute_get_xml_value(_param_attr)) == 0) {
+ ___set_Param(pCursor_Port, &(port->portnbr));
+ if(port->portnbr != NULL) {
+ _DEBUG_VERBOSE("[%d] PORTNBR : %s", _param_index, port->portnbr);
+ }
+ } else if (WBXML_STRCMP("SERVICE", wbxml_attribute_get_xml_value(_param_attr)) == 0) {
+ String_Node *target_ptr = ___get_Last_String_Node(port->service);
+ if(target_ptr==NULL) {
+ _DEBUG_VERBOSE("___get_Last_String_Node fail");
+ free_cp_pxlogical(pxLogical);
+ pxLogical = NULL;
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ ___set_Param(pCursor_Port, &(target_ptr->data));
+ if(target_ptr->data != NULL) {
+ _DEBUG_VERBOSE("SERVICE : %s", target_ptr->data);
+ }
+ if (port->service == NULL) {
+ port->service = target_ptr;
+ } else {
+ _DEBUG_VERBOSE("free port service");
+ free_string_node(target_ptr);
+ }
+ }
+ break;
+ }
+ _param_index++;
+ _DEBUG_VERBOSE("param_index : %d", _param_index);
+ }
+ }
+ }
+ pCursor_Port = pCursor_Port->next;
+ }
+ }
+ }
+ addr_index++;
+ }
+ }
+ }
+ pCursor_PxPhysical = pCursor_PxPhysical->next;
+ }
+ }
+ }
+ index++;
+ }
+ }
+ }
+
+ pCursor = pCursor->next;
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return pxLogical;
+}
+
+static void ___set_Param(WBXMLTreeNode * wbxml_dom_node, char **set_value)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if((wbxml_dom_node) == NULL, "wbxml_dom_node is NULL!!");
+
+ WBXMLList *attr_list = wbxml_dom_node->attrs;
+ WB_ULONG index = 0;
+ WB_ULONG nb_attrs = wbxml_list_len(attr_list);
+
+ while (index < nb_attrs) {
+ WBXMLAttribute *attr = (WBXMLAttribute *) wbxml_list_get(attr_list, index);
+ if (WBXML_STRCMP("value", wbxml_attribute_get_xml_name(attr)) == 0) {
+ const char *value_str = 0;
+ value_str = (const char *)wbxml_attribute_get_xml_value(attr);
+ int value_len = 0;
+ if (value_str != NULL) {
+ value_len = strlen(value_str);
+ }
+ int str_len = 0;
+ *set_value = (char *)calloc(value_len + 1, sizeof(char));
+ if (*set_value == NULL) {
+ break;
+ }
+
+ str_len = g_strlcpy(*set_value, value_str, value_len + 1);
+ if (str_len >= sizeof(*set_value)) {
+ _DEBUG_VERBOSE("buffer overflow");
+ break;
+ }
+ break;
+ }
+ index++;
+ }
+ _INNER_FUNC_EXIT;
+}
diff --git a/src/agent/dm-engine/cp/dm_cp_processor.c b/src/agent/dm-engine/cp/dm_cp_processor.c
new file mode 100755
index 0000000..ce1ffe5
--- /dev/null
+++ b/src/agent/dm-engine/cp/dm_cp_processor.c
@@ -0,0 +1,2000 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <glib.h>
+#include <glib/gprintf.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+#include <plugin/plugin_slp_sysnoti_wap_push.h>
+
+/*dm-agent*/
+#include "common/dm_common_def.h"
+#include "common/util/util.h"
+#include "mo-handler/dm_mo_common_internal.h"
+#include "mo-handler/dm_mo_common.h"
+#include "dm-engine/cp/dm_cp_parser.h"
+#include "dm-engine/cp/dm_cp_security.h"
+#include "dm-engine/cp/dm_cp_processor.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_CP"
+#endif
+
+#define IMSI_VALUE "310260487447094"
+
+#define MSG_SIZE 300
+
+#define W2 "Browser"
+#define W4 "MMS"
+#define W5 "SyncML DS"
+#define W7 "SyncML DM"
+#define WA "IM & PS"
+
+#define DELIMITER " : "
+#define L_BRACKET " ["
+#define R_BRACKET "] "
+#define LB "\n"
+#define APPLICATION "Application : "
+#define URL "URL : "
+#define PROXY "Proxy : "
+#define PORT "Port : "
+#define BOOKMARK "Bookmark : " /* not used */
+#define NO_DATA "No data "
+#define DEFAULT_NAP_TYPE "APN : "
+
+static int g_msgId;
+
+typedef struct {
+ int ext_id;
+ DM_CP *dm_cp;
+} CP_Data;
+
+static GList *dm_cp_list = NULL;
+
+static CP_ERROR _process_receieved_cp_stream(CP_TYPE cp_type, const char *msgBody, unsigned int msgSize, int ext_id);
+static CP_ERROR __send_msg2mf(SENDMSG_TYPE send_type, void *send_msg);
+static CP_ERROR _process_setting_oma_ds(DM_CP * dm_cp);
+static CP_ERROR _process_setting_oma_dm(DM_CP * dm_cp);
+
+static char __char2hex(char ch);
+static char *_get_netpin_key(int *key_len);
+static int __make_view_message(char **msgData, DM_CP * dm_cp);
+
+CP_ERROR process_Recieved_CP_WBXML(const char *msgBody, unsigned int msgSize, int ext_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((msgBody) == NULL, CP_ERROR_FAIL, "msgBody is NULL!!");
+
+ CP_ERROR ret = CP_ERROR_SUCCESS;
+
+ unsigned int wsp_header_size = (unsigned char)msgBody[2];
+ wsp_header_size += 3;
+ _DEBUG_INFO("wsp_header_size : %u", wsp_header_size);
+
+ unsigned int wbxml_size = msgSize - wsp_header_size;
+ _DEBUG_INFO("msgSize : %d, wbxml_size : %u", msgSize, wbxml_size);
+
+ /*
+ * Register PIN CODE to File
+ */
+ char file_buffer[50] = { 0, };
+ snprintf(file_buffer, sizeof(file_buffer), "%s/%d/%s", CP_DATA_REPOSITORY_PATH, ext_id, CP_SEC_FILE_NAME);
+ _DEBUG_INFO("file name : %s", file_buffer);
+
+// int file_ret = sync_agent_write_file(CP_SEC_REPOSITORY_PATH, msgBody, wsp_header_size, 1, 1);
+// int file_ret = sync_agent_write_whole_file(CP_SEC_REPOSITORY_PATH, msgBody, wsp_header_size, 1);
+ int file_ret = sync_agent_write_whole_file(file_buffer, msgBody, wsp_header_size, 1);
+ if (file_ret != 1) {
+ _DEBUG_INFO("Failed to repository CP PIN Info");
+ }
+
+ /*
+ * Division CP WBXML to WSP Header
+ */
+ char *wbxml_body = (char *)calloc(wbxml_size, sizeof(char));
+ if (wbxml_body == NULL) {
+ _DEBUG_INFO("alloc fail");
+ return 0;
+ }
+ memcpy(wbxml_body, msgBody + wsp_header_size, wbxml_size);
+
+ ret = _process_receieved_cp_stream(CP_TYPE_WBXML, wbxml_body, wbxml_size, ext_id);
+ _DEBUG_INFO("precess receive result : %d", ret);
+
+ free(wbxml_body);
+ wbxml_body = NULL;
+
+ return ret;
+}
+
+CP_ERROR process_Recieved_CP_XML(const char *msgBody, unsigned int msgSize, int ext_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((msgBody) == NULL, CP_ERROR_FAIL, "msgBody is NULL!!");
+
+ _EXTERN_FUNC_EXIT;
+ return _process_receieved_cp_stream(CP_TYPE_XML, msgBody, msgSize, ext_id);
+}
+
+CP_ERROR process_Check_Pincode(int is_initial, char *user_data, int *is_correct, int ext_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ CP_ERROR ret = CP_ERROR_SUCCESS;
+
+ /*
+ * 1. get CP header info in repository(file)
+ */
+ /*unsigned long required_length = 50;
+ bool isFinal = 0; */
+ unsigned long size_return = 0;
+ char *cp_pin_info = 0;
+ char *wbxml_body = 0;
+ unsigned long wbxml_size = 0;
+ char *key = 0;
+ int key_len = 0;
+ int i = 0;
+
+ char sec_file_name[50] = { 0, };
+ snprintf(sec_file_name, sizeof(sec_file_name), "%s/%d/%s", CP_DATA_REPOSITORY_PATH, ext_id, CP_SEC_FILE_NAME);
+ _DEBUG_INFO("sec file name : %s", sec_file_name);
+
+// int read_ret = sync_agent_read_file(CP_SEC_REPOSITORY_PATH, &cp_pin_info, required_length, &size_return, &isFinal);
+// int read_ret = sync_agent_read_whole_file(CP_SEC_REPOSITORY_PATH, &cp_pin_info, &size_return);
+ int read_ret = sync_agent_read_whole_file(sec_file_name, &cp_pin_info, &size_return);
+ if (read_ret == 0) {
+ _DEBUG_INFO("Failed to sync_agent_read_file( CP_SEC_REPOSITORY_PATH ) !!");
+ return CP_ERROR_FAIL;
+ }
+
+ char wbxml_file_name[50] = { 0, };
+ snprintf(wbxml_file_name, sizeof(wbxml_file_name), "%s/%d/%s", CP_DATA_REPOSITORY_PATH, ext_id, CP_WBXML_FILE_NAME);
+ _DEBUG_INFO("wbxml file name : %s", wbxml_file_name);
+// read_ret = sync_agent_read_whole_file(CP_WBXML_REPOSITORY_PATH, &wbxml_body, &wbxml_size);
+ read_ret = sync_agent_read_whole_file(wbxml_file_name, &wbxml_body, &wbxml_size);
+ if (read_ret == 0) {
+ _DEBUG_INFO("Failed to sync_agent_read_file ( CP_WBXML_REPOSITORY_PATH ) !!");
+ return CP_ERROR_FAIL;
+ }
+
+ /*
+ * Check SEC TYPE
+ */
+ char sec = cp_pin_info[6];
+ char sec_type = 0;
+ if (sec == CP_SEC) {
+ sec_type = cp_pin_info[7];
+ }
+ _DEBUG_INFO("SEC : %u, %x, SEC_TYPE : %u, %x, %c", sec, sec, sec_type, sec_type, sec_type);
+
+ /*
+ * Check Is Exist MAC in wbxml stream
+ */
+ int is_exist_mac = 0;
+ if (cp_pin_info[8] == CP_IS_EXIST_MAC) {
+ is_exist_mac = 1;
+ }
+
+ char mac[CP_MAC_LEN] = { 0, };
+ if (is_exist_mac != 0) {
+ i = 0;
+ for (; i < CP_MAC_LEN; i++) {
+ mac[i] = cp_pin_info[9 + i];
+ }
+ }
+
+ switch ((unsigned char)sec_type) {
+ case CP_SEC_TYPE_NETWPIN:
+ {
+ _DEBUG_INFO("SEC TYPE : NETWPIN");
+
+ char *temp = 0;
+ temp = _get_netpin_key(&key_len);
+ if (temp == NULL) {
+ _DEBUG_INFO("__get_NetPIN_key() failed !!");
+ ret = CP_ERROR_FAIL;
+ goto return_part;
+ }
+
+ key = (char *)calloc(key_len, sizeof(char));
+ if (key == NULL) {
+ _DEBUG_INFO("calloc failed !!");
+
+ if (temp != NULL)
+ free(temp);
+ ret = CP_ERROR_FAIL;
+ goto return_part;
+ }
+
+ memcpy(key, temp, key_len);
+
+ for (i = 0; i < key_len; i++) {
+ _DEBUG_INFO("key[%d] : 0x%02X", i, key[i]);
+ }
+
+ if (temp != NULL)
+ free(temp);
+ }
+ break;
+ case CP_SEC_TYPE_USERPIN:
+ {
+ _DEBUG_INFO("SEC TYPE : USERPIN");
+
+ int res = 0;
+ if (is_initial != 0) {
+ res = launch_oma_dm_cp_ui(1, ext_id);
+ if (res < 0) {
+ _DEBUG_INFO("launch_oma_dm_cp_ui() fail !!");
+ ret = CP_ERROR_FAIL;
+ } else {
+ _DEBUG_INFO("launch_oma_dm_cp_ui() success !!");
+ }
+
+ goto return_part;
+ } else {
+ if (user_data != NULL) {
+ key_len = strlen(user_data);
+
+ key = (char *)calloc(key_len, sizeof(char));
+ if (key == NULL) {
+ _DEBUG_INFO("calloc failed !!");
+ ret = CP_ERROR_FAIL;
+ goto return_part;
+ }
+
+ strncpy(key, user_data, key_len);
+ _DEBUG_INFO("key : %s ( %d )", user_data, key_len);
+ } else {
+ _DEBUG_INFO("launch_oma_dm_cp_ui() fail !!");
+ ret = CP_ERROR_FAIL;
+ goto return_part;
+ }
+ }
+ }
+ break;
+ case CP_SEC_TYPE_USERNETWPIN:
+ {
+ _DEBUG_INFO("SEC TYPE : USERNETWPIN");
+
+ int res = 0;
+ if (is_initial != 0) {
+ res = launch_oma_dm_cp_ui(2, ext_id);
+ if (res < 0) {
+ _DEBUG_INFO("launch_oma_dm_cp_ui() fail !!");
+ ret = CP_ERROR_FAIL;
+ } else {
+ _DEBUG_INFO("launch_oma_dm_cp_ui() success !!");
+ }
+
+ goto return_part;
+ } else {
+ /* USERNETWPIN checking logic */
+ int net_temp_len = 0;
+ char *net_temp = 0;
+ net_temp = _get_netpin_key(&net_temp_len);
+ if (net_temp == NULL) {
+ ret = CP_ERROR_FAIL;
+ _DEBUG_INFO("__get_NetPIN_key() failed !!");
+ goto return_part;
+ }
+
+ for (i = 0; i < net_temp_len; i++) {
+ _DEBUG_INFO("net_temp[%d] : 0x%02X", i, net_temp[i]);
+ }
+
+ int user_data_len = strlen(user_data);
+ char *temp_user_data = (char *)calloc(user_data_len, sizeof(char));
+ if (temp_user_data == NULL) {
+ _DEBUG_INFO("calloc failed !!");
+
+ if (net_temp != NULL)
+ free(net_temp);
+ ret = CP_ERROR_FAIL;
+ goto return_part;
+ }
+
+ strncpy(temp_user_data, user_data, user_data_len);
+ _DEBUG_INFO("temp user data : %s", temp_user_data);
+
+ key_len = net_temp_len + user_data_len;
+ _DEBUG_INFO("key length : %d", key_len);
+
+ key = (char *)calloc(key_len, sizeof(char));
+ if (key == NULL) {
+ _DEBUG_INFO("calloc failed !!");
+ ret = CP_ERROR_FAIL;
+ goto return_part;
+ }
+ memcpy(key, net_temp, net_temp_len);
+ memcpy(key + net_temp_len, temp_user_data, user_data_len);
+
+ for (i = 0; i < key_len; i++) {
+ _DEBUG_INFO("key[%d] : 0x%02X", i, key[i]);
+ }
+
+ if (net_temp != NULL)
+ free(net_temp);
+
+ if (temp_user_data != NULL)
+ free(temp_user_data);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ _DEBUG_INFO("start PIN checking logic !!");
+
+ unsigned char *hmac = sync_agent_encrypt_cryptograhic_hash_with_flags(SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_SHA1,
+ wbxml_body, wbxml_size,
+ key, key_len,
+ SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUN_HMAC);
+
+ *is_correct = 1;
+
+ i = 0;
+ for (; i < 20; i++) {
+ char compare[3] = { 0, };
+ char *mac_cursor = mac + (i * 2);
+ strncpy(compare, mac_cursor, 2);
+ _DEBUG_INFO("hmac[%d] : %02X \t mac[%d, %d] : %s", i, hmac[i], i * 2, i * 2 + 1, compare);
+ }
+
+ i = 0;
+ for (; i < 20; i++) {
+ char data[3] = { 0, };
+ snprintf(data, 3, "%02X", hmac[i]);
+
+ char compare[3] = { 0, };
+ char *mac_cursor = mac + (i * 2);
+ strncpy(compare, mac_cursor, 2);
+
+ _DEBUG_INFO("data : %s, compare : %s ( cnt : %d )", data, compare, i);
+
+ if (strcasecmp(data, compare) != 0) {
+ _DEBUG_INFO("failed to compare data !!");
+ *is_correct = 0;
+ break;
+ }
+ }
+
+ _DEBUG_INFO("end PIN checking logic !!");
+
+ return_part:
+ if (key != NULL)
+ free(key);
+
+ sync_agent_free_file(&cp_pin_info);
+
+ if (wbxml_body != NULL)
+ sync_agent_free_file(&wbxml_body);
+
+ _DEBUG_INFO("End !!");
+
+ return ret;
+}
+
+CP_ERROR process_Invalid_Pincode(int ext_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ CP_ERROR ret = CP_ERROR_SUCCESS;
+
+ /*
+ * 1. delete CP data
+ */
+ ret = process_Delete_CP_Data(ext_id);
+ if (ret != CP_ERROR_SUCCESS) {
+ _DEBUG_INFO("process_Delete_CP_Data() fail !!");
+ /* todo : exception handling */
+ } else {
+ _DEBUG_INFO("process_Delete_CP_Data() success !!");
+ }
+
+ /*
+ * 2. send remove message to MF
+ */
+ if (g_msgId != -1) {
+ ret = __send_msg2mf(REMOVE_MESSAGE, NULL);
+ }
+
+ _DEBUG_INFO("End !!");
+
+ return ret;
+}
+
+CP_ERROR process_Setting_CP(int ext_id)
+{
+ _DEBUG_INFO("Start !!");
+
+ CP_ERROR ret = CP_ERROR_SUCCESS;
+
+ unsigned long size_return = 0;
+
+ CP_TYPE cp_type = CP_TYPE_WBXML;
+
+ char type_file_name[50] = { 0, };
+ snprintf(type_file_name, sizeof(type_file_name), "%s/%d/%s", CP_DATA_REPOSITORY_PATH, ext_id, CP_TYPE_FILE_NAME);
+ _DEBUG_INFO("type file name : %s", type_file_name);
+
+ char *type = 0;
+// int read_ret = sync_agent_read_whole_file(CP_TYPE_REPOSITORY_PATH, &type, &size_return);
+ int read_ret = sync_agent_read_whole_file(type_file_name, &type, &size_return);
+ if (read_ret == 0) {
+ _DEBUG_INFO("Failed to sync_agent_read_file() : %s", type_file_name);
+ return CP_ERROR_FAIL;
+ }
+
+ if (strcmp("1", type) == 0) {
+ cp_type = CP_TYPE_XML;
+ } else if (strcmp("2", type) == 0) {
+ cp_type = CP_TYPE_WBXML;
+ } else {
+ cp_type = CP_TYPE_NONE;
+ }
+
+ char wbxml_file_name[50] = { 0, };
+ snprintf(wbxml_file_name, sizeof(wbxml_file_name), "%s/%d/%s", CP_DATA_REPOSITORY_PATH, ext_id, CP_WBXML_FILE_NAME);
+ _DEBUG_INFO("wbxml file name : %s", wbxml_file_name);
+
+ char *cp_body = 0;
+// read_ret = sync_agent_read_whole_file(CP_WBXML_REPOSITORY_PATH, &cp_body, &size_return);
+ read_ret = sync_agent_read_whole_file(wbxml_file_name, &cp_body, &size_return);
+ if (read_ret == 0) {
+ _DEBUG_INFO("Failed to sync_agent_read_file() : %s", wbxml_file_name);
+ return CP_ERROR_FAIL;
+ }
+// /*
+// * Parse recieved CP to sturct DM_CP
+// */
+// dm_cp = parsing_cp_stream(cp_type, cp_body, size_return);
+
+ GList *iter = NULL;
+ DM_CP *dm_cp;
+ for (iter = dm_cp_list; iter != 0; iter = g_list_next(iter)) {
+ dm_cp = 0;
+ if (iter->data != 0) {
+ if (((CP_Data *) (iter->data))->ext_id == ext_id) {
+ dm_cp = ((CP_Data *) (iter->data))->dm_cp;
+ break;
+ }
+ }
+ }
+
+ if (dm_cp != 0) {
+ /* checking app id for multiple app's */
+ if (dm_cp->applications->app_ID != NULL) {
+ if (strcmp(dm_cp->applications->app_ID, "w2") == 0) {
+ _DEBUG_INFO("app id : %s", W2);
+ /*
+ * todo
+ * ret = __process_Setting_Browser(dm_cp);
+ */
+ } else if (strcmp(dm_cp->applications->app_ID, "w4") == 0) {
+ _DEBUG_INFO("app id : %s", W4);
+ /*
+ * todo
+ * ret = __process_Setting_MMS(dm_cp);
+ */
+ } else if (strcmp(dm_cp->applications->app_ID, "w5") == 0) {
+ _DEBUG_INFO("app id : %s", W5);
+ ret = _process_setting_oma_ds(dm_cp);
+ if (ret != CP_ERROR_SUCCESS) {
+ _DEBUG_INFO("__process_Setting_OMA_DS() failed !!");
+ return CP_ERROR_FAIL;
+ } else {
+ _DEBUG_INFO("__process_Setting_OMA_DS() success !!");
+ }
+ } else if (strcmp(dm_cp->applications->app_ID, "w7") == 0) {
+ _DEBUG_INFO("app id : %s", W7);
+ ret = _process_setting_oma_dm(dm_cp);
+ if (ret != CP_ERROR_SUCCESS) {
+ _DEBUG_INFO("__process_Setting_OMA_DM() failed !!");
+ return CP_ERROR_FAIL;
+ } else {
+ _DEBUG_INFO("__process_Setting_OMA_DM() success !!");
+ }
+ } else if (strcmp(dm_cp->applications->app_ID, "wA") == 0) {
+ _DEBUG_INFO("app id : %s", WA);
+ /*
+ * todo
+ * ret = __process_Setting_IM_N_PS(dm_cp);
+ */
+ } else {
+ _DEBUG_INFO("app id : undefined !!");
+ }
+ }
+ } else {
+ _DEBUG_INFO("not exist 'CP_Data' for ext_id : %d", ext_id);
+ return CP_ERROR_FAIL;
+ }
+
+ _DEBUG_INFO("End !!");
+
+ return ret;
+}
+
+CP_ERROR process_Delete_All_CP_Data()
+{
+ _DEBUG_INFO("Start !!");
+
+ CP_ERROR ret = CP_ERROR_SUCCESS;
+
+ /* delete registered all CP data */
+ GList *iter = NULL;
+ for (iter = dm_cp_list; iter != 0;) {
+ if (iter->data != 0) {
+ CP_Data *temp = (CP_Data *) (iter->data);
+ char folder_name[50] = { 0, };
+ snprintf(folder_name, sizeof(folder_name), "%s/%d", CP_DATA_REPOSITORY_PATH, ((CP_Data *) (iter->data))->ext_id);
+ _DEBUG_INFO("folder name : %s", folder_name);
+
+ int file_ret = sync_agent_delete_directory(folder_name, TRUE);
+ if (file_ret != 1) {
+ _DEBUG_INFO("sync_agent_delete_directory( folder : %s ) failed !!", folder_name);
+ return CP_ERROR_FAIL;
+ }
+
+ dm_cp_list = g_list_remove(dm_cp_list, iter->data);
+ iter = g_list_next(iter);
+
+ if (temp->dm_cp != 0)
+ free(temp->dm_cp);
+ free(temp);
+ }
+ }
+
+ if (g_list_length(dm_cp_list) == 0) {
+ _DEBUG_INFO("dm_cp_list length : 0 !!");
+ g_list_free(dm_cp_list);
+ dm_cp_list = NULL;
+ }
+
+ _DEBUG_INFO("End !!");
+
+ return ret;
+}
+
+CP_ERROR process_Delete_CP_Data(int ext_id)
+{
+ _DEBUG_INFO("Start !!");
+
+ CP_ERROR ret = CP_ERROR_SUCCESS;
+
+ GList *iter = NULL;
+ CP_Data *temp = 0;
+ for (iter = dm_cp_list; iter != 0; iter = g_list_next(iter)) {
+ if (iter->data != 0) {
+ if (((CP_Data *) (iter->data))->ext_id == ext_id) {
+ temp = (CP_Data *) (iter->data);
+ dm_cp_list = g_list_remove(dm_cp_list, iter->data);
+ if (temp->dm_cp != 0)
+ free(temp->dm_cp);
+ free(temp);
+ break;
+ }
+ }
+ }
+
+ if (g_list_length(dm_cp_list) == 0) {
+ g_list_free(dm_cp_list);
+ dm_cp_list = NULL;
+ }
+
+ char folder_name[50] = { 0, };
+ snprintf(folder_name, sizeof(folder_name), "%s/%d", CP_DATA_REPOSITORY_PATH, ext_id);
+ _DEBUG_INFO("folder name : %s", folder_name);
+
+ int file_ret = sync_agent_delete_directory(folder_name, TRUE);
+ if (file_ret != 1) {
+ _DEBUG_INFO("sync_agent_delete_directory( folder : %s ) failed !!", folder_name);
+ return CP_ERROR_FAIL;
+ }
+
+ _DEBUG_INFO("End !!");
+
+ return ret;
+}
+
+void process_Set_msgId(int msgId)
+{
+ _DEBUG_INFO("Start !!");
+
+ g_msgId = msgId;
+ _DEBUG_INFO("g_msgId : %d", g_msgId);
+
+ _DEBUG_INFO("End !!");
+}
+
+/**************************** Impl static function *************************/
+
+static CP_ERROR _process_receieved_cp_stream(CP_TYPE cp_type, const char *msgBody, unsigned int msgSize, int ext_id)
+{
+ _INNER_FUNC_ENTER;
+ CP_ERROR ret = CP_ERROR_SUCCESS;
+
+ retvm_if((msgBody) == NULL, CP_ERROR_FAIL, "msgBody is NULL!!");
+
+ char type[1];
+ if (cp_type == CP_TYPE_XML) {
+ type[0] = '1';
+ } else if (cp_type == CP_TYPE_WBXML) {
+ type[0] = '2';
+ }
+
+ char type_file_name[50] = { 0, };
+ snprintf(type_file_name, sizeof(type_file_name), "%s/%d/%s", CP_DATA_REPOSITORY_PATH, ext_id, CP_TYPE_FILE_NAME);
+ _DEBUG_TRACE("type file name : %s", type_file_name);
+
+// int file_ret = sync_agent_write_file(CP_TYPE_REPOSITORY_PATH, type, 1, 1, 1);
+// int file_ret = sync_agent_write_whole_file(CP_TYPE_REPOSITORY_PATH, type, 1, 1);
+ int file_ret = sync_agent_write_whole_file(type_file_name, type, 1, 1);
+ if (file_ret != 1) {
+ _DEBUG_TRACE("Failed to repository CP Type");
+ _INNER_FUNC_EXIT;
+ return CP_ERROR_FAIL;
+ }
+
+ /*
+ * 3. Registry (DM_CP) to storage
+ */
+ char wbxml_file_name[50] = { 0, };
+ snprintf(wbxml_file_name, sizeof(wbxml_file_name), "%s/%d/%s", CP_DATA_REPOSITORY_PATH, ext_id, CP_WBXML_FILE_NAME);
+ _DEBUG_TRACE("wbxml file name : %s", wbxml_file_name);
+// file_ret = sync_agent_write_file(CP_WBXML_REPOSITORY_PATH, msgBody, msgSize, 1, 1);
+// file_ret = sync_agent_write_whole_file(CP_WBXML_REPOSITORY_PATH, msgBody, msgSize, 1);
+ file_ret = sync_agent_write_whole_file(wbxml_file_name, msgBody, msgSize, 1);
+ if (file_ret != 1) {
+ _DEBUG_TRACE("Failed to repository CP Body");
+ _INNER_FUNC_EXIT;
+ return CP_ERROR_FAIL;
+ }
+
+ /*
+ * 3. Handling Overwrite
+ */
+ CP_Data *dm_cp_data = (CP_Data *) calloc(1, sizeof(CP_Data));
+ if (dm_cp_data == NULL) {
+ _DEBUG_TRACE("CP_Data calloc failed !!");
+ _INNER_FUNC_EXIT;
+ return CP_ERROR_FAIL;
+ }
+
+ dm_cp_data->ext_id = ext_id;
+ /*
+ * Parse recieved CP to sturct DM_CP
+ */
+// dm_cp = parsing_cp_stream(cp_type, msgBody, msgSize);
+// if (dm_cp == 0) {
+// _DEBUG_TRACE("parsing_cp_stream() failed !!");
+// /* todo : exception handling */
+// return CP_ERROR_FAIL;
+// }
+
+ dm_cp_data->dm_cp = parsing_cp_stream(cp_type, msgBody, msgSize);
+ if (dm_cp_data->dm_cp == 0) {
+ _DEBUG_TRACE("parsing_cp_stream() failed !!");
+ /* todo : exception handling */
+ _INNER_FUNC_EXIT;
+ return CP_ERROR_FAIL;
+ }
+
+ dm_cp_list = g_list_append(dm_cp_list, dm_cp_data);
+
+ /*
+ * 4. Interact Msg F/W
+ */
+ // create message
+ pmci_san_message_s *send_msg = (pmci_san_message_s *) calloc(1, sizeof(pmci_san_message_s));
+ if (send_msg == NULL) {
+ _DEBUG_TRACE("calloc fail !!");
+ _INNER_FUNC_EXIT;
+ return CP_ERROR_FAIL;
+ }
+
+ send_msg->ext_id = ext_id;
+// send_msg->ext_id = 11; // ?? : temp setting value? unique management (id_provider available?) todo??
+// send_msg->pin_code = pin_code; // PIN code
+// char *msgData = "SYNCML";
+ char *msgData = NULL;
+ msgData = (char *)calloc(MSG_SIZE, sizeof(char));
+
+ if (msgData == NULL) {
+ _DEBUG_TRACE("calloc failed !!");
+ _INNER_FUNC_EXIT;
+ return CP_ERROR_FAIL;
+ }
+
+ int err = __make_view_message(&msgData, dm_cp_data->dm_cp);
+ if (err != 1) {
+ _DEBUG_TRACE("__make_view_message() failed !!");
+
+ if (msgData != NULL)
+ free(msgData);
+
+ _INNER_FUNC_EXIT;
+ return CP_ERROR_FAIL;
+ } else {
+
+ _DEBUG_TRACE("__make_view_message() success !!");
+ _DEBUG_TRACE("msgData : %s", msgData);
+ }
+
+// char *msgData = "Configuration message \n Application : Browser \n Proxy : wap_proxy \n Port : 9201 \n Received date : 17/04/2012";
+ if (msgData != NULL)
+ send_msg->msg_data = strdup(msgData); // message that will be sent to MF
+
+ ret = __send_msg2mf(ADD_MESSAGE, (void *)send_msg);
+ if (ret != CP_ERROR_SUCCESS) {
+ _DEBUG_TRACE("__sendMsg2MF() failed !!");
+ } else {
+ _DEBUG_TRACE("__sendMsg2MF() success !!");
+ }
+
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static CP_ERROR __send_msg2mf(SENDMSG_TYPE send_type, void *send_msg)
+{
+ _INNER_FUNC_ENTER;
+
+ CP_ERROR res = CP_ERROR_SUCCESS;
+ sync_agent_pm_return_e err_sendMsg = SYNC_AGENT_PM_SUCCESS;
+
+ switch (send_type) {
+ case ADD_MESSAGE:
+ {
+ int out_add_item_id = 0; // meaningless value
+
+ /* send message (add) */
+ err_sendMsg = sync_agent_add_service_data(6, (void *)send_msg, &out_add_item_id);
+ if (err_sendMsg != SYNC_AGENT_PM_SUCCESS) {
+ _DEBUG_VERBOSE("send msg ( ADD_MESSAGE ) to MF fail !!");
+ res = CP_ERROR_FAIL;
+ goto return_part;
+ /* todo : exception handling */
+ } else {
+ _DEBUG_VERBOSE("send msg ( ADD_MESSAGE ) to MF success !!");
+ }
+ _DEBUG_VERBOSE("---------------------------------------");
+ _DEBUG_VERBOSE("OUT ADD ITEM %d", out_add_item_id);
+ _DEBUG_VERBOSE("---------------------------------------");
+ }
+ break;
+ case REMOVE_MESSAGE:
+ {
+ /* send message (remove) */
+ err_sendMsg = sync_agent_remove_service_data(6, g_msgId);
+ if (err_sendMsg != SYNC_AGENT_PM_SUCCESS) {
+ _DEBUG_VERBOSE("send msg ( REMOVE_MESSAGE ) to MF fail !!");
+ res = CP_ERROR_FAIL;
+ goto return_part;
+ /* todo : exception handling */
+ } else {
+ _DEBUG_VERBOSE("send msg ( REMOVE_MESSAGE ) to MF success !!");
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ return_part:
+ if (send_msg != NULL) {
+ if (((pmci_san_message_s *) send_msg)->msg_data != NULL)
+ free(((pmci_san_message_s *) send_msg)->msg_data);
+ free(send_msg);
+ }
+
+ _INNER_FUNC_EXIT;
+ return res;
+}
+
+static CP_ERROR _process_setting_oma_ds(DM_CP * dm_cp)
+{
+ _INNER_FUNC_ENTER;
+ CP_ERROR ret = CP_ERROR_SUCCESS;
+
+ retvm_if((dm_cp) == NULL, CP_ERROR_FAIL, "dm_cp is NULL!!");
+
+ int event_type = 8;
+ /*sync_agent_event_error_e error; */
+
+ sync_agent_event_data_s *event = sync_agent_create_event(event_type);
+ if (event == NULL) {
+ _DEBUG_TRACE("event is NULL");
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+
+ DM_CP_Application *cp_application = dm_cp->applications;
+
+ _DEBUG_TRACE("cp_application->name : %s", cp_application->name);
+ sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_application->name); /* profileName */
+
+ String_Node *addr = cp_application->addr;
+ if (addr != NULL) {
+ _DEBUG_TRACE("cp_application->addr : %s", addr->data);
+ sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, addr->data); /* addr */
+ } else {
+ sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, ""); /* addr */
+ }
+
+ DM_CP_Application_AppAuth *cp_auth = cp_application->appAuth;
+ if (cp_auth != NULL) {
+ sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_auth->auth_name); /* id */
+ _DEBUG_TRACE("cp_application->auth_name : %s", cp_auth->auth_name);
+ sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_auth->auth_secret); /* password */
+ _DEBUG_TRACE("cp_application->auth_secret : %s", cp_auth->auth_secret);
+ } else {
+ sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, ""); /* id */
+ sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, ""); /* password */
+ }
+
+ int categoryCount = 0;
+ DM_CP_Application_Resource *cp_resource = cp_application->resource;
+ while (cp_resource != 0) {
+ categoryCount++;
+ cp_resource = cp_resource->next;
+ }
+ sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &categoryCount); /* categoryCount */
+
+ cp_resource = cp_application->resource;
+
+ while (cp_resource != 0) {
+ sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_resource->name); /* name */
+ sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_resource->accept); /* accept */
+ sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_resource->auth_name); /* id */
+ sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_resource->auth_secret); /* password */
+ sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_resource->auth_type); /* auth_type */
+ sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, cp_resource->auth_data); /* auth_data */
+
+ cp_resource = cp_resource->next;
+ }
+
+ /*
+ * IPC ( send msg to OMA DS Agent )
+ * Below rutine is made by Hard Coding?! If that, So Terrible.. I should consider this situation. - RJW
+ */
+
+ int client_len;
+ int client_sockfd;
+ struct sockaddr_un clientaddr;
+
+ client_sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (client_sockfd == -1) {
+ _DEBUG_TRACE("socket create Error!!");
+ sync_agent_free_event(event);
+ _INNER_FUNC_EXIT;
+ return CP_ERROR_FAIL;
+ }
+
+ bzero(&clientaddr, sizeof(clientaddr));
+ clientaddr.sun_family = AF_UNIX;
+
+ int str_len = 0;
+
+ str_len = g_strlcpy(clientaddr.sun_path, IPC_DS, (int)sizeof(clientaddr.sun_path));
+ if (str_len >= sizeof(clientaddr.sun_path)) {
+ _DEBUG_TRACE("buffer overflow");
+ sync_agent_free_event(event);
+ close(client_sockfd);
+ _INNER_FUNC_EXIT;
+ return CP_ERROR_FAIL;
+ }
+ client_len = sizeof(clientaddr);
+
+ if (connect(client_sockfd, (struct sockaddr *)&clientaddr, client_len) < 0) {
+ _DEBUG_TRACE("socket connect error");
+ sync_agent_free_event(event);
+ close(client_sockfd);
+ _INNER_FUNC_EXIT;
+ return CP_ERROR_FAIL;
+ }
+
+ int send_data_size = (event->data - event->size) + 1;
+ int write_ret = write(client_sockfd, (void *)(event->size), send_data_size);
+ _DEBUG_TRACE("write ret : %d", write_ret);
+ close(client_sockfd);
+ sync_agent_free_event(event);
+
+ _INNER_FUNC_EXIT;
+
+ return ret;
+}
+
+static CP_ERROR _process_setting_oma_dm(DM_CP * dm_cp)
+{
+ _INNER_FUNC_ENTER;
+
+ CP_ERROR ret = CP_ERROR_SUCCESS;
+ DM_ERROR dm_ret = DM_OK;
+
+ retvm_if((dm_cp) == NULL, CP_ERROR_FAIL, "dm_cp is NULL!!");
+
+ DM_CP_Application *applications = dm_cp->applications;
+ dm_acc *dmaccount = NULL;
+ if (applications != NULL) {
+ if (applications->provider_ID != NULL) {
+ dmaccount = (dm_acc *) calloc(1, sizeof(dm_acc));
+ if (dmaccount == NULL) {
+ _DEBUG_TRACE("alloc fail");
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+ char *server_id = NULL;
+ server_id = strdup(applications->provider_ID);
+ /*get_Serverid(SAMSUNG_FUMO_TYPE , &server_id); */
+ _DEBUG_TRACE("server id : %s", server_id);
+
+ dmaccount->server_id = strdup(applications->provider_ID);
+ _DEBUG_TRACE("server id : %s", dmaccount->server_id);
+
+ if (applications->addr != NULL) {
+ dmaccount->server_url = strdup(applications->addr->data);
+ _DEBUG_TRACE("server url : %s", dmaccount->server_url);
+ }
+
+ DM_CP_Application_AppAuth *appAuth = applications->appAuth;
+
+ if (appAuth != NULL) {
+ while (1) {
+ if (appAuth->auth_level != NULL) {
+ if (strcmp("APPSRV", appAuth->auth_level) == 0) {
+ if (appAuth->auth_secret != NULL) {
+ dmaccount->server_pw = strdup(appAuth->auth_secret);
+ _DEBUG_TRACE("server_pw : %s", dmaccount->server_pw);
+ }
+ if (appAuth->auth_type != NULL) {
+ if (strstr(appAuth->auth_type, "DIGEST") != NULL) {
+ dmaccount->server_auth_type = strdup("DIGEST");
+ _DEBUG_TRACE("server_auth_type : %s", dmaccount->server_auth_type);
+ } else if (strstr(appAuth->auth_type, "HMAC") != NULL) {
+ dmaccount->server_auth_type = strdup("HMAC");
+ _DEBUG_TRACE("server_auth_type : %s", dmaccount->server_auth_type);
+ } else if (strstr(appAuth->auth_type, "BASIC") != NULL) {
+ dmaccount->server_auth_type = strdup("BASIC");
+ _DEBUG_TRACE("server_auth_type : %s", dmaccount->server_auth_type);
+ } else {
+ _DEBUG_TRACE("server_auth_type: %s", appAuth->auth_type);
+ dmaccount->server_auth_type = strdup("DIGEST");
+ _DEBUG_TRACE("server_nextNonce : %s", dmaccount->server_auth_type);
+ }
+ } else if (appAuth->auth_type == NULL && dmaccount->server_auth_type == NULL) {
+ dmaccount->server_auth_type = strdup("DIGEST");
+ _DEBUG_TRACE("user_auth_type : %s", dmaccount->server_auth_type);
+ }
+
+ if (appAuth->auth_data != NULL) {
+ dmaccount->server_nextNonce = strdup(appAuth->auth_data);
+ _DEBUG_TRACE("server_nextNonce : %s", dmaccount->server_nextNonce);
+ }
+ } else if (!strcmp("CLIENT", appAuth->auth_level)) {
+ if (appAuth->auth_secret != NULL) {
+ dmaccount->user_pw = strdup(appAuth->auth_secret);
+ _DEBUG_TRACE("user_pw : %s", dmaccount->user_pw);
+ }
+
+ if (appAuth->auth_type != NULL) {
+ if (strstr(appAuth->auth_type, "DIGEST") != NULL) {
+ dmaccount->user_auth_type = strdup("DIGEST");
+ _DEBUG_TRACE("user_auth_type : %s", dmaccount->user_auth_type);
+ } else if (strstr(appAuth->auth_type, "HMAC") != NULL) {
+ dmaccount->user_auth_type = strdup("HMAC");
+ _DEBUG_TRACE("user_auth_type : %s", dmaccount->user_auth_type);
+ } else if (strstr(appAuth->auth_type, "BASIC") != NULL) {
+ dmaccount->user_auth_type = strdup("BASIC");
+ _DEBUG_TRACE("user_auth_type : %s", dmaccount->user_auth_type);
+ } else {
+ _DEBUG_TRACE("user_auth_type : %s", appAuth->auth_type);
+ dmaccount->user_auth_type = strdup("DIGEST");
+ _DEBUG_TRACE("user_auth_type : %s", dmaccount->user_auth_type);
+ }
+ } else if (appAuth->auth_type == NULL && dmaccount->user_auth_type == NULL) {
+ dmaccount->user_auth_type = strdup("DIGEST");
+ _DEBUG_TRACE("user_auth_type : %s", dmaccount->user_auth_type);
+ }
+
+ if (appAuth->auth_name != NULL) {
+ dmaccount->user_id = strdup(appAuth->auth_name);
+ _DEBUG_TRACE("user_id : %s", dmaccount->user_id);
+ }
+ if (appAuth->auth_data != NULL) {
+ dmaccount->user_nextNonce = strdup(appAuth->auth_data);
+ _DEBUG_TRACE("user_auth_type: %s", dmaccount->user_nextNonce);
+ }
+ }
+ } else {
+ ret = CP_ERROR_FAIL;
+ free_dm_acc(dmaccount);
+ goto error;
+ }
+
+ if (appAuth->next != NULL) {
+ appAuth = appAuth->next;
+ } else {
+ break;
+ }
+ }
+ }
+
+ if (server_id != NULL) {
+ int is_exist = 0;
+ SERVICE_SERVER_TYPE dmacc_type = NO_ENGINE_TYPE;
+
+ dmacc_type = get_engine_type_by_serverid(server_id);
+ _DEBUG_TRACE(" dm acc type : %d", dmacc_type);
+
+ if (dmacc_type != NO_ENGINE_TYPE) {
+ dm_ret = is_exist_dmacc(dmacc_type, &is_exist);
+ if (dm_ret != DM_OK) {
+ _DEBUG_TRACE("error is exist dm acc ");
+ ret = CP_ERROR_FAIL;
+ goto error;
+ }
+
+ if (is_exist == 1) {
+ _DEBUG_TRACE("exist dm acc ");
+ ret = update_dmacc(server_id, dmaccount);
+ _DEBUG_TRACE("update dm acc %d", ret);
+ if (ret == 1) {
+ first_server_bootstrap(server_id);
+ ret = CP_ERROR_SUCCESS;
+ } else {
+ ret = CP_ERROR_FAIL;
+ goto error;
+ }
+ } else {
+ _DEBUG_TRACE("not exist dm acc ");
+ ret = CP_ERROR_FAIL;
+ }
+ } else {
+ _DEBUG_TRACE("dmacc type is none");
+ ret = CP_ERROR_FAIL;
+ }
+ } else {
+ _DEBUG_TRACE("server id is null");
+ ret = CP_ERROR_FAIL;
+ }
+
+ _DEBUG_TRACE("update dm acc : %d", ret);
+ free_dm_acc(dmaccount);
+ }
+ } else {
+ ret = CP_ERROR_FAIL;
+ goto error;
+ }
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_TRACE("error : %d", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+
+}
+
+static char __char2hex(char ch)
+{
+ _INNER_FUNC_ENTER;
+
+ char ret = 0x00;
+ switch (ch) {
+ case '0':
+ ret = 0x00;
+ break;
+ case '1':
+ ret = 0x01;
+ break;
+ case '2':
+ ret = 0x02;
+ break;
+ case '3':
+ ret = 0x03;
+ break;
+ case '4':
+ ret = 0x04;
+ break;
+ case '5':
+ ret = 0x05;
+ break;
+ case '6':
+ ret = 0x06;
+ break;
+ case '7':
+ ret = 0x07;
+ break;
+ case '8':
+ ret = 0x08;
+ break;
+ case '9':
+ ret = 0x09;
+ break;
+ default:
+ break;
+ }
+
+ _DEBUG_VERBOSE("ch : %c ( 0x%02X )", ch, ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static char *_get_netpin_key(int *key_len)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_dev_return_e err = SYNC_AGENT_DEV_RETURN_SUCCESS;
+ char *imsi_value = 0;
+ char *trans_imsi_value = 0;
+ int imsi_len = 0;
+
+// char key[8] = {0, };
+ char *key = NULL;
+ char temp1, temp2;
+ int i = 0;
+
+ int flag = 0;
+
+ err = sync_agent_get_devinfo(2, "IMSI", &imsi_value);
+ if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ _DEBUG_TRACE("imsi value is error !!");
+ goto return_part;
+ } else {
+ flag = 1;
+ _DEBUG_TRACE("sync_agent_get_devinfo( IMSI ) success !!");
+ }
+
+ _DEBUG_TRACE("IMSI value : %s", imsi_value);
+ int len = 0;
+
+ imsi_len = strlen(imsi_value);
+ if ((imsi_len % 2) == 1) {
+ imsi_len += 2;
+ trans_imsi_value = (char *)calloc(imsi_len, sizeof(char));
+
+ if (trans_imsi_value == NULL) {
+ _DEBUG_TRACE("calloc failed !!");
+ goto return_part;
+ }
+
+ len = g_strlcat(trans_imsi_value, "9", imsi_len);
+ len = g_strlcat(trans_imsi_value, imsi_value, imsi_len);
+
+ if (len >= imsi_len) {
+ _DEBUG_TRACE(" buffer overflow !!");
+ /* todo : exception handling */
+ }
+
+ } else {
+ imsi_len += 3;
+ trans_imsi_value = (char *)calloc(imsi_len, sizeof(char));
+
+ if (trans_imsi_value == NULL) {
+ _DEBUG_TRACE("calloc failed !!");
+ goto return_part;
+ }
+
+ len = g_strlcat(trans_imsi_value, "1", imsi_len);
+ len = g_strlcat(trans_imsi_value, imsi_value, imsi_len);
+ len = g_strlcat(trans_imsi_value, "F", imsi_len);
+
+ if (len >= imsi_len) {
+ _DEBUG_TRACE(" buffer overflow !!");
+ /* todo : exception handling */
+ }
+
+ }
+
+ *key_len = imsi_len / 2;
+ _DEBUG_TRACE("imsi value len : %d", *key_len);
+
+ key = (char *)calloc(*key_len, sizeof(char));
+ if (key == NULL) {
+ _DEBUG_TRACE("calloc failed !!");
+ goto return_part;
+ }
+
+ for (; i < *key_len; i++) {
+ temp1 = __char2hex(trans_imsi_value[i * 2 + 1]);
+ temp2 = __char2hex(trans_imsi_value[i * 2]);
+ key[i] = (temp1 << 4) | temp2;
+ temp1 = 0;
+ temp2 = 0;
+ _DEBUG_TRACE("key[%d] : 0x%02X", i, key[i]);
+ }
+
+ return_part:
+ if ((imsi_value != NULL) && (flag == 1))
+ free(imsi_value);
+
+ if (trans_imsi_value != NULL)
+ free(trans_imsi_value);
+
+ _INNER_FUNC_EXIT;
+ return key;
+}
+
+static int __make_view_message(char **msgData, DM_CP * dm_cp)
+{
+ _INNER_FUNC_ENTER;
+
+ int res = 1;
+ int len = 0;
+
+ /* Application */
+ retvm_if((dm_cp) == NULL, 0, "dm_cp is NULL!!");
+
+ len = g_strlcat(*msgData, APPLICATION, MSG_SIZE);
+ if (dm_cp->applications->app_ID != NULL) {
+ if (dm_cp->applications->name != NULL) {
+ _DEBUG_VERBOSE("name : %s", dm_cp->applications->name);
+
+ len = g_strlcat(*msgData, dm_cp->applications->name, MSG_SIZE);
+ }
+
+ len = g_strlcat(*msgData, L_BRACKET, MSG_SIZE);
+ if (strcmp(dm_cp->applications->app_ID, "w2") == 0) {
+ _DEBUG_VERBOSE("app id : %s", W2);
+
+ len = g_strlcat(*msgData, W2, MSG_SIZE);
+ } else if (strcmp(dm_cp->applications->app_ID, "w4") == 0) {
+ _DEBUG_VERBOSE("app id : %s", W4);
+
+ len = g_strlcat(*msgData, W4, MSG_SIZE);
+ } else if (strcmp(dm_cp->applications->app_ID, "w5") == 0) {
+ _DEBUG_VERBOSE("app id : %s", W5);
+
+ len = g_strlcat(*msgData, W5, MSG_SIZE);
+ } else if (strcmp(dm_cp->applications->app_ID, "w7") == 0) {
+ _DEBUG_VERBOSE("app id : %s", W7);
+
+ len = g_strlcat(*msgData, W7, MSG_SIZE);
+ } else if (strcmp(dm_cp->applications->app_ID, "wA") == 0) {
+ _DEBUG_VERBOSE("app id : %s", WA);
+
+ len = g_strlcat(*msgData, WA, MSG_SIZE);
+ } else {
+ _DEBUG_VERBOSE("app id : undefined !!");
+ len = g_strlcat(*msgData, "Undefined ", MSG_SIZE);
+ }
+
+ len = g_strlcat(*msgData, R_BRACKET, MSG_SIZE);
+ } else {
+ _DEBUG_VERBOSE("Application ID is not existed - Invalid format !!");
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+
+ len = g_strlcat(*msgData, LB, MSG_SIZE);
+// _DEBUG_VERBOSE("msg data : %s", *msgData);
+
+ /* URL */
+
+ len = g_strlcat(*msgData, URL, MSG_SIZE);
+ if (dm_cp->applications->addr != NULL) {
+ if (dm_cp->applications->addr->data != NULL) {
+ _DEBUG_VERBOSE("url : %s", dm_cp->applications->addr->data);
+
+ len = g_strlcat(*msgData, dm_cp->applications->addr->data, MSG_SIZE);
+ } else {
+
+ len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
+ }
+ } else {
+
+ len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
+
+ }
+
+ len = g_strlcat(*msgData, LB, MSG_SIZE);
+// _DEBUG_VERBOSE("msg data : %s", *msgData);
+
+ /* NAP Addr type */
+ if (dm_cp->napdefs != NULL) {
+ if (dm_cp->napdefs->nap_addr_type != NULL) {
+ _DEBUG_VERBOSE("nap addr type : %s", dm_cp->napdefs->nap_addr_type);
+
+ len = g_strlcat(*msgData, dm_cp->napdefs->nap_addr_type, MSG_SIZE);
+ len = g_strlcat(*msgData, DELIMITER, MSG_SIZE);
+ if (dm_cp->napdefs->nap_address != NULL) {
+ _DEBUG_VERBOSE("nap addr : %s", dm_cp->napdefs->nap_address);
+ len = g_strlcat(*msgData, dm_cp->napdefs->nap_address, MSG_SIZE);
+
+ }
+ } else {
+
+ len = g_strlcat(*msgData, DEFAULT_NAP_TYPE, MSG_SIZE);
+ len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
+ }
+ } else {
+
+ len = g_strlcat(*msgData, DEFAULT_NAP_TYPE, MSG_SIZE);
+ len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
+ }
+
+ len = g_strlcat(*msgData, LB, MSG_SIZE);
+
+// _DEBUG_VERBOSE("msg data : %s", *msgData);
+
+ /* Proxy */
+
+ len = g_strlcat(*msgData, PROXY, MSG_SIZE);
+
+ if (dm_cp->applications->to_proxy != NULL) {
+ if (dm_cp->applications->to_proxy->data != NULL) {
+ _DEBUG_VERBOSE("proxy : %s", dm_cp->applications->to_proxy->data);
+
+ len = g_strlcat(*msgData, dm_cp->applications->to_proxy->data, MSG_SIZE);
+ } else {
+
+ len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
+
+ }
+ } else {
+
+ len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
+ }
+
+ len = g_strlcat(*msgData, LB, MSG_SIZE);
+// _DEBUG_VERBOSE("msg data : %s", *msgData);
+
+ /* Port */
+
+ len = g_strlcat(*msgData, PORT, MSG_SIZE);
+ if (dm_cp->pxLogical != NULL) {
+ if (dm_cp->pxLogical->port != NULL) {
+ if (dm_cp->pxLogical->port->portnbr != NULL) {
+ _DEBUG_VERBOSE("port : %s", dm_cp->pxLogical->port->portnbr);
+
+ len = g_strlcat(*msgData, dm_cp->pxLogical->port->portnbr, MSG_SIZE);
+ } else {
+
+ len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
+ }
+ } else {
+
+ len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
+ }
+ } else {
+
+ len = g_strlcat(*msgData, NO_DATA, MSG_SIZE);
+ }
+
+ len = g_strlcat(*msgData, LB, MSG_SIZE);
+// _DEBUG_VERBOSE("msg data : %s", *msgData);
+
+ if (len >= MSG_SIZE) {
+ _DEBUG_VERBOSE("over flow error");
+ res = -1;
+ }
+
+ _INNER_FUNC_EXIT;
+ return res;
+}
+
+void free_cp_application(DM_CP_Application * app)
+{
+ retm_if((app) == NULL, "dm_cp application is NULL!!");
+
+ if (app->accept != NULL) {
+ str_free(&(app->accept));
+ app->accept = NULL;
+ }
+ if (app->addr != NULL) {
+ free_string_node(app->addr);
+ app->addr = NULL;
+ }
+ if (app->appAddr != NULL) {
+ free_cp_application_app_addr(app->appAddr);
+ app->appAddr = NULL;
+ }
+ if (app->appAuth != NULL) {
+ free_cp_application_app_auth(app->appAuth);
+ app->appAuth = NULL;
+ }
+ if (app->app_ID != NULL) {
+ str_free(&(app->app_ID));
+ app->app_ID = NULL;
+ }
+ if (app->name != NULL) {
+ str_free(&(app->name));
+ app->name = NULL;
+ }
+ if (app->protocol != NULL) {
+ str_free(&(app->protocol));
+ app->protocol = NULL;
+ }
+ if (app->provider_ID != NULL) {
+ str_free(&(app->provider_ID));
+ app->provider_ID = NULL;
+ }
+ if (app->resource != NULL) {
+ free_cp_application_resource(app->resource);
+ app->resource = NULL;
+ }
+ if (app->to_napid != NULL) {
+ free_string_node(app->to_napid);
+ app->to_napid = NULL;
+ }
+ if (app->to_proxy != NULL) {
+ free_string_node(app->to_proxy);
+ app->to_proxy = NULL;
+ }
+ if (app->next != NULL) {
+ free_cp_application(app->next);
+ app->next = NULL;
+ }
+ free(app);
+ app = NULL;
+}
+
+void free_cp_application_app_addr(DM_CP_Application_AppAddr * app_addr)
+{
+ retm_if((app_addr) == NULL, "dm_cp is NULL!!");
+
+ if (app_addr->addr != NULL) {
+ str_free(&(app_addr->addr));
+ app_addr->addr = NULL;
+ }
+
+ if (app_addr->addr_type != NULL) {
+ str_free(&(app_addr->addr_type));
+ app_addr->addr_type = NULL;
+ }
+
+ if (app_addr->port != NULL) {
+ free_cp_port(app_addr->port);
+ app_addr->port = NULL;
+ }
+
+ if (app_addr->next != NULL) {
+ free_cp_application_app_addr(app_addr->next);
+ app_addr->next = NULL;
+ }
+
+ free(app_addr);
+ app_addr = NULL;
+}
+
+void free_cp_application_app_auth(DM_CP_Application_AppAuth * appAuth)
+{
+ retm_if((appAuth) == NULL, "dm_cp appAuth is NULL!!");
+
+ if (appAuth->auth_data != NULL) {
+ str_free(&(appAuth->auth_data));
+ appAuth->auth_data = NULL;
+ }
+ if (appAuth->auth_level != NULL) {
+ str_free(&(appAuth->auth_level));
+ appAuth->auth_level = NULL;
+ }
+ if (appAuth->auth_name != NULL) {
+ str_free(&(appAuth->auth_name));
+ appAuth->auth_name = NULL;
+ }
+ if (appAuth->auth_secret != NULL) {
+ str_free(&(appAuth->auth_secret));
+ appAuth->auth_secret = NULL;
+ }
+
+ if (appAuth->auth_type != NULL) {
+ str_free(&(appAuth->auth_type));
+ appAuth->auth_type = NULL;
+ }
+ if (appAuth->next != NULL) {
+ free_cp_application_app_auth(appAuth->next);
+ appAuth->next = NULL;
+ }
+
+ free(appAuth);
+ appAuth = NULL;
+}
+
+void free_cp_application_resource(DM_CP_Application_Resource * resource)
+{
+ retm_if((resource) == NULL, "dm_cp port is NULL!!");
+
+ if (resource->accept != NULL) {
+ str_free(&(resource->accept));
+ resource->accept = NULL;
+ }
+ if (resource->auth_data != NULL) {
+ str_free(&(resource->auth_data));
+ resource->auth_data = NULL;
+ }
+ if (resource->auth_name != NULL) {
+ str_free(&(resource->auth_name));
+ resource->auth_name = NULL;
+ }
+ if (resource->auth_secret != NULL) {
+ str_free(&(resource->auth_secret));
+ resource->auth_secret = NULL;
+ }
+ if (resource->auth_type != NULL) {
+ str_free(&(resource->auth_type));
+ resource->auth_type = NULL;
+ }
+ if (resource->name != NULL) {
+ str_free(&(resource->name));
+ resource->name = NULL;
+ }
+ if (resource->start_page != NULL) {
+ str_free(&(resource->start_page));
+ resource->start_page = NULL;
+ }
+ if (resource->uri != NULL) {
+ str_free(&(resource->uri));
+ resource->uri = NULL;
+ }
+ if (resource->next != NULL) {
+ free_cp_application_resource(resource->next);
+ resource->next = NULL;
+ }
+
+ free(resource);
+ resource = NULL;
+}
+
+void free_cp_port(DM_CP_Port * port)
+{
+ retm_if((port) == NULL, "dm_cp port is NULL!!");
+
+ if (port->portnbr != NULL) {
+ str_free(&(port->portnbr));
+ port->portnbr = NULL;
+ }
+ if (port->service != NULL) {
+ free_string_node(port->service);
+ port->service = NULL;
+ }
+ if (port->next != NULL) {
+ free_cp_port(port->next);
+ port->next = NULL;
+ }
+
+ free(port);
+ port = NULL;
+}
+
+void free_string_node(String_Node * service)
+{
+ retm_if((service) == NULL, "dm_cp string node is NULL!!");
+
+ if (service->data != NULL) {
+ str_free(&(service->data));
+ service->data = NULL;
+ }
+ if (service->next != NULL) {
+ free_string_node(service->next);
+ service->next = NULL;
+ }
+
+ free(service);
+ service = NULL;
+}
+
+void free_cp_napdef(DM_CP_Napdef * napdef)
+{
+ retm_if((napdef) == NULL, "dm_cp napdef is NULL!!");
+
+ if (napdef->auth_info != NULL) {
+ free_cp_napdef_authinfo(napdef->auth_info);
+ napdef->auth_info = NULL;
+ }
+ if (napdef->bearer != NULL) {
+ free_string_node(napdef->bearer);
+ napdef->bearer = NULL;
+ }
+ if (napdef->call_type != NULL) {
+ str_free(&(napdef->call_type));
+ napdef->call_type = NULL;
+ }
+ if (napdef->delivery_err_sdu != NULL) {
+ str_free(&(napdef->delivery_err_sdu));
+ napdef->delivery_err_sdu = NULL;
+ }
+ if (napdef->delivery_order != NULL) {
+ str_free(&(napdef->delivery_order));
+ napdef->delivery_order = NULL;
+ }
+ if (napdef->dn_link_speed != NULL) {
+ str_free(&(napdef->dn_link_speed));
+ napdef->dn_link_speed = NULL;
+ }
+ if (napdef->dns_addr != NULL) {
+ free_string_node(napdef->dns_addr);
+ napdef->dns_addr = NULL;
+ }
+ if (napdef->first_retry_timeout != NULL) {
+ str_free(&(napdef->first_retry_timeout));
+ napdef->first_retry_timeout = NULL;
+ }
+ if (napdef->guaranteed_bitrate_dnlink != NULL) {
+ str_free(&(napdef->guaranteed_bitrate_dnlink));
+ napdef->guaranteed_bitrate_dnlink = NULL;
+ }
+ if (napdef->guaranteed_bitrate_uplink != NULL) {
+ str_free(&(napdef->guaranteed_bitrate_uplink));
+ napdef->guaranteed_bitrate_uplink = NULL;
+ }
+ if (napdef->internet != NULL) {
+ str_free(&(napdef->internet));
+ napdef->internet = NULL;
+ }
+ if (napdef->linger != NULL) {
+ str_free(&(napdef->linger));
+ napdef->linger = NULL;
+ }
+ if (napdef->link_speed != NULL) {
+ str_free(&(napdef->link_speed));
+ napdef->link_speed = NULL;
+ }
+ if (napdef->local_addr != NULL) {
+ str_free(&(napdef->local_addr));
+ napdef->local_addr = NULL;
+ }
+ if (napdef->local_addr_type != NULL) {
+ str_free(&(napdef->local_addr_type));
+ napdef->local_addr_type = NULL;
+ }
+ if (napdef->max_bitrate_dnlink != NULL) {
+ str_free(&(napdef->max_bitrate_dnlink));
+ napdef->max_bitrate_dnlink = NULL;
+ }
+ if (napdef->max_bitrate_uplink != NULL) {
+ str_free(&(napdef->max_bitrate_uplink));
+ napdef->max_bitrate_uplink = NULL;
+ }
+ if (napdef->max_num_retry != NULL) {
+ str_free(&(napdef->max_num_retry));
+ napdef->max_num_retry = NULL;
+ }
+ if (napdef->max_sdu_size != NULL) {
+ str_free(&(napdef->max_sdu_size));
+ napdef->max_sdu_size = NULL;
+ }
+ if (napdef->name != NULL) {
+ str_free(&(napdef->name));
+ napdef->name = NULL;
+ }
+ if (napdef->nap_ID != NULL) {
+ str_free(&(napdef->nap_ID));
+ napdef->nap_ID = NULL;
+ }
+ if (napdef->nap_addr_type != NULL) {
+ str_free(&(napdef->nap_addr_type));
+ napdef->nap_addr_type = NULL;
+ }
+ if (napdef->nap_address != NULL) {
+ str_free(&(napdef->nap_address));
+ napdef->nap_address = NULL;
+ }
+ if (napdef->rereg_threshold != NULL) {
+ str_free(&(napdef->rereg_threshold));
+ napdef->rereg_threshold = NULL;
+ }
+ if (napdef->residual_ber != NULL) {
+ str_free(&(napdef->residual_ber));
+ napdef->residual_ber = NULL;
+ }
+ if (napdef->sdu_error_ratio != NULL) {
+ str_free(&(napdef->sdu_error_ratio));
+ napdef->sdu_error_ratio = NULL;
+ }
+ if (napdef->t_bit != NULL) {
+ str_free(&(napdef->t_bit));
+ napdef->t_bit = NULL;
+ }
+ if (napdef->traffic_class != NULL) {
+ str_free(&(napdef->traffic_class));
+ napdef->traffic_class = NULL;
+ }
+ if (napdef->traffic_handl_prio != NULL) {
+ str_free(&(napdef->traffic_handl_prio));
+ napdef->traffic_handl_prio = NULL;
+ }
+ if (napdef->transfer_delay != NULL) {
+ str_free(&(napdef->transfer_delay));
+ napdef->transfer_delay = NULL;
+ }
+ if (napdef->validity != NULL) {
+ free_cp_napdef_validity(napdef->validity);
+ napdef->validity = NULL;
+ }
+ if (napdef->next != NULL) {
+ free_cp_napdef(napdef->next);
+ napdef->next = NULL;
+ }
+
+ free(napdef);
+ napdef = NULL;
+
+}
+
+void free_cp_napdef_authinfo(DM_CP_Napdef_AuthInfo * auth_info)
+{
+ retm_if((auth_info) == NULL, "dm_cp napdef auth info is NULL!!");
+
+ if (auth_info->auth_entity != NULL) {
+ free_string_node(auth_info->auth_entity);
+ auth_info->auth_entity = NULL;
+ }
+ if (auth_info->auth_name != NULL) {
+ str_free(&(auth_info->auth_name));
+ auth_info->auth_name = NULL;
+ }
+ if (auth_info->auth_secret != NULL) {
+ str_free(&(auth_info->auth_secret));
+ auth_info->auth_secret = NULL;
+ }
+ if (auth_info->auth_type != NULL) {
+ str_free(&(auth_info->auth_type));
+ auth_info->auth_type = NULL;
+ }
+ if (auth_info->spi != NULL) {
+ str_free(&(auth_info->spi));
+ auth_info->spi = NULL;
+ }
+ if (auth_info->next != NULL) {
+ free_cp_napdef_authinfo(auth_info->next);
+ auth_info->next = NULL;
+ }
+
+ free(auth_info);
+ auth_info = NULL;
+}
+
+void free_cp_napdef_validity(DM_CP_Napdef_validity * validity)
+{
+ retm_if((validity) == NULL, "dm_cp napdef validity is NULL!!");
+
+ if (validity->country != NULL) {
+ str_free(&(validity->country));
+ validity->country = NULL;
+ }
+ if (validity->network != NULL) {
+ str_free(&(validity->network));
+ validity->network = NULL;
+ }
+ if (validity->sid != NULL) {
+ str_free(&(validity->sid));
+ validity->sid = NULL;
+ }
+ if (validity->soc != NULL) {
+ str_free(&(validity->soc));
+ validity->soc = NULL;
+ }
+ if (validity->validuntil != NULL) {
+ str_free(&(validity->validuntil));
+ validity->validuntil = NULL;
+ }
+ if (validity->next != NULL) {
+ free_cp_napdef_validity(validity->next);
+ validity->next = NULL;
+ }
+
+ free(validity);
+ validity = NULL;
+}
+
+void free_cp_bootstrap(DM_CP_Bootstrap * bootstraps)
+{
+ retm_if((bootstraps) == NULL, "dm_cp bootstraps is NULL!!");
+
+ if (bootstraps->context_allow != NULL) {
+ str_free(&(bootstraps->context_allow));
+ bootstraps->context_allow = NULL;
+ }
+ if (bootstraps->country != NULL) {
+ str_free(&(bootstraps->country));
+ bootstraps->country = NULL;
+ }
+ if (bootstraps->name != NULL) {
+ str_free(&(bootstraps->name));
+ bootstraps->name = NULL;
+ }
+ if (bootstraps->provurl != NULL) {
+ str_free(&(bootstraps->provurl));
+ bootstraps->provurl = NULL;
+ }
+ if (bootstraps->network != NULL) {
+ free_string_node(bootstraps->network);
+ bootstraps->network = NULL;
+ }
+ if (bootstraps->proxy_id != NULL) {
+ free_string_node(bootstraps->proxy_id);
+ bootstraps->proxy_id = NULL;
+ }
+ if (bootstraps->next != NULL) {
+ free_cp_bootstrap(bootstraps->next);
+ bootstraps->next = NULL;
+ }
+
+ free(bootstraps);
+ bootstraps = NULL;
+}
+
+void free_cp_pxlogical(DM_CP_PxLogical * pxLogical)
+{
+ retm_if((pxLogical) == NULL, "dm_cp pxlogical is NULL!!");
+
+ if (pxLogical->bas_auth_id != NULL) {
+ str_free(&(pxLogical->bas_auth_id));
+ pxLogical->bas_auth_id = NULL;
+ }
+ if (pxLogical->bas_auth_pw != NULL) {
+ str_free(&(pxLogical->bas_auth_pw));
+ pxLogical->bas_auth_pw = NULL;
+ }
+ if (pxLogical->domain != NULL) {
+ free_string_node(pxLogical->domain);
+ pxLogical->domain = NULL;
+ }
+ if (pxLogical->master != NULL) {
+ str_free(&(pxLogical->master));
+ pxLogical->master = NULL;
+ }
+ if (pxLogical->name != NULL) {
+ str_free(&(pxLogical->name));
+ pxLogical->name = NULL;
+ }
+ if (pxLogical->port != NULL) {
+ free_cp_port(pxLogical->port);
+ pxLogical->port = NULL;
+ }
+ if (pxLogical->ppg_auth_type != NULL) {
+ str_free(&(pxLogical->ppg_auth_type));
+ pxLogical->ppg_auth_type = NULL;
+ }
+ if (pxLogical->proxy_id != NULL) {
+ str_free(&(pxLogical->proxy_id));
+ pxLogical->proxy_id = NULL;
+ }
+ if (pxLogical->proxy_provider_id != NULL) {
+ str_free(&(pxLogical->proxy_provider_id));
+ pxLogical->proxy_provider_id = NULL;
+ }
+ if (pxLogical->proxy_pw != NULL) {
+ str_free(&(pxLogical->proxy_pw));
+ pxLogical->proxy_pw = NULL;
+ }
+ if (pxLogical->pull_enabled != NULL) {
+ str_free(&(pxLogical->pull_enabled));
+ pxLogical->pull_enabled = NULL;
+ }
+ if (pxLogical->pxAuthInfo != NULL) {
+ free_cp_pxlogical_pxauthinfo(pxLogical->pxAuthInfo);
+ pxLogical->pxAuthInfo = NULL;
+ }
+ if (pxLogical->pxPhysical != NULL) {
+ free_cp_pxLogical_pxphsical(pxLogical->pxPhysical);
+ pxLogical->pxPhysical = NULL;
+ }
+ if (pxLogical->start_page != NULL) {
+ str_free(&(pxLogical->start_page));
+ pxLogical->start_page = NULL;
+ }
+ if (pxLogical->trust != NULL) {
+ str_free(&(pxLogical->trust));
+ pxLogical->trust = NULL;
+ }
+ if (pxLogical->wsp_version != NULL) {
+ str_free(&(pxLogical->wsp_version));
+ pxLogical->wsp_version = NULL;
+ }
+ if (pxLogical->next != NULL) {
+ free_cp_pxlogical(pxLogical->next);
+ pxLogical->next = NULL;
+ }
+
+ free(pxLogical);
+ pxLogical = NULL;
+}
+
+void free_cp_pxlogical_pxauthinfo(DM_CP_PxLogical_PxAuthInfo * pxAuthInfo)
+{
+ retm_if((pxAuthInfo) == NULL, "dm_cp pxAuthInfo is NULL!!");
+
+ if (pxAuthInfo->pxAuth_id != NULL) {
+ str_free(&(pxAuthInfo->pxAuth_id));
+ pxAuthInfo->pxAuth_id = NULL;
+ }
+ if (pxAuthInfo->pxAuth_pw != NULL) {
+ str_free(&(pxAuthInfo->pxAuth_pw));
+ pxAuthInfo->pxAuth_pw = NULL;
+ }
+ if (pxAuthInfo->pxAuth_type != NULL) {
+ str_free(&(pxAuthInfo->pxAuth_type));
+ pxAuthInfo->pxAuth_type = NULL;
+ }
+ if (pxAuthInfo->next != NULL) {
+ free_cp_pxlogical_pxauthinfo(pxAuthInfo->next);
+ pxAuthInfo->next = NULL;
+ }
+
+ free(pxAuthInfo);
+ pxAuthInfo = NULL;
+
+}
+
+void free_cp_pxLogical_pxphsical(DM_CP_PxLogical_PxPhysical * pxPhysical)
+{
+ retm_if((pxPhysical) == NULL, "dm_cp pxPhysical is NULL!!");
+
+ if (pxPhysical->domain != NULL) {
+ free_string_node(pxPhysical->domain);
+ pxPhysical->domain = NULL;
+ }
+ if (pxPhysical->physical_proxy_id != NULL) {
+ str_free(&(pxPhysical->physical_proxy_id));
+ pxPhysical->physical_proxy_id = NULL;
+ }
+ if (pxPhysical->port != NULL) {
+ free_cp_port(pxPhysical->port);
+ pxPhysical->port = NULL;
+ }
+ if (pxPhysical->pull_enabled != NULL) {
+ str_free(&(pxPhysical->pull_enabled));
+ pxPhysical->pull_enabled = NULL;
+ }
+ if (pxPhysical->push_enabled != NULL) {
+ str_free(&(pxPhysical->push_enabled));
+ pxPhysical->push_enabled = NULL;
+ }
+
+ if (pxPhysical->pxAddr != NULL) {
+ str_free(&(pxPhysical->pxAddr));
+ pxPhysical->pxAddr = NULL;
+ }
+ if (pxPhysical->pxAddrType != NULL) {
+ str_free(&(pxPhysical->pxAddrType));
+ pxPhysical->pxAddrType = NULL;
+ }
+ if (pxPhysical->pxAddr_FQDN != NULL) {
+ str_free(&(pxPhysical->pxAddr_FQDN));
+ pxPhysical->pxAddr_FQDN = NULL;
+ }
+ if (pxPhysical->to_napid != NULL) {
+ free_string_node(pxPhysical->to_napid);
+ pxPhysical->to_napid = NULL;
+ }
+
+ if (pxPhysical->wsp_version != NULL) {
+ str_free(&(pxPhysical->wsp_version));
+ pxPhysical->wsp_version = NULL;
+ }
+ if (pxPhysical->next != NULL) {
+ free_cp_pxLogical_pxphsical(pxPhysical->next);
+ pxPhysical->next = NULL;
+ }
+
+ free(pxPhysical);
+ pxPhysical = NULL;
+
+}
diff --git a/src/agent/dm-engine/dl-manager/dd_parser.c b/src/agent/dm-engine/dl-manager/dd_parser.c
new file mode 100644
index 0000000..d17eeb5
--- /dev/null
+++ b/src/agent/dm-engine/dl-manager/dd_parser.c
@@ -0,0 +1,220 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <stdio.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "dm-engine/dl-manager/dd_parser.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_DL"
+#endif
+
+typedef enum {
+ DD_NODE_NO_TYPE = 0,
+ DD_NODE_OBJECT_TYPE,
+ DD_NODE_DESCRIPTION,
+ DD_NODE_OBJECT_URI,
+ DD_NODE_SIZE,
+ DD_NODE_INSTALL_NOTIFY_URI
+} DD_NODE_TYPE;
+
+static DD_NODE_TYPE ___get_node_type(unsigned char *node_name);
+static DM_ERROR __set_value_to_dd_object(xmlNode * a_node, Download_Descriptor ** dd_object);
+static DM_ERROR _convert_doc_to_dd_object(xmlDocPtr doc, Download_Descriptor ** dd_object);
+
+DM_ERROR convert_xml_to_DD_object(const char *dd_xml, unsigned int dd_xml_length, Download_Descriptor ** dd_object)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ /* parse the in memory document */
+ xmlDocPtr doc = NULL;
+
+ retvm_if((dd_xml) == NULL, COMMON_ERR_IS_NULL, "dd_xml is NULL!!");
+
+ if (dd_xml == NULL || dd_xml_length == 0 || *dd_object == NULL) {
+ _DEBUG_INFO("dd_xml == NULL || dd_xml_length == 0 || *dd_object == NULL");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+ _DEBUG_INFO("xml: %s, size: %d", dd_xml, dd_xml_length);
+ doc = xmlReadMemory(dd_xml, dd_xml_length, 0, 0, 0);
+ if (doc == NULL) {
+ _DEBUG_INFO("xmlReadMemory() Fail\n");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+ /* convert doc to dd_object */
+ ret = _convert_doc_to_dd_object(doc, dd_object);
+ _DEBUG_INFO("convert doc to dd object : %d", ret);
+
+ error:
+
+ if (doc != NULL)
+ xmlFreeDoc(doc);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+static DD_NODE_TYPE ___get_node_type(unsigned char *node_name)
+{
+ _INNER_FUNC_ENTER;
+
+ _DEBUG_VERBOSE("node_name: %s\n", node_name);
+
+ if (strcmp((const char *)node_name, "type") == 0) {
+ _INNER_FUNC_EXIT;
+ return DD_NODE_OBJECT_TYPE;
+ } else if (strcmp((const char *)node_name, "description") == 0) {
+ _INNER_FUNC_EXIT;
+ return DD_NODE_DESCRIPTION;
+ } else if (strcmp((const char *)node_name, "objectURI") == 0) {
+ _INNER_FUNC_EXIT;
+ return DD_NODE_OBJECT_URI;
+ } else if (strcmp((const char *)node_name, "size") == 0) {
+ _INNER_FUNC_EXIT;
+ return DD_NODE_SIZE;
+ } else if (strcmp((const char *)node_name, "installNotifyURI") == 0) {
+ _INNER_FUNC_EXIT;
+ return DD_NODE_INSTALL_NOTIFY_URI;
+ }
+
+ _INNER_FUNC_EXIT;
+ return DD_NODE_NO_TYPE;
+}
+
+static DM_ERROR __set_value_to_dd_object(xmlNode * a_node, Download_Descriptor ** dd_object)
+{
+ _INNER_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+ xmlNode *cur_node = 0;
+ DD_NODE_TYPE node_type = DD_NODE_NO_TYPE;
+
+ retvm_if((a_node) == NULL, COMMON_ERR_IS_NULL, "a_node is NULL!!");
+
+ unsigned char *content = NULL;
+ for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
+ if (cur_node->type == XML_ELEMENT_NODE) {
+ content = xmlNodeGetContent(cur_node);
+
+ _DEBUG_VERBOSE("node type: Element, name: %s\n", cur_node->name);
+ _DEBUG_VERBOSE("node type: Element, content: %s\n", content);
+
+ node_type = ___get_node_type((unsigned char *)(cur_node->name));
+ switch (node_type) {
+ case DD_NODE_OBJECT_TYPE:
+ {
+ if (content != NULL) {
+ (*dd_object)->object_type = strdup((const char *)content);
+ }
+ }
+ break;
+ case DD_NODE_DESCRIPTION:
+ {
+ if (content != NULL) {
+ (*dd_object)->object_description = strdup((const char *)content);
+ }
+ }
+ break;
+ case DD_NODE_OBJECT_URI:
+ {
+#ifdef _DM_BUNDANG_TEST
+ if (content != NULL) {
+ (*dd_object)->object_uri = get_new_uri((char *)content);
+ }
+#else
+ if (content != NULL) {
+ (*dd_object)->object_uri = strdup((const char *)content);
+ }
+#endif
+ if ((*dd_object)->object_uri != NULL) {
+ _DEBUG_VERBOSE("object_uri = %s\n", (*dd_object)->object_uri);
+ } else {
+ _DEBUG_VERBOSE("object uri null");
+ }
+ }
+ break;
+ case DD_NODE_SIZE:
+ {
+ if (content != NULL) {
+ (*dd_object)->object_size = atoi((const char *)content);
+ }
+ }
+ break;
+ case DD_NODE_INSTALL_NOTIFY_URI:
+ {
+#ifdef _DM_BUNDANG_TEST
+ if (content != NULL) {
+ (*dd_object)->install_notify_uri = get_new_uri((char *)content);
+ }
+#else
+ if (content != NULL) {
+ (*dd_object)->install_notify_uri = strdup((const char *)content);
+ }
+#endif
+ if ((*dd_object)->install_notify_uri != NULL) {
+ _DEBUG_VERBOSE("install_notify_uri = %s\n", (*dd_object)->install_notify_uri);
+ } else {
+ _DEBUG_VERBOSE("install notify uri null");
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ ret = __set_value_to_dd_object(cur_node->children, dd_object);
+ _DEBUG_VERBOSE("set value to dd object : %d", ret);
+ }
+
+ _INNER_FUNC_EXIT;
+ return DM_OK;
+}
+
+static DM_ERROR _convert_doc_to_dd_object(xmlDocPtr doc, Download_Descriptor ** dd_object)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ xmlNode *root_element = 0;
+
+ /* get the root element node */
+ root_element = xmlDocGetRootElement(doc);
+ if (root_element == NULL) {
+ _INNER_FUNC_EXIT;
+ return COMMON_ERR_IS_NULL;
+ }
+
+ /*DD_NODE_TYPE node_type = DD_NODE_NO_TYPE; */
+ ret = __set_value_to_dd_object(root_element, dd_object);
+ _DEBUG_TRACE("set value dd object : %d", ret);
+
+ _INNER_FUNC_EXIT;
+ return ret;
+}
diff --git a/src/agent/dm-engine/dl-manager/fw_downloader.c b/src/agent/dm-engine/dl-manager/fw_downloader.c
new file mode 100644
index 0000000..b228d7c
--- /dev/null
+++ b/src/agent/dm-engine/dl-manager/fw_downloader.c
@@ -0,0 +1,455 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <glib.h>
+#include <unistd.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "dm-engine/dl-manager/fw_downloader.h"
+#include "dm-engine/dl-manager/dd_parser.h"
+#include "dm-engine/dl-manager/sa_fw_downloader.h"
+#include "ipc_agent.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_DL"
+#endif
+
+static Data_Resume_Infomation *_alloc_data_resume_infomation();
+static void _free_data_resume_information(Data_Resume_Infomation * data_resume_info);
+static int _arrange_file(const char *download_folder, const char *file_name);
+static char *_get_msg_for_status(DM_ERROR download_status);
+
+DM_ERROR get_object_information(char *dd_server_uri, int *file_size, Download_Descriptor ** download_descriptor, DM_ERROR * download_status)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((dd_server_uri) == NULL, COMMON_ERR_IS_NULL, "dd_server_uri is NULL!!");
+
+ /* 1. construct HTTP msg */
+ /* 2. send msg to server (about dd_server_uri) */
+ /* 3. receive dd information from server */
+ GList *send_header = 0;
+ char *recvMsg = 0;
+ unsigned int recvMsg_size = 0;
+ GList *recv_header = 0;
+ ret = send_download_msg(DD_DOWNLOAD, dd_server_uri, "application/vnd.oma.dd+xml", send_header, 0, 0, &recv_header, &recvMsg, &recvMsg_size);
+ if (ret != DM_OK) {
+ *download_status = DM_ERR_LOSS_OF_SERVICE;
+ _DEBUG_INFO("send_DL_Msg() err [%d]\n", ret);
+ goto error;
+ }
+
+ /* 4. realloc or alloc download descriptor object */
+
+ /* 5. parse the dd information xml data (convert dd xml to dd object) */
+ ret = convert_xml_to_DD_object(recvMsg, recvMsg_size, download_descriptor);
+ if (ret != DM_OK) {
+ _DEBUG_INFO("send_DL_Msg() err [%d]\n", ret);
+ *download_status = DM_ERR_INVALID_DESCRIPTOR;
+ goto error;
+ }
+
+ if (*download_descriptor != NULL && (*download_descriptor)->object_uri != NULL) {
+ *file_size = (*download_descriptor)->object_size;
+
+ _DEBUG_INFO(" dd->object_uri = %s \n", (*download_descriptor)->object_uri);
+ _DEBUG_INFO(" dd->size = %d \n", (*download_descriptor)->object_size);
+ _DEBUG_INFO(" dd->object_description = %s \n", (*download_descriptor)->object_description);
+ } else {
+ _DEBUG_INFO("dd obejct uri null");
+ ret = DM_ERR_INVALID_DESCRIPTOR;
+ *download_status = DM_ERR_INVALID_DESCRIPTOR;
+ goto error;
+ }
+
+ error:
+
+ if (recvMsg != NULL)
+ free(recvMsg);
+
+ if (recv_header != NULL)
+ free_header_info(recv_header);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR check_file_resume(const char *checked_download_folder, DOWNLOAD_FILE_STATUS * file_status, Download_Descriptor * download_descriptor, Data_Resume_Infomation ** data_resume_info)
+{
+ _EXTERN_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+ /* 1. validate download_folder variable */
+ retvm_if((checked_download_folder) == NULL, COMMON_ERR_IS_NULL, "checked_download_folder is NULL!!");
+
+ if (file_status != NULL) {
+ _DEBUG_INFO("checked_download_folder == 0 && file_status != 0 ");
+ ret = COMMON_ERR_IS_NULL;
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ }
+
+ char *file_name = NULL;
+ char *file_path = NULL;
+
+ /* send_msg to server */
+ GList *send_header = 0;
+ char *recvMsg = 0;
+ unsigned int recvMsg_size = 0;
+ GList *recv_header = 0;
+ ret = send_download_msg(GET_FILE_NAME, download_descriptor->object_uri, download_descriptor->object_type, send_header, 0, 0, &recv_header, &recvMsg, &recvMsg_size);
+ if (ret != DM_OK) {
+ _DEBUG_INFO("send_DL_Msg() err [%d]\n", ret);
+ goto error;
+ }
+
+ /* get file_name for header info */
+ file_name = get_file_name(recv_header, download_descriptor->object_uri);
+ if (file_name == NULL) {
+ _DEBUG_INFO("file_name is null");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ /* check file */
+ file_path = g_strdup_printf("%s/%s", checked_download_folder, file_name);
+
+ _DEBUG_INFO("Download_Folder = %s\n", checked_download_folder);
+ _DEBUG_INFO("Download_Folder_Path = %s\n", file_path);
+
+ unsigned long file_size = 0;
+ int err = sync_agent_get_file_size(file_path, &file_size);
+ if (err == 0) {
+ _DEBUG_INFO("NOT_EXIST_FILE\n");
+ *file_status = NOT_EXIST_FILE;
+ goto return_part;
+ }
+
+ _DEBUG_INFO("Exist File Size = %d", file_size);
+ _DEBUG_INFO(" download_descriptor->object_size = %d", download_descriptor->object_size);
+ if (file_size >= download_descriptor->object_size) {
+ _DEBUG_INFO("EXIST_COMPLETED_FILE\n");
+ *file_status = EXIST_COMPLETED_FILE;
+ goto arrange;
+ }
+
+ return_part:
+
+ (*data_resume_info) = _alloc_data_resume_infomation();
+ if ((*data_resume_info) == NULL) {
+ _DEBUG_INFO("calloc failed !!");
+ ret = COMMON_ERR_ALLOC;
+ *file_status = NOT_EXIST_FILE;
+ goto error;
+ }
+ (*data_resume_info)->file_path = g_strdup_printf("%s", file_path);
+ (*data_resume_info)->current_data_size = file_size;
+ (*data_resume_info)->total_data_size = download_descriptor->object_size;
+ *file_status = EXIST_PARTIAL_FILE;
+ _DEBUG_INFO("EXIST_PARTIAL_FILE\n");
+
+ arrange:
+ err = _arrange_file(checked_download_folder, file_name);
+ if (err != 1) {
+ ret = COMMON_ERR_GENERIC;
+ }
+
+ error:
+ if (recvMsg != NULL)
+ free(recvMsg);
+
+ if (recv_header != NULL)
+ free_header_info(recv_header);
+
+ str_free(&file_name);
+ str_free(&file_path);
+
+ _DEBUG_INFO("END error : %d !!", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR download_object(const char *download_folder, char **object_downloaded_path, Data_Resume_Infomation * data_resume_info, int config, Download_Descriptor * download_descriptor, DM_ERROR * download_status)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((download_folder) == NULL, COMMON_ERR_IS_NULL, "download_folder is NULL!!");
+ retvm_if((data_resume_info) == NULL, COMMON_ERR_IS_NULL, "data_resume_info is NULL!!");
+ retvm_if((download_descriptor) == NULL, COMMON_ERR_IS_NULL, "download_descriptor is NULL!!");
+
+ if (data_resume_info->file_path == NULL) {
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ *download_status = DM_ERR_INVALID_DESCRIPTOR;
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ }
+
+ _DEBUG_INFO(" data_resume_info = %p", data_resume_info);
+ _DEBUG_INFO("file path : %s ", data_resume_info->file_path);
+ _DEBUG_INFO("file size : %d ", data_resume_info->total_data_size);
+
+ if (!sync_agent_is_existing_fs(data_resume_info->file_path)) {
+ _DEBUG_INFO("FILE IS NOT EXIST");
+ FILE *fp = fopen(data_resume_info->file_path, "w");
+ fclose(fp);
+
+ } else {
+ //
+ }
+ _DEBUG_INFO("############################################################################");
+ /*noti to ui */
+ int noti_err = noti_send_download_info(data_resume_info->total_data_size, data_resume_info->file_path);
+ sleep(1);
+ _DEBUG_INFO("download info noti : %d", noti_err);
+ _DEBUG_INFO("############################################################################");
+ if (noti_err != 1) {
+ ret = COMMON_ERR_IPC;
+ *download_status = DM_ERR_USER_CANDELLED;
+ goto error;
+ }
+ char *download_path = NULL;
+ int current_file_download_size = 0;
+ if (data_resume_info != NULL) {
+ current_file_download_size = data_resume_info->current_data_size;
+ }
+
+ GList *send_header = 0;
+ ret = download_data(download_descriptor->object_uri, download_descriptor->object_type, send_header, current_file_download_size, (char *)download_folder, config, &download_path);
+ if (ret != DM_OK) {
+ _DEBUG_INFO("send_DL_Msg() err [%d]\n", ret);
+ *download_status = DM_ERR_USER_CANDELLED;
+ goto error;
+ }
+
+ *object_downloaded_path = download_path;
+ *download_status = DM_DD_SUCCESS;
+
+ error:
+
+ if (data_resume_info != NULL) {
+ _free_data_resume_information(data_resume_info);
+ _DEBUG_INFO("__free_Data_Resume_Information() Success\n");
+ }
+
+ _DEBUG_INFO("END : %d !!", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR send_donwload_status(DM_ERROR download_status, Download_Descriptor * download_descriptor)
+{
+ _EXTERN_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((download_descriptor) == NULL, COMMON_ERR_IS_NULL, "download_descriptor is NULL!!");
+
+ if ((download_descriptor == NULL) || (download_descriptor->install_notify_uri == NULL)) {
+ _EXTERN_FUNC_EXIT;
+ return COMMON_ERR_IS_NULL;
+ }
+
+ GList *send_header = 0;
+ char *send_msg = 0;
+ char *recvMsg = 0;
+ unsigned int recvMsg_size = 0;
+ GList *recv_header = 0;
+
+ send_msg = _get_msg_for_status(download_status);
+ if (send_msg != NULL) {
+ ret = send_download_msg(SEND_DOWNLOAD_STATUS, download_descriptor->install_notify_uri, 0, send_header, send_msg, strlen(send_msg), &recv_header, &recvMsg, &recvMsg_size);
+ if (ret != DM_OK) {
+ _DEBUG_INFO("send_DL_Msg() err [%d]\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ }
+ }
+
+ if (recvMsg != NULL)
+ free(recvMsg);
+
+ if (recv_header != NULL)
+ free_header_info(recv_header);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+/* static function implementation*/
+
+void free_Download_Descriptor(Download_Descriptor ** download_descriptor)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (*download_descriptor != NULL) {
+
+ if ((*download_descriptor)->object_name != NULL)
+ free((*download_descriptor)->object_name);
+
+ if ((*download_descriptor)->object_description != NULL)
+ free((*download_descriptor)->object_description);
+
+ if ((*download_descriptor)->object_uri != NULL)
+ free((*download_descriptor)->object_uri);
+
+ if ((*download_descriptor)->next_uri != NULL)
+ free((*download_descriptor)->next_uri);
+
+ if ((*download_descriptor)->install_notify_uri != NULL)
+ free((*download_descriptor)->install_notify_uri);
+
+ if ((*download_descriptor)->info_uri != NULL)
+ free((*download_descriptor)->info_uri);
+
+ if ((*download_descriptor)->icon_uri != NULL)
+ free((*download_descriptor)->icon_uri);
+
+ if ((*download_descriptor)->object_vender != NULL)
+ free((*download_descriptor)->object_vender);
+
+ if ((*download_descriptor)->DD_version != NULL)
+ free((*download_descriptor)->DD_version);
+
+ if ((*download_descriptor)->install_param != NULL)
+ free((*download_descriptor)->install_param);
+
+ free((*download_descriptor));
+ }
+
+ *download_descriptor = 0;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+static Data_Resume_Infomation *_alloc_data_resume_infomation()
+{
+ _INNER_FUNC_ENTER;
+
+ _INNER_FUNC_EXIT;
+ return (Data_Resume_Infomation *) calloc(1, sizeof(Data_Resume_Infomation));
+}
+
+static void _free_data_resume_information(Data_Resume_Infomation * data_resume_info)
+{
+ _INNER_FUNC_ENTER;
+ if (data_resume_info != NULL) {
+
+ if (data_resume_info->file_path != NULL)
+ free(data_resume_info->file_path);
+
+ free(data_resume_info);
+ }
+
+ data_resume_info = NULL;
+ _INNER_FUNC_EXIT;
+}
+
+static int _arrange_file(const char *download_folder, const char *file_name)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((download_folder) == NULL, 0, "download_folder is NULL!!");
+ retvm_if((file_name) == NULL, 0, "file_name is NULL!!");
+
+ int err = 1;
+ GSList *fileList = 0;
+ err = sync_agent_get_file_list(download_folder, &fileList);
+ if (err != 1)
+ goto error;
+
+ GSList *iter = 0;
+ char *temp_file_info = 0;
+ char *temp_file_name = 0;
+ char *temp_file_path = 0;
+ for (iter = fileList; iter != 0; iter = g_slist_next(iter)) {
+ temp_file_info = (char *)(iter->data);
+ _DEBUG_TRACE("temp_file_name = %s\n", temp_file_name);
+
+ //
+ temp_file_name = strtok(temp_file_info, ",");
+ //
+
+ if (strcmp(temp_file_name, file_name) != 0) {
+ temp_file_path = g_strdup_printf("%s/%s", download_folder, temp_file_name);
+ _DEBUG_TRACE("temp_file_path = %s\n", temp_file_path);
+ err = sync_agent_delete_file(temp_file_path);
+ _DEBUG_TRACE("delete file = %d\n", err);
+ str_free(&temp_file_path);
+ }
+ }
+
+ error:
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static char *_get_msg_for_status(DM_ERROR download_status)
+{
+ _INNER_FUNC_ENTER;
+
+ char *send_msg = 0;
+
+ switch (download_status) {
+ case DM_OK:
+ send_msg = g_strdup_printf("%d Success", download_status);
+ break;
+ case DM_ERR_INSUFFICIENT_MEMORY:
+ send_msg = g_strdup_printf("%d Insufficient memory", download_status);
+ break;
+ case DM_ERR_USER_CANDELLED:
+ send_msg = g_strdup_printf("%d User Cancelled", download_status);
+ break;
+ case DM_ERR_LOSS_OF_SERVICE:
+ send_msg = g_strdup_printf("%d Loss of Service", download_status);
+ break;
+ case DM_ERR_ATTR_MISMATCH:
+ send_msg = g_strdup_printf("%d Attribute mismatch", download_status);
+ break;
+ case DM_ERR_INVALID_DESCRIPTOR:
+ send_msg = g_strdup_printf("%d Invalid descriptor", download_status);
+ break;
+ case DM_ERR_INVALID_DDVERSION:
+ send_msg = g_strdup_printf("%d Invalid DDVersion", download_status);
+ break;
+ case DM_ERR_DEVICE_ABORTED:
+ send_msg = g_strdup_printf("%d Device Aborted", download_status);
+ break;
+ case DM_ERR_NON_ACCEPTABLE_CONTENT:
+ send_msg = g_strdup_printf("%d Non-Acceptable Content", download_status);
+ break;
+ case DM_ERR_LOADER_ERROR:
+ send_msg = g_strdup_printf("%d Loader Error", download_status);
+ break;
+ default:
+ break;
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return send_msg;
+}
diff --git a/src/agent/dm-engine/dl-manager/na_fw_dl_binder.c b/src/agent/dm-engine/dl-manager/na_fw_dl_binder.c
new file mode 100644
index 0000000..b248f1a
--- /dev/null
+++ b/src/agent/dm-engine/dl-manager/na_fw_dl_binder.c
@@ -0,0 +1,52 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <stdlib.h>
+#include <string.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "dm-engine/dl-manager/na_fw_dl_binder.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_DL"
+#endif
+
+void add_header_info(GList ** header_info_list, char *key, char *value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if((key) == NULL, "key is NULL!!");
+ retm_if((value) == NULL, "value is NULL!!");
+
+ if (value != NULL) {
+ sync_agent_na_common_header_info_s *header_info = (sync_agent_na_common_header_info_s *) calloc(1, sizeof(sync_agent_na_common_header_info_s));
+ if (header_info == NULL) {
+ _DEBUG_INFO("alloc error");
+ return;
+ }
+ header_info->key = key;
+ header_info->value = value;
+ *header_info_list = g_list_append(*header_info_list, header_info);
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
diff --git a/src/agent/dm-engine/dl-manager/sa_fw_downloader.c b/src/agent/dm-engine/dl-manager/sa_fw_downloader.c
new file mode 100755
index 0000000..d285ec3
--- /dev/null
+++ b/src/agent/dm-engine/dl-manager/sa_fw_downloader.c
@@ -0,0 +1,666 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "dm-engine/dl-manager/sa_fw_downloader.h"
+#include "dm-engine/dl-manager/na_fw_dl_binder.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_DL"
+#endif
+
+#define DOWNLOAD_BODY_SIZE 66304
+//#define DOWNLOAD_BODY_SIZE 3592624
+#define MAX_COUNT 3
+
+static sync_agent_na_result_e _download_data(GList * header_info, int na_plugIn_id, unsigned char *download_folder, unsigned int download_start_size,
+ unsigned int download_body_size, unsigned char **out_download_path, sync_agent_na_send_type_e send_type, unsigned int session_id, int config);
+static sync_agent_na_result_e __get_data_info(void *http_req_info, void *http_info, int *total_doanload_size, char **current_download_range, char **download_file_name);
+static sync_agent_na_result_e __set_data_info(void *http_info, char *current_download_range);
+
+void free_header_info(GList * header_info)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (header_info != NULL) {
+ GList *iter = NULL;
+ sync_agent_na_common_header_info_s *iter_data;
+ for (iter = header_info; iter != NULL;) {
+ iter_data = NULL;
+ iter_data = ((sync_agent_na_common_header_info_s *) (iter->data));
+
+ iter = g_list_next(iter);
+ header_info = g_list_remove(header_info, iter_data);
+
+ if (iter_data->key != NULL)
+ free(iter_data->key);
+ if (iter_data->value != NULL)
+ free(iter_data->value);
+ free(iter_data);
+ }
+ g_list_free(header_info);
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+char *get_file_name(GList * recv_header, char *url_file_name)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((recv_header) == NULL, NULL, "recv_header is NULL!!");
+ retvm_if((url_file_name) == NULL, NULL, "url_file_name is NULL!!");
+
+ char *file_name = NULL;
+ file_name = get_file_name_from_http_header(recv_header);
+
+ /*gcf server not response Content-Disposition element */
+ if (file_name == NULL) {
+ char *temp_ptr = NULL;
+ _DEBUG_INFO("http content_disposition is null");
+
+ temp_ptr = strrchr(url_file_name, '/');
+ _DEBUG_INFO("result_file name : %s", temp_ptr);
+
+ if (temp_ptr != NULL) {
+ ++temp_ptr;
+ _DEBUG_INFO("remove '/' result_file name : %s", temp_ptr);
+ file_name = strdup(temp_ptr);
+
+ } else {
+ _DEBUG_INFO("dd object uri file name is null");
+ }
+ } else {
+ _DEBUG_INFO(" file name : %s", file_name);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return file_name;
+}
+
+char *get_file_name_from_http_header(GList * header_info)
+{
+ _EXTERN_FUNC_ENTER;
+ /* pasing file name */
+ char *file_name = 0;
+ char *value = 0;
+
+ retvm_if((header_info) == NULL, NULL, "header_info is NULL!!");
+
+ int ret = sync_agent_get_header_info(1, header_info, "Content-Disposition", &value);
+ if (ret != 1)
+ return 0;
+ if (value != NULL) {
+ _DEBUG_INFO("Key = %s, Value = %s\n", "Content-Disposition", value);
+ char *ptr1 = strstr(value, "attachment;");
+ if (ptr1 != NULL) {
+ ptr1 = strstr(ptr1, "fileName=");
+ if (ptr1 != NULL) {
+
+ char *temp = strdup(ptr1);
+
+ char *del = "\"";
+ char *temp_ptr = strtok(temp, del);
+ //temp_ptr = strtok(NULL, del);
+
+ file_name = strdup(temp_ptr);
+ _DEBUG_INFO("*download_file_name = %s\n", file_name);
+
+ if (temp != NULL)
+ free(temp);
+ }
+ }
+ } else {
+
+ }
+ _EXTERN_FUNC_EXIT;
+ return file_name;
+}
+
+DM_ERROR send_download_msg(DL_SEND_MSG_TYPE send_dl_type, char *local_uri, char *content_type, GList * header_info, char *sendMsg, unsigned int sendMsg_length, GList ** recv_header, char **recvMsg, unsigned int *recvMsg_length)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int transportType = 1;
+
+ sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+ DM_ERROR ret = DM_OK;
+ int net_session_id;
+
+ retvm_if((sendMsg) == NULL, COMMON_ERR_IS_NULL, "sendMsg is NULL!!");
+
+ //timeout : 30 seconds
+ res = sync_agent_open_connection(transportType, 30, (unsigned int *)(&(net_session_id)));
+
+ _DEBUG_INFO("res =%d\n", res);
+
+ if (res != SYNC_AGENT_NA_SUCCESS) {
+ ret = COMMON_ERR_INTERNAL_CONNECTION_ERROR;
+ goto error;
+ }
+
+ /* header binding */
+ switch (send_dl_type) {
+ case GET_FILE_NAME:
+ {
+ add_header_info(&header_info, "Range", g_strdup_printf("bytes=0-%d", DOWNLOAD_BODY_SIZE - 1));
+ /* intentionally not used "break" */
+ }
+ case DD_DOWNLOAD:
+ {
+ add_header_info(&header_info, "method", "get");
+ add_header_info(&header_info, "uri", local_uri);
+ add_header_info(&header_info, "Connection", "Keep-Alive");
+ add_header_info(&header_info, "User-Agent", "Samsung electronics GT-I9500 SyncML_DM Client");
+ add_header_info(&header_info, "Accept", content_type);
+ add_header_info(&header_info, "Accept-Charset", "UTF-8");
+ add_header_info(&header_info, "Content-Type", content_type);
+ }
+ break;
+ case SEND_DOWNLOAD_STATUS:
+ {
+ add_header_info(&header_info, "method", "post");
+ add_header_info(&header_info, "uri", local_uri);
+ add_header_info(&header_info, "Content-Length", g_strdup_printf("%d", sendMsg_length));
+ }
+ break;
+ default:
+ break;
+ }
+
+ /* send msg */
+ switch (send_dl_type) {
+ case DD_DOWNLOAD:
+ case GET_FILE_NAME:
+ case SEND_DOWNLOAD_STATUS:
+ {
+ res = sync_agent_send_msg( /*acc_info (id, pw, uri, ...), */
+ header_info, transportType, sendMsg, sendMsg_length, recv_header, (unsigned char **)recvMsg, recvMsg_length, SYNC_AGENT_NA_SEND_TYPE_SEND_N_RECEIVE, net_session_id);
+ }
+ break;
+ default:
+ break;
+ }
+
+ _DEBUG_INFO("res =%d\n", res);
+
+ if (res != SYNC_AGENT_NA_SUCCESS) {
+ ret = COMMON_ERR_INTERNAL_CONNECTION_ERROR;
+ goto returnerror;
+ }
+
+ res = sync_agent_close_connection(transportType, net_session_id);
+
+ _DEBUG_INFO("res =%d\n", res);
+ if (res != SYNC_AGENT_NA_SUCCESS) {
+ ret = COMMON_ERR_INTERNAL_CONNECTION_ERROR;
+ goto error;
+ }
+
+ if (sendMsg != NULL)
+ free(sendMsg);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ returnerror:
+ _DEBUG_INFO("returnerror = %d\n", ret);
+
+ res = sync_agent_close_connection(transportType, net_session_id);
+
+ _DEBUG_INFO("res =%d\n", res);
+ if (res != SYNC_AGENT_NA_SUCCESS) {
+ ret = COMMON_ERR_INTERNAL_CONNECTION_ERROR;
+ goto error;
+ }
+
+ if (sendMsg != NULL)
+ free(sendMsg);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO("error = %d\n", ret);
+
+ if (sendMsg != NULL)
+ free(sendMsg);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+DM_ERROR download_data(char *local_uri, char *content_type, GList * header_info, int current_file_download_size, char *download_folder, int config, char **download_path)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+ DM_ERROR ret = DM_OK;
+ int transportType = 1;
+ bool cancel_flag;
+ int net_session_id = 0;
+ int down_count = 0;
+
+ retvm_if((local_uri) == NULL, COMMON_ERR_IS_NULL, "local_uri is NULL!!");
+ retvm_if((header_info) == NULL, COMMON_ERR_IS_NULL, "header_info is NULL!!");
+ retvm_if((download_folder) == NULL, COMMON_ERR_IS_NULL, "download_folder is NULL!!");
+
+ //timeout : 30 seconds
+ res = sync_agent_open_connection(transportType, 30, (unsigned int *)(&(net_session_id)));
+
+ _DEBUG_INFO("res =%d\n", res);
+ if (res != SYNC_AGENT_NA_SUCCESS) {
+ ret = COMMON_ERR_INTERNAL_CONNECTION_ERROR;
+ goto error;
+ }
+
+ add_header_info(&header_info, "method", "get");
+ add_header_info(&header_info, "uri", local_uri);
+ add_header_info(&header_info, "Connection", "Keep-Alive");
+// add_header_info(&header_info, "User-Agent", "Samsung electronics GT-I9500 SyncML_DM Client");
+ add_header_info(&header_info, "Accept", content_type);
+ add_header_info(&header_info, "Accept-Charset", "UTF-8");
+ add_header_info(&header_info, "Content-Type", content_type);
+ add_header_info(&header_info, "Range", g_strdup_printf("bytes=%d-%d", current_file_download_size, current_file_download_size + DOWNLOAD_BODY_SIZE - 1));
+
+ sync_agent_register_cancel_callback(network_cancel_callback, &(net_session_id));
+
+ //check cancel flag (note that this can be called every where inside processing logic)
+ cancel_flag = sync_agent_check_cancel_flag();
+ if (cancel_flag != 0) {
+ ret = DM_ERR_USER_CANDELLED;
+ goto returnerror;
+ }
+
+ while (down_count < MAX_COUNT) {
+
+ res = _download_data( /*acc_info (id, pw, uri, ...), */
+ header_info, transportType, (unsigned char *)download_folder, current_file_download_size, DOWNLOAD_BODY_SIZE, (unsigned char **)download_path, SYNC_AGENT_NA_SEND_TYPE_SEND_N_RECEIVE, net_session_id, config);
+
+ down_count++;
+ _DEBUG_INFO("response download =%d\n", res);
+
+ if (res != SYNC_AGENT_NA_SUCCESS) {
+ if (res == SYNC_AGENT_NA_NETWORK_UNAVAILABLE) {
+ sleep(1);
+ if (down_count == MAX_COUNT) {
+ _DEBUG_INFO("download data wifi only error");
+ ret = DM_WIFI_ONLY_ERROR;
+ goto returnerror;
+ } else {
+ _DEBUG_INFO("download data network retry : %d", down_count);
+ continue;
+ }
+ }
+ _DEBUG_INFO("download data error");
+ ret = COMMON_ERR_INTERNAL_CONNECTION_ERROR;
+ /*f(res == SYNC_AGENT_NA_SEND_MSG_CANCEL) {
+ } */
+ goto returnerror;
+ } else {
+ _DEBUG_INFO("----------------------------------------download success-------------------------------------------\n");
+ down_count = MAX_COUNT;
+ break;
+ }
+ }
+
+ returnerror:
+ sync_agent_unregister_cancel_callback(network_cancel_callback, &(net_session_id));
+
+ cancel_flag = sync_agent_check_cancel_flag();
+ if (cancel_flag != 0) {
+ _DEBUG_INFO("----------------------------------------task cancel flag is : %d-------------------------------------------\n", cancel_flag);
+ _DEBUG_INFO("----------------------------------------download cancel-------------------------------------------\n");
+ if (cancel_flag != 0) {
+ _DEBUG_INFO("download cancel flag");
+ ret = DM_ERR_USER_CANDELLED;
+ }
+ }
+
+ _DEBUG_INFO("returnerror = %d\n", ret);
+ res = sync_agent_close_connection(transportType, net_session_id);
+
+ _DEBUG_INFO("res =%d\n", res);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO("error = %d\n", ret);
+ return ret;
+}
+
+static sync_agent_na_result_e _download_data(GList * header_info, int na_plugIn_id, unsigned char *download_folder, unsigned int download_start_size,
+ unsigned int download_body_size, unsigned char **out_download_path, sync_agent_na_send_type_e send_type, unsigned int session_id, int config)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((header_info) == NULL, COMMON_ERR_IS_NULL, "header_info is NULL!!");
+ retvm_if((download_folder) == NULL, COMMON_ERR_IS_NULL, "download_folder is NULL!!");
+
+ GList *recv_header_info = 0;
+ /* char *recvMsg = 0; */
+ unsigned char *recvMsg = NULL;
+ unsigned int recvMsg_size = 0;
+
+ unsigned int download_current_size = download_start_size;
+ /* unsigned int download_total_size = 0; */
+ int download_total_size = 0;
+ char *current_download_range = NULL;
+ char *download_file_name = NULL;
+
+ int count = 0; /* for test log */
+ sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+ GList *free_list = NULL;
+ sync_agent_na_common_header_info_s *free_item = NULL;
+ GList *backup_send_head_info_list = NULL;
+ GList *iter = NULL;
+
+ while (download_total_size == 0 || download_current_size < download_total_size - 1) {
+
+ _DEBUG_TRACE("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
+ _DEBUG_TRACE("############# %d th download", ++count);
+ _DEBUG_TRACE("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
+
+ /* back up the header list TODO */
+ /* GSList *backup_send_head_info_list = 0; */
+ backup_send_head_info_list = NULL;
+ iter = NULL;
+ for (iter = header_info; iter != NULL; iter = g_list_next(iter)) {
+ sync_agent_na_common_header_info_s *header_item_info = (sync_agent_na_common_header_info_s *) calloc(1, sizeof(sync_agent_na_common_header_info_s));
+ if (header_item_info == NULL) {
+ _DEBUG_TRACE("calloc failed !!");
+ ret = SYNC_AGENT_NA_DOWNLOAD_DATA_FAIL;
+ goto return_part;
+ }
+
+ if (((sync_agent_na_common_header_info_s *) (iter->data))->key != NULL) {
+ header_item_info->key = strdup(((sync_agent_na_common_header_info_s *) (iter->data))->key);
+
+ if (((sync_agent_na_common_header_info_s *) (iter->data))->value != NULL) {
+ header_item_info->value = strdup(((sync_agent_na_common_header_info_s *) (iter->data))->value);
+ } else {
+ _DEBUG_TRACE("key : %s, value is NULL !!", header_item_info->key);
+ header_item_info->value = NULL;
+ }
+
+ backup_send_head_info_list = g_list_append(backup_send_head_info_list, header_item_info);
+
+ if (strcmp(((sync_agent_na_common_header_info_s *) (iter->data))->key, "Range") == 0) {
+ _DEBUG_TRACE("[Before] key : %s, value : %s", ((sync_agent_na_common_header_info_s *) (iter->data))->key, ((sync_agent_na_common_header_info_s *) (iter->data))->value);
+ }
+
+ } else {
+ _DEBUG_TRACE("key is NULL !!");
+ header_item_info->key = NULL;
+ header_item_info->value = NULL;
+ free(header_item_info);
+ header_item_info = NULL;
+ }
+ }
+
+ if (config == 0) {
+ _DEBUG_TRACE("wifi only off mode download");
+ } else if (config == 1) {
+ ret = get_wifi_state();
+ _DEBUG_TRACE("wifi only mode : %d", ret);
+ if (ret != SYNC_AGENT_NA_SUCCESS) {
+ goto return_part;
+ }
+ }
+
+ /* send_msg */
+ ret = sync_agent_send_msg(backup_send_head_info_list, na_plugIn_id, 0, 0, &recv_header_info, &recvMsg, &recvMsg_size, send_type, session_id);
+ if (ret != SYNC_AGENT_NA_SUCCESS) {
+ _DEBUG_TRACE("sync_agent_send_msg() fail");
+ ret = SYNC_AGENT_NA_DOWNLOAD_DATA_FAIL;
+ goto return_part;
+ }
+
+ _DEBUG_TRACE("RecvMSg_Size = %d", recvMsg_size);
+ _DEBUG_TRACE("############# sync_agent_send_msg() success !!");
+
+ /* get download total size, download current range */
+ ret = __get_data_info(header_info, recv_header_info, &download_total_size, &current_download_range, &download_file_name);
+ if (ret != SYNC_AGENT_NA_SUCCESS) {
+ _DEBUG_TRACE("Get_Data_Down_Info() fail !!");
+ ret = SYNC_AGENT_NA_DOWNLOAD_DATA_FAIL;
+ goto return_part;
+ }
+
+ _DEBUG_TRACE("############# Get_Data_Down_Info() success !!");
+ if (current_download_range == NULL || download_total_size == 0 || download_file_name == NULL) {
+ _DEBUG_TRACE("current_download_range == NULL || download_total_size == 0 || download_file_name == NULL");
+ ret = SYNC_AGENT_NA_DOWNLOAD_DATA_FAIL;
+ goto return_part;
+ }
+
+ _DEBUG_TRACE("download_total_size = %d", download_total_size);
+ _DEBUG_TRACE("current_download_range = %s", current_download_range);
+ _DEBUG_TRACE("download_file_name = %s", download_file_name);
+
+ /* download path setting */
+ if (*out_download_path == NULL) {
+ *out_download_path = (unsigned char *)g_strdup_printf("%s/%s", download_folder, download_file_name);
+ _DEBUG_TRACE("*out_download_path = %s", *out_download_path);
+ }
+
+ /* increment download count */
+ char *del = "-";
+ /* int down_size = 0; */
+ char *ptr = strtok(current_download_range, del);
+ if (ptr != NULL) {
+
+ int start_size = 0;
+ int end_size = 0;
+
+ _DEBUG_TRACE("start_size = %s", ptr);
+ start_size = atoi(ptr);
+
+ ptr = strtok(NULL, del);
+ _DEBUG_TRACE("end_size = %s", ptr);
+ end_size = atoi(ptr);
+
+ _DEBUG_TRACE("prev download_current_size = %d", download_current_size);
+ _DEBUG_TRACE("Gap = %d", end_size - start_size);
+
+ download_current_size += (end_size - start_size + 1);
+ _DEBUG_TRACE("after download_current_size = %d", download_current_size);
+ }
+
+ bool isFinal = false;
+ if (download_current_size >= download_total_size - 1)
+ isFinal = true;
+
+ /* set file */
+ _DEBUG_TRACE("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! RecvMSg_Size = %d", recvMsg_size);
+ ret = sync_agent_append_file((char *)(*out_download_path), (char *)recvMsg, recvMsg_size, false);
+ if (ret != SYNC_AGENT_NA_SUCCESS) {
+ _DEBUG_TRACE("sync_agent_write_file() fail !!");
+ ret = SYNC_AGENT_NA_DOWNLOAD_DATA_FAIL;
+ goto return_part;
+ } else {
+ _DEBUG_TRACE("############# sync_agent_write_file() success !!");
+ }
+
+ /* set download total size, download current range */
+ char *new_download_range = g_strdup_printf("%d-%d", download_current_size, download_current_size + (download_body_size - 1));
+ ret = __set_data_info(header_info, new_download_range);
+ if (ret != SYNC_AGENT_NA_SUCCESS) {
+ _DEBUG_TRACE("Set_Data_Down_Info() fail !!");
+ ret = SYNC_AGENT_NA_DOWNLOAD_DATA_FAIL;
+ goto return_part;
+ }
+
+ _DEBUG_TRACE("############# Set_Data_Down_Info() success !!");
+
+ if (backup_send_head_info_list != NULL) {
+ for (free_list = backup_send_head_info_list; free_list != NULL;) {
+ free_item = (sync_agent_na_common_header_info_s *) (free_list->data);
+ free_list = g_list_next(free_list);
+
+ sync_agent_free_na_common_header_info(free_item);
+ }
+ g_list_free(backup_send_head_info_list);
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ return_part:
+
+ if (backup_send_head_info_list != NULL) {
+ for (free_list = backup_send_head_info_list; free_list != NULL;) {
+ free_item = (sync_agent_na_common_header_info_s *) (free_list->data);
+ free_list = g_list_next(free_list);
+
+ sync_agent_free_na_common_header_info(free_item);
+ }
+ g_list_free(backup_send_head_info_list);
+ }
+
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static sync_agent_na_result_e __get_data_info(void *http_req_info, void *http_info, int *total_doanload_size, char **current_download_range, char **download_file_name)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+
+ /* pasing file name */
+ char *temp_file_name = 0; /* strdup("attachment; fileName=\"FW-20110901-13121.bin\""); */
+ ret = sync_agent_get_header_info(1, (GList *) http_info, "Content-Disposition", &temp_file_name);
+ if (ret == SYNC_AGENT_NA_SUCCESS) {
+ _DEBUG_VERBOSE("success in sync_agent_get_header_info = %d", ret);
+ } else {
+ _DEBUG_VERBOSE("failed in sync_agent_get_header_info = %d", ret);
+ }
+ _DEBUG_VERBOSE("temp_file_name = %s\n", temp_file_name);
+ if (temp_file_name) {
+ char *ptr1 = strstr(temp_file_name, "attachment;");
+ if (ptr1 != 0) {
+ ptr1 = strstr(ptr1, "fileName=");
+ if (ptr1 != 0) {
+
+ char *temp = strdup(ptr1);
+
+ char *del = "\"";
+ char *temp_ptr = strtok(temp, del);
+ _DEBUG_VERBOSE("1st token = %s", temp_ptr);
+
+ temp_ptr = strtok(NULL, del);
+ _DEBUG_VERBOSE("2nd token = %s", temp_ptr);
+
+ *download_file_name = strdup(temp_ptr);
+ _DEBUG_VERBOSE("*download_file_name = %s", *download_file_name);
+
+ if (temp != 0)
+ free(temp);
+ }
+ }
+ } else {
+ char *result_name = NULL;
+
+ ret = sync_agent_get_header_info(1, (GList *) http_req_info, "uri", &temp_file_name);
+ if (ret == SYNC_AGENT_NA_SUCCESS) {
+ _DEBUG_VERBOSE("success in sync_agent_get_header_info = %d", ret);
+ } else {
+ _DEBUG_VERBOSE("failed in sync_agent_get_header_info = %d", ret);
+ }
+ _DEBUG_VERBOSE("temp_file_name = %s\n", temp_file_name);
+ if (temp_file_name != NULL) {
+
+ result_name = strrchr(temp_file_name, '/');
+ _DEBUG_VERBOSE("result_file name : %s", result_name);
+
+ if (result_name != NULL) {
+ ++result_name;
+ _DEBUG_VERBOSE("remove '/' result_file name : %s", result_name);
+
+ *download_file_name = strdup(result_name);
+ _DEBUG_VERBOSE("*download_file_name = %s\n", *download_file_name);
+ }
+ }
+ }
+ /* parsing data range info */
+ char *temp_range_value = 0; /* strdup("bytes 0-66303/3192624"); */
+ ret = sync_agent_get_header_info(1, (GList *) http_info, "Content-Range", &temp_range_value);
+ if (ret == SYNC_AGENT_NA_SUCCESS) {
+ _DEBUG_VERBOSE("success in sync_agent_get_header_info = %d", ret);
+ } else {
+ _DEBUG_VERBOSE("failed in sync_agent_get_header_info = %d", ret);
+ }
+ if (temp_range_value != NULL) {
+ char *temp = NULL;
+ temp = strdup(temp_range_value + strlen("bytes "));
+ _DEBUG_VERBOSE("temp_range = %s\n", temp);
+ if (temp != NULL) {
+ char *del2 = "/";
+ char *ptr2 = strtok(temp, del2);
+ if (ptr2 != 0) {
+ _DEBUG_VERBOSE("[na_http_plugIn] range = %s\n", ptr2);
+ *current_download_range = strdup(ptr2);
+
+ ptr2 = strtok(NULL, del2);
+ _DEBUG_VERBOSE("[na_http_plugIn] total = %s\n", ptr2);
+ *total_doanload_size = atoi(ptr2);
+ }
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static sync_agent_na_result_e __set_data_info(void *http_info, char *current_download_range)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_na_result_e ret = SYNC_AGENT_NA_SUCCESS;
+
+ GList *iter = NULL;
+ for (iter = (GList *) http_info; iter != NULL; iter = g_list_next(iter)) {
+
+ if (((sync_agent_na_common_header_info_s *) (iter->data))->key != 0 && !strcmp(((sync_agent_na_common_header_info_s *) (iter->data))->key, "Range")) {
+
+ char *value = ((sync_agent_na_common_header_info_s *) (iter->data))->value;
+ if (value != NULL) {
+ free(value);
+
+ ((sync_agent_na_common_header_info_s *) (iter->data))->value = g_strdup_printf("bytes=%s", current_download_range);
+ _DEBUG_VERBOSE("[After] key : %s, value : %s\n", ((sync_agent_na_common_header_info_s *) (iter->data))->key, ((sync_agent_na_common_header_info_s *) (iter->data))->value);
+ break;
+ } else {
+ _DEBUG_VERBOSE("[na_http_plugIn] value is NULL !! \n");
+ ret = SYNC_AGENT_NA_GET_HEADER_INFO_FAIL;
+ _INNER_FUNC_EXIT;
+ return ret;
+ }
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+ return ret;
+}
diff --git a/src/agent/dm-engine/dm_common_engine.c b/src/agent/dm-engine/dm_common_engine.c
new file mode 100755
index 0000000..42fa7ad
--- /dev/null
+++ b/src/agent/dm-engine/dm_common_engine.c
@@ -0,0 +1,605 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <stdio.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common_def.h"
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "framework/task/oma_dm_task_request.h"
+#include "framework/san-parser/pm_sanparser.h"
+#include "dm-engine/dm_common_engine.h"
+#include "dm-engine/fumo/fumo_engine.h"
+#include "dm-engine/lawmo/lawmo_engine.h"
+#include "mo-handler/dm_mo_common_internal.h"
+#include "mo-handler/dm_mo_common.h"
+#include "serviceadapter/dm-phase-handler/dm_phase_handler.h"
+#include "serviceadapter/sa_define.h"
+#include "serviceadapter/sa_session.h"
+#include "serviceadapter/sa_session_internal.h"
+#include "ipc_common.h"
+#include "ipc_agent.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "COMMON_ENGINE"
+#endif
+
+static DM_ERROR _change_engine_status(char *server_id, char *full_path, char *correlator, int service_engine_status);
+
+static DM_ERROR _change_engine_status(char *server_id, char *full_path, char *correlator, int service_engine_status)
+{
+ _INNER_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((server_id) == NULL, COMMON_ERR_IS_NULL, "full_path is NULL!!");
+ retvm_if((full_path) == NULL, COMMON_ERR_IS_NULL, "full_path is NULL!!");
+
+ int task_id;
+ task_id = sync_agent_get_self_request_id();
+ _DEBUG_TRACE("service engine db update");
+
+ engine_status *status;
+
+ int is_exist;
+ is_exist = IsExist_Engine_id(service_engine_status);
+
+ if (is_exist == 1) {
+ ret = Get_Engine_Status(service_engine_status, &status);
+ _DEBUG_TRACE("get engine status : %d", ret);
+ } else {
+ status = (engine_status *) calloc(1, sizeof(engine_status));
+ _DEBUG_TRACE("get engine status error");
+ }
+
+ if (status == NULL) {
+ _DEBUG_TRACE("calloc failed !!");
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+
+ if (correlator != NULL) {
+ status->correlator = strdup(correlator);
+ } else {
+ status->correlator = NULL;
+ }
+
+ status->engine_status = DM_SERVICE_ING;
+ status->engine_id = service_engine_status;
+ status->mo_path = strdup(full_path);
+ status->server_url = NULL;
+ status->result_status = DM_OK;
+ status->server_id = strdup(server_id);
+ status->task_id = task_id;
+ status->ui_noti_type = 0;
+ status->download_click = 0;
+ //status->ui_mode = ;
+
+ /* one engine */
+ /* if(IsExist_Engine_id(SERVICE_ENGINE)) {
+ ret = Delete_Engine_Status(SERVICE_ENGINE);
+ } */
+ ret = Update_Engine_Status(status);
+ _DEBUG_TRACE(" update engine status : %d \n", ret);
+
+ if (status != NULL)
+ Free_Memory_Engine_Status(&status, 1);
+
+ if (ret != DM_OK) {
+// DB_End_Transaction(TRANSACTION_ROLLBACK_);
+ goto error;
+ }
+ //sleep(10);
+/* ret = Update_Engine_Status_Column(IDLE_ENGINE, VALUE_ENGINE_STATUS, &service_engine_status);
+ _DEBUG_TRACE(" update engine status : %d \n", ret);
+ if (ret != DM_OK) {
+ DB_End_Transaction(TRANSACTION_ROLLBACK_);
+ goto error;
+ }*/
+
+ _INNER_FUNC_EXIT;
+ return ret;
+ error:
+
+ _DEBUG_TRACE(" end error : %d \n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+void init_Dm_Engine()
+{
+ _EXTERN_FUNC_ENTER;
+
+ /* always rebooting operation but excepted bootstrap */
+ reset_devinfo();
+ reset_devdetail();
+
+ _EXTERN_FUNC_EXIT;
+}
+
+DM_ERROR engine_start(char *server_id, char *full_path, char *correlator, ENGINE_ID * service_engine_id, int *resultCode)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ if (server_id == NULL || full_path == NULL) {
+ (*resultCode) = CLIENT_ERROR;
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_mo_type_e mo_type;
+
+ err_code = sync_agent_get_mo_type(full_path, &mo_type);
+ _DEBUG_INFO("get mo type result : %d", err_code);
+
+ (*resultCode) = DM_ERR_ACCEPTED_FOR_PROCESSING;
+
+ _DEBUG_INFO(" ------------------------------------------------------------------------------------------------------------------------------------- ");
+ _DEBUG_INFO(" mo_type : %d , server id : %s , full_path : %s , correlator : %s ", mo_type, server_id, full_path, correlator);
+ _DEBUG_INFO(" ------------------------------------------------------------------------------------------------------------------------------------- ");
+
+ switch (mo_type) {
+ case SYNC_AGENT_DM_MO_TYPE_FUMO:
+
+ _DEBUG_INFO("---------------------------------------------------------------- fumo engine ready --------------------------------------------------------------------- ");
+ ret = _change_engine_status(server_id, full_path, correlator, FUMO_SERVICE_ENGINE);
+ if (ret != DM_OK)
+ goto error;
+
+ if (correlator == NULL) {
+ /*because of gcf server */
+ /*ret = fumo_exec(full_path, correlator, (FUMO_Error *)resultCode);
+ if(ret !=DM_OK)
+ goto error; */
+ }
+
+ *service_engine_id = FUMO_SERVICE_ENGINE;
+
+ break;
+ case SYNC_AGENT_DM_MO_TYPE_LAWMO:
+ _DEBUG_INFO("---------------------------------------------------------------- lawmo engine ready --------------------------------------------------------------------- ");
+ ret = _change_engine_status(server_id, full_path, correlator, LAWMO_SERVICE_ENGINE);
+ if (ret != DM_OK)
+ goto error;
+
+ //if( !correlator) {
+ // 1 : this is just check , available operation
+ ret = lawmo_exec(full_path, correlator, (LAWMO_Result_code *) resultCode, CHECK_OPERATION);
+ if (ret != DM_OK)
+ goto error;
+ //}
+
+ *service_engine_id = LAWMO_SERVICE_ENGINE;
+
+ break;
+ default:
+ (*resultCode) = CLIENT_ERROR;
+ _DEBUG_INFO(" not existed engine \n");
+ break;
+ }
+
+ _DEBUG_INFO("====================result code : %d====================\n", *resultCode);
+ _DEBUG_INFO(" end!! resut code : %d\n", *resultCode);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+
+ _DEBUG_INFO("====================result code : %d====================\n", *resultCode);
+ _DEBUG_INFO(" error end %d result code : %d", ret, *resultCode);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR service_engine_start(ENGINE_ID service_engine_id, DM_ERROR * service_ret)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO(" start : service_engine_id : %d", service_engine_id);
+ DM_ERROR ret = DM_OK;
+ engine_status *service_status = NULL;
+ engine_status *after_service_status = NULL;
+ char *full_path = NULL;
+ char *correlator = NULL;
+ char *server_id = NULL;
+ int service_engine_status;
+ bool cancel_flag = 0;
+
+ cancel_flag = sync_agent_check_cancel_flag();
+ if (cancel_flag != 0) {
+ ret = DM_ERR_OPERATION_CANCELLED;
+ goto error;
+ }
+
+ if (IsExist_Engine_id(service_engine_id) == 1) {
+
+ _DEBUG_INFO("service engine id = %d\n", service_engine_id);
+ _DEBUG_INFO(" engine must re-start");
+
+ ret = Get_Engine_Status(service_engine_id, &service_status);
+ _DEBUG_INFO(" get engine status : %d \n", ret);
+ if (ret != DM_OK)
+ goto error;
+
+ if (service_status == NULL) {
+ _DEBUG_INFO("service status is null");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ if (service_status->engine_status == DM_SERVICE_UNKNOWN) {
+ _DEBUG_INFO("engine status unknown");
+ goto error;
+ }
+
+ if (service_status->engine_status == DM_SERVICE_ING) {
+ _DEBUG_INFO("-------------------------------------------- service type ------------------------------------------------ : %d", service_engine_id);
+
+ int engine_return = OPERATION_SUCCEEDED;
+
+ if (service_status->mo_path != NULL) {
+ full_path = strdup(service_status->mo_path);
+ _DEBUG_INFO("full path : %s ", full_path);
+ } else {
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ if (service_status->server_id != NULL) {
+ server_id = strdup(service_status->server_id);
+ _DEBUG_INFO("server_id : %s", server_id);
+ } else {
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ if (service_status->correlator != NULL) {
+ correlator = strdup(service_status->correlator);
+ _DEBUG_INFO("correlator : %s", correlator);
+ }
+
+ _DEBUG_INFO("service status : %d", service_status->engine_status);
+
+ switch (service_engine_id) {
+ case FUMO_SERVICE_ENGINE:
+ _DEBUG_INFO(" fumo exec");
+ ret = fumo_exec(full_path, correlator, (FUMO_Error *) (&engine_return));
+ _DEBUG_INFO("fumo ret : %d", ret);
+ *service_ret = ret;
+ if (ret != DM_OK && ret != DM_ERR_USER_CANDELLED && ret != DM_ERR_REMINDER_INTERVAL /*|| ret != DM_ERR_DEVICE_ABORTED */ )
+ goto error;
+ break;
+ case LAWMO_SERVICE_ENGINE:
+ _DEBUG_INFO(" lawmo exec");
+ ret = lawmo_exec(full_path, correlator, (LAWMO_Result_code *) (&engine_return), NON_CHECK_OPERATION);
+ _DEBUG_INFO("lawmo ret : %d", ret);
+ *service_ret = ret;
+ if (ret != DM_OK)
+ goto error;
+ break;
+ default:
+ break;
+ }
+ _DEBUG_INFO("exe resutlt : %d , server id : %s", engine_return, server_id);
+ _DEBUG_INFO("correlator : %s", correlator);
+
+ ret = Get_Engine_Status(service_engine_id, &after_service_status);
+ _DEBUG_INFO(" get engine status : %d \n", ret);
+ if (ret != DM_OK)
+ goto error;
+
+ if (after_service_status == NULL) {
+ _DEBUG_INFO("service status is null");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ if (after_service_status->download_click != RESUME_STATUS_INSTALL_BEFORE) {
+ /*engine status generic alert status */
+ service_engine_status = DM_GENERICALERT_ING;
+ ret = Update_Engine_Status_Column(service_engine_id, VALUE_ENGINE_STATUS, &service_engine_status);
+ _DEBUG_INFO("service engine status generic alert");
+
+ ret = Update_Engine_Status_Column(service_engine_id, VALUE_RESULT_STATUS, &engine_return);
+ _DEBUG_INFO("service engine status generic alert status : %d", engine_return);
+ }
+
+ str_free(&full_path);
+ str_free(&correlator);
+ str_free(&server_id);
+
+ if (service_status != NULL) {
+ Free_Memory_Engine_Status(&service_status, 1);
+ }
+ if (after_service_status != NULL) {
+ Free_Memory_Engine_Status(&after_service_status, 1);
+ }
+
+ } else {
+ if (service_status != NULL) {
+ Free_Memory_Engine_Status(&service_status, 1);
+ }
+ _DEBUG_INFO(" non service engine ing");
+ }
+
+ } else {
+ _DEBUG_INFO(" non service engine ");
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ if (service_status != NULL) {
+ Free_Memory_Engine_Status(&service_status, 1);
+ }
+
+ if (after_service_status != NULL) {
+ Free_Memory_Engine_Status(&after_service_status, 1);
+ }
+
+ str_free(&full_path);
+ str_free(&correlator);
+ str_free(&server_id);
+ _DEBUG_INFO(" error end %d ", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR set_engine_status_idle(ENGINE_ID service_engine_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ if (IsExist_Engine_id(service_engine_id) == 1) {
+ _DEBUG_INFO("service engine id = %d\n", service_engine_id);
+ }
+
+ ret = set_end_engine_status_idle();
+ if (ret != DM_OK)
+ goto error;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO(" error end %d ", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR set_end_engine_status_idle()
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ int common_engine_status = DM_IDLE;
+ _DEBUG_INFO(" engine idle");
+ ret = Update_Engine_Status_Column(IDLE_ENGINE, VALUE_ENGINE_STATUS, &common_engine_status);
+ if (ret != DM_OK)
+ goto error;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO(" error end %d ", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR dm_common_start(Event_Contents * pEvent_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((pEvent_data) == NULL, COMMON_ERR_IS_NULL, "pEvent_data is NULL!!");
+
+ ret = dm_common_operation(pEvent_data);
+ if (ret != DM_OK) {
+ goto error;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+
+ _DEBUG_INFO(" end!! error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+DM_ERROR dm_common_operation(Event_Contents * pEvent_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((pEvent_data) == NULL, COMMON_ERR_IS_NULL, "pEvent_data is NULL!!");
+
+ int return_ret = 0;
+ return_ret = remove(OMA_DM_MSG_PATH);
+ _DEBUG_INFO(" result file remove /tmp/dm.txt =[%d]\n", return_ret);
+
+ DM_ERROR service_ret = DM_OK;
+ ENGINE_ID service_engine_id = NO_SERVICE_ENGINE;
+ char *session_id = NULL;
+ char *server_id = NULL;
+ int session_type;
+
+ ret = get_server_info(pEvent_data, &server_id, &session_id, &session_type);
+ if (ret != DM_OK) {
+ goto error;
+ }
+
+ get_service_engine_id(&service_engine_id, pEvent_data->ui_mode);
+
+ /*pkg 1 ~ pkg2 */
+ int isFinish = 0;
+ int isgeneticAlert = 0;
+ void *session = NULL;
+ _DEBUG_INFO("----------------------------------------------------------------------------------------------------------\n");
+ _DEBUG_INFO(" setupphase Msg \n");
+ _DEBUG_INFO("----------------------------------------------------------------------------------------------------------\n");
+ ret = setup_phase(1, (Session **) & session, server_id, session_id, session_type, &service_engine_id, &isFinish, isgeneticAlert);
+ if (ret != DM_OK) {
+ _DEBUG_INFO("connect to server fail in dm common operation (authentication fail or network fail)");
+ _DEBUG_INFO(" result =[%d]\n", ret);
+ service_ret = ret;
+ goto error;
+ }
+
+ while (!isFinish) {
+
+ /* pkg 3 ~ pkg 4 */
+ /*isFinish = 0; */
+ _DEBUG_INFO("----------------------------------------------------------------------------------------------------------\n");
+ _DEBUG_INFO(" management Msg \n");
+ _DEBUG_INFO("----------------------------------------------------------------------------------------------------------\n");
+ ret = management_phase(1, (Session **) (&session), NULL, &service_engine_id, &isFinish);
+ if (ret != DM_OK) {
+ service_ret = ret;
+ goto error;
+ }
+
+ _DEBUG_INFO("isFinish : %d\n", isFinish);
+ _DEBUG_INFO("----------------------------------------------------------------------------------------------------------\n");
+
+ ret = service_engine_start(service_engine_id, &service_ret);
+ if (ret != DM_OK)
+ goto error;
+
+ ret = genericalert_operation(&session, &isFinish, service_engine_id);
+ if (ret != DM_OK)
+ goto error;
+
+ set_engine_status_idle(service_engine_id);
+ }
+
+ terminate_oma_dm_ui(service_ret, service_engine_id);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+
+ terminate_oma_dm_ui(service_ret, service_engine_id);
+
+ if (ret == DM_ERR_OPERATION_CANCELLED && service_ret == DM_ERR_OPERATION_CANCELLED) {
+ Delete_Engine_Status(service_engine_id);
+ _DEBUG_INFO("Delete fumo service engine");
+ }
+
+ set_engine_status_idle(service_engine_id);
+
+ if (service_engine_id != NO_SERVICE_ENGINE) {
+
+ if (service_engine_id != FUMO_SERVICE_ENGINE && check_existed_fumo_reminder_interval() == 0) {
+ Delete_Engine_Status(service_engine_id);
+ _DEBUG_INFO("Delete fumo service engine");
+ }
+ }
+
+ _DEBUG_INFO(" end error ret : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR genericalert_operation(void **session, int *isFinish, ENGINE_ID service_engine_id)
+{
+
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ char *pServer_id = NULL;
+ engine_status *status = NULL;
+
+ if (IsExist_Engine_id(service_engine_id) == 1) {
+ ret = Get_Engine_Status(service_engine_id, &status);
+ if (ret != DM_OK)
+ goto error;
+ _DEBUG_INFO(" result =[%d]\n", ret);
+
+ _DEBUG_INFO("server id : %s", status->server_id);
+ _DEBUG_INFO("engine_id : %d", status->engine_id);
+ _DEBUG_INFO("correlator : %s", status->correlator);
+ _DEBUG_INFO("engine_status : %d", status->engine_status);
+ _DEBUG_INFO("result status : %d", status->result_status);
+ _DEBUG_INFO("mo path : %s", status->mo_path);
+ _DEBUG_INFO("server url : %s", status->server_url);
+
+ if (status->engine_status == DM_GENERICALERT_ING) {
+ _DEBUG_INFO(" ----------------------------------------------------------------------generic alert-------------------------------------------------------------------------------");
+ _DEBUG_INFO("service engine id = %d\n", service_engine_id);
+
+ isFinish = 0;
+ int isgeneticAlert = 1;
+
+ if (status->server_id != NULL) {
+ pServer_id = strdup(status->server_id);
+ _DEBUG_INFO(" server id is %s", status->server_id);
+ } else {
+ _DEBUG_INFO(" server id is NULL");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+ //void * session = NULL;
+
+ ret = generic_alert(1, (Session **) session, pServer_id, NULL, isFinish, isgeneticAlert, service_engine_id, status->result_status);
+ if (ret != DM_OK)
+ goto error;
+ _DEBUG_INFO(" result =[%d]\n", ret);
+
+ /*update engine_status */
+ status->engine_status = DM_SERVICE_UNKNOWN;
+ ret = Update_Engine_Status(status);
+ _DEBUG_INFO(" update engine status : %d \n", ret);
+
+ str_free(&pServer_id);
+ }
+ } else {
+ _DEBUG_INFO("non generic alert");
+ }
+
+ if (status != NULL) {
+ Free_Memory_Engine_Status(&status, 1);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+
+ str_free(&pServer_id);
+ if (status != NULL)
+ Free_Memory_Engine_Status(&status, 1);
+
+ _DEBUG_INFO(" error end ret : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
diff --git a/src/agent/dm-engine/fumo/fumo_account.c b/src/agent/dm-engine/fumo/fumo_account.c
new file mode 100644
index 0000000..c18bf24
--- /dev/null
+++ b/src/agent/dm-engine/fumo/fumo_account.c
@@ -0,0 +1,83 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*common*/
+#include "common/dm_common.h"
+#include "dm-engine/fumo/fumo_account.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "FUMO_ENGINE"
+#endif
+
+int register_fota_account()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = 1;
+ sync_agent_dm_mo_error_e err = 1;
+ int count = 0;
+ int value = 0;
+
+ /*
+ * check ip push registration
+ */
+ //temp code
+/* int db_ret = 0;
+
+ db_ret = sync_agent_open_agent();
+ _DEBUG_INFO("OPEN DACI : %d", db_ret);*/
+ set_alarm_config_int(FUMO_ACCOUNT_FLAG_TYPE, FUMO_ACCOUNT_FLAG, 0, FUMO_ENGINE);
+ value = get_config_int(FUMO_ACCOUNT_FLAG_TYPE, FUMO_ACCOUNT_FLAG);
+
+ if (value != 1) {
+ do {
+ err = sync_agent_initialize_mo(3);
+ if (err == SYNC_AGENT_DM_MO_FAIL) {
+ _DEBUG_INFO("fail register fota account : %d ", err);
+ ret = 0;
+ } else {
+ _DEBUG_INFO("success register fota account : %d ", err);
+ break;
+ }
+ count++;
+ } while (err == SYNC_AGENT_DM_MO_FAIL && count < 3);
+
+ if (err == SYNC_AGENT_DM_MO_FAIL) {
+ ret = set_account_registration_alarm(FUMO_ACCOUNT_ALARM, FUMO_ACCOUNT_ALARM_TYPE);
+ _DEBUG_INFO("add fota account registration alarm : %d ", ret);
+ ret = 0;
+ } else {
+ ret = set_config_int(FUMO_ACCOUNT_FLAG_TYPE, FUMO_ACCOUNT_FLAG, 1, FUMO_ENGINE, 0);
+ _DEBUG_INFO("add fota account flag type setting result : %d ", ret);
+ delete_account_registration_alarm(FUMO_ACCOUNT_ALARM, FUMO_ACCOUNT_ALARM_TYPE);
+ _DEBUG_INFO("delete fota account delete alarm ");
+ }
+ } else {
+ //do nothing
+ }
+
+ /*db_ret = sync_agent_close_agent();
+ _DEBUG_INFO("CLOSE DACI : %d", db_ret); */
+ _DEBUG_INFO("end : %d", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
diff --git a/src/agent/dm-engine/fumo/fumo_engine.c b/src/agent/dm-engine/fumo/fumo_engine.c
new file mode 100644
index 0000000..9250283
--- /dev/null
+++ b/src/agent/dm-engine/fumo/fumo_engine.c
@@ -0,0 +1,1280 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "mo-handler/dm_mo_common.h"
+#include "mo-handler/dm_mo_handler.h"
+#include "dm-engine/fumo/fumo_engine.h"
+#include "dm-engine/dl-manager/fw_downloader.h"
+#include "dm-engine/dl-manager/dd_object.h"
+#include "ipc_common.h"
+#include "ipc_agent.h"
+
+#define MAX_FILE_SIZE 52428800
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "FUMO_ENGINE"
+#endif
+
+#define FOTA_LOW_BATTERY_LEVEL 50
+
+static DM_ERROR _firmware_download(char *server_url, MEMORY_TYPE * memory_type, FUMO_Error * fumo_return);
+static DM_ERROR _firmware_install(char *full_path, MEMORY_TYPE memory_type, FUMO_Error * fumo_return);
+static DM_ERROR __check_low_battery();
+static DM_ERROR __check_memory(long double file_size, MEMORY_TYPE * is_internal_memory);
+static DM_ERROR ___get_max_file_size(int *max_file_size);
+static DM_ERROR __check_max_file_size(int file_size);
+
+DM_ERROR fumo_engine_state_operation(char *full_path, char *down_server, FUMO_Error * fumo_return)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((full_path) == NULL, COMMON_ERR_IS_NULL, "full_path is NULL!!");
+ retvm_if((down_server) == NULL, COMMON_ERR_IS_NULL, "down_server is NULL!!");
+
+ char *result_mo_type = NULL;
+ sync_agent_dev_return_e dci_ret_exec = SYNC_AGENT_DEV_RETURN_SUCCESS;
+ bool cancel_flag = false;
+ MEMORY_TYPE memory_type = MEMORY_INTERNAL;
+ char *fumo_state_data = NULL;
+ FUMO_State fumo_state = UNKNOWN;
+
+ retvm_if((full_path) == NULL, COMMON_ERR_IS_NULL, "full_path is NULL!!");
+
+ ret = get_mo_operationtype(full_path, &result_mo_type);
+ if (ret != DM_OK)
+ goto error;
+
+ ret = get_current_fumo_state(full_path, &fumo_state_data);
+ if (ret != DM_OK)
+ goto error;
+
+ if (chartoint(fumo_state_data, (int *)(&fumo_state)) == 0) {
+ _DEBUG_INFO("error char to int value");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ _DEBUG_INFO(" -----------------------------------------------------------------------------------------------\n");
+ _DEBUG_INFO(" get fumo_state in db : %d\n", fumo_state);
+ _DEBUG_INFO(" -----------------------------------------------------------------------------------------------\n");
+
+ switch (fumo_state) {
+ case IDLE_START:
+ case DOWNLOAD_PROGRESSING:{
+
+ _DEBUG_INFO(" DOWNLOAD_PROGRESSING\n");
+ fumo_state = DOWNLOAD_PROGRESSING;
+
+ cancel_flag = sync_agent_check_cancel_flag();
+ if (cancel_flag != 0) {
+ ret = DM_OK;
+ *fumo_return = FUMO_USER_CANCELLED;
+ fumo_state = DOWNLOAD_FAILED;
+ goto error;
+ }
+
+ ret = _firmware_download(down_server, &memory_type, fumo_return);
+ if (ret != DM_OK && ret != DM_DOWNLOAD_POPUP && ret != DM_RESUME_IDLE) {
+ fumo_state = DOWNLOAD_FAILED;
+ goto error;
+ }
+
+ _DEBUG_INFO("fimware donwload success : 200 , cancel : 562, result is : %d\n", ret);
+
+ cancel_flag = sync_agent_check_cancel_flag();
+ if (cancel_flag != 0) {
+ ret = DM_OK;
+ *fumo_return = FUMO_USER_CANCELLED;
+ fumo_state = DOWNLOAD_FAILED;
+ goto error;
+ }
+
+ if (ret == DM_OK) {
+ _DEBUG_INFO("-----------download ok---------------");
+ fumo_state = DOWNLOAD_COMPLETE;
+
+ RESUME_STATUS download_clicked = RESUME_STATUS_INSTALL_BEFORE;
+ ret = Update_Engine_Status_Column(FUMO_SERVICE_ENGINE, VALUE_DOWNLOAD_CLICK, &download_clicked);
+ _DEBUG_INFO("update engine status clolumn download click : %d", ret);
+ ret = DM_OK;
+ } else if (ret == DM_ERR_REMINDER_INTERVAL || ret == DM_DOWNLOAD_POPUP || ret == DM_RESUME_IDLE) {
+ _DEBUG_INFO("-----------download popup---------------");
+ fumo_state = DOWNLOAD_PROGRESSING;
+ goto returnpart;
+ } else {
+ _DEBUG_INFO("-----------download fail---------------\n");
+ *fumo_return = FUMO_USER_CANCELLED;
+ fumo_state = DOWNLOAD_FAILED;
+ }
+
+ ret = set_current_fumo_state(full_path, fumo_state);
+ if (ret != DM_OK)
+ goto error;
+
+ if (strcmp(result_mo_type, DM_FUMO_DOWNLOAD_OP) == 0) {
+ } else if (strcmp(result_mo_type, DM_FUMO_UPDATE_OP) == 0) {
+ } else if (strcmp(result_mo_type, DM_FUMO_DOWNLOADAND_UPDATE_OP) == 0) {
+ fumo_engine_state_operation(full_path, down_server, fumo_return);
+ _DEBUG_INFO("engine state result : %d", ret);
+ }
+ }
+ break;
+ case DOWNLOAD_FAILED:
+ _DEBUG_INFO(" DOWNLOAD_FAILED\n");
+ goto error;
+
+ break;
+ case DOWNLOAD_COMPLETE:{
+ _DEBUG_INFO(" DOWNLOAD_COMPLETE\n");
+
+ if (strcmp(result_mo_type, DM_FUMO_DOWNLOAD_OP) == 0) {
+ } else if ((strcmp(result_mo_type, DM_FUMO_UPDATE_OP)) == 0 || strcmp(result_mo_type, DM_FUMO_DOWNLOADAND_UPDATE_OP) == 0) {
+ fumo_state = READY_TO_UPDATE;
+ ret = set_current_fumo_state(full_path, fumo_state);
+ if (ret != DM_OK)
+ goto error;
+
+ fumo_engine_state_operation(full_path, down_server, fumo_return);
+ _DEBUG_INFO("engine state result : %d", ret);
+ }
+ }
+ break;
+ case READY_TO_UPDATE:{
+ cancel_flag = sync_agent_check_cancel_flag();
+ if (cancel_flag != 0) {
+ ret = DM_OK;
+ *fumo_return = FUMO_USER_CANCELLED;
+ fumo_state = DOWNLOAD_FAILED;
+ goto error;
+ }
+
+ ret = _firmware_install(full_path, memory_type, fumo_return);
+
+ if (ret == DM_OK) {
+ /*if install success was rebooted */
+ _DEBUG_INFO("install fail");
+ goto error;
+ } else if (ret == COMMON_ERR_IPC || ret == DM_LOW_BATTERY_ERROR) {
+ _DEBUG_INFO("-----------cancel or ipc error---------------");
+ fumo_state = UPDATE_FAILED_HAVE_DATA;
+ goto returnpart;
+ } else if (ret == DM_ERR_REMINDER_INTERVAL || ret == DM_INSTALL_POPUP || ret == DM_RESUME_IDLE) {
+ _DEBUG_INFO("-----------download popup---------------");
+ fumo_state = READY_TO_UPDATE;
+ goto returnpart;
+ } else {
+ _DEBUG_INFO("-----------install fail---------------\n");
+ *fumo_return = FUMO_USER_CANCELLED;
+ fumo_state = UPDATE_FAILED_HAVE_DATA;
+ }
+
+ }
+ break;
+ case UPDATE_PROGRESSING:{
+
+ cancel_flag = sync_agent_check_cancel_flag();
+ if (cancel_flag != 0) {
+ ret = DM_OK;
+ *fumo_return = FUMO_USER_CANCELLED;
+ fumo_state = DOWNLOAD_FAILED;
+ goto error;
+ }
+
+ dci_ret_exec = sync_agent_execute_dev_function(2, "fota_result", 1, (int *)fumo_return);
+ //*fumo_return = result;
+ //*fumo_return = 202;
+ _DEBUG_INFO("-----------------firmware update result : %d fumo return : %d------------------", dci_ret_exec, (*fumo_return));
+ if (dci_ret_exec != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ fumo_state = UPDATE_FAILED_HAVE_DATA;
+ } else {
+ fumo_state = UPDATE_SUCCESSFUL_HAVE_DATA;
+ }
+
+ ret = set_current_fumo_state(full_path, fumo_state);
+ if (ret != DM_OK)
+ goto error;
+
+ ret = fumo_engine_state_operation(full_path, down_server, fumo_return);
+ _DEBUG_INFO("engine state result : %d", ret);
+ }
+ break;
+ case UPDATE_FAILED_HAVE_DATA:
+ case UPDATE_FAILED_NO_DATA:{
+
+ delete_fumo_contents(memory_type);
+ fumo_state = IDLE_START;
+ set_current_fumo_state(full_path, fumo_state);
+/* if(ret != DM_OK)
+ goto error;*/
+
+ /*ret = FUMO_UPDATE_FAILED; */
+ *fumo_return = FUMO_UPDATE_FAILED;
+ _DEBUG_INFO("update fail ");
+ }
+ break;
+ case UPDATE_SUCCESSFUL_HAVE_DATA:
+ case UPDATE_SUCCESSFUL_NO_DATA:{
+
+ _DEBUG_INFO("----------------------------------------------------------firmware update success delete files-----------------------------------------------------------");
+ delete_fumo_contents(memory_type);
+ fumo_state = IDLE_START;
+ set_current_fumo_state(full_path, fumo_state);
+/* if(ret != DM_OK)
+ goto error;*/
+
+ /*ret = FUMO_SUCCESS; */
+ *fumo_return = FUMO_SUCCESS;
+ _DEBUG_INFO("update success ");
+ }
+ break;
+ default:
+ break;
+ }
+
+ // str_free(&result_mo_type);
+ _DEBUG_INFO(" end fumo state : %d\n", fumo_state);
+ str_free(&fumo_state_data);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ returnpart:
+ _DEBUG_INFO("----------------------------------------------------------fumo download, install popup----------------------------------------------------------- %d", fumo_state);
+
+ set_current_fumo_state(full_path, fumo_state);
+ str_free(&fumo_state_data);
+ str_free(&result_mo_type);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO("----------------------------------------------------------fumo error-----------------------------------------------------------");
+ delete_fumo_contents(memory_type);
+
+ fumo_state = IDLE_START;
+ set_current_fumo_state(full_path, fumo_state);
+ str_free(&fumo_state_data);
+ str_free(&result_mo_type);
+
+ _DEBUG_INFO(" end error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR fumo_exec(char *full_path, char *correlator, FUMO_Error * fumo_return)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((full_path) == NULL, COMMON_ERR_IS_NULL, "full_path is NULL!!");
+
+ char *result_mo_type = NULL;
+ ret = get_mo_operationtype(full_path, &result_mo_type);
+ if (ret != DM_OK)
+ goto error;
+
+ if (result_mo_type == NULL) {
+ _DEBUG_INFO("result_mo_type is null");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ if (strcmp(result_mo_type, DM_FUMO_DOWNLOAD_OP) == 0) {
+ ret = firmware_download_opeartion(full_path, fumo_return);
+ if (ret != DM_OK)
+ goto error;
+ } else if (strcmp(result_mo_type, DM_FUMO_UPDATE_OP) == 0) {
+ ret = firmware_update_operation(full_path, fumo_return);
+ if (ret != DM_OK)
+ goto error;
+ } else if (strcmp(result_mo_type, DM_FUMO_DOWNLOADAND_UPDATE_OP) == 0) {
+ ret = firmware_downloadupdate_operation(full_path, fumo_return);
+ if (ret != DM_OK)
+ goto error;
+ } else {
+ ret = vendor_dependency_firmware_operation(full_path, fumo_return);
+ if (ret != DM_OK)
+ goto error;
+ }
+
+ str_free(&result_mo_type);
+ _DEBUG_INFO(" end : %d", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+
+ str_free(&result_mo_type);
+ _DEBUG_INFO(" end error : %d \n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+static DM_ERROR _firmware_download(char *server_url, MEMORY_TYPE * memory_type, FUMO_Error * fumo_return)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ DM_ERROR download_status = DM_ERR_USER_CANDELLED;
+ DM_ERROR installNofity_ret = DM_OK;
+ bool cancel_flag;
+ int config = -1;
+
+ char *download_folder = NULL;
+ int file_size = 0;
+ Download_Descriptor *download_descriptor = NULL;
+
+ engine_status *status = NULL;
+ int noti_res = 0;
+
+ if (server_url == NULL) {
+ *fumo_return = FUMO_USER_CANCELLED;
+ download_status = DM_ERR_INVALID_DESCRIPTOR;
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ _DEBUG_TRACE("----------------------------------------------------------------------------------------------------- \n");
+ _DEBUG_TRACE(" server url : %s \n", server_url);
+ _DEBUG_TRACE("----------------------------------------------------------------------------------------------------- \n");
+
+ ret = Get_Engine_Status(FUMO_SERVICE_ENGINE, &status);
+ if (ret != DM_OK || status == NULL) {
+ *fumo_return = FUMO_USER_CANCELLED;
+ download_status = DM_ERR_USER_CANDELLED;
+ goto error;
+ }
+
+ switch (status->download_click) {
+ case RESUME_STATUS_DONWLOAD_BEFORE: /*before click download popup */
+ {
+ _DEBUG_TRACE(" user interaction start \n");
+
+ cancel_flag = sync_agent_check_cancel_flag();
+ _DEBUG_TRACE(" cancel_flag : %d \n", cancel_flag);
+ if (cancel_flag != 0) {
+ *fumo_return = FUMO_USER_CANCELLED;
+ download_status = DM_ERR_USER_CANDELLED;
+ ret = DM_OK;
+ goto error;
+ }
+
+ int noti_res;
+ _DEBUG_TRACE("waiting connect to server success in firmware download\n");
+ noti_res = noti_download();
+ _DEBUG_TRACE("download noti response : %d \n ", noti_res);
+
+ if (noti_res == RESPONSE_TYPE_OK) {
+ ret = DM_DOWNLOAD_POPUP;
+ goto returnpart;
+
+ } else {
+ _DEBUG_TRACE("------------------------------------------------------downlaod popup noti error--------------------------------------------\n");
+ // error in noti-process
+ *fumo_return = FUMO_USER_CANCELLED;
+ download_status = DM_ERR_USER_CANDELLED;
+ ret = COMMON_ERR_IPC;
+ goto error;
+ }
+ }
+ break;
+ case RESUME_STATUS_DOWNLOAD: /*after click download popup */
+ {
+ _DEBUG_TRACE("------------------------------------------------------download button click---------------------------------------------\n");
+
+ download_descriptor = (Download_Descriptor *) calloc(1, sizeof(Download_Descriptor) + 1);
+ if (download_descriptor == NULL) {
+ _DEBUG_TRACE("calloc failed !!");
+ ret = COMMON_ERR_ALLOC;
+ *fumo_return = FUMO_USER_CANCELLED;
+ download_status = DM_ERR_INVALID_DESCRIPTOR;
+ goto error;
+ }
+
+ ret = get_object_information(server_url, &file_size, &download_descriptor, &download_status);
+ if (ret != DM_OK) {
+ *fumo_return = FUMO_USER_CANCELLED;
+ download_status = DM_ERR_INVALID_DESCRIPTOR;
+ goto error;
+ }
+ _DEBUG_TRACE(" user interaction start \n");
+
+ cancel_flag = sync_agent_check_cancel_flag();
+ _DEBUG_TRACE(" cancel_flag : %d \n", cancel_flag);
+ if (cancel_flag != 0) {
+ *fumo_return = FUMO_USER_CANCELLED;
+ download_status = DM_ERR_USER_CANDELLED;
+ ret = DM_OK;
+ goto error;
+ }
+
+ /*wifi config */
+ config = get_wifi_only_config();
+
+ /*battery state check */
+ ret = __check_low_battery();
+ _DEBUG_TRACE("ret : %d \n", ret);
+ if (ret != DM_OK) {
+ ret = DM_OK;
+ *fumo_return = FUMO_USER_CANCELLED;
+ goto error;
+ }
+
+ _DEBUG_TRACE("======================================================");
+ _DEBUG_TRACE("object size %d\n", file_size);
+ _DEBUG_TRACE("======================================================");
+
+ ret = __check_memory(file_size, memory_type);
+ if (ret != DM_OK) {
+ noti_res = noti_memory_full((int)file_size);
+ if (noti_res == RESPONSE_TYPE_OK) {
+ _DEBUG_TRACE("memory full popup success");
+ } else {
+ _DEBUG_TRACE("memory full popup fail");
+ }
+ download_status = DM_ERR_INSUFFICIENT_MEMORY;
+ *fumo_return = FUMO_USER_CANCELLED;
+ ret = DM_OK;
+ goto error;
+ }
+
+ if (config == -1) {
+ _DEBUG_TRACE("get wifi only config error");
+ *fumo_return = FUMO_MALFORMED_OR_BAD_URL;
+ download_status = DM_ERR_USER_CANDELLED;
+ ret = DM_WIFI_ONLY_ERROR;
+ goto error;
+ } else if (config == 0) {
+ _DEBUG_TRACE("wifi config = 0");
+ int wifi_ret = 0;
+ wifi_ret = get_wifi_state();
+ _DEBUG_TRACE("wifi mode : %d", wifi_ret);
+
+ if (wifi_ret != 1) {
+ _DEBUG_TRACE("3g mode");
+
+ ret = __check_max_file_size(file_size);
+ if (ret != DM_OK) {
+ _DEBUG_TRACE("get max file size error");
+ *fumo_return = FUMO_DOWNLOAD_FAILS_DUE_TO_DEVICE_OUT_OF_MEMORY;
+ download_status = DM_ERR_USER_CANDELLED;
+ ret = DM_WIFI_ONLY_ERROR;
+ goto error;
+ }
+ } else {
+ _DEBUG_TRACE("wifi mode");
+ }
+ } else {
+ _DEBUG_TRACE("wifi config = 1");
+ _DEBUG_TRACE("wifi only mode");
+ }
+
+ ret = get_fota_download_dir((*memory_type), &download_folder);
+ if (ret != DM_OK) {
+ *fumo_return = FUMO_DOWNLOAD_FAILS_DUE_TO_DEVICE_OUT_OF_MEMORY;
+ download_status = DM_ERR_INSUFFICIENT_MEMORY;
+ goto error;
+ }
+ _DEBUG_TRACE(" download ok \n ");
+
+ char *downloadUrl = NULL;
+ ret = Update_Engine_Status_Column(FUMO_SERVICE_ENGINE, VALUE_SERVER_URL, downloadUrl);
+ if (ret != DM_OK) {
+ *fumo_return = FUMO_USER_CANCELLED;
+ download_status = DM_ERR_USER_CANDELLED;
+ goto error;
+ }
+ /* remove remind interval */
+ delete_alarm_item(FUMO_INTERVAL, FUMO_INTERVAL_TYPE);
+ _DEBUG_TRACE(" delete fumo reminder in config db ");
+
+ //FOTASaveDir //FOTADownDir
+ DOWNLOAD_FILE_STATUS file_status = 0;
+ Data_Resume_Infomation *data_resume_info = NULL;
+ ret = check_file_resume(download_folder, &file_status, download_descriptor, &data_resume_info);
+ if (ret != DM_OK) {
+ *fumo_return = FUMO_MALFORMED_OR_BAD_URL;
+ download_status = DM_ERR_USER_CANDELLED;
+ goto error;
+ }
+
+ _DEBUG_TRACE(" file_status = %d \n", file_status);
+ /*was maked by sooyi */
+ if (file_status != EXIST_COMPLETED_FILE) {
+ char *object_path = 0;
+
+ if (config == -1) {
+ _DEBUG_TRACE("get wifi only config error");
+ *fumo_return = FUMO_MALFORMED_OR_BAD_URL;
+ download_status = DM_ERR_USER_CANDELLED;
+ ret = DM_WIFI_ONLY_ERROR;
+ goto error;
+ } else {
+ _DEBUG_TRACE("get wifi only config value : %d", config);
+
+ ret = download_object(download_folder, &object_path, data_resume_info, config, download_descriptor, &download_status);
+ _DEBUG_TRACE("download object : %s", object_path);
+ _DEBUG_TRACE(" download_object result : %d \n", ret);
+ if (ret != DM_OK) {
+ if (ret == DM_WIFI_ONLY_ERROR) {
+ _DEBUG_TRACE("send_DL_Msg() err [%d]\n", ret);
+ /* ipc wifi only pop up */
+ noti_res = noti_wifi_only_download_fail();
+
+ if (noti_res == RESPONSE_TYPE_OK) {
+ _DEBUG_TRACE("send_wifi only fail ipc success");
+ } else {
+ _DEBUG_TRACE("send_wifi only fail ipc fail");
+ }
+ }
+ *fumo_return = FUMO_USER_CANCELLED;
+ download_status = DM_ERR_USER_CANDELLED;
+ goto error;
+ } else {
+ //do nothing
+ }
+
+ installNofity_ret = send_donwload_status(download_status, download_descriptor);
+ _DEBUG_TRACE("send installNotify : %d", installNofity_ret);
+ }
+ } else {
+ _DEBUG_TRACE(" file is exist\n");
+ }
+ }
+ break;
+ case RESUME_STATUS_DOWNLOAD_LATER: /*later button clicked */
+ {
+ _DEBUG_TRACE("------------------------------------------------------later button click---------------------------------------------\n");
+
+ download_descriptor = (Download_Descriptor *) calloc(1, sizeof(Download_Descriptor) + 1);
+ if (download_descriptor == NULL) {
+ _DEBUG_TRACE("calloc failed !!");
+ ret = COMMON_ERR_ALLOC;
+ *fumo_return = FUMO_USER_CANCELLED;
+ download_status = DM_ERR_INVALID_DESCRIPTOR;
+ goto error;
+ }
+
+ ret = get_object_information(server_url, &file_size, &download_descriptor, &download_status);
+ if (ret != DM_OK) {
+ *fumo_return = FUMO_USER_CANCELLED;
+ download_status = DM_ERR_INVALID_DESCRIPTOR;
+ goto error;
+ }
+
+ installNofity_ret = send_donwload_status(download_status, download_descriptor);
+ _DEBUG_TRACE("send installNotify : %d", installNofity_ret);
+
+ RESUME_STATUS download_clicked = RESUME_STATUS_DOWNLOAD_IDLE;
+ ret = Update_Engine_Status_Column(FUMO_SERVICE_ENGINE, VALUE_DOWNLOAD_CLICK, &download_clicked);
+ _DEBUG_TRACE("update engine status clolumn download click : %d", ret);
+
+ *fumo_return = FUMO_USER_CANCELLED;
+ download_status = DM_ERR_USER_CANDELLED;
+ ret = DM_ERR_REMINDER_INTERVAL;
+ }
+ break;
+ case RESUME_STATUS_DOWNLOAD_IDLE:
+ default:
+ {
+ /*case RESUME_STATUS_IDLE, default */
+ ret = DM_RESUME_IDLE;
+ goto returnpart;
+
+ _DEBUG_TRACE("----------------------------------------------------bad flow--------------------------------------------------------------------");
+ }
+
+ break;
+ }
+
+ if (status != NULL)
+ Free_Memory_Engine_Status(&status, 1);
+
+ if (download_descriptor != NULL) {
+ _DEBUG_TRACE("__free_Download_Descriptor()\n");
+ free_Download_Descriptor(&download_descriptor);
+ }
+ str_free(&download_folder);
+
+ _INNER_FUNC_EXIT;
+
+ return ret;
+
+ returnpart:
+
+ if (status != NULL)
+ Free_Memory_Engine_Status(&status, 1);
+
+ if (download_descriptor != NULL) {
+ _DEBUG_TRACE("__free_Download_Descriptor()\n");
+ free_Download_Descriptor(&download_descriptor);
+ }
+ str_free(&download_folder);
+
+ _DEBUG_TRACE(" end error : %d \n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ error:
+
+ if (status != NULL)
+ Free_Memory_Engine_Status(&status, 1);
+
+ installNofity_ret = send_donwload_status(download_status, download_descriptor);
+ _DEBUG_INFO("send installNotify : %d", installNofity_ret);
+
+ if (download_descriptor != NULL) {
+ _DEBUG_INFO("__free_Download_Descriptor()\n");
+ free_Download_Descriptor(&download_descriptor);
+ }
+ str_free(&download_folder);
+
+ _DEBUG_INFO(" end error : %d \n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+
+}
+
+static DM_ERROR _firmware_install(char *full_path, MEMORY_TYPE memory_type, FUMO_Error * fumo_return)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ if (full_path == NULL) {
+ *fumo_return = FUMO_USER_CANCELLED;
+ goto error;
+ }
+
+ sync_agent_dev_return_e dci_ret_flag = SYNC_AGENT_DEV_RETURN_SUCCESS;
+ engine_status *status = NULL;
+ int noti_res = 0;
+ FUMO_State fumo_state = READY_TO_UPDATE;
+
+ ret = Get_Engine_Status(FUMO_SERVICE_ENGINE, &status);
+ if (ret != DM_OK || status == NULL) {
+ *fumo_return = FUMO_USER_CANCELLED;
+ goto error;
+ }
+
+ switch (status->download_click) {
+ case RESUME_STATUS_INSTALL_BEFORE:
+ {
+ /** install UI control */
+ noti_res = noti_install();
+ if (noti_res == RESPONSE_TYPE_OK) {
+ ret = DM_INSTALL_POPUP;
+ goto returnpart;
+ } else {
+ // error in noti-process
+ ret = COMMON_ERR_IPC;
+ *fumo_return = FUMO_USER_CANCELLED;
+ goto error;
+ }
+ }
+ break;
+ case RESUME_STATUS_INSTALL:
+ {
+ /* battery state check */
+ ret = __check_low_battery();
+ if (ret != DM_OK) {
+ ret = DM_LOW_BATTERY_ERROR;
+ *fumo_return = FUMO_USER_CANCELLED;
+ goto error;
+ }
+
+ _DEBUG_TRACE("------------------fota install ok------------------");
+ _DEBUG_TRACE(" fota flag api \n");
+ delete_alarm_item(FUMO_INTERVAL, FUMO_INTERVAL_TYPE);
+ _DEBUG_TRACE(" delete fumo reminder in config db ");
+
+ fumo_state = UPDATE_PROGRESSING;
+ ret = set_current_fumo_state(full_path, fumo_state);
+ if (ret != DM_OK) {
+ *fumo_return = FUMO_USER_CANCELLED;
+ goto error;
+ }
+
+ dci_ret_flag = sync_agent_execute_dev_function(2, "fota_flag", 1, memory_type);
+ //dci_ret_flag= SYNC_AGENT_DEV_RETURN_SUCCESS;
+ _DEBUG_TRACE(" fota flag result : %d \n", dci_ret_flag);
+ if (dci_ret_flag != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ _DEBUG_TRACE(" fota flag fail!!!!!!!!!!!! \n");
+ *fumo_return = FUMO_FAILED_VALIDATION;
+
+ ret = set_current_fumo_state(full_path, fumo_state);
+ if (ret != DM_OK) {
+ *fumo_return = FUMO_USER_CANCELLED;
+ goto error;
+ }
+
+ goto error;
+ } else {
+ //for reboot
+ _DEBUG_TRACE(" -------------------------------------------------------------------- \n");
+ _DEBUG_TRACE(" fota install to be rebooting l!!!!!!!!!!!! \n");
+ _DEBUG_TRACE(" -------------------------------------------------------------------- \n");
+ sleep(1);
+ exit(0);
+ break;
+ }
+ }
+ break;
+ case RESUME_STATUS_INSTALL_LATER:
+ {
+ //cancle to install
+ _DEBUG_TRACE("------------------canceled install------------------");
+
+ *fumo_return = FUMO_USER_CANCELLED;
+
+ RESUME_STATUS download_clicked = RESUME_STATUS_INSTALL_IDLE;
+ ret = Update_Engine_Status_Column(FUMO_SERVICE_ENGINE, VALUE_DOWNLOAD_CLICK, &download_clicked);
+ _DEBUG_TRACE("update engine status clolumn download click : %d", ret);
+ /*fumo_state = IDLE_START;
+ ret = set_current_fumo_state(full_path, fumo_state);
+ if(ret != DM_OK)
+ goto error; */
+ ret = DM_ERR_REMINDER_INTERVAL;
+ goto error;
+ }
+ break;
+ case RESUME_STATUS_INSTALL_IDLE:
+ default:
+ {
+ ret = DM_RESUME_IDLE;
+ goto returnpart;
+ _DEBUG_TRACE("----------------------------------------------------install later --------------------------------------------------------------------");
+ }
+ break;
+ }
+
+ if (status != NULL) {
+ Free_Memory_Engine_Status(&status, 1);
+ }
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ returnpart:
+
+ if (status != NULL) {
+ Free_Memory_Engine_Status(&status, 1);
+ }
+ _DEBUG_INFO(" return part : %d \n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ error:
+
+ if (status != NULL) {
+ Free_Memory_Engine_Status(&status, 1);
+ }
+ _DEBUG_INFO(" end error : %d \n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR firmware_download_opeartion(char *full_path, FUMO_Error * fumo_return)
+{
+ _EXTERN_FUNC_ENTER;
+ /*call DL module */
+ _DEBUG_INFO(" start\n");
+
+ DM_ERROR ret = DM_OK;
+
+ if (full_path == NULL) {
+ (*fumo_return) = FUMO_MALFORMED_OR_BAD_URL;
+ goto error;
+ }
+
+ char *full_path_pkgurl = NULL;
+ full_path_pkgurl = g_strdup_printf("%s%s", full_path, DM_FUMO_DWONLOAD_OP_PKGURL);
+
+ char *down_server = NULL;
+ ret = get_mo_data(full_path_pkgurl, &down_server);
+ if (ret != DM_OK) {
+ goto error;
+ }
+
+ if (down_server == NULL) {
+ _DEBUG_INFO("not found download server");
+ (*fumo_return) = FUMO_MALFORMED_OR_BAD_URL;
+ //ret =
+ goto error;
+ }
+#ifdef _DM_BUNDANG_TEST
+ /*redirection code */
+ char *pkg_url = get_new_uri(down_server);
+
+ ret = fumo_engine_state_operation(full_path, pkg_url, fumo_return);
+ if (ret != DM_OK)
+ goto error;
+#else
+ ret = fumo_engine_state_operation(full_path, down_server, fumo_return);
+ if (ret != DM_OK)
+ goto error;
+#endif
+ /*
+ * return server ret
+ */
+
+ str_free(&full_path_pkgurl);
+ str_free(&down_server);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ str_free(&full_path_pkgurl);
+ str_free(&down_server);
+
+ _DEBUG_INFO(" end error : %d \n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR firmware_update_operation(char *full_path, FUMO_Error * fumo_return)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ if (full_path == NULL) {
+ (*fumo_return) = FUMO_MALFORMED_OR_BAD_URL;
+ goto error;
+ }
+
+ char *full_path_pkgurl = NULL;
+ full_path_pkgurl = g_strdup_printf("%s%s", full_path, DM_FUMO_UPDATE_PKG_OP_DATA);
+
+ char *down_server = NULL;
+ ret = get_mo_data(full_path_pkgurl, &down_server);
+ if (ret != DM_OK) {
+ goto error;
+ }
+
+ if (down_server == NULL) {
+ _DEBUG_INFO("not found download server");
+ (*fumo_return) = FUMO_MALFORMED_OR_BAD_URL;
+ //ret =
+ goto error;
+ }
+#ifdef _DM_BUNDANG_TEST
+ /*redirection code */
+ char *pkg_url = get_new_uri(down_server);
+
+ ret = fumo_engine_state_operation(full_path, pkg_url, fumo_return);
+ if (ret != DM_OK)
+ goto error;
+#else
+ ret = fumo_engine_state_operation(full_path, down_server, fumo_return);
+ if (ret != DM_OK)
+ goto error;
+#endif
+
+ /*
+ * return server ret
+ */
+
+ str_free(&full_path_pkgurl);
+ str_free(&down_server);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ str_free(&full_path_pkgurl);
+ str_free(&down_server);
+
+ _DEBUG_INFO(" end error : %d \n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR firmware_downloadupdate_operation(char *full_path, FUMO_Error * fumo_return)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ if (full_path == NULL) {
+ _DEBUG_INFO(" full path = null\n");
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ (*fumo_return) = FUMO_MALFORMED_OR_BAD_URL;
+ goto error;
+ }
+
+ char *full_path_pkgurl = NULL;
+ full_path_pkgurl = g_strdup_printf("%s%s", full_path, DM_FUMO_DOWNLOADAND_UPDATE_OP_PKGURL);
+
+ char *down_server = NULL;
+ ret = get_mo_data(full_path_pkgurl, &down_server);
+ _DEBUG_INFO(" server_url : %s\n", down_server);
+ if (ret != DM_OK) {
+ goto error;
+ }
+
+ if (down_server == NULL) {
+ _DEBUG_INFO("not found download server");
+ (*fumo_return) = FUMO_MALFORMED_OR_BAD_URL;
+ //ret =
+ goto error;
+ }
+#ifdef _DM_BUNDANG_TEST
+ /*redirection code */
+ char *pkg_url = get_new_uri(down_server);
+
+ ret = fumo_engine_state_operation(full_path, pkg_url, fumo_return);
+ if (ret != DM_OK) {
+ goto error;
+ }
+#else
+ ret = fumo_engine_state_operation(full_path, down_server, fumo_return);
+ if (ret != DM_OK) {
+ goto error;
+ }
+#endif
+ /*
+ * return server ret
+ */
+
+ str_free(&full_path_pkgurl);
+ str_free(&down_server);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ str_free(&full_path_pkgurl);
+ str_free(&down_server);
+
+ _DEBUG_INFO(" end error : %d \n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR vendor_dependency_firmware_operation(char *full_path, FUMO_Error * fumo_return)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ int check_operation = 1;
+
+ if (full_path == NULL) {
+ ret = DM_ERR_COMMAND_FAILED;
+ *fumo_return = FUMO_USER_CANCELLED;
+ goto error;
+ }
+
+ sync_agent_dm_mo_error_e ext_return;
+ ext_return = sync_agent_execute_mo_ext(full_path, (int *)fumo_return, check_operation);
+ if (ext_return != SYNC_AGENT_DM_MO_SUCCESS) {
+ ret = DM_ERR_COMMAND_FAILED;
+ *fumo_return = FUMO_USER_CANCELLED;
+ goto error;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+
+ _DEBUG_INFO(" end error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR get_current_fumo_state(char *full_path, char **fumo_state_data)
+{
+ _EXTERN_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((full_path) == NULL, COMMON_ERR_IS_NULL, "full_path is NULL!!");
+
+ char *fumo_root = NULL;
+ char *fumo_state_url = NULL;
+
+ //ret = get_mo_servicetype(full_path, &fumo_root);
+ ret = get_mo_root_path(full_path, &fumo_root);
+ if (ret != DM_OK) {
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+ fumo_state_url = g_strdup_printf("%s%s", fumo_root, DM_FUMO_STATE_OP);
+
+ ret = get_mo_data(fumo_state_url, fumo_state_data);
+ if (ret != DM_OK) {
+ ret = COMMON_ERR_GET_TYPE_NOT_FOUND;
+ goto error;
+ }
+
+ str_free(&fumo_state_url);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ str_free(&fumo_state_url);
+
+ _DEBUG_INFO(" end error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR set_current_fumo_state(char *full_path, FUMO_State fumo_state)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((full_path) == NULL, COMMON_ERR_IS_NULL, "full_path is NULL!!");
+
+ char *fumo_root = NULL;
+ char *fumo_state_url = NULL;
+ char *fumo_state_data = NULL;
+
+ //ret = get_mo_servicetype(full_path, &fumo_root);
+ ret = get_mo_root_path(full_path, &fumo_root);
+ if (ret != DM_OK) {
+ goto error;
+ }
+
+ fumo_state_url = g_strdup_printf("%s%s", fumo_root, DM_FUMO_STATE_OP);
+ fumo_state_data = g_strdup_printf("%d", fumo_state);
+
+ _DEBUG_INFO(" fumo_state : %d\n", fumo_state);
+
+ //sync_agent_dm_mo_error_e mo_ret = sync_agent_begin_transaction_mo();
+ ret = replace_mo_data(fumo_state_url, fumo_state_data);
+ //mo_ret = sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_COMMIT);
+ if (ret != DM_OK)
+ goto error;
+
+ str_free(&fumo_state_url);
+ str_free(&fumo_state_data);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ str_free(&fumo_state_url);
+ str_free(&fumo_state_data);
+
+ _DEBUG_INFO(" end error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+static DM_ERROR __check_low_battery()
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ char *battery_level = 0;
+
+ ret = get_battery_state(&battery_level);
+ if (ret != DM_OK)
+ goto error;
+
+ int int_battery_level = 0;
+ if (battery_level != NULL) {
+ int err;
+ err = chartoint((battery_level), &int_battery_level);
+ if (err == 1) {
+ _DEBUG_VERBOSE("battery level : %d ", int_battery_level);
+ if (FOTA_LOW_BATTERY_LEVEL > int_battery_level) {
+ int noti_ret = 0;
+ _DEBUG_VERBOSE("batter : %s, low battery : %d", battery_level, FOTA_LOW_BATTERY_LEVEL);
+ noti_ret = noti_low_battery(battery_level);
+ _DEBUG_VERBOSE("noti low battery : %d", noti_ret);
+
+ goto error;
+ } else {
+ //do nothing
+ }
+ } else {
+ _DEBUG_VERBOSE("battery level is null");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+ } else {
+ _DEBUG_VERBOSE("battery level is null");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+ _DEBUG_VERBOSE("end");
+ return ret;
+ error:
+ _DEBUG_VERBOSE("end error : %d", DM_LOW_BATTERY_ERROR);
+ _INNER_FUNC_EXIT;
+ return DM_LOW_BATTERY_ERROR;
+}
+
+static DM_ERROR __check_memory(long double file_size, MEMORY_TYPE * is_internal_memory)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ int ipc_ret = 0;
+ int existed_sd;
+ long double need_size = file_size * 2;
+
+ ret = compare_memory_space(FOTA_DELTA_INTERNAL_STORAGE, need_size);
+
+ if (ret != DM_OK) {
+ ret = existed_sd_card_memory(&existed_sd);
+ if (existed_sd == 0 || ret != DM_OK) {
+ /* ui ->not existed sd card or make folder error */
+ ipc_ret = noti_over_max_file_size();
+ if (ipc_ret == RESPONSE_TYPE_OK) {
+ _DEBUG_VERBOSE("file size over the memory");
+ } else {
+ _DEBUG_VERBOSE("file size over the memory ipc fail");
+ }
+ _INNER_FUNC_EXIT;
+ return DM_OVER_MEMORY_ERROR;
+ }
+
+ /* ui -> do u want to use sd_card? */
+ ipc_ret = noti_memory_full((int)need_size);
+ if (ipc_ret == RESPONSE_TYPE_OK) {
+
+ //FOTA_DELTA_SD_INTERNAL_STORAGE
+ ret = compare_memory_space(FOTA_DELTA_SD_EXTERNAL_STORAGE, need_size);
+ if (ret == DM_MEMORY_ERROR) {
+ /* ui -> sd_card full */
+ ipc_ret = noti_over_max_file_size();
+ if (ipc_ret == RESPONSE_TYPE_OK) {
+ _DEBUG_VERBOSE("file size over the memory");
+ } else {
+ _DEBUG_VERBOSE("file size over the memory ipc fail");
+ }
+ _INNER_FUNC_EXIT;
+ return DM_OVER_MEMORY_ERROR;
+ } else {
+ _DEBUG_VERBOSE("save in sd memory card");
+ }
+
+ } else {
+ _DEBUG_VERBOSE("memory full ipc fail");
+ _INNER_FUNC_EXIT;
+ return DM_OVER_MEMORY_ERROR;
+ }
+ /*sd card path */
+ (*is_internal_memory) = MEMORY_SD_CARD;
+ } else {
+
+ /*internal memory path */
+ (*is_internal_memory) = MEMORY_INTERNAL;
+ }
+
+ _INNER_FUNC_EXIT;
+ return DM_OK;
+}
+
+static DM_ERROR ___get_max_file_size(int *max_file_size)
+{
+ _INNER_FUNC_ENTER;
+
+ int err = 0;
+ char *required_contents = NULL;
+ unsigned long size_return = 0;
+
+ err = sync_agent_is_existing_fs(MAX_DELTA_FILE_SIZE);
+ /*define value when this is file not existed */
+ if (err == 0) {
+ _DEBUG_VERBOSE("max file size : 50MB");
+ *max_file_size = MAX_FILE_SIZE;
+ _INNER_FUNC_EXIT;
+ return DM_OK;
+ }
+
+ /*value when this is file existed */
+ err = sync_agent_read_whole_file(MAX_DELTA_FILE_SIZE, &required_contents, &size_return);
+ if (err == 1) {
+ _DEBUG_VERBOSE("max file size : %s", required_contents);
+
+ err = chartoint(required_contents, max_file_size);
+ if (err == 1) {
+ str_free(&required_contents);
+ _INNER_FUNC_EXIT;
+ return DM_OK;
+ } else {
+ _DEBUG_VERBOSE("get max file size error");
+ _INNER_FUNC_EXIT;
+ return COMMON_ERR_IS_NULL;
+ }
+ } else {
+ _DEBUG_VERBOSE("get max file size error");
+ _INNER_FUNC_EXIT;
+ return COMMON_ERR_IS_NULL;
+ }
+ _DEBUG_VERBOSE("get max file size error");
+
+ _INNER_FUNC_EXIT;
+ return COMMON_ERR_IS_NULL;
+}
+
+static DM_ERROR __check_max_file_size(int file_size)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ int noti_res = 0;
+
+ int max_file_size = 0;
+ ret = ___get_max_file_size(&max_file_size);
+ if (ret != DM_OK) {
+ _DEBUG_VERBOSE("get max file size error");
+ ret = DM_WIFI_ONLY_ERROR;
+ goto error;
+ }
+ _DEBUG_VERBOSE("file size = %d, max file size = %d", file_size, max_file_size);
+
+ /*max_file_size = 0 (0 in file or not existed file)
+ * - can't use this option
+ * - this option is max file size define in file when 3g mode
+ */
+ if (max_file_size != 0 && file_size > max_file_size) {
+ noti_res = noti_over_max_file_size();
+ _DEBUG_VERBOSE("noti over max file size : %d", noti_res);
+
+ _DEBUG_VERBOSE("can't save current_size on 3g mode");
+ ret = DM_WIFI_ONLY_ERROR;
+ goto error;
+
+ } else {
+ _DEBUG_VERBOSE("save current size on 3g mode");
+ }
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ error:
+
+ _DEBUG_INFO("end error : %d", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
diff --git a/src/agent/dm-engine/lawmo/lawmo_account.c b/src/agent/dm-engine/lawmo/lawmo_account.c
new file mode 100644
index 0000000..e4d5469
--- /dev/null
+++ b/src/agent/dm-engine/lawmo/lawmo_account.c
@@ -0,0 +1,101 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "dm-engine/lawmo/lawmo_account.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "LAWMO_ENGINE"
+#endif
+
+int register_lawmo_account(int item_id, void *user_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = 1;
+ sync_agent_dm_mo_error_e err = 1;
+ int count = 0;
+ int value = 0;
+
+/*int db_ret = 0;
+ * db_ret = sync_agent_open_agent();
+ _DEBUG_INFO("OPEN DACI : %d", db_ret);*/
+
+ set_alarm_config_int(LAWMO_ACCOUNT_FLAG_TYPE, LAWMO_ACCOUNT_FLAG, 0, LAWMO_ENGINE);
+ value = get_config_int(LAWMO_ACCOUNT_FLAG_TYPE, LAWMO_ACCOUNT_FLAG);
+
+ _DEBUG_INFO("lawmo account flag : %d ", value);
+
+ if (value != 1) {
+ do {
+ err = sync_agent_initialize_mo(7);
+ if (err == SYNC_AGENT_DM_MO_FAIL) {
+ _DEBUG_INFO("fail register lawmo account : %d ", err);
+ ret = 0;
+ } else {
+ _DEBUG_INFO("success register lawmo account : %d ", err);
+ break;
+ }
+ count++;
+ } while (err == SYNC_AGENT_DM_MO_FAIL && count < 3);
+
+ if (err == SYNC_AGENT_DM_MO_FAIL) {
+ _DEBUG_INFO("add lawmo account registration alarm : %d ", ret);
+ ret = set_account_registration_alarm(LAWMO_ACCOUNT_ALARM, LAWMO_ACCOUNT_ALARM_TYPE);
+ _DEBUG_INFO("set account registration alarm lawmo account : %d ", ret);
+ ret = 0;
+ } else {
+ ret = set_config_int(LAWMO_ACCOUNT_FLAG_TYPE, LAWMO_ACCOUNT_FLAG, 1, LAWMO_ENGINE, 0);
+ _DEBUG_INFO("add lawmo account flag type setting result : %d ", ret);
+ delete_account_registration_alarm(LAWMO_ACCOUNT_ALARM, LAWMO_ACCOUNT_ALARM_TYPE);
+ _DEBUG_INFO("delete lawmo account delete alarm");
+ }
+ } else {
+ //do nothing
+ }
+
+/* db_ret = sync_agent_close_agent();
+ _DEBUG_INFO("CLOSE DACI : %d", db_ret);*/
+
+ _DEBUG_INFO("end : %d", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+int deregister_lawmo_account(int item_id, void *user_data)
+{
+ _EXTERN_FUNC_ENTER;
+ int ret = 1;
+
+ ret = sync_agent_open_agent();
+ _DEBUG_INFO("OPEN DACI : %d", ret);
+
+ //set_alarm_config_int(LAWMO_ACCOUNT_FLAG_TYPE, LAWMO_ACCOUNT_FLAG, 0, LAWMO_ENGINE);
+ set_config_int(LAWMO_ACCOUNT_FLAG_TYPE, LAWMO_ACCOUNT_FLAG, 0, LAWMO_ENGINE, 0);
+ _DEBUG_INFO("lawmo account flag 0");
+
+ ret = sync_agent_close_agent();
+ _DEBUG_INFO("CLOSE DACI : %d", ret);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
diff --git a/src/agent/dm-engine/lawmo/lawmo_engine.c b/src/agent/dm-engine/lawmo/lawmo_engine.c
new file mode 100644
index 0000000..06a5476
--- /dev/null
+++ b/src/agent/dm-engine/lawmo/lawmo_engine.c
@@ -0,0 +1,352 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*common*/
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "dm-engine/lawmo/lawmo_engine.h"
+#include "dm-engine/dm_common_engine.h"
+#include "mo-handler/dm_mo_common.h"
+#include "mo-handler/dm_mo_handler.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "LAWMO_ENGINE"
+#endif
+
+static DM_ERROR _lawmo_fullylock(LAWMO_Result_code * lawmo_return);
+static DM_ERROR _lawmo_partiallylock(LAWMO_Result_code * lawmo_return);
+static DM_ERROR _lawmo_unlock(LAWMO_Result_code * lawmo_return);
+static DM_ERROR _lawmo_factoryreset(LAWMO_Result_code * lawmo_return);
+static DM_ERROR _lawmo_wipe(LAWMO_Result_code * lawmo_return);
+static DM_ERROR _vendor_dependency_lawmo_operation(char *full_path, LAWMO_Result_code * lawmo_return, int check_operation);
+
+DM_ERROR lawmo_exec(char *full_path, char *correlator, LAWMO_Result_code * lawmo_return, int check_operation)
+{
+
+ _DEBUG_INFO(" start\n");
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((full_path) == NULL, COMMON_ERR_IS_NULL, "full_path is NULL!!");
+
+ char *result_mo_type = NULL;
+ /*LAWMO_State lawmo_state ; */
+
+ ret = get_mo_operationtype(full_path, &result_mo_type);
+ //ret = get_mo_root_path(full_path, &result_mo_type);
+ if (ret != DM_OK)
+ goto error;
+
+ if (strcmp(result_mo_type, DM_LAWMO_OPERATIONS_FULLYLOCK_OP) == 0) {
+ if (check_operation == NON_CHECK_OPERATION) { //async
+ ret = _lawmo_fullylock(lawmo_return);
+ if (ret != DM_OK)
+ goto error;
+ if ((*lawmo_return) == OPERATION_SUCCEEDED) {
+ ret = set_current_lawmo_state(full_path, FULLY_LOCKED);
+ if (ret != DM_OK)
+ goto error;
+ }
+ }
+ } else if (strcmp(result_mo_type, DM_LAWMO_OPERATIONS_PARTIALLYLOCK_OP) == 0) {
+ if (check_operation == NON_CHECK_OPERATION) { //async
+ ret = _lawmo_partiallylock(lawmo_return);
+ if (ret != DM_OK)
+ goto error;
+ if ((*lawmo_return) == OPERATION_SUCCEEDED) {
+ ret = set_current_lawmo_state(full_path, PARTIALLY_LOCKED);
+ if (ret != DM_OK)
+ goto error;
+ }
+ }
+ } else if (strcmp(result_mo_type, DM_LAWMO_OPERATIONS_UNLOCK_OP) == 0) {
+ if (check_operation == NON_CHECK_OPERATION) { //async
+ ret = _lawmo_unlock(lawmo_return);
+ if (ret != DM_OK)
+ goto error;
+ if ((*lawmo_return) == OPERATION_SUCCEEDED) {
+ ret = set_current_lawmo_state(full_path, UNLOCKED);
+ if (ret != DM_OK)
+ goto error;
+ }
+ }
+ } else if (strcmp(result_mo_type, DM_LAWMO_OPERATIONS_FACTORYRESET_OP) == 0) {
+ if (check_operation == NON_CHECK_OPERATION) { //async
+ ret = _lawmo_factoryreset(lawmo_return);
+ if (ret != DM_OK)
+ goto error;
+ }
+ } else if (strcmp(result_mo_type, DM_LAWMO_OPERATIONS_WIPE_OP) == 0) {
+ if (check_operation == NON_CHECK_OPERATION) { //async
+ ret = _lawmo_wipe(lawmo_return);
+ if (ret != DM_OK)
+ goto error;
+ }
+ } else {
+ //1 : this is just available operation
+ ret = _vendor_dependency_lawmo_operation(full_path, lawmo_return, check_operation);
+ //*lawmo_return = 1200;
+ if (ret != DM_OK)
+ goto error;
+
+ }
+
+ str_free(&result_mo_type);
+ _DEBUG_INFO(" end\n");
+ return ret;
+ error:
+ str_free(&result_mo_type);
+ _DEBUG_INFO(" end error : %d \n", ret);
+ return ret;
+}
+
+/*this is oma dm spec function but this is not used slp phone.*/
+static DM_ERROR _lawmo_fullylock(LAWMO_Result_code * lawmo_return)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+/* (*lawmo_return) = OPERATION_SUCCEEDED;
+
+ sync_agent_dev_return_e error = 0;
+ //error = sync_agent_execute_dev_function(2, "full_lock", 0);
+
+ if(error == 1 ) {
+ (*lawmo_return) = OPERATION_SUCCEEDED;
+ } else {
+ (*lawmo_return) = FULLY_LOCK_DEVICE_FAILED;
+ ret = FULLY_LOCK_DEVICE_FAILED;
+ goto error;
+ }*/
+ /*this is oma dm spec function but this is not used slp phone. */
+ /*not use this function so fail return */
+ (*lawmo_return) = FULLY_LOCK_DEVICE_FAILED;
+ ret = FULLY_LOCK_DEVICE_FAILED;
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+}
+
+/*this is oma dm spec function but this is not used slp phone.*/
+static DM_ERROR _lawmo_partiallylock(LAWMO_Result_code * lawmo_return)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+/* (*lawmo_return) = OPERATION_SUCCEEDED;
+
+ sync_agent_dev_return_e error =0;
+ //error = sync_agent_execute_dev_function(2, "partial_lock", 0);
+
+ if(error == 1 ) {
+ (*lawmo_return) = OPERATION_SUCCEEDED;
+ } else {
+ (*lawmo_return) = PARTIALLY_LOCK_DEVICE_FAILED;
+ ret = PARTIALLY_LOCK_DEVICE_FAILED;
+ goto error;
+ }*/
+
+ /*not use this function so fail return */
+ (*lawmo_return) = PARTIALLY_LOCK_DEVICE_FAILED;
+ ret = PARTIALLY_LOCK_DEVICE_FAILED;
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+}
+
+/*this is oma dm spec function but this is not used slp phone.*/
+static DM_ERROR _lawmo_unlock(LAWMO_Result_code * lawmo_return)
+{
+ _INNER_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+/* (*lawmo_return) = OPERATION_SUCCEEDED;
+
+ sync_agent_dev_return_e error = 0;
+ //error = sync_agent_execute_dev_function(2, "unlock", 0);
+
+ if(error == 1) {
+ (*lawmo_return) = OPERATION_SUCCEEDED;
+ } else {
+ (*lawmo_return) = UNLOCK_DEVICE_FAILED;
+ ret = UNLOCK_DEVICE_FAILED;
+ goto error;
+ }*/
+
+ /*not use this function so fail return */
+ (*lawmo_return) = UNLOCK_DEVICE_FAILED;
+ ret = UNLOCK_DEVICE_FAILED;
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+}
+
+/*this is oma dm spec function but this is not used slp phone.*/
+static DM_ERROR _lawmo_factoryreset(LAWMO_Result_code * lawmo_return)
+{
+ _INNER_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+/* (*lawmo_return) = OPERATION_SUCCEEDED;
+
+ sync_agent_dev_return_e error = 0;
+ //error = sync_agent_execute_dev_function(2, "factory_reset", 0);
+
+ if(error == 1) {
+ (*lawmo_return) = OPERATION_SUCCEEDED;
+ } else {
+ (*lawmo_return) = WIPE_DEVICES_DATA_FAILED;
+ ret = WIPE_DEVICES_DATA_FAILED;
+ goto error;
+ }*/
+
+ /*not use this function so fail return */
+ (*lawmo_return) = WIPE_DEVICES_DATA_FAILED;
+ ret = WIPE_DEVICES_DATA_FAILED;
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+}
+
+/*this is oma dm spec function but this is not used slp phone.*/
+static DM_ERROR _lawmo_wipe(LAWMO_Result_code * lawmo_return)
+{
+ _INNER_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+ /*(*lawmo_return) = OPERATION_SUCCEEDED;
+ sync_agent_dev_return_e error = 0;
+ //error = sync_agent_execute_dev_function(2, "factory_reset", 0);
+
+ if(error == 1) {
+ (*lawmo_return) = OPERATION_SUCCEEDED;
+ } else {
+ (*lawmo_return) = WIPE_DEVICES_DATA_FAILED;
+ ret = WIPE_DEVICES_DATA_FAILED;
+ goto error;
+ } */
+
+ /*not use this function so fail return */
+ (*lawmo_return) = WIPE_DEVICES_DATA_FAILED;
+ ret = WIPE_DEVICES_DATA_FAILED;
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+}
+
+static DM_ERROR _vendor_dependency_lawmo_operation(char *full_path, LAWMO_Result_code * lawmo_return, int check_operation)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ sync_agent_dm_mo_error_e ext_return;
+ ext_return = sync_agent_execute_mo_ext(full_path, (int *)lawmo_return, check_operation);
+ _DEBUG_TRACE("ext_return : %d", ext_return);
+ if (ext_return != SYNC_AGENT_DM_MO_SUCCESS) {
+ ret = DM_ERR_COMMAND_FAILED;
+ goto error;
+ }
+
+ _INNER_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_TRACE(" end error : %d \n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR get_current_lawmo_state(char *full_path, char **lawmo_state_data)
+{
+ _INNER_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((full_path) == NULL, COMMON_ERR_IS_NULL, "full_path is NULL!!");
+
+ char *lawmo_root = NULL;
+ char *lawmo_state_url = NULL;
+ //ret = get_mo_servicetype(full_path, &lawmo_root);
+ ret = get_mo_root_path(full_path, &lawmo_root);
+ if (ret != DM_OK) {
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+ lawmo_state_url = g_strdup_printf("%s%s", lawmo_root, DM_LAWMO_STATE_OP);
+
+ ret = get_mo_data(lawmo_state_url, lawmo_state_data);
+ if (ret != DM_OK) {
+ ret = COMMON_ERR_GET_TYPE_NOT_FOUND;
+ goto error;
+ }
+
+ str_free(&lawmo_state_url);
+ _INNER_FUNC_EXIT;
+ return ret;
+ error:
+ str_free(&lawmo_state_url);
+ _DEBUG_INFO(" end error : %d\n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR set_current_lawmo_state(char *full_path, LAWMO_State lawmo_state)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((full_path) == NULL, COMMON_ERR_IS_NULL, "full_path is NULL!!");
+
+ char *lawmo_root = NULL;
+ char *lawmo_state_url = NULL;
+ char *lawmo_state_data = NULL;
+
+ //ret = get_mo_servicetype(full_path, &lawmo_root);
+ ret = get_mo_root_path(full_path, &lawmo_root);
+ if (ret != DM_OK) {
+ goto error;
+ }
+
+ lawmo_state_url = g_strdup_printf("%s%s", lawmo_root, DM_LAWMO_STATE_OP);
+ lawmo_state_data = g_strdup_printf("%d", lawmo_state);
+
+ _DEBUG_INFO(" fumo_state : %d\n", lawmo_state);
+ ret = replace_mo_data(lawmo_state_url, lawmo_state_data);
+ if (ret != DM_OK)
+ goto error;
+
+ str_free(&lawmo_state_url);
+ str_free(&lawmo_state_data);
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ error:
+ str_free(&lawmo_state_url);
+ str_free(&lawmo_state_data);
+ _DEBUG_INFO(" end error : %d\n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
diff --git a/src/agent/framework/platform-event-handler/dm_platform_event_handler.c b/src/agent/framework/platform-event-handler/dm_platform_event_handler.c
new file mode 100755
index 0000000..c91a434
--- /dev/null
+++ b/src/agent/framework/platform-event-handler/dm_platform_event_handler.c
@@ -0,0 +1,973 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+#include <plugin/plugin_slp_sysnoti_wap_push.h>
+
+/*common*/
+#include "common/dm_common_def.h"
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "framework/task/oma_dm_task_request.h"
+#include "framework/platform-event-handler/dm_platform_event_handler.h"
+#include "framework/san-parser/pm_sanparser.h"
+#include "dm-engine/fumo/fumo_account.h"
+#include "dm-engine/fumo/fumo_engine.h"
+#include "dm-engine/lawmo/lawmo_account.h"
+#include "dm-engine/lawmo/lawmo_engine.h"
+#include "dm-engine/cp/dm_cp_processor.h"
+#include "dm-engine/cp/dm_cp_security.h"
+#include "mo-handler/dm_mo_common.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_CP_PEH"
+#endif
+
+static DM_ERROR _fumo_interval_alarm(int item_id);
+static DM_ERROR _fumo_account_registration_alarm(int item_id);
+static DM_ERROR _lawmo_account_registration_alarm(int item_id);
+static DM_ERROR _send_event_ds(char *event_msg);
+static int _dm_notification_operation(const char *out_message, unsigned int outlen);
+
+static int _dm_notification_operation(const char *out_message, unsigned int outlen)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((out_message) == NULL, COMMON_ERR_IS_NULL, "out_message is NULL!!");
+
+ SanPackage *pSanPackage = NULL;
+ Event_Contents *ev_data = NULL;
+ int is_exist = 0;
+ pSanPackage = sanpackage_noti_parser((char *)out_message, outlen);
+ if (pSanPackage != NULL) {
+ ev_data = (Event_Contents *) calloc(1, sizeof(Event_Contents));
+ if (ev_data == NULL) {
+ _DEBUG_TRACE("calloc failed !!");
+ free_sanpackageparser(pSanPackage);
+ return COMMON_ERR_ALLOC;
+ }
+ ev_data->type = IP_PUSH_EVENT;
+ if ((pSanPackage->sessionID) == NULL || (pSanPackage->serverID) == NULL) {
+ _DEBUG_TRACE("san message null");
+ goto error;
+ }
+ ev_data->session_id = strdup((char *)pSanPackage->sessionID);
+ ev_data->server_id = strdup((char *)pSanPackage->serverID);
+ ev_data->noti_type = pSanPackage->uiMode;
+
+ _DEBUG_TRACE("event type ip push : %d", ev_data->type);
+ _DEBUG_TRACE("session id : %s", ev_data->session_id);
+ _DEBUG_TRACE("server id : %s", ev_data->server_id);
+ _DEBUG_TRACE("noti type : %d", ev_data->noti_type);
+
+ /* UI CONFIRM */
+ SERVICE_SERVER_TYPE engine_type;
+ engine_type = get_service_engine_type(ev_data->server_id);
+ _DEBUG_TRACE("engine type : %d", engine_type);
+
+ switch (engine_type) {
+ case SAMSUNG_FUMO_TYPE:
+ {
+ /*
+ * check samsung dm acc
+ */
+ ret = is_exist_dmacc(SAMSUNG_FUMO_TYPE, &is_exist);
+ if (ret != DM_OK || is_exist == 0) {
+ _DEBUG_TRACE("is exist dmacc error : %d or not exist dm acc : %d", ret, is_exist);
+ goto error;
+ }
+
+ ret = fumo_service_start(ev_data);
+ if (ret != DM_OK)
+ goto error;
+ }
+ break;
+ case GCF_TYPE:
+ {
+ /*
+ * check gcf dm acc
+ */
+ ret = is_exist_dmacc(GCF_TYPE, &is_exist);
+ if (ret != DM_OK || is_exist == 0) {
+ _DEBUG_TRACE("is exist dmacc error : %d or not exist dm acc : %d", ret, is_exist);
+ goto error;
+ }
+
+ ret = fumo_service_start(ev_data);
+ if (ret != DM_OK)
+ goto error;
+ }
+ break;
+ case SAMSUNG_FMM_TYPE:
+ {
+
+ /*
+ * check gcf dm acc
+ */
+ ret = is_exist_dmacc(SAMSUNG_FMM_TYPE, &is_exist);
+ if (ret != DM_OK || is_exist == 0) {
+ _DEBUG_TRACE("is exist dmacc error : %d or not exist dm acc : %d", ret, is_exist);
+ goto error;
+ }
+
+ ret = dm_lawmo_common_task_request(ev_data);
+ if (ret != DM_OK)
+ goto error;
+
+ }
+ break;
+ default:
+ _DEBUG_TRACE("dm non engine ", ret);
+ break;
+ }
+
+ } else {
+ _DEBUG_TRACE("san message null");
+ goto error;
+ }
+
+ free_sanpackageparser(pSanPackage);
+ _INNER_FUNC_EXIT;
+ return 1;
+
+ error:
+ event_data_free((void *)ev_data);
+ free_sanpackageparser(pSanPackage);
+ _INNER_FUNC_EXIT;
+ _DEBUG_INFO("end error");
+ return 0;
+}
+
+int dm_wap_push_incomming_callback(int item_id, void *user_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((user_data) == NULL, -1, "user_data is NULL!!");
+
+ pmci_san_incoming_s *incomming_struct = (pmci_san_incoming_s *) user_data;
+ if (incomming_struct != NULL) {
+ /* db open */
+ int db_ret = 0;
+ db_ret = sync_agent_open_agent();
+ _DEBUG_INFO("OPEN DACI : %d", db_ret);
+
+ /* generate ext_id */
+ int ext_id = -1;
+ char **ext_id_list = NULL;
+ while (1) {
+ ext_id_list = sync_agent_generate_item_luid(1, 1);
+ if (ext_id_list == NULL) {
+ ret = -1;
+ return ret;
+ }
+ ext_id = atoi(ext_id_list[0]);
+ _DEBUG_INFO("ext_id : %d", ext_id);
+
+ /* create folder for generated ext_id */
+ char folder_name[50] = { 0, };
+ snprintf(folder_name, sizeof(folder_name), "%s/%d", CP_DATA_REPOSITORY_PATH, ext_id);
+ _DEBUG_INFO("folder name : %s", folder_name);
+
+ int folder_ret = sync_agent_create_directory(folder_name);
+ if (folder_ret != 1) {
+ _DEBUG_INFO("sync_agent_create_directory( ext_id : %d ) failed !!", ext_id);
+ _DEBUG_INFO("retry sync_agent_generate_item_luid() !!");
+// return DM_ERR_UNKNOWN;
+ if (ext_id_list[0] != NULL)
+ free(ext_id_list[0]);
+
+ if (ext_id_list != NULL)
+ free(ext_id_list);
+
+ ext_id = -1;
+ ext_id_list = NULL;
+ } else {
+ _DEBUG_INFO("sync_agent_create_directory( ext_id : %d ) success !!", ext_id);
+ if (ext_id_list[0] != NULL)
+ free(ext_id_list[0]);
+
+ if (ext_id_list != NULL)
+ free(ext_id_list);
+
+ break;
+ }
+ }
+
+ db_ret = sync_agent_close_agent();
+ _DEBUG_INFO("CLOSE DACI : %d", db_ret);
+
+ // switch( version )
+ switch (incomming_struct->version) {
+ case 13: /*SAN_DM_XML = 13 */
+ {
+ /*pSanPackage = sanPackage11Parser( msgBody, msgSize ) ; */
+ }
+ break;
+ case 14: /*SAN_DM_WBXML = 14 */
+ {
+ /*pSanPackage = sanPackage12Parser( msgBody, msgSize ) ; */
+ }
+ break;
+ case 15: /*SAN_DM_NOTI = 15 */
+ {
+ int result = _dm_notification_operation(incomming_struct->msg_body, incomming_struct->msg_size);
+ _DEBUG_INFO("wap push parser : %d", result);
+ }
+ break;
+ case 16: /*SAN_CP_XML = 16 */
+ {
+ // CP_ERROR result = process_Recieved_CP_XML(msgBody, msgSize);
+ CP_ERROR result = process_Recieved_CP_XML(incomming_struct->msg_body, incomming_struct->msg_size, ext_id);
+ _DEBUG_INFO("xml cp parser : %d", result);
+ }
+ break;
+ case 17: /*SAN_CP_WBXML = 17 */
+ {
+ // CP_ERROR result = process_Recieved_CP_WBXML(msgBody, msgSize);
+ CP_ERROR result = process_Recieved_CP_WBXML(incomming_struct->msg_body, incomming_struct->msg_size, ext_id);
+ _DEBUG_INFO("wxml cp parser : %d", result);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ _DEBUG_INFO("end");
+
+ if (ret == DM_OK)
+ ret = 1;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+int dm_wap_push_operation_callback(int item_id, void *user_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((user_data) == NULL, -1, "user_data is NULL!!");
+
+ CP_ERROR err = CP_ERROR_SUCCESS;
+
+ pmci_san_operation_s *operation_struct = (pmci_san_operation_s *) user_data;
+ if (operation_struct != NULL) {
+
+ process_Set_msgId(operation_struct->msg_id);
+ _DEBUG_INFO("msg id : %d", operation_struct->msg_id);
+ _DEBUG_INFO("ext id : %d", operation_struct->ext_id);
+
+ if (operation_struct->msg_id == -1 && operation_struct->ext_id == -1) { // delete all
+ _DEBUG_INFO("operation : delete all !!");
+
+ err = process_Delete_All_CP_Data();
+ if (err != CP_ERROR_SUCCESS) {
+ _DEBUG_INFO("process_Delete_All_CP_Data() fail !!");
+ // ret = DM_ERR_CP
+ goto return_part;
+ } else {
+ _DEBUG_INFO("process_Delete_All_CP_Data() success !!");
+ }
+ } else if (operation_struct->msg_id == -1 && operation_struct->ext_id != -1) { // delete 1 msg
+ _DEBUG_INFO("operation : delete 1 msg !!");
+
+ err = process_Delete_CP_Data(operation_struct->ext_id);
+ if (err != CP_ERROR_SUCCESS) {
+ _DEBUG_INFO("process_Delete_CP_Data() fail !!");
+ // ret = DM_ERR_CP
+ goto return_part;
+ } else {
+ _DEBUG_INFO("process_Delete_CP_Data() success !!");
+ }
+ } else { // install
+ _DEBUG_INFO("operation : install !!");
+
+ int is_correct = -1;
+ err = process_Check_Pincode(1, NULL, &is_correct, operation_struct->ext_id);
+ if (err != CP_ERROR_SUCCESS) {
+ _DEBUG_INFO("process_Check_Pincode() fail !!");
+ // ret = DM_ERR_CP
+ goto return_part;
+ } else {
+ _DEBUG_INFO("process_Check_Pincode() success !!");
+
+ /* process_Setting_CP() */
+ if (is_correct == 1) {
+ _DEBUG_INFO("NETWPIN case - Valid PIN !!");
+
+ err = process_Setting_CP(operation_struct->ext_id);
+ if (err != CP_ERROR_SUCCESS) {
+ _DEBUG_INFO("process_Setting_CP() fail !!");
+ goto return_part;
+ } else {
+ _DEBUG_INFO("process_Setting_CP() success !!");
+ }
+ } else if (is_correct == 0) {
+ _DEBUG_INFO("NETWPIN case - Invalid PIN !!");
+ err = CP_ERROR_FAIL;
+ }
+ }
+ }
+ }
+
+ return_part:
+ if (operation_struct != NULL)
+ free(operation_struct);
+
+ if (ret == DM_OK)
+ ret = 1;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+int dm_ip_push_callback(int item_id, void *user_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((user_data) == NULL, -1, "user_data is NULL!!");
+
+ OPER_MODE operationMode;
+ operationMode = OPER_SERVER_INITIATION_FROM_IP;
+ char *pushmessage = NULL;
+ //ip_push_struct->message = strdup("IPP_20111216000000000000000001|DM|Ft4/CLTiWx/Y0AK+fBIayALoAAAAlPcKeDZnMXExNHI3NQ==");
+
+ pushmessage = (char *)user_data;
+
+ _DEBUG_INFO("user_data : %s", (char *)user_data);
+ _DEBUG_INFO("push contents : %s", pushmessage);
+
+ if (pushmessage != NULL) {
+ char *app_type = strchr(pushmessage, '|') + 1;
+ char *message = NULL;
+ message = strstr(app_type, "DS|");
+
+ if (message != NULL) {
+ _DEBUG_INFO("DS event : %s", message);
+ ret = _send_event_ds(message);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ }
+
+ message = strchr(app_type, '|') + 1;
+ _DEBUG_INFO("message :%s", message);
+
+ unsigned int outlen = 0;
+ unsigned char *out_message = g_base64_decode(message, &outlen);
+
+ int result = _dm_notification_operation((const char *)out_message, outlen);
+ _DEBUG_INFO("ip push parser : %d", result);
+
+ } else {
+ _DEBUG_INFO("push message null");
+ //do nothing
+ goto error;
+ }
+
+ str_free(&pushmessage);
+
+ if (ret == DM_OK) {
+ ret = 1;
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+
+ error:
+ str_free(&pushmessage);
+
+ _EXTERN_FUNC_EXIT;
+ _DEBUG_INFO("end error ");
+ return ret;
+
+}
+
+int dm_telephony_incomming_callback(int item_id, void *user_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO("----------------------------------------------------incomming tel----------------------------------------------------");
+
+ DM_ERROR ret = DM_OK;
+ int is_exist = 0;
+ engine_status *status = NULL;
+
+ /*ret = DB_Open();
+ _DEBUG_INFO("dm db open = %d", ret); */
+
+ is_exist = IsExist_Engine_id(FUMO_SERVICE_ENGINE);
+ _DEBUG_INFO("is engine : %d", is_exist);
+
+ if (is_exist != 0) {
+ ret = Get_Engine_Status(FUMO_SERVICE_ENGINE, &status);
+ if (ret != DM_OK)
+ goto error;
+
+ if (status != NULL) {
+ if (status->ui_mode != NULL) {
+ if (strcmp(status->ui_mode, OMADM_FUMO_BACKGROUND_UI_TYPE) != 0) {
+
+ if (status->engine_status == DM_SERVICE_ING || status->engine_status == DM_SERVICE_UNKNOWN) {
+ _DEBUG_INFO("cancel fumo task id = %d ", status->task_id);
+ cancel_task(status->task_id);
+ _DEBUG_INFO("terminate ui");
+ terminate_oma_dm_ui(DM_ERR_NOT_FOUND, FUMO_SERVICE_ENGINE);
+ } else {
+ /*do nothing */
+ }
+ } else {
+ /*do nothing */
+ _DEBUG_INFO("back ground ui");
+ }
+ } else {
+ /*do nothing */
+ }
+ } else {
+ /*do nothing */
+ }
+ } else {
+ /*do nothing */
+ }
+ /*sleep(1);
+ DB_Close(); */
+ if (status != NULL) {
+ Free_Memory_Engine_Status(&status, 1);
+ }
+
+ if (ret == DM_OK) {
+ ret = 1;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ error:
+ /*sleep(1);
+ DB_Close(); */
+ if (status != NULL) {
+ Free_Memory_Engine_Status(&status, 1);
+ }
+ _DEBUG_INFO("ERROR END = %d", ret);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+int dm_telephony_end_callback(int item_id, void *user_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO("----------------------------------------------------end tel----------------------------------------------------");
+
+ DM_ERROR ret = DM_OK;
+ sync_agent_da_return_e err = SYNC_AGENT_DA_SUCCESS;
+
+ engine_status *status = NULL;
+ int is_exist = 0;
+ int is_alarm = 0;
+ char *server_id = NULL;
+
+ /*ret = DB_Open();
+ _DEBUG_INFO("dm db open = %d", ret);
+ */
+ err = sync_agent_open_agent();
+ _DEBUG_INFO("sync agent db open = %d", ret);
+
+ is_exist = IsExist_Engine_id(FUMO_SERVICE_ENGINE);
+ _DEBUG_INFO("is engine : %d", is_exist);
+ if (is_exist == 0) {
+ sleep(1);
+ //DB_Close();
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ }
+
+ ret = Get_Engine_Status(FUMO_SERVICE_ENGINE, &status);
+ if (ret != DM_OK) {
+ sleep(1);
+ //DB_Close();
+ _DEBUG_INFO("sync agent db close = %d", ret);
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ }
+
+ if (status != NULL && status->ui_mode != NULL) {
+ if (!strcmp(status->ui_mode, OMADM_FUMO_BACKGROUND_UI_TYPE)) {
+
+ is_alarm = check_existed_fumo_reminder_interval();
+ if (is_alarm == 1) {
+ _DEBUG_INFO("have alarm");
+ } else {
+ sleep(5);
+
+ ret = get_Serverid(SAMSUNG_FUMO_TYPE, &server_id);
+ if (ret != DM_OK) {
+ sleep(1);
+ //DB_Close();
+ err = sync_agent_close_agent();
+ _DEBUG_INFO("sync agent db close = %d", ret);
+ Free_Memory_Engine_Status(&status, 1);
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ }
+
+ if (server_id != NULL) {
+ //current time > alarm time
+ Event_Contents *ev_data = (Event_Contents *) calloc(1, sizeof(Event_Contents));
+ ev_data->type = UI_EVENT;
+ ev_data->session_id = NULL;
+ ev_data->server_id = server_id;
+ ev_data->noti_type = NOTI_TYPE_USERINTERACTION;
+ ev_data->ui_mode = strdup(OMADM_FUMO_NOTI_UI_TYPE);
+
+ ret = dm_fumo_common_task_request(ev_data);
+ if (ret != DM_OK) {
+ //DB_Close();
+ err = sync_agent_close_agent();
+ _DEBUG_INFO("sync agent db close = %d", ret);
+ Free_Memory_Engine_Status(&status, 1);
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ }
+ } else {
+ _DEBUG_INFO("server id is null");
+ }
+ }
+ }
+ }
+
+ if (ret == DM_OK) {
+ ret = 1;
+ }
+
+ sleep(1);
+ //DB_Close();
+ err = sync_agent_close_agent();
+ _DEBUG_INFO("sync agent db close = %d", ret);
+ Free_Memory_Engine_Status(&status, 1);
+
+ _EXTERN_FUNC_EXIT;
+ return 1;
+}
+
+int network_on_callback()
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("network on");
+ _EXTERN_FUNC_EXIT;
+ return 1;
+}
+
+int network_off_callback()
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("network off");
+ _EXTERN_FUNC_EXIT;
+ return 1;
+}
+
+int network_change_callback()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = 0;
+ _DEBUG_INFO("changed network");
+
+ ret = 1;
+/*for prevent*/
+/*
+ * int config = 0;
+
+ //each company's
+ //check alarm
+
+ if(config == 0) {
+ _DEBUG_INFO("wifi only off mode download");
+ } else if (config == 1) {
+ ret = get_wifi_state();
+ _DEBUG_INFO("wifi only mode : %d", ret);
+ if (ret != SYNC_AGENT_NA_SUCCESS) {
+ return 0;
+ }
+
+ ret = auto_operate_service_engine();
+ if(ret !=DM_OK ) {
+ _DEBUG_INFO("error : %d", ret);
+ return 0;
+ }
+ }*/
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+int alarm_callback(int item_id, void *user_data)
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("#######Scheduler Send Msg Success!!!!!########## : %d", item_id);
+
+ DM_ERROR ret = DM_OK;
+ int value = -1;
+ int count = 0;
+
+ int exist = 0;
+ sync_agent_da_return_e result = SYNC_AGENT_DA_SUCCESS;
+ sync_agent_da_config_s *config = NULL;
+ GList *list = NULL;
+
+ int db_ret = 0;
+ db_ret = sync_agent_open_agent();
+
+ result = sync_agent_is_exist_config(FUMO_INTERVAL_TYPE, FUMO_INTERVAL, &exist);
+ if (result != SYNC_AGENT_DA_SUCCESS) {
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+
+ _DEBUG_INFO("exist : %d", exist);
+
+ if (exist != 0) {
+ result = sync_agent_get_config_list(FUMO_INTERVAL_TYPE, &list);
+ count = g_list_length(list);
+ _DEBUG_INFO("count : %d", count);
+ if (count != 0 && list != NULL) {
+ config = (sync_agent_da_config_s *) g_list_nth_data(list, 0);
+ if (chartoint(config->value, &value) == 1) {
+ if (value == item_id) {
+ ret = _fumo_interval_alarm(item_id);
+ if (ret != DM_OK) {
+ sync_agent_free_config_list(list);
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+ }
+ }
+ }
+ count = 0;
+ value = -1;
+ sync_agent_free_config_list(list);
+ list = NULL;
+ } else {
+
+ result = sync_agent_remove_service_data(1, item_id);
+ _DEBUG_INFO("delete alarm %d", result);
+
+ }
+
+ result = sync_agent_is_exist_config(FUMO_ACCOUNT_ALARM_TYPE, FUMO_ACCOUNT_ALARM, &exist);
+ if (result != SYNC_AGENT_DA_SUCCESS) {
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+
+ _DEBUG_INFO("exist : %d", exist);
+
+ if (exist != 0) {
+ result = sync_agent_get_config_list(FUMO_ACCOUNT_ALARM_TYPE, &list);
+ count = g_list_length(list);
+ _DEBUG_INFO("count : %d", count);
+ if (count != 0 && list != NULL) {
+ config = (sync_agent_da_config_s *) g_list_nth_data(list, 0);
+ if (chartoint(config->value, &value) == 1) {
+ if (value == item_id) {
+ ret = _fumo_account_registration_alarm(item_id);
+ if (ret != DM_OK) {
+ sync_agent_free_config_list(list);
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+ }
+ }
+ }
+ count = 0;
+ value = -1;
+ sync_agent_free_config_list(list);
+ list = NULL;
+ }
+
+ result = sync_agent_is_exist_config(LAWMO_ACCOUNT_ALARM_TYPE, LAWMO_ACCOUNT_ALARM, &exist);
+ if (result != SYNC_AGENT_DA_SUCCESS) {
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+
+ _DEBUG_INFO("exist : %d", exist);
+
+ if (exist != 0) {
+ result = sync_agent_get_config_list(LAWMO_ACCOUNT_ALARM_TYPE, &list);
+ count = g_list_length(list);
+ _DEBUG_INFO("count : %d", count);
+ if (count != 0 && list != NULL) {
+ config = (sync_agent_da_config_s *) g_list_nth_data(list, 0);
+ if (chartoint(config->value, &value) == 1) {
+ if (value == item_id) {
+ ret = _lawmo_account_registration_alarm(item_id);
+ if (ret != DM_OK) {
+ sync_agent_free_config_list(list);
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+ }
+ }
+ }
+ count = 0;
+ value = -1;
+ sync_agent_free_config_list(list);
+ list = NULL;
+ }
+
+ db_ret = sync_agent_close_agent();
+ _DEBUG_INFO("CLOSE DACI : %d", db_ret);
+
+ _EXTERN_FUNC_EXIT;
+ return 1;
+}
+
+static DM_ERROR _fumo_interval_alarm(int item_id)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ char *server_id = NULL;
+ engine_status *status = NULL;
+ Event_Contents *ev_data = NULL;
+ int is_exist = 0;
+
+ ret = DB_Open();
+ _DEBUG_TRACE("status db : %d", ret);
+
+ /*
+ * check samsung dm acc
+ */
+ ret = is_exist_dmacc(SAMSUNG_FUMO_TYPE, &is_exist);
+ if (ret != DM_OK || is_exist == 0) {
+ _DEBUG_TRACE("is exist dmacc error : %d or not exist dm acc : %d", ret, is_exist);
+ goto error;
+ }
+
+ if (IsExist_Engine_id(FUMO_SERVICE_ENGINE) != 0) {
+ ret = Get_Engine_Status(FUMO_SERVICE_ENGINE, &status);
+ if (ret != DM_OK)
+ goto error;
+
+ _DEBUG_TRACE(" result =[%d]\n", ret);
+ /*update engine_status */
+ if (status != NULL) {
+ if (status->server_id != NULL) {
+ server_id = strdup(status->server_id);
+ }
+
+ status->engine_status = DM_SERVICE_ING;
+ if (status->download_click == RESUME_STATUS_INSTALL_IDLE) {
+ status->download_click = RESUME_STATUS_INSTALL;
+ } else if (status->download_click == RESUME_STATUS_DOWNLOAD_IDLE) {
+ status->download_click = RESUME_STATUS_DOWNLOAD;
+ } else {
+ status->download_click = RESUME_STATUS_DOWNLOAD;
+ }
+
+ ret = Update_Engine_Status(status);
+ _DEBUG_TRACE(" update engine status : %d \n", ret);
+
+ DB_Close();
+
+ Free_Memory_Engine_Status(&status, 1);
+ }
+ } else {
+
+ }
+
+ /*************************************************/
+
+ if (server_id == NULL) {
+ ret = get_Serverid(SAMSUNG_FUMO_TYPE, &server_id);
+ if (ret != DM_OK || server_id == NULL)
+ goto error;
+ }
+
+ ev_data = (Event_Contents *) calloc(1, sizeof(Event_Contents));
+ if (ev_data == NULL) {
+ _DEBUG_TRACE("calloc failed !!");
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+ ev_data->type = UI_EVENT;
+ ev_data->session_id = NULL;
+ ev_data->server_id = strdup(server_id);
+ ev_data->noti_type = NOTI_TYPE_USERINTERACTION;
+ ev_data->ui_mode = strdup(OMADM_FUMO_NOTI_UI_TYPE);
+
+ _DEBUG_TRACE("alarm : %s", ev_data->server_id);
+ ret = dm_fumo_common_task_request(ev_data);
+ if (ret != DM_OK) {
+ goto error;
+ }
+
+ str_free(&server_id);
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ error:
+ str_free(&server_id);
+ event_data_free((void *)ev_data);
+
+ DB_Close();
+ if (status != NULL)
+ Free_Memory_Engine_Status(&status, 1);
+
+ _DEBUG_TRACE("end error : %d", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static DM_ERROR _fumo_account_registration_alarm(int item_id)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ ret = register_fota_account();
+ if (ret == 0) {
+ _DEBUG_TRACE("fail register fota account : %d ", ret);
+ ret = DM_ERR_FOTA_ACCOUNT_REGISTRATION;
+ } else {
+ _DEBUG_TRACE("success register fota account : %d ", ret);
+ }
+
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static DM_ERROR _lawmo_account_registration_alarm(int item_id)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ ret = register_lawmo_account(item_id, NULL);
+ if (ret == 0) {
+ _DEBUG_TRACE("fail register lawmo account : %d ", ret);
+ ret = DM_ERR_LAWMO_ACCOUNT_REGISTRATION;
+ } else {
+ _DEBUG_TRACE("success register lawmo account : %d ", ret);
+ }
+
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static DM_ERROR _send_event_ds(char *event_msg)
+{
+ _INNER_FUNC_ENTER;
+
+ int client_len;
+ int client_sockfd;
+ struct sockaddr_un clientaddr;
+ int event_type = 9;
+ char *msg = NULL;
+
+ retvm_if((event_msg) == NULL, DM_ERR_EVENT_DS, "event_msg is NULL!!");
+
+ msg = strchr(event_msg, '|') + 1;
+ _DEBUG_TRACE("msg = %s", msg);
+
+ sync_agent_event_data_s *event = sync_agent_create_event(event_type);
+ if (event == NULL) {
+ _DEBUG_TRACE("event is NULL");
+ _INNER_FUNC_EXIT;
+ return DM_ERR_EVENT_DS;
+ }
+
+ sync_agent_append_event_data_param(event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, msg);
+
+ client_sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (client_sockfd == -1) {
+ _DEBUG_TRACE("socket create Error!!");
+ sync_agent_free_event(event);
+ _INNER_FUNC_EXIT;
+ return DM_ERR_EVENT_DS;
+ }
+
+ bzero(&clientaddr, sizeof(clientaddr));
+ clientaddr.sun_family = AF_UNIX;
+
+ int str_len = 0;
+
+ str_len = g_strlcpy(clientaddr.sun_path, IPC_DS, (int)sizeof(clientaddr.sun_path));
+ if (str_len >= sizeof(clientaddr.sun_path)) {
+ _DEBUG_TRACE("buffer overflow");
+ sync_agent_free_event(event);
+ close(client_sockfd);
+ _INNER_FUNC_EXIT;
+ return CP_ERROR_FAIL;
+ }
+
+ client_len = sizeof(clientaddr);
+
+ if (connect(client_sockfd, (struct sockaddr *)&clientaddr, client_len) < 0) {
+ _DEBUG_TRACE("socket connect error");
+ sync_agent_free_event(event);
+ close(client_sockfd);
+ _INNER_FUNC_EXIT;
+ return DM_ERR_EVENT_DS;
+ }
+
+ int send_data_size = (event->data - event->size) + 1;
+ int write_ret = write(client_sockfd, (void *)(event->size), send_data_size);
+ _DEBUG_TRACE("write ret : %d", write_ret);
+ close(client_sockfd);
+ sync_agent_free_event(event);
+
+ _INNER_FUNC_EXIT;
+ return DM_OK;
+}
+
+void event_data_free(void *event_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if((event_data) == NULL, "event_data is NULL!!");
+
+ Event_Contents *pEvent_data = (Event_Contents *) event_data;
+
+ pEvent_data->type = 0;
+ pEvent_data->noti_type = 0;
+ str_free(&(pEvent_data->server_id));
+ str_free(&(pEvent_data->session_id));
+ str_free(&(pEvent_data->ui_mode));
+
+ free(pEvent_data);
+
+ _EXTERN_FUNC_EXIT;
+}
diff --git a/src/agent/framework/san-parser/pm_sanparser.c b/src/agent/framework/san-parser/pm_sanparser.c
new file mode 100644
index 0000000..f82cad9
--- /dev/null
+++ b/src/agent/framework/san-parser/pm_sanparser.c
@@ -0,0 +1,363 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <inttypes.h>
+#include <wbxml/wbxml.h>
+#include <wbxml/wbxml_tree.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "framework/san-parser/pm_sanparser.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "DM_SAN"
+#endif
+
+SanPackage *sanpackage_noti_parser(const char *msgBody, unsigned int msgSize)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((msgBody) == NULL, NULL, "msgBody is NULL!!");
+
+ _DEBUG_INFO("[sanPackage12Parser] msgSize : %d ", msgSize);
+
+ unsigned int idLength = (uint8_t) msgBody[23];
+ if (msgSize < (24 + idLength)) {
+ _DEBUG_INFO("[sanPackage12Parser] SAN package size is smaller than");
+ _DEBUG_INFO("[sanPackage12Parser] its minimal size specified in the spec, related to [Header] part.");
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+ }
+
+ SanPackage *san = (SanPackage *) calloc(1, sizeof(SanPackage));
+ if (san == NULL) {
+ _DEBUG_INFO("[sanPackage12Parser] SAN package memory allocation fail. [Container]");
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+ }
+ // MSG BODY WITHOUT DIGEST
+ san->msgBodyWithoutDigest = (char *)calloc(msgSize - 16, sizeof(char));
+ if (san->msgBodyWithoutDigest == NULL) {
+ _DEBUG_INFO("[sanPackage12Parser] SAN package memory allocation fail. [Msg body]");
+ goto error;
+ }
+ memcpy(san->msgBodyWithoutDigest, msgBody + 16, msgSize - 16);
+ san->msgBodyWithoutDigestLength = msgSize - 16;
+
+ // DIGEST
+ san->digest = (char *)calloc(16, sizeof(char));
+ if (san->digest == NULL) {
+ _DEBUG_INFO("[sanPackage12Parser] SAN package memory allocation fail. [Digest]");
+ goto error;
+ }
+ memcpy(san->digest, msgBody, 16);
+
+ // VERSION
+ unsigned int version = ((uint8_t) msgBody[16]) << 2;
+ version = version | ((uint8_t) msgBody[17]) >> 6;
+
+ /*CURRENT VERSION 11
+ if ( version != 12 ) {
+ _DEBUG_INFO("[sanPackage12Parser] Not supported SAN version %d.", version);
+ goto error;
+ } */
+ _DEBUG_INFO("[sanPackage12Parser] SAN version %d.", version);
+ san->version = version;
+
+ // UI MODE
+ san->uiMode = (((uint8_t) msgBody[17]) & 0x30) >> 4;
+
+ // INITIATOR
+ san->initiator = (((uint8_t) msgBody[17]) & 0x08) >> 3;
+
+ // SESSION ID
+ /*san->sessionID = ((uint8_t)msgBody[21]) << 8;
+ san->sessionID = san->sessionID | (uint8_t)msgBody[22]; */
+ _DEBUG_INFO("session id : %02X%02X \n", msgBody[21], msgBody[22]);
+ san->sessionID = (unsigned char *)g_strdup_printf("%02X%02X", msgBody[21], msgBody[22]);
+ _DEBUG_INFO("------------------------------------------------------------------------------\n");
+ _DEBUG_INFO("session id : %s \n", san->sessionID);
+
+ // SERVER ID
+ if (idLength != 0) {
+ san->serverID = (char *)calloc(idLength + 1, sizeof(char));
+ if (san->serverID == NULL) {
+ _DEBUG_INFO("[sanPackage_noti_Parser] SAN package memory allocation fail. [Server ID]");
+ goto error;
+ }
+ memcpy(san->serverID, msgBody + 24, idLength);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return san;
+
+ error:
+ free_sanpackageparser(san);
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+
+}
+
+SanPackage *sanpackage_xml_parser(const char *msgBody, unsigned int msgSize)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((msgBody) == NULL, NULL, "msgBody is NULL!!");
+
+ SanPackage *san = (SanPackage *) calloc(1, sizeof(SanPackage));
+ if (san == NULL) {
+ _DEBUG_INFO("[sanPackage_xml_Parser] SAN package memory allocation fail. [Container]");
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+ }
+
+ WBXMLTree *wbxml_tree = NULL;
+ WBXMLError wbxml_err = wbxml_tree_from_wbxml((unsigned char *)msgBody, msgSize, WBXML_LANG_UNKNOWN, WBXML_CHARSET_UNKNOWN, &wbxml_tree);
+
+ if (wbxml_err != WBXML_OK) {
+ _DEBUG_INFO("[sanPackage_xml_Parser] 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_INFO("[sanPackage_xml_Parser] 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_INFO("[sanPackage_xml_Parser] 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_INFO("[sanPackage_xml_Parser] NULL sessionID detected. sessionID MUST NOT be NULL.");
+ goto error;
+ }
+ san->sessionID = (unsigned char *)strdup(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_INFO("[sanPackage_xml_Parser] 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_INFO("[sanPackage_xml_Parser] NULL serverID detected. serverID MUST NOT be NULL.");
+ goto error;
+ }
+
+ san->serverID = (char *)calloc(serverIDlen, sizeof(char));
+ if (san->serverID == NULL) {
+ _DEBUG_INFO("[sanPackage_xml_Parser] SAN package memory allocation fail. [Server ID]");
+ goto error;
+ }
+ memcpy(san->serverID, serverID, serverIDlen);
+ }
+ } else if (strcmp(child_node_name, "Cred") == 0) {
+
+ san->cred = (SanCred *) calloc(1, sizeof(SanCred));
+ if (san->cred == NULL) {
+ _DEBUG_INFO("[sanPackage_xml_Parser] 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_INFO("[sanPackage_xml_Parser] 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_INFO("[sanPackage_xml_Parser] NULL credFormat detected. credFormat MUST NOT be NULL.");
+ goto error;
+ }
+
+ san->cred->credFormat = (char *)calloc(credFormatLen, sizeof(char));
+ if (san->cred->credFormat == NULL) {
+ _DEBUG_INFO("[sanPackage_xml_Parser] SAN package memory allocation fail. [credFormat]");
+ goto error;
+ }
+ memcpy(san->cred->credFormat, 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_INFO("[sanPackage_xml_Parser] 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_INFO("[sanPackage11Parser] NULL credAuth detected. credAuth MUST NOT be NULL.");
+ goto error;
+ }
+
+ san->cred->credAuth = (char *)calloc(credAuthLen, sizeof(char));
+ if (san->cred->credAuth == NULL) {
+ _DEBUG_INFO("[sanPackage_xml_Parser] SAN package memory allocation fail. [credAuth]");
+ goto error;
+ }
+ memcpy(san->cred->credAuth, 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_INFO("[sanPackage_xml_Parser] 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_INFO("[sanPackage_xml_Parser] NULL credData detected. credData MUST NOT be NULL.");
+ goto error;
+ }
+
+ san->cred->credData = (char *)calloc(credDataLen, sizeof(char));
+ if (san->cred->credData == NULL) {
+ _DEBUG_INFO("[sanPackage_xml_Parser] SAN package memory allocation fail. [credData]");
+ goto error;
+ }
+ memcpy(san->cred->credData, credData, credDataLen);
+ }
+ }
+ }
+
+ wbxml_tree_destroy(wbxml_tree);
+
+ _EXTERN_FUNC_EXIT;
+ return san;
+
+ error:
+ free_sanpackageparser(san);
+
+ _EXTERN_FUNC_EXIT;
+
+ return NULL;
+
+}
+
+void free_sanpackageparser(SanPackage * san)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (san != NULL) {
+ if (san->msgBodyWithoutDigest != NULL)
+ free(san->msgBodyWithoutDigest);
+ if (san->digest != NULL)
+ free(san->digest);
+ if (san->cred != NULL) {
+ if (san->cred->credFormat != NULL)
+ free(san->cred->credFormat);
+ if (san->cred->credAuth != NULL)
+ free(san->cred->credAuth);
+ if (san->cred->credData != NULL)
+ free(san->cred->credData);
+ free(san->cred);
+ }
+ if (san->serverID != NULL) {
+ free(san->serverID);
+ }
+ if (san->sessionID != NULL) {
+ free(san->sessionID);
+ }
+ free(san);
+ }
+ san = NULL;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void san_printmsg(SanPackage * san)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int i;
+ retm_if((san) == NULL, "san is NULL!!");
+
+ _DEBUG_INFO("Printing SAN package ============================\n\n");
+
+ _DEBUG_INFO("MsgBody without Digest :\n\t");
+ for (i = 0; i < san->msgBodyWithoutDigestLength; i++) {
+ _DEBUG_INFO("%02x ", san->msgBodyWithoutDigest[i]);
+ if ((i + 1) % 16 == 0)
+ printf("\n\t");
+ }
+ _DEBUG_INFO("\n");
+
+ _DEBUG_INFO("Digest : %s\n", san->digest);
+ if (san->cred != NULL) {
+ if (san->cred->credFormat)
+ _DEBUG_INFO("Cred Format : %s\n", san->cred->credFormat);
+ if (san->cred->credAuth != NULL)
+ _DEBUG_INFO("Cred Type : %s\n", san->cred->credAuth);
+ if (san->cred->credData != NULL)
+ _DEBUG_INFO("Cred Data : %s\n", san->cred->credData);
+ }
+ _DEBUG_INFO("Version : %d\n", san->version);
+ _DEBUG_INFO("UI mode : %d\n", san->uiMode);
+ _DEBUG_INFO("Initiator : %d\n", san->initiator);
+ _DEBUG_INFO("Session ID : %u\n", san->sessionID);
+ _DEBUG_INFO("Server ID : %s\n", san->serverID);
+
+ _EXTERN_FUNC_EXIT;
+}
diff --git a/src/agent/framework/task/oma_dm_task_register.c b/src/agent/framework/task/oma_dm_task_register.c
new file mode 100644
index 0000000..a458541
--- /dev/null
+++ b/src/agent/framework/task/oma_dm_task_register.c
@@ -0,0 +1,101 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "framework/task/oma_dm_task_register.h"
+#include "framework/task/oma_dm_task_spec.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "TASK_SPEC"
+#endif
+
+DM_ERROR task_register()
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ sync_agent_ec_task_spec_s *pDm_InitSpec = make_dm_init_task_spec();
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_DM_INIT_TASK_REQUEST, EC_MSG_TYPE_NAME_DM_INIT_TASK_REQUEST, pDm_InitSpec, NULL);
+
+ sync_agent_ec_task_spec_s *pDm_ResetSpec = make_dm_reset_task_spec();
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_DM_RESET_TASK_REQUEST, EC_MSG_TYPE_NAME_DM_RESET_TASK_REQUEST, pDm_ResetSpec, NULL);
+
+ sync_agent_ec_task_spec_s *pBootstrapSpec = make_bootstrap_task_spec();
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_BOOTSTRAP_TASK_REQUEST, EC_MSG_TYPE_NAME_BOOTSTRAP_TASK_REQUEST, pBootstrapSpec, NULL);
+
+ sync_agent_ec_task_spec_s *pDm_fumo_commonSpec = make_dm_fumo_common_process_task_spec();
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_DM_FUMO_COMMON_TASK_REQUEST, EC_MSG_TYPE_NAME_DM_FUMO_COMMON_TASK_REQUEST, pDm_fumo_commonSpec, NULL);
+
+ sync_agent_ec_task_spec_s *pDm_fumo_uiSpec = make_dm_fumo_ui_process_task_spec();
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_DM_FUMO_UI_TASK_REQUEST, EC_MSG_TYPE_NAME_DM_FUMO_UI_TASK_REQUEST, pDm_fumo_uiSpec, NULL);
+
+ sync_agent_ec_task_spec_s *pDm_lawmo_commonSpec = make_dm_lawmo_common_process_task_spec();
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_DM_LAWMO_COMMON_TASK_REQUEST, EC_MSG_TYPE_NAME_DM_LAWMO_COMMON_TASK_REQUEST, pDm_lawmo_commonSpec, NULL);
+
+ sync_agent_ec_task_spec_s *pGenericAlertSpec = make_genericAlert_process_task_spec();
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_GENERICALERT_TASK_REQUEST, EC_MSG_TYPE_NAME_GENERICALERT_TASK_REQUEST, pGenericAlertSpec, NULL);
+
+ sync_agent_ec_task_spec_s *pFumoServiceEngineSpec = make_fumo_serviceEngine_process_task_spec();
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_FUMO_SERVICE_ENGINE_TASK_REQUEST, EC_MSG_TYPE_NAME_FUMO_SERVICE_ENGINE_TASK_REQUEST, pFumoServiceEngineSpec, NULL);
+
+ sync_agent_ec_task_spec_s *pLawmoServiceEngineSpec = make_lawmo_serviceEngine_process_task_spec();
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_LAWMO_SERVICE_ENGINE_TASK_REQUEST, EC_MSG_TYPE_NAME_LAWMO_SERVICE_ENGINE_TASK_REQUEST, pLawmoServiceEngineSpec, NULL);
+
+ sync_agent_ec_task_spec_s *pFumo_schedule_Spec = make_fumo_schedule_process_task_spec();
+
+ sync_agent_register_task_spec(EC_MSG_TYPE_FUMO_SCHEDULE_TASK_REQUEST, EC_MSG_TYPE_NAME_FUMO_SCHEDULE_TASK_REQUEST, pFumo_schedule_Spec, NULL);
+
+ _DEBUG_INFO("register tasks end");
+
+ _DEBUG_INFO("register queuing rule start");
+ sync_agent_ec_queuing_rule_spec_s *pfumo_Rule = sync_agent_create_queuing_rule_spec_outline("dm_fumo_common_queuing_rule");
+ sync_agent_ec_queuing_rule_spec_s *plawmo_Rule = sync_agent_create_queuing_rule_spec_outline("dm_lawmo_common_queuing_rule");
+
+ sync_agent_ec_error_e ec_error = sync_agent_add_progress_blocking_element(pfumo_Rule,
+ EC_MSG_TYPE_DM_FUMO_COMMON_TASK_REQUEST, pDm_fumo_commonSpec,
+ 0);
+ ec_error = sync_agent_add_progress_blocking_element(pfumo_Rule, EC_MSG_TYPE_FUMO_SERVICE_ENGINE_TASK_REQUEST, pFumoServiceEngineSpec, 0);
+ ec_error = sync_agent_add_progress_blocking_element(pfumo_Rule, EC_MSG_TYPE_DM_FUMO_UI_TASK_REQUEST, pDm_fumo_uiSpec, 0);
+
+ ec_error = sync_agent_add_progress_blocking_element(plawmo_Rule, EC_MSG_TYPE_DM_LAWMO_COMMON_TASK_REQUEST, pDm_lawmo_commonSpec, 0);
+ ec_error = sync_agent_add_progress_blocking_element(plawmo_Rule, EC_MSG_TYPE_LAWMO_SERVICE_ENGINE_TASK_REQUEST, pLawmoServiceEngineSpec, 0);
+
+ sync_agent_register_async_queuing_rule_spec(pfumo_Rule, NULL, NULL);
+ sync_agent_unref_queuing_rule_spec(pfumo_Rule);
+ sync_agent_register_async_queuing_rule_spec(plawmo_Rule, NULL, NULL);
+ sync_agent_unref_queuing_rule_spec(plawmo_Rule);
+
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+
+}
diff --git a/src/agent/framework/task/oma_dm_task_request.c b/src/agent/framework/task/oma_dm_task_request.c
new file mode 100644
index 0000000..50096f7
--- /dev/null
+++ b/src/agent/framework/task/oma_dm_task_request.c
@@ -0,0 +1,265 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <stdio.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "framework/task/oma_dm_task_request.h"
+#include "framework/task/oma_dm_task_spec.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "TASK_SPEC"
+#endif
+
+DM_ERROR dm_init_task_request()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int request_msg_id = -1;
+ /*sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN; */
+
+ _DEBUG_INFO(" calling initt_async_request_task\n");
+ sync_agent_request_async_task(EC_MSG_TYPE_DM_INIT_TASK_REQUEST, 0, 0, NULL, NULL, NULL, NULL, NULL, &request_msg_id);
+
+ _DEBUG_INFO(" init_async_request_task done: %d", request_msg_id);
+ if (request_msg_id == -1) {
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_ASYNC_TASK;
+ }
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+}
+
+DM_ERROR dm_reset_task_request()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int request_msg_id = -1;
+ /*sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN; */
+
+ _DEBUG_INFO(" calling reset_async_request_task\n");
+ sync_agent_request_async_task(EC_MSG_TYPE_DM_RESET_TASK_REQUEST, 0, 0, NULL, NULL, NULL, NULL, NULL, &request_msg_id);
+
+ _DEBUG_INFO(" reset_async_request_task: %d", request_msg_id);
+ if (request_msg_id == -1) {
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_ASYNC_TASK;
+ }
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+}
+
+DM_ERROR bootstrap_task_request()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int bootstrapType = 0;
+ void *in_param_value_array[1] = { &bootstrapType };
+ 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 };
+ int request_msg_id = -1;
+ /*sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN; */
+
+ _DEBUG_INFO(" calling bootstrap_async_request_task\n");
+
+ sync_agent_request_async_task(EC_MSG_TYPE_BOOTSTRAP_TASK_REQUEST, 0, 1, in_param_index_array, in_param_value_type_array, in_param_value_array, NULL, NULL, &request_msg_id);
+
+ _DEBUG_INFO(" bootstrap_async_request_task done: %d", request_msg_id);
+ if (request_msg_id == -1) {
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_ASYNC_TASK;
+ }
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+}
+
+DM_ERROR dm_fumo_common_task_request(Event_Contents * pEvent_data)
+{
+
+ _EXTERN_FUNC_ENTER;
+
+ void *in_param_value_array[1] = { &pEvent_data };
+ 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 };
+
+ int request_msg_id = -1;
+ /*sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN; */
+
+ _DEBUG_INFO(" calling common_async_request_task\n");
+
+ sync_agent_request_async_task(EC_MSG_TYPE_DM_FUMO_COMMON_TASK_REQUEST, 0, 1, in_param_index_array, in_param_value_type_array, in_param_value_array, NULL, NULL, &request_msg_id);
+
+ _DEBUG_INFO(" common_async_request_task done : %d", request_msg_id);
+
+ if (request_msg_id == -1) {
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_ASYNC_TASK;
+ }
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+}
+
+DM_ERROR dm_fumo_ui_task_request(Event_Contents * pEvent_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ void *in_param_value_array[1] = { &pEvent_data };
+ 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 };
+
+ int request_msg_id = -1;
+ /*sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN; */
+
+ _DEBUG_INFO(" calling common_async_request_task\n");
+
+ sync_agent_request_async_task(EC_MSG_TYPE_DM_FUMO_UI_TASK_REQUEST, 0, 1, in_param_index_array, in_param_value_type_array, in_param_value_array, NULL, NULL, &request_msg_id);
+
+ _DEBUG_INFO(" common_async_request_task done: %d", request_msg_id);
+ if (request_msg_id == -1) {
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_ASYNC_TASK;
+ }
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+}
+
+DM_ERROR dm_lawmo_common_task_request(Event_Contents * pEvent_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ void *in_param_value_array[1] = { &pEvent_data };
+ 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 };
+
+ int request_msg_id = -1;
+ /*sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN; */
+
+ _DEBUG_INFO(" calling common_async_request_task\n");
+
+ sync_agent_request_async_task(EC_MSG_TYPE_DM_LAWMO_COMMON_TASK_REQUEST, 0, 1, in_param_index_array, in_param_value_type_array, in_param_value_array, NULL, NULL, &request_msg_id);
+
+ _DEBUG_INFO(" common_async_request_task done: %d", request_msg_id);
+ if (request_msg_id == -1) {
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_ASYNC_TASK;
+ }
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+
+}
+
+DM_ERROR genericAlert_task_request()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int request_msg_id = -1;
+ /*sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN; */
+
+ _DEBUG_INFO(" calling generic_async_request_task\n");
+ sync_agent_request_async_task(EC_MSG_TYPE_GENERICALERT_TASK_REQUEST, 0, 0, NULL, NULL, NULL, NULL, NULL, &request_msg_id);
+
+ _DEBUG_INFO(" generic_async_request_task done: %d", request_msg_id);
+ if (request_msg_id == -1) {
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_ASYNC_TASK;
+ }
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+
+}
+
+DM_ERROR fumo_serviceEngine_task_request()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int request_msg_id = -1;
+ /*sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN; */
+
+ _DEBUG_INFO(" calling service_engine_async_request_task\n");
+ sync_agent_request_async_task(EC_MSG_TYPE_FUMO_SERVICE_ENGINE_TASK_REQUEST, 0, 0, NULL, NULL, NULL, NULL, NULL, &request_msg_id);
+
+ _DEBUG_INFO(" service_engine_async_request_task done: %d", request_msg_id);
+ if (request_msg_id == -1) {
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_ASYNC_TASK;
+ }
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+}
+
+DM_ERROR lawmo_serviceEngine_task_request()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int request_msg_id = -1;
+ /*sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN; */
+
+ _DEBUG_INFO(" calling service_engine_async_request_task\n");
+ sync_agent_request_async_task(EC_MSG_TYPE_LAWMO_SERVICE_ENGINE_TASK_REQUEST, 0, 0, NULL, NULL, NULL, NULL, NULL, &request_msg_id);
+
+ _DEBUG_INFO(" service_engine_async_request_task done: %d", request_msg_id);
+ if (request_msg_id == -1) {
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_ASYNC_TASK;
+ }
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+}
+
+DM_ERROR fumo_schedule_task_request(Reminder_Interval remider_interval_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ void *in_param_value_array[1] = { &remider_interval_type };
+ 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 };
+ int request_msg_id = -1;
+ sync_agent_ec_task_error_e task_error = SYNC_AGENT_EC_TASK_ERROR_NOT_YET_RUN;
+ sync_agent_ec_uint out_param_cnt = 0;
+ sync_agent_ec_param_param_s **out_param_array = NULL;
+
+ _DEBUG_INFO(" calling fumo_schedule_sync_request_task\n");
+
+ sync_agent_request_sync_task(EC_MSG_TYPE_FUMO_SCHEDULE_TASK_REQUEST, 0, 1, in_param_index_array, in_param_value_type_array, in_param_value_array, &request_msg_id, &task_error, &out_param_cnt, &out_param_array);
+
+ _DEBUG_INFO(" fumo_schedule_sync_request_task done: %d", request_msg_id);
+
+ sync_agent_get_param_value(&(out_param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &ret);
+
+ if (request_msg_id == -1) {
+ _EXTERN_FUNC_EXIT;
+ return DM_ERR_ASYNC_TASK;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+}
+
+void cancel_task(int task_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_cancel_task(task_id);
+
+ _EXTERN_FUNC_EXIT;
+}
diff --git a/src/agent/framework/task/oma_dm_task_spec.c b/src/agent/framework/task/oma_dm_task_spec.c
new file mode 100644
index 0000000..7bbb4f6
--- /dev/null
+++ b/src/agent/framework/task/oma_dm_task_spec.c
@@ -0,0 +1,934 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "framework/task/oma_dm_task_spec.h"
+#include "framework/task/oma_dm_task_request.h"
+#include "framework/san-parser/pm_sanparser.h"
+#include "framework/ui-event-handler/ipc_agent.h"
+#include "framework/platform-event-handler/dm_platform_event_handler.h"
+#include "dm-engine/dm_common_engine.h"
+#include "dm-engine/bootstrap/factory_bootstrap.h"
+#include "dm-engine/fumo/fumo_engine.h"
+#include "dm-engine/lawmo/lawmo_engine.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "TASK_SPEC"
+#endif
+
+static sync_agent_ec_task_error_e _start_dm_init_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_dm_reset_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_bootstrap_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_dm_fumo_common_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_dm_fumo_ui_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_dm_lawmo_common_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_genericAlert_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_fumo_serviceEngine_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_lawmo_serviceEngine_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+static sync_agent_ec_task_error_e _start_fumo_schedule_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array);
+
+sync_agent_ec_task_spec_s *make_dm_init_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("dm_init_start", 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("dm_init",
+ _start_dm_init_process, NULL, NULL,
+ 1, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+
+}
+
+static sync_agent_ec_task_error_e _start_dm_init_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ sync_agent_open_mo();
+ ret = DB_Open();
+ _DEBUG_TRACE("status db : %d", ret);
+ ret = sync_agent_open_agent();
+ _DEBUG_TRACE("status db : %d", ret);
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+ ENGINE_STATUS value = DM_IDLE;
+ engine_status *status = NULL;
+
+ int is_exist = IsExist_Engine_id(IDLE_ENGINE);
+ if (is_exist == 0)
+ goto error;
+
+ ret = Get_Engine_Status(IDLE_ENGINE, &status);
+ if (ret != DM_OK) {
+ _DEBUG_TRACE("status is null");
+ goto error;
+ }
+ if (status != NULL) {
+
+ _DEBUG_TRACE("STATUS VALUE : %d ", status->engine_status);
+ value = status->engine_status;
+
+ if (value == DM_BEFORE_BOOTSTRAP) {
+ ret = bootstrap_task_request();
+ } else {
+ init_Dm_Engine();
+ ret = auto_operate_service_engine();
+ }
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &value);
+
+ sync_agent_close_mo();
+ ret = sync_agent_close_agent();
+ _DEBUG_TRACE("close db agent : %d", ret);
+ DB_Close();
+
+ Free_Memory_Engine_Status(&status, 1);
+
+ } else {
+ _DEBUG_TRACE("status is null");
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &value);
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+
+ sync_agent_close_mo();
+ ret = sync_agent_close_agent();
+ _DEBUG_TRACE("close db agent : %d", ret);
+ DB_Close();
+
+ if (status != NULL)
+ Free_Memory_Engine_Status(&status, 1);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_spec_s *make_dm_reset_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("dm_reset_start", 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("dm_reset",
+ _start_dm_reset_process, NULL, NULL,
+ 1, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+
+}
+
+static sync_agent_ec_task_error_e _start_dm_reset_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ ret = DB_Open();
+ ret = sync_agent_open_agent();
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ //ret = reset_dm();
+ if (ret != DM_OK)
+ goto error;
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &ret);
+
+ ret = sync_agent_close_agent();
+ DB_Close();
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &ret);
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+
+ ret = sync_agent_close_agent();
+ DB_Close();
+ _INNER_FUNC_EXIT;
+ return err;
+
+}
+
+sync_agent_ec_task_spec_s *make_bootstrap_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("bootstrap_start", true, false, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_int("bootstrap_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("dm_bootstrap_task",
+ _start_bootstrap_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;
+}
+
+static sync_agent_ec_task_error_e _start_bootstrap_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ sync_agent_open_mo();
+ _DEBUG_TRACE(" Done Open Mo DB\n");
+ ret = DB_Open();
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ /*
+ * factory bootstrap 0
+ * server init bootstrap 1
+ * smart card bootstrap 2
+ */
+
+ int bootstrapType = 0;
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &bootstrapType);
+ int i = 0;
+ int max_try = 3;
+
+ ret = reset_dm();
+ _DEBUG_TRACE("reset dm db : %d", ret);
+
+ for (i = 0; i < max_try; ++i) {
+ switch (bootstrapType) {
+ case 0:
+ ret = factory_bootstrap(NO_ENGINE_TYPE);
+ _DEBUG_TRACE("factory bootstrap : %d", ret);
+ if (ret != DM_OK) {
+ ret = reset_dm();
+ _DEBUG_TRACE("reset dm db : %d", ret);
+ ret = DM_ERR_BOOTSTRAP;
+ continue;
+ } else {
+ i = max_try;
+ break;
+ }
+ break;
+ default:
+ ret = DM_ERR_BOOTSTRAP;
+ goto error;
+ break;
+ }
+ }
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+ _DEBUG_TRACE("end");
+
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE(" Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ _DEBUG_TRACE("error");
+
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_spec_s *make_dm_fumo_common_process_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_structure("eventData", NULL, event_data_free, true, false, false, 0, false, 0, false, 0);
+ sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_int("common_fumo_dm_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("common_fumo_dm",
+ _start_dm_fumo_common_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;
+
+}
+
+static sync_agent_ec_task_error_e _start_dm_fumo_common_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ _DEBUG_TRACE(" Done Open Mo DB\n");
+
+ DM_ERROR ret = DM_OK;
+ ret = DB_Open();
+ ret = sync_agent_open_agent();
+ sync_agent_open_mo();
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ /* todo
+ * telephony vconf status get
+ * if connecting call status
+ * add quick panel
+ * goto error;
+ */
+ int roaming_state = -1;
+ int call_state = -1;
+ Event_Contents *pEvent_data = NULL;
+ int task_id;
+
+ get_roaming_state(&roaming_state);
+ get_call_sate(&call_state);
+ if (roaming_state == -1 || call_state == -1) {
+ _DEBUG_TRACE("NOT ROAMING OR CALL STATUS roaming state : %d , call state : %d", roaming_state, call_state);
+ ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ goto error;
+ }
+
+ task_id = sync_agent_get_self_request_id();
+ _DEBUG_TRACE("task id ============================================ %d", task_id);
+
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &pEvent_data);
+ if (pEvent_data == NULL) {
+ _DEBUG_TRACE("-------------------------------------NOT EVENT IDLE---------------------------------------");
+ goto error;
+ }
+
+ if (pEvent_data->server_id == NULL) {
+ _DEBUG_TRACE("server id null");
+ ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ goto error;
+ }
+
+ if (pEvent_data != NULL) {
+ _DEBUG_TRACE("mode = %d", pEvent_data->type);
+ _DEBUG_TRACE("server id = %s", pEvent_data->server_id);
+ _DEBUG_TRACE("session id= %s", pEvent_data->session_id);
+ _DEBUG_TRACE("noti type id= %d", pEvent_data->noti_type);
+ _DEBUG_TRACE("ui mode id= %s", pEvent_data->ui_mode);
+ }
+
+ if (pEvent_data->ui_mode != NULL) {
+ //for using fumo ui
+ //add_config_db_using_ui( task_id, pEvent_data->ui_mode);
+
+ int is_exist;
+ is_exist = IsExist_Engine_id(FUMO_SERVICE_ENGINE);
+
+ if (is_exist == 0) {
+ engine_status status;
+ memset(&status, 0x00, sizeof(engine_status));
+ status.engine_id = FUMO_SERVICE_ENGINE;
+ status.engine_status = DM_SERVICE_UNKNOWN;
+ //status.server_id = strdup(pEvent_data->server_id);
+ status.server_id = pEvent_data->server_id;
+ status.server_url = 0;
+ status.correlator = 0;
+ status.mo_path = 0;
+ status.result_status = DM_OK;
+ //status.ui_mode = strdup(pEvent_data->ui_mode);
+ status.ui_mode = pEvent_data->ui_mode;
+ status.task_id = task_id;
+ status.ui_noti_type = get_default_noti_type(pEvent_data->ui_mode, pEvent_data->noti_type); //0;
+
+ status.download_click = RESUME_STATUS_DONWLOAD_BEFORE;
+ _DEBUG_TRACE("status noti ui type : %d", status.ui_noti_type);
+ DB_Begin_Transaction();
+
+ ret = Add_Engine_Status(&status);
+ _DEBUG_TRACE(" -------------------------------------add engine status : %d -------------------------------------\n", ret);
+ DB_End_Transaction(TRANSACTION_COMMIT_);
+
+ //str_free(&(status.server_id));
+ //str_free(&(status.ui_mode));
+
+ } else {
+ engine_status *status;
+ ret = Get_Engine_Status(FUMO_SERVICE_ENGINE, &status);
+ if (status != NULL) {
+ _DEBUG_TRACE(" -------------------------------------update engine status -------------------------------------\n");
+ status->ui_mode = strdup(pEvent_data->ui_mode);
+ status->task_id = task_id;
+ status->ui_noti_type = get_default_noti_type(pEvent_data->ui_mode, pEvent_data->noti_type); //0;
+ status->download_click = RESUME_STATUS_DONWLOAD_BEFORE;
+
+ DB_Begin_Transaction();
+ ret = Update_Engine_Status(status);
+ _DEBUG_TRACE(" update engine status : %d \n", ret);
+ DB_End_Transaction(TRANSACTION_COMMIT_);
+
+ if (status != NULL)
+ Free_Memory_Engine_Status(&status, 1);
+
+ }
+ }
+
+ int noti_ret = noti_start(pEvent_data->ui_mode);
+ _DEBUG_TRACE("noti start : %d", noti_ret);
+
+ } else {
+ _DEBUG_TRACE("ui mode null");
+ }
+
+ ENGINE_STATUS value = 0;
+ engine_status *status = NULL;
+ ret = Get_Engine_Status(IDLE_ENGINE, &status);
+ if (status != NULL) {
+ _DEBUG_TRACE("STATUS VALUE : %d ", status->engine_status);
+ value = status->engine_status;
+
+ if (value != DM_BEFORE_BOOTSTRAP) {
+ ret = dm_common_start(pEvent_data);
+ } else {
+ //do popup ui
+ //retry factorybootstrap
+ }
+
+ Free_Memory_Engine_Status(&status, 1);
+ } else {
+ ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ }
+
+ _DEBUG_TRACE("end ret :%d ", ret);
+ if (ret != DM_OK)
+ goto error;
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ event_data_free((void *)pEvent_data);
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ _DEBUG_ERROR("error : %d", ret);
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ event_data_free((void *)pEvent_data);
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ _DEBUG_ERROR("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_spec_s *make_dm_fumo_ui_process_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_structure("eventData", NULL, event_data_free, true, false, false, 0, false, 0, false, 0);
+ sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_int("ui_fumo_dm_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("ui_fumo_dm",
+ _start_dm_fumo_ui_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;
+
+}
+
+static sync_agent_ec_task_error_e _start_dm_fumo_ui_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+ ret = DB_Open();
+ /* todo
+ * telephony vconf status get
+ * if connecting call status
+ *
+ * add quick panel
+ *
+ * goto error;
+ */
+
+ int task_id;
+ task_id = sync_agent_get_self_request_id();
+ _DEBUG_TRACE("task id ============================================ %d", task_id);
+
+ Event_Contents *pEvent_data = NULL;
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &pEvent_data);
+ if (pEvent_data == NULL || (pEvent_data->session_id) == NULL || (pEvent_data->server_id) == NULL) {
+ _DEBUG_TRACE("-------------------------------------NOT EVENT IDLE---------------------------------------");
+ ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ goto error;
+ }
+
+ _DEBUG_TRACE("-----------------------------------%s---------------------------------------", pEvent_data->session_id);
+ _DEBUG_TRACE("-----------------------------------%s---------------------------------------", pEvent_data->server_id);
+ _DEBUG_TRACE("noti type id= %d", pEvent_data->noti_type);
+ _DEBUG_TRACE("session id= %s", pEvent_data->session_id);
+
+ _DEBUG_TRACE("server id= %s", pEvent_data->server_id);
+ ENGINE_STATUS value = 0;
+ engine_status *status = NULL;
+ ret = Get_Engine_Status(IDLE_ENGINE, &status);
+ if (status != NULL) {
+ _DEBUG_TRACE("STATUS VALUE : %d ", status->engine_status);
+ value = status->engine_status;
+
+ if (value != DM_BEFORE_BOOTSTRAP) {
+ ret = launch_om_dm_fumo_noti_ui(pEvent_data->noti_type, pEvent_data->session_id, pEvent_data->server_id);
+ if (ret == 0) {
+ _DEBUG_TRACE("ui launch fail");
+ }
+ } else {
+ //do popup ui
+ //retry factorybootstrap
+ }
+
+ Free_Memory_Engine_Status(&status, 1);
+ }
+
+ _DEBUG_TRACE("end ret :%d ", ret);
+ if (ret != 1)
+ goto error;
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ DB_Close();
+ event_data_free((void *)pEvent_data);
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ //err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ _DEBUG_TRACE("error");
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ DB_Close();
+ event_data_free((void *)pEvent_data);
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_spec_s *make_dm_lawmo_common_process_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_structure("eventData", NULL, event_data_free, true, false, false, 0, false, 0, false, 0);
+ sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_int("common_lawmo_dm_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("common_lawmo_dm",
+ _start_dm_lawmo_common_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;
+}
+
+static sync_agent_ec_task_error_e _start_dm_lawmo_common_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_open_mo();
+ _DEBUG_TRACE(" Done Open Mo DB\n");
+
+ DM_ERROR ret = DM_OK;
+ ret = DB_Open();
+ ret = sync_agent_open_agent();
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+/* int task_id;
+ task_id = sync_agent_get_self_request_id();*/
+
+ Event_Contents *pEvent_data = NULL;
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_STRUCT, &pEvent_data);
+ if (pEvent_data == NULL) {
+ _DEBUG_TRACE("-------------------------------------NOT EVENT IDLE---------------------------------------");
+ goto error;
+ }
+
+ if (pEvent_data != NULL) {
+ _DEBUG_TRACE("mode = %d", pEvent_data->type);
+ _DEBUG_TRACE("server id = %s", pEvent_data->server_id);
+ _DEBUG_TRACE("session id= %s", pEvent_data->session_id);
+ _DEBUG_TRACE("noti type id= %d", pEvent_data->noti_type);
+ _DEBUG_TRACE("ui mode id= %s", pEvent_data->ui_mode);
+ }
+
+ ENGINE_STATUS value = 0;
+ engine_status *status = NULL;
+ ret = Get_Engine_Status(IDLE_ENGINE, &status);
+ if (status != NULL) {
+ _DEBUG_TRACE("STATUS VALUE : %d ", status->engine_status);
+ value = status->engine_status;
+
+ if (value != DM_BEFORE_BOOTSTRAP) {
+ ret = dm_common_start(pEvent_data);
+ } else {
+ //do popup ui
+ //retry factorybootstrap
+ }
+
+ Free_Memory_Engine_Status(&status, 1);
+ }
+/* //for using ui
+ if(engine_type == SAMSUNG_FUMO_TYPE)
+ delete_config_db_using_ui( task_id);*/
+
+ _DEBUG_TRACE("end ret :%d ", ret);
+ if (ret != DM_OK)
+ goto error;
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ event_data_free((void *)pEvent_data);
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+
+ _DEBUG_TRACE("error");
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+ event_data_free((void *)pEvent_data);
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_spec_s *make_genericAlert_process_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("genericAlert_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("dm_genericAlert_task",
+ _start_genericAlert_process, NULL, NULL,
+ 1, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+
+}
+
+static sync_agent_ec_task_error_e _start_genericAlert_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_open_mo();
+ _DEBUG_TRACE(" Done Open Mo DB\n");
+
+ DM_ERROR ret = DM_OK;
+ ret = DB_Open();
+ ret = sync_agent_open_agent();
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ /*ENGINE_ID service_engine_id = GENERICALERT;
+ engine_status *service_status= NULL;
+ char* server_id = NULL;
+ int result = DM_OK;
+
+ if( IsExist_Engine_id(service_engine_id) == 1) {
+ ret = Get_Engine_Status(SERVICE_ENGINE, &service_status);
+ if(ret != DM_OK)
+ goto error;
+
+ server_id = strdup(service_status->server_id);
+ result = service_status->engine_status;
+ ret = Free_Memory_Engine_Status(&service_status, 1);
+
+ ret = genericalert_operation(result, server_id);
+
+ } else {
+ //do nothting
+ } */
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+ _DEBUG_TRACE("end");
+
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+
+/*error:
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ _DEBUG_TRACE("error");
+
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE( "Done Close Mo DB\n");
+ return err;*/
+}
+
+sync_agent_ec_task_spec_s *make_fumo_serviceEngine_process_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("fumo_service_engine_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("dm_fumo_service_engine_task",
+ _start_fumo_serviceEngine_process, NULL, NULL,
+ 1, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+
+}
+
+static sync_agent_ec_task_error_e _start_fumo_serviceEngine_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ DM_ERROR service_ret = DM_OK;
+
+ sync_agent_open_mo();
+ ret = DB_Open();
+ _DEBUG_TRACE("status db open : %d", ret);
+ ret = sync_agent_open_agent();
+ _DEBUG_TRACE("daci db open : %d", ret);
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ int roaming_state = -1;
+ int call_state = -1;
+ get_roaming_state(&roaming_state);
+ get_call_sate(&call_state);
+ if (roaming_state == -1 || call_state == -1) {
+ _DEBUG_TRACE("NOT ROAMING OR CALL STATUS roaming state : %d , call state : %d", roaming_state, call_state);
+ ret = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ goto error;
+ }
+
+ int task_id;
+ task_id = sync_agent_get_self_request_id();
+ ret = Update_Engine_Status_Column(FUMO_SERVICE_ENGINE, VALUE_TASK_ID, &task_id);
+ _DEBUG_TRACE("update engine status : %d", ret);
+ _DEBUG_TRACE("------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
+ _DEBUG_TRACE("task id : %d", task_id);
+ _DEBUG_TRACE("------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------");
+ ret = service_engine_start(FUMO_SERVICE_ENGINE, &service_ret);
+ if (ret != DM_OK)
+ goto error;
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ _DEBUG_TRACE("end");
+
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ _DEBUG_TRACE("error");
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_spec_s *make_lawmo_serviceEngine_process_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("lawmo_service_engine_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("dm_lawmo_service_engine_task",
+ _start_lawmo_serviceEngine_process, NULL, NULL,
+ 1, param_spec_array);
+
+ sync_agent_unref_param_spec(pParam_spec1);
+
+ _EXTERN_FUNC_EXIT;
+ return pTask_spec;
+
+}
+
+static sync_agent_ec_task_error_e _start_lawmo_serviceEngine_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ DM_ERROR service_ret = DM_OK;
+
+ sync_agent_open_mo();
+ ret = DB_Open();
+ ret = sync_agent_open_agent();
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ ret = service_engine_start(LAWMO_SERVICE_ENGINE, &service_ret);
+ if (ret != DM_OK)
+ goto error;
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ _DEBUG_TRACE("end");
+
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+
+ sync_agent_set_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+ _DEBUG_TRACE("error");
+
+ ret = sync_agent_close_agent();
+ DB_Close();
+ sync_agent_close_mo();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_ec_task_spec_s *make_fumo_schedule_process_task_spec()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_ec_param_spec_s *pParam_spec1 = sync_agent_alloc_param_spec_int("fumo_schdule_start", true, false, false, 0, 0, false, 0, false, 0, 0);
+ sync_agent_ec_param_spec_s *pParam_spec2 = sync_agent_alloc_param_spec_int("fumo_schdule_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("dm_fumo_schdule_task",
+ _start_fumo_schedule_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;
+}
+
+static sync_agent_ec_task_error_e _start_fumo_schedule_process(unsigned int param_cnt, sync_agent_ec_param_param_s ** param_array)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ int da_err = 0;
+ da_err = sync_agent_open_agent();
+ _DEBUG_TRACE("db open result : %d", da_err);
+
+ sync_agent_ec_task_error_e err = SYNC_AGENT_EC_TASK_ERROR_RUN_SUCCESS;
+
+ Reminder_Interval reminder_interval_type = 0;
+ sync_agent_get_param_value(&(param_array[0]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, &reminder_interval_type);
+
+ delete_alarm_item(FUMO_INTERVAL, FUMO_INTERVAL_TYPE);
+
+ ret = add_alarm_item(reminder_interval_type, FUMO_INTERVAL, FUMO_INTERVAL_TYPE);
+ if (ret != DM_OK)
+ goto error;
+
+ _DEBUG_TRACE("end");
+ if (ret != DM_OK) {
+ _DEBUG_TRACE("schedule fail");
+ goto error;
+ }
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ da_err = sync_agent_close_agent();
+ _DEBUG_TRACE("db close result : %d", da_err);
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ err = SYNC_AGENT_EC_TASK_ERROR_RUN_FAILED;
+ _DEBUG_TRACE("error");
+
+ sync_agent_set_param_value(&(param_array[1]->param_value), SYNC_AGENT_EC_VALUE_TYPE_INT, (void *)(&ret));
+
+ da_err = sync_agent_close_agent();
+ _DEBUG_TRACE("Done Close Mo DB\n");
+ _INNER_FUNC_EXIT;
+ return err;
+}
diff --git a/src/agent/framework/ui-event-handler/ipc_agent.c b/src/agent/framework/ui-event-handler/ipc_agent.c
new file mode 100755
index 0000000..61b6caf
--- /dev/null
+++ b/src/agent/framework/ui-event-handler/ipc_agent.c
@@ -0,0 +1,1948 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <stdio.h>
+#include <aul.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "framework/platform-event-handler/dm_platform_event_handler_internal.h"
+#include "framework/task/oma_dm_task_request.h"
+#include "dm-engine/fumo/fumo_account.h"
+#include "dm-engine/fumo/fumo_engine_internal.h"
+#include "dm-engine/cp/dm_cp_processor.h"
+#include "mo-handler/dm_mo_common.h"
+#include "mo-handler/dm_mo_common_internal.h"
+#include "ipc_common.h"
+#include "ipc_agent.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_IPC"
+#endif
+
+static gint64 timeout;
+static GMutex mutex;
+static GCond cond;
+
+#define TIMEOUT_VAL_UIC 60 //uic time out time
+#define REST_TIMEOUT_VAL 10
+
+static gint64 uic_timeout_val = 0;
+
+static uic_res_data *res_uic_data = NULL;
+
+static int (*_get_event_callback(int event_id)) (sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+static int __event_callback_software_update(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int __event_callback_cancel(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int __event_callback_download(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int __event_callback_install(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int __event_callback_set_interval(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+static int __event_callback_account_registration(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+static int __event_callback_get_profile(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int __event_callback_set_profile(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int __event_callback_reset_profile(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+static int __event_callback_uic_alert(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+static int __event_callback_get_fumo_config(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int __event_callback_set_fumo_config_wifi_only(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+static int __event_callback_check_pin_code(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int __event_callback_default(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+static int __event_add_dmacc(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+static int __event_remove_dmacc(sync_agent_event_data_s * request, sync_agent_event_data_s * response);
+
+static int _IPC_noti(int noti_type, int noti_id, int input_param, char *input_string, void *user_data);
+static sync_agent_event_ipc_cancel_e __dm_task_process_check_cancel_flag(void *user_data);
+
+static int __check_ui_mode(char **ui_mode, char *input_string);
+static int __launch_ui(char *ui_mode, int noti_type);
+
+static int __uic_response(int noti_id, void *user_data);
+
+static int __check_ui_mode(char **ui_mode, char *input_string)
+{
+ _INNER_FUNC_ENTER;
+
+ if (*ui_mode == NULL) {
+ if (input_string != NULL) {
+ if (strcmp(input_string, OMADM_ALERT_UI_TYPE) == 0 || strcmp(input_string, OMADM_FUMO_NOTI_UI_TYPE) == 0 || strcmp(input_string, OMADM_FUMO_UI_TYPE) == 0 || strcmp(input_string, OMADM_FUMO_BACKGROUND_UI_TYPE) == 0) {
+
+ *ui_mode = strdup(input_string);
+ } else {
+ //do nothing
+ }
+ } else {
+ _DEBUG_VERBOSE("ERROR UI MODE NULL");
+ _INNER_FUNC_EXIT;
+ return RESPONSE_TYPE_CANCEL;
+ }
+ } else {
+ _DEBUG_VERBOSE("ui mode : %s", *ui_mode);
+ _DEBUG_VERBOSE("ui mode : %s", input_string);
+ if (input_string != NULL) {
+ if (strcmp(input_string, OMADM_ALERT_UI_TYPE) == 0 || strcmp(input_string, OMADM_FUMO_NOTI_UI_TYPE) == 0 || strcmp(input_string, OMADM_FUMO_UI_TYPE) == 0 || strcmp(input_string, OMADM_FUMO_BACKGROUND_UI_TYPE) == 0) {
+
+ str_free(ui_mode);
+ *ui_mode = strdup(input_string);
+ } else {
+ //do nothing
+ }
+ } else {
+ //do nothing
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+ return RESPONSE_TYPE_OK;
+}
+
+static int __launch_ui(char *ui_mode, int noti_type)
+{
+ _INNER_FUNC_ENTER;
+
+ int ui_ret = 1;
+
+ if (ui_mode != NULL) {
+ if (strcmp(ui_mode, OMADM_FUMO_UI_TYPE) == 0) {
+ ui_ret = launch_oma_dm_fumo_ui();
+ _DEBUG_VERBOSE("fumo ui : %d", ui_ret);
+ } else if (strcmp(ui_mode, OMADM_FUMO_NOTI_UI_TYPE) == 0) {
+ ui_ret = launch_om_dm_fumo_noti_ui(NOTI_TYPE_USERINTERACTION, NULL, NULL);
+ _DEBUG_VERBOSE("noti ui : %d", ui_ret);
+ } else if (strcmp(ui_mode, OMADM_FUMO_BACKGROUND_UI_TYPE) == 0) {
+ if (noti_type == NOTI_INSTALL) {
+ ui_ret = launch_om_dm_fumo_noti_ui(NOTI_TYPE_BACKGRUOUND, NULL, NULL);
+ _DEBUG_VERBOSE("noti ui : %d", ui_ret);
+ }
+ _DEBUG_VERBOSE("background ui");
+ _INNER_FUNC_EXIT;
+ return 0;
+ } else if (strcmp(ui_mode, OMADM_ALERT_UI_TYPE) == 0) {
+ ui_ret = launch_om_dm_fumo_alert_ui();
+ _DEBUG_VERBOSE("alert ui : %d", ui_ret);
+ } else {
+ _INNER_FUNC_EXIT;
+ return -1;
+ }
+
+ if (ui_ret == 0) {
+ _DEBUG_VERBOSE("UI launch fail");
+ _INNER_FUNC_EXIT;
+ return -1;
+ }
+
+ } else {
+ _DEBUG_VERBOSE("ERROR UI MODE NULL");
+ _INNER_FUNC_EXIT;
+ return -1;
+ }
+ _INNER_FUNC_EXIT;
+ return 1;
+}
+
+static int (*_get_event_callback(int event_id)) (sync_agent_event_data_s * request, sync_agent_event_data_s * response) {
+ _DEBUG_TRACE("%s: start (event_id:%d)\n", __func__, event_id);
+
+ switch (event_id) {
+ case EVENT_SOFTWARE_UPDATE: // Type 0, Replies Exist
+
+ return __event_callback_software_update;
+ break;
+
+ case EVENT_CANCEL: // Type 0, No Reply
+
+ return __event_callback_cancel;
+ break;
+
+ case EVENT_DOWNLOAD: // Type 0, No Reply
+
+ return __event_callback_download;
+ break;
+
+ case EVENT_INSTALL: // Type 0, No Reply
+ return __event_callback_install;
+ break;
+
+ case EVENT_SET_INTERVAL:
+ return __event_callback_set_interval;
+ break;
+
+ case EVENT_ACCOUNT_REGISTRATION:
+ return __event_callback_account_registration;
+ break;
+
+ case EVENT_GET_FUMO_CONFIG:
+ return __event_callback_get_fumo_config;
+ break;
+
+ case EVENT_SET_FUMO_CONFIG:
+ return __event_callback_set_fumo_config_wifi_only;
+ break;
+
+ case EVENT_GET_PROFILE:
+ return __event_callback_get_profile;
+ break;
+
+ case EVENT_SET_PROFILE:
+ return __event_callback_set_profile;
+ break;
+
+ case EVENT_SET_RESET_PROFILE:
+ return __event_callback_reset_profile;
+ break;
+
+ case EVENT_UIC_ALERT:
+ return __event_callback_uic_alert;
+ break;
+
+ case EVENT_CHECK_PIN_CODE:
+ return __event_callback_check_pin_code;
+ break;
+
+ case EVENT_ADD_DMACC:
+ return __event_add_dmacc;
+ break;
+
+ case EVENT_REMOVE_DMACC:
+ return __event_remove_dmacc;
+ break;
+
+ default:
+ return __event_callback_default;
+ break;
+ }
+
+}
+
+// Type 0, No Reply
+static int __event_callback_software_update(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _INNER_FUNC_ENTER;
+ //2012.11.20
+ EVENT_RESPONSE ev_response = EVENT_RESPONSE_OK;
+
+#if 1
+ // IPC_EVENT_TYPE_0;
+ /*sleep(10); // for test */
+
+ DM_ERROR ret;
+ retvm_if((request) == NULL, 0, "request is NULL!!");
+
+ UI_TYPE ui_type;
+ char *session_id = NULL;
+ char *fota_ui_type = NULL;
+ char *server_id = NULL;
+ int task_id = 0;
+ SERVICE_SERVER_TYPE server_type = SAMSUNG_FUMO_TYPE;
+ OPER_MODE operationMode = OPER_UNKNOWN;
+ NotI_Type noti_type = NOTI_TYPE_NOT_SPECIFIED;
+
+ sync_agent_get_event_data_param(request, &ui_type);
+ _DEBUG_VERBOSE("UI TYPE : %d\n", ui_type);
+
+ switch (ui_type) {
+ case FOTA_COMMON_UI:
+ _DEBUG_VERBOSE("common ui");
+ fota_ui_type = OMADM_FUMO_UI_TYPE;
+ sync_agent_get_event_data_param(request, &task_id);
+ _DEBUG_VERBOSE("get task id : %d", task_id);
+ sync_agent_get_event_data_param(request, &server_type);
+ ret = get_Serverid(server_type, &server_id);
+ //ret =get_Serverid(SAMSUNG_FUMO_TYPE , &server_id);
+ //ret =get_Serverid(GCF_TYPE , &server_id);
+ _DEBUG_VERBOSE("get server id : %s : %d", server_id, ret);
+ operationMode = OPER_USER_INITIATION;
+ break;
+ case FOTA_NOTI_UI:
+ _DEBUG_VERBOSE("noti ui");
+ fota_ui_type = OMADM_FUMO_NOTI_UI_TYPE;
+ sync_agent_get_event_data_param(request, &session_id);
+ sync_agent_get_event_data_param(request, &server_id);
+ _DEBUG_VERBOSE("get session id : %s", session_id);
+ _DEBUG_VERBOSE("get server id : %s", server_id);
+ operationMode = OPER_SERVER_INITIATION_FROM_IP;
+ break;
+ case FOTA_BACKGROUND_UI:
+ _DEBUG_VERBOSE("background ui");
+ break;
+ case ADMIN_UI:
+ _DEBUG_VERBOSE("admin ui");
+ fota_ui_type = OMADM_ADMIN_UI_TYPE;
+ sync_agent_get_event_data_param(request, &server_type);
+ ret = get_Serverid(server_type, &server_id);
+ _DEBUG_VERBOSE("get server id : %s : %d", server_id, ret);
+ operationMode = OPER_USER_INITIATION;
+ break;
+ case CP_UI:
+ _DEBUG_VERBOSE("cp ui");
+ break;
+ default:
+ _DEBUG_VERBOSE("not use ui");
+ break;
+ }
+
+ if (server_id != NULL) {
+ _DEBUG_VERBOSE("fumo server id = %s", server_id);
+ Event_Contents *ev_data = (Event_Contents *) calloc(1, sizeof(Event_Contents));
+ if (ev_data == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ goto error;
+ }
+ ev_data->type = UI_EVENT;
+ if (session_id != NULL)
+ ev_data->session_id = strdup(session_id);
+ if (server_id != NULL) {
+ ev_data->server_id = strdup(server_id);
+ str_free(&server_id);
+ }
+ ev_data->noti_type = noti_type;
+ ev_data->ui_mode = strdup(fota_ui_type);
+
+ ret = dm_fumo_common_task_request(ev_data);
+ if (ret != DM_OK) {
+ event_data_free((void *)ev_data);
+ goto error;
+ }
+ } else {
+ goto error;
+ }
+
+ //2012.11.20
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+#else
+
+ // IPC_EVENT_TYPE_1;
+ int response_int = REPLY_FAIL_TO_CONNECT; //initial value
+
+ //Todo ------------------------------------------------------------------------------------------------------------------------ (from here)
+ sleep(10); // for test
+
+ response_int = REPLY_SUCCESS_TO_CONNECT; // resulted value
+ // ---------------------------------------------------------------------------------------------------------------------------------- (end)
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_int);
+#endif
+
+ str_free(&(session_id));
+ str_free(&(server_id));
+ _INNER_FUNC_EXIT;
+ return 0;
+ error:
+ //2012.11.20
+ ev_response = EVENT_RESPONSE_FAIL;
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+ str_free(&(session_id));
+ str_free(&(server_id));
+ return 0;
+
+}
+
+// Type 0, No Reply
+static int __event_callback_cancel(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((request) == NULL, 0, "request is NULL!!");
+
+ //2012.11.20
+ EVENT_RESPONSE ev_response = EVENT_RESPONSE_OK;
+ _DEBUG_VERBOSE(">>> >>> >>> Connect to server CANCELED !!!\n");
+
+ int task_id;
+ sync_agent_get_event_data_param(request, &task_id);
+ _DEBUG_VERBOSE("task id : %d\n", task_id);
+
+ /*sync_agent_cancel_task(task_id); */
+ cancel_task(task_id);
+
+ //2012.11.20
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+ _INNER_FUNC_EXIT;
+ return 0;
+}
+
+// Type 0, No Reply
+static int __event_callback_download(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((request) == NULL, 0, "request is NULL!!");
+
+ DM_ERROR ret = DM_OK;
+
+ //2012.11.20
+ EVENT_RESPONSE ev_response = EVENT_RESPONSE_OK;
+ int response_type = 0;
+ RESUME_STATUS download_clicked = 0;
+
+ sync_agent_get_event_data_param(request, &response_type);
+ _DEBUG_VERBOSE("DOWNLOAD BUTTON TYPE : %d\n", response_type);
+
+ ret = DB_Open();
+ _DEBUG_VERBOSE("db open : %d", ret);
+
+ if (response_type == RESPONSE_TYPE_OK) {
+ /*download button clicked */
+ download_clicked = RESUME_STATUS_DOWNLOAD;
+ ret = Update_Engine_Status_Column(FUMO_SERVICE_ENGINE, VALUE_DOWNLOAD_CLICK, &download_clicked);
+ _DEBUG_VERBOSE("update engine status clolumn download click : %d", ret);
+
+ } else if (RESPONSE_TYPE_CANCEL) {
+ /*later button clicked */
+ download_clicked = RESUME_STATUS_DOWNLOAD_LATER;
+ ret = Update_Engine_Status_Column(FUMO_SERVICE_ENGINE, VALUE_DOWNLOAD_CLICK, &download_clicked);
+ _DEBUG_VERBOSE("update engine status clolumn download click : %d", ret);
+ }
+ DB_Close();
+
+ ret = fumo_serviceEngine_task_request();
+ if (ret != DM_OK) {
+ goto error;
+ }
+ //2012.11.20
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+ _INNER_FUNC_EXIT;
+ return 0;
+ error:
+ //2012.11.20
+ ev_response = EVENT_RESPONSE_FAIL;
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+ _INNER_FUNC_EXIT;
+ return 0;
+}
+
+// Type 0, No Reply
+static int __event_callback_install(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((request) == NULL, 0, "request is NULL!!");
+
+ DM_ERROR ret = DM_OK;
+
+ //2012.11.20
+ EVENT_RESPONSE ev_response = EVENT_RESPONSE_OK;
+ int response_type = 0;
+ RESUME_STATUS download_clicked = 0;
+
+ sync_agent_get_event_data_param(request, &response_type);
+ _DEBUG_VERBOSE("INSTALL BUTTON TYPE : %d\n", response_type);
+
+ ret = DB_Open();
+ _DEBUG_VERBOSE("db open : %d", ret);
+
+ if (response_type == RESPONSE_TYPE_OK) {
+ /*download button clicked */
+ download_clicked = RESUME_STATUS_INSTALL;
+ ret = Update_Engine_Status_Column(FUMO_SERVICE_ENGINE, VALUE_DOWNLOAD_CLICK, &download_clicked);
+ _DEBUG_VERBOSE("update engine status clolumn install click : %d", ret);
+
+ } else if (RESPONSE_TYPE_CANCEL) {
+ /*later button clicked */
+ download_clicked = RESUME_STATUS_INSTALL_LATER;
+ ret = Update_Engine_Status_Column(FUMO_SERVICE_ENGINE, VALUE_DOWNLOAD_CLICK, &download_clicked);
+ _DEBUG_VERBOSE("update engine status clolumn install click : %d", ret);
+ }
+ DB_Close();
+
+ ret = fumo_serviceEngine_task_request();
+ if (ret != DM_OK) {
+ goto error;
+ }
+ //2012.11.20
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+ _INNER_FUNC_EXIT;
+ return 0;
+ error:
+ //2012.11.20
+ ev_response = EVENT_RESPONSE_FAIL;
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+ _INNER_FUNC_EXIT;
+ return 0;
+}
+
+// Type 0, No Reply
+static int __event_callback_set_interval(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((request) == NULL, 0, "request is NULL!!");
+
+ DM_ERROR ret = DM_OK;
+ //2012.11.20
+ EVENT_RESPONSE ev_response = EVENT_RESPONSE_OK;
+ int request_param = INTERVAL_CANCEL;
+
+ sync_agent_get_event_data_param(request, &request_param);
+ _DEBUG_VERBOSE("interval val from UI : %d\n", request_param);
+
+ switch (request_param) {
+ case RESPONSE_TYPE_REMINDER_INTERVAL_1_HOUR:
+ request_param = INTERVAL_1HOUR;
+ break;
+ case RESPONSE_TYPE_REMINDER_INTERVAL_3_HOURS:
+ request_param = INTERVAL_3HOURS;
+ break;
+ case RESPONSE_TYPE_REMINDER_INTERVAL_6_HOURS:
+ request_param = INTERVAL_6HOURS;
+ break;
+ case RESPONSE_TYPE_REMINDER_INTERVAL_12_HOURS:
+ request_param = INTERVAL_12HOURS;
+ break;
+ case RESPONSE_TYPE_REMINDER_INTERVAL_1_DAY:
+ request_param = INTERVAL_1DAY;
+ break;
+ case RESPONSE_TYPE_CANCEL:
+ request_param = INTERVAL_CANCEL;
+ break;
+ default:
+ break;
+ }
+
+ _DEBUG_VERBOSE(" interval val in fumo engine : %d\n", request_param);
+ if (request_param != INTERVAL_CANCEL) {
+ ret = fumo_schedule_task_request(request_param);
+ if (ret != DM_OK) {
+ goto error;
+ }
+ _DEBUG_VERBOSE("fumo schedule task result : %d\n", ret);
+ } else {
+ _DEBUG_VERBOSE("fumo schedule cancel : %d \n", ret);
+ }
+
+ //2012.11.20
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+ _INNER_FUNC_EXIT;
+ return 0;
+
+ error:
+ //2012.11.20
+ ev_response = EVENT_RESPONSE_FAIL;
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+ _INNER_FUNC_EXIT;
+ return 1;
+}
+
+// Type 0, No Reply
+static int __event_callback_account_registration(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((request) == NULL, 0, "request is NULL!!");
+
+ //2012.11.20
+ EVENT_RESPONSE ev_response = EVENT_RESPONSE_OK;
+
+ int ret = -1;
+ //temp code
+ int db_ret = 0;
+ db_ret = sync_agent_open_agent();
+ _DEBUG_VERBOSE("OPEN DACI : %d", db_ret);
+
+ ret = register_fota_account();
+
+ db_ret = sync_agent_close_agent();
+ _DEBUG_VERBOSE("CLOSE DACI : %d", db_ret);
+
+ if (ret == 0) {
+ _DEBUG_VERBOSE("fail register fota account : %d ", ret);
+ goto error;
+ } else {
+ _DEBUG_VERBOSE("success register fota account : %d ", ret);
+ }
+
+ //2012.11.20
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+ _INNER_FUNC_EXIT;
+ return 0;
+ error:
+ //2012.11.20
+ ev_response = EVENT_RESPONSE_FAIL;
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+ _INNER_FUNC_EXIT;
+ return 0;
+}
+
+// Type 1, Fumo setting data Reply
+static int __event_callback_get_profile(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((request) == NULL, 0, "request is NULL!!");
+
+ EVENT_RESPONSE ev_response = EVENT_RESPONSE_OK;
+
+ char *profile_name = NULL;
+ SERVICE_SERVER_TYPE sv_type = NO_ENGINE_TYPE;
+
+ char *client_id = NULL;
+ char *client_pwd = NULL;
+ char *client_sourceUrl = NULL;
+ char *client_targetUrl = NULL;
+ int client_isBase64 = 0;
+ char *client_nextNonce = NULL;
+ char *client_authType = NULL;
+
+ char *server_url = NULL;
+ char *server_pwd = NULL;
+ char *server_sourceUrl = NULL;
+ char *server_targetUrl = NULL;
+ int server_isBase64 = 0;
+ char *server_nextNonce = NULL;
+ char *server_authType = NULL;
+
+ sync_agent_dm_mo_error_e db_ret = SYNC_AGENT_DM_MO_SUCCESS;
+ char *server_id = NULL;
+
+ sync_agent_get_event_data_param(request, &sv_type);
+ _DEBUG_VERBOSE("server type : %d\n", sv_type);
+
+ db_ret = sync_agent_open_mo();
+ _DEBUG_VERBOSE("mo db open : %d", db_ret);
+
+ switch (sv_type) {
+ case SAMSUNG_FUMO_TYPE:
+ {
+ profile_name = "Fumo";
+ }
+ break;
+ case SAMSUNG_FMM_TYPE:
+ {
+ profile_name = "Lawmo";
+ }
+ break;
+ case GCF_TYPE:
+ {
+ profile_name = "gcf";
+ }
+ break;
+ default:
+ {
+ _DEBUG_VERBOSE("not exist server id error");
+ goto error;
+ }
+ }
+
+ get_Serverid(sv_type, &server_id);
+ _DEBUG_VERBOSE("server id : %s", server_id);
+
+ if (server_id != NULL) {
+ DM_ERROR err = get_client_dmacc(server_id, &client_id, &client_pwd, &client_sourceUrl, &client_targetUrl, &client_isBase64, &client_nextNonce, &client_authType);
+ if (err != DM_OK) {
+ _DEBUG_VERBOSE("get_client_dmacc() fail !!");
+ goto error;
+ } else {
+ _DEBUG_VERBOSE("get_client_dmacc() success !!");
+ }
+
+ err = get_server_dmacc(server_id, &server_url, &server_pwd, &server_sourceUrl, &server_targetUrl, &server_isBase64, &server_nextNonce, &server_authType);
+ if (err != DM_OK) {
+ _DEBUG_VERBOSE("get_server_dmacc() fail !!");
+ goto error;
+ } else {
+ _DEBUG_VERBOSE("get_server_dmacc() success !!");
+ }
+
+ db_ret = sync_agent_close_mo();
+ _DEBUG_VERBOSE("mo db close : %d", db_ret);
+
+ _DEBUG_VERBOSE("profile_name : %s", profile_name);
+ _DEBUG_VERBOSE("client_targetUrl : %s", client_targetUrl);
+ _DEBUG_VERBOSE("server_id : %s", server_url);
+ _DEBUG_VERBOSE("server_pwd : %s", server_pwd);
+ _DEBUG_VERBOSE("client_id : %s", client_id);
+ _DEBUG_VERBOSE("client_pwd : %s", client_pwd);
+ _DEBUG_VERBOSE("client_authType : %s", client_authType);
+ _DEBUG_VERBOSE("server_authType : %s", server_authType);
+
+ //2012.11.20
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, profile_name);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_targetUrl);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_url);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_pwd);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_id);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_pwd);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, client_authType);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, server_authType);
+
+ str_free(&server_nextNonce);
+ str_free(&client_nextNonce);
+ str_free(&client_sourceUrl);
+ str_free(&server_sourceUrl);
+ str_free(&server_targetUrl);
+ str_free(&client_targetUrl);
+ str_free(&server_url);
+ str_free(&server_pwd);
+ str_free(&client_id);
+ str_free(&client_pwd);
+ str_free(&client_authType);
+ str_free(&server_authType);
+ } else {
+ _DEBUG_VERBOSE("not exist server id error");
+ goto error;
+ }
+
+ _INNER_FUNC_EXIT;
+ return 0;
+ error:
+
+ db_ret = sync_agent_close_mo();
+ _DEBUG_VERBOSE("mo db close : %d", db_ret);
+ //2012.11.20
+ ev_response = EVENT_RESPONSE_FAIL;
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+ _INNER_FUNC_EXIT;
+ return 0;
+}
+
+static int __event_callback_set_profile(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((request) == NULL, 0, "request is NULL!!");
+
+ //2012.11.20
+ EVENT_RESPONSE ev_response = EVENT_RESPONSE_OK;
+
+ int ret = -1;
+ SERVICE_SERVER_TYPE sv_type = NO_ENGINE_TYPE;
+ char *server_id = NULL;
+
+ dm_acc *dmaccount = (dm_acc *) calloc(1, sizeof(dm_acc));
+ if (dmaccount == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ goto error;
+ }
+ //update 2012.11.20
+ sync_agent_get_event_data_param(request, &sv_type);
+ _DEBUG_VERBOSE("server profile type : %d", sv_type);
+ sync_agent_get_event_data_param(request, &(dmaccount->server_url));
+ _DEBUG_VERBOSE("server url : %s", (dmaccount->server_url));
+ sync_agent_get_event_data_param(request, &(dmaccount->server_id));
+ _DEBUG_VERBOSE("server id : %s", dmaccount->server_id);
+ sync_agent_get_event_data_param(request, &(dmaccount->server_pw));
+ _DEBUG_VERBOSE("server_pw : %s", dmaccount->server_pw);
+ sync_agent_get_event_data_param(request, &(dmaccount->user_id));
+ _DEBUG_VERBOSE("user_id : %s", dmaccount->user_id);
+ sync_agent_get_event_data_param(request, &(dmaccount->user_pw));
+ _DEBUG_VERBOSE("user_pw : %s", dmaccount->user_pw);
+ sync_agent_get_event_data_param(request, &(dmaccount->user_auth_type));
+ _DEBUG_VERBOSE("user_auth_type : %s", dmaccount->user_auth_type);
+ sync_agent_get_event_data_param(request, &(dmaccount->server_auth_type));
+ _DEBUG_VERBOSE("server_auth_type : %s", dmaccount->server_auth_type);
+
+ get_Serverid(sv_type, &server_id);
+ _DEBUG_VERBOSE("server id : %s", server_id);
+
+ if (server_id != NULL) {
+ ret = update_dmacc(server_id, dmaccount);
+ if (ret != 1) {
+ _DEBUG_VERBOSE("update dm acc fail", ret);
+ goto error;
+
+ } else {
+ _DEBUG_VERBOSE("update dm acc success", ret);
+ }
+
+ } else {
+ goto error;
+ }
+
+ _DEBUG_VERBOSE("update dm acc : %d", ret);
+ free_dm_acc(dmaccount);
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+ _INNER_FUNC_EXIT;
+ return 0;
+ error:
+ //2012.11.20
+ free_dm_acc(dmaccount);
+ ev_response = EVENT_RESPONSE_FAIL;
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+ _INNER_FUNC_EXIT;
+ return 0;
+}
+
+static int __event_callback_reset_profile(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if((request) == NULL, 0, "request is NULL!!");
+
+ //2012.11.20
+ EVENT_RESPONSE ev_response = EVENT_RESPONSE_OK;
+ SERVICE_SERVER_TYPE sv_type = NO_ENGINE_TYPE;
+
+ sync_agent_get_event_data_param(request, &sv_type);
+ _DEBUG_VERBOSE("PROFILE TYPE : %d\n", sv_type);
+
+ switch (sv_type) {
+ case SAMSUNG_FUMO_TYPE:
+ {
+ reset_dmacc_msctestserver();
+ }
+ break;
+ case SAMSUNG_FMM_TYPE:
+ {
+ reset_dmacc_mscserver();
+ }
+ break;
+ case GCF_TYPE:
+ {
+ reset_dmacc_gcf();
+ }
+ break;
+ default:
+ {
+ goto error;
+ }
+ }
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+ _INNER_FUNC_EXIT;
+ return 0;
+ error:
+ //2012.11.20
+ ev_response = EVENT_RESPONSE_FAIL;
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+ _INNER_FUNC_EXIT;
+ return 0;
+}
+
+static int __event_callback_uic_alert(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _INNER_FUNC_ENTER;
+
+ uic_type type = UIC_NONE_TYPE;
+ RESPONSE_TYPE response_ret = EVENT_RESPONSE_FAIL;
+ char *input_text = NULL;
+ int count = 0;
+ int i = 0;
+
+ /*
+ if (type == UIC_DISPLAY_TYPE) {
+ return 0;
+ }
+ */
+ free_res_data(res_uic_data);
+
+ sync_agent_get_event_data_param(request, &response_ret);
+ _DEBUG_TRACE("response is %d", response_ret);
+
+ sync_agent_get_event_data_param(request, &type);
+ _DEBUG_TRACE("uic type %d", type);
+
+ /*alloc reponse data */
+ res_uic_data = calloc(1, sizeof(uic_res_data) + 1);
+ res_uic_data->status = response_ret;
+
+ if (response_ret == RESPONSE_TYPE_OK) {
+
+ _DEBUG_TRACE("response ok");
+
+ switch (type) {
+ case UIC_CONFIRMATION_TYPE:
+ break;
+ case UIC_INPUT_TEXT_TYPE:{
+ sync_agent_get_event_data_param(request, &input_text);
+ _DEBUG_TRACE("input text %s", input_text);
+
+ res_uic_data->input_text = strdup(input_text);
+ }
+ break;
+ case UIC_SINGLE_CHOICE_TYPE:
+ case UIC_MULTIPLE_CHOICE_TYPE:{
+ sync_agent_get_event_data_param(request, &count);
+ _DEBUG_TRACE("count is %d\n", count);
+
+ if (count != 0) {
+ /*single, multiple choice */
+ for (i = 0; i < count; ++i) {
+ char *input = NULL;
+ char *value = NULL;
+ sync_agent_get_event_data_param(request, &input);
+ _DEBUG_TRACE(" choice : %s", input);
+ if (input == NULL) {
+ input = strdup("NULL");
+ res_uic_data->res_multi_data = g_list_append(res_uic_data->res_multi_data, input);
+ } else {
+ _DEBUG_TRACE("value data : %s", input);
+ value = strdup(input);
+ res_uic_data->res_multi_data = g_list_append(res_uic_data->res_multi_data, value);
+ }
+ }
+ } else {
+ _DEBUG_TRACE("not choice");
+ }
+ }
+ break;
+ case UIC_DISPLAY_TYPE:
+ default:
+ break;
+ }
+ } else {
+ /*
+ * time out
+ * error
+ * ...
+ */
+ _DEBUG_TRACE("response fail");
+ }
+
+ //signal off
+ g_mutex_lock(&(mutex));
+ g_cond_signal(&(cond));
+ g_mutex_unlock(&(mutex));
+
+ EVENT_RESPONSE ev_response = EVENT_RESPONSE_OK;
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+ _INNER_FUNC_EXIT;
+ return 0;
+}
+
+static int __event_callback_get_fumo_config(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if((request) == NULL, 0, "request is NULL!!");
+
+ //2012.11.20
+ EVENT_RESPONSE ev_response = EVENT_RESPONSE_OK;
+
+ int wifi_only = -1;
+ sync_agent_open_agent();
+
+ wifi_only = get_wifi_only_config();
+ sync_agent_close_agent();
+
+ if (wifi_only == -1) {
+ _DEBUG_VERBOSE("get wifi only config fail\n");
+ goto error;
+ } else {
+ _DEBUG_VERBOSE("get wifi only config success\n");
+ }
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+ _DEBUG_VERBOSE("wifi only : %d", wifi_only);
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &wifi_only);
+
+ _INNER_FUNC_EXIT;
+ return 0;
+ error:
+ //2012.11.20
+ ev_response = EVENT_RESPONSE_FAIL;
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+ _INNER_FUNC_EXIT;
+ return 0;
+}
+
+static int __event_callback_set_fumo_config_wifi_only(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if((request) == NULL, 0, "request is NULL!!");
+
+ //2012.11.20
+ EVENT_RESPONSE ev_response = EVENT_RESPONSE_OK;
+ int ret = 1;
+ int wifi_only_param;
+
+ sync_agent_get_event_data_param(request, &wifi_only_param);
+
+ sync_agent_open_agent();
+ ret = set_wifi_only_config(wifi_only_param);
+ sync_agent_close_agent();
+ if (ret != 1) {
+ goto error;
+ }
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+ _INNER_FUNC_EXIT;
+ return 0;
+ error:
+ //2012.11.20
+ ev_response = EVENT_RESPONSE_FAIL;
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+ _INNER_FUNC_EXIT;
+ return 0;
+}
+
+static int __event_callback_check_pin_code(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if((request) == NULL, 0, "request is NULL!!");
+
+ //2012.11.20
+ EVENT_RESPONSE ev_response = EVENT_RESPONSE_OK;
+
+ CP_ERROR err = CP_ERROR_SUCCESS;
+
+ int ext_id = 0;
+ sync_agent_get_event_data_param(request, &ext_id);
+ _DEBUG_VERBOSE("ext id : %d", ext_id);
+
+ char *user_pin = NULL;
+
+ int response_type = RESPONSE_TYPE_NONE;
+ sync_agent_get_event_data_param(request, &response_type);
+ _DEBUG_VERBOSE("response type : %d", response_type);
+
+ int response_value = 0;
+
+ if (response_type == RESPONSE_TYPE_OK) {
+ _DEBUG_VERBOSE("check pin code !!");
+ sync_agent_get_event_data_param(request, &user_pin);
+ _DEBUG_VERBOSE("user pin : %s", user_pin);
+
+ int is_correct = 0;
+ err = process_Check_Pincode(0, user_pin, &is_correct, ext_id);
+ if (err != CP_ERROR_SUCCESS) {
+ _DEBUG_VERBOSE("process_Check_Pincode() fail !!");
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+ response_value = 0;
+ /* todo : exception handling */
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_value);
+ } else {
+ _DEBUG_VERBOSE("process_Check_Pincode() success !!");
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+ if (is_correct != 0) {
+ response_value = 1;
+ } else {
+ response_value = 0;
+ }
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_value);
+
+ /* process_Setting_CP() */
+ if (is_correct == 1) {
+ _DEBUG_VERBOSE("Valid PIN !!");
+
+ err = process_Setting_CP(ext_id);
+ if (err != CP_ERROR_SUCCESS) {
+ _DEBUG_VERBOSE("process_Setting_CP() fail !!");
+ } else {
+ _DEBUG_VERBOSE("process_Setting_CP() success !!");
+ }
+ } else if (is_correct == 0) {
+ _DEBUG_VERBOSE("Invalid PIN !!");
+ }
+ }
+ } else { /* response_type == RESPONSE_TYPE_CANCEL */
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+ response_value = 1; /* meaningless value */
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_value);
+
+ if (ext_id != -1) {
+ _DEBUG_VERBOSE("fail logic !!");
+ err = process_Invalid_Pincode(ext_id);
+ if (err != CP_ERROR_SUCCESS) {
+ _DEBUG_VERBOSE("process_Invalid_Pincode() fail !!");
+ /* todo : exception handling */
+ } else {
+ _DEBUG_VERBOSE("process_Invalid_Pincode() success !!");
+ }
+ } else {
+ _DEBUG_VERBOSE("cancel logic !!");
+ /* do nothing !! */
+ }
+ }
+
+ str_free(&(user_pin));
+ _INNER_FUNC_EXIT;
+ return 0;
+}
+
+static int __event_add_dmacc(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_dm_mo_error_e db_ret = SYNC_AGENT_DM_MO_SUCCESS;
+ DM_ERROR ret = DM_OK;
+
+ EVENT_RESPONSE ev_response = EVENT_RESPONSE_OK;
+ SERVICE_SERVER_TYPE sv_type = NO_ENGINE_TYPE;
+
+ sync_agent_get_event_data_param(request, &sv_type);
+ _DEBUG_VERBOSE("server type : %d\n", sv_type);
+
+ db_ret = sync_agent_open_mo();
+ _DEBUG_VERBOSE("mo db open : %d", db_ret);
+
+ ret = DB_Open();
+ _DEBUG_VERBOSE("dm status open : %d", db_ret);
+
+ ret = DB_Begin_Transaction();
+ _DEBUG_VERBOSE("end transaction : %d", ret);
+
+ switch (sv_type) {
+ //todo will change ipc refactoring
+ case SAMSUNG_FUMO_TYPE:
+ {
+ _DEBUG_VERBOSE("add mscservertest dmacc");
+ ret = add_dm_acc(sv_type);
+ }
+ break;
+ case SAMSUNG_FMM_TYPE:
+ {
+ _DEBUG_VERBOSE("add mscserver dmacc");
+ ret = add_dm_acc(sv_type);
+ }
+ break;
+ case GCF_TYPE:
+ {
+ _DEBUG_VERBOSE("add gcf dmacc");
+ ret = add_dm_acc(sv_type);
+ }
+ break;
+ default:
+ {
+ _DEBUG_VERBOSE("not exist server id error");
+ }
+ }
+
+ _DEBUG_VERBOSE("add dm acc error :%d", ret);
+
+ if (ret != DM_OK) {
+ ev_response = EVENT_RESPONSE_FAIL;
+ goto error;
+ }
+
+ ret = DB_End_Transaction(TRANSACTION_COMMIT_);
+ _DEBUG_VERBOSE("end transaction : %d", ret);
+
+ db_ret = sync_agent_close_mo();
+ _DEBUG_VERBOSE("mo db close : %d", db_ret);
+
+ DB_Close();
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+ _INNER_FUNC_EXIT;
+ return 0;
+
+ error:
+
+ ret = DB_End_Transaction(TRANSACTION_ROLLBACK_);
+ _DEBUG_VERBOSE("end transaction : %d", ret);
+
+ db_ret = sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_ROLLBACK);
+ _DEBUG_VERBOSE("end transaction : %d", db_ret);
+
+ db_ret = sync_agent_close_mo();
+ _DEBUG_VERBOSE("mo db close : %d", db_ret);
+
+ DB_Close();
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+ _INNER_FUNC_EXIT;
+ return 0;
+}
+
+static int __event_remove_dmacc(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_dm_mo_error_e db_ret = SYNC_AGENT_DM_MO_SUCCESS;
+ DM_ERROR ret = DM_OK;
+ engine_status *status = NULL;
+ ENGINE_STATUS engine_status = DM_IDLE;
+
+ EVENT_RESPONSE ev_response = EVENT_RESPONSE_OK;
+ SERVICE_SERVER_TYPE sv_type = NO_ENGINE_TYPE;
+
+ sync_agent_get_event_data_param(request, &sv_type);
+ _DEBUG_VERBOSE("server type : %d\n", sv_type);
+
+ //mo db
+ db_ret = sync_agent_open_mo();
+ _DEBUG_VERBOSE("mo db open : %d", db_ret);
+
+ //config, alram db
+ ret = DB_Open();
+ _DEBUG_VERBOSE("config alarm open : %d", db_ret);
+
+ int is_exist = IsExist_Engine_id(IDLE_ENGINE);
+ if (is_exist == 0)
+ goto error;
+
+ ret = Get_Engine_Status(IDLE_ENGINE, &status);
+ if (ret != DM_OK) {
+ _DEBUG_ERROR("Get_Engine_Status is not DM_OK");
+ goto error;
+ }
+
+ if(status == NULL) {
+ _DEBUG_ERROR("status is null");
+ goto error;
+ }
+
+ _DEBUG_VERBOSE("STATUS VALUE : %d ", status->engine_status);
+ engine_status = status->engine_status;
+
+ if (engine_status == DM_BEFORE_BOOTSTRAP) {
+ _DEBUG_VERBOSE("not bootstrap");
+ goto error;
+ }
+
+ db_ret = sync_agent_begin_transaction_mo();
+ _DEBUG_VERBOSE("end transaction : %d", db_ret);
+
+ ret = DB_Begin_Transaction();
+ _DEBUG_VERBOSE("end transaction : %d", ret);
+
+ switch (sv_type) {
+
+ case UI_SAMSUNG_FUMO_TYPE:
+ {
+ _DEBUG_VERBOSE("remove mscservertest dmacc");
+ ret = remove_dm_acc(DM_DMACC_MSCTESTSERVER);
+ if (ret != DM_OK) {
+ _DEBUG_ERROR("remove dm acc error :%d", ret);
+ goto error;
+ } else {
+ //config db
+ int is_exist = IsExist_Engine_id(FUMO_SERVICE_ENGINE);
+ if (is_exist == 0) {
+ _DEBUG_VERBOSE("not exist fumo engine");
+ }
+
+ ret = Delete_Engine_Status(FUMO_SERVICE_ENGINE);
+ if (ret != DM_OK) {
+ _DEBUG_ERROR("delete engine status :%d", ret);
+ goto error;
+ }
+ //alarm db
+ delete_alarm_item(FUMO_INTERVAL, FUMO_INTERVAL_TYPE);
+ _DEBUG_TRACE(" delete fumo reminder in config db ");
+
+ //delete delta file
+ delete_fumo_contents(MEMORY_INTERNAL);
+ delete_fumo_contents(MEMORY_SD_CARD);
+
+ //change fumo state 10
+ char *fumo_state = NULL;
+ fumo_state = g_strdup_printf("%s%s%s%s", MO_ROOT, MO_SEPERATOR, FUMO_SERVICE, DM_FUMO_STATE_OP);
+ set_current_fumo_state(fumo_state, IDLE_START);
+ str_free(&fumo_state);
+ }
+ }
+ break;
+ case UI_SAMSUNG_FMM_TYPE:
+ {
+ _DEBUG_VERBOSE("remove mscserver dmacc");
+ ret = remove_dm_acc(DM_DMACC_MSCSERVER);
+ if (ret != DM_OK) {
+ _DEBUG_ERROR("remove dm acc error :%d", ret);
+ goto error;
+ } else {
+
+ //config db
+ int is_exist = IsExist_Engine_id(LAWMO_SERVICE_ENGINE);
+ if (is_exist == 0) {
+ _DEBUG_VERBOSE("not exist fumo engine");
+ }
+
+ ret = Delete_Engine_Status(LAWMO_SERVICE_ENGINE);
+ if (ret != DM_OK) {
+ _DEBUG_ERROR("delete engine status :%d", ret);
+ goto error;
+ }
+
+ }
+ }
+ break;
+ case UI_GCF_TYPE:
+ {
+ _DEBUG_VERBOSE("remove gcf dmacc");
+ ret = remove_dm_acc(DM_DMACC_GCF);
+ if (ret != DM_OK) {
+ _DEBUG_ERROR("remove dm acc error :%d", ret);
+ goto error;
+ } else {
+ _DEBUG_VERBOSE("remove dm acc");
+ }
+ }
+ break;
+ default:
+ {
+ _DEBUG_VERBOSE("not exist server id error");
+ }
+ }
+
+ ret = DB_End_Transaction(TRANSACTION_COMMIT_);
+ _DEBUG_VERBOSE("end transaction : %d", ret);
+
+ db_ret = sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_COMMIT);
+ _DEBUG_VERBOSE("end transaction : %d", db_ret);
+
+ _DEBUG_VERBOSE("remove dm acc error :%d", ret);
+
+ db_ret = sync_agent_close_mo();
+ _DEBUG_VERBOSE("mo db close : %d", db_ret);
+
+ DB_Close();
+
+ if (status != NULL) {
+ Free_Memory_Engine_Status(&status, 1);
+ }
+
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+ _INNER_FUNC_EXIT;
+ return 0;
+ error:
+
+ ret = DB_End_Transaction(TRANSACTION_ROLLBACK_);
+ _DEBUG_VERBOSE("end transaction : %d", ret);
+
+ db_ret = sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_ROLLBACK);
+ _DEBUG_VERBOSE("end transaction : %d", db_ret);
+
+ db_ret = sync_agent_close_mo();
+ _DEBUG_VERBOSE("mo db close : %d", db_ret);
+
+ DB_Close();
+
+ if (status != NULL) {
+ Free_Memory_Engine_Status(&status, 1);
+ }
+
+ ev_response = EVENT_RESPONSE_FAIL;
+ sync_agent_append_event_data_param(response, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &ev_response);
+
+ _INNER_FUNC_EXIT;
+ return 0;
+}
+
+static int __event_callback_default(sync_agent_event_data_s * request, sync_agent_event_data_s * response)
+{
+ _INNER_FUNC_ENTER;
+ retvm_if((request) == NULL, 0, "request is NULL!!");
+
+ _DEBUG_VERBOSE("Undefined Event !!! \n");
+
+ _INNER_FUNC_EXIT;
+ return 0;
+}
+
+int set_IPC()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_event_error_e error = SYNC_AGENT_EVENT_IPC_ERR;
+ int event_id = 0;
+ for (event_id = 1; event_id < EVENT_NUM; event_id++) {
+ error = sync_agent_set_event_callback(event_id, _get_event_callback(event_id));
+ if (error != SYNC_AGENT_EVENT_SUCCESS) {
+ _DEBUG_INFO("FAILURE: sync_agent_set_event_callback (event id: %d)\n", event_id);
+ break;
+ } else {
+ _DEBUG_INFO("SUCCESS: sync_agent_set_event_callback (event id: %d)\n", event_id);
+
+ g_mutex_init(&(mutex));
+ g_cond_init(&(cond));
+ }
+ }
+
+ _DEBUG_INFO("%s: end (error:%d, event_id:%d) \n", __func__, error, event_id);
+ _EXTERN_FUNC_EXIT;
+ return error;
+}
+
+int noti_start(char *ui_mode)
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("-----------------------------------------------------------------------noti start-------------------------------------------------------------------------------------");
+ _EXTERN_FUNC_EXIT;
+ return _IPC_noti(IPC_NOTI_TYPE_0, NOTI_ENGINE_START, 0, ui_mode, NULL);
+}
+
+int noti_download()
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("-----------------------------------------------------------------------noti_connect_to_server-------------------------------------------------------------------------------------");
+ _EXTERN_FUNC_EXIT;
+ return _IPC_noti(IPC_NOTI_TYPE_0, NOTI_DOWNLOAD, 0, NULL, NULL);
+}
+
+int noti_install()
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("-----------------------------------------------------------------------noti_install-------------------------------------------------------------------------------------");
+ _EXTERN_FUNC_EXIT;
+ return _IPC_noti(IPC_NOTI_TYPE_0, NOTI_INSTALL, 0, NULL, NULL);
+}
+
+int noti_send_download_info(int filesize, char *path)
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("-----------------------------------------------------------------------noti_send_download_info-------------------------------------------------------------------------------------");
+ _EXTERN_FUNC_EXIT;
+ return _IPC_noti(IPC_NOTI_TYPE_0, NOTI_DOWNLOAD_INFO, filesize, path, NULL);
+}
+
+int noti_low_battery(char *battery_level)
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("-----------------------------------------------------------------------noti_low_battery-------------------------------------------------------------------------------------");
+ _EXTERN_FUNC_EXIT;
+ return _IPC_noti(IPC_NOTI_TYPE_0, NOTI_LOW_BATTERY, 0, battery_level, NULL);
+}
+
+int alert_uic_display(uic_data * uic_value)
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("-----------------------------------------------------------------------noti_alert_ui_display-------------------------------------------------------------------------------------");
+ _EXTERN_FUNC_EXIT;
+ return _IPC_noti(IPC_NOTI_TYPE_0, NOTI_ALERT_DISPLAY, 0, OMADM_ALERT_UI_TYPE, uic_value);
+}
+
+int alert_uic_confirmation(uic_data * uic_value)
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("-----------------------------------------------------------------------noti_alert_ui_confirmation-------------------------------------------------------------------------------------");
+ _EXTERN_FUNC_EXIT;
+ return _IPC_noti(IPC_NOTI_TYPE_0, NOTI_ALERT_CONFIRMATION, 0, OMADM_ALERT_UI_TYPE, uic_value);
+}
+
+int alert_uic_inputText(uic_data * uic_value)
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("-----------------------------------------------------------------------noti_alert_ui_inputText-------------------------------------------------------------------------------------");
+ _EXTERN_FUNC_EXIT;
+ return _IPC_noti(IPC_NOTI_TYPE_0, NOTI_ALERT_INPUTTEXT, 0, OMADM_ALERT_UI_TYPE, uic_value);
+}
+
+int alert_uic_single_choice(uic_data * uic_value)
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("-----------------------------------------------------------------------noti_alert_ui_single_choice-------------------------------------------------------------------------------------");
+ _EXTERN_FUNC_EXIT;
+ return _IPC_noti(IPC_NOTI_TYPE_0, NOTI_ALERT_SINGLE_CHOICE, 0, OMADM_ALERT_UI_TYPE, uic_value);
+}
+
+int alert_uic_multiple_choice(uic_data * uic_value)
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("-----------------------------------------------------------------------noti_alert_ui_multi_choice-------------------------------------------------------------------------------------");
+ _EXTERN_FUNC_EXIT;
+ return _IPC_noti(IPC_NOTI_TYPE_0, NOTI_ALERT_MULTIPLE_CHOICE, 0, OMADM_ALERT_UI_TYPE, uic_value);
+}
+
+int noti_engine_fail(int prev_noti_id, int fail_type)
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("-----------------------------------------------------------------------noti_engine_fail-------------------------------------------------------------------------------------");
+ _EXTERN_FUNC_EXIT;
+ return _IPC_noti(IPC_NOTI_TYPE_0, NOTI_ENGINE_FAIL, prev_noti_id, 0, &fail_type);
+}
+
+int noti_wifi_only_download_fail()
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("-----------------------------------------------------------------------noti_wifi_only_download_fail-------------------------------------------------------------------------------------");
+ _EXTERN_FUNC_EXIT;
+ return _IPC_noti(IPC_NOTI_TYPE_0, NOTI_WIFI_ONLY_DOWNLOAD_FAIL, 0, 0, 0);
+}
+
+int noti_memory_full(int file_size)
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("-----------------------------------------------------------------------noti_memory_full-------------------------------------------------------------------------------------");
+ _EXTERN_FUNC_EXIT;
+ return _IPC_noti(IPC_NOTI_TYPE_0, NOTI_MEMORY_FULL, file_size, 0, 0);
+}
+
+int noti_over_max_file_size()
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO("-----------------------------------------------------------------------noti_over_max_file_size-------------------------------------------------------------------------------------");
+ _EXTERN_FUNC_EXIT;
+ return _IPC_noti(IPC_NOTI_TYPE_0, NOTI_OVER_BIG_SIZE, 0, 0, 0);
+}
+
+static int _IPC_noti(int noti_type, int noti_id, int input_param, char *input_string, void *user_data)
+{
+ _INNER_FUNC_ENTER;
+
+ int ret = RESPONSE_TYPE_NONE;
+ int task_id = -1;
+ char *ui_mode = NULL;
+ int count = 0;
+ GList *iter = NULL;
+ uic_data *uic_value = NULL;
+ sync_agent_event_data_s *noti = NULL;
+ sync_agent_event_data_s *reply_msg = NULL;
+ sync_agent_event_error_e err = SYNC_AGENT_EVENT_FAIL;
+
+ task_id = sync_agent_get_self_request_id();
+ _DEBUG_TRACE("task : id %d ", task_id);
+ if (task_id == -1) {
+ ret = RESPONSE_TYPE_CANCEL;
+ _INNER_FUNC_EXIT;
+ goto return_part;
+ }
+
+ ret = get_fumo_ui_mode(&ui_mode);
+ _DEBUG_TRACE("get ui mode : %d", ret);
+ if (ret != DM_OK) {
+ ret = RESPONSE_TYPE_CANCEL;
+ _INNER_FUNC_EXIT;
+ return ret;
+ }
+
+ _DEBUG_TRACE("ui mode : %s", ui_mode);
+ ret = __check_ui_mode(&ui_mode, input_string);
+ if (ret != RESPONSE_TYPE_OK) {
+ str_free(&(ui_mode));
+ _INNER_FUNC_EXIT;
+ return RESPONSE_TYPE_CANCEL;
+ }
+ _DEBUG_TRACE("ui mode : %s", ui_mode);
+
+ ret = __launch_ui(ui_mode, noti_type);
+ if (ret == -1) {
+ str_free(&(ui_mode));
+ _INNER_FUNC_EXIT;
+ return RESPONSE_TYPE_CANCEL;
+ } else if (ret == 0) {
+ str_free(&(ui_mode));
+ _INNER_FUNC_EXIT;
+ return RESPONSE_TYPE_OK;
+ }
+
+ _DEBUG_TRACE("ui mode : %s", ui_mode);
+ _DEBUG_TRACE("create noti noti_id : %d", noti_id);
+
+ noti = sync_agent_create_noti(noti_id);
+ if (noti == NULL) {
+ _DEBUG_TRACE("failed to sync_agent_create_noti");
+ str_free(&(ui_mode));
+ _INNER_FUNC_EXIT;
+ return ret;
+ }
+
+ _DEBUG_TRACE("append_eventdata");
+ switch (noti_id) {
+ case NOTI_UNKNOWN:
+ break;
+ case NOTI_DOWNLOAD: //Type 0
+ break;
+ case NOTI_INSTALL: //Type 0
+ break;
+ case NOTI_DOWNLOAD_INFO: //Type 0
+ {
+ if (&input_param == NULL || input_string == NULL) {
+ _DEBUG_TRACE("Error: input param: NULL\n");
+ ret = RESPONSE_TYPE_CANCEL;
+ _INNER_FUNC_EXIT;
+ goto return_part;
+ }
+ _DEBUG_TRACE("agent noti: filesize:%d, path:%s\n", input_param, input_string);
+
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &input_param);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, input_string);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &task_id);
+ }
+ break;
+ case NOTI_ENGINE_START: //Type 0
+ {
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &task_id);
+ }
+ break;
+ case NOTI_ENGINE_FAIL: //Type 0
+ {
+ int *fail_type = (int *)(user_data);
+
+ _DEBUG_TRACE("noti id : %d\n", input_param);
+ _DEBUG_TRACE("fail : %d\n", *fail_type);
+
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &input_param);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, fail_type);
+ }
+ break;
+ case NOTI_WIFI_ONLY_DOWNLOAD_FAIL: //Type 0
+ {
+ _DEBUG_TRACE("wifi only downlaod fail ipc");
+ }
+ break;
+ case NOTI_MEMORY_FULL: //Type 0
+ {
+ _DEBUG_TRACE("memory full ipc : %d", input_param);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &input_param);
+
+ }
+ break;
+ case NOTI_OVER_BIG_SIZE: //Type 0
+ {
+ _DEBUG_TRACE("over max size");
+ }
+ break;
+ case NOTI_LOW_BATTERY: //Type 0
+ {
+ if (input_string == NULL) {
+
+ _DEBUG_TRACE("Error : input string : NULL\n");
+ ret = RESPONSE_TYPE_CANCEL;
+ _INNER_FUNC_EXIT;
+ goto return_part;
+ }
+
+ _DEBUG_TRACE("agent noti - battery level : %s\n", input_string);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, input_string);
+ }
+ break;
+ case NOTI_ALERT_DISPLAY: //Type 2, response event
+ case NOTI_ALERT_CONFIRMATION: //Type 2, response event
+ case NOTI_ALERT_INPUTTEXT: //Type 2, response event
+ {
+ _DEBUG_TRACE("uic flow noti type : %d", noti_id);
+ uic_value = (uic_data *) user_data;
+
+ uic_timeout_val = atoi(uic_value->pUic_option->max_t);
+
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, uic_value->pUic_option->min_t);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, uic_value->pUic_option->max_t);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, uic_value->pUic_option->default_data);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, uic_value->pUic_option->maxlen);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, uic_value->pUic_option->input_type);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, uic_value->pUic_option->echo_type);
+
+ _DEBUG_TRACE("display : %s\n", uic_value->display);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, uic_value->display);
+ }
+ break;
+ case NOTI_ALERT_SINGLE_CHOICE: //Type 2, response event
+ case NOTI_ALERT_MULTIPLE_CHOICE: //Type 2, response event
+ {
+ uic_value = (uic_data *) user_data;
+
+ uic_timeout_val = atoi(uic_value->pUic_option->max_t);
+
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, uic_value->pUic_option->min_t);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, uic_value->pUic_option->max_t);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, uic_value->pUic_option->default_data);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, uic_value->pUic_option->maxlen);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, uic_value->pUic_option->input_type);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, uic_value->pUic_option->echo_type);
+
+ _DEBUG_TRACE("display : %s\n", uic_value->display);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, uic_value->display);
+
+ count = g_list_length(uic_value->multi_data);
+ _DEBUG_TRACE("choice data count : %d\n", count);
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &count);
+
+ for (iter = uic_value->multi_data; iter != NULL; iter = g_list_next(iter)) {
+ _DEBUG_TRACE("choice data : %s", (char *)(iter->data));
+ sync_agent_append_event_data_param(noti, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (char *)(iter->data));
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ if (noti_id != NOTI_ALERT_DISPLAY && noti_id != NOTI_ALERT_CONFIRMATION && noti_id != NOTI_ALERT_INPUTTEXT && noti_id != NOTI_ALERT_SINGLE_CHOICE && noti_id != NOTI_ALERT_MULTIPLE_CHOICE) {
+ DB_Begin_Transaction();
+
+ ret = Update_Engine_Status_Column(FUMO_SERVICE_ENGINE, VALUE_UI_NOTI_TYPE, &noti_id);
+ if (ret != DM_OK) {
+ _DEBUG_TRACE("update engine status column : %d, %d\n", ret, noti_id);
+ ret = RESPONSE_TYPE_CANCEL;
+ goto return_part;
+ }
+ }
+
+ _DEBUG_TRACE("sendNoti");
+ reply_msg = sync_agent_send_noti(ui_mode, noti, __dm_task_process_check_cancel_flag, ui_mode, &err);
+ if(reply_msg == NULL) {
+ _DEBUG_TRACE("sendNoti return : %d", err);
+ } else {
+ _DEBUG_TRACE("sendNoti return : %d , event_num[%d] , reply_msg data[%s]", err, reply_msg->event_num, reply_msg->data);
+ }
+ if (err != SYNC_AGENT_EVENT_SUCCESS) {
+ if (err == SYNC_AGENT_EVENT_IPC_ERR) {
+ //todo : ui off
+ if (noti_id != NOTI_ALERT_DISPLAY && noti_id != NOTI_ALERT_CONFIRMATION && noti_id != NOTI_ALERT_INPUTTEXT && noti_id != NOTI_ALERT_SINGLE_CHOICE && noti_id != NOTI_ALERT_MULTIPLE_CHOICE) {
+ DB_End_Transaction(TRANSACTION_ROLLBACK_);
+ }
+ }
+
+ _DEBUG_TRACE("sendNoti (noti id:%d), FAIL\n", noti_id);
+ ret = RESPONSE_TYPE_CANCEL;
+ goto return_part;
+
+ } else {
+
+ _DEBUG_TRACE("sendNoti (noti id:%d), success\n", noti_id);
+ _DEBUG_TRACE("IPC RESPONSE\n");
+
+ if (noti_id != NOTI_ALERT_DISPLAY && noti_id != NOTI_ALERT_CONFIRMATION && noti_id != NOTI_ALERT_INPUTTEXT && noti_id != NOTI_ALERT_SINGLE_CHOICE && noti_id != NOTI_ALERT_MULTIPLE_CHOICE) {
+ DB_End_Transaction(TRANSACTION_COMMIT_);
+ } else {
+ ret = __uic_response(noti_id, user_data);
+ _DEBUG_TRACE("uic_response ret : %d", ret);
+ }
+ }
+
+ if (ret == DM_OK) {
+ ret = RESPONSE_TYPE_OK;
+ }
+
+ str_free(&(ui_mode));
+ sync_agent_free_noti(noti);
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ return_part:
+
+ str_free(&(ui_mode));
+ sync_agent_free_noti(noti);
+ _DEBUG_TRACE("%s : end : %d\n", __func__, ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+sync_agent_event_ipc_cancel_e __dm_task_process_check_cancel_flag(void *user_data)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((user_data) == NULL, SYNC_AGENT_EVENT_IPC_CANCEL_NEED_CANCEL, "user_data is NULL!!");
+
+ sync_agent_ec_boolean cancel_flag = sync_agent_check_cancel_flag();
+ sync_agent_event_ipc_cancel_e result_cancel;
+ int result_ui;
+ char *ui_mode = (char *)user_data;
+
+ if (cancel_flag == 0) {
+ result_cancel = SYNC_AGENT_EVENT_IPC_CANCEL_UN_NEED_CANCEL;
+ _DEBUG_VERBOSE("%s : cancel_flag = %d\n", __func__, result_cancel);
+ } else {
+ result_cancel = SYNC_AGENT_EVENT_IPC_CANCEL_NEED_CANCEL;
+ _DEBUG_VERBOSE("%s : cancel_flag = %d\n", __func__, result_cancel);
+ }
+
+ if (strcmp(ui_mode, OMADM_FUMO_UI_TYPE) == 0) {
+ result_ui = aul_app_is_running(OMA_DM_FUMO_UI_PKG);
+ if (result_ui == 0) {
+ _DEBUG_VERBOSE("oma dm fumo ui process off \n");
+ result_cancel = SYNC_AGENT_EVENT_IPC_CANCEL_NEED_CANCEL;
+ }
+ } else if (strcmp(ui_mode, OMADM_FUMO_NOTI_UI_TYPE) == 0) {
+ result_ui = aul_app_is_running(OMA_DM_FUMO_NOTI_UI_PKG);
+ if (result_ui == 0) {
+ _DEBUG_VERBOSE("oma dm noti ui process off \n");
+ result_cancel = SYNC_AGENT_EVENT_IPC_CANCEL_NEED_CANCEL;
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return result_cancel;
+}
+
+static int __uic_response(int noti_id, void *user_data)
+{
+ _INNER_FUNC_ENTER;
+ int ret = RESPONSE_TYPE_NONE;
+
+ switch (noti_id) {
+ case NOTI_ALERT_DISPLAY: //Type 0
+ {
+ _DEBUG_TRACE("display alert response ");
+ ret = RESPONSE_TYPE_OK;
+ }
+ break;
+ case NOTI_ALERT_CONFIRMATION: //Type 0
+ {
+ _DEBUG_TRACE("confirmation alert response ");
+
+ //signal on
+ if (uic_timeout_val == TIMEOUT_VAL_UIC) {
+ uic_timeout_val = TIMEOUT_VAL_UIC + REST_TIMEOUT_VAL;
+ } else {
+ uic_timeout_val += REST_TIMEOUT_VAL;
+ }
+
+ timeout = g_get_monotonic_time() + uic_timeout_val * G_TIME_SPAN_SECOND;
+
+ _DEBUG_TRACE("timeout : %d ", timeout);
+
+ g_mutex_lock(&(mutex));
+ g_cond_wait_until(&(cond), &(mutex), timeout);
+ g_mutex_unlock(&(mutex));
+
+ if (res_uic_data == NULL) {
+ /*signal by timeout */
+ ret = RESPONSE_TYPE_TIMEOVER;
+ } else {
+ ret = res_uic_data->status;
+ _DEBUG_TRACE("response is %d\n", ret);
+
+ free_res_data(res_uic_data);
+ res_uic_data = NULL;
+ }
+ }
+ break;
+ case NOTI_ALERT_INPUTTEXT: //Type 0
+ {
+ //signal on
+ if (uic_timeout_val == TIMEOUT_VAL_UIC) {
+ uic_timeout_val = TIMEOUT_VAL_UIC + REST_TIMEOUT_VAL;
+ } else {
+ uic_timeout_val += REST_TIMEOUT_VAL;
+ }
+
+ timeout = g_get_monotonic_time() + uic_timeout_val * G_TIME_SPAN_SECOND;
+
+ _DEBUG_TRACE("timeout : %d ", timeout);
+
+ g_mutex_lock(&(mutex));
+ g_cond_wait_until(&(cond), &(mutex), timeout);
+ g_mutex_unlock(&(mutex));
+
+ uic_data *uic_value = (uic_data *) user_data;
+
+ if (res_uic_data == NULL) {
+ /*signal by timeout */
+ uic_value->res_data->input_text = strdup("NULL");
+ _DEBUG_TRACE("INPUT TEXT CANCEL / TIMEOVER");
+ ret = RESPONSE_TYPE_TIMEOVER;
+ } else {
+ ret = res_uic_data->status;
+ _DEBUG_TRACE("response is %d\n", ret);
+ _DEBUG_TRACE("input text alert response ");
+
+ if (ret == RESPONSE_TYPE_OK) {
+ if (res_uic_data->input_text == NULL) {
+ res_uic_data->input_text = strdup("NULL");
+ }
+
+ uic_value->res_data->input_text = strdup(res_uic_data->input_text);
+
+ } else {
+ uic_value->res_data->input_text = strdup("NULL");
+ _DEBUG_TRACE("INPUT TEXT CANCEL / TIMEOVER");
+ }
+
+ free_res_data(res_uic_data);
+ res_uic_data = NULL;
+ }
+ }
+ break;
+ case NOTI_ALERT_SINGLE_CHOICE: //Type 0
+ case NOTI_ALERT_MULTIPLE_CHOICE: //Type 0
+ {
+
+ //signal on
+ if (uic_timeout_val == TIMEOUT_VAL_UIC) {
+ uic_timeout_val = TIMEOUT_VAL_UIC + REST_TIMEOUT_VAL;
+ } else {
+ uic_timeout_val += REST_TIMEOUT_VAL;
+ }
+
+ timeout = g_get_monotonic_time() + uic_timeout_val * G_TIME_SPAN_SECOND;
+ _DEBUG_TRACE("timeout : %d ", timeout);
+
+ g_mutex_lock(&(mutex));
+ g_cond_wait_until(&(cond), &(mutex), timeout);
+ g_mutex_unlock(&(mutex));
+
+ _DEBUG_TRACE("choice alert response ");
+
+ uic_data *uic_value = (uic_data *) user_data;
+ int count = 0;
+ char *input = NULL;
+
+ if (res_uic_data == NULL) {
+ /*signal by timeout */
+ ret = RESPONSE_TYPE_TIMEOVER;
+ input = strdup("NULL");
+ uic_value->res_data->res_multi_data = g_list_append(uic_value->res_data->res_multi_data, input);
+ _DEBUG_TRACE("CHOICE CANCEL / TIMEOVER");
+ } else {
+ ret = res_uic_data->status;
+ _DEBUG_TRACE("response is %d\n", ret);
+
+ if (ret == RESPONSE_TYPE_OK) {
+
+ if (res_uic_data->res_multi_data != NULL) {
+ count = g_list_length(res_uic_data->res_multi_data);
+
+ if (count == 0) {
+ input = strdup("NULL");
+ uic_value->res_data->res_multi_data = g_list_append(uic_value->res_data->res_multi_data, input);
+ } else {
+ GList *iter = NULL;
+ for (iter = res_uic_data->res_multi_data; iter != NULL; iter = g_list_next(iter)) {
+ input = NULL;
+ input = strdup(iter->data);
+ uic_value->res_data->res_multi_data = g_list_append(uic_value->res_data->res_multi_data, input);
+ }
+ }
+ } else {
+ input = strdup("NULL");
+ uic_value->res_data->res_multi_data = g_list_append(uic_value->res_data->res_multi_data, input);
+ _DEBUG_TRACE("CHOICE CANCEL / TIMEOVER");
+ }
+ }
+
+ free_res_data(res_uic_data);
+ res_uic_data = NULL;
+ }
+ }
+ break;
+ case NOTI_DOWNLOAD:
+ case NOTI_INSTALL:
+ case NOTI_DOWNLOAD_INFO:
+ case NOTI_ENGINE_START:
+ case NOTI_LOW_BATTERY:
+ case NOTI_OVER_BIG_SIZE:
+ break;
+
+ default:
+ break;
+ }
+
+ _INNER_FUNC_EXIT;
+ return ret;
+}
diff --git a/src/agent/framework/ui-event-handler/user-interaction/user_interaction.c b/src/agent/framework/ui-event-handler/user-interaction/user_interaction.c
new file mode 100644
index 0000000..dd9d5f1
--- /dev/null
+++ b/src/agent/framework/ui-event-handler/user-interaction/user_interaction.c
@@ -0,0 +1,407 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <unistd.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "framework/ui-event-handler/user-interaction/user_interaction.h"
+#include "serviceadapter/sa_util.h"
+#include "ipc_agent.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_UI"
+#endif
+
+#define TIMEOUT_MIN_VAL 10
+#define TIMEOUT_MAX_VAL 60
+#define TIEM_ZERO "0"
+
+void free_uic_value(uic_data ** uic_value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (uic_value != NULL) {
+ if (*uic_value != NULL) {
+ str_free(&((*uic_value)->display));
+ if ((*uic_value)->multi_data != NULL) {
+ GList *iter = NULL;
+ char *data = NULL;
+ for (iter = (*uic_value)->multi_data; iter != NULL; iter = g_list_next(iter)) {
+ data = (char *)(iter->data);
+ str_free(&(data));
+
+ }
+ }
+ if ((*uic_value)->pUic_option != NULL) {
+ str_free(&((*uic_value)->pUic_option->default_data));
+ str_free(&((*uic_value)->pUic_option->echo_type));
+ str_free(&((*uic_value)->pUic_option->input_type));
+ str_free(&((*uic_value)->pUic_option->max_t));
+ str_free(&((*uic_value)->pUic_option->maxlen));
+ str_free(&((*uic_value)->pUic_option->min_t));
+ free((*uic_value)->pUic_option);
+ (*uic_value)->pUic_option = NULL;
+ }
+ if ((*uic_value)->res_data != NULL) {
+ free_res_data((*uic_value)->res_data);
+ (*uic_value)->res_data = NULL;
+ }
+ free((*uic_value));
+ (*uic_value) = NULL;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void free_res_data(uic_res_data * res_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if((res_data) == NULL, "res data is NULL!!");
+
+ res_data->status = 0;
+ res_data->type = UIC_NONE_TYPE;
+
+ str_free(&(res_data->input_text));
+
+ if (res_data->res_multi_data != NULL) {
+ GList *iter = NULL;
+ char *data = NULL;
+ for (iter = res_data->res_multi_data; iter != NULL; iter = g_list_next(iter)) {
+ data = (char *)(iter->data);
+ str_free(&(data));
+ }
+ }
+ free(res_data);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+DM_ERROR exec_userinteration_option(char *data, uic_option ** uic_value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ char *findValue = NULL;
+
+ if (data == NULL) {
+ _DEBUG_INFO("uic_data null");
+ (*uic_value)->min_t = strdup("0");
+ (*uic_value)->max_t = g_strdup_printf("%d", TIMEOUT_MAX_VAL);
+ (*uic_value)->default_data = strdup("0");
+ (*uic_value)->maxlen = strdup("0");
+ (*uic_value)->input_type = strdup("0");
+ (*uic_value)->echo_type = strdup("0");
+
+ } else {
+
+ ret = findStgringValue(data, UI_OP_MINDT, UI_OP_EQUAL, &findValue);
+ if (findValue != NULL) {
+ if (!strncmp(findValue, TIEM_ZERO, strlen(TIEM_ZERO))) {
+ (*uic_value)->min_t = g_strdup_printf("%d", TIMEOUT_MIN_VAL);
+ } else {
+ (*uic_value)->min_t = strdup(findValue);
+ }
+ str_free(&findValue);
+ } else {
+ (*uic_value)->min_t = g_strdup_printf("%d", TIMEOUT_MIN_VAL);
+ }
+ _DEBUG_INFO("min time : %s", (*uic_value)->min_t);
+ /*UI value setting */
+ ret = findStgringValue(data, UI_OP_MAXDT, UI_OP_EQUAL, &findValue);
+ if (findValue != NULL) {
+ _DEBUG_INFO("max time : %s", findValue);
+ if (!strncmp(findValue, TIEM_ZERO, strlen(TIEM_ZERO))) {
+ (*uic_value)->max_t = g_strdup_printf("%d", TIMEOUT_MAX_VAL);
+ } else {
+ (*uic_value)->max_t = strdup(findValue);
+ }
+ str_free(&findValue);
+ } else {
+ (*uic_value)->max_t = g_strdup_printf("%d", TIMEOUT_MAX_VAL);
+ }
+ _DEBUG_INFO("max time : %s", (*uic_value)->max_t);
+ /*UI value setting */
+ ret = findStgringValue(data, UI_OP_DR, UI_OP_EQUAL, &findValue);
+ if (findValue != NULL) {
+ _DEBUG_INFO("default data: %s", findValue);
+ (*uic_value)->default_data = strdup(findValue);
+ str_free(&findValue);
+ } else {
+ (*uic_value)->default_data = strdup("0");
+ }
+ /*UI value setting */
+ ret = findStgringValue(data, UI_OP_MAXLEN, UI_OP_EQUAL, &findValue);
+ if (findValue != NULL) {
+ _DEBUG_INFO("max len : %s", findValue);
+ (*uic_value)->maxlen = strdup(findValue);
+ str_free(&findValue);
+ } else {
+ (*uic_value)->maxlen = strdup("0");
+ }
+ /*UI value setting */
+ ret = findStgringValue(data, UI_OP_IT, UI_OP_EQUAL, &findValue);
+ if (findValue != NULL) {
+ _DEBUG_INFO("input type : %s", findValue);
+ (*uic_value)->input_type = strdup(findValue);
+ str_free(&findValue);
+ } else {
+ (*uic_value)->input_type = strdup("0");
+ }
+
+ /*UI value setting */
+ ret = findStgringValue(data, UI_OP_ET, UI_OP_EQUAL, &findValue);
+ if (findValue != NULL) {
+ _DEBUG_INFO("echo_type : %s", findValue);
+ (*uic_value)->echo_type = strdup(findValue);
+ str_free(&findValue);
+ } else {
+ (*uic_value)->echo_type = strdup("0");
+ }
+ }
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR ui_display(uic_data * uic_value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((uic_value) == NULL, COMMON_ERR_IS_NULL, "uic_value is NULL!!");
+
+ int ui_ret = 0;
+
+ /* ui_ret = launch_om_dm_fumo_alert_ui();
+ if(ui_ret != 1) {
+ ret = DM_ALERT_UI_LAUNCH_ERROR;
+ goto error;
+ } else {
+ sleep(1);
+ */
+ ui_ret = alert_uic_display(uic_value);
+ if (ui_ret != 1) {
+ uic_value->res_data->status = DM_ERR_NOT_EXECUTED;
+ _DEBUG_INFO("display alert fail : %d", DM_ERR_NOT_EXECUTED);
+ } else {
+ uic_value->res_data->status = DM_OK;
+ _DEBUG_INFO("display alert success : %d", uic_value->res_data->status);
+ }
+ /*} */
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+/*error:
+ _EXTERN_FUNC_EXIT;
+ return ret;*/
+}
+
+DM_ERROR ui_confirm_or_reject(uic_data * uic_value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((uic_value) == NULL, COMMON_ERR_IS_NULL, "uic_value is NULL!!");
+
+ /* cancel -> atomic, sequence */
+ int ui_ret = 0;
+ /* ui_ret = launch_om_dm_fumo_alert_ui();
+ if(ui_ret != 1) {
+ ret = DM_ALERT_UI_LAUNCH_ERROR;
+ goto error;
+ } else {
+ sleep(1);
+ */
+ ui_ret = alert_uic_confirmation(uic_value);
+
+ if (ui_ret == 1) {
+ //ok
+ uic_value->res_data->status = DM_OK;
+ _DEBUG_INFO("display alert success : %d", DM_OK);
+ } else {
+ /*calcel or app launch fail or timeout */
+ uic_value->res_data->status = DM_ERR_NOT_MODIFIED;
+ _DEBUG_INFO("confirm alert fail : %d", DM_ERR_NOT_MODIFIED);
+ }
+ /*} */
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+/*error:
+ _EXTERN_FUNC_EXIT;
+ return ret;*/
+}
+
+DM_ERROR ui_text_input(uic_data * uic_value, char **result_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((uic_value) == NULL, COMMON_ERR_IS_NULL, "uic_value is NULL!!");
+
+ int ui_ret = 0;
+ /* ui_ret = launch_om_dm_fumo_alert_ui();
+ if(ui_ret != 1) {
+ ret = DM_ALERT_UI_LAUNCH_ERROR;
+ goto error;
+ } else {
+ sleep(1);
+ */
+ ui_ret = alert_uic_inputText(uic_value);
+
+ if (ui_ret == 1) {
+
+ if (uic_value->res_data->input_text != NULL) {
+ (*result_data) = strdup(uic_value->res_data->input_text);
+ uic_value->res_data->status = DM_OK;
+ _DEBUG_INFO("test input alert success : %d", DM_OK);
+ } else {
+ (*result_data) = strdup("NULL");
+ uic_value->res_data->status = DM_ERR_NOT_EXECUTED;
+ _DEBUG_INFO("input alert fail : %d", DM_ERR_NOT_EXECUTED);
+ }
+ } else {
+ /*calcel or app launch fail */
+ (*result_data) = strdup("NULL");
+ uic_value->res_data->status = DM_ERR_NOT_EXECUTED;
+ _DEBUG_INFO("input alert fail : %d", DM_ERR_NOT_EXECUTED);
+ }
+ /* } */
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+/*error:
+ _EXTERN_FUNC_EXIT;
+ return ret;*/
+}
+
+DM_ERROR ui_single_choice(uic_data * uic_value, GList ** responseItems)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((uic_value) == NULL, COMMON_ERR_IS_NULL, "uic_value is NULL!!");
+
+ int ui_ret = 0;
+ /* ui_ret = launch_om_dm_fumo_alert_ui();
+ if(ui_ret != 1) {
+ ret = DM_ALERT_UI_LAUNCH_ERROR;
+ goto error;
+ } else {
+ sleep(1);
+ */
+ ui_ret = alert_uic_single_choice(uic_value);
+ if (ui_ret == 1) {
+ if (uic_value->res_data->res_multi_data != NULL) {
+ GList *iter = NULL;
+ for (iter = uic_value->res_data->res_multi_data; iter != NULL; iter = g_list_next(iter)) {
+ char *data = NULL;
+ _DEBUG_INFO("choice data : %s", (char *)(iter->data));
+ data = strdup((char *)(iter->data));
+ (*responseItems) = g_list_append((*responseItems), data);
+ }
+ uic_value->res_data->status = DM_OK;
+ _DEBUG_INFO("single choice alert success : %d", DM_OK);
+ } else {
+ /*calcel or app launch fail */
+ char *data = NULL;
+ data = strdup("NULL");
+ (*responseItems) = g_list_append((*responseItems), data);
+ uic_value->res_data->status = DM_ERR_NOT_EXECUTED;
+ _DEBUG_INFO("single choice alert fail : %d", DM_ERR_NOT_EXECUTED);
+ }
+ } else {
+ /*calcel or app launch fail or timeout */
+ char *data = NULL;
+ data = strdup("NULL");
+ (*responseItems) = g_list_append((*responseItems), data);
+ uic_value->res_data->status = DM_ERR_NOT_EXECUTED;
+ _DEBUG_INFO("single choice alert fail : %d", DM_ERR_NOT_EXECUTED);
+ }
+ //}
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+/*error:
+ _EXTERN_FUNC_EXIT;
+ return ret;*/
+}
+
+DM_ERROR ui_multiple_choice(uic_data * uic_value, GList ** responseItems)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((uic_value) == NULL, COMMON_ERR_IS_NULL, "uic_value is NULL!!");
+
+ int ui_ret = 0;
+ /* ui_ret = launch_om_dm_fumo_alert_ui();
+ if(ui_ret != 1) {
+ ret = DM_ALERT_UI_LAUNCH_ERROR;
+ goto error;
+ } else { */
+ sleep(1);
+ ui_ret = alert_uic_multiple_choice(uic_value);
+ if (ui_ret == 1) {
+ if (uic_value->res_data->res_multi_data != NULL) {
+ GList *iter = NULL;
+ for (iter = uic_value->res_data->res_multi_data; iter != NULL; iter = g_list_next(iter)) {
+ char *data = NULL;
+ _DEBUG_INFO("choice data : %s", (char *)(iter->data));
+ data = strdup((char *)(iter->data));
+ (*responseItems) = g_list_append((*responseItems), data);
+ }
+ uic_value->res_data->status = DM_OK;
+ _DEBUG_INFO("multiple choice alert success : %d", DM_OK);
+ } else {
+ /*calcel or app launch fail */
+ char *data = NULL;
+ data = strdup("NULL");
+ (*responseItems) = g_list_append((*responseItems), data);
+ uic_value->res_data->status = DM_ERR_NOT_EXECUTED;
+ _DEBUG_INFO("multiple choice alert fail : %d", DM_ERR_NOT_EXECUTED);
+ }
+
+ } else {
+ /*calcel or app launch fail */
+ char *data = NULL;
+ data = strdup("NULL");
+ (*responseItems) = g_list_append((*responseItems), data);
+ uic_value->res_data->status = DM_ERR_NOT_EXECUTED;
+ _DEBUG_INFO("multiple choice alert fail : %d", DM_ERR_NOT_EXECUTED);
+ }
+// }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+/*error:
+
+ _EXTERN_FUNC_EXIT;
+ return ret;*/
+}
diff --git a/src/agent/main.c b/src/agent/main.c
new file mode 100755
index 0000000..256840b
--- /dev/null
+++ b/src/agent/main.c
@@ -0,0 +1,264 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <unistd.h>
+#include <libxml/parser.h>
+#include <signal.h>
+
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus.h>
+//#include <appcore-common.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "framework/task/oma_dm_task_request.h"
+#include "ipc_agent.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM"
+#endif
+
+#define MC_SERVICE_OBJECT_PATH "/com/samsung/omadmagent" /* Don't use special character */
+#define MC_SERVICE_DBUS "com.samsung.omadmagent"
+#define MC_SERVICE_INTERFACE "com.samsung.omadmagent"
+
+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");
+ FILE *file_exist = NULL;
+ file_exist = fopen("/opt/data/fota/oma-dm/.oma-dm-agent-enabled", "r");
+ if (file_exist != NULL) {
+ _DEBUG_INFO("file oma-dm-agent-enabled exist!!");
+ fclose(file_exist);
+ } else {
+ _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 _agent_daemon_signal_handler(int signo, siginfo_t * info, void *p_context)
+{
+ _EXTERN_FUNC_ENTER;
+
+ switch (signo) {
+ case SIGTERM:
+ _DEBUG_INFO("Got SIGTERM");
+
+ /* stop gmain loop */
+ sync_agent_stop_main_loop(0);
+
+ break;
+
+ default:
+ break;
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+int main()
+{
+ _EXTERN_FUNC_ENTER;
+// _DEBUG_INFO("[TIME] 1. main : %d msec\n", appcore_measure_time_from("APP_START_TIME"));
+// appcore_measure_start();
+
+ sync_agent_deinit_error_e deinit_error = SYNC_AGENT_DEINIT_SUCCESS;
+ sync_agent_init_error_e init_error = SYNC_AGENT_INIT_SUCCESS;
+ struct sigaction sig_act;
+
+ if (sync_agent_daemonize() < 0) {
+ _DEBUG_ERROR("daemonize error");
+ return -1;
+ }
+// _DEBUG_INFO("[TIME] 2. main : %d msec\n", appcore_measure_time());
+// appcore_measure_start();
+ xmlInitParser();
+
+ _register_dbus_service();
+
+ init_error = sync_agent_init("/usr/share/oma-dm-cfg/fw-init/omadm_fw_config.xml");
+ if (init_error != SYNC_AGENT_INIT_SUCCESS) {
+ _DEBUG_ERROR("Failed to OMA DM sync_agent_init() : %d", init_error);
+ return -1;
+ } else {
+ _DEBUG_INFO("done init_Framework - OMA DM");
+ }
+
+ /*for network connection */
+ DM_ERROR ret = DM_OK;
+ int return_Ipc = 0;
+ //sleep(4);
+ //network_connection_delay();
+ return_Ipc = set_IPC();
+ _DEBUG_INFO("return ipc : %d", return_Ipc);
+
+ check_csc();
+
+ ret = init_dm();
+ _DEBUG_INFO("return init dm : %d", ret);
+/* if (ret != DM_OK) {
+ goto error;
+ }*/
+
+ ret = dm_init_task_request();
+ if (ret != DM_OK) {
+ goto error;
+ }
+
+ /* 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);
+
+ ret = end_dm();
+ if (ret != DM_OK) {
+ _DEBUG_ERROR("end_dm() failed !!");
+ goto error;
+ }
+
+ if (connection) {
+ dbus_connection_unref(connection);
+ connection = NULL;
+ }
+
+ deinit_error = sync_agent_deinit();
+ if (deinit_error != SYNC_AGENT_DEINIT_SUCCESS) {
+ _DEBUG_ERROR("deinit fail : %d!!", deinit_error);
+ }
+
+ xmlCleanupParser();
+
+ _EXTERN_FUNC_EXIT;
+
+ return 1;
+
+ error:
+ _DEBUG_ERROR("end error : %d\n", ret);
+
+ if (connection) {
+ dbus_connection_unref(connection);
+ connection = NULL;
+ }
+
+ deinit_error = sync_agent_deinit();
+ if (deinit_error != SYNC_AGENT_DEINIT_SUCCESS) {
+ _DEBUG_ERROR("deinit fail : %d!!", deinit_error);
+ }
+
+ xmlCleanupParser();
+
+ _EXTERN_FUNC_EXIT;
+
+ return 0;
+}
diff --git a/src/agent/mo-handler/dm_mo_common.c b/src/agent/mo-handler/dm_mo_common.c
new file mode 100755
index 0000000..5278757
--- /dev/null
+++ b/src/agent/mo-handler/dm_mo_common.c
@@ -0,0 +1,1522 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "serviceadapter/sa_session.h"
+#include "serviceadapter/protocolbinder/syncml_def.h"
+#include "serviceadapter/sa_elements_internal.h"
+#include "mo-handler/dm_mo_common.h"
+#include "mo-handler/dm_mo_handler.h"
+#include "dm-engine/bootstrap/factory_bootstrap.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "MO_ENGINE"
+#endif
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /* mo test interface */
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/*
+
+void dmacc_define_fumo() {
+ _DEBUG_INFO( " start!!\n");
+
+ sync_agent_dm_mo_type_e type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+
+ char *mo_full_path0 = FUMO_DM_ACC;
+ char *value0 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type0 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path00 = FUMO_DM_ACC_FUMO;
+ char *value00 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type00 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path1 = FUMO_DM_ACC_APPID;
+ char *value1 = "w7";
+ sync_agent_dm_mo_node_type_e mo_node_type1 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path2 = FUMO_DM_ACC_SERVERID;
+ char *value2 = "x6g1q14r75";
+ sync_agent_dm_mo_node_type_e mo_node_type2 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path3 = FUMO_DM_ACC_NAME;
+ char *value3 = "slp_msc_fumo";
+ sync_agent_dm_mo_node_type_e mo_node_type3 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path4 = FUMO_DM_ACC_PRECONREF;
+ char *value4 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type4 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path5 = FUMO_DM_ACC_TOCONREF;
+ char *value5 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type5 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path6 =FUMO_DM_ACC_TOCONREF_X;
+ char *value6 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type6 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path7 =FUMO_DM_ACC_TOCONREF_X_CONREF;
+ char *value7 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type7 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path8 =FUMO_DM_ACC_APPADDR;
+ char *value8 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type8 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path9 =FUMO_DM_ACC_APPADDR_X;
+ char *value9 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type9 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path10 =FUMO_DM_ACC_APPADDR_X_ADDR;
+ char *value10 ="https://121.252.197.81:443/v1/device/magicsync/mdm";
+ sync_agent_dm_mo_node_type_e mo_node_type10 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path11 =FUMO_DM_ACC_APPADDR_X_ADDRTYPE;
+ char *value11 = "IPv4";
+ sync_agent_dm_mo_node_type_e mo_node_type11 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path12 =FUMO_DM_ACC_APPADDR_X_PORT;
+ char *value12 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type12 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path13 =FUMO_DM_ACC_APPADDR_X_PORT_X;
+ char *value13 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type13 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path14 =FUMO_DM_ACC_APPADDR_X_PORT_X_PORTNBR;
+ char *value14 ="443";
+ sync_agent_dm_mo_node_type_e mo_node_type14 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path15 =FUMO_DM_ACC_AAUTHPREF;
+ char *value15 = "DIGEST";
+ sync_agent_dm_mo_node_type_e mo_node_type15 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path16 =FUMO_DM_ACC_APPAUTH;
+ char *value16 =NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type16 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path17 = FUMO_DM_ACC_APPAUTH_X1;
+ char *value17 =NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type17 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path18 = FUMO_DM_ACC_APPAUTH_X1_AAUTHLEVEL;
+ char *value18 ="CLCRED";
+ sync_agent_dm_mo_node_type_e mo_node_type18 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path19 = FUMO_DM_ACC_APPAUTH_X1_AAUTHTYPE;
+ char *value19 ="DIGEST";
+ sync_agent_dm_mo_node_type_e mo_node_type19 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path20 = FUMO_DM_ACC_APPAUTH_X1_AAUTHNAME;
+ char *value20;
+
+ sync_agent_get_devinfo(2, "DevID", &value20 );//"IMEI:004401055493403";
+ MO_NODE_TYPE mo_node_type20 = MO_NODE_LEAF;
+
+ char *mo_full_path21 = FUMO_DM_ACC_APPAUTH_X1_SECRET;
+ char *value21 = generate_Device_Password_temp( value20, value2);
+ sync_agent_dm_mo_node_type_e mo_node_type21 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path22 = FUMO_DM_ACC_APPAUTH_X1_AAUTHDATA;
+ char *value22 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type22 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path23 = FUMO_DM_ACC_APPAUTH_X2;
+ char *value23 =NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type23 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path24 = FUMO_DM_ACC_APPAUTH_X2_AAUTHLEVEL;
+ char *value24 ="SRVRED";
+ sync_agent_dm_mo_node_type_e mo_node_type24 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path25 = FUMO_DM_ACC_APPAUTH_X2_AAUTHTYPE;
+ char *value25 ="DIGEST";
+ sync_agent_dm_mo_node_type_e mo_node_type25 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path26 = FUMO_DM_ACC_APPAUTH_X2_AAUTHNAME;
+ char *value26 ="x6g1q14r75";
+ sync_agent_dm_mo_node_type_e mo_node_type26 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path27 = FUMO_DM_ACC_APPAUTH_X2_SECRET;
+ char *value27 ="T1NQIERNIFNIcnZIcg==";
+ sync_agent_dm_mo_node_type_e mo_node_type27 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path28 = FUMO_DM_ACC_APPAUTH_X2_AAUTHDATA;
+ char *value28 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type28 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path29 = FUMO_DM_ACC_EXT;
+ char *value29 =NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type29 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ sync_agent_dm_mo_framework_property_s *framework_property = NULL;
+ sync_agent_dm_mo_runtime_property_s *runtime_property = NULL;
+
+ _DEBUG_INFO( " add start!!\n");
+
+ add_mo(type, mo_full_path0, value0, mo_node_type0, framework_property, runtime_property);
+ add_mo(type, mo_full_path00, value00, mo_node_type00, framework_property, runtime_property);
+ add_mo(type, mo_full_path1, value1, mo_node_type1, framework_property, runtime_property);
+ add_mo(type, mo_full_path2, value2, mo_node_type2, framework_property, runtime_property);
+ add_mo(type, mo_full_path3, value3, mo_node_type3, framework_property, runtime_property);
+ add_mo(type, mo_full_path4, value4, mo_node_type4, framework_property, runtime_property);
+ add_mo(type, mo_full_path5, value5, mo_node_type5, framework_property, runtime_property);
+ add_mo(type, mo_full_path6, value6, mo_node_type6, framework_property, runtime_property);
+ add_mo(type, mo_full_path7, value7, mo_node_type7, framework_property, runtime_property);
+ add_mo(type, mo_full_path8, value8, mo_node_type8, framework_property, runtime_property);
+ add_mo(type, mo_full_path9, value9, mo_node_type9, framework_property, runtime_property);
+ add_mo(type, mo_full_path10, value10, mo_node_type10, framework_property, runtime_property);
+ add_mo(type, mo_full_path11, value11, mo_node_type11, framework_property, runtime_property);
+ add_mo(type, mo_full_path12, value12, mo_node_type12, framework_property, runtime_property);
+ add_mo(type, mo_full_path13, value13, mo_node_type13, framework_property, runtime_property);
+ add_mo(type, mo_full_path14, value14, mo_node_type14, framework_property, runtime_property);
+ add_mo(type, mo_full_path15, value15, mo_node_type15, framework_property, runtime_property);
+ add_mo(type, mo_full_path16, value16, mo_node_type16, framework_property, runtime_property);
+ add_mo(type, mo_full_path17, value17, mo_node_type17, framework_property, runtime_property);
+ add_mo(type, mo_full_path18, value18, mo_node_type18, framework_property, runtime_property);
+ add_mo(type, mo_full_path19, value19, mo_node_type19, framework_property, runtime_property);
+ add_mo(type, mo_full_path20, value20, mo_node_type20, framework_property, runtime_property);
+ add_mo(type, mo_full_path21, value21, mo_node_type21, framework_property, runtime_property);
+ add_mo(type, mo_full_path22, value22, mo_node_type22, framework_property, runtime_property);
+ add_mo(type, mo_full_path23, value23, mo_node_type23, framework_property, runtime_property);
+ add_mo(type, mo_full_path24, value24, mo_node_type24, framework_property, runtime_property);
+ add_mo(type, mo_full_path25, value25, mo_node_type25, framework_property, runtime_property);
+ add_mo(type, mo_full_path26, value26, mo_node_type26, framework_property, runtime_property);
+ add_mo(type, mo_full_path27, value27, mo_node_type27, framework_property, runtime_property);
+ add_mo(type, mo_full_path28, value28, mo_node_type28, framework_property, runtime_property);
+ add_mo(type, mo_full_path29, value29, mo_node_type29, framework_property, runtime_property);
+
+ _DEBUG_INFO( " end!!\n");
+}
+
+void dmacc_define_lawmo() {
+ _DEBUG_INFO( " start!!\n");
+
+ sync_agent_dm_mo_type_e type = SYNC_AGENT_DM_MO_TYPE_DMACC;
+
+ char *mo_full_path0 = LAWMO_DM_ACC;
+ char *value0 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type0 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path00 = LAWMO_DM_ACC_LAWMO;
+ char *value00 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type00 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path1 = LAWMO_DM_ACC_APPID;
+ char *value1 = "w7";
+ sync_agent_dm_mo_node_type_e mo_node_type1 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path2 = LAWMO_DM_ACC_SERVERID;
+ char *value2 = "5e8o9279r2";
+ sync_agent_dm_mo_node_type_e mo_node_type2 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path3 = LAWMO_DM_ACC_NAME;
+ char *value3 = "slp_msc_lawmo";
+ sync_agent_dm_mo_node_type_e mo_node_type3 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path4 = LAWMO_DM_ACC_PRECONREF;
+ char *value4 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type4 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path5 = LAWMO_DM_ACC_TOCONREF;
+ char *value5 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type5 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path6 =LAWMO_DM_ACC_TOCONREF_X;
+ char *value6 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type6 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path7 =LAWMO_DM_ACC_TOCONREF_X_CONREF;
+ char *value7 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type7 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path8 =LAWMO_DM_ACC_APPADDR;
+ char *value8 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type8 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path9 =LAWMO_DM_ACC_APPADDR_X;
+ char *value9 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type9 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path10 =LAWMO_DM_ACC_APPADDR_X_ADDR;
+ char *value10 ="https://dm.samsungdive.com:443/v1/sdm/magicsync/dm";
+ sync_agent_dm_mo_node_type_e mo_node_type10 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path11 =LAWMO_DM_ACC_APPADDR_X_ADDRTYPE;
+ char *value11 = "IPv4";
+ sync_agent_dm_mo_node_type_e mo_node_type11 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path12 =LAWMO_DM_ACC_APPADDR_X_PORT;
+ char *value12 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type12 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path13 =LAWMO_DM_ACC_APPADDR_X_PORT_X;
+ char *value13 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type13 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path14 =LAWMO_DM_ACC_APPADDR_X_PORT_X_PORTNBR;
+ char *value14 ="443";
+ sync_agent_dm_mo_node_type_e mo_node_type14 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path15 =LAWMO_DM_ACC_AAUTHPREF;
+ char *value15 = "DIGEST";
+ sync_agent_dm_mo_node_type_e mo_node_type15 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path16 =LAWMO_DM_ACC_APPAUTH;
+ char *value16 =NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type16 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path17 = LAWMO_DM_ACC_APPAUTH_X1;
+ char *value17 =NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type17 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path18 = LAWMO_DM_ACC_APPAUTH_X1_AAUTHLEVEL;
+ char *value18 ="CLCRED";
+ sync_agent_dm_mo_node_type_e mo_node_type18 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path19 = LAWMO_DM_ACC_APPAUTH_X1_AAUTHTYPE;
+ char *value19 ="DIGEST";
+ sync_agent_dm_mo_node_type_e mo_node_type19 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path20 = LAWMO_DM_ACC_APPAUTH_X1_AAUTHNAME;
+ char *value20;
+
+ sync_agent_get_devinfo(2, "DevID", &value20 );//"IMEI:004401055493403";
+ sync_agent_dm_mo_node_type_e mo_node_type20 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path21 = LAWMO_DM_ACC_APPAUTH_X1_SECRET;
+ char *value21 = generate_Device_Password_temp( value20, value2);
+ sync_agent_dm_mo_node_type_e mo_node_type21 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path22 = LAWMO_DM_ACC_APPAUTH_X1_AAUTHDATA;
+ char *value22 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type22 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path23 = LAWMO_DM_ACC_APPAUTH_X2;
+ char *value23 =NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type23 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path24 = LAWMO_DM_ACC_APPAUTH_X2_AAUTHLEVEL;
+ char *value24 ="SRVRED";
+ sync_agent_dm_mo_node_type_e mo_node_type24 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path25 = LAWMO_DM_ACC_APPAUTH_X2_AAUTHTYPE;
+ char *value25 ="DIGEST";
+ sync_agent_dm_mo_node_type_e mo_node_type25 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path26 = LAWMO_DM_ACC_APPAUTH_X2_AAUTHNAME;
+ char *value26 ="5e8o9279r2";
+ sync_agent_dm_mo_node_type_e mo_node_type26 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path27 = LAWMO_DM_ACC_APPAUTH_X2_SECRET;
+ char *value27 ="T1NQIERNIFNlcnZlcg==";
+ sync_agent_dm_mo_node_type_e mo_node_type27 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path28 = LAWMO_DM_ACC_APPAUTH_X2_AAUTHDATA;
+ char *value28 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type28 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path29 = LAWMO_DM_ACC_EXT;
+ char *value29 =NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type29 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ sync_agent_dm_mo_framework_property_s *framework_property = NULL;
+ sync_agent_dm_mo_runtime_property_s *runtime_property = NULL;
+
+ _DEBUG_INFO( " add start!!\n");
+
+ add_mo(type, mo_full_path0, value0, mo_node_type0, framework_property, runtime_property);
+ add_mo(type, mo_full_path00, value00, mo_node_type00, framework_property, runtime_property);
+ add_mo(type, mo_full_path1, value1, mo_node_type1, framework_property, runtime_property);
+ add_mo(type, mo_full_path2, value2, mo_node_type2, framework_property, runtime_property);
+ add_mo(type, mo_full_path3, value3, mo_node_type3, framework_property, runtime_property);
+ add_mo(type, mo_full_path4, value4, mo_node_type4, framework_property, runtime_property);
+ add_mo(type, mo_full_path5, value5, mo_node_type5, framework_property, runtime_property);
+ add_mo(type, mo_full_path6, value6, mo_node_type6, framework_property, runtime_property);
+ add_mo(type, mo_full_path7, value7, mo_node_type7, framework_property, runtime_property);
+ add_mo(type, mo_full_path8, value8, mo_node_type8, framework_property, runtime_property);
+ add_mo(type, mo_full_path9, value9, mo_node_type9, framework_property, runtime_property);
+ add_mo(type, mo_full_path10, value10, mo_node_type10, framework_property, runtime_property);
+ add_mo(type, mo_full_path11, value11, mo_node_type11, framework_property, runtime_property);
+ add_mo(type, mo_full_path12, value12, mo_node_type12, framework_property, runtime_property);
+ add_mo(type, mo_full_path13, value13, mo_node_type13, framework_property, runtime_property);
+ add_mo(type, mo_full_path14, value14, mo_node_type14, framework_property, runtime_property);
+ add_mo(type, mo_full_path15, value15, mo_node_type15, framework_property, runtime_property);
+ add_mo(type, mo_full_path16, value16, mo_node_type16, framework_property, runtime_property);
+ add_mo(type, mo_full_path17, value17, mo_node_type17, framework_property, runtime_property);
+ add_mo(type, mo_full_path18, value18, mo_node_type18, framework_property, runtime_property);
+ add_mo(type, mo_full_path19, value19, mo_node_type19, framework_property, runtime_property);
+ add_mo(type, mo_full_path20, value20, mo_node_type20, framework_property, runtime_property);
+ add_mo(type, mo_full_path21, value21, mo_node_type21, framework_property, runtime_property);
+ add_mo(type, mo_full_path22, value22, mo_node_type22, framework_property, runtime_property);
+ add_mo(type, mo_full_path23, value23, mo_node_type23, framework_property, runtime_property);
+ add_mo(type, mo_full_path24, value24, mo_node_type24, framework_property, runtime_property);
+ add_mo(type, mo_full_path25, value25, mo_node_type25, framework_property, runtime_property);
+ add_mo(type, mo_full_path26, value26, mo_node_type26, framework_property, runtime_property);
+ add_mo(type, mo_full_path27, value27, mo_node_type27, framework_property, runtime_property);
+ add_mo(type, mo_full_path28, value28, mo_node_type28, framework_property, runtime_property);
+ add_mo(type, mo_full_path29, value29, mo_node_type29, framework_property, runtime_property);
+
+ _DEBUG_INFO( " end!!\n");
+}
+
+ void devinfo_define() {
+ _DEBUG_INFO( " start!!\n");
+
+ sync_agent_dm_mo_type_e type = SYNC_AGENT_DM_MO_TYPE_DEVINFO;
+
+ char *mo_full_path0 = DM_DEVINFO;
+ char *value0 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type0 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path1 = DM_DEVINFO_BEARER;
+ char *value1 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type1 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path2 = DM_DEVINFO_DEVID;
+ char *value2;
+
+ sync_agent_get_devinfo(2, "DevID", &value2 );//"IMEI:004401055493403";
+ sync_agent_dm_mo_node_type_e mo_node_type2 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path3 = DM_DEVINFO_MAN;
+ char *value3 = "samsung-electronics";
+ sync_agent_dm_mo_node_type_e mo_node_type3 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path4 = DM_DEVINFO_MOD;
+ char *value4 = "GT-I9500";
+ sync_agent_dm_mo_node_type_e mo_node_type4 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path5 = DM_DEVINFO_DMV;
+ char *value5 = "1.2";
+ sync_agent_dm_mo_node_type_e mo_node_type5 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path6 =DM_DEVINFO_LANG;
+ char *value6 = "en-us";
+ sync_agent_dm_mo_node_type_e mo_node_type6 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path7 =DM_DEVINFO_EXT;
+ char *value7 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type7 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ sync_agent_dm_mo_framework_property_s *framework_property = NULL;
+ sync_agent_dm_mo_runtime_property_s *runtime_property = NULL;
+
+ _DEBUG_INFO( " add start!!\n");
+
+ add_mo(type, mo_full_path0, value0, mo_node_type0, framework_property, runtime_property);
+ add_mo(type, mo_full_path1, value1, mo_node_type1, framework_property, runtime_property);
+ add_mo(type, mo_full_path2, value2, mo_node_type2, framework_property, runtime_property);
+ add_mo(type, mo_full_path3, value3, mo_node_type3, framework_property, runtime_property);
+ add_mo(type, mo_full_path4, value4, mo_node_type4, framework_property, runtime_property);
+ add_mo(type, mo_full_path5, value5, mo_node_type5, framework_property, runtime_property);
+ add_mo(type, mo_full_path6, value6, mo_node_type6, framework_property, runtime_property);
+ add_mo(type, mo_full_path7, value7, mo_node_type7, framework_property, runtime_property);
+
+ _DEBUG_INFO( " end!!\n");
+}
+ void devdetail_define() {
+ _DEBUG_INFO( " start!!\n");
+
+ sync_agent_dm_mo_type_e type = SYNC_AGENT_DM_MO_TYPE_DEVDETAIL;
+
+ char *mo_full_path0 = DM_DEVDETAIL;
+ char *value0 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type0 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path1 = DM_DEVDETAIL_BEARER;
+ char *value1 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type1 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path2 = DM_DEVINFO_URI;
+ char *value2 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type2 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path3 = DM_DEVINFO_URI_MAXDEPTH;
+ char *value3 = g_strdup_printf("%d",100);
+ sync_agent_dm_mo_node_type_e mo_node_type3 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path4 = DM_DEVINFO_URI_MAXTOTLEN;
+ char *value4 = g_strdup_printf("%d",100);;
+ sync_agent_dm_mo_node_type_e mo_node_type4 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path5 = DM_DEVINFO_URI_MAXSEGLEN;
+ char *value5 = g_strdup_printf("%d",100);;
+ sync_agent_dm_mo_node_type_e mo_node_type5 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path6 =DM_DEVINFO_DEVTYP;
+ char *value6 = "Smart";
+ sync_agent_dm_mo_node_type_e mo_node_type6 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path7 =DM_DEVINFO_OEM;
+ char *value7 = "null";
+ sync_agent_dm_mo_node_type_e mo_node_type7 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path8 =DM_DEVINFO_FWV;
+ char *value8 = "M.I9200XXKC1-P.I13-";
+ sync_agent_dm_mo_node_type_e mo_node_type8 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path9 =DM_DEVINFO_SWV;
+ char *value9 = "M.I9200XXKC1-P.I13-";
+ sync_agent_dm_mo_node_type_e mo_node_type9 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path10 =DM_DEVINFO_HWV;
+ char *value10 ="GT-I9500";
+ sync_agent_dm_mo_node_type_e mo_node_type10 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path11 =DM_DEVINFO_LRGOBJ;
+ char *value11 = "IPv4";
+ sync_agent_dm_mo_node_type_e mo_node_type11 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ sync_agent_dm_mo_framework_property_s *framework_property = NULL;
+ sync_agent_dm_mo_runtime_property_s *runtime_property = NULL;
+
+ _DEBUG_INFO( " add start!!\n");
+
+ add_mo(type, mo_full_path0, value0, mo_node_type0, framework_property, runtime_property);
+ add_mo(type, mo_full_path1, value1, mo_node_type1, framework_property, runtime_property);
+ add_mo(type, mo_full_path2, value2, mo_node_type2, framework_property, runtime_property);
+ add_mo(type, mo_full_path3, value3, mo_node_type3, framework_property, runtime_property);
+ add_mo(type, mo_full_path4, value4, mo_node_type4, framework_property, runtime_property);
+ add_mo(type, mo_full_path5, value5, mo_node_type5, framework_property, runtime_property);
+ add_mo(type, mo_full_path6, value6, mo_node_type6, framework_property, runtime_property);
+ add_mo(type, mo_full_path7, value7, mo_node_type7, framework_property, runtime_property);
+ add_mo(type, mo_full_path8, value8, mo_node_type8, framework_property, runtime_property);
+ add_mo(type, mo_full_path9, value9, mo_node_type9, framework_property, runtime_property);
+ add_mo(type, mo_full_path10, value10, mo_node_type10, framework_property, runtime_property);
+ add_mo(type, mo_full_path11, value11, mo_node_type11, framework_property, runtime_property);
+
+ _DEBUG_INFO( " ed!!\n");
+
+}
+
+ void fumo_define() {
+ _DEBUG_INFO( " start!!\n");
+
+ sync_agent_dm_mo_type_e type = SYNC_AGENT_DM_MO_TYPE_FUMO;
+
+ char *mo_full_path0 = DM_FUMO;
+ char *value0 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type0 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path1 = DM_FUMO_PKGNAME;
+ char *value1 = "0830_0831_FW_delta.tar";
+ sync_agent_dm_mo_node_type_e mo_node_type1 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path2 = DM_FUMO_VERSION;
+ char *value2 = "M.I9200XXKC1-P.I13-";
+ sync_agent_dm_mo_node_type_e mo_node_type2 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path3 = DM_FUMO_DOWNLOAD;
+ char *value3 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type3 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path4 = DM_FUMO_DWONLOAD_PKGURL;
+ char *value4 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type4 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path5 = DM_FUMO_UPDATE;
+ char *value5 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type5 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path6 =DM_FUMO_UPDATE_PKG_DATA;
+ char *value6 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type6 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path7 =DM_FUMO_DOWNLOADAND_UPDATE;
+ char *value7 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type7 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path8 =DM_FUMO_DOWNLOADAND_UPDATE_PKGURL;
+ char *value8 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type8 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path9 =DM_FUMO_STATE;
+ char *value9 = "10";
+ sync_agent_dm_mo_node_type_e mo_node_type9 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path10 =DM_FUMO_EXT;
+ char *value10 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type10 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ sync_agent_dm_mo_framework_property_s *framework_property = NULL;
+ sync_agent_dm_mo_runtime_property_s *runtime_property = NULL;
+
+ _DEBUG_INFO( " add start!!\n");
+
+ add_mo(type, mo_full_path0, value0, mo_node_type0, framework_property, runtime_property);
+ add_mo(type, mo_full_path1, value1, mo_node_type1, framework_property, runtime_property);
+ add_mo(type, mo_full_path2, value2, mo_node_type2, framework_property, runtime_property);
+ add_mo(type, mo_full_path3, value3, mo_node_type3, framework_property, runtime_property);
+ add_mo(type, mo_full_path4, value4, mo_node_type4, framework_property, runtime_property);
+ add_mo(type, mo_full_path5, value5, mo_node_type5, framework_property, runtime_property);
+ add_mo(type, mo_full_path6, value6, mo_node_type6, framework_property, runtime_property);
+ add_mo(type, mo_full_path7, value7, mo_node_type7, framework_property, runtime_property);
+ add_mo(type, mo_full_path8, value8, mo_node_type8, framework_property, runtime_property);
+ add_mo(type, mo_full_path9, value9, mo_node_type9, framework_property, runtime_property);
+ add_mo(type, mo_full_path10, value10, mo_node_type10, framework_property, runtime_property);
+
+ _DEBUG_INFO( " end!!\n");
+}
+ void lawmo_define() {
+
+ _DEBUG_INFO( " start!!\n");
+
+ sync_agent_dm_mo_type_e type = SYNC_AGENT_DM_MO_TYPE_LAWMO;
+
+ char *mo_full_path0 = DM_LAWMO;
+ char *value0 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type0 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path1 = DM_LAWMO_STATE;
+ char *value1 = "30";
+ sync_agent_dm_mo_node_type_e mo_node_type1 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path2 = DM_LAWMO_AVAILABLEWIPELIST;
+ char *value2 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type2 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path3 = DM_LAWMO_AVAILABLEWIPELIST_x1;
+ char *value3 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type3 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path4 = DM_LAWMO_AVAILABLEWIPELIST_x1_LISTITEMNAME;
+ char *value4 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type4 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path5 = DM_LAWMO_AVAILABLEWIPELIST_x1_TOBEWIPED;
+ char *value5 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type5 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path6 =DM_LAWMO_LAWMOCONFIG;
+ char *value6 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type6 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path7 =DM_LAWMO_LAWMOCONFIG_NOFITYUSER;
+ char *value7 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type7 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path8 =DM_LAWMO_OPERATIONS;
+ char *value8 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type8 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ char *mo_full_path9 =DM_LAWMO_OPERATIONS_FULLYLOCK;
+ char *value9 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type9 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path10 =DM_LAWMO_OPERATIONS_PARTIALLYLOCK;
+ char *value10 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type10 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path11 =DM_LAWMO_OPERATIONS_UNLOCK;
+ char *value11 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type11 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path12 =DM_LAWMO_OPERATIONS_FACTORYRESET;
+ char *value12 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type12 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path13 =DM_LAWMO_OPERATIONS_WIPE;
+ char *value13 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type13 = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ char *mo_full_path14 =DM_LAWMO_EXT;
+ char *value14 = NULL;
+ sync_agent_dm_mo_node_type_e mo_node_type14 = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ sync_agent_dm_mo_framework_property_s *framework_property = NULL;
+ sync_agent_dm_mo_runtime_property_s *runtime_property = NULL;
+
+ _DEBUG_INFO( " add start!!\n");
+
+ add_mo(type, mo_full_path0, value0, mo_node_type0, framework_property, runtime_property);
+ add_mo(type, mo_full_path1, value1, mo_node_type1, framework_property, runtime_property);
+ add_mo(type, mo_full_path2, value2, mo_node_type2, framework_property, runtime_property);
+ add_mo(type, mo_full_path3, value3, mo_node_type3, framework_property, runtime_property);
+ add_mo(type, mo_full_path4, value4, mo_node_type4, framework_property, runtime_property);
+ add_mo(type, mo_full_path5, value5, mo_node_type5, framework_property, runtime_property);
+ add_mo(type, mo_full_path6, value6, mo_node_type6, framework_property, runtime_property);
+ add_mo(type, mo_full_path7, value7, mo_node_type7, framework_property, runtime_property);
+ add_mo(type, mo_full_path8, value8, mo_node_type8, framework_property, runtime_property);
+ add_mo(type, mo_full_path9, value9, mo_node_type9, framework_property, runtime_property);
+ add_mo(type, mo_full_path10, value10, mo_node_type10, framework_property, runtime_property);
+ add_mo(type, mo_full_path11, value11, mo_node_type11, framework_property, runtime_property);
+ add_mo(type, mo_full_path12, value12, mo_node_type12, framework_property, runtime_property);
+ add_mo(type, mo_full_path13, value13, mo_node_type13, framework_property, runtime_property);
+ add_mo(type, mo_full_path14, value14, mo_node_type14, framework_property, runtime_property);
+
+ _DEBUG_INFO( " end!!\n");
+}
+
+*/
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /* mo common inteface */
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+void free_dm_acc(dm_acc * dmaccount)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (dmaccount == NULL)
+ return;
+
+ if (dmaccount->server_url != NULL) {
+ free(dmaccount->server_url);
+ dmaccount->server_url = NULL;
+ }
+ if (dmaccount->server_id != NULL) {
+ free(dmaccount->server_id);
+ dmaccount->server_id = NULL;
+ }
+ if (dmaccount->server_pw != NULL) {
+ free(dmaccount->server_pw);
+ dmaccount->server_pw = NULL;
+ }
+ if (dmaccount->server_auth_type != NULL) {
+ free(dmaccount->server_auth_type);
+ dmaccount->server_auth_type = NULL;
+ }
+ if (dmaccount->user_id != NULL) {
+ free(dmaccount->user_id);
+ dmaccount->user_id = NULL;
+ }
+ if (dmaccount->user_pw != NULL) {
+ free(dmaccount->user_pw);
+ dmaccount->user_pw = NULL;
+ }
+ if (dmaccount->user_auth_type != NULL) {
+ free(dmaccount->user_auth_type);
+ dmaccount->user_auth_type = NULL;
+ }
+ if (dmaccount->user_nextNonce != NULL) {
+ free(dmaccount->user_nextNonce);
+ dmaccount->user_nextNonce = NULL;
+ }
+ if (dmaccount->server_nextNonce != NULL) {
+ free(dmaccount->server_nextNonce);
+ dmaccount->server_nextNonce = NULL;
+ }
+
+ free(dmaccount);
+ dmaccount = NULL;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+DM_ERROR get_client_dmacc(char *pServer_id, char **client_id, char **client_pwd, char **sourceUrl, char **targetUrl, int *isBase64, char **nextNonce, char **authType)
+{
+
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ sync_agent_dev_return_e err;
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_acc_info_s *acc_info = NULL;
+ sync_agent_dm_mo_acc_item_info_s sync_agent_mo_acc_info_item;
+
+ sync_agent_mo_acc_info_item.acc_type = DEVICE_MANAGE_ACC_TYPE_CLIENT;
+ sync_agent_mo_acc_info_item.serverid = pServer_id;
+
+ err_code = sync_agent_get_mo_acc_item(&sync_agent_mo_acc_info_item, &acc_info);
+ //acc_info = sync_agent_get_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_CLIENT);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS || acc_info == NULL) {
+ _DEBUG_INFO(" acc null!!\n");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ _DEBUG_INFO(" id = %s\n", acc_info->auth_name);
+ _DEBUG_INFO(" pwd = %s\n", acc_info->auth_secret);
+/* _DEBUG_INFO( " Session_id = %s\n", pSession_id);*/
+ _DEBUG_INFO(" serverUrl = %s\n", acc_info->addr);
+ _DEBUG_INFO(" nextNonce = %s\n", acc_info->auth_data);
+
+ if ((acc_info->auth_name) == NULL || (acc_info->auth_secret) == NULL || (acc_info->addr) == NULL) {
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ (*client_id) = strdup(acc_info->auth_name);
+ (*client_pwd) = strdup(acc_info->auth_secret);
+ (*targetUrl) = strdup(acc_info->addr);
+ if (acc_info->auth_data != NULL) {
+ str_free(nextNonce);
+ (*nextNonce) = strdup(acc_info->auth_data);
+ }
+ //(*sourceUrl) = strdup("IMEI:004401055493403");
+ if (acc_info->auth_type != NULL)
+ (*authType) = strdup(acc_info->auth_type);
+
+ err = sync_agent_get_devinfo(2, "DevID", sourceUrl);
+ _DEBUG_INFO(" sourceUrl = %s\n", (*sourceUrl));
+
+ *isBase64 = 1;
+
+ sync_agent_free_mo_acc_item(&acc_info);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ ret = COMMON_ERR_MO_NOT_FOUND_IN_DB;
+ sync_agent_free_mo_acc_item(&acc_info);
+ _DEBUG_INFO(" end!! error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR get_server_dmacc(char *pServer_id, char **server_id, char **server_pwd, char **sourceUrl, char **targetUrl, int *isBase64, char **nextNonce, char **authType)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((pServer_id) == NULL, COMMON_ERR_IS_NULL, "pServer_id is NULL!!");
+
+ DM_ERROR ret = DM_OK;
+ sync_agent_dev_return_e err;
+
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_acc_info_s *acc_info = NULL;
+ sync_agent_dm_mo_acc_item_info_s sync_agent_mo_acc_info_item;
+
+ sync_agent_mo_acc_info_item.acc_type = DEVICE_MANAGE_ACC_TYPE_SERVER;
+ sync_agent_mo_acc_info_item.serverid = pServer_id;
+
+ err_code = sync_agent_get_mo_acc_item(&sync_agent_mo_acc_info_item, &acc_info);
+ //acc_info = sync_agent_get_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_CLIENT);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS || acc_info == NULL) {
+ _DEBUG_INFO(" acc null!!\n");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ _DEBUG_INFO(" id = %s\n", acc_info->auth_name);
+ _DEBUG_INFO(" pwd = %s\n", acc_info->auth_secret);
+/* _DEBUG_INFO( " Session_id = %s\n", pSession_id);*/
+ _DEBUG_INFO(" serverUrl = %s\n", acc_info->addr);
+ _DEBUG_INFO(" nextNonce = %s\n", acc_info->auth_data);
+
+ if ((acc_info->auth_name) == NULL || (acc_info->auth_secret) == NULL || (acc_info->addr) == NULL) {
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ (*server_id) = strdup(acc_info->auth_name);
+ (*server_pwd) = strdup(acc_info->auth_secret);
+ (*targetUrl) = strdup(acc_info->addr);
+ if (acc_info->auth_data != NULL)
+ (*nextNonce) = strdup(acc_info->auth_data);
+ //(*sourceUrl) = strdup("IMEI:004401055493403");
+ if (acc_info->auth_type != NULL)
+ (*authType) = strdup(acc_info->auth_type);
+
+ err = sync_agent_get_devinfo(2, "DevID", sourceUrl);
+ _DEBUG_INFO(" sourceUrl = %s\n", (*sourceUrl));
+
+ *isBase64 = 1;
+ // temp test code
+
+ sync_agent_free_mo_acc_item(&acc_info);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ sync_agent_free_mo_acc_item(&acc_info);
+ ret = COMMON_ERR_MO_NOT_FOUND_IN_DB;
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+int update_dmacc(char *pServer_id, dm_acc * dmaccount)
+{
+ _EXTERN_FUNC_ENTER;
+ int ret = 1;
+
+ retvm_if((pServer_id) == NULL, COMMON_ERR_IS_NULL, "pServer_id is NULL!!");
+
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_acc_info_s *acc_info_c = NULL;
+ sync_agent_dm_acc_info_s *acc_info_s = NULL;
+ sync_agent_dm_mo_acc_item_info_s sync_agent_mo_acc_info_item;
+
+ sync_agent_open_mo();
+ err_code = sync_agent_begin_transaction_mo();
+ _DEBUG_INFO("transanction begin : %d", err_code);
+
+ sync_agent_mo_acc_info_item.acc_type = DEVICE_MANAGE_ACC_TYPE_CLIENT;
+ sync_agent_mo_acc_info_item.serverid = pServer_id;
+
+ err_code = sync_agent_get_mo_acc_item(&sync_agent_mo_acc_info_item, &acc_info_c);
+ //acc_info = sync_agent_get_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_CLIENT);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS || acc_info_c == NULL) {
+ _DEBUG_INFO(" acc null!!\n");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ _DEBUG_INFO("user id = %s\n", dmaccount->user_id);
+ _DEBUG_INFO("user pwd = %s\n", dmaccount->user_pw);
+ _DEBUG_INFO("user auth type = %s\n", dmaccount->user_auth_type);
+ _DEBUG_INFO("user nextNonce = %s\n", dmaccount->user_nextNonce);
+
+ //if ((acc_info_c->auth_name) == NULL || (acc_info_c->auth_secret) == NULL || (acc_info_c->addr) == NULL) {
+ if ( (acc_info_c->addr) == NULL) {
+ ret = 0;
+ goto error;
+ }
+ if (dmaccount->user_id != NULL) {
+ if(acc_info_c->auth_name != NULL) {
+ str_free(&(acc_info_c->auth_name));
+ }
+ acc_info_c->auth_name = strdup(dmaccount->user_id);
+ }
+ if (dmaccount->user_pw != NULL) {
+ if(acc_info_c->auth_secret != NULL) {
+ str_free(&(acc_info_c->auth_secret));
+ }
+ acc_info_c->auth_secret = strdup(dmaccount->user_pw);
+ }
+ if (dmaccount->user_auth_type != NULL) {
+ str_free(&(acc_info_c->auth_type));
+ acc_info_c->auth_type = strdup(dmaccount->user_auth_type);
+ } else {
+ if (acc_info_c->auth_type != NULL) {
+ //do nothing
+ } else {
+ acc_info_c->auth_type = strdup("DIGEST");
+ }
+ }
+
+ if (dmaccount->user_nextNonce != NULL) {
+ str_free(&(acc_info_c->auth_data));
+ acc_info_c->auth_data = strdup(dmaccount->user_nextNonce);
+ }
+ //acc_info_c->auth_level = dmaccount->base64;
+ err_code = sync_agent_update_mo_acc_item(&sync_agent_mo_acc_info_item, acc_info_c);
+ //err_code = sync_agent_set_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_CLIENT, acc_info_c);
+ _DEBUG_INFO("sync agent update result : %d", err_code);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+ _DEBUG_INFO("set client account result : %d", err_code);
+
+/*************************************************************************************/
+
+ sync_agent_mo_acc_info_item.acc_type = DEVICE_MANAGE_ACC_TYPE_SERVER;
+ sync_agent_mo_acc_info_item.serverid = pServer_id;
+
+ err_code = sync_agent_get_mo_acc_item(&sync_agent_mo_acc_info_item, &acc_info_s);
+ //acc_info = sync_agent_get_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_CLIENT);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS || acc_info_s == NULL) {
+ _DEBUG_INFO(" acc null!!\n");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ _DEBUG_INFO("server id = %s\n", dmaccount->server_url);
+ _DEBUG_INFO("server id = %s\n", dmaccount->server_id);
+ _DEBUG_INFO("sever pwd = %s\n", dmaccount->server_pw);
+ _DEBUG_INFO("server auth type = %s\n", dmaccount->server_auth_type);
+ _DEBUG_INFO("server nextNonce = %s\n", dmaccount->server_nextNonce);
+
+ //if ((acc_info_s->auth_name) == NULL || (acc_info_s->auth_secret) == NULL || (acc_info_s->addr) == NULL) {
+ if ((acc_info_s->auth_name) == NULL || (acc_info_s->addr) == NULL) {
+ ret = 0;
+ goto error;
+ }
+
+ if (dmaccount->server_url != NULL) {
+ str_free(&(acc_info_s->addr));
+ acc_info_s->addr = strdup(dmaccount->server_url);
+ }
+ if (dmaccount->server_id != NULL) {
+ str_free(&(acc_info_s->auth_name));
+ acc_info_s->auth_name = strdup(dmaccount->server_id);
+ }
+ if (dmaccount->server_pw != NULL) {
+ if(acc_info_s->auth_secret != NULL) {
+ str_free(&(acc_info_s->auth_secret));
+ }
+ acc_info_s->auth_secret = strdup(dmaccount->server_pw);
+ }
+ if (dmaccount->server_auth_type != NULL) {
+ str_free(&(acc_info_s->auth_type));
+ acc_info_s->auth_type = strdup(dmaccount->server_auth_type);
+ }
+ if (dmaccount->server_nextNonce != NULL) {
+ str_free(&(acc_info_s->auth_data));
+ acc_info_s->auth_data = strdup(dmaccount->server_nextNonce);
+ }
+ //acc_info_s->auth_level = dmaccount->base64;
+ err_code = sync_agent_update_mo_acc_item(&sync_agent_mo_acc_info_item, acc_info_s);
+ //err_code = sync_agent_set_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_SERVER, acc_info_s);
+ _DEBUG_INFO("set server account result : %d", err_code);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ /*************************************************************************************/
+
+ err_code = sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_COMMIT);
+ _DEBUG_INFO("transanction commit : %d", err_code);
+ sync_agent_close_mo();
+
+ err_code = sync_agent_free_mo_acc_item(&acc_info_c);
+ _DEBUG_INFO("free mo acc result : %d", err_code);
+
+ err_code = sync_agent_free_mo_acc_item(&acc_info_s);
+ _DEBUG_INFO("free mo acc result : %d", err_code);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ err_code = sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_ROLLBACK);
+ _DEBUG_INFO("transanction rollback : %d", err_code);
+ sync_agent_close_mo();
+
+ err_code = sync_agent_free_mo_acc_item(&acc_info_c);
+ _DEBUG_INFO("free mo acc result : %d", err_code);
+
+ err_code = sync_agent_free_mo_acc_item(&acc_info_s);
+ _DEBUG_INFO("free mo acc result : %d", err_code);
+
+ _DEBUG_INFO(" end!! error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR get_dmacc_authType(char *pServer_id, AuthType * pAuthType)
+{
+ _EXTERN_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((pServer_id) == NULL, COMMON_ERR_IS_NULL, "pServer_id is NULL!!");
+
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_acc_info_s *acc_info = NULL;
+ sync_agent_dm_mo_acc_item_info_s sync_agent_mo_acc_info_item;
+
+ sync_agent_mo_acc_info_item.acc_type = DEVICE_MANAGE_ACC_TYPE_CLIENT;
+ sync_agent_mo_acc_info_item.serverid = pServer_id;
+
+ err_code = sync_agent_get_mo_acc_item(&sync_agent_mo_acc_info_item, &acc_info);
+ //acc_info = sync_agent_get_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_CLIENT);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS || acc_info == NULL) {
+ _DEBUG_INFO(" acc null!!\n");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ *pAuthType = __get_Session_AuthType_enum(acc_info->auth_type);
+
+ _DEBUG_INFO(" end!! auth type : %d\n", *pAuthType);
+
+ sync_agent_free_mo_acc_item(&acc_info);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+
+ ret = COMMON_ERR_MO_NOT_FOUND_IN_DB;
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR get_format(sync_agent_dm_mo_format_e format_enum, char **format)
+{
+ _EXTERN_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+ switch (format_enum) {
+ case SYNC_AGENT_DM_MO_FORMAT_NO_SET:
+ (*format) = strdup(ELEMENT_NULL);
+ break;
+ case SYNC_AGENT_DM_MO_FORMAT_B64:
+ (*format) = strdup(ELEMENT_B64);
+ break;
+ case SYNC_AGENT_DM_MO_FORMAT_BIN:
+ (*format) = strdup(ELEMENT_BIN);
+ break;
+ case SYNC_AGENT_DM_MO_FORMAT_BOOL:
+ (*format) = strdup(ELEMENT_BOOL);
+ break;
+ case SYNC_AGENT_DM_MO_FORMAT_CHR:
+ (*format) = strdup(ELEMENT_CHR);
+ break;
+ case SYNC_AGENT_DM_MO_FORMAT_INT:
+ (*format) = strdup(ELEMENT_INT);
+ break;
+ case SYNC_AGENT_DM_MO_FORMAT_NODE:
+ (*format) = strdup(ELEMENT_NODE);
+ break;
+ case SYNC_AGENT_DM_MO_FORMAT_NULL:
+ (*format) = strdup(ELEMENT_NULL);
+ break;
+ case SYNC_AGENT_DM_MO_FORMAT_XML:
+ (*format) = strdup(ELEMENT_XML);
+ break;
+ case SYNC_AGENT_DM_MO_FORMAT_DATE:
+ (*format) = strdup(ELEMENT_DATE);
+ break;
+ case SYNC_AGENT_DM_MO_FORMAT_TIME:
+ (*format) = strdup(ELEMENT_TIME);
+ break;
+ case SYNC_AGENT_DM_MO_FORMAT_FLOAT:
+ (*format) = strdup(ELEMENT_FLOAT);
+ break;
+ default:
+ break;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR get_format_enum(char *format, sync_agent_dm_mo_format_e * format_enum)
+{
+ _EXTERN_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((format) == NULL, COMMON_ERR_IS_NULL, "format is NULL!!");
+
+ if (!strcmp(format, ELEMENT_NULL)) {
+ (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_NO_SET;
+ } else if (!strcmp(format, ELEMENT_B64)) {
+ (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_B64;
+ } else if (!strcmp(format, ELEMENT_BIN)) {
+ (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_BIN;
+ } else if (!strcmp(format, ELEMENT_BOOL)) {
+ (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_BOOL;
+ } else if (!strcmp(format, ELEMENT_CHR)) {
+ (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_CHR;
+ } else if (!strcmp(format, ELEMENT_INT)) {
+ (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_INT;
+ } else if (!strcmp(format, ELEMENT_NODE)) {
+ (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_NODE;
+ } else if (!strcmp(format, ELEMENT_NULL)) {
+ (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_NULL;
+ } else if (!strcmp(format, ELEMENT_XML)) {
+ (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_XML;
+ } else if (!strcmp(format, ELEMENT_DATE)) {
+ (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_DATE;
+ } else if (!strcmp(format, ELEMENT_TIME)) {
+ (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_TIME;
+ } else if (!strcmp(format, ELEMENT_FLOAT)) {
+ (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_FLOAT;
+ } else {
+ (*format_enum) = SYNC_AGENT_DM_MO_FORMAT_NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+/*
+
+DM_ERROR get_contenttype(sync_agent_dm_mo_df_type_e contenttype_enum, char** contenttype)
+{
+ _DEBUG_INFO( " start!!\n");
+ DM_ERROR ret;
+
+ switch(contenttype_enum){
+ case SYNC_AGENT_DM_MO_DF_TYPE_NO_SET:
+ //(*contenttype) = strdup( (*mo_node)->runtime_property->type_value );
+ break;
+ case SYNC_AGENT_DM_MO_DF_TYPE_MIME:
+ //(*contenttype) = strdup( (*mo_node)->runtime_property->type_value );
+ break;
+ case SYNC_AGENT_DM_MO_DF_TYPE_DDFNAME:
+ //(*contenttype) = strdup( (*mo_node)->runtime_property->type_value );
+ break;
+ default:
+ break;
+ }
+
+ _DEBUG_INFO( " end!!\n");
+}
+*/
+
+void reset_dmacc_mscserver()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_open_mo();
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+
+ int is_exist = 0;
+
+ err_code = sync_agent_is_exist_mo(DM_DMACC_MSCSERVER, &is_exist);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_INFO("exist mo error : %d", err_code);
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+
+ if (is_exist != 1) {
+ _DEBUG_INFO("dm acc not exist");
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+
+ err_code = sync_agent_uptodate_mo_table(SYNC_AGENT_DM_MO_TYPE_DMACC, 5, DM_DMACC_MSCSERVER);
+ _DEBUG_INFO(" end!!: err_code : %d", err_code);
+ sync_agent_close_mo();
+
+ _EXTERN_FUNC_EXIT;
+
+}
+
+void reset_dmacc_msctestserver()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_open_mo();
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ int is_exist = 0;
+
+ err_code = sync_agent_is_exist_mo(DM_DMACC_MSCTESTSERVER, &is_exist);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_INFO("exist mo error : %d", err_code);
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+
+ if (is_exist != 1) {
+ _DEBUG_INFO("dm acc not exist");
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+
+ err_code = sync_agent_uptodate_mo_table(SYNC_AGENT_DM_MO_TYPE_DMACC, 6, DM_DMACC_MSCTESTSERVER);
+ _DEBUG_INFO(" end!!: err_code : %d", err_code);
+ sync_agent_close_mo();
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void reset_dmacc_gcf()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_open_mo();
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+
+ int is_exist = 0;
+
+ err_code = sync_agent_is_exist_mo(DM_DMACC_GCF, &is_exist);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_INFO("exist mo error : %d", err_code);
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+
+ if (is_exist != 1) {
+ _DEBUG_INFO("dm acc not exist");
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+
+ err_code = sync_agent_uptodate_mo_table(SYNC_AGENT_DM_MO_TYPE_DMACC, 4, DM_DMACC_GCF);
+ _DEBUG_INFO(" end!!: err_code : %d", err_code);
+ sync_agent_close_mo();
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void reset_devinfo()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_dm_mo_error_e err_code = sync_agent_uptodate_mo_table(SYNC_AGENT_DM_MO_TYPE_DEVINFO, 2, DM_DEVINFO);
+ _DEBUG_INFO(" end!!: err_code : %d", err_code);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void reset_devdetail()
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_dm_mo_error_e err_code = sync_agent_uptodate_mo_table(SYNC_AGENT_DM_MO_TYPE_DEVDETAIL, 1, DM_DEVDETAIL);
+ _DEBUG_INFO(" end!! : err_code : %d", err_code);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+DM_ERROR get_mo_root_path(const char *mo_full_path, char **root_path)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ char *temp_root = NULL;
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+
+ retvm_if((mo_full_path) == NULL, COMMON_ERR_IS_NULL, "mo_full_path is NULL!!");
+
+ err_code = sync_agent_get_root_path(mo_full_path, &temp_root);
+ _DEBUG_INFO("get root path : %d", err_code);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ _EXTERN_FUNC_EXIT;
+ return COMMON_ERR_IS_NULL;
+ }
+
+ _DEBUG_INFO("get root path : %s", temp_root);
+
+ if (temp_root != NULL) {
+ (*root_path) = strdup(temp_root);
+ _DEBUG_INFO(" root : %s\n", (*root_path));
+ }
+ _DEBUG_INFO(" root : %s\n", temp_root);
+ /*root_size = strlen(temp_root) - 2 ;
+ memcpy( (*root_path), temp_root + 2, root_size); */
+
+ if ((*root_path) == NULL) {
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO(" end!! error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+SERVICE_SERVER_TYPE get_engine_type_by_serverid(const char *server_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((server_id) == NULL, COMMON_ERR_IS_NULL, "server_id is NULL!!");
+
+ sync_agent_open_mo();
+ SERVICE_SERVER_TYPE engine_type = NO_ENGINE_TYPE;
+ SERVICE_SERVER_TYPE service_engine_type = NO_ENGINE_TYPE;
+
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ err_code = sync_agent_get_server_type(server_id, (int *)(&service_engine_type));
+ _DEBUG_INFO("get server type result : %d", err_code);
+ _DEBUG_INFO("service engine type : %d", service_engine_type);
+ if (service_engine_type != NO_ENGINE_TYPE) {
+ //todo change & operation
+ if ((service_engine_type & SAMSUNG_FUMO_TYPE) == SAMSUNG_FUMO_TYPE) {
+ engine_type = SAMSUNG_FUMO_TYPE;
+ _DEBUG_INFO("FUMO SERVICE");
+ } else if ((service_engine_type & SAMSUNG_FMM_TYPE) == SAMSUNG_FMM_TYPE) {
+ engine_type = SAMSUNG_FMM_TYPE;
+ _DEBUG_INFO("LAWMO SERVICE");
+ } else if ((service_engine_type & GCF_TYPE) == GCF_TYPE) {
+ engine_type = GCF_TYPE;
+ _DEBUG_INFO("GCF_TYPE");
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return engine_type;
+ } else {
+ //error;
+ }
+
+ sync_agent_close_mo();
+
+ _EXTERN_FUNC_EXIT;
+ return NO_ENGINE_TYPE;
+}
+
+SERVICE_SERVER_TYPE get_service_type(const char *mo_full_path)
+{
+ //sync_agent_open_mo();
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((mo_full_path) == NULL, COMMON_ERR_IS_NULL, "mo_full_path is NULL!!");
+
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_mo_type_e engine_type;
+ err_code = sync_agent_get_mo_type(mo_full_path, &engine_type);
+ _DEBUG_INFO("get mo type result : %d", err_code);
+
+ //sync_agent_close_mo();
+ _EXTERN_FUNC_EXIT;
+ return engine_type;
+}
+
+DM_ERROR get_Serverid(SERVICE_SERVER_TYPE mo_type, char **server_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_open_mo();
+ char *temp_server_id = 0;
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ err_code = sync_agent_get_serverid(mo_type, &temp_server_id);
+ _DEBUG_INFO("get server id : %d", err_code);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ _EXTERN_FUNC_EXIT;
+ return COMMON_ERR_IS_NULL;
+ }
+
+ _DEBUG_INFO("get server id : %s", temp_server_id);
+
+ if (temp_server_id != NULL) {
+ (*server_id) = strdup(temp_server_id);
+ str_free(&temp_server_id);
+ } else {
+ _EXTERN_FUNC_EXIT;
+ return COMMON_ERR_IS_NULL;
+ }
+
+ //sync_agent_close_mo();
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+}
+
+DM_ERROR get_server_type(char *server_id, int *server_type)
+{
+ _EXTERN_FUNC_ENTER;
+ retvm_if((server_id) == NULL, COMMON_ERR_IS_NULL, "server id is NULL!!");
+
+ DM_ERROR ret = DM_OK;
+ sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_server_info_s *server_info = NULL;
+ sync_agent_dm_server_info_s *cursor_ptr = NULL;
+
+ err = sync_agent_get_serverinfo(&server_info);
+ if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_INFO("get server info : %d", err);
+ return COMMON_ERR_IS_NULL;
+ }
+
+ *server_type = SYNC_AGENT_DM_MO_TYPE_NO_TYPE;
+ cursor_ptr = server_info;
+
+ _DEBUG_INFO("server_id : %s", server_id);
+
+ while (cursor_ptr != NULL) {
+ _DEBUG_INFO("server_id list : %s", cursor_ptr->server_id);
+ _DEBUG_INFO("server_type list: %d", cursor_ptr->server_type);
+
+ cursor_ptr = cursor_ptr->next;
+ }
+
+ cursor_ptr = server_info;
+ while (cursor_ptr != NULL) {
+ _DEBUG_INFO("server_id : %s", cursor_ptr->server_id);
+ _DEBUG_INFO("server_type : %d", cursor_ptr->server_type);
+
+ if (cursor_ptr->server_id != NULL) {
+ if (!strncmp(server_id, cursor_ptr->server_id, strlen(server_id))) {
+ _DEBUG_INFO("server_id : %s", server_id);
+ _DEBUG_INFO("same server type : %d", cursor_ptr->server_type);
+ *server_type = cursor_ptr->server_type;
+
+ sync_agent_free_serverinfo(server_info);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ } else {
+ _DEBUG_INFO("not same server id");
+ }
+ }
+
+ cursor_ptr = cursor_ptr->next;
+ }
+
+ sync_agent_free_serverinfo(server_info);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR add_dm_acc(SERVICE_SERVER_TYPE server_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ ret = factory_bootstrap(server_type);
+ if (ret != DM_OK) {
+ _DEBUG_INFO("factory bootstrap fail : %d", ret);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR remove_dm_acc(char *mo_path)
+{
+ _EXTERN_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+ sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_FAIL;
+
+ err = sync_agent_delete_mo_tree_item(mo_path);
+ _DEBUG_INFO("delete dmacc mo %d", err);
+ if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_INFO("delete dmacc mo fail");
+ ret = DM_ERR_BOOTSTRAP;
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
+
+DM_ERROR is_exist_dmacc(SERVICE_SERVER_TYPE dmacc_type, int *is_exist)
+{
+ _EXTERN_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+ sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_FAIL;
+ char *mo_path = NULL;
+
+ switch (dmacc_type) {
+ case SAMSUNG_FUMO_TYPE:
+ mo_path = DM_DMACC_MSCTESTSERVER;
+
+ break;
+ case SAMSUNG_FMM_TYPE:
+ mo_path = DM_DMACC_MSCSERVER;
+
+ break;
+ case GCF_TYPE:
+ mo_path = DM_DMACC_GCF;
+
+ break;
+ default:
+ break;
+
+ }
+
+ err = sync_agent_is_exist_mo(mo_path, is_exist);
+ if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_INFO("exist dmacc mo fail %d", err);
+ ret = COMMON_ERR_NOT_FOUND;
+ }
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
diff --git a/src/agent/mo-handler/dm_mo_handler.c b/src/agent/mo-handler/dm_mo_handler.c
new file mode 100755
index 0000000..22a03e1
--- /dev/null
+++ b/src/agent/mo-handler/dm_mo_handler.c
@@ -0,0 +1,1778 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <glib.h>
+#include <sys/stat.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "mo-handler/dm_mo_common.h"
+#include "mo-handler/dm_mo_handler.h"
+#include "serviceadapter/sa_session.h"
+#include "serviceadapter/sa_elements_internal.h"
+#include "serviceadapter/sa_elements.h"
+#include "serviceadapter/protocolbinder/syncml_def.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "MO_ENGINE"
+#endif
+
+#define DEFAULT_ACL "Get=*&Replace=*&Delete=*"
+
+/*static void __get_mo(sync_agent_dm_mo_type_e type, char *mo_full_path);*/
+/*static sync_agent_dm_mo_type_e get_motype(char* full_path);*/
+/*static DM_ERROR __map_mottoitem(sync_agent_dm_mo_node_s* mo_node, Item **pItem);*/
+
+static sync_agent_dm_mo_node_type_e _get_mo_node_type(char *format, char *value);
+static DM_ERROR _get_child_mo(char *mo_full_path, GList ** mo_node_list);
+static DM_ERROR _get_descendant_mo(char *mo_full_path, sync_agent_dm_mo_node_s ** root_node, int *count);
+static DM_ERROR _map_mo_listtoitemwithdata(GList * mo_node_list, GList ** pItems);
+static DM_ERROR _map_mo_treetoitemwithdata(sync_agent_dm_mo_node_s * mo_root, int count, GList ** pItems);
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /* mo test interface */
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+/*DM_ERROR pre_define_mo()
+{
+ _DEBUG_INFO( " start!!\n");
+
+ sync_agent_dm_mo_error_e mo_ret = sync_agent_begin_transaction_mo();
+ _DEBUG_INFO( " transaction begin : %d \n", mo_ret);
+
+ //dmacc_define_fumo();
+ //dmacc_define_lawmo();
+ //devinfo_define();
+ devdetail_define();
+ fumo_define();
+ lawmo_define();
+
+ mo_ret = sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_COMMIT);
+ _DEBUG_INFO( " transaction end : %d \n", __func__,mo_ret);
+ _DEBUG_INFO( " end!!\n");
+
+ return 0;
+}*/
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /* mo handler interface */
+ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+DM_ERROR get_mo_node_format_contenttype(const char *mo_path, char **format, char **contenttype)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((mo_path) == NULL, COMMON_ERR_IS_NULL, "mo_path is NULL!!");
+
+ sync_agent_dm_mo_error_e err;
+ sync_agent_dm_mo_node_s *mo_node = NULL;
+
+ err = sync_agent_get_mo_item(mo_path, &mo_node);
+ //err = sync_agent_get_mo(mo_type, mo_path, &mo_node, SYNC_AGENT_DM_MO_GET_OPTION_ALL);
+ if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+ ret = COMMON_ERR_GET_TYPE_NOT_FOUND;
+ goto error;
+ }
+
+ if (mo_node->runtime_property != NULL) {
+ sync_agent_dm_mo_format_e format_enum;
+ format_enum = mo_node->runtime_property->format;
+ ret = get_format(format_enum, format);
+ _DEBUG_INFO("format :%d , : %s", format_enum, *format);
+ if (ret != DM_OK) {
+ goto error;
+ }
+
+ sync_agent_dm_mo_df_type_e contenttype_enum;
+ contenttype_enum = mo_node->runtime_property->type;
+ _DEBUG_INFO("df type : %d", contenttype_enum);
+ if (mo_node->runtime_property->type_value != NULL) {
+ (*contenttype) = strdup(mo_node->runtime_property->type_value);
+ _DEBUG_INFO("content type : %s", *contenttype);
+ }
+
+ /*ret = get_contenttype(contenttype_enum, contenttype);
+ if(ret != DM_OK)
+ goto error; */
+ } else {
+ /*do nothing */
+ }
+
+ err = sync_agent_free_mo_item(mo_node);
+ _DEBUG_INFO("free mo: %d", err);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+
+ err = sync_agent_free_mo_item(mo_node);
+ _DEBUG_INFO("free mo : %d", err);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+DM_ERROR get_mo_node_property(const char *mo_path, propoerty_type pr_type, char **property)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((mo_path) == NULL, COMMON_ERR_IS_NULL, "mo_path is NULL!!");
+
+ _DEBUG_INFO(" start!!, full_path : %s", mo_path);
+ DM_ERROR ret = DM_OK;
+
+ sync_agent_dm_mo_error_e err;
+ sync_agent_dm_mo_node_s *mo_node = NULL;
+ err = sync_agent_get_mo_items(mo_path, &mo_node);
+ //err = sync_agent_get_mo(mo_type, mo_path, &mo_node, SYNC_AGENT_DM_MO_GET_OPTION_ALL);
+ if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+ ret = COMMON_ERR_GET_TYPE_NOT_FOUND;
+ goto error;
+ }
+
+ if (mo_node != NULL) {
+ if (mo_node->runtime_property != NULL) {
+ switch (pr_type) {
+ case PROP_TYPE_ACL:
+ {
+ sync_agent_dm_mo_node_s *iter = NULL;
+ char *temp_value = NULL;
+ int len = 0;
+ temp_value = calloc(1024, sizeof(char));
+ if (temp_value == NULL) {
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+ for (iter = mo_node; iter != NULL; iter = iter->next_node) {
+ _DEBUG_INFO("node iter");
+ if (iter->runtime_property != NULL && iter->runtime_property->acl != NULL) {
+ len = g_strlcat(temp_value, iter->runtime_property->acl, 1024);
+ _DEBUG_INFO("temp acl value length : %d", len);
+ //(*property) = strdup(mo_node->runtime_property->acl);
+ if (iter->next_node != NULL) {
+ len = g_strlcat(temp_value, "&", 1024);
+ _DEBUG_INFO("temp acl value length : %d", len);
+ }
+ _DEBUG_INFO("acl : %s", temp_value);
+
+ } else {
+ _DEBUG_INFO("not existed acl");
+ }
+ }
+ if (strlen(temp_value) > 0) {
+ *property = strdup(temp_value);
+ _DEBUG_INFO("acl : %s", *property);
+ } else {
+ *property = strdup("NULL");
+ }
+
+ str_free(&temp_value);
+ }
+ break;
+ case PROP_TYPE_FORMAT:
+ {
+ sync_agent_dm_mo_format_e format_enum;
+ format_enum = mo_node->runtime_property->format;
+ ret = get_format(format_enum, property);
+ _DEBUG_INFO("format : %s", *property);
+
+ break;
+ case PROP_TYPE_SIZE:
+ {
+ if (mo_node->runtime_property->size != NULL) {
+ (*property) = strdup(mo_node->runtime_property->size);
+ _DEBUG_INFO("size : %s", *property);
+ } else {
+ _DEBUG_INFO(" size 0");
+ (*property) = strdup("0");
+ /*ret = COMMON_ERR_GET_TYPE_NOT_FOUND; */
+ /*do nothing */
+ }
+ }
+ break;
+ case PROP_TYPE_TYPE:
+ {
+ sync_agent_dm_mo_df_type_e contenttype_enum;
+ contenttype_enum = mo_node->runtime_property->type;
+ _DEBUG_INFO("df type : %d", contenttype_enum);
+ if (mo_node->runtime_property->type_value != NULL) {
+ (*property) = strdup(mo_node->runtime_property->type_value);
+ _DEBUG_INFO("content type : %s", *property);
+ } else {
+ _DEBUG_INFO("content type is not existed");
+ (*property) = strdup("MIME");
+ _DEBUG_INFO("content type : %s", *property);
+ }
+ }
+ break;
+ case PROP_TYPE_NAME:
+ {
+ if (mo_node->runtime_property->name != NULL) {
+ (*property) = strdup(mo_node->runtime_property->name);
+ _DEBUG_INFO("name : %s", *property);
+ } else {
+ _DEBUG_INFO("name is not existed");
+ (*property) = strdup(mo_path);
+ /*ret = COMMON_ERR_GET_TYPE_NOT_FOUND; */
+ /*do nothing */
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ } else {
+ /*do nothing */
+ _DEBUG_INFO("not existed runtime property");
+ ret = COMMON_ERR_GET_TYPE_NOT_FOUND;
+ }
+ } else {
+ /*do nothing */
+ _DEBUG_INFO("not existed mo node");
+ ret = COMMON_ERR_GET_TYPE_NOT_FOUND;
+ }
+
+ err = sync_agent_free_mo_item(mo_node);
+ _DEBUG_INFO("free %d", err);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ err = sync_agent_free_mo_item(mo_node);
+ _DEBUG_INFO("free %d", err);
+
+ _DEBUG_INFO(" end!! error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR clean_dm_mo()
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ sync_agent_dm_mo_error_e error;
+
+ error = sync_agent_delete_all_mo_table();
+ if (error != SYNC_AGENT_DM_MO_SUCCESS) {
+ ret = COMMON_ERR_DELETE;
+ goto error;
+ }
+
+ _DEBUG_INFO(" end!!\n");
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR replace_itemtomo(Item * item)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((item) == NULL, COMMON_ERR_IS_NULL, "item is NULL!!");
+
+ char *target_url = NULL;
+ char *value = NULL;
+ char *contenttype = NULL;
+ char *format = NULL;
+
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_mo_type_e mo_type;
+
+ GetType prop_type = GET_TYPE_NOMAL;
+ char *real_full_path = NULL;
+
+ target_url = (char *)get_location_locuri(item->target);
+ if (item->private.data != NULL) {
+ value = item->private.data;
+ _DEBUG_INFO("replace value : %s", value);
+ }
+ if (item->contenttype != NULL) {
+ contenttype = item->contenttype;
+ _DEBUG_INFO("contenttype value : %s", contenttype);
+ }
+ if (item->format != NULL) {
+ format = item->format;
+ _DEBUG_INFO("format value : %s", format);
+ }
+
+ err_code = sync_agent_get_mo_type(target_url, &mo_type);
+ _DEBUG_INFO("get mo type result : %d", err_code);
+
+ if (contenttype != NULL && value != NULL) {
+ if (strncmp(contenttype, ELEMENT_DMTNDS_XML, strlen(ELEMENT_DMTNDS_XML)) == 0) {
+ err_code = sync_agent_import_tnds_stream(SYNC_AGENT_DM_MO_TNDS_ACTION_REPLACE, SYNC_AGENT_DM_MO_TNDS_TYPE_XML, mo_type, target_url, value, strlen(value));
+ goto return_part;
+ } else if (strncmp(contenttype, ELEMENT_DMTNDS_WBXML, strlen(ELEMENT_DMTNDS_WBXML)) == 0) {
+ err_code = sync_agent_import_tnds_stream(SYNC_AGENT_DM_MO_TNDS_ACTION_REPLACE, SYNC_AGENT_DM_MO_TNDS_TYPE_WBXML, mo_type, target_url, value, strlen(value));
+ goto return_part;
+ }
+ } else {
+ _DEBUG_INFO("have not content type");
+ }
+
+ ret = get_type_mo_tree(target_url, &prop_type, &real_full_path);
+ if (ret != DM_OK)
+ goto error;
+
+ _DEBUG_INFO("mo tree type : %d", prop_type);
+ switch (prop_type) {
+ case GET_TYPE_ACL_PROP:
+ {
+ _DEBUG_INFO("update acl property type");
+ ret = replace_mo_property(real_full_path, NULL, value, NULL, NULL, prop_type);
+ if (ret != DM_OK)
+ goto error;
+ }
+ break;
+ case GET_TYPE_SIZE_PROP:
+ case GET_TYPE_TYPE_PROP:
+ case GET_TYPE_FORMAT_PROP:
+ case GET_TYPE_NAME_PROP:
+ break;
+ default:
+ {
+ _DEBUG_INFO("update value");
+ ret = replace_mo(target_url, value, NULL, contenttype, format, prop_type);
+ if (ret != DM_OK)
+ goto error;
+ }
+ break;
+ }
+
+ return_part:
+ str_free(&(real_full_path));
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ str_free(&(real_full_path));
+ _DEBUG_INFO(" error end %d \n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+DM_ERROR replace_mo_data(char *mo_full_path, char *value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((mo_full_path) == NULL, COMMON_ERR_IS_NULL, "mo_full_path is NULL!!");
+
+ _DEBUG_INFO("target : %s , value : %s \n", mo_full_path, value);
+
+ DM_ERROR ret = DM_OK;
+
+ ret = replace_mo(mo_full_path, value, NULL, NULL, NULL, GET_TYPE_NOMAL);
+ if (ret != DM_OK)
+ goto error;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO(" error end %d \n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR replace_mo_property(char *mo_full_path, char *value, char *prop_value, char *contenttype, char *format, GetType prop_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((mo_full_path) == NULL, COMMON_ERR_IS_NULL, "mo_full_path is NULL!!");
+
+ _DEBUG_INFO(" target : %s , value : %s \n", mo_full_path, prop_value);
+
+ DM_ERROR ret = DM_OK;
+
+ ret = replace_mo(mo_full_path, value, prop_value, contenttype, format, prop_type);
+ if (ret != DM_OK)
+ goto error;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO(" error end %d \n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR replace_mo(char *mo_full_path, char *value, char *prop_value, char *contenttype, char *format, GetType prop_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((mo_full_path) == NULL, COMMON_ERR_IS_NULL, "mo_full_path is NULL!!");
+
+ _DEBUG_INFO("target : %s \n", mo_full_path);
+
+ DM_ERROR ret = DM_OK;
+
+ sync_agent_dm_mo_node_s *mo_node = NULL;
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_mo_format_e format_enum = SYNC_AGENT_DM_MO_FORMAT_NO_SET;
+
+ err_code = sync_agent_get_mo_item(mo_full_path, &mo_node);
+ //err_code = sync_agent_get_mo(type, mo_full_path, &mo_node, SYNC_AGENT_DM_MO_GET_OPTION_ALL);
+ if (mo_node == NULL) {
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ if (value != NULL) {
+ if (mo_node->value != NULL) {
+ free(mo_node->value);
+ mo_node->value = NULL;
+ } else {
+ _DEBUG_INFO(" Not existed mo node value ");
+ }
+ mo_node->value = strdup(value);
+ _DEBUG_INFO(" mo value : %s", value);
+
+ if (mo_node->runtime_property != NULL) {
+ if (mo_node->runtime_property->size != NULL) {
+ free(mo_node->runtime_property->size);
+ mo_node->runtime_property->size = NULL;
+ } else {
+ _DEBUG_INFO(" Not existed mo node runtime property size ");
+ }
+ int size = 0;
+ size = (strlen(value) * sizeof(char));
+ mo_node->runtime_property->size = g_strdup_printf("%d", size);
+ _DEBUG_INFO(" mo value size : %s", mo_node->runtime_property->size);
+ }
+ } else {
+ _DEBUG_INFO(" Not existed value");
+ }
+
+ switch (prop_type) {
+ case GET_TYPE_ACL_PROP:{
+ if (mo_node->runtime_property != NULL) {
+ if (mo_node->runtime_property->acl != NULL) {
+ free(mo_node->runtime_property->acl);
+ mo_node->runtime_property->acl = NULL;
+ } else {
+ _DEBUG_INFO(" Not existed mo node runtim property acl ");
+ }
+ mo_node->runtime_property->acl = strdup(prop_value);
+ _DEBUG_INFO(" acl value : %s", prop_value);
+ } else {
+ _DEBUG_INFO(" Not existed mo node runtim property ");
+ }
+ }
+ break;
+ case GET_TYPE_TYPE_PROP:
+ case GET_TYPE_NAME_PROP:
+ case GET_TYPE_SIZE_PROP:
+ case GET_TYPE_FORMAT_PROP:{
+ _DEBUG_INFO("do not replace format");
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (contenttype != NULL) {
+ if (mo_node->runtime_property != NULL) {
+ if (mo_node->runtime_property->type_value != NULL) {
+ free(mo_node->runtime_property->type_value);
+ mo_node->runtime_property->type_value = NULL;
+ } else {
+ _DEBUG_INFO(" Not existed mo node runtim property contenttype ");
+ }
+ mo_node->runtime_property->type_value = strdup(contenttype);
+ _DEBUG_INFO(" contenttype value : %s", contenttype);
+ } else {
+ _DEBUG_INFO(" Not existed contenttype ");
+ }
+ }
+
+ if (format != NULL) {
+ if (mo_node->runtime_property != NULL) {
+ ret = get_format_enum(format, &format_enum);
+ mo_node->runtime_property->format = format_enum;
+ }
+ }
+
+ err_code = sync_agent_update_mo_item(mo_node);
+ //err_code = sync_agent_update_mo(mo_node);
+ if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_INFO(" Success to sync_agent_update_mo()\n");
+ } else {
+ _DEBUG_INFO(" Failed to sync_agent_update_mo()\n");
+ goto error;
+ }
+
+ err_code = sync_agent_free_mo_item(mo_node);
+ _DEBUG_INFO("free : %d", err_code);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ sync_agent_free_mo_item(mo_node);
+ _DEBUG_INFO("free : %d", err_code);
+ _DEBUG_INFO(" error end %d \n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR add_itemtomo(Item * item, char *server_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((item) == NULL, COMMON_ERR_IS_NULL, "item is NULL!!");
+
+ char *target_url = NULL;
+ char *value = NULL;
+ char *contenttype = NULL;
+ char *format = NULL;
+
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ int server_type = SYNC_AGENT_DM_MO_TYPE_NO_TYPE;
+ sync_agent_dm_mo_node_type_e node_type = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ target_url = (char *)get_location_locuri(item->target);
+ if (item->private.data != NULL) {
+ value = item->private.data;
+ _DEBUG_INFO("get mo value : %s", value);
+ }
+ if (item->contenttype != NULL) {
+ contenttype = item->contenttype;
+ _DEBUG_INFO("get mo contenttype : %s", contenttype);
+ }
+ if (item->format != NULL) {
+ format = item->format;
+ _DEBUG_INFO("get mo format : %s", format);
+ }
+
+ node_type = _get_mo_node_type(format, value);
+ _DEBUG_INFO("get mo node type : %d", node_type);
+
+ ret = get_server_type(server_id, &server_type);
+ _DEBUG_INFO("get server type : %d, result : %d", server_type, ret);
+ if (ret != DM_OK) {
+ _DEBUG_INFO("get server error : %d", ret);
+ }
+
+ if (contenttype != NULL && value != NULL) {
+ if (strncmp(contenttype, ELEMENT_DMTNDS_XML, strlen(ELEMENT_DMTNDS_XML)) == 0) {
+ err_code = sync_agent_import_tnds_stream(SYNC_AGENT_DM_MO_TNDS_ACTION_ADD, SYNC_AGENT_DM_MO_TNDS_TYPE_XML, server_type, target_url, value, strlen(value));
+ goto return_part;
+ } else if (strncmp(contenttype, ELEMENT_DMTNDS_WBXML, strlen(ELEMENT_DMTNDS_WBXML)) == 0) {
+ err_code = sync_agent_import_tnds_stream(SYNC_AGENT_DM_MO_TNDS_ACTION_ADD, SYNC_AGENT_DM_MO_TNDS_TYPE_WBXML, server_type, target_url, value, strlen(value));
+ goto return_part;
+ }
+ }
+
+ ret = add_mo(server_type, target_url, value, node_type, contenttype, format);
+ if (ret != DM_OK)
+ goto error;
+
+ return_part:
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO(" error end %d ", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR add_mo(int server_type, char *mo_full_path, char *value, sync_agent_dm_mo_node_type_e node_type, char *contenttype, char *format)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((mo_full_path) == NULL, COMMON_ERR_IS_NULL, "mo_full_path is NULL!!");
+
+ DM_ERROR ret = DM_OK;
+ sync_agent_dm_mo_error_e mo_error = SYNC_AGENT_DM_MO_FAIL;
+ sync_agent_dm_mo_node_s *sync_agent_mo_item = NULL;
+ sync_agent_dm_mo_format_e format_enum = SYNC_AGENT_DM_MO_FORMAT_NO_SET;
+
+ mo_error = sync_agent_create_mo_item(&sync_agent_mo_item);
+ if (mo_error == SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_INFO("Success to sync_agent_create_mo()\n");
+ } else {
+ _DEBUG_INFO("Failed to sync_agent_create_mo() [%d] \n", mo_error);
+ ret = COMMON_ERR_DELETE;
+ goto error;
+ }
+
+ /*setting mo node value */
+ sync_agent_mo_item->type = node_type;
+ //sync_agent_mo_item->mo_type = server_type;
+ sync_agent_mo_item->server_type = server_type;
+ _DEBUG_INFO("node type : %d", node_type);
+ _DEBUG_INFO("server type : %d", server_type);
+
+ sync_agent_mo_item->full_path = strdup(mo_full_path);
+
+ if (value != NULL) {
+ sync_agent_mo_item->value = strdup(value);
+ int size = 0;
+ size = strlen(value) * sizeof(char);
+ sync_agent_mo_item->runtime_property->size = g_strdup_printf("%d", size);
+ }
+ /*============================================================================*/
+
+ /*setting mo node runtime property value */
+ if (contenttype != NULL) {
+ sync_agent_mo_item->runtime_property->type_value = strdup(contenttype);
+ }
+ if (format != NULL) {
+ ret = get_format_enum(format, &format_enum);
+ sync_agent_mo_item->runtime_property->format = format_enum;
+ }
+ sync_agent_mo_item->runtime_property->acl = strdup(DEFAULT_ACL);
+ /*============================================================================*/
+
+ /*setting mo node framework property value */
+ /* for gcf 2101 test : samsung requested default accessType value */
+ sync_agent_mo_item->framework_property->accessType = SYNC_AGENT_DM_MO_ACCESSTYPE_ADD |
+ SYNC_AGENT_DM_MO_ACCESSTYPE_COPY | SYNC_AGENT_DM_MO_ACCESSTYPE_DELETE | SYNC_AGENT_DM_MO_ACCESSTYPE_EXEC | SYNC_AGENT_DM_MO_ACCESSTYPE_GET | SYNC_AGENT_DM_MO_ACCESSTYPE_REPLACE;
+
+ sync_agent_mo_item->framework_property->scope = SYNC_AGENT_DM_MO_SCOPE_DYNAMIC;
+ /*============================================================================*/
+
+ mo_error = sync_agent_add_mo_item(sync_agent_mo_item);
+ //mo_error = sync_agent_add_mo(mo_type, mo_full_path, &mo_node);
+ if (mo_error == SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_INFO("Success to sync_agent_add_mo_item()\n");
+ } else {
+ _DEBUG_INFO("Failed to sync_agent_add_mo_item() [%d] \n", mo_error);
+ ret = COMMON_ERR_DELETE;
+ goto error;
+ }
+
+ mo_error = sync_agent_free_mo_item(sync_agent_mo_item);
+ _DEBUG_INFO("free_mo_item : %d", mo_error);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ mo_error = sync_agent_free_mo_item(sync_agent_mo_item);
+ _DEBUG_INFO("free_mo_item : %d", mo_error);
+
+ _DEBUG_INFO(" end error %d, db add error %d\n", ret, mo_error);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+DM_ERROR delete_itemtomo(Item * item)
+{
+ _EXTERN_FUNC_ENTER;
+ _DEBUG_INFO(" start ");
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((item) == NULL, COMMON_ERR_IS_NULL, "item is NULL!!");
+
+ char *targetUrl = NULL;
+ targetUrl = (char *)get_location_locuri(item->target);
+
+ ret = delete_mo(targetUrl);
+ if (ret != DM_OK)
+ goto error;
+
+ _DEBUG_INFO(" end!! \n");
+ return ret;
+ error:
+ _DEBUG_INFO(" error end %d ", ret);
+ return ret;
+}
+
+DM_ERROR delete_mo(char *mo_full_path)
+{
+ _EXTERN_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((mo_full_path) == NULL, COMMON_ERR_IS_NULL, "mo_full_path is NULL!!");
+
+ sync_agent_dm_mo_error_e err_code = sync_agent_delete_mo_item(mo_full_path);
+
+ if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_INFO("Success to sync_agent_delete_mo()\n");
+ } else {
+ _DEBUG_INFO("Failed to sync_agent_delete_mo() [%d] \n", err_code);
+ ret = COMMON_ERR_DELETE;
+ goto error;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO(" error end %d ", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+static DM_ERROR _get_child_mo(char *mo_full_path, GList ** mo_node_list)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((mo_full_path) == NULL, COMMON_ERR_IS_NULL, "mo_full_path is NULL!!");
+
+/* ret = sync_agent_open_mo();
+ _DEBUG_TRACE("mo open : %d", ret);*/
+ sync_agent_dm_mo_node_s *mo_node = NULL;
+ sync_agent_dm_mo_item_s sync_agent_item;
+
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_mo_type_e mo_type;
+ err_code = sync_agent_get_mo_type(mo_full_path, &mo_type);
+ _DEBUG_TRACE("get mo type result : %d", err_code);
+ _DEBUG_TRACE("mo full path : %s", mo_full_path);
+ _DEBUG_TRACE("mo type : %d", mo_type);
+
+ sync_agent_item.interface_type = MO_ITEM_CHILD_MO_VALUE_LIST;
+ sync_agent_item.mo_path = mo_full_path;
+ sync_agent_item.option = SYNC_AGENT_DM_MO_GET_OPTION_ALL;
+ sync_agent_item.mo_type = mo_type;
+
+ err_code = sync_agent_query_mo_item(&sync_agent_item, mo_node_list);
+ //err_code = sync_agent_get_child_mo_list(type, mo_full_path, mo_node_list, count, SYNC_AGENT_DM_MO_GET_OPTION_ALL);
+ if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_TRACE("Success to sync_agent_get_child_mo_list()\n");
+ } else {
+ _DEBUG_TRACE("Failed to sync_agent_get_child_mo_list()\n");
+ ret = COMMON_ERR_MO_NOT_FOUND_IN_DB;
+ goto error;
+ }
+
+ if ((*mo_node_list) == NULL) {
+ _DEBUG_TRACE("Not Existed childe node!!\n");
+ ret = COMMON_ERR_MO_NOT_FOUND_IN_DB;
+ goto error;
+ }
+
+ GList *iter = NULL;
+
+ for (iter = *mo_node_list; iter != NULL; iter = g_list_next(iter)) {
+ mo_node = (sync_agent_dm_mo_node_s *) (iter->data);
+
+ _DEBUG_TRACE("mo_node->id : %d\n", mo_node->id);
+ _DEBUG_TRACE(" mo_node->parent_id : %d\n", mo_node->parent_id);
+ _DEBUG_TRACE("mo_node->name : %s\n", mo_node->name);
+ _DEBUG_TRACE("mo_node->value : %s\n", mo_node->value);
+ _DEBUG_TRACE("mo_node->full_path : %s\n", mo_node->full_path);
+ _DEBUG_TRACE("mo_node->type : %d\n\n", mo_node->type);
+
+ _DEBUG_TRACE(" framework_property->accessType : %d\n", mo_node->framework_property->accessType);
+ _DEBUG_TRACE(" framework_property->defaultValue : %s\n", mo_node->framework_property->defaultValue);
+ _DEBUG_TRACE(" framework_property->description : %s\n", mo_node->framework_property->description);
+ _DEBUG_TRACE(" framework_property->dffFormat : %d\n", mo_node->framework_property->dffFormat);
+ _DEBUG_TRACE(" framework_property->occurrence : %d\n", mo_node->framework_property->occurrence);
+ _DEBUG_TRACE(" framework_property->scope : %d\n", mo_node->framework_property->scope);
+ _DEBUG_TRACE(" framework_property->dfTitle : %s\n", mo_node->framework_property->dfTitle);
+ _DEBUG_TRACE(" framework_property->dfType : %d\n\n", mo_node->framework_property->dfType);
+ }
+
+ _DEBUG_TRACE(" end \n");
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_TRACE(" error end \n");
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+}
+
+int print_Node(sync_agent_dm_mo_node_s * mo_node, int depth, void **data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((mo_node) == NULL, -1, "mo_node is NULL!!");
+
+ _DEBUG_INFO("mo_node->name : %s\n", mo_node->full_path);
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+static DM_ERROR _get_descendant_mo(char *mo_full_path, sync_agent_dm_mo_node_s ** root_node, int *count)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((mo_full_path) == NULL, COMMON_ERR_IS_NULL, "mo_full_path is NULL!!");
+
+ _DEBUG_TRACE(" start full path : %s \n", mo_full_path);
+
+ DM_ERROR ret = DM_OK;
+ int e_ret = 0;
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_mo_type_e mo_type;
+ err_code = sync_agent_get_mo_type(mo_full_path, &mo_type);
+ _DEBUG_TRACE("get mo type result : %d", err_code);
+ _DEBUG_TRACE("mo type : %d", mo_type);
+
+ err_code = sync_agent_get_descendant_mo_tree(mo_type, mo_full_path, root_node, count, SYNC_AGENT_DM_MO_GET_OPTION_NODE);
+ _DEBUG_TRACE(" Descendant nodes count : %d\n", (*count));
+
+ if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_TRACE(" Success to sync_agent_get_descendant_mo_tree()\n");
+
+ } else {
+ _DEBUG_TRACE(" Failed to sync_agent_get_descendant_mo_tree()\n");
+ ret = COMMON_ERR_MO_NOT_FOUND_IN_DB;
+ goto error;
+ }
+
+ if (*count == 0 || root_node == NULL) {
+ _DEBUG_TRACE(" Not Existed Descendant node!!\n");
+ ret = COMMON_ERR_MO_NOT_FOUND_IN_DB;
+ goto error;
+ }
+
+ GList **temp = NULL;
+ int depth = 0;
+ int errStop = 0;
+
+ e_ret = sync_agent_traverse_mo_tree_preorder((*root_node), print_Node, depth, errStop, (void **)temp);
+ _DEBUG_TRACE("sync agent traverse mo : %d", e_ret);
+
+ _DEBUG_TRACE(" end \n");
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO(" error end \n");
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR check_mo_scope(char *full_path)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((full_path) == NULL, COMMON_ERR_IS_NULL, "full_path is NULL!!");
+
+ _DEBUG_INFO(" full path : %s \n", full_path);
+ DM_ERROR ret = DM_OK;
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_mo_node_s *mo_node = NULL;
+ err_code = sync_agent_get_mo_item(full_path, &mo_node);
+ if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_INFO(" Success to sync_agent_get_mo()\n");
+ } else {
+ _DEBUG_INFO(" Failed to sync_agent_get_mo()\n");
+ ret = COMMON_ERR_MO_NOT_FOUND_IN_DB;
+ goto error;
+ }
+
+ if (mo_node == NULL) {
+ _DEBUG_INFO(" getted mo_node is null\n");
+ ret = COMMON_ERR_MO_NOT_FOUND_IN_DB;
+ goto error;
+ }
+
+ sync_agent_dm_mo_scope_e scope;
+ if (mo_node->framework_property != NULL) {
+ scope = mo_node->framework_property->scope;
+ if (scope == SYNC_AGENT_DM_MO_SCOPE_PERMANENT) {
+ _DEBUG_INFO("permanent node");
+ ret = DM_ERR_COMMAND_NOT_ALLOWED;
+ goto error;
+ }
+ _DEBUG_INFO("dynamic node");
+ } else {
+ _DEBUG_INFO("have not framework property");
+ }
+
+ sync_agent_dm_mo_node_type_e node_type;
+ node_type = mo_node->type;
+ if (node_type == SYNC_AGENT_DM_MO_NODE_ROOT) {
+ _DEBUG_INFO("root node");
+ ret = DM_ERR_COMMAND_NOT_ALLOWED;
+ goto error;
+ }
+
+ err_code = sync_agent_free_mo_item(mo_node);
+ _DEBUG_INFO(" free mo_node : %d", err_code);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+
+ err_code = sync_agent_free_mo_item(mo_node);
+ _DEBUG_INFO(" free mo_node : %d", err_code);
+
+ _DEBUG_INFO(" end error");
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR copy_itemtomo(Item * item)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((item) == NULL, COMMON_ERR_IS_NULL, "item is NULL!!");
+ retvm_if((item->target) == NULL, COMMON_ERR_IS_NULL, "target_url is NULL!!");
+ retvm_if((item->source) == NULL, COMMON_ERR_IS_NULL, "source_url is NULL!!");
+
+ char *source_url = NULL;
+ char *target_url = NULL;
+
+ source_url = (char *)get_location_locuri(item->source);
+ target_url = (char *)get_location_locuri(item->target);
+
+ ret = copy_mo_data(target_url, source_url);
+ if (ret != DM_OK)
+ goto error;
+
+ error:
+ _EXTERN_FUNC_EXIT;
+ _DEBUG_INFO(" error end %d \n", ret);
+ return ret;
+
+}
+
+DM_ERROR copy_mo_data(char *target_url, char *source_url)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((target_url) == NULL, COMMON_ERR_IS_NULL, "target_url is NULL!!");
+
+ _DEBUG_INFO("source : %s , target : %s \n", source_url, target_url);
+ DM_ERROR ret = DM_OK;
+
+ /*if(type == -1 ) {
+ ret = COMMON_ERR_MO_NOT_FOUND_IN_DB;
+ goto error;
+ } */
+
+ ret = copy_mo(target_url, source_url);
+ if (ret != DM_OK)
+ goto error;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO(" error end %d \n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR copy_mo(char *target_url, char *source_url)
+{
+ _EXTERN_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((target_url) == NULL, COMMON_ERR_IS_NULL, "target_url is NULL!!");
+ retvm_if((source_url) == NULL, COMMON_ERR_IS_NULL, "source_url is NULL!!");
+
+ _DEBUG_INFO(" start!! source : %s, target_url \n", source_url, target_url);
+
+ sync_agent_dm_mo_node_s *sync_agent_mo_item = NULL;
+ sync_agent_dm_mo_node_s *sync_agent_new_mo_item = NULL;
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ int is_mo = 0;
+
+ err_code = sync_agent_get_mo_item(source_url, &sync_agent_mo_item);
+ //err_code = sync_agent_get_mo(type, source_url, &sync_agent_mo_item, SYNC_AGENT_DM_MO_GET_OPTION_ALL);
+ if (sync_agent_mo_item == NULL) {
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ err_code = sync_agent_is_exist_mo(target_url, &is_mo);
+ _DEBUG_INFO("is existed mo : %d", err_code);
+ if (is_mo == 1) {
+ //update
+ err_code = sync_agent_get_mo_item(target_url, &sync_agent_new_mo_item);
+ //err_code = sync_agent_get_mo(mo_type, target_url, &new_sync_agent_mo_item, SYNC_AGENT_DM_MO_GET_OPTION_ALL);
+ if (sync_agent_new_mo_item == NULL) {
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ if (sync_agent_mo_item->value != NULL) {
+ str_free(&(sync_agent_new_mo_item->value));
+ sync_agent_new_mo_item->value = strdup(sync_agent_mo_item->value);
+ } else {
+ _DEBUG_INFO(" Not existed mo node value ");
+ }
+
+ err_code = sync_agent_update_mo_item(sync_agent_new_mo_item);
+ //err_code = sync_agent_update_mo(mo_type, new_sync_agent_mo_item);
+ if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_INFO(" Success to copy_MO()\n");
+ } else {
+ _DEBUG_INFO(" Failed to copy_MO()\n");
+ goto error;
+ }
+
+ } else {
+ //add
+
+ err_code = sync_agent_create_mo_item(&sync_agent_new_mo_item);
+ if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_INFO("Success to sync_agent_create_mo()\n");
+ } else {
+ _DEBUG_INFO("Failed to sync_agent_create_mo() [%d] \n", err_code);
+ ret = COMMON_ERR_DELETE;
+ goto error;
+ }
+ //sync_agent_dm_mo_node_s sync_agent_temp_new_mo_item;
+ sync_agent_new_mo_item->full_path = strdup(target_url);
+
+ if (sync_agent_mo_item->value != NULL) {
+ sync_agent_new_mo_item->value = strdup(sync_agent_mo_item->value);
+ }
+
+ sync_agent_new_mo_item->mo_type = SYNC_AGENT_DM_MO_TYPE_NO_TYPE;
+ sync_agent_new_mo_item->type = SYNC_AGENT_DM_MO_NODE_LEAF;
+ sync_agent_new_mo_item->server_type = sync_agent_mo_item->server_type;
+
+ err_code = sync_agent_add_mo_item(sync_agent_new_mo_item);
+ //err_code = sync_agent_add_mo(new_sync_agent_mo_item->mo_type, target_url, new_mo_node);
+ if (err_code == SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_INFO(" Success to copy_MO()\n");
+ } else {
+ _DEBUG_INFO(" Failed to copy_MO()\n");
+ goto error;
+ }
+ }
+
+ err_code = sync_agent_free_mo_item(sync_agent_mo_item);
+ _DEBUG_INFO("free : %d", err_code);
+
+ err_code = sync_agent_free_mo_item(sync_agent_new_mo_item);
+ _DEBUG_INFO("free : %d", err_code);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ err_code = sync_agent_free_mo_item(sync_agent_mo_item);
+ _DEBUG_INFO("free : %d", err_code);
+
+ err_code = sync_agent_free_mo_item(sync_agent_new_mo_item);
+ _DEBUG_INFO("free : %d", err_code);
+
+ _DEBUG_INFO(" error end %d \n", ret);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR get_mo_operationtype(char *full_path, char **result_oper_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((full_path) == NULL, COMMON_ERR_IS_NULL, "full_path is NULL!!");
+
+ _DEBUG_INFO("full path : %s \n", full_path);
+ DM_ERROR ret = DM_OK;
+
+ if (full_path != NULL) {
+ int full_size = 0;
+ int real_size = 0;
+ int root_size = 0;
+ char *result_mo_type = NULL;
+
+ ret = get_mo_root_path(full_path, &result_mo_type);
+ if (ret != DM_OK) {
+ goto error;
+ }
+
+ if (result_mo_type != NULL) {
+ full_size = strlen(full_path);
+ root_size = strlen(result_mo_type);
+
+ real_size = full_size - (root_size);
+ (*result_oper_type) = (char *)calloc(1, real_size + 1);
+ if ((*result_oper_type) == NULL) {
+ _DEBUG_INFO("alloc error");
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+ memcpy((*result_oper_type), full_path + root_size, real_size);
+ (*result_oper_type)[real_size] = '\0';
+ _DEBUG_INFO(" result_mo_type : %s \n", (*result_oper_type));
+ } else {
+ _DEBUG_INFO("result mo type is null ");
+ }
+ } else {
+ _DEBUG_INFO("result oper type null ");
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO(" error end \n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+static sync_agent_dm_mo_node_type_e _get_mo_node_type(char *format, char *value)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((format) == NULL && value == NULL, SYNC_AGENT_DM_MO_NODE_INTERIOR, "format is NULL!!");
+
+ _DEBUG_INFO(" start , format : %s\n", format);
+ sync_agent_dm_mo_node_type_e type = SYNC_AGENT_DM_MO_NODE_LEAF;
+
+ if (value != NULL) {
+ type = SYNC_AGENT_DM_MO_NODE_LEAF;
+ goto return_part;
+ } else {
+ if (format != NULL) {
+ if (strcmp(format, ELEMENT_NODE) == 0) {
+ type = SYNC_AGENT_DM_MO_NODE_INTERIOR;
+ }
+ }
+ }
+
+ return SYNC_AGENT_DM_MO_NODE_INTERIOR;
+
+ return_part:
+ _DEBUG_TRACE(" end type : [%d]\n", type);
+ _INNER_FUNC_EXIT;
+ return type;
+
+}
+
+DM_ERROR get_mo_data(char *full_path, char **data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((full_path) == NULL, COMMON_ERR_IS_NULL, "full_path is NULL!!");
+
+ /*string tok compare */
+ _DEBUG_INFO(" start full_path : %s \n", full_path);
+
+ GList *iter = NULL;
+ GList *mo_node_list = NULL;
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_mo_node_s *mo_node = NULL;
+ sync_agent_dm_mo_node_s *mo_node_iter = NULL;
+
+ int i = 0;
+ int size = 0;
+ int node_name_size = 0;
+ int count = 0;
+ char child_buffer[1024] = { 0, };
+
+ err_code = sync_agent_get_mo_item(full_path, &mo_node);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS || mo_node == NULL) {
+ _DEBUG_INFO(" Failed to sync_agent_get_mo()\n");
+ ret = COMMON_ERR_MO_NOT_FOUND_IN_DB;
+ goto error;
+ } else {
+ _DEBUG_INFO(" Success to sync_agent_get_mo()\n");
+ }
+
+ _DEBUG_INFO(" mo_node->id : %d\n", mo_node->id);
+ _DEBUG_INFO(" mo_node->parent_id : %d\n", mo_node->parent_id);
+ _DEBUG_INFO(" mo_node->name : %s\n", mo_node->name);
+ _DEBUG_INFO(" mo_node->value : %s\n", mo_node->value);
+ _DEBUG_INFO(" mo_node->full_path : %s\n", mo_node->full_path);
+ _DEBUG_INFO(" mo_node->type : %d\n", mo_node->type);
+
+ if (mo_node->type == SYNC_AGENT_DM_MO_NODE_LEAF) {
+ if (mo_node->value != NULL) {
+ (*data) = g_strdup(mo_node->value);
+ }
+ } else {
+ //else if( mo_node->type == SYNC_AGENT_DM_MO_NODE_INTERIOR )
+ ret = _get_child_mo(full_path, &mo_node_list);
+ if (ret != DM_OK)
+ goto error;
+
+ count = g_list_length(mo_node_list);
+ if (mo_node_list != NULL && count != 0) {
+
+ for (iter = mo_node_list; iter != NULL; iter = g_list_next(iter)) {
+ mo_node_iter = (sync_agent_dm_mo_node_s *) iter->data;
+
+ node_name_size = strlen(mo_node_iter->name);
+ memcpy(child_buffer + size, mo_node_iter->name, node_name_size);
+ size += node_name_size;
+ if (i < count - 1) {
+ memcpy(child_buffer + size, "/", 1);
+ size++;
+ }
+ _DEBUG_INFO("mo node list : %s", mo_node_iter->name);
+ _DEBUG_INFO("child node get : %s", child_buffer);
+ }
+ (*data) = strdup(child_buffer);
+ }
+
+ if (mo_node_list != NULL) {
+ err_code = sync_agent_free_mo_item_list(mo_node_list);
+ _DEBUG_INFO(" free mo list : %d", err_code);
+ }
+ }
+
+ sync_agent_free_mo_item(mo_node);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ (*data) = NULL;
+
+ sync_agent_free_mo_item(mo_node);
+
+ _DEBUG_INFO(" error end\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+int map_nodeToItemWithData(sync_agent_dm_mo_node_s * mo_node, int depth, void **data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO(" start \n");
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((mo_node) == NULL, -1, "mo_node is NULL!!");
+
+ Item *pItem = NULL;
+
+ if (mo_node->full_path != NULL) {
+ _DEBUG_INFO(" mo_node path : \n", mo_node->full_path);
+
+ ret = construct_Item(mo_node->full_path, NULL, NULL, mo_node->value, 0, 0, &pItem);
+ if (ret != DM_OK)
+ _DEBUG_INFO(" ITEM NULL\n");
+
+ (*data) = g_list_append(((GList *) (*data)), pItem);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+int map_nodeToItem(sync_agent_dm_mo_node_s * mo_node, int depth, void **data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO(" start \n");
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((mo_node) == NULL, -1, "mo_node is NULL!!");
+
+ Item *pItem = NULL;
+
+ if (mo_node->full_path != NULL) {
+ _DEBUG_INFO(" mo_node path : \n", mo_node->full_path);
+
+ ret = construct_Item(mo_node->full_path, NULL, NULL, NULL, 0, 0, &pItem);
+ if (ret != DM_OK) {
+ _DEBUG_INFO(" ITEM NULL\n");
+ }
+
+ (*data) = g_list_append(((GList *) (*data)), pItem);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+static DM_ERROR _map_mo_treetoitemwithdata(sync_agent_dm_mo_node_s * root_node, int count, GList ** pItems)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((root_node) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "root_node is NULL!!");
+
+ int depth = 0;
+ int errStop = 0;
+ int e_ret = 0;
+
+ e_ret = sync_agent_traverse_mo_tree_preorder(root_node, map_nodeToItemWithData, depth, errStop, (void **)pItems);
+ _DEBUG_TRACE(" sync-agent traverse mo : %d", e_ret);
+
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static DM_ERROR map_mo_treeToItem(sync_agent_dm_mo_node_s * root_node, int count, GList ** pItems)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ _DEBUG_INFO(" start count : [%d]\n", count);
+
+ retvm_if((root_node) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "root_node is NULL!!");
+
+ int depth = 0;
+ int errStop = 0;
+ int e_ret = 0;
+
+ e_ret = sync_agent_traverse_mo_tree_preorder(root_node, map_nodeToItem, depth, errStop, (void **)pItems);
+ _DEBUG_INFO(" sync-agent traverse mo : %d", e_ret);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+static DM_ERROR _map_mo_listtoitemwithdata(GList * mo_node_list, GList ** pItems)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((mo_node_list) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "mo_node_list is NULL!!");
+
+ int i = 0;
+ GList *iter = NULL;
+ sync_agent_dm_mo_node_s *mo_node = NULL;
+
+ for (iter = mo_node_list; iter != NULL; iter = g_list_next(iter)) {
+ Item *pItem = NULL;
+ mo_node = (sync_agent_dm_mo_node_s *) (iter->data);
+
+ if (mo_node->value != NULL && strlen(mo_node->value) != 0) {
+ ret = construct_Item(mo_node->full_path, NULL, NULL, mo_node->value, 0, 0, &pItem);
+ if (ret != DM_OK) {
+ free_Item(pItem);
+ goto error;
+ }
+
+ (*pItems) = g_list_append((*pItems), pItem);
+
+ _DEBUG_TRACE("[%d], %s", i, pItem->source->locURI);
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+ return ret;
+ error:
+
+ _DEBUG_TRACE(" error end\n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR get_child_mo_list(char *full_path, GList ** pItems)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ _DEBUG_INFO(" start \n");
+
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ //sync_agent_dm_mo_node_s *mo_node_list = NULL ;
+ GList *mo_node_list = NULL;
+ if (full_path == NULL) {
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+ _DEBUG_INFO("full_path : %s", full_path);
+
+ ret = _get_child_mo(full_path, &mo_node_list);
+ if (ret != DM_OK)
+ goto error;
+
+ ret = _map_mo_listtoitemwithdata(mo_node_list, pItems);
+ if (ret != DM_OK)
+ goto error;
+
+ err_code = sync_agent_free_mo_item_list(mo_node_list);
+ _DEBUG_INFO("free mo list L %d ", err_code);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+
+ err_code = sync_agent_free_mo_item_list(mo_node_list);
+ _DEBUG_INFO("free mo list L %d ", err_code);
+ _DEBUG_INFO(" error end\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR get_type_mo_tree(char *mo_full_path, GetType * get_type, char **real_full_path)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ if (mo_full_path == NULL) {
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ char *result = NULL;
+ unsigned int size = 0;
+
+ _DEBUG_INFO(" full_path exist\n");
+
+ result = strstr(mo_full_path, ELEMENT_STRUCTDATA);
+ if (result != NULL) {
+ _DEBUG_INFO(" structdata\n");
+ (*get_type) = GET_TYPE_STRUCTDATA;
+ goto returnpart;
+ }
+
+ result = strstr(mo_full_path, ELEMENT_STRUCT);
+ if (result != NULL) {
+ _DEBUG_INFO(" struct\n");
+ (*get_type) = GET_TYPE_STRUCT;
+ goto returnpart;
+ }
+
+ result = strstr(mo_full_path, ELEMENT_TNDS);
+ if (result != NULL) {
+ _DEBUG_INFO(" tnds\n");
+ (*get_type) = GET_TYPE_TNDS;
+ goto returnpart;
+ }
+
+/* result = strstr(mo_full_path, ELEMENT_PROPERTY);
+ if(result != NULL) {
+ _DEBUG_INFO( " property\n");
+ (*get_type) = GET_PROPERTY;
+ goto returnpart;
+ }*/
+
+ result = strstr(mo_full_path, ELEMENT_PROP_ACL);
+ if (result != NULL) {
+ _DEBUG_INFO(" ACL\n");
+ (*get_type) = GET_TYPE_ACL_PROP;
+ goto returnpart;
+ }
+
+ result = strstr(mo_full_path, ELEMENT_PROP_SIZE);
+ if (result != NULL) {
+ _DEBUG_INFO(" Size\n");
+ (*get_type) = GET_TYPE_SIZE_PROP;
+ goto returnpart;
+ }
+
+ result = strstr(mo_full_path, ELEMENT_PROP_TYPE);
+ if (result != NULL) {
+ _DEBUG_INFO(" Type\n");
+ (*get_type) = GET_TYPE_TYPE_PROP;
+ goto returnpart;
+ }
+
+ result = strstr(mo_full_path, ELEMENT_PROP_NAME);
+ if (result != NULL) {
+ _DEBUG_INFO(" Name\n");
+ (*get_type) = GET_TYPE_NAME_PROP;
+ goto returnpart;
+ }
+
+ result = strstr(mo_full_path, ELEMENT_PROP_FORMAT);
+ if (result != NULL) {
+ _DEBUG_INFO(" Formt\n");
+ (*get_type) = GET_TYPE_FORMAT_PROP;
+ goto returnpart;
+ }
+
+ _DEBUG_INFO(" end ret : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ returnpart:
+
+ size = strlen(mo_full_path) - strlen(result);
+ (*real_full_path) = (char *)calloc(1, sizeof(char) * size + 1);
+ if ((*real_full_path) == NULL) {
+ _DEBUG_INFO("alloc fail");
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+
+ memcpy((*real_full_path), mo_full_path, size);
+
+ _DEBUG_INFO(" full_path_len : [%d], result_len : [%d] real_full_path : %s ", strlen(mo_full_path), size, (*real_full_path));
+ _DEBUG_INFO(" returnpart end [%d]\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+
+ _DEBUG_INFO(" error end [%d]\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR get_struct(char *mo_full_path, GList ** pItems)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_mo_node_s *root_node = NULL;
+ int count = 0;
+
+ ret = _get_descendant_mo(mo_full_path, &root_node, &count);
+ if (ret != DM_OK)
+ goto error;
+
+ ret = map_mo_treeToItem(root_node, count, pItems);
+ if (ret != DM_OK)
+ goto error;
+
+ err = sync_agent_free_mo_item(root_node);
+ if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+ goto error;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+
+ err = sync_agent_free_mo_item(root_node);
+ if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+ goto error;
+ }
+
+ _DEBUG_INFO(" error end : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR get_structdata(char *mo_full_path, GList ** pItems)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ sync_agent_dm_mo_error_e err = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_mo_node_s *root_node = NULL;
+ int count = 0;
+
+ ret = _get_descendant_mo(mo_full_path, &root_node, &count);
+ if (ret != DM_OK)
+ goto error;
+
+ ret = _map_mo_treetoitemwithdata(root_node, count, pItems);
+ if (ret != DM_OK)
+ goto error;
+
+ err = sync_agent_free_mo_item(root_node);
+ if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+ goto error;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+
+ err = sync_agent_free_mo_item(root_node);
+ if (err != SYNC_AGENT_DM_MO_SUCCESS) {
+ goto error;
+ }
+
+ _DEBUG_INFO(" error end : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR get_tnds(char *contenttype, char *mo_full_path, char **output_stream, unsigned int *stream_size)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO(" start mo full path : %s \n", mo_full_path);
+ DM_ERROR ret = DM_OK;
+
+ unsigned int byte_size = 0;
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_mo_type_e mo_type;
+ char *mo_root = NULL;
+ char *result = NULL;
+ int size = 0;
+
+ result = strstr(mo_full_path, ELEMENT_TNDS);
+ if (result != NULL) {
+ size = result - mo_full_path;
+ mo_root = (char *)calloc(1, size);
+ if (mo_root == NULL) {
+ _DEBUG_INFO("alloc fail");
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+ memcpy(mo_root, mo_full_path, size);
+ _DEBUG_INFO(" tnds\n");
+
+ err_code = sync_agent_get_mo_type(mo_root, &mo_type);
+ _DEBUG_INFO("get mo type result : %d", err_code);
+ _DEBUG_INFO("mo type : %d", mo_type);
+
+ if (strcmp(contenttype, ELEMENT_DMTNDS_XML) == 0) {
+ err_code = sync_agent_export_tnds_stream(SYNC_AGENT_DM_MO_TNDS_TYPE_XML, mo_type, mo_root, output_stream, &byte_size);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ ret = DM_ERR_TNDS;
+ goto error;
+ }
+ *stream_size = byte_size;
+ } else if (strcmp(contenttype, ELEMENT_DMTNDS_WBXML) == 0) {
+ err_code = sync_agent_export_tnds_stream(SYNC_AGENT_DM_MO_TNDS_TYPE_WBXML, mo_type, mo_root, output_stream, &byte_size);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ ret = DM_ERR_TNDS;
+ goto error;
+ }
+ *stream_size = byte_size;
+ }
+ _DEBUG_INFO(" tnds byte size : %d\n", byte_size);
+ } else {
+ _DEBUG_INFO(" not tnds");
+ }
+
+ if(mo_root != NULL) {
+ free(mo_root);
+ }
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO(" error end : %d\n", ret);
+ if(mo_root != NULL) {
+ free(mo_root);
+ }
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR set_client_nextnonce(char *pServer_id, char *next_nonce)
+{
+ _EXTERN_FUNC_EXIT;
+
+ DM_ERROR ret = DM_OK;
+
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_acc_info_s *acc_info = NULL;
+ sync_agent_dm_mo_acc_item_info_s sync_agent_mo_acc_info_item;
+
+ if (next_nonce != NULL) {
+
+ sync_agent_mo_acc_info_item.acc_type = DEVICE_MANAGE_ACC_TYPE_CLIENT;
+ sync_agent_mo_acc_info_item.serverid = pServer_id;
+
+ err_code = sync_agent_get_mo_acc_item(&sync_agent_mo_acc_info_item, &acc_info);
+ //acc_info = sync_agent_get_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_CLIENT);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS || acc_info == NULL) {
+ _DEBUG_INFO(" acc null!!\n");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ str_free(&(acc_info->auth_data));
+ acc_info->auth_data = next_nonce;
+
+ //sync_agent_set_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_CLIENT, acc_info);
+ err_code = sync_agent_update_mo_acc_item(&sync_agent_mo_acc_info_item, acc_info);
+ _DEBUG_INFO("sync agent update result : %d", err_code);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ } else {
+ //do nothing
+ }
+
+ sync_agent_free_mo_acc_item(&acc_info);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ sync_agent_free_mo_acc_item(&acc_info);
+
+ _DEBUG_INFO(" error end : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR set_client_authtype(char *pServer_id, AuthType auth_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ char *authname = NULL;
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_acc_info_s *acc_info = NULL;
+ sync_agent_dm_mo_acc_item_info_s sync_agent_mo_acc_info_item;
+
+ if (pServer_id == NULL) {
+ _DEBUG_INFO(" server id is null");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ sync_agent_mo_acc_info_item.acc_type = DEVICE_MANAGE_ACC_TYPE_CLIENT;
+ sync_agent_mo_acc_info_item.serverid = pServer_id;
+
+ err_code = sync_agent_get_mo_acc_item(&sync_agent_mo_acc_info_item, &acc_info);
+ //acc_info = sync_agent_get_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_CLIENT);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS || acc_info == NULL) {
+ _DEBUG_INFO(" acc null!!\n");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ __set_Session_AuthType_name(auth_type, &authname);
+
+ _DEBUG_INFO("authtype is %s", authname);
+ acc_info->auth_type = authname;
+
+ //err = sync_agent_set_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_CLIENT, acc_info);
+ err_code = sync_agent_update_mo_acc_item(&sync_agent_mo_acc_info_item, acc_info);
+ _DEBUG_INFO("sync agent update result : %d", err_code);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ sync_agent_free_mo_acc_item(&acc_info);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+
+ sync_agent_free_mo_acc_item(&acc_info);
+
+ _DEBUG_INFO(" error end : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
diff --git a/src/agent/serviceadapter/dm-phase-handler/dm_phase_handler.c b/src/agent/serviceadapter/dm-phase-handler/dm_phase_handler.c
new file mode 100755
index 0000000..e8fafeb
--- /dev/null
+++ b/src/agent/serviceadapter/dm-phase-handler/dm_phase_handler.c
@@ -0,0 +1,1451 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common_def.h"
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "serviceadapter/dm-phase-handler/dm_phase_handler.h"
+#include "serviceadapter/protocolbinder/syncml_protocol_binder.h"
+#include "serviceadapter/sa_define.h"
+#include "serviceadapter/sa_syncml_binders.h"
+#include "serviceadapter/sa_elements.h"
+#include "serviceadapter/sa_elements_internal.h"
+#include "serviceadapter/sa_command.h"
+#include "serviceadapter/sa_command_internal.h"
+#include "serviceadapter/sa_session.h"
+#include "serviceadapter/sa_session_internal.h"
+#include "serviceadapter/sa_util.h"
+#include "serviceadapter/networkbinder/na_binder.h"
+#include "mo-handler/dm_mo_common.h"
+#include "mo-handler/dm_mo_handler.h"
+#include "dm-engine/dm_common_engine.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_CONTEXT"
+#endif
+
+#define MAX_SESSION_COUNT 5
+
+/*temp size*/
+#define LARGE_OBJECT_SIZE 10000
+
+static int file_count = 0;
+
+/*static ErrorType get_AccountInfo(int accountId, char **id, char **pwd, char **serverUrl, int *isBase64, char **nextNonce);*/
+static DM_ERROR __get_dmaccInfo(char *pServer_id, char **client_id, char **client_pwd, char **sourceUrl, char **targetUrl, int *isBase64, char **nextNonce);
+static DM_ERROR __check_hmac(Session ** session, char *msg, unsigned int msg_size);
+static DM_ERROR __create_authentication(Session ** session, char *client_id, char *client_pwd, int isBase64, char *nextNonce);
+static DM_ERROR ___generater_deviceInfo_replacecmd(Command ** pReplaceCommand);
+static DM_ERROR __create_devinfo_replace_cmd(Session * session, Command ** pCommand);
+static DM_ERROR _generate_setupphase_msg(Session ** session, char *pServer_id, char *pSession_id, int session_type, char **msg, unsigned int *msg_size);
+static DM_ERROR _generate_management_msg(Session ** session, char **msg, unsigned int *msg_size);
+static DM_ERROR _generate_generic_alert(Session ** session, char *pServer_id, char *pSession_id, char **msg, int *msg_size, int service_engine_id, int result);
+static DM_ERROR _send_msg(char *accType, int transportType, Session ** session, char *server_url, GList * header_info, char *sendMsg, unsigned int sendMsg_length, GList ** recv_header, char **recvMsg, unsigned int *recvMsg_length);
+static DM_ERROR _recv_msg(Session ** session, char *recvMsg, unsigned int recvMsg_length, ENGINE_ID * service_engine_id, int *isFinish, int isgeneticAlert);
+
+static DM_ERROR __get_dmaccInfo(char *pServer_id, char **client_id, char **client_pwd, char **sourceUrl, char **targetUrl, int *isBase64, char **nextNonce)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((pServer_id) == NULL, COMMON_ERR_IS_NULL, "pServer_id is NULL!!");
+
+ char *authType = NULL;
+ ret = get_client_dmacc(pServer_id, client_id, client_pwd, sourceUrl, targetUrl, isBase64, nextNonce, &authType);
+ if (ret != DM_OK)
+ goto error;
+
+ _DEBUG_VERBOSE(" end\n");
+ _INNER_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_VERBOSE(" error end [%d]\n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static DM_ERROR ___generater_deviceInfo_replacecmd(Command ** pReplaceCommand)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ /*get DevInfo */
+ Item *pItem = NULL;
+ ret = get_child_mo_list(DM_DEVINFO, &(*pReplaceCommand)->private.change.items);
+ if (ret != DM_OK)
+ goto error;
+
+ GList *iter = NULL;
+ for (iter = (*pReplaceCommand)->private.change.items; iter != NULL; iter = g_list_next(iter)) {
+ pItem = iter->data;
+ pItem->contenttype = g_strdup(ELEMENT_TEXTPLAIN);
+ pItem->format = g_strdup(ELEMENT_CHR);
+ }
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_VERBOSE(" error end\n");
+ _INNER_FUNC_EXIT;
+ return ret;
+
+}
+
+static DM_ERROR __create_devinfo_replace_cmd(Session * session, Command ** pCommand)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ retvm_if((session) == NULL, COMMON_ERR_IS_NULL, "session is NULL!!");
+
+ ret = create_replace_cmd(session, pCommand);
+ if (ret != DM_OK)
+ goto error;
+
+ ret = ___generater_deviceInfo_replacecmd(pCommand);
+ if (ret != DM_OK)
+ goto error;
+
+ _INNER_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_VERBOSE(" error : %d\n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+
+}
+
+static DM_ERROR _generate_setupphase_msg(Session ** session, char *pServer_id, char *pSession_id, int session_type, char **msg, unsigned int *msg_size)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((pServer_id) == NULL, COMMON_ERR_IS_NULL, "pServer_id is NULL!!");
+
+ int isFinal = 1;
+
+ /*Client init */
+ if (pSession_id == NULL)
+ pSession_id = g_strdup_printf("%ld", time(NULL));
+
+ char *sourceUrl = NULL;
+ char *client_id = NULL;
+ char *client_pwd = NULL;
+ char *targetUrl = NULL;
+ int isBase64 = 0;
+ char *nextNonce = NULL;
+
+ ret = __get_dmaccInfo(pServer_id, &client_id, &client_pwd, &sourceUrl, &targetUrl, &isBase64, &nextNonce);
+ if (ret != DM_OK)
+ goto error;
+
+ if (nextNonce == NULL) {
+ (nextNonce) = strdup(ELEMENT_DEFAULT_CLIENT_NONCE);
+ }
+
+ if ((*session) == NULL) {
+ ret = create_syncml_session(VERSION_12, PROTOCOL_TYPE_DM, pServer_id, client_id, pSession_id, sourceUrl, targetUrl, session);
+ if (ret != DM_OK)
+ goto error;
+ } else {
+ (*session)->msgID = 0;
+
+#ifdef _DM_BUNDANG_TEST
+ /*redirection code */
+ if ((*session)->target->locURI != NULL) {
+ char *replace = NULL;
+ replace = get_new_uri((*session)->target->locURI);
+ str_free(&((*session)->target->locURI));
+ (*session)->target->locURI = g_strdup(replace);
+ str_free(&replace);
+ _DEBUG_TRACE(" targer url : %s \n", (*session)->target->locURI);
+ }
+#endif
+ isBase64 = 1;
+ }
+
+ _DEBUG_TRACE(" targer url : %s \n", (*session)->target->locURI);
+ ret = __create_authentication(session, client_id, client_pwd, isBase64, nextNonce);
+ if (ret != DM_OK)
+ goto error;
+
+ _DEBUG_TRACE("targer url : %s \n", (*session)->target->locURI);
+
+ GList *commands = NULL;
+ GList *commands_last = NULL;
+
+ /*SyncHdr */
+ SyncHdr *pSyncHdr = NULL;
+ ret = create_syncml_hdr((*session), &pSyncHdr);
+ if (ret != DM_OK)
+ goto error;
+
+ /*SyncBody */
+ /* create alert */
+ AlertType syncType;
+ switch (session_type) {
+ case 0: //IP_PUSH_EVENT
+ case 1: //WAP_PUSH_EVENT
+ syncType = DM_ALERT_SERVER_INITIATED_MGMT;
+ break;
+ case 2: //UI_EVENT
+ case 3: //SERVER_BOOTSTRAP_EVENT
+ syncType = DM_ALERT_CLIENT_INITIATED_MGMT;
+ break;
+ default:
+ syncType = DM_ALERT_CLIENT_INITIATED_MGMT;
+ break;
+ }
+
+ Command *pAlertCommand = NULL;
+ ret = create_alert_cmd((*session), syncType, &pAlertCommand);
+ if (ret != DM_OK)
+ goto error;
+ putCmdIntoList(&commands, &commands_last, pAlertCommand);
+
+ /* create replace */
+ Command *pReplaceCommand = NULL;
+ ret = __create_devinfo_replace_cmd((*session), &pReplaceCommand);
+ if (ret != DM_OK)
+ goto error;
+ putCmdIntoList(&commands, &commands_last, pReplaceCommand);
+
+ /*create SyncML */
+ SyncML *pSyncML = NULL;
+ ret = create_syncml(pSyncHdr, NULL, commands, isFinal, &pSyncML);
+ if (ret != DM_OK)
+ goto error;
+
+ /* convert Msg */
+ ret = syncml_objectbinder(pSyncML, msg, msg_size);
+ if (ret != DM_OK)
+ goto error;
+
+ /*xml */
+/* xml_len = remove_xml_header(xml, xml_len);
+ _DEBUG_TRACE("msg : %s", msg);
+ ret = check_hmac( session, xml, xml_len);*/
+
+ /*wbxml */
+ _DEBUG_TRACE("msg : %s", msg);
+ ret = __check_hmac(session, *msg, *msg_size);
+ _DEBUG_TRACE(" check hmac:%d\n", ret);
+
+ //free generate structure
+ free_syncml(pSyncML);
+ pSyncML = NULL;
+
+ //session->status, session->alertCommand are already freed in free_SyncML function
+ (*session)->status = NULL;
+
+ if ((*session)->alertCommand != NULL) {
+ g_list_free((*session)->alertCommand);
+ (*session)->alertCommand = NULL;
+ }
+
+ (*session)->isSendingfinal = isFinal;
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ error:
+
+ _DEBUG_TRACE(" error : %d\n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static DM_ERROR _generate_management_msg(Session ** session, char **msg, unsigned int *msg_size)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((*session) == NULL, COMMON_ERR_IS_NULL, "session is NULL!!");
+
+ sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+ sync_agent_pb_error_e err = init_syncml_binder_function_set(&pBinder_function_set);
+
+ SyncML *pSyncML = NULL;
+ SyncHdr *pSyncHdr = NULL;
+
+ GList *commands = NULL;
+ GList *commands_last = NULL;
+ int isFinal = 1;
+ bool cancel_flag = false;
+
+ GList *status_iter = NULL;
+ Status *pStatus = NULL;
+
+ Command *pAlertCommand = NULL;
+ GList *alert_iter = NULL;
+
+ GList *results_iter = NULL;
+ Command *pResultsCommand = NULL;
+ Command *restResultsCommand = NULL;
+
+ unsigned int estimate_size = 0;
+ int data_size = 0;
+
+ GList *results_data_iter = NULL;
+ GList *rest_result_data_iter = NULL;
+
+ Item *result_item = NULL;
+ Item *rest_result_item = NULL;
+ char *result_data = NULL;
+ int full_msg = 0;
+
+ sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ pBinder = syncml_binder_init(pBinder, SYNC_AGENT_PB_ENCODING_WBXML_12, false, true, pBinder_function_set);
+
+#ifdef _DM_BUNDANG_TEST
+ /*redirection code */
+ if ((*session)->target->locURI != NULL) {
+ char *replace = NULL;
+ replace = get_new_uri((*session)->target->locURI);
+ str_free(&((*session)->target->locURI));
+ (*session)->target->locURI = g_strdup(replace);
+ str_free(&replace);
+
+ _DEBUG_TRACE(" targer url : %s \n", (*session)->target->locURI);
+ }
+#endif
+
+ /* create SyncHdr */
+ ret = create_syncml_hdr((*session), &pSyncHdr);
+ if (ret != DM_OK)
+ goto error;
+ err = syncml_binder_append(pBinder, PE_SYNCML_START, NULL);
+ err = syncml_binder_append(pBinder, PE_HEADER, pSyncHdr);
+ err = syncml_binder_append(pBinder, PE_BODY_START, NULL);
+
+/* ExecuteObject ** responseObj = (ExecuteObject*) pResponseObj;*/
+ for (status_iter = (*session)->status; status_iter != NULL; status_iter = g_list_next(status_iter)) {
+ _DEBUG_TRACE("======================================status command================================\n");
+ pStatus = status_iter->data;
+ err = syncml_binder_append(pBinder, PE_STATUS, pStatus);
+ }
+
+ //if we have to send alert command(1222,1223 etc)
+ cancel_flag = sync_agent_check_cancel_flag();
+ _DEBUG_TRACE("======================================alert command================================\n");
+ _DEBUG_TRACE("======================================%d================================\n", cancel_flag);
+
+ if (cancel_flag != 0) {
+ ret = create_alert_cmd((*session), DM_ALERT_SESSION_ABORT, &pAlertCommand);
+ if (ret != DM_OK)
+ goto error;
+ putCmdIntoList(&commands, &commands_last, pAlertCommand);
+ err = syncml_binder_append(pBinder, PE_ALERT, pAlertCommand);
+ }
+
+ for (alert_iter = (*session)->alertCommand; alert_iter != NULL; alert_iter = g_list_next(alert_iter)) {
+ _DEBUG_TRACE("======================================alert command================================\n");
+ pAlertCommand = alert_iter->data;
+ putCmdIntoList(&commands, &commands_last, pAlertCommand);
+ err = syncml_binder_append(pBinder, PE_ALERT, pAlertCommand);
+ }
+
+ _DEBUG_TRACE(" server maxsize : %d ", (*session)->targetMaxMsgSize);
+ if ((*session)->resultsCommand != NULL) {
+ _DEBUG_TRACE("result command length : %d ", g_list_length((*session)->resultsCommand));
+
+ _DEBUG_TRACE("======================================result command================================\n");
+ for (results_iter = (*session)->resultsCommand; results_iter != NULL;) {
+ _DEBUG_TRACE("resultcommand iter");
+ pResultsCommand = results_iter->data;
+
+ sync_agent_get_stream_size_from_protocol_binder(pBinder, &estimate_size);
+ _DEBUG_TRACE("msg extimate size : %d ", estimate_size);
+
+ ret = duplicate_command(pResultsCommand, &restResultsCommand);
+ _DEBUG_TRACE("dupicate command : %d", ret);
+ if (ret != DM_OK) {
+ goto error;
+ }
+
+ results_iter = g_list_next(results_iter);
+
+ for (results_data_iter = pResultsCommand->private.results.items, rest_result_data_iter = restResultsCommand->private.results.items; results_data_iter != NULL && rest_result_data_iter != NULL;) {
+ _DEBUG_TRACE("resultcommand item iter");
+
+ result_item = (Item *) (results_data_iter->data);
+ rest_result_item = (Item *) (rest_result_data_iter->data);
+
+ result_data = result_item->private.data;
+
+ results_data_iter = g_list_next(results_data_iter);
+ rest_result_data_iter = g_list_next(rest_result_data_iter);
+
+ if (full_msg == 1) {
+ _DEBUG_TRACE("remove item because msg size over");
+ pResultsCommand->private.results.items = g_list_remove(pResultsCommand->private.results.items, result_item);
+ } else {
+ _DEBUG_TRACE("result item add packet");
+ if (result_item->moreData == 1) {
+ _DEBUG_TRACE("item msg cut by largeObject");
+ isFinal = 0;
+
+ char *data = NULL;
+ int maxsize = 0;
+ data = strdup(result_data);
+
+ str_free(&(result_item->private.data));
+ str_free(&(rest_result_item->private.data));
+
+ maxsize = (*session)->targetMaxMsgSize - estimate_size - DEFAULT_REST_SIZE;
+ _DEBUG_TRACE("maxsize : %d", maxsize);
+
+ result_item->private.data = (char *)calloc(1, maxsize + 1);
+ if (result_item->private.data == NULL) {
+ _DEBUG_TRACE("alloc fail");
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+ memcpy(result_item->private.data, data, maxsize);
+
+ _DEBUG_TRACE("rest data size : %d", result_item->size - maxsize);
+ rest_result_item->private.data = (char *)calloc(1, result_item->size - maxsize + 1);
+ if (rest_result_item->private.data == NULL) {
+ _DEBUG_TRACE("alloc fail");
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+ memcpy(rest_result_item->private.data, data + maxsize, result_item->size - maxsize);
+ rest_result_item->size = result_item->size - maxsize;
+
+ if (maxsize > result_item->size - maxsize) {
+ _DEBUG_TRACE("set msg non more data");
+ rest_result_item->moreData = 0;
+ }
+
+ data_size += maxsize;
+ _DEBUG_TRACE("msg(moredata) data size : %d ", data_size);
+
+ full_msg = 1;
+ } else {
+ _DEBUG_TRACE("remove item temp list");
+ data_size += result_item->size;
+
+ _DEBUG_TRACE("msg data size : %d ", data_size);
+ restResultsCommand->private.results.items = g_list_remove(restResultsCommand->private.results.items, rest_result_item);
+ }
+ }
+ }
+
+ /*multiple msg */
+ _DEBUG_TRACE(" ESTIMATE SIZE IN RESULTS= %d", estimate_size + data_size + DEFAULT_REST_SIZE);
+ if ((*session)->targetMaxMsgSize >= estimate_size + data_size + DEFAULT_REST_SIZE) {
+ _DEBUG_TRACE("insert result in msg");
+ putCmdIntoList(&commands, &commands_last, pResultsCommand);
+ (*session)->resultsCommand = g_list_remove((*session)->resultsCommand, pResultsCommand);
+
+ err = syncml_binder_append(pBinder, PE_RESULTS_START, pResultsCommand);
+ err = syncml_binder_append(pBinder, PE_RESULTS_END, NULL);
+
+ } else {
+ /*large object */
+ isFinal = 0;
+ _DEBUG_TRACE("cut result in msg");
+
+ if (full_msg == 1) {
+ _DEBUG_TRACE("msg msg over large object");
+ } else {
+ _DEBUG_TRACE("msg cut by MultiMsg");
+ }
+ _DEBUG_TRACE("free rest result command");
+ /*while break */
+ break;
+ }
+
+ if (full_msg == 1) {
+ /*large object rest part preapend in resultsCommands list for next msg */
+ if (g_list_length(restResultsCommand->private.results.items) > 0) {
+ (*session)->resultsCommand = g_list_prepend((*session)->resultsCommand, restResultsCommand);
+ }
+ _DEBUG_TRACE("msg cut by MultiMsg");
+ break;
+ } else {
+ free_command(restResultsCommand);
+ restResultsCommand = NULL;
+ _DEBUG_TRACE("free rest result command");
+ }
+ }
+ _DEBUG_TRACE("added result command");
+ }
+
+ /*syncml */
+ ret = create_syncml(pSyncHdr, (*session)->status, commands, isFinal, &pSyncML);
+ if (ret != DM_OK)
+ goto error;
+
+ _DEBUG_TRACE("final element : %d", isFinal);
+ if (isFinal == 1) {
+ err = syncml_binder_append(pBinder, PE_FINAL, NULL);
+ }
+
+ err = syncml_binder_append(pBinder, PE_BODY_END, NULL);
+ err = syncml_binder_append(pBinder, PE_SYNCML_END, NULL);
+
+ syncml_binder_get_stream(pBinder, msg, msg_size);
+
+ char *xml = NULL;
+ unsigned int xml_size = 0;
+ err = sync_agent_get_xml_from_protocol_binder(pBinder, &xml, &xml_size);
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ fprintf(stderr, " msg from client \n");
+ if (fputs(xml, stderr) == EOF) {
+ _DEBUG_TRACE("debuging test error");
+ }
+ set_xml_to_file(xml, OMA_DM_MSG_PATH);
+ str_free(&xml);
+ }
+
+ syncml_binder_terminate(pBinder);
+
+ /*xml */
+/* xml_len = remove_xml_header(xml, xml_len);
+ _DEBUG_TRACE("msg : %s", msg);
+ ret = check_hmac( session, xml, xml_len);*/
+
+ /*wbxml */
+ ret = __check_hmac(session, *msg, *msg_size);
+ _DEBUG_TRACE(" check hmac:%d\n", ret);
+
+ free_syncml(pSyncML);
+ pSyncML = NULL;
+
+ //session->status, session->alertCommand are already freed in free_SyncML function
+ (*session)->status = NULL;
+ if ((*session)->alertCommand != NULL) {
+ g_list_free((*session)->alertCommand);
+ (*session)->alertCommand = NULL;
+ }
+ if (isFinal == 1) {
+ g_list_free((*session)->resultsCommand);
+ (*session)->resultsCommand = NULL;
+ }
+
+ (*session)->isSendingfinal = isFinal;
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ error:
+ free_command(restResultsCommand);
+ restResultsCommand = NULL;
+
+ free_synchdr(pSyncHdr);
+ pSyncHdr = NULL;
+
+ free_syncml(pSyncML);
+ pSyncML = NULL;
+
+ _DEBUG_TRACE(" error :%d\n", ret);
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ //1500 -> ERROR_INTERNAL_OK : generatePreSyncMsg has been completed without any error
+ //1512 -> ERROR_INTERNAL_NO_MEMORY : failed to allocate memory
+ //1513 -> ERROR_INTERNAL_NOT_DEFINED : something is not defined that must have
+ //1503 -> ERROR_INTERNAL_BINDER_ERROR : binder error
+}
+
+DM_ERROR __check_hmac(Session ** session, char *xml, unsigned int xml_len)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((xml) == NULL, COMMON_ERR_IS_NULL, "xml is NULL!!");
+ retvm_if((*session) == NULL, COMMON_ERR_IS_NULL, "session is NULL!!");
+
+ AuthType auth_type = AUTH_TYPE_UNKNOWN;
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ sync_agent_dm_acc_info_s *acc_info = NULL;
+ sync_agent_dm_mo_acc_item_info_s sync_agent_mo_acc_info_item;
+
+ sync_agent_mo_acc_info_item.acc_type = DEVICE_MANAGE_ACC_TYPE_CLIENT;
+ sync_agent_mo_acc_info_item.serverid = (*session)->pServer_id;
+
+ err_code = sync_agent_get_mo_acc_item(&sync_agent_mo_acc_info_item, &acc_info);
+ //acc_info = sync_agent_get_acc_info(pServer_id, DEVICE_MANAGE_ACC_TYPE_CLIENT);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS || acc_info == NULL) {
+ _DEBUG_VERBOSE(" acc null!!\n");
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ _DEBUG_VERBOSE(" id = %s\n", acc_info->auth_name);
+ _DEBUG_VERBOSE(" pwd = %s\n", acc_info->auth_secret);
+ _DEBUG_VERBOSE(" serverUrl = %s\n", acc_info->addr);
+ _DEBUG_VERBOSE(" nextNonce = %s\n", acc_info->auth_data);
+
+ if ((acc_info->auth_name) == NULL || (acc_info->auth_secret) == NULL || (acc_info->addr) == NULL) {
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ auth_type = __get_Session_AuthType_enum(acc_info->auth_type);
+ if (auth_type == AUTH_TYPE_HMAC) {
+
+ _DEBUG_VERBOSE("auth name : %s", acc_info->auth_name);
+ _DEBUG_VERBOSE("auth secret : %s", acc_info->auth_secret);
+ _DEBUG_VERBOSE("auth data : %s", acc_info->auth_data);
+/* _DEBUG_VERBOSE("xml : %s", xml);
+ _DEBUG_VERBOSE("xml_len : %d", xml_len);*/
+
+ unsigned char *nonce = NULL;
+ unsigned int nonce_size = 0;
+ ret = nonce_decode(acc_info->auth_data, &nonce, &nonce_size);
+ _DEBUG_VERBOSE("nonce result : %d", ret);
+ _DEBUG_VERBOSE("nonce : %s, noncesize : %d", nonce, nonce_size);
+
+ char *mac = NULL;
+ ret = gemerate_hmac(acc_info->auth_name, acc_info->auth_secret, nonce, nonce_size, xml, xml_len, &mac);
+ if (ret != DM_OK)
+ goto error;
+ _DEBUG_VERBOSE("mac : %s", mac);
+
+ ret = create_hmac(acc_info->auth_name, "MD5", mac, session);
+ str_free(&mac);
+ if (ret != DM_OK)
+ goto error;
+ } else {
+ _DEBUG_VERBOSE(" auth type : [%d] \n", auth_type);
+ }
+
+ sync_agent_free_mo_acc_item(&acc_info);
+
+ _INNER_FUNC_EXIT;
+ return ret;
+ error:
+
+ sync_agent_free_mo_acc_item(&acc_info);
+
+ _INNER_FUNC_EXIT;
+ _DEBUG_VERBOSE(" end : %d", ret);
+ return ret;
+}
+
+static DM_ERROR __create_authentication(Session ** session, char *client_id, char *client_pwd, int isBase64, char *nextNonce)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((*session) == NULL, COMMON_ERR_IS_NULL, "session is NULL!!");
+ retvm_if((client_id) == NULL, COMMON_ERR_IS_NULL, "client_id is NULL!!");
+
+ Cred *pCred = NULL;
+ Chal *chal = (*session)->res_chal;
+ FormatType formatType = FORMAT_TYPE_UNKNOWN;
+ AuthType pAuthType = AUTH_TYPE_UNKNOWN;
+ char *credData = NULL;
+
+ ret = get_dmacc_authType((*session)->pServer_id, &pAuthType);
+ if (ret != DM_OK)
+ goto error;
+ _DEBUG_VERBOSE(" pAuthType : [%d] \n", pAuthType);
+
+ if (chal == NULL) {
+ _DEBUG_VERBOSE("CHAL DOES NOT EXIST\n");
+
+ unsigned int out_len = 0;
+ unsigned char *nextNonceDecode = NULL;
+
+ switch (pAuthType) {
+ case AUTH_TYPE_BASIC:{
+ formatType = FORMAT_TYPE_BASE64;
+ }
+ break;
+ case AUTH_TYPE_MD5:
+ case AUTH_TYPE_HMAC:
+ {
+ if (isBase64 == 1)
+ formatType = FORMAT_TYPE_BASE64;
+ else
+ formatType = FORMAT_TYPE_UNKNOWN;
+
+ if (nextNonce != NULL) {
+ _DEBUG_VERBOSE("nextnonce : %s", nextNonce);
+ ret = nonce_decode(nextNonce, &nextNonceDecode, &out_len);
+ _DEBUG_VERBOSE("nonce result : %d", ret);
+ _DEBUG_VERBOSE("nextnoncedecode : %s out len : %d", nextNonceDecode, out_len);
+ } else {
+ pAuthType = AUTH_TYPE_BASIC;
+ formatType = FORMAT_TYPE_BASE64;
+ }
+ if (pAuthType == AUTH_TYPE_HMAC) {
+ (*session)->isHMAC = 1;
+
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ _DEBUG_VERBOSE(" client id : %s , client pwd : %s\n", client_id, client_pwd);
+
+ ret = create_auth_credString(pAuthType, client_id, client_pwd, nextNonceDecode, out_len, &credData);
+ if (ret != DM_OK)
+ goto error;
+
+ ret = create_auth_cred(client_id, client_pwd, pAuthType, formatType, credData, &pCred);
+ if (ret != DM_OK)
+ goto error;
+
+ } else {
+ _DEBUG_VERBOSE("CHAL DOES EXIST\n");
+
+ unsigned int out_len = 0;
+ unsigned char *nextNonceDecode = NULL;
+
+ if ((*session)->res_chal->type == AUTH_TYPE_HMAC) {
+ (*session)->isHMAC = 1;
+
+ } else {
+ (*session)->isHMAC = 0;
+ }
+
+ if (chal->nonce_plain != NULL) {
+ _DEBUG_VERBOSE("chal->nonce_plain : %s", chal->nonce_plain);
+ ret = nonce_decode(chal->nonce_plain, &nextNonceDecode, &out_len);
+ _DEBUG_VERBOSE("nonce result : %d", ret);
+ _DEBUG_VERBOSE("nextnonceDecode : %s, out len : %d", nextNonceDecode, out_len);
+ if (ret != DM_OK)
+ goto error;
+ }
+ ret = create_auth_credString(chal->type, client_id, client_pwd, chal->type == AUTH_TYPE_BASIC ? (const unsigned char *)(chal->nonce_b64) : (const unsigned char *)(nextNonceDecode), out_len, &credData);
+ if (ret != DM_OK)
+ goto error;
+
+ ret = create_auth_cred(client_id, client_pwd, chal->type, chal->format, credData, &pCred);
+ if (ret != DM_OK)
+ goto error;
+ }
+ str_free(&credData);
+
+ ret = set_session_authcred((*session), pCred);
+ if (ret != DM_OK)
+ goto error;
+
+ _INNER_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_VERBOSE(" end error %d \n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static DM_ERROR _generate_generic_alert(Session ** session, char *pServer_id, char *pSession_id, char **msg, int *msg_size, int service_engine_id, int result)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ engine_status *service_status = NULL;
+ int isFinal = 1;
+
+ retvm_if((pServer_id) == NULL, COMMON_ERR_IS_NULL, "pServer_id is NULL!!");
+
+ char *sourceUrl = NULL;
+ char *client_id = NULL;
+ char *client_pwd = NULL;
+ char *targetUrl = NULL;
+ int isBase64 = 0;
+ char *nextNonce = NULL;
+ SyncHdr *pSyncHdr = NULL;
+ Command *pAlertCommand = NULL;
+ char *format = NULL;
+ char *contenttype = NULL;
+ Command *pReplaceCommand = NULL;
+ char *data = NULL;
+ char *pCorrelator = NULL;
+ char *rSourceUrl = NULL;
+
+ /*Client init */
+
+ if ((*session) != NULL) {
+ _DEBUG_TRACE("session is Exist");
+ if ((*session)->sessionID != NULL) {
+ _DEBUG_TRACE("session id : %s", (*session)->sessionID);
+ pSession_id = (*session)->sessionID;
+ }
+ } else if (pSession_id == NULL) {
+ pSession_id = g_strdup_printf("%ld", time(NULL));
+ }
+
+ ret = __get_dmaccInfo(pServer_id, &client_id, &client_pwd, &sourceUrl, &targetUrl, &isBase64, &nextNonce);
+
+ if (ret != DM_OK)
+ goto error;
+
+ if (nextNonce == NULL) {
+ (nextNonce) = strdup(ELEMENT_DEFAULT_CLIENT_NONCE);
+ }
+
+ _DEBUG_TRACE(" id = %s\n", client_id);
+ _DEBUG_TRACE(" pwd = %s\n", client_pwd);
+ _DEBUG_TRACE(" Session_id = %s\n", pSession_id);
+ _DEBUG_TRACE(" sourceUrl = %s\n", sourceUrl);
+ _DEBUG_TRACE(" serverUrl = %s\n", targetUrl);
+ _DEBUG_TRACE(" nextNonce = %s\n", nextNonce);
+
+ if ((*session) == NULL) {
+ ret = create_syncml_session(VERSION_12, PROTOCOL_TYPE_DM, pServer_id, client_id, pSession_id, sourceUrl, targetUrl, session);
+ if (ret != DM_OK)
+ goto error;
+ } else {
+ (*session)->msgID = 0;
+
+#ifdef _DM_BUNDANG_TEST
+ /*redirection code */
+ if ((*session)->target->locURI != NULL) {
+ char *replace = NULL;
+ replace = get_new_uri((*session)->target->locURI);
+ str_free(&((*session)->target->locURI));
+ (*session)->target->locURI = g_strdup(replace);
+ str_free(&replace);
+ _DEBUG_TRACE(" targer url : %s \n", (*session)->target->locURI);
+ }
+#endif
+
+ //nextNonce = g_nextnonce;
+ //nextNonce = strdup( (*session)->res_chal->nonce_plain);
+ _DEBUG_TRACE(" NextNonce = %s\n", nextNonce);
+ isBase64 = 1;
+ }
+
+ ret = __create_authentication(session, client_id, client_pwd, isBase64, nextNonce);
+ if (ret != DM_OK)
+ goto error;
+
+ /*SyncHdr */
+
+ ret = create_syncml_hdr((*session), &pSyncHdr);
+ if (ret != DM_OK)
+ goto error;
+
+ GList *commands = NULL;
+ GList *commands_last = NULL;
+
+ /* create alert */
+ ret = create_alert_cmd((*session), DM_ALERT_CLIENT_INITIATED_MGMT, &pAlertCommand);
+ if (ret != DM_OK)
+ goto error;
+ putCmdIntoList(&commands, &commands_last, pAlertCommand);
+
+ /* create alert */
+ pAlertCommand = NULL;
+ ret = create_alert_cmd((*session), DM_ALERT_GENERIC_ALERT, &pAlertCommand);
+ if (ret != DM_OK)
+ goto error;
+
+ _DEBUG_TRACE(" service engine status = [%d]\n", service_engine_id);
+
+ ret = Get_Engine_Status(service_engine_id, &service_status);
+ if (ret != DM_OK) {
+ goto error;
+ }
+
+ _DEBUG_TRACE("STATUS VALUE : %d ", service_status->engine_status);
+ _DEBUG_TRACE("generic alert status data : %d ", result);
+
+ if (service_status->correlator != NULL) {
+ pCorrelator = g_strdup(service_status->correlator);
+ }
+ if (service_status->mo_path != NULL) {
+ rSourceUrl = g_strdup(service_status->mo_path);
+ }
+ if (rSourceUrl == NULL) {
+ ret = COMMON_ERR_IS_NULL;
+ goto error;
+ }
+
+ SERVICE_SERVER_TYPE engine_type = get_service_type(rSourceUrl);
+ switch (engine_type) {
+ case SAMSUNG_FUMO_TYPE:
+ case GCF_TYPE:
+ //format = strdup("chr");//NULL;
+ //contenttype = strdup("text/plain");//NULL;
+ contenttype = strdup("org.openmobilealliance.dm.firmwareupdate.downloadandupdate");
+ break;
+ case SAMSUNG_FMM_TYPE:
+ contenttype = strdup("urn:oma:at:lawmo:1.0:OperationComplete");
+ break;
+ default:
+ break;
+ }
+ //ret = get_mo_node_format_contenttype(rSourceUrl ,&format, &contenttype );
+
+ data = g_strdup_printf("%d", result);
+ unsigned int size = 0;
+ unsigned int moredata = 0;
+ _DEBUG_TRACE("generic alert status data : %s ", data);
+
+ Item *pItem = NULL;
+ ret = set_correlator(&pAlertCommand, pCorrelator);
+
+ ret = construct_Item(rSourceUrl, format, contenttype, data, size, moredata, &pItem);
+ pAlertCommand->private.alert.items = g_list_append(pAlertCommand->private.alert.items, pItem);
+ putCmdIntoList(&commands, &commands_last, pAlertCommand);
+
+ /* create replace */
+ ret = __create_devinfo_replace_cmd((*session), &pReplaceCommand);
+ if (ret != DM_OK)
+ goto error;
+ putCmdIntoList(&commands, &commands_last, pReplaceCommand);
+
+ /*create SyncML */
+ SyncML *pSyncML = NULL;
+ ret = create_syncml(pSyncHdr, NULL, commands, isFinal, &pSyncML);
+ if (ret != DM_OK)
+ goto error;
+
+ (*session)->isSendingfinal = isFinal;
+
+ /* convert Msg */
+ ret = syncml_objectbinder(pSyncML, msg, (unsigned int *)msg_size);
+ if (ret != DM_OK)
+ goto error;
+
+ /*xml */
+/* xml_len = remove_xml_header(xml, xml_len);
+ _DEBUG_TRACE("msg : %s", msg);
+ ret = check_hmac( session, xml, xml_len);*/
+
+ /*wbxml */
+ _DEBUG_TRACE("msg : %s", msg);
+ ret = __check_hmac(session, *msg, *msg_size);
+
+ //free generate structure
+ free_syncml(pSyncML);
+ pSyncML = NULL;
+
+ //session->status, session->alertCommand are already freed in free_SyncML function
+ if ((*session)->resultsCommand != NULL) {
+ g_list_free((*session)->resultsCommand);
+ (*session)->resultsCommand = NULL;
+ }
+
+ if ((*session)->alertCommand != NULL) {
+ g_list_free((*session)->alertCommand);
+ (*session)->alertCommand = NULL;
+ }
+
+ (*session)->status = NULL;
+ (*session)->isSendingfinal = isFinal;
+
+ Free_Memory_Engine_Status(&service_status, 1);
+
+ str_free(&pCorrelator);
+ str_free(&rSourceUrl);
+ str_free(&data);
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ error:
+ if (service_status != NULL)
+ Free_Memory_Engine_Status(&service_status, 1);
+
+ str_free(&pCorrelator);
+ str_free(&rSourceUrl);
+ str_free((&data));
+
+ _DEBUG_TRACE(" error : %d\n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR send_msg(char *accType, int transportType, Session ** session, GList * header_info, char *sendMsg, unsigned int sendMsg_length, GList ** recv_header, char **recvMsg, unsigned int *recvMsg_length)
+{
+ _EXTERN_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((accType) == NULL, COMMON_ERR_IS_NULL, "accType is NULL!!");
+ retvm_if((*session) == NULL, COMMON_ERR_IS_NULL, "session is NULL!!");
+ retvm_if((sendMsg) == NULL, COMMON_ERR_IS_NULL, "sendMsg is NULL!!");
+
+ ret = _send_msg(accType, transportType, session, (*session)->target->locURI, header_info, sendMsg, sendMsg_length, recv_header, recvMsg, recvMsg_length);
+ if (ret != DM_OK)
+ goto error;
+
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR recv_msg(Session ** session, char *recvMsg, unsigned int recvMsg_length, ENGINE_ID * service_engine_id, int *isFinish, int isgeneticAlert)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((*session) == NULL, COMMON_ERR_IS_NULL, "session is NULL!!");
+ retvm_if((recvMsg) == NULL, COMMON_ERR_IS_NULL, "recvMsg is NULL!!");
+
+ ret = _recv_msg(session, recvMsg, recvMsg_length, service_engine_id, isFinish, isgeneticAlert);
+ if (ret != DM_OK)
+ goto error;
+
+ _EXTERN_FUNC_EXIT;
+ return DM_OK;
+
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR _send_msg(char *accType, int transportType, Session ** session, char *server_url, GList * header_info, char *sendMsg, unsigned int sendMsg_length, GList ** recv_header, char **recvMsg, unsigned int *recvMsg_length)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_na_result_e res = SYNC_AGENT_NA_SUCCESS;
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((*session) == NULL, COMMON_ERR_IS_NULL, "session is NULL!!");
+ retvm_if((accType) == NULL, COMMON_ERR_IS_NULL, "accType is NULL!!");
+ retvm_if((server_url) == NULL, COMMON_ERR_IS_NULL, "server_url is NULL!!");
+ retvm_if((sendMsg) == NULL, COMMON_ERR_IS_NULL, "sendMsg is NULL!!");
+
+ int net_session_id = 0;
+ bool cancel_flag;
+
+ _DEBUG_TRACE("server url : %s", server_url);
+ //timeout : 30 seconds
+ res = sync_agent_open_connection(transportType, 30, (unsigned int *)(&(net_session_id)));
+
+ _DEBUG_TRACE("res =%d\n", res);
+
+ if (res != SYNC_AGENT_NA_SUCCESS) {
+ ret = COMMON_ERR_INTERNAL_CONNECTION_ERROR;
+ goto error;
+ }
+
+ sync_agent_register_cancel_callback(network_cancel_callback, &(net_session_id));
+
+ //check cancel flag (note that this can be called every where inside processing logic)
+ cancel_flag = sync_agent_check_cancel_flag();
+ if (cancel_flag) {
+ ret = DM_ERR_USER_CANDELLED;
+ sync_agent_unregister_cancel_callback(network_cancel_callback, &(net_session_id));
+ goto returnerror;
+ }
+
+ int err = 0;
+ if ((*session)->reqhmacinfo != NULL) {
+ err = NA_http_header_binder(accType, server_url, (*session)->jsessionid, (*session)->isHMAC, (*session)->reqhmacinfo->username, (*session)->reqhmacinfo->mac, &header_info);
+ } else {
+ err = NA_http_header_binder(accType, server_url, (*session)->jsessionid, (*session)->isHMAC, NULL, NULL, &header_info);
+ }
+
+ if (err != 1) {
+ _DEBUG_TRACE("header binding error : %d", err);
+ ret = DM_ERR_USER_CANDELLED;
+ sync_agent_unregister_cancel_callback(network_cancel_callback, &(net_session_id));
+ goto returnerror;
+ }
+
+ res = sync_agent_send_msg( /*acc_info (id, pw, uri, ...), */
+ header_info, transportType, sendMsg, sendMsg_length, recv_header, (unsigned char **)recvMsg, recvMsg_length, SYNC_AGENT_NA_SEND_TYPE_SEND_N_RECEIVE, net_session_id);
+ _DEBUG_TRACE(" res =%d\n", res);
+
+ sync_agent_unregister_cancel_callback(network_cancel_callback, &(net_session_id));
+ if (res != SYNC_AGENT_NA_SUCCESS) {
+ ret = COMMON_ERR_INTERNAL_CONNECTION_ERROR;
+ goto returnerror;
+ } else {
+ cancel_flag = sync_agent_check_cancel_flag();
+ if (cancel_flag) {
+ ret = DM_ERR_USER_CANDELLED;
+ goto returnerror;
+ }
+ }
+
+ //_DEBUG_TRACE("recieve http header : %s ", (*recv_header));
+
+ _DEBUG_TRACE(" CKECK JSESSION\n");
+ char *temp_jsessionid = NULL;
+ char *real_jsessionid = NULL;
+ char *real_other_cookie = NULL;
+ res = sync_agent_get_header_info(1, (*recv_header), "Set-Cookie", &temp_jsessionid);
+ if (res == SYNC_AGENT_NA_SUCCESS) {
+ ret = add_jsession_in_httpheader(*recv_header, temp_jsessionid, &real_jsessionid, &real_other_cookie);
+ if (ret == DM_OK) {
+ if (real_jsessionid != NULL && (*session)->jsessionid != NULL) {
+ if (strcmp((*session)->jsessionid, real_jsessionid) != 0) {
+ str_free(&((*session)->jsessionid));
+ (*session)->jsessionid = strdup(real_jsessionid);
+ } else {
+ str_free(&real_jsessionid);
+ }
+ } else {
+ (*session)->jsessionid = strdup(real_jsessionid);
+ }
+
+ _DEBUG_TRACE("-------------------------------------------------------------------------------------------------------------------------------------------------");
+ _DEBUG_TRACE("jsession id = %s\n", (*session)->jsessionid);
+ _DEBUG_TRACE("-------------------------------------------------------------------------------------------------------------------------------------------------");
+ }
+ ret = DM_OK;
+ }
+
+ char *temp_hmac = NULL;
+ res = sync_agent_get_header_info(1, (*recv_header), HTTP_X_SYNCML_HMAC, &temp_hmac);
+ if (res == SYNC_AGENT_NA_SUCCESS) {
+ if (temp_hmac != NULL) {
+ ret = add_response_hmacinfo(session, temp_hmac);
+ if (ret != DM_OK) {
+ res = sync_agent_close_connection(transportType, net_session_id);
+ _DEBUG_TRACE(" %d res =%d\n", __LINE__, res);
+ goto returnerror;
+ }
+ }
+ }
+
+ res = sync_agent_close_connection(transportType, net_session_id);
+
+ _DEBUG_TRACE("res =%d\n", res);
+ if (res != SYNC_AGENT_NA_SUCCESS) {
+ ret = COMMON_ERR_INTERNAL_CONNECTION_ERROR;
+ goto returnerror;
+ }
+
+ if (sendMsg != NULL)
+ free(sendMsg);
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ returnerror:
+ _DEBUG_TRACE(" returnerror = %d\n", ret);
+
+ res = sync_agent_close_connection(transportType, net_session_id);
+ _DEBUG_TRACE(" %d res =%d\n", __LINE__, res);
+ if (res != SYNC_AGENT_NA_SUCCESS) {
+ ret = COMMON_ERR_INTERNAL_CONNECTION_ERROR;
+ goto error;
+ }
+
+ if (sendMsg != NULL)
+ free(sendMsg);
+
+ _INNER_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_TRACE(" error = %d\n", ret);
+
+ if (sendMsg != NULL)
+ free(sendMsg);
+
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static DM_ERROR _recv_msg(Session ** session, char *recvMsg, unsigned int recvMsg_length, ENGINE_ID * service_engine_id, int *isFinish, int isgeneticAlert)
+{
+
+ _INNER_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((*session) == NULL, COMMON_ERR_IS_NULL, "session is NULL!!");
+ retvm_if((recvMsg) == NULL, COMMON_ERR_IS_NULL, "recvMsg is NULL!!");
+
+ reset_cmdid_session((*session));
+
+ SyncML *pSyncML = (SyncML *) calloc(1, sizeof(SyncML));
+ if (pSyncML == NULL) {
+ _DEBUG_TRACE("alloc fail");
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+ char *xml = NULL;
+ unsigned int xml_len = 0;
+ ret = reverse_syncml_objectbinder(&pSyncML, recvMsg, recvMsg_length, &xml, &xml_len);
+ if (ret != DM_OK)
+ goto error;
+
+ /* check receive msg */
+ ret = receive_header((*session), pSyncML->hdr);
+ if (ret != DM_OK)
+ goto error;
+
+ ret = receive_statuses((*session), pSyncML->status);
+ if (ret != DM_OK) {
+ goto error;
+ }
+
+ /* check that pending list is empty */
+ GList *o = NULL;
+ for (o = (*session)->pendingStatus; o != NULL; o = g_list_next(o)) {
+ PendingStatus *pending = o->data;
+ _DEBUG_TRACE(" in pendingStatus List msgID : %d, cmdID : %d\n", pending->msgID, pending->cmdID);
+ }
+
+ ret = receive_cmd((*session), pSyncML->commands);
+ if (ret != DM_OK)
+ goto error;
+
+ /*service engine */
+ if ((*session)->service_engine_id != NO_SERVICE_ENGINE) {
+ *service_engine_id = (*session)->service_engine_id;
+ }
+
+ if (pSyncML->final != 0) {
+ (*session)->isSendingfinal = 0;
+ (*session)->isReceivingFinal = 1;
+ } else {
+ (*session)->isReceivingFinal = 0;
+ }
+
+ _DEBUG_TRACE("receive final : %d , isgeneticAlert : %d ", (*session)->isReceivingFinal, isgeneticAlert);
+
+ if (*session != NULL && (*session)->isReceivingFinal != 0 && ((*session)->status != NULL && g_list_length((*session)->status) == 1 && (*session)->resultsCommand == NULL && isgeneticAlert == 0)) {
+ (*isFinish) = 1;
+ _DEBUG_TRACE("---------------------------------------------------------------------------recv msg end------------------------------------------------------------------------\n");
+ _DEBUG_TRACE("---------------------------------------------------------------------------free session------------------------------------------------------------------------\n");
+ free_session((*session));
+ *session = NULL;
+ } else {
+ _DEBUG_TRACE("not final");
+ }
+
+ if (recvMsg != NULL)
+ free(recvMsg);
+ if (pSyncML != NULL)
+ free_syncml(pSyncML);
+
+ _INNER_FUNC_ENTER;
+ return ret;
+
+ error:
+ _DEBUG_TRACE(" error : %d\n", ret);
+ if (recvMsg != NULL)
+ free(recvMsg);
+ if (pSyncML != NULL)
+ free_syncml(pSyncML);
+
+ _INNER_FUNC_ENTER;
+ return ret;
+
+}
+
+DM_ERROR setup_phase(int transportType, Session ** session, char *pServer_id, char *pSession_id, int session_type, ENGINE_ID * service_engine_id, int *isFinish, int isgenericAlert)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ retvm_if((pServer_id) == NULL, COMMON_ERR_IS_NULL, "pServer_id is NULL!!");
+
+ /*generate setupPhase Msg */
+ char *msg = NULL;
+ unsigned int msg_size = 0;
+
+ /*exchange Msg */
+ char *recv_msg = NULL;
+ int recv_msg_size = 0;
+
+ GList *recv_header = 0;
+ GList *list = NULL;
+ int count = 0;
+
+ while (count++ != MAX_SESSION_COUNT) {
+ //when errortype is ERROR_AUTH_REQUIRED try request using res_chal just one more time
+ //it can be only happend when server required MD5 authentication(we send basic authentication every time by default)
+ msg = NULL;
+ msg_size = 0;
+ ret = _generate_setupphase_msg(session, pServer_id, pSession_id, session_type, &msg, &msg_size);
+ if (ret != DM_OK)
+ goto error;
+
+ file_count++;
+ char file_name[1000];
+ /*debuging */
+ snprintf(file_name, (int)sizeof(file_name), "/opt/data/oma-dm-cfg/packet/wbxml_send_msg_%d.wbxml", file_count);
+ _DEBUG_INFO("file name : %s", file_name);
+ sync_agent_write_whole_file(file_name, msg, msg_size, true);
+
+ list = NULL;
+ recv_header = NULL;
+ ret = _send_msg("OMA_DM", 1, session, (*session)->target->locURI, list, msg, msg_size, &recv_header, &recv_msg, (unsigned int *)(&recv_msg_size));
+ if (ret != DM_OK)
+ goto error;
+ /*debuging */
+ snprintf(file_name, (int)sizeof(file_name), "/opt/data/oma-dm-cfg/packet/wbxml_receivce_msg_%d.wbxml", file_count);
+ _DEBUG_INFO("file name : %s", file_name);
+ sync_agent_write_whole_file(file_name, recv_msg, recv_msg_size, true);
+
+ ret = _recv_msg(session, recv_msg, recv_msg_size, service_engine_id, isFinish, isgenericAlert);
+ if (ret != DM_ERR_UNAUTHORIZED && ret != DM_ERR_AUTHENTICATION_REQUIRED) {
+ _DEBUG_INFO(" authentication : %d\n ", ret);
+ break;
+ }
+
+ _DEBUG_INFO("revceive end ======================");
+
+ }
+
+ if (ret != DM_OK || (*session != NULL && (*session)->status != NULL && (g_list_length((*session)->status) == 1 && (*session)->resultsCommand == NULL && (*session)->alertCommand == NULL && isgenericAlert == 0))) {
+ *isFinish = 1;
+ _DEBUG_INFO("---------------------------------------------------------------------------recv msg end------------------------------------------------------------------------\n");
+ _DEBUG_INFO("---------------------------------------------------------------------------free session------------------------------------------------------------------------\n");
+ free_session((*session));
+ *session = NULL;
+ if (ret != DM_OK)
+ goto error;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO(" end error %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR management_phase(int transportType, Session ** session, char *pSession_id, ENGINE_ID * service_engine_id, int *isFinish)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((*session) == NULL, COMMON_ERR_IS_NULL, "session is NULL!!");
+
+ while ((*isFinish) == 0) {
+
+ /*generate management phase Msg */
+ char *msg = NULL;
+ unsigned int msg_size = 0;
+
+ /*exchange Msg */
+ char *recvMsg = NULL;
+ unsigned int recvMsg_size = 0;
+ GList *recv_header = 0;
+ GList *list = NULL;
+
+ ret = _generate_management_msg(session, &msg, &msg_size);
+ if (ret != DM_OK)
+ goto error;
+ /*for debuging */
+ file_count++;
+ char file_name[1000];
+ snprintf(file_name, (int)sizeof(file_name), "/opt/data/oma-dm-cfg/packet/wbxml_management_send_msg_%d.wbxml", file_count);
+ _DEBUG_INFO("file name : %s", file_name);
+ sync_agent_write_whole_file(file_name, msg, msg_size, true);
+
+ ret = send_msg("OMA_DM", 1, session, list, msg, msg_size, &recv_header, &recvMsg, &recvMsg_size);
+ if (ret != DM_OK)
+ goto error;
+
+ /*for debuging */
+ snprintf(file_name, (int)sizeof(file_name), "/opt/data/oma-dm-cfg/packet/wbxml_management_receivce_msg_%d.wbxml", file_count);
+ _DEBUG_INFO("file name : %s", file_name);
+ sync_agent_write_whole_file(file_name, recvMsg, recvMsg_size, true);
+
+ ret = recv_msg(session, recvMsg, recvMsg_size, service_engine_id, isFinish, 0);
+ if (ret != DM_OK)
+ goto error;
+
+ _DEBUG_INFO(" end : %d \n", ret);
+
+ }
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO(" error : %d end \n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR generic_alert(int transportType, Session ** session, char *pServer_id, char *pSession_id, int *isFinish, int isgeneticAlert, ENGINE_ID service_engine_id, int result)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ /*generate setupPhase Msg */
+ char *msg = NULL;
+ unsigned int msg_size = 0;
+
+ /*exchange Msg */
+ GList *list = NULL;
+ char *recvMsg = NULL;
+ unsigned int recvMsg_size = 0;
+ GList *recv_header = 0;
+
+ int count = 0;
+ while (count++ != MAX_SESSION_COUNT) {
+
+ msg = NULL;
+ msg_size = 0;
+ ret = _generate_generic_alert(session, pServer_id, pSession_id, &msg, (int *)(&msg_size), service_engine_id, result);
+ if (ret != DM_OK)
+ goto error;
+
+ file_count++;
+ char file_name[1000];
+
+ snprintf(file_name, (int)sizeof(file_name), "/opt/data/oma-dm-cfg/packet/wbxml_generic_send_msg_%d.wbxml", file_count);
+ _DEBUG_INFO("file name : %s", file_name);
+ sync_agent_write_whole_file(file_name, msg, msg_size, true);
+
+ list = NULL;
+ recv_header = NULL;
+ ret = send_msg("OMA_DM", 1, session, list, msg, msg_size, &recv_header, &recvMsg, &recvMsg_size);
+ if (ret != DM_OK)
+ goto error;
+
+ snprintf(file_name, (int)sizeof(file_name), "/opt/data/oma-dm-cfg/packet/wbxml_generic_receivce_msg_%d.wbxml", file_count);
+ _DEBUG_INFO("file name : %s", file_name);
+ sync_agent_write_whole_file(file_name, recvMsg, recvMsg_size, true);
+
+ ret = recv_msg(session, recvMsg, recvMsg_size, &service_engine_id, isFinish, isgeneticAlert);
+ _DEBUG_INFO(" Recv_Msg : %d count : %d \n ", ret, count);
+
+ if (ret != DM_ERR_UNAUTHORIZED && ret != DM_ERR_AUTHENTICATION_REQUIRED) {
+ _DEBUG_INFO(" generic alert authentication : %d\n ", ret);
+ break;
+ }
+ }
+
+ _DEBUG_INFO(" end : %d \n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO(" error : %d end \n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
diff --git a/src/agent/serviceadapter/networkbinder/na_binder.c b/src/agent/serviceadapter/networkbinder/na_binder.c
new file mode 100644
index 0000000..e3cad3e
--- /dev/null
+++ b/src/agent/serviceadapter/networkbinder/na_binder.c
@@ -0,0 +1,213 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "serviceadapter/networkbinder/na_binder.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_NA"
+#endif
+
+int NA_http_header_binder(char *accType, char *loc_uri, char *sessionid, int isHMAC, char *username, char *mac, GList ** list)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((accType) == NULL, COMMON_ERR_IS_NULL, "accType is NULL!!");
+ retvm_if((loc_uri) == NULL, COMMON_ERR_IS_NULL, "loc_uri is NULL!!");
+
+ if (strcmp(accType, "OMA_DM") == 0) {
+ _DEBUG_INFO(" header info start\n");
+ sync_agent_na_common_header_info_s *method = (sync_agent_na_common_header_info_s *) calloc(1, sizeof(sync_agent_na_common_header_info_s));
+ if (method == NULL) {
+ _DEBUG_INFO("alloc error");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ method->key = "method";
+ method->value = "post";
+ *list = g_list_append(*list, method);
+ _DEBUG_INFO(" post method\n");
+
+ sync_agent_na_common_header_info_s *uri = (sync_agent_na_common_header_info_s *) calloc(1, sizeof(sync_agent_na_common_header_info_s));
+ if (uri == NULL) {
+ _DEBUG_INFO("alloc error");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ uri->key = "uri";
+ uri->value = loc_uri;
+ *list = g_list_append(*list, uri);
+ _DEBUG_INFO(" uri\n");
+/*
+ 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));
+ 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);
+ _DEBUG_INFO( " \n");
+*/
+ sync_agent_na_common_header_info_s *connection = (sync_agent_na_common_header_info_s *) calloc(1, sizeof(sync_agent_na_common_header_info_s));
+ if (connection == NULL) {
+ _DEBUG_INFO("alloc error");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ connection->key = "Connection";
+ connection->value = "Keep-Alive";
+ *list = g_list_append(*list, connection);
+ _DEBUG_INFO(" connection\n");
+
+ sync_agent_na_common_header_info_s *useragent = (sync_agent_na_common_header_info_s *) calloc(1, sizeof(sync_agent_na_common_header_info_s));
+ if (useragent == NULL) {
+ _DEBUG_INFO("alloc error");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ useragent->key = "User-Agent";
+ useragent->value = "Samsung electronics GT-I9500 SyncML_DM Client";
+ *list = g_list_append(*list, useragent);
+ _DEBUG_INFO(" user agent\n");
+
+ sync_agent_na_common_header_info_s *accept = (sync_agent_na_common_header_info_s *) calloc(1, sizeof(sync_agent_na_common_header_info_s));
+ if (accept == NULL) {
+ _DEBUG_INFO("alloc error");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ accept->key = "Accept";
+ accept->value = "application/vnd.syncml.dm+wbxml";
+ *list = g_list_append(*list, accept);
+ _DEBUG_INFO(" accept\n");
+
+/* 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));
+ 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);
+ _DEBUG_INFO( " \n");*/
+
+ sync_agent_na_common_header_info_s *accept_charset = (sync_agent_na_common_header_info_s *) calloc(1, sizeof(sync_agent_na_common_header_info_s));
+ if (accept_charset == NULL) {
+ _DEBUG_INFO("alloc error");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ accept_charset->key = "Accept-Charset";
+ accept_charset->value = "UTF-8";
+ *list = g_list_append(*list, accept_charset);
+ _DEBUG_INFO(" accept charset\n");
+
+ sync_agent_na_common_header_info_s *content_type = (sync_agent_na_common_header_info_s *) calloc(1, sizeof(sync_agent_na_common_header_info_s));
+ if (content_type == NULL) {
+ _DEBUG_INFO("alloc error");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ content_type->key = "Content-Type";
+ content_type->value = "application/vnd.syncml.dm+wbxml";
+ *list = g_list_append(*list, content_type);
+ _DEBUG_INFO(" content type\n");
+
+ if (sessionid != NULL) {
+ _DEBUG_INFO(" jsessionid : %s\n", sessionid);
+ sync_agent_na_common_header_info_s *cookie = (sync_agent_na_common_header_info_s *) calloc(1, sizeof(sync_agent_na_common_header_info_s));
+ if (cookie == NULL) {
+ _DEBUG_INFO("alloc error");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ cookie->key = HTTP_COOKIE;
+ cookie->value = sessionid;
+ *list = g_list_append(*list, cookie);
+ _DEBUG_INFO(" cookie : %s\n", cookie->value);
+ }
+
+ if (isHMAC == 1) {
+ /* x-syncml-hmac: algorithm=MD5, username="156354238", mac=SF2dMGut4v2Mpmsrs1ydTw== */
+ _DEBUG_INFO(" x-syncml-hmac : %d\n", isHMAC);
+ sync_agent_na_common_header_info_s *hmac = (sync_agent_na_common_header_info_s *) calloc(1, sizeof(sync_agent_na_common_header_info_s));
+ if (hmac == NULL) {
+ _DEBUG_INFO("alloc error");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ hmac->key = HTTP_X_SYNCML_HMAC;
+ if (username != NULL) {
+ hmac->value = g_strdup_printf("algorithm=MD5, username=\"%s\", mac=%s", username, mac);
+ _DEBUG_INFO(" hmac = %s : %s\n", hmac->key, hmac->value);
+ }
+ *list = g_list_append(*list, hmac);
+ }
+ }
+
+ GList *iter = NULL;
+ for (iter = *list; iter != NULL; iter = g_list_next(iter)) {
+ fputs("[NA_Header_Binder] key : ", stdout);
+ if (fputs(((sync_agent_na_common_header_info_s *) (iter->data))->key, stdout) == EOF) {
+ _DEBUG_INFO("debuging test error");
+ break;
+ }
+ fputs(", value : ", stdout);
+ if (fputs(((sync_agent_na_common_header_info_s *) (iter->data))->value, stdout) == EOF) {
+ _DEBUG_INFO("debuging test error");
+ break;
+ }
+ fputs("\n", stdout);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return 1;
+}
+
+int add_jsession_in_httpheader(GList * recv_header, char *temp_jsessionid, char **real_jsessionid, char **real_other_cookie)
+{
+ _EXTERN_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+ char *start_jessionid_msg = NULL;
+ _DEBUG_INFO(" set cookie is : %s \n", temp_jsessionid);
+
+ /*temp_jsessionid = "JSESSIONID=D15C621FD39535094F1B000307D5D520.sdm1; Path=/v1/sdm; Secure" */
+ if (temp_jsessionid != NULL) {
+
+ _DEBUG_INFO("-------------------------------------------------------------------------------------------------------------------------------------------------");
+ _DEBUG_INFO("cookie is = %s\n", temp_jsessionid);
+ _DEBUG_INFO("-------------------------------------------------------------------------------------------------------------------------------------------------");
+
+ start_jessionid_msg = strstr(temp_jsessionid, "JSESSIONID");
+ if (start_jessionid_msg != NULL) {
+ _DEBUG_INFO(" set cookie is : %s \n", start_jessionid_msg);
+ (*real_jsessionid) = strdup(start_jessionid_msg);
+
+ _DEBUG_INFO(" set cookie is : %s \n", (*real_jsessionid));
+ } else {
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ }
+
+ } else {
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
diff --git a/src/agent/serviceadapter/protocolbinder/syncml_protocol_binder.c b/src/agent/serviceadapter/protocolbinder/syncml_protocol_binder.c
new file mode 100755
index 0000000..91e5217
--- /dev/null
+++ b/src/agent/serviceadapter/protocolbinder/syncml_protocol_binder.c
@@ -0,0 +1,3062 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <glib.h>
+#include <assert.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "serviceadapter/protocolbinder/syncml_def.h"
+#include "serviceadapter/protocolbinder/syncml_protocol_binder.h"
+#include "serviceadapter/sa_command_internal.h"
+#include "serviceadapter/sa_command.h"
+#include "serviceadapter/sa_elements_internal.h"
+#include "serviceadapter/sa_elements.h"
+#include "serviceadapter/sa_define.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_BINDER"
+#endif
+
+#define SYNC_AGENT_INIT_ESTIMATE_DOC_SIZE 10 /* TODO : remove */
+
+static ProtocolVersion __get_oma_dm_protocol_version(char *verdtd);
+static Location *__get_location(WBXMLTreeNode * node);
+static Cred *__get_cred(WBXMLTreeNode * node);
+static Chal *__get_chal(WBXMLTreeNode * node);
+
+static sync_agent_pb_error_e __append_location_to_wbxml_node(Location * pLocation, sync_agent_pb_protocol_binder_info_s * pBinder, WBXMLTreeNode * parent_node);
+static sync_agent_pb_error_e __append_cred_to_wbxml_node(Cred * pCred, sync_agent_pb_protocol_binder_info_s * pBinder, WBXMLTreeNode * parent_node);
+static sync_agent_pb_error_e __append_chal_to_wbxml_node(Chal * pChal, sync_agent_pb_protocol_binder_info_s * pBinder, WBXMLTreeNode * parent_node);
+
+static sync_agent_pb_error_e _syncml_binder_syncml_start_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node);
+static sync_agent_pb_error_e _syncml_binder_header_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node);
+static sync_agent_pb_error_e _syncml_binder_final_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node);
+static sync_agent_pb_error_e _syncml_binder_body_start_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node);
+static sync_agent_pb_error_e _syncml_binder_status_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node);
+static sync_agent_pb_error_e _syncml_binder_alert_command_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node);
+static sync_agent_pb_error_e _syncml_binder_results_command_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node);
+static sync_agent_pb_error_e _syncml_binder_replace_command_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node);
+
+static sync_agent_pb_error_e _syncml_binder_header_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
+static sync_agent_pb_error_e _syncml_binder_results_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
+static sync_agent_pb_error_e _syncml_binder_get_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
+static sync_agent_pb_error_e _syncml_binder_alert_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
+static sync_agent_pb_error_e _syncml_binder_add_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
+static sync_agent_pb_error_e _syncml_binder_replace_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
+static sync_agent_pb_error_e _syncml_binder_delete_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
+static sync_agent_pb_error_e _syncml_binder_atomic_end_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
+static sync_agent_pb_error_e _syncml_binder_atomic_start_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
+static sync_agent_pb_error_e _syncml_binder_sequence_end_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
+static sync_agent_pb_error_e _syncml_binder_sequence_start_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
+static sync_agent_pb_error_e _syncml_binder_exec_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
+static sync_agent_pb_error_e _syncml_binder_final_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
+static sync_agent_pb_error_e _syncml_binder_status_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
+static sync_agent_pb_error_e _syncml_binder_copy_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent);
+
+const sync_agent_pb_function_info_s oma_dm_binder_function_info[] = {
+ {PE_SYNCML_START, "SyncML", _syncml_binder_syncml_start_converter_function, NULL, false},
+ {PE_SYNCML_END, "/SyncML", NULL, NULL, false},
+ {PE_HEADER, "SyncHdr", _syncml_binder_header_converter_function, _syncml_binder_header_reverse_converter_function, true},
+ {PE_BODY_START, "SyncBody", _syncml_binder_body_start_converter_function, NULL, false},
+ {PE_BODY_END, "/SyncBody", NULL, NULL, false},
+ {PE_FINAL, "Final", _syncml_binder_final_converter_function, _syncml_binder_final_reverse_converter_function, true},
+ {PE_ALERT, "Alert", _syncml_binder_alert_command_converter_function, _syncml_binder_alert_command_reverse_converter_function, true},
+ {PE_STATUS, "Status", _syncml_binder_status_converter_function, _syncml_binder_status_reverse_converter_function, true},
+ {PE_RESULTS_START, "Results", _syncml_binder_results_command_converter_function, _syncml_binder_results_command_reverse_converter_function, false},
+ {PE_RESULTS_END, "/Results", NULL, NULL, false},
+ {PE_GET, "Get", NULL, _syncml_binder_get_command_reverse_converter_function, true},
+ {PE_ADD, "Add", NULL, _syncml_binder_add_command_reverse_converter_function, true},
+ {PE_REPLACE, "Replace", _syncml_binder_replace_command_converter_function, _syncml_binder_replace_command_reverse_converter_function, true},
+ {PE_DELETE, "Delete", NULL, _syncml_binder_delete_command_reverse_converter_function, true},
+ {PE_EXEC, "Exec", NULL, _syncml_binder_exec_command_reverse_converter_function, true},
+ {PE_SEQUENCE_START, "Sequence", NULL, _syncml_binder_sequence_start_command_reverse_converter_function, false},
+ {PE_SEQUENCE_END, "/Sequence", NULL, _syncml_binder_sequence_end_command_reverse_converter_function, false},
+ {PE_ATOMIC_START, "Atomic", NULL, _syncml_binder_atomic_start_command_reverse_converter_function, false},
+ {PE_ATOMIC_END, "/Atomic", NULL, _syncml_binder_atomic_end_command_reverse_converter_function, false},
+ {PE_COPY, "Copy", NULL, _syncml_binder_copy_command_reverse_converter_function, true}
+};
+
+static sync_agent_pb_error_e __append_location_to_wbxml_node(Location * pLocation, sync_agent_pb_protocol_binder_info_s * pBinder, WBXMLTreeNode * parent_node)
+{
+ _INNER_FUNC_ENTER;
+ _DEBUG_VERBOSE("start");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ if (pLocation->locURI != NULL) {
+ WBXMLTreeNode *LocURI = sync_agent_add_child_text_node(pBinder, parent_node, ELEMENT_LOCURI, pLocation->locURI, strlen(pLocation->locURI));
+ if (LocURI == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ } else {
+ /* error case */
+ }
+
+ if (pLocation->locName != NULL) {
+ WBXMLTreeNode *locName = sync_agent_add_child_text_node(pBinder, parent_node, ELEMENT_LOCNAME, pLocation->locName, strlen(pLocation->locName));
+ if (locName == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+ error:
+ _DEBUG_VERBOSE("error : %d", err);
+ _INNER_FUNC_EXIT;
+ return err;
+
+}
+
+static sync_agent_pb_error_e __append_cred_to_wbxml_node(Cred * pCred, sync_agent_pb_protocol_binder_info_s * pBinder, WBXMLTreeNode * parent_node)
+{
+ _INNER_FUNC_ENTER;
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ retvm_if((pCred) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pCred is NULL!!");
+ retvm_if((pBinder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pBinder is NULL!!");
+
+ /* check validity */
+ WBXMLTreeNode *cred_node = sync_agent_add_child_node(pBinder, 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(pBinder, cred_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = NULL;
+
+ switch (pCred->type) {
+ case AUTH_TYPE_BASIC:
+
+ if (pCred->format == FORMAT_TYPE_BASE64) {
+ WBXMLTreeNode *format_node = sync_agent_add_child_text_node(pBinder, 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(pBinder, 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 (pCred->data != NULL) {
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(pBinder, cred_node, ELEMENT_DATA, pCred->data, strlen(pCred->data));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ break;
+ case AUTH_TYPE_MD5:
+ {
+ if (pCred->format == FORMAT_TYPE_BASE64) {
+ WBXMLTreeNode *format_node = sync_agent_add_child_text_node(pBinder, 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(pBinder, 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 (pCred->data != NULL) {
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(pBinder, cred_node, ELEMENT_DATA, pCred->data, strlen(pCred->data));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ break;
+ case AUTH_TYPE_HMAC:
+ {
+ /*do not use cred element */
+ }
+ break;
+ default:
+ break;
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ _DEBUG_VERBOSE("error : %d", err);
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e __append_chal_to_wbxml_node(Chal * pChal, sync_agent_pb_protocol_binder_info_s * pBinder, WBXMLTreeNode * parent_node)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ retvm_if((pChal) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pChal is NULL!!");
+ retvm_if((pBinder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pBinder is NULL!!");
+
+ /* check validity */
+ WBXMLTreeNode *chal_node = sync_agent_add_child_node(pBinder, parent_node, ELEMENT_CHAL);
+ if (chal_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(pBinder, chal_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *type_node = NULL;
+
+ switch (pChal->type) {
+ case AUTH_TYPE_BASIC:
+
+ if (pChal->format == FORMAT_TYPE_BASE64) {
+ WBXMLTreeNode *format_node = sync_agent_add_child_text_node(pBinder, 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(pBinder, 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;
+ }
+
+ break;
+ case AUTH_TYPE_MD5:
+ {
+ if (pChal->format == FORMAT_TYPE_BASE64) {
+ WBXMLTreeNode *format_node = sync_agent_add_child_text_node(pBinder, 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(pBinder, 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;
+ }
+
+ WBXMLTreeNode *nextnonce_node = sync_agent_add_child_text_node(pBinder, meta_node, ELEMENT_NEXTNONCE, pChal->nonce_plain, strlen(pChal->nonce_plain));
+ if (nextnonce_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ break;
+ case AUTH_TYPE_HMAC:
+ {
+ if (pChal->format == FORMAT_TYPE_BASE64) {
+ WBXMLTreeNode *format_node = sync_agent_add_child_text_node(pBinder, 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(pBinder, meta_node, ELEMENT_TYPE, ELEMENT_AUTH_HMAC, strlen(ELEMENT_AUTH_HMAC));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *nextnonce_node = sync_agent_add_child_text_node(pBinder, meta_node, ELEMENT_NEXTNONCE, pChal->nonce_plain, strlen(pChal->nonce_plain));
+ if (nextnonce_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ _DEBUG_VERBOSE("error : %d", err);
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_syncml_start_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pBinder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pBinder is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ WBXMLTreeNode *syncml_node = sync_agent_create_node(pBinder, ELEMENT_SYNCML);
+ if (syncml_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ *ppWbxml_dom_node = syncml_node;
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ sync_agent_destroy_wbxml_node(syncml_node);
+ _DEBUG_TRACE("error :%d", err);
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_header_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pBinder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pBinder is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ SyncHdr *pSyncHdr = (SyncHdr *) pContent;
+
+ /* add SyncHdr, VerDTD, VerProto node */
+ WBXMLTreeNode *synchdr_node = NULL;
+ synchdr_node = sync_agent_create_node(pBinder, 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_VERDTD_10;
+ verProto_data = ELEMENT_VERPROTO_10;
+ } else if (pSyncHdr->version == VERSION_11) {
+ verDTD_data = ELEMENT_VERDTD_11;
+ verProto_data = ELEMENT_VERPROTO_11;
+ } else if (pSyncHdr->version == VERSION_12) {
+ verDTD_data = ELEMENT_VERDTD_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(pBinder, 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(pBinder, 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->sessionID != NULL) {
+ sessionID_node = sync_agent_add_child_text_node(pBinder, synchdr_node, ELEMENT_SESSIONID, pSyncHdr->sessionID, strlen(pSyncHdr->sessionID));
+ } else {
+ sessionID_node = sync_agent_add_child_node(pBinder, 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->messageID);
+ if (msgID_data == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ WBXMLTreeNode *msgID_node = sync_agent_add_child_text_node(pBinder, synchdr_node, ELEMENT_MSGID, msgID_data, strlen(msgID_data));
+ str_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(pBinder, 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, pBinder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+
+ WBXMLTreeNode *source_node = sync_agent_add_child_node(pBinder, 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, pBinder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+
+ if (pSyncHdr->responseURI) {
+ WBXMLTreeNode *respuri_node = sync_agent_add_child_text_node(pBinder, synchdr_node, ELEMENT_RESPURI, pSyncHdr->responseURI, strlen(pSyncHdr->responseURI));
+ if (respuri_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pSyncHdr->cred != NULL) {
+ err = __append_cred_to_wbxml_node(pSyncHdr->cred, pBinder, synchdr_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+ }
+
+ char *meta = ELEMENT_META;
+ if (pSyncHdr->maxmsgsize != 0 || pSyncHdr->maxobjsize != 0) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(pBinder, synchdr_node, meta);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ unsigned int maxmsgsize = pSyncHdr->maxmsgsize;
+ unsigned int maxobjsize = pSyncHdr->maxobjsize;
+
+ 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(pBinder, meta_node, ELEMENT_MAXMSGSIZE, str_maxmsgsize, strlen(str_maxmsgsize));
+ str_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 *maxmsgsize_node = sync_agent_add_child_text_node(pBinder, meta_node, ELEMENT_MAXOBJSIZE, str_maxobjsize, strlen(str_maxobjsize));
+ str_free(&str_maxobjsize);
+ if (maxmsgsize_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ *ppWbxml_dom_node = synchdr_node;
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ sync_agent_destroy_wbxml_node(synchdr_node);
+ _DEBUG_TRACE("error :%d", err);
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_final_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pBinder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pBinder is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ WBXMLTreeNode *final_node = sync_agent_create_node(pBinder, ELEMENT_FINAL);
+ if (final_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ *ppWbxml_dom_node = final_node;
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ sync_agent_destroy_wbxml_node(final_node);
+ _DEBUG_TRACE("error :%d", err);
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_body_start_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pBinder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pBinder is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ WBXMLTreeNode *syncbody_node = sync_agent_create_node(pBinder, ELEMENT_SYNCBODY);
+ if (syncbody_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ *ppWbxml_dom_node = syncbody_node;
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ sync_agent_destroy_wbxml_node(syncbody_node);
+ _DEBUG_TRACE("error :%d", err);
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_status_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pBinder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pBinder is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ Status *pStatus = (Status *) pContent;
+ assert(pStatus != NULL);
+
+ CommandType type = pStatus->type;
+
+ WBXMLTreeNode *status_node = NULL;
+ status_node = sync_agent_create_node(pBinder, ELEMENT_STATUS);
+ if (status_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ unsigned int cmdID = pStatus->cmdID;
+ char *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(pBinder, status_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ str_free(&str_cmdID);
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ unsigned int msgRef = pStatus->msgRef;
+ char *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(pBinder, status_node, ELEMENT_MSGREF, str_msgRef, strlen(str_msgRef));
+ str_free(&str_msgRef);
+ if (msgref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ unsigned int cmdRef = pStatus->cmdRef;
+ char *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(pBinder, status_node, ELEMENT_CMDREF, str_cmdRef, strlen(str_cmdRef));
+ str_free(&str_cmdRef);
+ if (cmdref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ char *str_command = NULL;
+ switch (type) {
+ case COMMAND_TYPE_ALERT:
+ {
+ str_command = ELEMENT_ALERT;
+ }
+ 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_GET:
+ {
+ str_command = ELEMENT_GET;
+ }
+ break;
+ case COMMAND_TYPE_RESULTS:
+ {
+ str_command = ELEMENT_RESULTS;
+ }
+ break;
+ case COMMAND_TYPE_EXEC:
+ {
+ str_command = ELEMENT_EXEC;
+ }
+ break;
+ case COMMAND_TYPE_SEQUENCE:
+ {
+ str_command = ELEMENT_SEQUENCE;
+ }
+ break;
+ case COMMAND_TYPE_ATOMIC:
+ {
+ str_command = ELEMENT_ATOMIC;
+ }
+ 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(pBinder, 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->targetRef != NULL) {
+ WBXMLTreeNode *targetref_node = sync_agent_add_child_text_node(pBinder, status_node, ELEMENT_TARGETREF, pStatus->targetRef->locURI, strlen(pStatus->targetRef->locURI));
+ if (targetref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ if (pStatus->sourceRef != NULL) {
+ WBXMLTreeNode *sourceref_node = sync_agent_add_child_text_node(pBinder, status_node, ELEMENT_SOURCEREF, pStatus->sourceRef->locURI, strlen(pStatus->sourceRef->locURI));
+ 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, pBinder, status_node);
+ * if(err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+ */
+ }
+
+ if (pStatus->chal != NULL) {
+ err = __append_chal_to_wbxml_node(pStatus->chal, pBinder, status_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+
+ }
+
+ WBXMLTreeNode *data_node = sync_agent_add_child_text_node(pBinder, 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) {
+ GList *Iter = NULL;
+ Item *item = NULL;
+ if (pStatus->items != NULL) {
+ for (Iter = pStatus->items; Iter != NULL; Iter = g_list_next(Iter)) {
+ item = (Iter->data);
+ if (item != NULL) {
+ WBXMLTreeNode *item_node = sync_agent_add_child_node(pBinder, status_node, ELEMENT_ITEM);
+ if (item_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ char *data = NULL;
+ data = item->private.data;
+ if (data != NULL) {
+ WBXMLTreeNode *item_data_node = sync_agent_add_child_text_node(pBinder, item_node, ELEMENT_DATA, data, strlen(data));
+ if (item_data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ *ppWbxml_dom_node = status_node;
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ sync_agent_destroy_wbxml_node(status_node);
+
+ _DEBUG_TRACE("error :%d", err);
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_alert_command_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pBinder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pBinder is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ Command *pCommand = (Command *) pContent;
+ CommandAlertPrivate *pAlert = (CommandAlertPrivate *) (&(pCommand->private));
+ WBXMLTreeNode *alert_node = NULL;
+
+ if (pAlert == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ _DEBUG_TRACE("pAlert is not defined");
+ goto error;
+ }
+
+ if (pAlert->type == ALERT_UNKNOWN) {
+ /* error case */
+ err = SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR;
+ _DEBUG_TRACE("type is unknown");
+ goto error;
+ }
+
+ alert_node = sync_agent_create_node(pBinder, ELEMENT_ALERT);
+ if (alert_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ char *str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(pBinder, alert_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ str_free(&str_cmdID);
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+/* if(pCommand->cred){
+ err = __append_cred_to_wbxml_node(pCommand->cred, pBinder, alert_node);
+ if(err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+ }*/
+
+ char *str_alert_type = g_strdup_printf("%d", 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(pBinder, alert_node, ELEMENT_DATA, str_alert_type, strlen(str_alert_type));
+ str_free(&str_alert_type);
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pAlert->Correlator != NULL) {
+ char *pCorrelator = g_strdup(pAlert->Correlator);
+ if (pCorrelator == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ WBXMLTreeNode *correlator_node = sync_agent_add_child_text_node(pBinder, alert_node, ELEMENT_CORRELATOR, pCorrelator, strlen(pCorrelator));
+ str_free(&pCorrelator);
+ if (correlator_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ GList *Iter = NULL;
+ Item *item = NULL;
+ for (Iter = pAlert->items; Iter != NULL; Iter = g_list_next(Iter)) {
+ item = (Iter->data);
+ WBXMLTreeNode *item_node = sync_agent_add_child_node(pBinder, alert_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(pBinder, 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, pBinder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+ }
+ if (item->target != NULL) {
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(pBinder, 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, pBinder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+ }
+
+ if (item->format != NULL || item->contenttype != NULL) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(pBinder, item_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ if (item->format != NULL) {
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(pBinder, meta_node, ELEMENT_FORMAT, item->format, strlen(item->format));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (item->contenttype != NULL) {
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(pBinder, meta_node, ELEMENT_TYPE, item->contenttype, strlen(item->contenttype));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ if (item->moreData != 0) {
+ if (item->size > 0) {
+ char *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(pBinder, meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
+ str_free(&str_size);
+ if (size_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ }
+ }
+ }
+ }
+
+ if (item->dataType == ITEM_DATA) {
+ if (item->private.data != NULL) {
+ WBXMLTreeNode *data_node = sync_agent_add_child_text_node(pBinder, item_node, ELEMENT_DATA, item->private.data, strlen(item->private.data));
+ //WBXMLTreeNode* data_node = sync_agent_add_child_cdata_node(pBinder, 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->moreData != 0) {
+ WBXMLTreeNode *data_node = sync_agent_add_child_node(pBinder, item_node, ELEMENT_MOREDATA);
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ *ppWbxml_dom_node = alert_node;
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ sync_agent_destroy_wbxml_node(alert_node);
+ _DEBUG_TRACE("error :%d", err);
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_results_command_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pBinder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pBinder is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ Command *pCommand = (Command *) pContent;
+ CommandResultsPrivate *pResults = (CommandResultsPrivate *) (&(pCommand->private));
+ WBXMLTreeNode *results_node = NULL;
+ if (pResults == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ _DEBUG_TRACE("pResults is not defined");
+ goto error;
+ }
+
+ results_node = sync_agent_create_node(pBinder, ELEMENT_RESULTS);
+ if (results_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ char *str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(pBinder, results_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ str_free(&str_cmdID);
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ if (pResults->msgRef != 0) {
+ char *str_msgRef = g_strdup_printf("%u", pResults->msgRef);
+ if (str_msgRef == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ WBXMLTreeNode *msgref_node = sync_agent_add_child_text_node(pBinder, results_node, ELEMENT_MSGREF, str_msgRef, strlen(str_msgRef));
+ str_free(&str_msgRef);
+ if (msgref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ char *str_cmdRef = g_strdup_printf("%u", pResults->cmdRef);
+ if (str_cmdRef == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ WBXMLTreeNode *msgref_node = sync_agent_add_child_text_node(pBinder, results_node, ELEMENT_CMDREF, str_cmdRef, strlen(str_cmdRef));
+ str_free(&str_cmdRef);
+ if (msgref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ /* if(content_type){
+ WBXMLTreeNode * meta_node = sync_agent_add_child_node(pBinder, results_node, ELEMENT_META);
+ sync_agent_add_child_text_node(pBinder, meta_node, ELEMENT_TYPE, content_type, strlen(content_type));
+ } */
+
+ if (pResults->targetRef != NULL) {
+ WBXMLTreeNode *targetref_node = sync_agent_add_child_text_node(pBinder, results_node, ELEMENT_TARGETREF, pResults->targetRef->locURI, strlen(pResults->targetRef->locURI));
+ if (targetref_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+
+ GList *Iter = NULL;
+ Item *item = NULL;
+ for (Iter = pResults->items; Iter != NULL; Iter = g_list_next(Iter)) {
+ item = (Iter->data);
+ WBXMLTreeNode *item_node = sync_agent_add_child_node(pBinder, results_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(pBinder, 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, pBinder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+ }
+ if (item->target != NULL) {
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(pBinder, 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, pBinder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+ }
+
+ if (item->format != NULL || item->contenttype != NULL) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(pBinder, item_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ if (item->format != NULL) {
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(pBinder, meta_node, ELEMENT_FORMAT, item->format, strlen(item->format));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (item->contenttype != NULL) {
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(pBinder, meta_node, ELEMENT_TYPE, item->contenttype, strlen(item->contenttype));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ if (item->moreData != 0) {
+ if (item->size > 0) {
+ char *str_size = g_strdup_printf("%u", item->size);
+ WBXMLTreeNode *size_node = sync_agent_add_child_text_node(pBinder, meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
+ str_free(&str_size);
+ if (size_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+ }
+ if (item->dataType == ITEM_DATA) {
+ if (item->private.data != NULL) {
+ WBXMLTreeNode *data_node = sync_agent_add_child_text_node(pBinder, item_node, ELEMENT_DATA, item->private.data, strlen(item->private.data));
+ //WBXMLTreeNode* data_node = sync_agent_add_child_cdata_node(pBinder, 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->moreData != 0) {
+ WBXMLTreeNode *data_node = sync_agent_add_child_node(pBinder, item_node, ELEMENT_MOREDATA);
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ *ppWbxml_dom_node = results_node;
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ sync_agent_destroy_wbxml_node(results_node);
+ _DEBUG_TRACE("error :%d", err);
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_replace_command_converter_function(sync_agent_pb_protocol_binder_info_s * pBinder, Content_Ptr pContent, WBXMLTreeNode ** ppWbxml_dom_node)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pBinder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pBinder is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ Command *pCommand = (Command *) pContent;
+ CommandChangePrivate *pChange = (CommandChangePrivate *) (&(pCommand->private));
+
+ if (pChange == NULL) {
+ err = SYNC_AGENT_PB_RETURN_NOT_DEFINED;
+ _DEBUG_TRACE("pChange is not defined");
+ _INNER_FUNC_EXIT;
+ return err;
+ }
+
+ WBXMLTreeNode *replace_node = NULL;
+ replace_node = sync_agent_create_node(pBinder, ELEMENT_REPLACE);
+ if (replace_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ char *str_cmdID = g_strdup_printf("%u", pCommand->cmdID);
+ if (str_cmdID == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ WBXMLTreeNode *cmdid_node = sync_agent_add_child_text_node(pBinder, replace_node, ELEMENT_CMDID, str_cmdID, strlen(str_cmdID));
+ str_free(&str_cmdID);
+ if (cmdid_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+
+ GList *Iter = NULL;
+ Item *item = NULL;
+ for (Iter = pChange->items; Iter != NULL; Iter = g_list_next(Iter)) {
+ item = (Iter->data);
+ WBXMLTreeNode *item_node = sync_agent_add_child_node(pBinder, 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(pBinder, 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, pBinder, source_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+ }
+ if (item->target != NULL) {
+ WBXMLTreeNode *target_node = sync_agent_add_child_node(pBinder, 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, pBinder, target_node);
+ if (err != SYNC_AGENT_PB_RETURN_OK)
+ goto error;
+ }
+ if (item->format != NULL || item->contenttype != NULL) {
+ WBXMLTreeNode *meta_node = sync_agent_add_child_node(pBinder, item_node, ELEMENT_META);
+ if (meta_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ if (item->format != NULL) {
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(pBinder, meta_node, ELEMENT_FORMAT, item->format, strlen(item->format));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ if (item->contenttype != NULL) {
+ WBXMLTreeNode *type_node = sync_agent_add_child_text_node(pBinder, meta_node, ELEMENT_TYPE, item->contenttype, strlen(item->contenttype));
+ if (type_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ if (item->moreData != 0) {
+ if (item->size > 0) {
+ char *str_size = g_strdup_printf("%u", item->size);
+ WBXMLTreeNode *size_node = sync_agent_add_child_text_node(pBinder, meta_node, ELEMENT_SIZE, str_size, strlen(str_size));
+ str_free(&str_size);
+ if (size_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+ }
+ }
+ if (item->dataType == ITEM_DATA) {
+ if (item->private.data != NULL) {
+ //WBXMLTreeNode* data_node = sync_agent_add_child_cdata_node(pBinder, item_node, ELEMENT_DATA, item->private.data, strlen(item->private.data));
+ WBXMLTreeNode *data_node = sync_agent_add_child_text_node(pBinder, 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->moreData != 0) {
+ WBXMLTreeNode *data_node = sync_agent_add_child_node(pBinder, item_node, ELEMENT_MOREDATA);
+ if (data_node == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto error;
+ }
+ }
+ }
+
+ *ppWbxml_dom_node = replace_node;
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+ error:
+ sync_agent_destroy_wbxml_node(replace_node);
+ _DEBUG_TRACE("error :%d", err);
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static ProtocolVersion __get_oma_dm_protocol_version(char *verdtd)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((verdtd) == NULL, VERSION_12, "verdtd is NULL!!");
+
+ ProtocolVersion protocol_version = VERSION_UNKNOWN;
+ if (strcmp(verdtd, ELEMENT_VERDTD_12) == 0) {
+ protocol_version = VERSION_12;
+ } else if (strcmp(verdtd, ELEMENT_VERDTD_11) == 0) {
+ protocol_version = VERSION_11;
+ } else if (strcmp(verdtd, ELEMENT_VERDTD_10) == 0) {
+ protocol_version = VERSION_10;
+ }
+
+ _INNER_FUNC_EXIT;
+ return protocol_version;
+}
+
+static Location *__get_location(WBXMLTreeNode * node)
+{
+
+ _INNER_FUNC_ENTER;
+
+ retvm_if((node) == NULL, NULL, "node is NULL!!");
+ DM_ERROR ret = DM_OK;
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+ Location *pLocation = NULL;
+
+ WBXMLTreeNode *child = NULL;
+ const char *child_name = NULL;
+
+ char *locURI = NULL;
+ char *locName = NULL;
+ /* get first child : required LocURI */
+ child = node->children;
+
+ child_name = (const char *)wbxml_tag_get_xml_name(child->name);
+ if (strcmp(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;
+ if (child != NULL) {
+ child_name = (const char *)wbxml_tag_get_xml_name(child->name);
+ if (strcmp(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;
+ }
+ }
+
+ ret = create_location(locURI, locName, &pLocation);
+ if (ret != DM_OK) {
+ goto return_part;
+ }
+
+ _INNER_FUNC_EXIT;
+ return pLocation;
+
+ return_part:
+ _DEBUG_VERBOSE("error : %d", ret);
+ if (pLocation != NULL) {
+ free_location(pLocation);
+ pLocation = NULL;
+ }
+
+ _INNER_FUNC_EXIT;
+ return NULL;
+}
+
+static Cred *__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 *cred = NULL;
+
+ char *data = NULL;
+ char *type = NULL;
+ char *format = NULL;
+
+ WBXMLTreeNode *child = NULL;
+ const char *child_xml_name = NULL;
+ for (child = node->children; child != NULL; child = child->next) {
+ 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_credwithdata(converttoauthtype(type), data);
+ if (cred == NULL) {
+ return NULL;
+ }
+
+ /*all auth type base 64 */
+ set_credformattype(cred, FORMAT_TYPE_BASE64);
+ _DEBUG_VERBOSE("base 64 format");
+
+ _INNER_FUNC_EXIT;
+ return cred;
+
+ return_part:
+ _DEBUG_VERBOSE("error");
+ free_cred(cred);
+
+ _INNER_FUNC_EXIT;
+ return NULL;
+}
+
+static Chal *__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 *chal = (Chal *) calloc(1, sizeof(Chal));
+ if (chal == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ _INNER_FUNC_EXIT;
+ return NULL;
+ }
+ WBXMLTreeNode *chal_child = node->children;
+
+ WBXMLTreeNode *meta_child = NULL;
+ const char *meta_child_xml_name = NULL;
+ for (meta_child = chal_child->children; meta_child != NULL; meta_child = meta_child->next) {
+ 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_VERBOSE("Type = [%s]", type);
+
+ chal->type = converttoauthtype(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_VERBOSE("Format = [%s]", format);
+
+ chal->format = converttoformattype(format);
+ } else if (strcmp(meta_child_xml_name, "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_VERBOSE("NextNonce =[%s] ", nextnonce);
+ if (chal->format == FORMAT_TYPE_BASE64 && chal->type == AUTH_TYPE_BASIC) {
+ chal->nonce_b64 = strdup(nextnonce);
+ } else if (chal->format == FORMAT_TYPE_BASE64 && (chal->type == AUTH_TYPE_MD5 || chal->type == AUTH_TYPE_HMAC)) {
+ chal->nonce_plain = (char *)calloc(1, nonce_len + 1);
+ if (chal->nonce_plain == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ memcpy(chal->nonce_plain, nextnonce, nonce_len);
+ chal->nonce_plain[nonce_len] = '\0';
+ }
+ chal->nonce_length = nonce_len;
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+ return chal;
+
+ return_part:
+ _DEBUG_VERBOSE("error ");
+ free_chal(chal);
+ _INNER_FUNC_EXIT;
+ return NULL;
+}
+
+static sync_agent_pb_error_e _syncml_binder_header_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((wbxml_dom_node) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "wbxml_dom_node is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ SyncHdr *pSyncHdr = (SyncHdr *) calloc(1, sizeof(SyncHdr));
+ if (pSyncHdr == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_TRACE("pSyncHdr is null");
+ goto return_part;
+ }
+
+ WBXMLTreeNode *child = NULL;
+ const char *child_xml_name = NULL;
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ 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_dm_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->sessionID = strdup(sessionID);
+ } else {
+ pSyncHdr->sessionID = 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->messageID = atoi(msgID);
+ } else if (strcmp(child_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = __get_location(child);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pTargetLocation != NULL)
+ pSyncHdr->target = pTargetLocation;
+ } else if (strcmp(child_xml_name, ELEMENT_SOURCE) == 0) {
+ Location *pSourceLocation = __get_location(child);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pSourceLocation != NULL)
+ 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;
+ }
+ if (resp_uri != NULL) {
+ _DEBUG_TRACE("resp_uri =[%s] ", resp_uri);
+ pSyncHdr->responseURI = strdup(resp_uri);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ Cred *pCred = NULL;
+ pCred = __get_cred(child);
+ if (pCred == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ _DEBUG_TRACE("Cred\n");
+ pSyncHdr->cred = pCred;
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_TRACE("end");
+ *pContent = pSyncHdr;
+ } else {
+ _DEBUG_TRACE("error");
+ free_synchdr(pSyncHdr);
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_results_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pReverse_binder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pReverse_binder is NULL!!");
+ retvm_if((wbxml_dom_node) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "wbxml_dom_node is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ void *user_data = sync_agent_get_user_data_from_reverse_protocol_binder(pReverse_binder);
+
+ SyncHdr *pSyncHdr = (SyncHdr *) user_data;
+ Item *item = NULL;
+
+ /* get data from dom tree */
+ Command *pResults = (Command *) calloc(1, sizeof(Command));
+ if (pResults == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_TRACE("pResults is null");
+ goto return_part;
+ }
+
+ pResults->type = COMMAND_TYPE_RESULTS;
+ pResults->msgID = pSyncHdr->messageID;
+ pResults->refCount = 1;
+
+ WBXMLTreeNode *child = NULL;
+ const char *child_xml_name = NULL;
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ 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;
+ }
+ if (cmd_id != NULL) {
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ pResults->cmdID = 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;
+ }
+ if (msg_ref != NULL) {
+ _DEBUG_TRACE("MsgRef = [%s]", msg_ref);
+ pResults->private.results.msgRef = 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;
+ }
+ if (cmd_ref != NULL) {
+ _DEBUG_TRACE("MsgRef = [%s]", cmd_ref);
+ pResults->private.results.cmdRef = atoi(cmd_ref);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+
+ WBXMLTreeNode *grandchild = NULL;
+ const char *grandchild_xml_name = NULL;
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ 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;
+ }
+ if (contentType != NULL) {
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ 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 */
+ if (item == NULL)
+ item = create_Item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+
+ WBXMLTreeNode *grandchild = NULL;
+ const char *grandchild_xml_name = NULL;
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ Location *pSourceLocation = __get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pSourceLocation != NULL)
+ item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = __get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pTargetLocation != NULL)
+ item->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
+ WBXMLTreeNode *grandgrandchild = NULL;
+ const char *grandgrandchild_xml_name = NULL;
+
+ for (grandgrandchild = grandchild->children; grandgrandchild != NULL; grandgrandchild = grandgrandchild->next) {
+ grandgrandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandgrandchild->name);
+
+ if (strcmp(grandgrandchild_xml_name, ELEMENT_TYPE) == 0) {
+ char *contentType = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &contentType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (contentType != NULL) {
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ item->contenttype = strdup(contentType);
+ }
+ } else if (strcmp(grandgrandchild_xml_name, ELEMENT_SIZE) == 0) {
+ char *size = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &size);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (size != NULL) {
+ _DEBUG_TRACE("Size = [%s]", size);
+ item->size = atoi(size);
+ }
+ } else if (strcmp(grandgrandchild_xml_name, ELEMENT_FORMAT) == 0) {
+ char *format = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &format);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (format != NULL) {
+ _DEBUG_TRACE("Content Type = [%s]", format);
+ item->format = strdup(format);
+ }
+ }
+ }
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+ char *data = NULL;
+ err = sync_agent_get_text_from_cdata_node(grandchild, &data);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (data != NULL) {
+ _DEBUG_TRACE("Data =[%s] ", data);
+ item->private.data = g_strdup(data);
+ item->dataType = ITEM_DATA;
+ }
+ } else if (strcmp(grandchild_xml_name, ELEMENT_MOREDATA) == 0) {
+ _DEBUG_TRACE(ELEMENT_MOREDATA);
+ item->moreData = 1;
+ }
+ }
+ pResults->private.results.items = g_list_append(pResults->private.results.items, item);
+ item = NULL;
+ }
+ }
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_TRACE("end");
+ *pContent = pResults;
+ } else {
+ _DEBUG_TRACE("error");
+ free_command(pResults);
+ free_Item(item);
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_get_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pReverse_binder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pReverse_binder is NULL!!");
+ retvm_if((wbxml_dom_node) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "wbxml_dom_node is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ void *user_data = sync_agent_get_user_data_from_reverse_protocol_binder(pReverse_binder);
+ SyncHdr *pSyncHdr = (SyncHdr *) user_data;
+ Item *item = NULL;
+
+ /* get data from dom tree */
+ Command *pGet = (Command *) calloc(1, sizeof(Command));
+ if (pGet == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_TRACE("pGet is null");
+ goto return_part;
+ }
+
+ pGet->type = COMMAND_TYPE_GET;
+ pGet->msgID = pSyncHdr->messageID;
+ pGet->refCount = 1;
+
+ WBXMLTreeNode *child = NULL;
+ const char *child_xml_name = NULL;
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ 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;
+ }
+ if (cmd_id != NULL) {
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ pGet->cmdID = atoi(cmd_id);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_META) == 0) {
+
+ WBXMLTreeNode *grandchild = NULL;
+ const char *grandchild_xml_name = NULL;
+
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ 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;
+ }
+ if (contentType != NULL) {
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ pGet->private.access.type = strdup(contentType);
+ }
+ }
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+
+ if (item == NULL)
+ item = create_Item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+
+ WBXMLTreeNode *grandchild = NULL;
+ const char *grandchild_xml_name = NULL;
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ Location *pSourceLocation = __get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pSourceLocation != NULL)
+ item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = __get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pTargetLocation != NULL)
+ item->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
+ WBXMLTreeNode *grandgrandchild = NULL;
+ const char *grandgrandchild_xml_name = NULL;
+
+ for (grandgrandchild = grandchild->children; grandgrandchild != NULL; grandgrandchild = grandgrandchild->next) {
+ grandgrandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandgrandchild->name);
+
+ if (strcmp(grandgrandchild_xml_name, ELEMENT_TYPE) == 0) {
+ char *contentType = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &contentType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (contentType != NULL) {
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ item->contenttype = strdup(contentType);
+ }
+ } else if (strcmp(grandgrandchild_xml_name, ELEMENT_SIZE) == 0) {
+ char *size = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &size);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (size != NULL) {
+ _DEBUG_TRACE("Size = [%s]", size);
+ item->size = atoi(size);
+ }
+ } else if (strcmp(grandgrandchild_xml_name, ELEMENT_FORMAT) == 0) {
+ char *format = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &format);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (format != NULL) {
+ _DEBUG_TRACE("Content Type =[%s] ", format);
+ item->format = strdup(format);
+ }
+ }
+ }
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+ char *data = NULL;
+ err = sync_agent_get_text_from_cdata_node(grandchild, &data);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (data != NULL) {
+ _DEBUG_TRACE("Data = [%s]", data);
+ item->private.data = strdup(data);
+ item->dataType = ITEM_DATA;
+ }
+ } else if (strcmp(grandchild_xml_name, ELEMENT_MOREDATA) == 0) {
+ _DEBUG_TRACE(ELEMENT_MOREDATA);
+ item->moreData = 1;
+ }
+ }
+
+ pGet->private.access.items = g_list_append(pGet->private.access.items, item);
+ item = NULL;
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_TRACE("end");
+ *pContent = pGet;
+ } else {
+ _DEBUG_TRACE("error");
+ free_command(pGet);
+ free_Item(item);
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_alert_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pReverse_binder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pReverse_binder is NULL!!");
+ retvm_if((wbxml_dom_node) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "wbxml_dom_node is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ void *user_data = sync_agent_get_user_data_from_reverse_protocol_binder(pReverse_binder);
+ SyncHdr *pSyncHdr = (SyncHdr *) user_data;
+ Item *item = NULL;
+
+ /* get data from dom tree */
+ Command *pAlert = (Command *) calloc(1, sizeof(Command));
+ if (pAlert == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_TRACE("pAlert is null");
+ goto return_part;
+ }
+
+ pAlert->type = COMMAND_TYPE_ALERT;
+ pAlert->msgID = pSyncHdr->messageID;
+ pAlert->refCount = 1;
+
+ WBXMLTreeNode *child = NULL;
+ const char *child_xml_name = NULL;
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ 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;
+ }
+ if (cmd_id != NULL) {
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ pAlert->cmdID = atoi(cmd_id);
+ }
+ } 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;
+ }
+ if (data != NULL) {
+ _DEBUG_TRACE("Data = [%s]", data);
+ pAlert->private.alert.type = atoi(data);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+ _DEBUG_TRACE("alert item");
+ if (item == NULL) {
+ item = create_Item();
+ }
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+
+ WBXMLTreeNode *grandchild = NULL;
+ const char *grandchild_xml_name = NULL;
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ Location *pSourceLocation = __get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pSourceLocation != NULL)
+ pAlert->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = __get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pTargetLocation != NULL)
+ item->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
+ WBXMLTreeNode *grandgrandchild = NULL;
+ const char *grandgrandchild_xml_name = NULL;
+
+ for (grandgrandchild = grandchild->children; grandgrandchild != NULL; grandgrandchild = grandgrandchild->next) {
+ grandgrandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandgrandchild->name);
+
+ 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;
+ }
+ if (maxObjSize != NULL) {
+ _DEBUG_TRACE("MaxObjSize = [%s]", maxObjSize);
+ pAlert->private.alert.maxObjSize = atoi(maxObjSize);
+ }
+ }
+ }
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+ char *data = NULL;
+ /*err = sync_agent_get_text_from_cdata_node(grandchild, &data); */
+ err = sync_agent_get_text_from_node(grandchild, &data);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (data != NULL) {
+ _DEBUG_TRACE("item Data =[%s] ", data);
+ item->private.data = g_strdup(data);
+ item->dataType = ITEM_DATA;
+ }
+ }
+ }
+ pAlert->private.alert.items = g_list_append(pAlert->private.alert.items, item);
+ item = NULL;
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_TRACE("end");
+ *pContent = pAlert;
+ } else {
+ _DEBUG_TRACE("error");
+ free_command(pAlert);
+ free_Item(item);
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_add_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pReverse_binder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pReverse_binder is NULL!!");
+ retvm_if((wbxml_dom_node) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "wbxml_dom_node is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ void *user_data = sync_agent_get_user_data_from_reverse_protocol_binder(pReverse_binder);
+ SyncHdr *pSyncHdr = (SyncHdr *) user_data;
+ Item *item = NULL;
+
+ /* get data from dom tree */
+ Command *pAdd = (Command *) calloc(1, sizeof(Command));
+ if (pAdd == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_TRACE("pAdd is null");
+ goto return_part;
+ }
+
+ pAdd->type = COMMAND_TYPE_ADD;;
+ pAdd->msgID = pSyncHdr->messageID;
+ pAdd->private.change.type = CHANGE_ADD;
+ pAdd->refCount = 1;
+
+ WBXMLTreeNode *child = NULL;
+ const char *child_xml_name = NULL;
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ 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;
+ }
+ if (cmd_id != NULL) {
+ _DEBUG_TRACE("CmdID =[%s] ", cmd_id);
+ pAdd->cmdID = atoi(cmd_id);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+
+ if (item == NULL)
+ item = create_Item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+
+ WBXMLTreeNode *grandchild = NULL;
+ const char *grandchild_xml_name = NULL;
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ Location *pSourceLocation = __get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pSourceLocation != NULL)
+ item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = __get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pTargetLocation != NULL)
+ item->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
+ WBXMLTreeNode *grandgrandchild = NULL;
+ const char *grandgrandchild_xml_name = NULL;
+
+ for (grandgrandchild = grandchild->children; grandgrandchild != NULL; grandgrandchild = grandgrandchild->next) {
+ grandgrandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandgrandchild->name);
+
+ if (strcmp(grandgrandchild_xml_name, ELEMENT_TYPE) == 0) {
+ char *contentType = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &contentType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (contentType != NULL) {
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ item->contenttype = strdup(contentType);
+ }
+ } else if (strcmp(grandgrandchild_xml_name, ELEMENT_SIZE) == 0) {
+ char *size = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &size);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (size != NULL) {
+ _DEBUG_TRACE("Size =[%s] ", size);
+ item->size = atoi(size);
+ }
+ } else if (strcmp(grandgrandchild_xml_name, ELEMENT_FORMAT) == 0) {
+ char *format = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &format);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (format != NULL) {
+ _DEBUG_TRACE("format =[%s] ", format);
+ item->format = strdup(format);
+ }
+ }
+ }
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+ char *data = NULL;
+ err = sync_agent_get_text_from_cdata_node(grandchild, &data);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (data != NULL) {
+ _DEBUG_TRACE("Data =[%s] ", data);
+ item->private.data = g_strdup(data);
+ item->dataType = ITEM_DATA;
+ }
+ } else if (strcmp(grandchild_xml_name, ELEMENT_MOREDATA) == 0) {
+ _DEBUG_TRACE(ELEMENT_MOREDATA);
+ item->moreData = 1;
+ }
+ }
+ pAdd->private.change.items = g_list_append(pAdd->private.change.items, item);
+ item = NULL;
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_TRACE("end");
+ *pContent = pAdd;
+ } else {
+ _DEBUG_TRACE("error");
+ free_command(pAdd);
+ free_Item(item);
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_replace_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pReverse_binder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pReverse_binder is NULL!!");
+ retvm_if((wbxml_dom_node) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "wbxml_dom_node is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ void *user_data = sync_agent_get_user_data_from_reverse_protocol_binder(pReverse_binder);
+ SyncHdr *pSyncHdr = (SyncHdr *) user_data;
+ Item *item = NULL;
+
+ /* get data from dom tree */
+ Command *pReplace = (Command *) calloc(1, sizeof(Command));
+ if (pReplace == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_TRACE("pReplace is null");
+ goto return_part;
+ }
+
+ pReplace->type = COMMAND_TYPE_REPLACE;;
+ pReplace->msgID = pSyncHdr->messageID;
+ pReplace->private.change.type = CHANGE_REPLACE;
+ pReplace->refCount = 1;
+
+ WBXMLTreeNode *child = NULL;
+ const char *child_xml_name = NULL;
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ 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;
+ }
+ if (cmd_id) {
+ _DEBUG_TRACE("CmdID =[%s] ", cmd_id);
+ pReplace->cmdID = atoi(cmd_id);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+
+ if (item == NULL)
+ item = create_Item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+
+ WBXMLTreeNode *grandchild = NULL;
+ const char *grandchild_xml_name = NULL;
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ Location *pSourceLocation = __get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pSourceLocation != NULL)
+ item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = __get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pTargetLocation != NULL)
+ item->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
+ WBXMLTreeNode *grandgrandchild = NULL;
+ const char *grandgrandchild_xml_name = NULL;
+
+ for (grandgrandchild = grandchild->children; grandgrandchild != NULL; grandgrandchild = grandgrandchild->next) {
+ grandgrandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandgrandchild->name);
+ if (strcmp(grandgrandchild_xml_name, ELEMENT_TYPE) == 0) {
+
+ char *contentType = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &contentType);
+ _DEBUG_TRACE("%d\n", err);
+
+ /* if (err != SYNC_AGENT_PB_RETURN_OK || err != SYNC_AGENT_PB_RETURN_UTIL_NO_TEXT_VALUE) {
+ goto return_part;
+ } */
+ if (contentType != NULL) {
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ item->contenttype = strdup(contentType);
+ }
+ } else if (strcmp(grandgrandchild_xml_name, ELEMENT_SIZE) == 0) {
+
+ char *size = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &size);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (size != NULL) {
+ _DEBUG_TRACE("Size =[%s] ", size);
+ item->size = atoi(size);
+ }
+ } else if (strcmp(grandgrandchild_xml_name, ELEMENT_FORMAT) == 0) {
+ char *format = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &format);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (format != NULL) {
+ _DEBUG_TRACE("Content Type = [%s]", format);
+ item->format = strdup(format);
+ }
+ }
+ }
+
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+ char *data = NULL;
+ err = sync_agent_get_text_from_cdata_node(grandchild, &data);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (data != NULL) {
+ _DEBUG_TRACE("Data = [%s]", data);
+ item->private.data = g_strdup(data);
+ item->dataType = ITEM_DATA;
+ }
+ }
+ }
+ pReplace->private.change.items = g_list_append(pReplace->private.change.items, item);
+ item = NULL;
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_TRACE("end");
+ *pContent = pReplace;
+ } else {
+ _DEBUG_TRACE("error");
+ free_command(pReplace);
+ free_Item(item);
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_delete_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pReverse_binder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pReverse_binder is NULL!!");
+ retvm_if((wbxml_dom_node) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "wbxml_dom_node is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ void *user_data = sync_agent_get_user_data_from_reverse_protocol_binder(pReverse_binder);
+ SyncHdr *pSyncHdr = (SyncHdr *) user_data;
+ Item *item = NULL;
+
+ /* get data from dom tree */
+ Command *pDelete = (Command *) calloc(1, sizeof(Command));
+ if (pDelete == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_TRACE("pDelete is null");
+ goto return_part;
+ }
+
+ pDelete->type = COMMAND_TYPE_DELETE;
+ pDelete->msgID = pSyncHdr->messageID;
+ pDelete->private.change.type = CHANGE_DELETE;
+ pDelete->refCount = 1;
+
+ WBXMLTreeNode *child = NULL;
+ const char *child_xml_name = NULL;
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ 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;
+ }
+ if (cmd_id != NULL) {
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ pDelete->cmdID = atoi(cmd_id);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+ /* create Item */
+ if (item == NULL)
+ item = create_Item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+
+ WBXMLTreeNode *grandchild = NULL;
+ const char *grandchild_xml_name = NULL;
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ Location *pSourceLocation = __get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pSourceLocation != NULL)
+ item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = __get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pTargetLocation != NULL)
+ item->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
+ WBXMLTreeNode *grandgrandchild = NULL;
+ const char *grandgrandchild_xml_name = NULL;
+
+ for (grandgrandchild = grandchild->children; grandgrandchild != NULL; grandgrandchild = grandgrandchild->next) {
+ grandgrandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandgrandchild->name);
+
+ if (strcmp(grandgrandchild_xml_name, ELEMENT_TYPE) == 0) {
+ char *contentType = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &contentType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (contentType != NULL) {
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ item->contenttype = strdup(contentType);
+ }
+ }
+ }
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+
+ }
+ }
+ pDelete->private.change.items = g_list_append(pDelete->private.change.items, item);
+ item = NULL;
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_TRACE("end");
+ *pContent = pDelete;
+ } else {
+ _DEBUG_TRACE("error");
+ free_command(pDelete);
+ free_Item(item);
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_exec_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pReverse_binder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pReverse_binder is NULL!!");
+ retvm_if((wbxml_dom_node) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "wbxml_dom_node is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ void *user_data = sync_agent_get_user_data_from_reverse_protocol_binder(pReverse_binder);
+ SyncHdr *pSyncHdr = (SyncHdr *) user_data;
+
+ /* get data from dom tree */
+ Command *pExec = (Command *) calloc(1, sizeof(Command));
+ if (pExec == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_TRACE("pExec is null");
+ goto return_part;
+ }
+
+ pExec->type = COMMAND_TYPE_EXEC;
+ pExec->msgID = pSyncHdr->messageID;
+ pExec->refCount = 1;
+
+ WBXMLTreeNode *child = NULL;
+ const char *child_xml_name = NULL;
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ 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;
+ }
+ if (cmd_id != NULL) {
+ _DEBUG_TRACE("CmdID =[%s] ", cmd_id);
+ pExec->cmdID = atoi(cmd_id);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_CORRELATOR) == 0) {
+ char *pCorrelator = NULL;
+ err = sync_agent_get_text_from_node(child, &pCorrelator);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (pCorrelator != NULL) {
+ _DEBUG_TRACE("pCorrelator = [%s]", pCorrelator);
+ pExec->private.exec.correlator = strdup(pCorrelator);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+ /* create Item */
+ pExec->private.exec.item = create_Item();
+ if (pExec->private.exec.item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ WBXMLTreeNode *grandchild = NULL;
+ const char *grandchild_xml_name = NULL;
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ Location *pSourceLocation = __get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pSourceLocation != NULL)
+ pExec->private.exec.item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = __get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pTargetLocation != NULL)
+ pExec->private.exec.item->target = pTargetLocation;
+ }
+ }
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_TRACE("end");
+ *pContent = pExec;
+ } else {
+ _DEBUG_TRACE("error");
+ free_command(pExec);
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_sequence_start_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
+{
+
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pReverse_binder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pReverse_binder is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ void *user_data = sync_agent_get_user_data_from_reverse_protocol_binder(pReverse_binder);
+ SyncHdr *pSyncHdr = (SyncHdr *) user_data;
+
+ /* get data from dom tree */
+ Command *pSequence = (Command *) calloc(1, sizeof(Command));
+
+ if (pSequence == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_TRACE("pSequence is null");
+ goto return_part;
+ }
+
+ pSequence->type = COMMAND_TYPE_SEQUENCE;
+ pSequence->msgID = pSyncHdr->messageID;
+ pSequence->refCount = 1;
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_TRACE("end");
+ *pContent = pSequence;
+ } else {
+ _DEBUG_TRACE("error");
+ free_command(pSequence);
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+}
+
+static sync_agent_pb_error_e _syncml_binder_sequence_end_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
+{
+
+ _INNER_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_TRACE("end");
+ } else {
+ _DEBUG_TRACE("error");
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+}
+
+static sync_agent_pb_error_e _syncml_binder_atomic_start_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
+{
+
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pReverse_binder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pReverse_binder is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ void *user_data = sync_agent_get_user_data_from_reverse_protocol_binder(pReverse_binder);
+ SyncHdr *pSyncHdr = (SyncHdr *) user_data;
+ Command *pAtomic = (Command *) calloc(1, sizeof(Command));
+
+ if (pAtomic == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_TRACE("pExec is null");
+ goto return_part;
+ }
+
+ pAtomic->type = COMMAND_TYPE_ATOMIC;
+ pAtomic->msgID = pSyncHdr->messageID;
+ pAtomic->refCount = 1;
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_TRACE("end");
+ *pContent = pAtomic;
+ } else {
+ _DEBUG_TRACE("error");
+ free_command(pAtomic);
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_atomic_end_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
+{
+
+ _INNER_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_TRACE("end");
+ } else {
+ _DEBUG_TRACE("error");
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_final_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
+{
+ _INNER_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ int *pFinal = (int *)1;
+ *pContent = pFinal;
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_status_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((wbxml_dom_node) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "wbxml_dom_node is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ /* get data from dom tree */
+ Status *pStatus = (Status *) calloc(1, sizeof(Status));
+ if (pStatus == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_TRACE("pStatus is null");
+ goto return_part;
+ }
+
+ WBXMLTreeNode *child = NULL;
+ const char *child_xml_name = NULL;
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ 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;
+ }
+ if (cmd_id != NULL) {
+ _DEBUG_TRACE("CmdID =[%s] ", cmd_id);
+ pStatus->cmdID = atoi(cmd_id);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_MSGREF) == 0) {
+ char *msgref = NULL;
+ err = sync_agent_get_text_from_node(child, &msgref);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (msgref != NULL) {
+ _DEBUG_TRACE("MsgRef = [%s]", msgref);
+ pStatus->msgRef = atoi(msgref);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_CMDREF) == 0) {
+ char *cmdref = NULL;
+ err = sync_agent_get_text_from_node(child, &cmdref);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (cmdref != NULL) {
+ _DEBUG_TRACE("CmdRef = [%s]", cmdref);
+ pStatus->cmdRef = atoi(cmdref);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_CMD) == 0) {
+ char *cmd = NULL;
+ err = sync_agent_get_text_from_node(child, &cmd);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (cmd != NULL) {
+ _DEBUG_TRACE("Cmd =[%s] ", cmd);
+ pStatus->type = converttocommandtype(cmd);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_TARGETREF) == 0) {
+ char *targetref = NULL;
+ Location *pLocation = NULL;
+ err = sync_agent_get_text_from_node(child, &targetref);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (targetref != NULL) {
+ DM_ERROR ret = DM_OK;
+ _DEBUG_TRACE("TargetRef = [%s]", targetref);
+ ret = create_location(targetref, NULL, &pLocation);
+ if(ret != DM_OK) {
+ _DEBUG_VERBOSE("create_location failed");
+ goto return_part;
+ }
+ pStatus->targetRef = pLocation;
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_SOURCEREF) == 0) {
+ char *sourceref = NULL;
+ Location *pLocation = NULL;
+ err = sync_agent_get_text_from_node(child, &sourceref);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (sourceref != NULL) {
+ DM_ERROR ret = DM_OK;
+ _DEBUG_TRACE("SourceRef = [%s]", sourceref);
+ ret = create_location(sourceref, NULL, &pLocation);
+ if(ret != DM_OK) {
+ _DEBUG_VERBOSE("create_location failed");
+ goto return_part;
+ }
+ pStatus->sourceRef = pLocation;
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_CRED) == 0) {
+ _DEBUG_TRACE(ELEMENT_CRED);
+ pStatus->cred = __get_cred(child);
+ } else if (strcmp(child_xml_name, ELEMENT_CHAL) == 0) {
+ _DEBUG_TRACE("Chal\n");
+ pStatus->chal = __get_chal(child);
+ } 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;
+ }
+ if (data != NULL) {
+ _DEBUG_TRACE("Data = [%s]\n", data);
+ pStatus->data = strdup(data);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+ /* TODO : item */
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_TRACE("end");
+ *pContent = pStatus;
+ } else {
+ _DEBUG_TRACE("error");
+ free_status(pStatus);
+ }
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static sync_agent_pb_error_e _syncml_binder_copy_command_reverse_converter_function(sync_agent_pb_protocol_binder_reverse_info_s * pReverse_binder, WBXMLTreeNode * wbxml_dom_node, Content_Ptr * pContent)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((pReverse_binder) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "pReverse_binder is NULL!!");
+ retvm_if((wbxml_dom_node) == NULL, SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY, "wbxml_dom_node is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ void *user_data = sync_agent_get_user_data_from_reverse_protocol_binder(pReverse_binder);
+ SyncHdr *pSyncHdr = (SyncHdr *) user_data;
+ Item *item = NULL;
+ /* get data from dom tree */
+ Command *pCopy = (Command *) calloc(1, sizeof(Command));
+ if (pCopy == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ _DEBUG_TRACE("pCopy is null");
+ goto return_part;
+ }
+
+ pCopy->type = COMMAND_TYPE_COPY;
+ pCopy->msgID = pSyncHdr->messageID;
+ pCopy->private.change.type = CHANGE_COPY;
+ pCopy->refCount = 1;
+
+ WBXMLTreeNode *child = NULL;
+ const char *child_xml_name = NULL;
+ for (child = wbxml_dom_node->children; child != NULL; child = child->next) {
+ 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;
+ }
+ if (cmd_id != NULL) {
+ _DEBUG_TRACE("CmdID = [%s]", cmd_id);
+ pCopy->cmdID = atoi(cmd_id);
+ }
+ } else if (strcmp(child_xml_name, ELEMENT_ITEM) == 0) {
+ /* create Item */
+
+ if (item == NULL)
+ item = create_Item();
+ if (item == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+
+ WBXMLTreeNode *grandchild = NULL;
+ const char *grandchild_xml_name = NULL;
+ for (grandchild = child->children; grandchild != NULL; grandchild = grandchild->next) {
+ grandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandchild->name);
+
+ if (strcmp(grandchild_xml_name, ELEMENT_SOURCE) == 0) {
+ Location *pSourceLocation = __get_location(grandchild);
+ if (pSourceLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pSourceLocation != NULL)
+ item->source = pSourceLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_TARGET) == 0) {
+ Location *pTargetLocation = __get_location(grandchild);
+ if (pTargetLocation == NULL) {
+ err = SYNC_AGENT_PB_RETURN_OUT_OF_MEMORY;
+ goto return_part;
+ }
+ if (pTargetLocation != NULL)
+ item->target = pTargetLocation;
+ } else if (strcmp(grandchild_xml_name, ELEMENT_META) == 0) {
+ WBXMLTreeNode *grandgrandchild = NULL;
+ const char *grandgrandchild_xml_name = NULL;
+
+ for (grandgrandchild = grandchild->children; grandgrandchild != NULL; grandgrandchild = grandgrandchild->next) {
+ grandgrandchild_xml_name = (const char *)wbxml_tag_get_xml_name(grandgrandchild->name);
+
+ if (strcmp(grandgrandchild_xml_name, ELEMENT_TYPE) == 0) {
+ char *contentType = NULL;
+ err = sync_agent_get_text_from_node(grandgrandchild, &contentType);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+ if (contentType != NULL) {
+ _DEBUG_TRACE("Content Type = [%s]", contentType);
+ item->contenttype = strdup(contentType);
+ }
+ }
+ }
+ } else if (strcmp(grandchild_xml_name, ELEMENT_DATA) == 0) {
+
+ }
+ }
+ pCopy->private.change.items = g_list_append(pCopy->private.change.items, item);
+ item = NULL;
+ }
+ }
+
+ return_part:
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_TRACE("end");
+ *pContent = pCopy;
+ } else {
+ _DEBUG_TRACE("error");
+ free_command(pCopy);
+ free_Item(item);
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_pb_error_e init_syncml_binder_function_set(sync_agent_pb_protocol_binder_function_set_s ** pBinder_function_set)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ err = sync_agent_init_binder_function_set(sizeof(oma_dm_binder_function_info) / sizeof(sync_agent_pb_function_info_s), (sync_agent_pb_function_info_s *) oma_dm_binder_function_info, pBinder_function_set);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+void free_syncml_binder_function_set(sync_agent_pb_protocol_binder_function_set_s * pBinder_function_set)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if((pBinder_function_set) == NULL, "pBinder_function_set is NULL!!");
+
+ sync_agent_free_binder_function_set(pBinder_function_set);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_pb_protocol_binder_info_s *syncml_binder_init(sync_agent_pb_protocol_binder_info_s * pBinder, sync_agent_pb_encoding_e enc, bool use_strtbl, bool use_flow_mode, sync_agent_pb_protocol_binder_function_set_s * pBinder_function_set)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_pb_protocol_binder_info_s *pOutBinder = NULL;
+
+ pOutBinder = sync_agent_init_protocol_binder(pBinder, SYNC_AGENT_PB_PROTOCOL_SYNCML_SYNCML12, NULL, enc, 1, use_strtbl, false, use_flow_mode, false, NULL, NULL, pBinder_function_set);
+
+ if (pOutBinder == NULL) {
+ goto return_part;
+ }
+ //protocol_binder_set_estimate_doc_size(pOutBinder, SYNC_AGENT_INIT_ESTIMATE_DOC_SIZE);
+
+ return_part:
+ _EXTERN_FUNC_EXIT;
+ return pOutBinder;
+}
+
+sync_agent_pb_error_e syncml_binder_append(sync_agent_pb_protocol_binder_info_s * pBinder, OMA_DM_Protocol_Element protocol_element, Content_Ptr pContent)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((pBinder) == NULL, SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR, "pBinder is NULL!!");
+
+ _DEBUG_TRACE(" protocol_element = %d, pContent = %p\n", protocol_element, pContent);
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ err = sync_agent_append_element(pBinder, protocol_element, pContent);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+void syncml_binder_terminate(sync_agent_pb_protocol_binder_info_s * pBinder)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if((pBinder) == NULL, "pBinder is NULL!!");
+
+ sync_agent_destroy_protocol_binder(pBinder);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+sync_agent_pb_error_e syncml_binder_get_stream(sync_agent_pb_protocol_binder_info_s * pBinder, char **byte_stream, unsigned int *byte_stream_size)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((pBinder) == NULL, SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR, "pBinder is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ err = sync_agent_get_stream_from_protocol_binder(pBinder, byte_stream, byte_stream_size);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ goto return_part;
+ }
+
+ return_part:
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_pb_error_e syncml_binder_get_stream_size(sync_agent_pb_protocol_binder_info_s * pBinder, unsigned int *byte_stream_size)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((pBinder) == NULL, SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR, "pBinder is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ err = sync_agent_get_stream_size_from_protocol_binder(pBinder, byte_stream_size);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_pb_error_e syncml_binder_get_encoding(sync_agent_pb_protocol_binder_info_s * pBinder, sync_agent_pb_encoding_e * enc)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((pBinder) == NULL, SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR, "pBinder is NULL!!");
+
+ sync_agent_pb_error_e err = SYNC_AGENT_PB_RETURN_OK;
+
+ err = sync_agent_get_encoding_from_protocol_binder(pBinder, enc);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_pb_error_e reverse_syncml_binder_init(char *byte_stream,
+ unsigned int byte_stream_len, sync_agent_pb_decoding_e dec, sync_agent_pb_protocol_binder_function_set_s * pBinder_function_set, void *user_data, sync_agent_pb_protocol_binder_reverse_info_s ** ppBinder)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((byte_stream) == NULL, SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR, "byte_stream is NULL!!");
+ retvm_if((pBinder_function_set) == NULL, SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR, "pBinder_function_set is NULL!!");
+
+ sync_agent_pb_protocol_e protocol = SYNC_AGENT_PB_PROTOCOL_UNKNOWN;
+ sync_agent_pb_error_e err = sync_agent_init_reverse_protocol_binder(byte_stream, byte_stream_len, dec,
+ &protocol, pBinder_function_set, user_data, ppBinder);
+
+ _EXTERN_FUNC_EXIT;
+ return err;
+}
+
+sync_agent_pb_error_e reverse_syncml_binder_next(sync_agent_pb_protocol_binder_reverse_info_s * pBinder, OMA_DM_Protocol_Element * protocol_element, char **protocol_element_name, Content_Ptr * pContent)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((pBinder) == NULL, SYNC_AGENT_PB_RETURN_UNKNOWN_ERROR, "pBinder is NULL!!");
+
+ sync_agent_pb_error_e err = sync_agent_next_element(pBinder, protocol_element, protocol_element_name, pContent);
+
+ _EXTERN_FUNC_EXIT;
+
+ return err;
+}
diff --git a/src/agent/serviceadapter/sa_command.c b/src/agent/serviceadapter/sa_command.c
new file mode 100644
index 0000000..47d9b3a
--- /dev/null
+++ b/src/agent/serviceadapter/sa_command.c
@@ -0,0 +1,944 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "serviceadapter/sa_command.h"
+#include "serviceadapter/sa_command_internal.h"
+#include "serviceadapter/sa_elements.h"
+#include "serviceadapter/sa_elements_internal.h"
+#include "serviceadapter/sa_session.h"
+#include "serviceadapter/sa_session_internal.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_SA"
+#endif
+
+static Command *_create_Cmd(Session * pSession, CommandType type);
+
+static Command *_create_Cmd(Session * pSession, CommandType type)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((pSession) == NULL, NULL, "pSession is NULL!!");
+ retvm_if((type) == COMMAND_TYPE_UNKNOWN, NULL, "type is NULL!!");
+
+ _DEBUG_TRACE(" start type : %d msgID : %d cmdID : %d\n", type, pSession->msgID, pSession->cmdID);
+
+ Command *cmd = (Command *) calloc(1, sizeof(Command));
+ if (cmd == NULL) {
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+
+ cmd->type = type;
+ cmd->msgID = pSession->msgID;
+ cmd->cmdID = pSession->cmdID;
+ cmd->refCount = 1;
+
+ PendingStatus *temp = NULL;
+ ret = create_prependingstatus(pSession->msgID, pSession->cmdID, &temp);
+ if (ret != DM_OK)
+ goto error;
+
+ pSession->pendingStatus = g_list_append(pSession->pendingStatus, temp);
+ pSession->cmdID++;
+ _DEBUG_INFO("session cmdId : %d", pSession->cmdID);
+
+ _DEBUG_TRACE(" end\n");
+ _INNER_FUNC_EXIT;
+ return cmd;
+
+ error:
+ free_command(cmd);
+ _DEBUG_TRACE(" error : %d\n", ret);
+ _INNER_FUNC_EXIT;
+ return NULL;
+
+}
+
+DM_ERROR duplicate_command(Command * source, Command ** target)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((source) == NULL, COMMON_ERR_IS_NULL, "command is NULL!!");
+ DM_ERROR ret = DM_OK;
+
+ CommandType type = source->type;
+
+ switch (type) {
+ case COMMAND_TYPE_RESULTS:
+ {
+ _DEBUG_INFO("dup result command");
+ *target = (Command *) calloc(1, sizeof(Command));
+ if (*target == NULL) {
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+
+ (*target)->type = type;
+ (*target)->msgID = source->msgID;
+ (*target)->cmdID = source->cmdID;
+ (*target)->refCount = 1;
+ if (source->source != NULL) {
+ _DEBUG_INFO("source location");
+ (*target)->source = dup_location(source->source);
+ }
+ if (source->target) {
+ _DEBUG_INFO("taget location");
+ (*target)->target = dup_location(source->target);
+ }
+
+ _DEBUG_INFO("result data cmdRef : %d, msgRef : %d", source->private.results.cmdRef, source->private.results.msgRef);
+ (*target)->private.results.cmdRef = source->private.results.cmdRef;
+ (*target)->private.results.msgRef = source->private.results.msgRef;
+
+ if (source->private.results.targetRef) {
+ _DEBUG_INFO("target ref");
+ (*target)->private.results.targetRef = dup_location(source->private.results.targetRef);
+ }
+ if (source->private.results.type) {
+ _DEBUG_INFO("type");
+ (*target)->private.results.type = strdup(source->private.results.type);
+ }
+ if (source->private.results.items) {
+ _DEBUG_INFO("result item list");
+ GList *iter_list = NULL;
+ Item *temp = NULL;
+
+ for (iter_list = source->private.results.items; iter_list != NULL; iter_list = g_list_next(iter_list)) {
+ _DEBUG_INFO("result item");
+ temp = (Item *) iter_list->data;
+ Item *dup_item = NULL;
+ if (temp->source != NULL) {
+ if (temp->source->locURI != NULL) {
+ _DEBUG_INFO("loc uri : %s", temp->source->locURI);
+ }
+ ret = construct_Item(temp->source->locURI, temp->format, temp->contenttype, temp->private.data, temp->size, temp->moreData, &dup_item);
+ _DEBUG_INFO("construct item : %d", ret);
+
+ (*target)->private.results.items = g_list_append((*target)->private.results.items, dup_item);
+ } else {
+ _DEBUG_INFO("source is null");
+ }
+ }
+ }
+ }
+ break;
+ case COMMAND_TYPE_ALERT:
+ case COMMAND_TYPE_HEADER:
+ case COMMAND_TYPE_ADD:
+ case COMMAND_TYPE_REPLACE:
+ case COMMAND_TYPE_DELETE:
+ case COMMAND_TYPE_GET:
+ case COMMAND_TYPE_EXEC:
+ case COMMAND_TYPE_SEQUENCE:
+ case COMMAND_TYPE_ATOMIC:
+ case COMMAND_TYPE_COPY:
+ case COMMAND_TYPE_UNKNOWN:
+ break;
+
+ }
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+void free_commands(GList * commands)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (commands == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+
+ GList *iter = NULL;
+ Command *pCommand = NULL;
+ for (iter = commands; iter != NULL;) {
+ pCommand = iter->data;
+ _DEBUG_INFO("command type is %d\n", pCommand->type);
+
+ iter = g_list_next(iter);
+ commands = g_list_remove(commands, pCommand);
+ if (pCommand->type != COMMAND_TYPE_UNKNOWN) {
+ free_command(pCommand);
+ _DEBUG_INFO("free command");
+ }
+ }
+ _DEBUG_INFO("free command list");
+ g_list_free(commands);
+
+ _EXTERN_FUNC_EXIT;
+ return;
+}
+
+DM_ERROR set_correlator(Command ** pAlertCommand, char *pCorrelator)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((*pAlertCommand) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "pAlertCommand is NULL!!");
+ retvm_if((pCorrelator) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "pCorrelator is NULL!!");
+
+ (*pAlertCommand)->private.alert.Correlator = g_strdup(pCorrelator);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+DM_ERROR create_alert_cmd(Session * session, AlertType syncType, Command ** pCommand)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ *pCommand = _create_Cmd(session, COMMAND_TYPE_ALERT);
+ if ((*pCommand) == NULL) {
+ ret = COMMON_ERR_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+
+ (*pCommand)->private.alert.type = syncType;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR create_replace_cmd(Session * session, Command ** pCommand)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "session is NULL!!");
+
+ (*pCommand) = _create_Cmd(session, COMMAND_TYPE_REPLACE);
+ if ((*pCommand) == NULL) {
+ ret = COMMON_ERR_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+
+ (*pCommand)->private.change.type = CHANGE_REPLACE;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR create_results_cmd(Session * session, Command ** pCommand)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "session is NULL!!");
+
+ *pCommand = _create_Cmd(session, COMMAND_TYPE_RESULTS);
+ if ((*pCommand) == NULL) {
+ ret = COMMON_ERR_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR create_add_cmd(Session * session, char *luid, const char *contenttype, char *data, unsigned int size, int moreData, Command ** pCommand)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "session is NULL!!");
+ retvm_if((luid) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "luid is NULL!!");
+ retvm_if((contenttype) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "contenttype is NULL!!");
+
+ Item *temp = NULL;
+ Location *pLocation = NULL;
+
+ *pCommand = _create_Cmd(session, COMMAND_TYPE_ADD);
+ if (*pCommand == NULL) {
+ ret = COMMON_ERR_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+
+ ret = create_item_data(data, size, &temp);
+ if (ret != DM_OK) {
+ ret = COMMON_ERR_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+
+ (*pCommand)->private.change.type = CHANGE_ADD;
+ temp->contenttype = g_strdup(contenttype);
+ temp->moreData = moreData;
+
+ ret = create_location(luid, NULL, &pLocation);
+ if (ret != DM_OK)
+ goto error;
+
+ set_itemsource(temp, pLocation);
+ (*pCommand)->private.change.items = g_list_append((*pCommand)->private.change.items, temp);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ free_Item(temp);
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR create_delete_cmd(Session * session, char *luid, const char *contenttype, Command ** pCommand)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "session is NULL!!");
+ retvm_if((luid) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "luid is NULL!!");
+ retvm_if((contenttype) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "contenttype is NULL!!");
+
+ Item *temp = NULL;
+ Location *pLocation = NULL;
+
+ *pCommand = _create_Cmd(session, COMMAND_TYPE_DELETE);
+ if (*pCommand == NULL) {
+ ret = COMMON_ERR_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+
+ temp = create_Item();
+ if (temp == NULL) {
+ ret = COMMON_ERR_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+
+ (*pCommand)->private.change.type = CHANGE_DELETE;
+
+ ret = create_location(luid, NULL, &pLocation);
+ if (ret != DM_OK)
+ goto error;
+
+ set_itemsource(temp, pLocation);
+ temp->contenttype = g_strdup(contenttype);
+ (*pCommand)->private.change.items = g_list_append((*pCommand)->private.change.items, temp);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ free_Item(temp);
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+void free_command(Command * pCommand)
+{
+ _EXTERN_FUNC_ENTER;
+ if (pCommand == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+
+ GList *iter = NULL;
+ _DEBUG_INFO(" Command type is %d", pCommand->type);
+
+ if (pCommand->refCount > 1) {
+ _DEBUG_INFO("Command's refCount is %d\n", pCommand->refCount);
+ /*decrease_command_refcount(pCommand); */
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+
+ switch (pCommand->type) {
+ case COMMAND_TYPE_ALERT:
+ _DEBUG_INFO("alert type : %d", pCommand->private.alert.type);
+ if ((pCommand->private.alert.type >= DM_ALERT_DISPLAY && pCommand->private.alert.type <= DM_ALERT_MULTIPLE_CHOICE)
+ && pCommand->private.alert.items != NULL) {
+ for (iter = pCommand->private.alert.items; iter != NULL; iter = g_list_next(iter)) {
+ free_Item((Item *) iter->data);
+ }
+ }
+ _DEBUG_INFO("alert correlator");
+ if (pCommand->private.alert.Correlator != NULL) {
+ free(pCommand->private.alert.Correlator);
+ pCommand->private.alert.Correlator = NULL;
+ }
+ break;
+ case COMMAND_TYPE_HEADER:
+ _DEBUG_INFO("header type");
+ //COMMAND_TYPE_HEADER doesnot come here
+ break;
+ case COMMAND_TYPE_ADD:
+ case COMMAND_TYPE_REPLACE:
+ case COMMAND_TYPE_DELETE:
+ case COMMAND_TYPE_COPY:
+ _DEBUG_INFO("add repalce delete type");
+ if (pCommand->private.change.items != NULL) {
+ for (iter = pCommand->private.change.items; iter != NULL; iter = g_list_next(iter)) {
+ free_Item(iter->data);
+ }
+ }
+ break;
+ case COMMAND_TYPE_GET:
+ _DEBUG_INFO("get type");
+ if (pCommand->private.access.type != NULL) {
+ free(pCommand->private.access.type);
+ pCommand->private.access.type = NULL;
+ }
+
+ if (pCommand->private.access.items != NULL) {
+ for (iter = pCommand->private.access.items; iter != NULL; iter = g_list_next(iter)) {
+ free_Item(iter->data);
+ }
+ }
+ break;
+ case COMMAND_TYPE_RESULTS:
+ _DEBUG_INFO("result type");
+ if (pCommand->private.results.type != NULL) {
+ free(pCommand->private.results.type);
+ pCommand->private.results.type = NULL;
+ }
+ if (pCommand->private.results.items != NULL) {
+ for (iter = pCommand->private.results.items; iter != NULL; iter = g_list_next(iter)) {
+ free_Item(iter->data);
+ }
+ }
+
+ break;
+ case COMMAND_TYPE_EXEC:
+ _DEBUG_INFO("exec type");
+ if (pCommand->private.exec.correlator != NULL) {
+ free(pCommand->private.exec.correlator);
+ pCommand->private.exec.correlator = NULL;
+ }
+ if (pCommand->private.exec.item != NULL) {
+ free_Item(pCommand->private.exec.item);
+ }
+ break;
+ case COMMAND_TYPE_UNKNOWN:
+ _DEBUG_INFO("unknown type");
+ break;
+ case COMMAND_TYPE_SEQUENCE:
+ case COMMAND_TYPE_ATOMIC:
+ _DEBUG_INFO("sequence atomic copy type");
+ if (pCommand->private.sequence_atomic.commands != NULL) {
+ for (iter = pCommand->private.sequence_atomic.commands; iter != NULL; iter = g_list_next(iter)) {
+ free_command(iter->data);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ _DEBUG_INFO("command source");
+ if (pCommand->source != NULL) {
+ free_location(pCommand->source);
+ pCommand->source = NULL;
+ }
+
+ _DEBUG_INFO("command target");
+ if (pCommand->target != NULL) {
+ free_location(pCommand->target);
+ pCommand->target = NULL;
+ }
+
+ _DEBUG_INFO("free command ");
+ free(pCommand);
+ pCommand = NULL;
+
+ _DEBUG_INFO("free command end");
+ _EXTERN_FUNC_EXIT;
+}
+
+void free_statuses(GList * status)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (!status) {
+ _DEBUG_INFO(" List is null\n");
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+
+ GList *iter = NULL;
+ int i = 0;
+ _DEBUG_INFO(" count : %d\n", g_list_length(status));
+ for (iter = status; iter != NULL; iter = g_list_next(iter)) {
+ _DEBUG_INFO(" count : %d\n", ++i);
+ free_status(iter->data);
+ }
+
+ g_list_free(status);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void free_status(Status * pStatus)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (pStatus == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+
+ if (pStatus->data != NULL)
+ free(pStatus->data);
+
+ if (pStatus->sourceRef != NULL)
+ free_location(pStatus->sourceRef);
+
+ if (pStatus->targetRef != NULL)
+ free_location(pStatus->targetRef);
+/*
+ if(pStatus->res_chal)
+ free_chal(pStatus->res_chal);
+
+ if(pStatus->cred)
+ free_cred(pStatus->cred);*/
+
+ //free_Item(pStatus->item);
+ GList *iter = NULL;
+ for (iter = pStatus->items; iter != NULL; iter = g_list_next(iter))
+ free_Item(iter->data);
+
+ if (pStatus != NULL) {
+ free(pStatus);
+ pStatus = NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+DM_ERROR get_statuscode(Status * status)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((status) == NULL, DM_ERR_FORBIDDEN, "status is NULL!!");
+
+ _EXTERN_FUNC_EXIT;
+ return atoi(status->data);
+}
+
+ChangeType converttochangetype(unsigned int type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ ChangeType changeType = CHANGE_UNKNOWN;
+ switch (type) {
+ case 1:
+ changeType = CHANGE_ADD;
+ break;
+ case 2:
+ changeType = CHANGE_REPLACE;
+ break;
+ case 3:
+ changeType = CHANGE_DELETE;
+ break;
+ case 4:
+ changeType = CHANGE_COPY;
+ break;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return changeType;
+}
+
+unsigned int convertfromchangetype(ChangeType changeType)
+{
+ _EXTERN_FUNC_ENTER;
+
+ unsigned int type = 0;
+
+ switch (changeType) {
+ case CHANGE_ADD:
+ type = 1;
+ break;
+ case CHANGE_REPLACE:
+ type = 2;
+ break;
+ case CHANGE_DELETE:
+ type = 3;
+ break;
+ case CHANGE_UNKNOWN:
+ break;
+ case CHANGE_COPY:
+ type = 4;
+ break;
+ default:
+ break;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return type;
+}
+
+CommandType converttocommandtype(char *type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((type) == NULL, COMMAND_TYPE_UNKNOWN, "type is NULL!!");
+
+ if (strcmp(type, "Alert") == 0) {
+ _EXTERN_FUNC_EXIT;
+ return COMMAND_TYPE_ALERT;
+ } else if (strcmp(type, "SyncHdr") == 0) {
+ _EXTERN_FUNC_EXIT;
+ return COMMAND_TYPE_HEADER;
+ } else if (strcmp(type, "Add") == 0) {
+ _EXTERN_FUNC_EXIT;
+ return COMMAND_TYPE_ADD;
+ } else if (strcmp(type, "Replace") == 0) {
+ _EXTERN_FUNC_EXIT;
+ return COMMAND_TYPE_REPLACE;
+ } else if (strcmp(type, "Delete") == 0) {
+ _EXTERN_FUNC_EXIT;
+ return COMMAND_TYPE_DELETE;
+ } else if (strcmp(type, "Results") == 0) {
+ _EXTERN_FUNC_EXIT;
+ return COMMAND_TYPE_RESULTS;
+ } else if (strcmp(type, "Get") == 0) {
+ _EXTERN_FUNC_EXIT;
+ return COMMAND_TYPE_GET;
+ } else if (strcmp(type, "Exec") == 0) {
+ _EXTERN_FUNC_EXIT;
+ return COMMAND_TYPE_EXEC;
+ } else if (strcmp(type, "Sequence") == 0) {
+ _EXTERN_FUNC_EXIT;
+ return COMMAND_TYPE_SEQUENCE;
+ } else if (strcmp(type, "Atomic") == 0) {
+ _EXTERN_FUNC_EXIT;
+ return COMMAND_TYPE_ATOMIC;
+ } else if (strcmp(type, "Copy") == 0) {
+ _EXTERN_FUNC_EXIT;
+ return COMMAND_TYPE_COPY;
+ }
+ _EXTERN_FUNC_EXIT;
+ return COMMAND_TYPE_UNKNOWN;
+}
+
+char *convertfromcommandtype(CommandType type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ char *commandType = NULL;
+
+ switch (type) {
+ case COMMAND_TYPE_ALERT:
+ commandType = "Alert";
+ break;
+ case COMMAND_TYPE_HEADER:
+ commandType = "SyncHdr";
+ break;
+ case COMMAND_TYPE_ADD:
+ commandType = "Add";
+ break;
+ case COMMAND_TYPE_REPLACE:
+ commandType = "Replace";
+ break;
+ case COMMAND_TYPE_DELETE:
+ commandType = "Delete";
+ break;
+ case COMMAND_TYPE_RESULTS:
+ commandType = "Results";
+ break;
+ case COMMAND_TYPE_GET:
+ commandType = "Get";
+ break;
+ case COMMAND_TYPE_EXEC:
+ commandType = "Exec";
+ break;
+ case COMMAND_TYPE_ATOMIC:
+ commandType = "Atomic";
+ break;
+ case COMMAND_TYPE_SEQUENCE:
+ commandType = "Sequence";
+ break;
+ case COMMAND_TYPE_COPY:
+ commandType = "Copy";
+ break;
+ default:
+ commandType = "UNKNOWN";
+ }
+ _EXTERN_FUNC_EXIT;
+ return commandType;
+}
+
+ChangeType convertToChangeTypeFromCommandType(CommandType type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ ChangeType changeType = CHANGE_UNKNOWN;
+ switch (type) {
+
+ case COMMAND_TYPE_ADD:
+ changeType = CHANGE_ADD;
+ break;
+ case COMMAND_TYPE_REPLACE:
+ changeType = CHANGE_REPLACE;
+ break;
+ case COMMAND_TYPE_DELETE:
+ changeType = CHANGE_DELETE;
+ break;
+ case COMMAND_TYPE_COPY:
+ changeType = CHANGE_COPY;
+ break;
+ case COMMAND_TYPE_UNKNOWN:
+ case COMMAND_TYPE_ALERT:
+ case COMMAND_TYPE_HEADER:
+ case COMMAND_TYPE_GET:
+ case COMMAND_TYPE_RESULTS:
+ case COMMAND_TYPE_EXEC:
+ case COMMAND_TYPE_SEQUENCE:
+ case COMMAND_TYPE_ATOMIC:
+ _DEBUG_INFO("not changetype command");
+ break;
+ default:
+ break;
+ }
+ _EXTERN_FUNC_EXIT;
+ return changeType;
+}
+
+CommandType convertToCommandTypeFromChangeType(ChangeType type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ CommandType commandType = COMMAND_TYPE_UNKNOWN;
+
+ switch (type) {
+ case CHANGE_UNKNOWN:
+ commandType = COMMAND_TYPE_UNKNOWN;
+ break;
+ case CHANGE_ADD:
+ commandType = COMMAND_TYPE_ADD;
+ break;
+ case CHANGE_REPLACE:
+ commandType = COMMAND_TYPE_REPLACE;
+ break;
+ case CHANGE_DELETE:
+ commandType = COMMAND_TYPE_DELETE;
+ break;
+ case CHANGE_COPY:
+ commandType = COMMAND_TYPE_COPY;
+ break;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return commandType;
+
+}
+
+DM_ERROR create_newstatuslocation(Session * session, DM_ERROR data, Command * command, Location * sourceref, Location * targetref, CommandType type, Status ** pStatus)
+{
+
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((session) == NULL, COMMON_ERR_IS_NULL, "session is NULL!!");
+ retvm_if((command) == NULL, COMMON_ERR_IS_NULL, "command is NULL!!");
+
+ ret = create_status(data, session->cmdID, session->lastRecievedMsgID, command->cmdID, sourceref, targetref, NULL, type, pStatus);
+ if (ret != DM_OK)
+ goto error;
+
+ session->cmdID++;
+ _DEBUG_INFO("session cmdId : %d", session->cmdID);
+
+ _DEBUG_INFO(" end %d\n", data);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR create_newstatus(Session * session, DM_ERROR data, Command * command, Location * sourceref, Location * targetref, CommandType type, Status ** pStatus)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((session) == NULL, COMMON_ERR_IS_NULL, "session is NULL!!");
+ retvm_if((command) == NULL, COMMON_ERR_IS_NULL, "command is NULL!!");
+
+ ret = create_status(data, session->cmdID, session->lastRecievedMsgID, command->cmdID, sourceref, targetref, NULL, type, pStatus);
+ if (ret != DM_OK)
+ goto error;
+
+ session->cmdID++;
+ _DEBUG_INFO("session cmdId : %d", session->cmdID);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR create_status(DM_ERROR data, unsigned int cmdID, unsigned int msgref, unsigned int cmdref, Location * sourceref, Location * targetref, Chal * pChal, CommandType type, Status ** pStatus)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ _DEBUG_INFO("cmdref : %d msgref : %d", cmdref, msgref);
+ _DEBUG_INFO("create status : %d", data);
+
+ *pStatus = (Status *) calloc(1, sizeof(Status));
+ if (*pStatus == NULL) {
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+
+ (*pStatus)->cmdID = cmdID;
+ (*pStatus)->msgRef = msgref;
+ (*pStatus)->cmdRef = cmdref;
+ (*pStatus)->type = type;
+
+ (*pStatus)->data = g_strdup_printf("%d", data);
+
+ if (sourceref != NULL) {
+ (*pStatus)->sourceRef = dup_location(sourceref);
+ }
+
+ if (targetref != NULL) {
+ (*pStatus)->targetRef = dup_location(targetref);
+ if (targetref->locName != NULL) {
+ _DEBUG_INFO("targetref : %s", targetref->locName);
+ }
+ if (targetref->locURI != NULL) {
+ _DEBUG_INFO("targetref : %s", targetref->locURI);
+ }
+ }
+
+ if (pChal != NULL)
+ (*pStatus)->chal = dup_chal(pChal);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR set_status_data(Session * session, Command * pCommand, Item * item, DM_ERROR data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "session is NULL!!");
+ retvm_if((pCommand) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "pCommand is NULL!!");
+ retvm_if((item) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "item is NULL!!");
+
+ GList *status_iter = NULL;
+ Status *temp = NULL;
+ char *target_url = get_location_locuri(item->target);
+
+ for (status_iter = session->status; status_iter != NULL; status_iter = g_list_next(status_iter)) {
+ temp = status_iter->data;
+
+ if (pCommand->cmdID == temp->cmdRef && strcmp(temp->targetRef->locURI, target_url) == 0) {
+ status_iter->data = g_strdup_printf("%d", data);
+ break;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR set_resultscommand_msgref(Command * pCommand, unsigned int msgRef)
+{
+
+ _EXTERN_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((pCommand) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "pCommand is NULL!!");
+
+ pCommand->private.results.msgRef = msgRef;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+DM_ERROR set_resultscommand_cmdref(Command * pCommand, unsigned int cmdRef)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((pCommand) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "pCommand is NULL!!");
+
+ pCommand->private.results.cmdRef = cmdRef;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+DM_ERROR set_resultscommand_targetref(Command * pCommand, Location * pLocation)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((pCommand) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "pCommand is NULL!!");
+ retvm_if((pLocation) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "pLocation is NULL!!");
+
+ pCommand->private.results.targetRef = dup_location(pLocation);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
diff --git a/src/agent/serviceadapter/sa_elements.c b/src/agent/serviceadapter/sa_elements.c
new file mode 100644
index 0000000..8f38723
--- /dev/null
+++ b/src/agent/serviceadapter/sa_elements.c
@@ -0,0 +1,766 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "serviceadapter/protocolbinder/syncml_def.h"
+#include "serviceadapter/sa_elements.h"
+#include "serviceadapter/sa_elements_internal.h"
+#include "serviceadapter/sa_session_internal.h"
+#include "serviceadapter/sa_command.h"
+#include "mo-handler/dm_mo_common.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_SA"
+#endif
+
+DM_ERROR create_hmac(char *auth_name, char *auth_type, char *mac, Session ** session)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((auth_name) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "auth_name is NULL!!");
+ retvm_if((auth_type) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "auth_type is NULL!!");
+ retvm_if((mac) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "mac is NULL!!");
+
+ if ((*session)->reqhmacinfo == NULL) {
+ (*session)->reqhmacinfo = (Hmac *) calloc(1, sizeof(Hmac));
+ if ((*session)->reqhmacinfo == NULL) {
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+ }
+
+ if ((*session)->reqhmacinfo->username != NULL) {
+ str_free(&(*session)->reqhmacinfo->username);
+ }
+ if ((*session)->reqhmacinfo->authtype != NULL) {
+ str_free(&(*session)->reqhmacinfo->authtype);
+ }
+ if ((*session)->reqhmacinfo->mac != NULL) {
+ str_free(&(*session)->reqhmacinfo->mac);
+ }
+
+ (*session)->reqhmacinfo->username = strdup(auth_name);
+ (*session)->reqhmacinfo->authtype = strdup(auth_type);
+ (*session)->reqhmacinfo->mac = strdup(mac);
+
+ _DEBUG_INFO("user name : %s", auth_name);
+ _DEBUG_INFO("auth type : %s", auth_type);
+ _DEBUG_INFO("mac : %s", mac);
+
+ _DEBUG_INFO(" end : %d", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO(" end error : %d", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR create_location(const char *locURI, const char *locName, Location ** pLocation)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((locURI) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "locURI is NULL!!");
+ _DEBUG_INFO("start with locURI = %s, locName = %s\n", locURI, locName);
+
+ *pLocation = (Location *) calloc(1, sizeof(Location) + 1);
+ if (*pLocation == NULL) {
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+ (*pLocation)->locURI = g_strdup(locURI);
+
+ if (locName != NULL) {
+ (*pLocation)->locName = g_strdup(locName);
+ }
+
+ _DEBUG_INFO("end");
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+Location *dup_location(Location * pLocation)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((pLocation) == NULL, NULL, "pLocation is NULL!!");
+
+ Location *location = NULL;
+ ret = create_location(pLocation->locURI, pLocation->locName, &location);
+ if (ret != DM_OK)
+ goto error;
+
+ _EXTERN_FUNC_EXIT;
+ return location;
+
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+
+}
+
+char *get_location_locname(Location * location)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((location) == NULL, NULL, "location is NULL!!");
+
+ _EXTERN_FUNC_EXIT;
+
+ return location->locName;
+}
+
+char *get_location_locuri(Location * location)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((location) == NULL, NULL, "location is NULL!!");
+
+ _EXTERN_FUNC_EXIT;
+
+ return location->locURI;
+}
+
+void free_location(Location * loc)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if((loc) == NULL, "loc is NULL!!");
+
+ if (loc->locURI != NULL) {
+ _DEBUG_INFO(" loc->locURI = %s\n", loc->locURI);
+ free(loc->locURI);
+ loc->locURI = NULL;
+ }
+
+ if (loc->locName != NULL) {
+ _DEBUG_INFO(" loc->locName = %s\n", loc->locName);
+ free(loc->locName);
+ loc->locName = NULL;
+ }
+ if (loc != NULL) {
+ free(loc);
+ loc = NULL;
+ }
+ _EXTERN_FUNC_EXIT;
+}
+
+void free_cred(Cred * cred)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (cred == NULL)
+ return;
+
+ if (cred->data != NULL) {
+ free(cred->data);
+ cred->data = NULL;
+ }
+
+ if (cred->username != NULL) {
+ free(cred->username);
+ cred->username = NULL;
+ }
+
+ if (cred->password != NULL) {
+ free(cred->password);
+ cred->password = NULL;
+ }
+ if (cred != NULL) {
+ free(cred);
+ cred = NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+DM_ERROR create_auth_cred(char *userName, char *pwd, AuthType authType, FormatType formatType, char *data, Cred ** cred)
+{
+
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((userName) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "userName is NULL!!");
+ retvm_if((pwd) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "pwd is NULL!!");
+
+ _DEBUG_INFO(" user : %s , pwd : %s, authtype : %d,. formattype : %d, cred : %s\n", userName, pwd, authType, formatType, data);
+
+ if (strlen(userName) == 0 || strlen(pwd) == 0) {
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ if (data != NULL) {
+ *cred = (Cred *) calloc(1, sizeof(Cred));
+ if (*cred == NULL) {
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+
+ (*cred)->type = authType;
+ (*cred)->format = formatType;
+ (*cred)->username = strdup(userName);
+ (*cred)->password = strdup(pwd);
+
+ (*cred)->data = strdup(data);
+ } else if (data == NULL && authType == AUTH_TYPE_HMAC) {
+ /* hmac */
+ } else {
+ /*error */
+ ret = COMMON_ERR_IS_NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+Cred *create_credwithdata(AuthType authType, char *data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((data) == NULL, NULL, "data is NULL!!");
+
+ Cred *cred = (Cred *) calloc(1, sizeof(Cred));
+ if (cred == NULL) {
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+
+ cred->type = authType;
+ cred->data = strdup(data);
+
+ _EXTERN_FUNC_EXIT;
+ return cred;
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+
+}
+
+void set_credformattype(Cred * cred, FormatType formatType)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if((cred) == NULL, "cred is NULL!!");
+
+ cred->format = formatType;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+DM_ERROR check_server_cred(Cred * hdrCred, Session * session) //Cred *sessionCred)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((hdrCred) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "hdrCred is NULL!!");
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "session is NULL!!");
+
+ char *server_id;
+ char *server_pwd;
+ char *sourceUrl;
+ char *targetUrl;
+ int isBase64;
+ char *nextNonce;
+ char *authType;
+
+ ret = get_server_dmacc(session->pServer_id, &server_id, &server_pwd, &sourceUrl, &targetUrl, &isBase64, &nextNonce, &authType);
+ if (ret != DM_OK)
+ goto error;
+ _DEBUG_INFO("packet server pw data : %s", hdrCred->data);
+ _DEBUG_INFO("server pw : %s", server_pwd);
+ if (hdrCred->data != NULL) {
+ if (strcmp(hdrCred->data, server_pwd) == 0) {
+ ret = DM_OK;
+ } else {
+ ret = DM_ERR_UNAUTHORIZED;
+ }
+ } else {
+ //do nothing
+ }
+ str_free(&server_id);
+ str_free(&server_pwd);
+ str_free(&sourceUrl);
+ str_free(&targetUrl);
+ str_free(&nextNonce);
+ str_free(&authType);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO(" end error : %d", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR create_chal(FormatType format, AuthType type, char *nextnonce, Chal ** pChal)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((nextnonce) == NULL, COMMON_ERR_INTERNAL_NO_MEMORY, "nextnonce is NULL!!");
+ _DEBUG_INFO("start with format = %d, type = %d Nextnonce = %s\n", format, type, nextnonce);
+
+ DM_ERROR ret = DM_OK;
+
+ *pChal = (Chal *) calloc(1, sizeof(Chal));
+ if (*pChal == NULL) {
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+
+ (*pChal)->format = format;
+ (*pChal)->type = type;
+ if (type == AUTH_TYPE_MD5 || type == AUTH_TYPE_HMAC) {
+ (*pChal)->nonce_plain = g_strdup(nextnonce);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+void free_chal(Chal * pChal)
+{
+ _EXTERN_FUNC_ENTER;
+ if (pChal == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+
+ pChal->format = 0;
+ pChal->type = 0;
+ pChal->nonce_length = 0;
+
+ if (pChal->nonce_plain != NULL) {
+ free(pChal->nonce_plain);
+ pChal->nonce_plain = NULL;
+ }
+
+ if (pChal->nonce_b64 != NULL) {
+ free(pChal->nonce_b64);
+ pChal->nonce_b64 = NULL;
+ }
+
+ if (pChal != NULL) {
+ free(pChal);
+ pChal = NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+Chal *dup_chal(Chal * pChal)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((pChal) == NULL, NULL, "pChal is NULL!!");
+
+ Chal *temp = (Chal *) calloc(1, sizeof(Chal));
+ if (temp == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+
+ temp->type = pChal->type;
+ temp->format = pChal->format;
+
+ if (pChal->nonce_b64 != NULL)
+ temp->nonce_b64 = strdup(pChal->nonce_b64);
+
+ if (pChal->nonce_length != 0)
+ temp->nonce_length = pChal->nonce_length;
+
+ if (pChal->nonce_plain != NULL)
+ temp->nonce_plain = strdup(pChal->nonce_plain);
+
+ _EXTERN_FUNC_EXIT;
+ return temp;
+}
+
+void free_hmac(Hmac * hmac)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (hmac != NULL) {
+ str_free(&(hmac->authtype));
+ str_free(&(hmac->username));
+ str_free(&(hmac->mac));
+
+ free(hmac);
+ hmac = NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+AuthType converttoauthtype(char *authType)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((authType) == NULL, AUTH_TYPE_UNKNOWN, "authType is NULL!!");
+
+ if (strcmp(authType, ELEMENT_AUTH_BASIC) == 0) {
+ _EXTERN_FUNC_EXIT;
+ return AUTH_TYPE_BASIC;
+ } else if (strcmp(authType, ELEMENT_AUTH_MD5) == 0) {
+ _EXTERN_FUNC_EXIT;
+ return AUTH_TYPE_MD5;
+ } else if (strcmp(authType, ELEMENT_AUTH_HMAC) == 0) {
+ _EXTERN_FUNC_EXIT;
+ return AUTH_TYPE_HMAC;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return AUTH_TYPE_UNKNOWN;
+}
+
+FormatType converttoformattype(char *formatType)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((formatType) == NULL, FORMAT_TYPE_UNKNOWN, "formatType is NULL!!");
+
+ if (strcmp(formatType, ELEMENT_FORMAT_BASE64) == 0) {
+ _EXTERN_FUNC_EXIT;
+ return FORMAT_TYPE_BASE64;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return FORMAT_TYPE_UNKNOWN;
+}
+
+DM_ERROR construct_Item(char *sourceUrl, const char *format, const char *contenttype, const char *data, unsigned int size, int moreData, Item ** pItem)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((sourceUrl) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "sourceUrl is NULL!!");
+
+ Location *pLocation = NULL;
+
+ ret = create_item_data((char *)data, size, pItem);
+ if (ret != DM_OK)
+ goto error;
+
+ if (contenttype != NULL)
+ (*pItem)->contenttype = g_strdup(contenttype);
+
+ if (format != NULL)
+ (*pItem)->format = g_strdup(format);
+
+ (*pItem)->moreData = moreData;
+
+ ret = create_location(sourceUrl, NULL, &pLocation);
+ if (ret != DM_OK)
+ goto error;
+
+ set_itemsource((*pItem), pLocation);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+Item *create_Item()
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ Item *item = (Item *) calloc(1, sizeof(Item));
+ if (item == NULL) {
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+
+ item->dataType = ITEM_UNKNOWN;
+
+ _EXTERN_FUNC_EXIT;
+ return item;
+
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+}
+
+DM_ERROR create_item_data(char *data, unsigned int size, Item ** pItem)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ (*pItem) = create_Item();
+ if ((*pItem) == NULL) {
+ ret = COMMON_ERR_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+
+ if (data != NULL) {
+ (*pItem)->private.data = strdup(data);
+ }
+
+ (*pItem)->dataType = ITEM_DATA;
+ (*pItem)->size = size;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+void set_itemtarget(Item * item, Location * target)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if((item) == NULL, "item is NULL!!");
+
+ item->target = target;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void set_itemsource(Item * item, Location * source)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if((item) == NULL, "item is NULL!!");
+
+ item->source = source;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+void free_Item(Item * item)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if((item) == NULL, "item is NULL!!");
+
+ if (item->source != NULL) {
+ free_location(item->source);
+ item->source = NULL;
+ }
+
+ if (item->target != NULL) {
+ free_location(item->target);
+ item->target = NULL;
+ }
+
+ switch (item->dataType) {
+ case ITEM_DATA:
+ if (item->private.data != NULL) {
+ free(item->private.data);
+ item->private.data = NULL;
+ }
+ break;
+ case ITEM_UNKNOWN:
+ //noting to free
+ break;
+ }
+
+ if (item->contenttype != NULL) {
+ free(item->contenttype);
+ item->contenttype = NULL;
+ }
+
+ if (item->format != NULL) {
+ free(item->format);
+ item->format = NULL;
+ }
+
+ free(item);
+ item = NULL;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+DM_ERROR create_syncml(SyncHdr * syncHdr, GList * status, GList * commands, int isFinal, SyncML ** pSyncML)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((syncHdr) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "syncHdr is NULL!!");
+
+ *pSyncML = (SyncML *) calloc(1, sizeof(SyncML));
+ if (*pSyncML == NULL) {
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+
+ (*pSyncML)->hdr = syncHdr;
+ (*pSyncML)->status = status;
+ (*pSyncML)->commands = commands;
+ (*pSyncML)->final = isFinal;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_INFO(" error : %d", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+void free_syncml(SyncML * syncML)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if((syncML) == NULL, "syncML is NULL!!");
+
+ free_synchdr(syncML->hdr);
+ syncML->hdr = NULL;
+
+ free_statuses(syncML->status);
+ syncML->status = NULL;
+
+ free_commands(syncML->commands);
+ syncML->commands = NULL;
+
+ if (syncML != NULL) {
+ free(syncML);
+ syncML = NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+DM_ERROR create_syncml_hdr(Session * session, SyncHdr ** pSyncHdr)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "session is NULL!!");
+
+ if (session->protocolVersion == VERSION_UNKNOWN) {
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ if (session->protocolType != PROTOCOL_TYPE_DM) {
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ if (session->source == NULL) {
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ if (session->target == NULL) {
+ ret = COMMON_ERR_INTERNAL_NOT_DEFINED;
+ goto error;
+ }
+
+ *pSyncHdr = (SyncHdr *) calloc(1, sizeof(SyncHdr));
+
+ if (*pSyncHdr == NULL) {
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+
+ (*pSyncHdr)->version = session->protocolVersion;
+ (*pSyncHdr)->protocol = session->protocolType;
+ (*pSyncHdr)->target = session->target; //don't free free in session free section
+ (*pSyncHdr)->source = session->source; //don't free free in session free section
+
+ if (session->cred != NULL)
+ (*pSyncHdr)->cred = session->cred; //don't free free in session free section
+
+ (*pSyncHdr)->sessionID = strdup(session->sessionID); //free
+ (*pSyncHdr)->messageID = ++session->msgID;
+
+ (*pSyncHdr)->maxmsgsize = session->sourceMaxMsgSize;
+ (*pSyncHdr)->maxobjsize = session->sourceMaxObjSize;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+void free_synchdr(SyncHdr * syncHdr)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if((syncHdr) == NULL, "syncHdr is NULL!!");
+
+ if (syncHdr->sessionID != NULL) {
+ free(syncHdr->sessionID);
+ syncHdr->sessionID = NULL;
+ }
+
+ if (syncHdr->responseURI != NULL) {
+ free(syncHdr->responseURI);
+ syncHdr->responseURI = NULL;
+ }
+
+ syncHdr->source = NULL;
+ syncHdr->target = NULL;
+ syncHdr->cred = NULL;
+
+ if (syncHdr != NULL) {
+ free(syncHdr);
+ syncHdr = NULL;
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
diff --git a/src/agent/serviceadapter/sa_session.c b/src/agent/serviceadapter/sa_session.c
new file mode 100644
index 0000000..acc17d5
--- /dev/null
+++ b/src/agent/serviceadapter/sa_session.c
@@ -0,0 +1,2193 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <string.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "common/dm_common_def.h"
+#include "common/util/util.h"
+#include "framework/ui-event-handler/user-interaction/user_interaction.h"
+#include "serviceadapter/sa_session.h"
+#include "serviceadapter/sa_session_internal.h"
+#include "serviceadapter/sa_elements.h"
+#include "serviceadapter/sa_elements_internal.h"
+#include "serviceadapter/sa_command.h"
+#include "serviceadapter/sa_command_internal.h"
+#include "serviceadapter/dm-phase-handler/dm_phase_handler.h"
+#include "mo-handler/dm_mo_common.h"
+#include "mo-handler/dm_mo_handler.h"
+#include "dm-engine/dm_common_engine.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_SA"
+#endif
+
+//#define DEFAULT_SERVER_MAXMSGSIZE 61440
+#define DEFAULT_SERVER_MAXMSGSIZE 5120
+
+static DM_ERROR _receive_alert_status(Session * session, Status * status);
+static DM_ERROR _receive_results_status(Session * session, Status * status);
+
+static DM_ERROR _receive_alert_cmd(Session * session, Command * command);
+static DM_ERROR _receive_get_cmd(Session * session, Command * command);
+static DM_ERROR _receive_results_cmd(Session * session, Command * command);
+static DM_ERROR _receive_changes_cmd(Session * session, Command * command);
+static DM_ERROR _receive_exec_cmd(Session * session, Command * command);
+static DM_ERROR _receive_atomic_cmd(Session * session, Command * command);
+static DM_ERROR _receice_sequence_cmd(Session * session, Command * command);
+
+static DM_ERROR __receive_get_property_cmd(char *server_id, char *full_path, char *real_full_path, propoerty_type pr_type, Item ** pItem, int *resultStatus);
+static DM_ERROR __rollback_atomic(Session * session, Command * pCommand);
+static DM_ERROR __userInteration_operation(Command * command, GList ** response, int *result_status);
+
+static void _free_pending_statuses(GList * pendingStatus);
+static void __free_pending_status(PendingStatus * pendingStatus);
+
+static void _set_hmac_value(char **key, char *value, int size);
+
+static DM_ERROR _receive_get_cmd(Session * session, Command * command)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "session is NULL!!");
+ retvm_if((command) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "command is NULL!!");
+ retvm_if((command->private.access.items) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "command->private.access.items is NULL!!");
+
+ int resultStatus = DM_OK;
+
+ Status *temp = NULL;
+ Command *pCommand = NULL;
+
+ char *full_path = NULL;
+ int error_acl = 0;
+
+ ret = create_results_cmd(session, &pCommand);
+ if (ret != DM_OK)
+ goto error;
+
+ set_resultscommand_msgref(pCommand, command->msgID);
+ set_resultscommand_cmdref(pCommand, command->cmdID);
+
+ GList *iter = NULL;
+ Item *item = NULL;
+ char *format = NULL;
+ char *contenttype = NULL;
+ char *data = NULL;
+ unsigned int size = 0;
+ int moreData = 0;
+ Item *pItem;
+ int is_mo = 0;
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ /* URL length over size : 414 error */
+ for (iter = command->private.access.items; iter != NULL; iter = g_list_next(iter)) {
+ item = (iter->data);
+
+ if (item == NULL) {
+ _DEBUG_TRACE("item null");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+
+ char *target = get_location_locuri(item->target);
+ if (target != NULL) {
+ full_path = g_strdup(target);
+ }
+
+ GList *pItems = NULL;
+ GetType gettype = GET_TYPE_NOMAL;
+ char *real_full_path = NULL;
+
+ ret = get_type_mo_tree(full_path, &gettype, &real_full_path);
+ if (ret != DM_OK)
+ goto error;
+
+ switch (gettype) {
+ case GET_TYPE_NOMAL:
+ {
+ _DEBUG_TRACE(" get_type_nomal \n");
+
+ err_code = sync_agent_is_exist_mo(full_path, &is_mo);
+ _DEBUG_TRACE("is existed mo : %d", err_code);
+ _DEBUG_TRACE("is mo : %d", is_mo);
+ if (is_mo == 0) {
+ _DEBUG_TRACE("NOT EXIST MO");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ _DEBUG_TRACE("EXIST MO");
+
+ //error_acl = 1;
+ err_code = sync_agent_check_acl_value(full_path, SYNC_AGENT_DM_MO_ACCESSTYPE_GET, session->pServer_id, &error_acl);
+ _DEBUG_TRACE("sync agent acl result : %d", err_code);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ _DEBUG_TRACE("----------------------------------------------------------------------------------------ACL RETURN--------------------------------------------------- : %d", error_acl);
+ if (error_acl == 0) {
+ _DEBUG_TRACE("ACL PERMISSION ERROR");
+ resultStatus = DM_ERR_PERMISSION_DENIED;
+ goto error;
+ } else if (error_acl == 1) {
+ _DEBUG_TRACE("accesstype permission ERROR");
+ resultStatus = DM_ERR_COMMAND_NOT_ALLOWED;
+ goto error;
+ } else {
+ _DEBUG_TRACE("ACL PERMISSION");
+ ret = get_mo_node_format_contenttype(full_path, &format, &contenttype);
+ if (ret != DM_OK)
+ goto error;
+
+ ret = get_mo_data(full_path, &data);
+ if (ret != DM_OK)
+ goto error;
+
+ if (data != NULL) {
+ size = strlen(data);
+ if (session->targetMaxMsgSize - DEFAULT_MORE_REST_SIZE < size) {
+ _DEBUG_TRACE("set more data ");
+ moreData = 1;
+ }
+ }
+
+ ret = construct_Item(full_path, format, contenttype, data, size, moreData, &pItem);
+ if (ret != DM_OK)
+ goto error;
+
+ pCommand->private.results.items = g_list_append(pCommand->private.results.items, pItem);
+ }
+ }
+ break;
+ case GET_TYPE_STRUCT:
+ {
+ _DEBUG_TRACE(" get_type_struct \n");
+ err_code = sync_agent_is_exist_mo(real_full_path, &is_mo);
+ _DEBUG_TRACE("is existed mo : %d", err_code);
+ _DEBUG_TRACE("is mo : %d", is_mo);
+ if (is_mo == 0) {
+ str_free(&real_full_path);
+ _DEBUG_TRACE("NOT EXIST MO");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ _DEBUG_TRACE("EXIST MO");
+
+ //error_acl = 1;
+ err_code = sync_agent_check_acl_value(real_full_path, SYNC_AGENT_DM_MO_ACCESSTYPE_GET, session->pServer_id, &error_acl);
+ _DEBUG_TRACE("sync agent acl result : %d", err_code);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ str_free(&real_full_path);
+ _DEBUG_TRACE("acl get fail");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ _DEBUG_TRACE("----------------------------------------------------------------------------------------ACL RETURN--------------------------------------------------- : %d", error_acl);
+ if (error_acl == 0) {
+ _DEBUG_TRACE("ACL PERMISSION ERROR");
+ resultStatus = DM_ERR_PERMISSION_DENIED;
+ //free_command(pCommand);
+ goto error;
+ } else if (error_acl == 1) {
+ _DEBUG_TRACE("accesstype PERMISSION ERROR");
+ resultStatus = DM_ERR_COMMAND_NOT_ALLOWED;
+ goto error;
+ } else {
+ _DEBUG_TRACE("ACL PERMISSION");
+ ret = get_struct(real_full_path, &pItems);
+ if (ret != DM_OK) {
+ str_free(&real_full_path);
+ goto error;
+ }
+
+ str_free(&real_full_path);
+ pCommand->private.results.items = pItems;
+ }
+ }
+ break;
+ case GET_TYPE_STRUCTDATA:
+ {
+ err_code = sync_agent_is_exist_mo(real_full_path, &is_mo);
+ _DEBUG_TRACE("is existed mo : %d", err_code);
+ _DEBUG_TRACE("is mo : %d", is_mo);
+ if (is_mo == 0) {
+ str_free(&real_full_path);
+ _DEBUG_TRACE("NOT EXIST MO");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ _DEBUG_TRACE("EXIST MO");
+
+ _DEBUG_TRACE(" get_type_structdata \n");
+ //error_acl = 1;
+ err_code = sync_agent_check_acl_value(real_full_path, SYNC_AGENT_DM_MO_ACCESSTYPE_GET, session->pServer_id, &error_acl);
+ _DEBUG_TRACE("sync agent acl result : %d", err_code);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ str_free(&real_full_path);
+ _DEBUG_TRACE("acl get fail");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ _DEBUG_TRACE("----------------------------------------------------------------------------------------ACL RETURN--------------------------------------------------- : %d", error_acl);
+ if (error_acl == 0) {
+ _DEBUG_TRACE("ACL PERMISSION ERROR");
+ resultStatus = DM_ERR_PERMISSION_DENIED;
+ //free_command(pCommand);
+ goto error;
+ } else if (error_acl == 1) {
+ _DEBUG_TRACE("accesstype PERMISSION ERROR");
+ resultStatus = DM_ERR_COMMAND_NOT_ALLOWED;
+ goto error;
+ } else {
+ _DEBUG_TRACE("ACL PERMISSION");
+ ret = get_structdata(real_full_path, &pItems);
+ if (ret != DM_OK) {
+ str_free(&real_full_path);
+ goto error;
+ }
+
+ str_free(&real_full_path);
+ pCommand->private.results.items = pItems;
+ }
+ }
+ break;
+ case GET_TYPE_TNDS:
+ {
+ _DEBUG_TRACE(" get_type_tnds \n");
+ /*xml, wbxml */
+ /*currnt XML */
+ err_code = sync_agent_is_exist_mo(real_full_path, &is_mo);
+ _DEBUG_TRACE("is existed mo : %d", err_code);
+ if (is_mo == 0) {
+ str_free(&real_full_path);
+ _DEBUG_TRACE("NOT EXIST MO");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ _DEBUG_TRACE("EXIST MO");
+
+ //error_acl = 1;
+ err_code = sync_agent_check_acl_value(real_full_path, SYNC_AGENT_DM_MO_ACCESSTYPE_GET, session->pServer_id, &error_acl);
+ _DEBUG_TRACE("sync agent acl result : %d", err_code);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ str_free(&real_full_path);
+ _DEBUG_TRACE("acl get fail");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ _DEBUG_TRACE("----------------------------------------------------------------------------------------ACL RETURN--------------------------------------------------- : %d", error_acl);
+ if (error_acl == 0) {
+ _DEBUG_TRACE("ACL PERMISSION ERROR");
+ resultStatus = DM_ERR_PERMISSION_DENIED;
+ //free_command(pCommand);
+ goto error;
+ } else if (error_acl == 1) {
+ _DEBUG_TRACE("accesstype PERMISSION ERROR");
+ resultStatus = DM_ERR_COMMAND_NOT_ALLOWED;
+ goto error;
+ } else {
+ _DEBUG_TRACE("ACL PERMISSION");
+ const char *format = ELEMENT_XML;
+ const char *contenttype = ELEMENT_DMTNDS_XML;
+ char *output_stream = NULL;
+ unsigned int size = 0;
+ int moreData = 0;
+ Item *pItem;
+
+ ret = get_tnds(ELEMENT_DMTNDS_XML, full_path, &output_stream, &size);
+ if (ret != DM_OK)
+ goto error;
+
+ _DEBUG_TRACE("max size : %d", session->targetMaxMsgSize);
+ _DEBUG_TRACE("data size : %d", size);
+ if (output_stream != NULL && session->targetMaxMsgSize - DEFAULT_MORE_REST_SIZE < size) {
+ _DEBUG_TRACE("set more data ");
+ moreData = 1;
+ }
+
+ ret = construct_Item(real_full_path, format, contenttype, output_stream, size, moreData, &pItem);
+ if (ret != DM_OK) {
+ str_free(&real_full_path);
+ goto error;
+ }
+
+ str_free(&real_full_path);
+ _DEBUG_TRACE("add cmd item");
+ pCommand->private.results.items = g_list_append(pCommand->private.results.items, pItem);
+ }
+ }
+ break;
+ case GET_TYPE_ACL_PROP:
+ {
+ ret = __receive_get_property_cmd(session->pServer_id, full_path, real_full_path, PROP_TYPE_ACL, &pItem, &resultStatus);
+ if (ret != DM_OK || resultStatus != DM_OK) {
+ str_free(&real_full_path);
+ goto error;
+ }
+ str_free(&real_full_path);
+ _DEBUG_TRACE("add cmd item");
+ pCommand->private.results.items = g_list_append(pCommand->private.results.items, pItem);
+ }
+ break;
+ case GET_TYPE_SIZE_PROP:
+ {
+ ret = __receive_get_property_cmd(session->pServer_id, full_path, real_full_path, PROP_TYPE_SIZE, &pItem, &resultStatus);
+ if (ret != DM_OK || resultStatus != DM_OK) {
+ str_free(&real_full_path);
+ goto error;
+ }
+ str_free(&real_full_path);
+ _DEBUG_TRACE("add cmd item");
+ pCommand->private.results.items = g_list_append(pCommand->private.results.items, pItem);
+ }
+ break;
+ case GET_TYPE_TYPE_PROP:
+ {
+ ret = __receive_get_property_cmd(session->pServer_id, full_path, real_full_path, PROP_TYPE_TYPE, &pItem, &resultStatus);
+ if (ret != DM_OK || resultStatus != DM_OK) {
+ str_free(&real_full_path);
+ goto error;
+ }
+ str_free(&real_full_path);
+ _DEBUG_TRACE("add cmd item");
+ pCommand->private.results.items = g_list_append(pCommand->private.results.items, pItem);
+ }
+ break;
+ case GET_TYPE_FORMAT_PROP:
+ {
+ ret = __receive_get_property_cmd(session->pServer_id, full_path, real_full_path, PROP_TYPE_FORMAT, &pItem, &resultStatus);
+ if (ret != DM_OK || resultStatus != DM_OK) {
+ str_free(&real_full_path);
+ goto error;
+ }
+ str_free(&real_full_path);
+ _DEBUG_TRACE("add cmd item");
+ pCommand->private.results.items = g_list_append(pCommand->private.results.items, pItem);
+ }
+ break;
+ case GET_TYPE_NAME_PROP:
+ {
+ ret = __receive_get_property_cmd(session->pServer_id, full_path, real_full_path, PROP_TYPE_NAME, &pItem, &resultStatus);
+ if (ret != DM_OK || resultStatus != DM_OK) {
+ str_free(&real_full_path);
+ goto error;
+ }
+ str_free(&real_full_path);
+ _DEBUG_TRACE("add cmd item");
+ pCommand->private.results.items = g_list_append(pCommand->private.results.items, pItem);
+ }
+ break;
+
+ default:
+ _DEBUG_TRACE(" get_type_default \n");
+ break;
+ }
+
+ session->resultsCommand = g_list_append(session->resultsCommand, pCommand);
+ _DEBUG_TRACE("add session result command result command list length : %d", g_list_length(session->resultsCommand));
+
+ ret = create_newstatus(session, resultStatus, command, item->source, item->target, COMMAND_TYPE_GET, &temp);
+ if (ret != DM_OK)
+ goto error;
+
+ session->status = g_list_append(session->status, temp);
+
+ str_free(&full_path);
+
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+
+ str_free(&full_path);
+ free_command(pCommand);
+ _DEBUG_TRACE(" error : %d\n", ret);
+
+ if (item != NULL) {
+ ret = create_newstatus(session, resultStatus, command, item->source, item->target, COMMAND_TYPE_GET, &temp);
+ if (ret != DM_OK)
+ goto ex_error;
+ } else {
+ ret = create_newstatus(session, resultStatus, command, command->source, command->target, COMMAND_TYPE_GET, &temp);
+ if (ret != DM_OK)
+ goto ex_error;
+ }
+
+ session->status = g_list_append(session->status, temp);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ ex_error:
+
+ free_status(temp);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+static DM_ERROR __receive_get_property_cmd(char *server_id, char *full_path, char *real_full_path, propoerty_type pr_type, Item ** pItem, int *resultStatus)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((server_id) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "server_id is NULL!!");
+ retvm_if((full_path) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "full_path is NULL!!");
+ retvm_if((real_full_path) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "real_full_path is NULL!!");
+
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+ int is_mo = 0;
+ int error_acl = 0;
+ char *format = NULL;
+ char *contenttype = NULL;
+ int moreData = 0;
+ unsigned int size = 0;
+
+ _DEBUG_TRACE(" get property ");
+
+ err_code = sync_agent_is_exist_mo(real_full_path, &is_mo);
+ _DEBUG_TRACE("is existed mo : %d", err_code);
+ if (is_mo == 0) {
+ _DEBUG_TRACE("NOT EXIST MO");
+ *resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ _DEBUG_TRACE("EXIST MO");
+
+ //error_acl = 1;
+ err_code = sync_agent_check_acl_value(real_full_path, SYNC_AGENT_DM_MO_ACCESSTYPE_GET, server_id, &error_acl);
+ _DEBUG_TRACE("sync agent acl result : %d", err_code);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_TRACE("acl get fail");
+ *resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ _DEBUG_TRACE("----------------------------------------------------------------------------------------ACL RETURN--------------------------------------------------- : %d", error_acl);
+ if (error_acl == 0) {
+ _DEBUG_TRACE("ACL PERMISSION ERROR");
+ *resultStatus = DM_ERR_PERMISSION_DENIED;
+ //free_command(pCommand);
+ goto error;
+ } else if (error_acl == 1) {
+ _DEBUG_TRACE("accesstype PERMISSION ERROR");
+ *resultStatus = DM_ERR_COMMAND_NOT_ALLOWED;
+ goto error;
+ } else {
+ _DEBUG_TRACE("ACL PERMISSION");
+
+ ret = get_mo_node_format_contenttype(real_full_path, &format, &contenttype);
+ if (ret != DM_OK)
+ goto error;
+
+ char *property = NULL;
+ ret = get_mo_node_property(real_full_path, pr_type, &property);
+ if (ret != DM_OK) {
+ *resultStatus = DM_ERR_PERMISSION_DENIED;
+ //str_free(&real_full_path);
+ goto error;
+ }
+ _DEBUG_TRACE("property value : %s", property);
+ ret = construct_Item(full_path, format, contenttype, property, size, moreData, pItem);
+ if (ret != DM_OK)
+ goto error;
+ }
+
+ _DEBUG_TRACE(" end %d", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+ error:
+
+ _DEBUG_TRACE(" end eror : %d", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static DM_ERROR _receive_alert_cmd(Session * session, Command * command)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "session is NULL!!");
+ retvm_if((command) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "command is NULL!!");
+
+ Status *temp = NULL;
+ int result_status = DM_OK;
+ GList *response = NULL;
+
+ int alert_data = command->private.alert.type; //atoi(item->private.data);
+
+ if (DM_ALERT_DISPLAY <= alert_data && DM_ALERT_MULTIPLE_CHOICE >= alert_data) {
+ _DEBUG_TRACE("alert ui");
+ ret = __userInteration_operation(command, &response, &result_status);
+ _DEBUG_TRACE("status : %d", result_status);
+
+ } else if (DM_ALERT_NEXT_MESSAGE <= alert_data && DM_ALERT_MULTIPLE_CHOICE > alert_data) {
+ _DEBUG_TRACE("result status : %d", result_status);
+ goto error;
+ }
+
+ if (ret != DM_OK) {
+ ret = DM_OK;
+ result_status = DM_ERR_NOT_EXECUTED;
+ goto error;
+ }
+
+ ret = create_newstatus(session, result_status, command, command->source, command->target, COMMAND_TYPE_ALERT, &temp);
+ if (ret != DM_OK) {
+ goto ex_error;
+ }
+
+ switch (alert_data) {
+ case DM_ALERT_DISPLAY:
+ case DM_ALERT_CONFIRM_OR_REJECT:
+ break;
+ case DM_ALERT_TEXT_INPUT:
+ case DM_ALERT_SINGLE_CHOICE:
+ case DM_ALERT_MULTIPLE_CHOICE:
+ {
+ Item *pItem = NULL;
+ GList *iter = NULL;
+
+ if (response != NULL) {
+ _DEBUG_TRACE("--------------------response data existed--------------------");
+ for (iter = response; iter != NULL; iter = g_list_next(iter)) {
+ if (iter->data != NULL) {
+ char *value = NULL;
+ value = strdup((char *)iter->data);
+ ret = create_item_data(value, strlen(value), &pItem);
+ if (ret != DM_OK) {
+ if (temp->data != NULL) {
+ str_free(&(temp->data));
+ }
+ temp->data = g_strdup_printf("%d", DM_ERR_NOT_EXECUTED);
+ goto return_part;
+ }
+
+ temp->items = g_list_append(temp->items, pItem);
+ }
+ }
+ } else {
+ _DEBUG_TRACE("--------------------response data not existed--------------------");
+ //do nothing
+ }
+ }
+ break;
+
+ }
+
+ return_part:
+
+ session->status = g_list_append(session->status, temp);
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ error:
+
+ ret = create_newstatus(session, result_status, command, command->source, command->target, COMMAND_TYPE_ALERT, &temp);
+ if (ret != DM_OK) {
+ goto ex_error;
+ }
+
+ session->status = g_list_append(session->status, temp);
+ _DEBUG_TRACE(" error : %d\n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ ex_error:
+ free_status(temp);
+ _DEBUG_TRACE(" error : %d\n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static DM_ERROR _receive_results_cmd(Session * session, Command * command)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+}
+
+static DM_ERROR _receive_changes_cmd(Session * session, Command * command)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "session is NULL!!");
+ retvm_if((command) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "command is NULL!!");
+
+ ChangeType type = command->private.change.type;
+ _DEBUG_TRACE(" start command type : %d\n", type);
+
+ int resultStatus = DM_OK;
+ int error_acl = 0;
+ int is_mo = 0;
+ GList *item_iter = NULL;
+ Item *item = NULL;
+ char *targetUrl = NULL;
+ char *sourceUrl = NULL;
+ Status *temp = NULL;
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+
+ char *real_full_path = NULL;
+ GetType gettype = GET_TYPE_NOMAL;
+
+ for (item_iter = command->private.change.items; item_iter != NULL; item_iter = g_list_next(item_iter)) {
+ item = item_iter->data;
+ targetUrl = NULL;
+ targetUrl = get_location_locuri(item->target);
+
+ switch (type) {
+ case CHANGE_ADD:
+ _DEBUG_TRACE(" add command \n");
+ err_code = sync_agent_is_exist_mo(targetUrl, &is_mo);
+ _DEBUG_TRACE("is exist result : %d", err_code);
+ _DEBUG_TRACE("is mo : %d", is_mo);
+ if (is_mo == 1) {
+ resultStatus = DM_ERR_ALEADY_EXISTS;
+ goto error;
+ } else {
+ //error_acl = 1;
+ err_code = sync_agent_check_acl_value(targetUrl, SYNC_AGENT_DM_MO_ACCESSTYPE_ADD, session->pServer_id, &error_acl);
+ _DEBUG_TRACE("sync agent acl result : %d", err_code);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ if (err_code == SYNC_AGENT_DM_MO_NOT_EXIST_NODE) {
+ error_acl = 2;
+ } else {
+ resultStatus = DM_ERR_PERMISSION_DENIED;
+ goto error;
+ }
+ }
+ _DEBUG_TRACE("----------------------------------------------------------------------------------------ACL RETURN--------------------------------------------------- : %d", error_acl);
+ if (error_acl == 0) {
+ _DEBUG_TRACE("ACL PERMISSION ERROR");
+ resultStatus = DM_ERR_PERMISSION_DENIED;
+ goto error;
+ } else if (error_acl == 1) {
+ _DEBUG_TRACE("accesstype PERMISSION ERROR");
+ resultStatus = DM_ERR_COMMAND_NOT_ALLOWED;
+ goto error;
+ } else {
+ _DEBUG_TRACE("ACL PERMISSION");
+ ret = add_itemtomo(item, session->pServer_id);
+ if (ret != DM_OK)
+ goto error;
+ }
+ }
+
+ break;
+ case CHANGE_REPLACE:
+ _DEBUG_TRACE(" replace command \n");
+
+ ret = get_type_mo_tree(targetUrl, &gettype, &real_full_path);
+ if (ret != DM_OK)
+ goto error;
+
+ switch (gettype) {
+ case GET_TYPE_NOMAL:
+ {
+ _DEBUG_TRACE("nomal type : %d", gettype);
+ err_code = sync_agent_is_exist_mo(targetUrl, &is_mo);
+ _DEBUG_TRACE("is existed mo: %d, result: %d", is_mo, err_code);
+ if (is_mo == 0) {
+ _DEBUG_TRACE("NOT EXIST MO");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ //error_acl = 1;
+ err_code = sync_agent_check_acl_value(targetUrl, SYNC_AGENT_DM_MO_ACCESSTYPE_REPLACE, session->pServer_id, &error_acl);
+ _DEBUG_TRACE("sync agent acl result : %d", err_code);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_TRACE("acl get fail");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ _DEBUG_TRACE("----------------------------------------------------------------------------------------ACL RETURN--------------------------------------------------- : %d", error_acl);
+ if (error_acl == 0) {
+ _DEBUG_TRACE("ACL PERMISSION ERROR");
+ resultStatus = DM_ERR_PERMISSION_DENIED;
+ goto error;
+ } else if (error_acl == 1) {
+ _DEBUG_TRACE("accesstype PERMISSION ERROR");
+ resultStatus = DM_ERR_COMMAND_NOT_ALLOWED;
+ goto error;
+ } else {
+ _DEBUG_TRACE("ACL PERMISSION");
+ ret = check_mo_scope(targetUrl);
+ if (ret != DM_OK) {
+ resultStatus = ret;
+ goto error;
+ } else {
+ ret = replace_itemtomo(item);
+ if (ret != DM_OK)
+ goto error;
+ }
+ }
+ }
+ break;
+ case GET_TYPE_ACL_PROP:
+ {
+ _DEBUG_TRACE(" property type : %d", gettype);
+ err_code = sync_agent_is_exist_mo(real_full_path, &is_mo);
+ _DEBUG_TRACE("is existed mo : %d", err_code);
+ if (is_mo == 0) {
+ _DEBUG_TRACE("NOT EXIST MO");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ /*do not check acl for replace property */
+ /*err_code = sync_agent_check_acl_value(real_full_path, SYNC_AGENT_DM_MO_ACCESSTYPE_REPLACE, session->pServer_id, &error_acl);
+ _DEBUG_TRACE("sync agent acl result : %d", err_code);
+ if(err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ */
+ /* error_acl = 2;
+ _DEBUG_TRACE("----------------------------------------------------------------------------------------ACL RETURN--------------------------------------------------- : %d", error_acl);
+ if(error_acl == 0) {
+ _DEBUG_TRACE("ACL PERMISSION ERROR");
+ resultStatus = DM_ERR_PERMISSION_DENIED;
+ goto error;
+ } else if(error_acl == 1) {
+ _DEBUG_TRACE("accesstype PERMISSION ERROR");
+ resultStatus = DM_ERR_COMMAND_NOT_ALLOWED;
+ goto error;
+ } else { */
+ _DEBUG_TRACE("----------------------------------------------------------------------------------------ACL RETURN--------------------------------------------------- : %d", 2);
+ ret = check_mo_scope(real_full_path);
+ if (ret != DM_OK) {
+ resultStatus = ret;
+ goto error;
+ } else {
+ //check_scope == 1 (dynamic)
+ ret = replace_itemtomo(item);
+ if (ret != DM_OK)
+ goto error;
+ }
+ //}
+ }
+ break;
+ case GET_TYPE_NAME_PROP:
+ case GET_TYPE_TYPE_PROP:
+ case GET_TYPE_FORMAT_PROP:
+ case GET_TYPE_SIZE_PROP:
+ {
+ _DEBUG_TRACE(" property type : %d", gettype);
+ err_code = sync_agent_is_exist_mo(real_full_path, &is_mo);
+ _DEBUG_TRACE("is existed mo : %d", err_code);
+ if (is_mo == 0) {
+ _DEBUG_TRACE("NOT EXIST MO");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ resultStatus = DM_ERR_COMMAND_NOT_ALLOWED;
+ }
+ break;
+ default:
+ _DEBUG_TRACE("replace type error");
+ break;
+ }
+ break;
+ case CHANGE_DELETE:
+ _DEBUG_TRACE(" delete command \n");
+ err_code = sync_agent_is_exist_mo(targetUrl, &is_mo);
+ _DEBUG_TRACE("is existed mo : %d", err_code);
+ if (is_mo == 0) {
+ _DEBUG_TRACE("NOT EXIST MO");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ } else {
+
+ //error_acl = 1;
+ err_code = sync_agent_check_acl_value(targetUrl, SYNC_AGENT_DM_MO_ACCESSTYPE_DELETE, session->pServer_id, &error_acl);
+ _DEBUG_TRACE("sync agent acl result : %d", err_code);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_TRACE("acl get fail");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ _DEBUG_TRACE("----------------------------------------------------------------------------------------ACL RETURN--------------------------------------------------- : %d", error_acl);
+ if (error_acl == 0) {
+ _DEBUG_TRACE("ACL PERMISSION ERROR");
+ resultStatus = DM_ERR_PERMISSION_DENIED;
+ goto error;
+ } else if (error_acl == 1) {
+ _DEBUG_TRACE("accesstype PERMISSION ERROR");
+ resultStatus = DM_ERR_COMMAND_NOT_ALLOWED;
+ goto error;
+ } else {
+ _DEBUG_TRACE("ACL PERMISSION");
+ ret = check_mo_scope(targetUrl);
+ if (ret != DM_OK) {
+ resultStatus = ret;
+ } else {
+ ret = delete_itemtomo(item);
+ if (ret != DM_OK)
+ goto error;
+ }
+ }
+ }
+ break;
+ case CHANGE_COPY:
+ _DEBUG_TRACE(" copy command \n");
+ sourceUrl = NULL;
+ sourceUrl = get_location_locuri(item->source);
+ if (sourceUrl != NULL) {
+ err_code = sync_agent_is_exist_mo(sourceUrl, &is_mo);
+ _DEBUG_TRACE("is existed mo : %d", err_code);
+ if (is_mo == 0) {
+ _DEBUG_TRACE("NOT EXIT MO");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ } else {
+ //error_acl = 1;
+ err_code = sync_agent_check_acl_value(sourceUrl, SYNC_AGENT_DM_MO_ACCESSTYPE_COPY, session->pServer_id, &error_acl);
+ _DEBUG_TRACE("sync agent acl result : %d", err_code);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_TRACE("acl get fail");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ _DEBUG_TRACE("----------------------------------------------------------------------------------------ACL RETURN--------------------------------------------------- : %d", error_acl);
+ if (error_acl == 0) {
+ _DEBUG_TRACE("ACL PERMISSION ERROR");
+ resultStatus = DM_ERR_PERMISSION_DENIED;
+ goto error;
+ } else if (error_acl == 1) {
+ _DEBUG_TRACE("accesstype PERMISSION ERROR");
+ resultStatus = DM_ERR_COMMAND_NOT_ALLOWED;
+ goto error;
+ }
+ err_code = sync_agent_check_acl_value(targetUrl, SYNC_AGENT_DM_MO_ACCESSTYPE_COPY, session->pServer_id, &error_acl);
+ _DEBUG_TRACE("sync agent acl result : %d", err_code);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_TRACE("acl get fail");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ _DEBUG_TRACE("----------------------------------------------------------------------------------------ACL RETURN--------------------------------------------------- : %d", error_acl);
+ if (error_acl == 0) {
+ _DEBUG_TRACE("ACL PERMISSION ERROR");
+ resultStatus = DM_ERR_PERMISSION_DENIED;
+ goto error;
+ } else if (error_acl == 1) {
+ _DEBUG_TRACE("accesstype PERMISSION ERROR");
+ resultStatus = DM_ERR_COMMAND_NOT_ALLOWED;
+ goto error;
+ } else {
+ _DEBUG_TRACE("ACL PERMISSION");
+ ret = copy_itemtomo(item);
+ if (ret != DM_OK)
+ goto error;
+ }
+ }
+ } else {
+ //do nothing
+ }
+ break;
+ default:
+ break;
+ }
+
+ ret = create_newstatus(session, resultStatus, command, item->source, item->target, command->type, &temp);
+ if (ret != DM_OK)
+ goto error;
+ session->status = g_list_append(session->status, temp);
+ }
+
+ str_free(&(real_full_path));
+ _INNER_FUNC_ENTER;
+ return ret;
+
+ error:
+ ret = create_newstatus(session, resultStatus, command, command->source, command->target, command->type, &temp);
+ if (ret != DM_OK)
+ goto ex_error;
+ session->status = g_list_append(session->status, temp);
+
+ str_free(&(real_full_path));
+ _DEBUG_TRACE(" error : %d\n", ret);
+ _INNER_FUNC_ENTER;
+ return ret;
+ ex_error:
+
+ free_status(temp);
+ str_free(&(real_full_path));
+ _DEBUG_TRACE(" error : %d\n", ret);
+ _INNER_FUNC_ENTER;
+ return ret;
+}
+
+static DM_ERROR _receive_exec_cmd(Session * session, Command * command)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "session is NULL!!");
+ retvm_if((command) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "command is NULL!!");
+
+ int resultStatus = DM_ERR_ACCEPTED_FOR_PROCESSING;
+ int error_acl = 0;
+ char *targetUrl = NULL;
+ Item *item = NULL;
+ item = command->private.exec.item;
+ Status *temp = NULL;
+ char *pCorrelator = NULL;
+ char *server_id = NULL;
+ int is_mo = 0;
+ sync_agent_dm_mo_error_e err_code = SYNC_AGENT_DM_MO_SUCCESS;
+
+ _DEBUG_TRACE("----------------------------------------------------------------------------exec cmd --------------------------------------------------------------------------- ");
+ targetUrl = get_location_locuri(command->private.exec.item->target);
+ /*todo: server_id */
+ //error_acl = 1;
+ err_code = sync_agent_is_exist_mo(targetUrl, &is_mo);
+ _DEBUG_TRACE("is existed mo : %d", err_code);
+ if (is_mo == 0) {
+ _DEBUG_TRACE("NOT EXIT MO");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ } else {
+
+ //error_acl = 1;
+ err_code = sync_agent_check_acl_value(targetUrl, SYNC_AGENT_DM_MO_ACCESSTYPE_EXEC, session->pServer_id, &error_acl);
+ _DEBUG_TRACE("sync agent acl result : %d", err_code);
+ if (err_code != SYNC_AGENT_DM_MO_SUCCESS) {
+ _DEBUG_TRACE("acl get fail");
+ resultStatus = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ _DEBUG_TRACE("----------------------------------------------------------------------------------------ACL RETURN--------------------------------------------------- : %d", error_acl);
+ if (error_acl == 0) {
+ _DEBUG_TRACE("ACL PERMISSION ERROR");
+ resultStatus = DM_ERR_PERMISSION_DENIED;
+ goto error;
+ } else if (error_acl == 1) {
+ _DEBUG_TRACE("accesstype PERMISSION ERROR");
+ resultStatus = DM_ERR_COMMAND_NOT_ALLOWED;
+ goto error;
+ } else {
+ _DEBUG_TRACE("ACL PERMISSION");
+ targetUrl = get_location_locuri(item->target);
+ pCorrelator = command->private.exec.correlator;
+ server_id = session->pServer_id;
+
+ ret = engine_start(server_id, targetUrl, pCorrelator, &(session->service_engine_id), &resultStatus);
+ _DEBUG_TRACE("--------------------------------------------------------engine_start off %d-----------------------------------------------------------------\n", ret);
+ if (ret != DM_OK) {
+ //ret = DM_ERR_NOT_FOUND;
+ goto error;
+ }
+ }
+ }
+
+ ret = create_newstatus(session, resultStatus, command, item->source, item->target, COMMAND_TYPE_EXEC, &temp);
+ if (ret != DM_OK)
+ goto ex_error;
+ session->status = g_list_append(session->status, temp);
+
+ _INNER_FUNC_ENTER;
+ return ret;
+
+ error:
+ ret = create_newstatus(session, resultStatus, command, item->source, item->target, COMMAND_TYPE_EXEC, &temp);
+ if (ret != DM_OK)
+ goto ex_error;
+ session->status = g_list_append(session->status, temp);
+
+ _DEBUG_TRACE(" error : %d\n", ret);
+ _INNER_FUNC_ENTER;
+ return ret;
+ ex_error:
+ _DEBUG_TRACE(" error : %d\n", ret);
+ _INNER_FUNC_ENTER;
+ return ret;
+
+}
+
+static DM_ERROR _receice_sequence_cmd(Session * session, Command * command)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "session is NULL!!");
+ retvm_if((command) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "command is NULL!!");
+
+ int resultStatus = DM_OK;
+ //sync_agent_dm_mo_error_e mo_ret = sync_agent_begin_transaction_mo();
+
+ Status *temp = NULL;
+ ret = create_newstatus(session, resultStatus, command, command->source, command->target, COMMAND_TYPE_SEQUENCE, &temp);
+ if (ret != DM_OK)
+ goto error;
+
+ session->status = g_list_append(session->status, temp);
+
+ ret = receive_cmd(session, command->private.sequence_atomic.commands);
+ if (ret != DM_OK) {
+ resultStatus = DM_ERR_COMMAND_FAILED;
+ }
+ //mo_ret = sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_COMMIT);
+
+ _INNER_FUNC_ENTER;
+ return ret;
+
+ error:
+ _DEBUG_TRACE(" error : %d\n", ret);
+ _INNER_FUNC_ENTER;
+ return ret;
+
+}
+
+static DM_ERROR _receive_atomic_cmd(Session * session, Command * command)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "session is NULL!!");
+ retvm_if((command) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "command is NULL!!");
+
+ int resultStatus = DM_ERR_ACCEPTED_FOR_PROCESSING;
+
+ GList *atomic_iter = NULL;
+ Command *pCommand = NULL;
+ Status *temp = NULL;
+ sync_agent_dm_mo_error_e mo_ret = sync_agent_begin_transaction_mo();
+
+ for (atomic_iter = command->private.sequence_atomic.commands; atomic_iter != NULL;) {
+ pCommand = atomic_iter->data;
+
+ if (pCommand->type == COMMAND_TYPE_GET) {
+ ret = create_newstatus(session, DM_ERR_COMMAND_FAILED, pCommand, pCommand->source, pCommand->target, COMMAND_TYPE_GET, &temp);
+ if (ret != DM_OK)
+ goto error;
+
+ session->status = g_list_append(session->status, temp);
+
+ atomic_iter = g_list_next(atomic_iter);
+ command->private.sequence_atomic.commands = g_list_remove(command->private.sequence_atomic.commands, pCommand);
+ }
+ }
+
+ ret = receive_cmd(session, command->private.sequence_atomic.commands);
+ if (ret != DM_OK) {
+ resultStatus = DM_ERR_ATOMIC_FAILED;
+ }
+
+ if (resultStatus == DM_ERR_ACCEPTED_FOR_PROCESSING) {
+ mo_ret = sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_COMMIT);
+ } else {
+ mo_ret = sync_agent_end_transaction_mo(SYNC_AGENT_DM_MO_TRANSACTION_ROLLBACK);
+ __rollback_atomic(session, command);
+ }
+
+ Status *temp_status = NULL;
+ ret = create_newstatus(session, resultStatus, command, pCommand->source, pCommand->target, COMMAND_TYPE_ATOMIC, &temp_status);
+ if (ret != DM_OK)
+ goto error;
+
+ session->status = g_list_append(session->status, temp_status);
+
+ _INNER_FUNC_ENTER;
+ return ret;
+
+ error:
+ _DEBUG_TRACE(" error : %d\n", ret);
+ _INNER_FUNC_ENTER;
+ return ret;
+
+}
+
+static DM_ERROR _receive_alert_status(Session * session, Status * status)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((status) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "status is NULL!!");
+
+ unsigned int code = get_statuscode(status);
+ if (code >= 400 && code != DM_ERR_REQUIRE_REFRESH) {
+ //401 unauthorized
+ //407 Authentication required
+ //405 command not allowed
+ //406 optional feature not supported
+ //500 command failed
+ //412 Incomplete command
+ //415 unsupported media type or format
+ //404 not found ->it have to be considered
+
+ //TODO error handling it's error~!!!!!
+ ret = code;
+ }
+ _DEBUG_TRACE(" end, Error Type : %d\n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static DM_ERROR _receive_results_status(Session * session, Status * status)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((status) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "status is NULL!!");
+
+ unsigned int code = get_statuscode(status);
+ if (code >= 400) {
+ //TODO error handling it's error~!!!!!
+ //401 unauthorized
+ //407 authentication required
+ //404 not found
+ //413 request entity too large
+ //415 unspported media type or format
+ //500 command failed
+ ret = code;
+ }
+
+ _DEBUG_TRACE(" end, Error Type : %d\n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static void _free_pending_statuses(GList * pendingStatus)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if((pendingStatus) == NULL, "pendingStatus is NULL!!");
+
+ GList *iter = NULL;
+ for (iter = pendingStatus; iter != NULL; iter = g_list_next(iter))
+ __free_pending_status(iter->data);
+
+ g_list_free(pendingStatus);
+
+ _INNER_FUNC_EXIT;
+}
+
+static void __free_pending_status(PendingStatus * pendingStatus)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if((pendingStatus) == NULL, "pendingStatus is NULL!!");
+
+ free(pendingStatus);
+ pendingStatus = NULL;
+
+ _INNER_FUNC_EXIT;
+}
+
+DM_ERROR create_syncml_session(ProtocolVersion protocolVersion, ProtocolType protocolType, char *server_id, char *client_id, char *pSession_id, char *pSourceUrl, char *pTargetUrl, Session ** pSession)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((pSourceUrl) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "pSourceUrl is NULL!!");
+ retvm_if((pTargetUrl) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "pTargetUrl is NULL!!");
+
+ *pSession = (Session *) calloc(1, sizeof(Session));
+ if (*pSession == NULL) {
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+
+ (*pSession)->protocolType = protocolType;
+ (*pSession)->protocolVersion = protocolVersion;
+/* (*pSession)->accountId = accountId;*/
+ if (server_id != NULL)
+ (*pSession)->pServer_id = strdup(server_id);
+ (*pSession)->service_engine_id = NO_SERVICE_ENGINE;
+ (*pSession)->sessionID = strdup(pSession_id);
+ (*pSession)->jsessionid = NULL;
+
+ ret = create_location(pSourceUrl, client_id, &((*pSession)->source));
+ if (ret != DM_OK)
+ goto error;
+
+ ret = create_location(pTargetUrl, NULL, &((*pSession)->target));
+ if (ret != DM_OK)
+ goto error;
+
+ (*pSession)->msgID = 0;
+ (*pSession)->cmdID = 1;
+
+ (*pSession)->res_chal = NULL;
+ (*pSession)->req_chal = NULL;
+
+ (*pSession)->isHMAC = 0; /*not using hmac */
+ (*pSession)->reqhmacinfo = (Hmac *) calloc(1, sizeof(Hmac) + 1);
+ if ((*pSession)->reqhmacinfo == NULL) {
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+ (*pSession)->resphmacinfo = (Hmac *) calloc(1, sizeof(Hmac) + 1);
+ if ((*pSession)->resphmacinfo == NULL) {
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+
+ (*pSession)->sourceMaxMsgSize = DEFAULT_MAX_MSG_SIZE;
+ (*pSession)->sourceMaxObjSize = DEFAULT_MAX_OBJ_SIZE;
+
+ (*pSession)->targetMaxMsgSize = 0;
+ (*pSession)->targetMaxObjSize = 0;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+
+ if (*pSession != NULL) {
+ _DEBUG_TRACE("free session");
+ free_session(*pSession);
+ }
+
+ _DEBUG_TRACE(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+void free_session(Session * session)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if((session) == NULL, "session is NULL!!");
+
+ if (session->pServer_id != NULL) {
+ free(session->pServer_id);
+ session->pServer_id = NULL;
+ }
+
+ if (session->sessionID != NULL) {
+ free(session->sessionID);
+ session->sessionID = NULL;
+ }
+
+ free_statuses(session->status);
+ session->status = NULL;
+
+ free_statuses(session->tempStatus);
+ session->status = NULL;
+
+ if (session->target != NULL) {
+ free_location(session->target);
+ session->target = NULL;
+ }
+
+ if (session->source != NULL) {
+ free_location(session->source);
+ session->source = NULL;
+ }
+
+ if (session->orgTarget != NULL) {
+ free_location(session->orgTarget);
+ session->orgTarget = NULL;
+ }
+
+ if (session->cred != NULL) {
+ free_cred(session->cred);
+ session->cred = NULL;
+ }
+
+ if (session->res_chal != NULL) {
+ free_chal(session->res_chal);
+ session->res_chal = NULL;
+ }
+
+ if (session->req_chal != NULL) {
+ free_chal(session->req_chal);
+ session->req_chal = NULL;
+ }
+
+ if (session->reqhmacinfo != NULL) {
+ free_hmac(session->reqhmacinfo);
+ session->reqhmacinfo = NULL;
+ }
+ if (session->resphmacinfo != NULL) {
+ free_hmac(session->resphmacinfo);
+ session->resphmacinfo = NULL;
+ }
+
+ _free_pending_statuses(session->pendingStatus);
+ session->pendingStatus = NULL;
+
+ if (session->pLargeObjCmd != NULL) {
+ free_command(session->pLargeObjCmd);
+ }
+
+ session = NULL;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+DM_ERROR receive_header(Session * session, SyncHdr * header)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ Location *pLocation = NULL;
+
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "session is NULL!!");
+ retvm_if((header) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "header is NULL!!");
+
+ if (session->sessionID != NULL && header->sessionID != NULL) {
+ if (strcmp(session->sessionID, header->sessionID) != 0) {
+ ret = COMMON_ERR_GENERIC;
+ goto error;
+ }
+ }
+
+ session->lastRecievedMsgID = header->messageID;
+
+ if (0 < header->maxmsgsize)
+ session->targetMaxMsgSize = header->maxmsgsize;
+ else
+ session->targetMaxMsgSize = DEFAULT_SERVER_MAXMSGSIZE;
+
+ if (0 < header->maxobjsize)
+ session->targetMaxObjSize = header->maxobjsize;
+
+ if (header->responseURI != NULL) {
+ if (session->orgTarget == NULL) {
+ session->orgTarget = session->target;
+ session->target = NULL;
+ }
+
+ if (session->target != NULL)
+ free_location(session->target);
+
+ ret = create_location(header->responseURI, get_location_locname(session->orgTarget), &pLocation);
+ if (ret != DM_OK)
+ goto error;
+ session->target = pLocation;
+
+ if (session->target == NULL) {
+ ret = COMMON_ERR_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+
+ _DEBUG_INFO(" target %s\n", session->target->locURI);
+ }
+
+ Status *temp = NULL;
+ DM_ERROR statusData = DM_ERR_UNKNOWN;
+
+ if (header->cred != NULL) {
+ _DEBUG_INFO("header cred ");
+ //ret = check_server_cred(header->cred, session);
+ statusData = DM_ERR_AUTH_ACCEPTED;
+ /*
+ * check server cred
+ */
+ } else {
+ _DEBUG_INFO("header not cred ");
+ statusData = DM_OK;
+ }
+
+ ret = create_status(statusData, session->cmdID++, session->lastRecievedMsgID, 0, header->source, header->target, NULL, COMMAND_TYPE_HEADER, &temp);
+ if (ret != DM_OK)
+ goto error;
+
+ session->status = g_list_append(session->status, temp);
+
+ //free_chal(pChal);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ //free_chal(pChal);
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR receive_statuses(Session * session, GList * receiveStatus)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "session is NULL!!");
+
+ GList *statusItem = receiveStatus;
+ Status *status = NULL;
+ Chal *pChal = NULL;
+ Status *req_chal_status = NULL;
+ GList *header = NULL;
+
+ while (statusItem) {
+ status = statusItem->data;
+
+ if (status->cmdRef == 0) {
+ /*status of SyncHdr */
+ assert(status->type == COMMAND_TYPE_HEADER);
+ assert(status->data);
+ DM_ERROR errorCode = atoi(status->data);
+
+ if (errorCode == DM_ERR_AUTH_ACCEPTED || errorCode == DM_OK || errorCode == DM_ERR_UNAUTHORIZED || errorCode == DM_ERR_AUTHENTICATION_REQUIRED) {
+ //212 || 200 || 401 || 407
+ //when auth type is AUTH_TYPE_BASIC does not need to send cred in syncHdr in same session
+ //when auth type is AUTH_TYPE_MD5 the next nonce in Chal MUST used for the digest when the next sync session is started.
+
+ Chal *chal = status->chal;
+ if (chal != NULL) {
+ _DEBUG_INFO("exist chal");
+
+ //res_chal in status have to be stored in config_tbl because it have to be used next sync session
+ _DEBUG_INFO("format type :%d\n", chal->format);
+
+ /*next session nonce data */
+ if (chal->nonce_plain != NULL) {
+ set_client_nextnonce(session->pServer_id, chal->nonce_plain);
+ }
+
+ /*create next req_chal */
+ if (chal->type == AUTH_TYPE_MD5) {
+ _DEBUG_INFO("session have cred md5");
+ set_client_authtype(session->pServer_id, chal->type);
+ ret = create_chal(FORMAT_TYPE_BASE64, AUTH_TYPE_MD5, ELEMENT_DEFAULT_CLIENT_NONCE, &pChal);
+ if (ret != DM_OK)
+ goto error;
+ } else if (chal->type == AUTH_TYPE_HMAC) {
+ session->isHMAC = 1;
+ _DEBUG_INFO("session have not cred , using hmac");
+ set_client_authtype(session->pServer_id, chal->type);
+ ret = create_chal(FORMAT_TYPE_BASE64, AUTH_TYPE_HMAC, ELEMENT_DEFAULT_CLIENT_NONCE, &pChal);
+ if (ret != DM_OK)
+ goto error;
+ }
+
+ if (pChal != NULL) {
+
+ for (header = session->status; header != NULL; header = g_list_next(header)) {
+ req_chal_status = (Status *) (header->data);
+ if (req_chal_status != NULL) {
+ _DEBUG_TRACE("req_chal_status status type : %d", req_chal_status->type);
+ if (req_chal_status->type == COMMAND_TYPE_HEADER) {
+ ((Status *) (req_chal_status))->chal = dup_chal(pChal);
+ _DEBUG_TRACE("add header chal");
+ break;
+ }
+ }
+ }
+ }
+
+ } else {
+ _DEBUG_INFO("chal null");
+ }
+
+ if (errorCode == DM_ERR_AUTH_ACCEPTED || errorCode == DM_ERR_UNAUTHORIZED || errorCode == DM_ERR_AUTHENTICATION_REQUIRED) {
+ if (session->cred != NULL) {
+ free_cred(session->cred);
+ session->cred = NULL;
+ } else {
+ //do nothing
+ }
+ }
+ // 401 || 407
+ if (errorCode == DM_ERR_UNAUTHORIZED) {
+ ret = DM_ERR_UNAUTHORIZED;
+ goto error;
+ } else if (errorCode == DM_ERR_AUTHENTICATION_REQUIRED) {
+ ret = DM_ERR_AUTHENTICATION_REQUIRED;
+ goto error;
+ }
+
+ } else if (errorCode == DM_ERR_SERVER_FAILURE) {
+ ret = DM_ERR_SERVER_FAILURE;
+ goto error;
+ }
+ } else {
+ //status except status of SyncHdr
+ GList *pendingStatusItem = session->pendingStatus;
+ PendingStatus *pending = NULL;
+ while (pendingStatusItem) {
+ pending = pendingStatusItem->data;
+
+ if (pending->cmdID == status->cmdRef && pending->msgID == status->msgRef) {
+ //if status's cmdID and msgID exists in pendigStatus
+
+ if (status->type == COMMAND_TYPE_ALERT) {
+ ret = _receive_alert_status(session, status);
+ } else if (status->type == COMMAND_TYPE_RESULTS) {
+ ret = _receive_results_status(session, status);
+ } else {
+ /*
+ COMMAND_TYPE_GET, COMMAND_TYPE_ADD, COMMAND_TYPE_REPLACE, COMMAND_TYPE_DELETE
+ COMMAND_TYPE_COPY, COMMAND_TYPE_EXEC, COMMAND_TYPE_ATOMIC, COMMAND_TYPE_SEQUENCE
+ */
+ }
+ if (ret != DM_OK)
+ goto error;
+
+ session->pendingStatus = g_list_remove(session->pendingStatus, pending);
+ free(pending);
+ } else {
+ //if status's cmdID and msgID doesn't exists in pendigStatus
+ //is it error?? does this can happen??
+ }
+ pendingStatusItem = g_list_next(pendingStatusItem);
+ }
+ }
+ statusItem = g_list_next(statusItem);
+ }
+
+ free_chal(pChal);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ free_chal(pChal);
+ _DEBUG_INFO(" error, Error Type %d \n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR receive_cmd(Session * session, GList * receiveCommand)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "session is NULL!!");
+
+ GList *commandItem = receiveCommand;
+ Command *command = NULL;
+
+ while (commandItem) {
+ command = commandItem->data;
+
+ switch (command->type) {
+ case COMMAND_TYPE_ALERT:
+ ret = _receive_alert_cmd(session, command);
+ break;
+ case COMMAND_TYPE_GET:
+ ret = _receive_get_cmd(session, command);
+ break;
+ case COMMAND_TYPE_RESULTS:
+ ret = _receive_results_cmd(session, command);
+ break;
+ case COMMAND_TYPE_ADD:
+ case COMMAND_TYPE_REPLACE:
+ case COMMAND_TYPE_DELETE:
+ case COMMAND_TYPE_COPY:
+ ret = _receive_changes_cmd(session, command);
+ break;
+ case COMMAND_TYPE_EXEC:
+ ret = _receive_exec_cmd(session, command);
+ break;
+ case COMMAND_TYPE_SEQUENCE:
+ ret = _receice_sequence_cmd(session, command);
+ break;
+ case COMMAND_TYPE_ATOMIC:
+ ret = _receive_atomic_cmd(session, command);
+ break;
+ case COMMAND_TYPE_UNKNOWN:
+ case COMMAND_TYPE_HEADER:
+ _DEBUG_INFO("not support command");
+ break;
+ default:
+ break;
+ }
+
+ _DEBUG_INFO("receivce cmd ret : %d", ret);
+ commandItem = g_list_next(commandItem);
+ if (ret != DM_OK)
+ goto error;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR create_prependingstatus(unsigned int msgID, unsigned int cmdID, PendingStatus ** pPendingStatus)
+{
+ _EXTERN_FUNC_EXIT;
+
+ DM_ERROR ret = DM_OK;
+
+ *pPendingStatus = (PendingStatus *) calloc(1, sizeof(PendingStatus));
+
+ if (*pPendingStatus == NULL) {
+ ret = COMMON_ERR_ALLOC;
+ goto error;
+ }
+
+ (*pPendingStatus)->msgID = msgID;
+ (*pPendingStatus)->cmdID = cmdID;
+
+ ret = DM_OK;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO(" error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR set_session_authcred(Session * session, Cred * cred)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "session is NULL!!");
+// retvm_if((cred) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED , "cred is NULL!!");
+ if (cred != NULL) {
+ session->cred = cred;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+void reset_cmdid_session(Session * session)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if((session) == NULL, "session is NULL!!");
+
+ session->cmdID = 1;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+AuthType __get_Session_AuthType_enum(char *data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ AuthType type = AUTH_TYPE_UNKNOWN;
+
+ retvm_if((data) == NULL, AUTH_TYPE_MD5, "data is NULL!!");
+
+ if (strcmp(data, ELEMENT_BASIC) == 0) {
+ type = AUTH_TYPE_BASIC;
+ } else if (strcmp(data, ELEMENT_DIGEST) == 0) {
+ type = AUTH_TYPE_MD5;
+ } else if (strcmp(data, ELEMENT_HMAC) == 0) {
+ type = AUTH_TYPE_HMAC;
+ } else {
+ type = AUTH_TYPE_UNKNOWN;
+ }
+ _DEBUG_VERBOSE(" end : [%d] \n", type);
+ _EXTERN_FUNC_EXIT;
+ return type;
+}
+
+void __set_Session_AuthType_name(AuthType authType, char **authname)
+{
+ _EXTERN_FUNC_ENTER;
+
+ switch (authType) {
+ case AUTH_TYPE_BASIC:
+ (*authname) = strdup(ELEMENT_BASIC);
+ break;
+ case AUTH_TYPE_MD5:
+ (*authname) = strdup(ELEMENT_DIGEST);
+ break;
+ case AUTH_TYPE_HMAC:
+ (*authname) = strdup(ELEMENT_HMAC);
+ break;
+ default:
+ (*authname) = strdup(ELEMENT_BASIC);
+ break;
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+}
+
+//temp code
+/*
+DM_ERROR get_session_clientauthtype(Session * session, AuthType * authType){
+ _DEBUG_INFO(" start \n");
+
+ DM_ERROR ret = DM_OK;
+ char* data = NULL;
+
+ ret = get_dmacc_authType( session->pServer_id, authType);
+ if(ret != DM_OK) {
+ (*authType) = AUTH_TYPE_BASIC;
+ ret = DM_OK;
+ }
+
+ if(data != NULL) {
+ (*authType) = __get_Session_AuthType(data);
+ free(data);
+ data = NULL;
+ }
+ _DEBUG_INFO(" end \n");
+ return ret;
+error :
+ _DEBUG_INFO(" error end [%d]\n", ret);
+ return ret;
+}
+
+DM_ERROR get_session_serverauthtype(Session * session, AuthType* authType){
+ _DEBUG_INFO(" start \n");
+
+ DM_ERROR ret = DM_OK;
+ char* data = NULL;
+
+ ret = get_dmacc_authType( session->pServer_id, authType);
+ if(ret != DM_OK) {
+ (*authType) = AUTH_TYPE_BASIC;
+ ret = DM_OK;
+ }
+
+ if(data != NULL) {
+ (*authType) = __get_Session_AuthType(data);
+
+ free(data);
+ data = NULL;
+ }
+
+ _DEBUG_INFO(" end \n");
+ return ret;
+
+error:
+ _DEBUG_INFO(" error end [%d]\n", ret);
+ return ret;
+}
+*/
+
+static DM_ERROR __userInteration_operation(Command * command, GList ** response, int *result_status)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((command) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "command is NULL!!");
+
+ CommandAlertPrivate pAlert = command->private.alert;
+ AlertType type = pAlert.type;
+ GList *alertItems = pAlert.items;
+ GList *iter = NULL;
+ Item *pItem = NULL;
+ int size = g_list_length(alertItems);
+ int i = 0;
+ //GList * responseItems = NULL;
+ char *result_data;
+ /*char* findValue = NULL; */
+ /*int isCancel = 0; */
+ uic_data *pUic_data = (uic_data *) calloc(1, sizeof(uic_data) + 1);
+ if (pUic_data == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ _INNER_FUNC_EXIT;
+ return COMMON_ERR_ALLOC;
+ }
+ pUic_data->pUic_option = (uic_option *) calloc(1, sizeof(uic_option) + 1);
+ if ((pUic_data->pUic_option) == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ free_uic_value(&pUic_data);
+ _INNER_FUNC_EXIT;
+ return COMMON_ERR_ALLOC;
+ }
+ pUic_data->res_data = (uic_res_data *) calloc(1, sizeof(uic_res_data) + 1);
+ //uic_option *uic_value = (uic_option *)calloc(1,sizeof(uic_option));
+ if ((pUic_data->res_data) == NULL) {
+ _DEBUG_VERBOSE("alloc fail");
+ free_uic_value(&pUic_data);
+ _INNER_FUNC_EXIT;
+ return COMMON_ERR_ALLOC;
+ }
+ switch (type) {
+ case DM_ALERT_DISPLAY:
+ _DEBUG_VERBOSE("alert display ui");
+ for (iter = alertItems, i = 0; iter != NULL; iter = g_list_next(iter), ++i) {
+ pItem = iter->data;
+ if (i == 0 && size != 1) {
+ /*user interaction option */
+ _DEBUG_VERBOSE("uic opation : %s", pItem->private.data);
+ ret = exec_userinteration_option(pItem->private.data, &(pUic_data->pUic_option));
+ } else {
+ if (pItem->private.data != NULL) {
+ /*user interaction execute */
+ _DEBUG_VERBOSE("uic display : %s", pItem->private.data);
+ pUic_data->display = strdup(pItem->private.data);
+ ret = ui_display(pUic_data);
+ *result_status = pUic_data->res_data->status;
+ }
+ }
+ }
+ break;
+ case DM_ALERT_CONFIRM_OR_REJECT:
+ _DEBUG_VERBOSE("alert confirm ui");
+ _DEBUG_VERBOSE("alert confirm alert item size : %d", size);
+ for (iter = alertItems, i = 0; iter != NULL; iter = g_list_next(iter), ++i) {
+ pItem = iter->data;
+ if (i == 0 && size != 1) {
+ /*user interaction option */
+ ret = exec_userinteration_option(pItem->private.data, &(pUic_data->pUic_option));
+ } else {
+ /*user interaction execute */
+ _DEBUG_VERBOSE("uic display : %s", pItem->private.data);
+ pUic_data->display = strdup(pItem->private.data);
+ ret = ui_confirm_or_reject(pUic_data);
+ *result_status = pUic_data->res_data->status;
+ }
+ }
+ break;
+ case DM_ALERT_TEXT_INPUT:
+ _DEBUG_VERBOSE("alert input ui");
+ for (iter = alertItems, i = 0; iter != NULL; iter = g_list_next(iter), ++i) {
+ pItem = iter->data;
+ if (i == 0 && size != 1) {
+ /*user interaction option */
+ /*IT ( A , N, D, T , P , I )
+ *ET (T , P )
+ */
+ ret = exec_userinteration_option(pItem->private.data, &(pUic_data->pUic_option));
+ } else {
+ /*user interaction execute */
+ _DEBUG_VERBOSE("uic display : %s", pItem->private.data);
+ pUic_data->display = strdup(pItem->private.data);
+ ret = ui_text_input(pUic_data, &result_data);
+ *result_status = pUic_data->res_data->status;
+ if (pUic_data->res_data->status == DM_OK) {
+ (*response) = g_list_append((*response), result_data);
+ } else {
+ _DEBUG_VERBOSE("input text null");
+ }
+ }
+ }
+
+ break;
+ case DM_ALERT_SINGLE_CHOICE:{
+ _DEBUG_VERBOSE("alert single choice ui");
+ for (iter = alertItems, i = 0; iter != NULL; iter = g_list_next(iter), ++i) {
+ pItem = iter->data;
+ if (i == 0 && size != 1) {
+ /*user interaction option */
+ ret = exec_userinteration_option(pItem->private.data, &(pUic_data->pUic_option));
+ } else {
+ /*user interaction execute */
+ if (i == 1) {
+ _DEBUG_VERBOSE("uic display : %s", pItem->private.data);
+ pUic_data->display = strdup(pItem->private.data);
+ } else {
+ GList *iter_end = NULL;
+ iter_end = g_list_next(iter);
+ char *data = NULL;
+ data = strdup(pItem->private.data);
+ pUic_data->multi_data = g_list_append(pUic_data->multi_data, data);
+
+ if (iter_end == NULL) {
+ ret = ui_single_choice(pUic_data, response);
+ *result_status = pUic_data->res_data->status;
+ break;
+ }
+ }
+ }
+ }
+ }
+ break;
+ case DM_ALERT_MULTIPLE_CHOICE:{
+ _DEBUG_VERBOSE("alert single/multiple choice ui");
+ for (iter = alertItems, i = 0; iter != NULL; iter = g_list_next(iter), ++i) {
+ pItem = iter->data;
+ if (i == 0 && size != 1) {
+ /*user interaction option */
+ if (pItem->private.data != NULL)
+ ret = exec_userinteration_option(pItem->private.data, &(pUic_data->pUic_option));
+ } else {
+ /*user interaction execute */
+ if (i == 1) {
+ _DEBUG_VERBOSE("uic display : %s", pItem->private.data);
+ pUic_data->display = strdup(pItem->private.data);
+ } else {
+ GList *iter_end = NULL;
+ iter_end = g_list_next(iter);
+ char *data = NULL;
+ data = strdup(pItem->private.data);
+ pUic_data->multi_data = g_list_append(pUic_data->multi_data, data);
+
+ if (iter_end == NULL) {
+ ret = ui_multiple_choice(pUic_data, response);
+ *result_status = pUic_data->res_data->status;
+ break;
+ }
+ }
+ }
+ }
+ }
+ break;
+ case ALERT_UNKNOWN:
+ case DM_ALERT_SERVER_INITIATED_MGMT:
+ case DM_ALERT_CLIENT_INITIATED_MGMT:
+ case DM_ALERT_NEXT_MESSAGE:
+ case DM_ALERT_SESSION_ABORT:
+ case DM_ALERT_CLIENT_EVENT:
+ case DM_ALERT_NO_END_OF_DATA:
+ case DM_ALERT_GENERIC_ALERT:
+ _DEBUG_VERBOSE("not user interaction type");
+ break;
+ default:
+ break;
+ }
+
+ /*
+ session->status
+ for(iter = responseItems; iter != NULL; iter = g_list_next(iter)){
+ pItem = iter->data;
+ temp->items = g_list_append(temp->items, pItem);
+ }
+ */
+ free_uic_value(&pUic_data);
+
+ _DEBUG_VERBOSE(" end\n");
+ _INNER_FUNC_EXIT;
+ return ret;
+
+}
+
+DM_ERROR add_response_hmacinfo(Session ** session, char *temp_hmac)
+{
+ _EXTERN_FUNC_ENTER;
+ DM_ERROR ret = DM_OK;
+ /*x-syncml-hmac: algorithm=MD5, username="156354238", mac=hvMeISwxSVUEofF2jHhQjA== */
+
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "session is NULL!!");
+ retvm_if((temp_hmac) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "hmac is NULL!!");
+
+ char *start = NULL;
+ char *end = NULL;
+
+ if ((*session)->resphmacinfo == NULL) {
+ _DEBUG_INFO("hmac response calloc");
+ (*session)->resphmacinfo = (Hmac *) calloc(1, sizeof(Hmac) + 1);
+ if ((*session)->resphmacinfo == NULL) {
+ return COMMON_ERR_ALLOC;
+ }
+ }
+
+ _DEBUG_INFO("temp_hmac : %s", temp_hmac);
+ start = strstr(temp_hmac, "=");
+ if (start == NULL) {
+ _DEBUG_INFO("auth type null");
+ return COMMON_ERR_INTERNAL_NOT_DEFINED;
+ }
+ _DEBUG_INFO("hmac : %s", start);
+
+ end = strstr(temp_hmac, ",");
+ if (end == NULL) {
+ _DEBUG_INFO("auth type null");
+ return COMMON_ERR_INTERNAL_NOT_DEFINED;
+ }
+ _DEBUG_INFO("hmac : %s", end);
+
+ _set_hmac_value(&((*session)->resphmacinfo->authtype), start + 1, (end - start - 1));
+ if ((*session)->resphmacinfo->authtype == NULL) {
+ _DEBUG_INFO("alloc fail");
+ _EXTERN_FUNC_EXIT;
+ return COMMON_ERR_ALLOC;
+ }
+ _DEBUG_INFO("auty type : %s", (*session)->resphmacinfo->authtype);
+
+ start = strstr(end, "=");
+ if (start == NULL) {
+ _DEBUG_INFO("username null");
+ return COMMON_ERR_INTERNAL_NOT_DEFINED;
+ }
+ _DEBUG_INFO("hmac : %s", start);
+
+ end = strstr(start, ",");
+ if (end == NULL) {
+ _DEBUG_INFO("username null");
+ return COMMON_ERR_INTERNAL_NOT_DEFINED;
+ }
+ _DEBUG_INFO("hmac : %s", end);
+
+ _set_hmac_value(&((*session)->resphmacinfo->username), start + 2, (end - start - 3));
+ if ((*session)->resphmacinfo->username == NULL) {
+ _DEBUG_INFO("alloc fail");
+ _EXTERN_FUNC_EXIT;
+ return COMMON_ERR_ALLOC;
+ }
+ _DEBUG_INFO("username : %s", (*session)->resphmacinfo->username);
+
+ start = strstr(end, "=");
+ if (start == NULL) {
+ _DEBUG_INFO("mac null");
+ return COMMON_ERR_INTERNAL_NOT_DEFINED;
+ }
+ _DEBUG_INFO("hmac : %s", start);
+ (*session)->resphmacinfo->mac = strdup(start + 1);
+ _DEBUG_INFO("mac : %s", (*session)->resphmacinfo->mac);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+static void _set_hmac_value(char **key, char *value, int size)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if((value) == NULL, "value is NULL!!");
+ retm_if((size) == 0, "size is NULL!!");
+
+ if (*key != NULL) {
+ free(*key);
+ *key = NULL;
+ } else {
+ _DEBUG_INFO("key null");
+ }
+
+ (*key) = (char *)calloc(1, size + 1);
+ if ((*key) == NULL) {
+ _INNER_FUNC_EXIT;
+ return;
+ }
+
+ strncpy((*key), value, size);
+
+ _INNER_FUNC_EXIT;
+}
+
+/*DM_ERROR process_commands(Command* pCommand, int * resultStatus) {
+
+ _DEBUG_TRACE( " start\n");
+
+ DM_ERROR ret = DM_OK;
+ switch (pCommand->type) {
+ case COMMAND_TYPE_UNKNOWN:
+ break;
+ case COMMAND_TYPE_ALERT:
+ ret = __process_alert(pCommand, resultStatus);
+ break;
+ case COMMAND_TYPE_ADD:
+ break;
+ ret = __process_add(pCommand, resultStatus);
+ case COMMAND_TYPE_REPLACE:
+ ret = __process_replace(pCommand, resultStatus);
+ break;
+ case COMMAND_TYPE_DELETE:
+ ret = __process_delete(pCommand, resultStatus);
+ break;
+ case COMMAND_TYPE_EXEC:
+ ret = __process_exec(pCommand, resultStatus);
+ break;
+ case COMMAND_TYPE_SEQUENCE:
+ ret = __process_sequence(pCommand, resultStatus);
+ break;
+ case COMMAND_TYPE_ATOMIC:
+ ret = __process_atomic(pCommand, resultStatus);
+ break;
+ case COMMAND_TYPE_COPY:
+ break;
+ default:
+ break;
+ }
+
+return_part:
+ if (ret != DM_OK)
+ goto error;
+
+ _DEBUG_TRACE( " end\n");
+ return ret;
+error:
+ _DEBUG_TRACE( " error end : ret %d\n", ret);
+ return ret;
+
+}*/
+
+static DM_ERROR __rollback_atomic(Session * session, Command * pCommand)
+{
+ _INNER_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+ retvm_if((session) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "session is NULL!!");
+ retvm_if((pCommand) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "pCommand is NULL!!");
+
+ Command *current_Command = NULL;
+ /*Status * temp_status = NULL; */
+ GList *atomic_iter = NULL;
+ GList *items = NULL;
+ GList *temp_items = NULL;
+ Item *item = NULL;
+ sync_agent_dm_mo_error_e mo_ret = sync_agent_begin_transaction_mo();
+ _DEBUG_VERBOSE("transaction start : %d", mo_ret);
+
+ for (atomic_iter = pCommand->private.sequence_atomic.commands; atomic_iter != NULL; atomic_iter = g_list_next(atomic_iter)) {
+ current_Command = (Command *) atomic_iter->data;
+
+ switch (current_Command->type) {
+ case COMMAND_TYPE_ALERT:
+ items = current_Command->private.alert.items;
+ break;
+ case COMMAND_TYPE_ADD:
+ case COMMAND_TYPE_REPLACE:
+ case COMMAND_TYPE_DELETE:
+ case COMMAND_TYPE_COPY:
+ items = current_Command->private.change.items;
+ break;
+ case COMMAND_TYPE_GET:
+ items = current_Command->private.access.items;
+ // delete result status
+ break;
+ case COMMAND_TYPE_UNKNOWN:
+ case COMMAND_TYPE_HEADER:
+ case COMMAND_TYPE_RESULTS:
+ case COMMAND_TYPE_EXEC:
+ case COMMAND_TYPE_SEQUENCE:
+ case COMMAND_TYPE_ATOMIC:
+ _DEBUG_VERBOSE("not support command in atomic");
+ break;
+ default:
+ break;
+ }
+
+ for (temp_items = items; temp_items != NULL; temp_items = g_list_next(temp_items)) {
+ item = temp_items->data;
+
+ ret = set_status_data(session, current_Command, item, DM_ERR_ATOMIC_ROLL_BACK_OK);
+ }
+ }
+
+ _DEBUG_VERBOSE(" end\n");
+ _INNER_FUNC_EXIT;
+ return ret;
+
+}
diff --git a/src/agent/serviceadapter/sa_syncml_binders.c b/src/agent/serviceadapter/sa_syncml_binders.c
new file mode 100644
index 0000000..120e99d
--- /dev/null
+++ b/src/agent/serviceadapter/sa_syncml_binders.c
@@ -0,0 +1,321 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "serviceadapter/sa_syncml_binders.h"
+#include "serviceadapter/protocolbinder/syncml_protocol_binder.h"
+#include "serviceadapter/sa_elements_internal.h"
+#include "serviceadapter/sa_command_internal.h"
+#include "serviceadapter/sa_util.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_SA"
+#endif
+
+DM_ERROR syncml_objectbinder(SyncML * pSyncML, char **msg, unsigned int *msg_size)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((pSyncML) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "pSyncML is NULL!!");
+
+ sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+
+ sync_agent_pb_error_e err = init_syncml_binder_function_set(&pBinder_function_set);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ ret = COMMON_ERR_INTERNAL_BINDER_ERROR;
+ goto error;
+ }
+
+ sync_agent_pb_protocol_binder_info_s *pBinder = NULL;
+ pBinder = syncml_binder_init(pBinder, SYNC_AGENT_PB_ENCODING_WBXML_12, false, true, pBinder_function_set);
+
+ err = syncml_binder_append(pBinder, PE_SYNCML_START, NULL);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ ret = COMMON_ERR_INTERNAL_BINDER_ERROR;
+ goto error;
+ }
+
+ err = syncml_binder_append(pBinder, PE_HEADER, pSyncML->hdr);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ ret = COMMON_ERR_INTERNAL_BINDER_ERROR;
+ goto error;
+ }
+ err = syncml_binder_append(pBinder, PE_BODY_START, NULL);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ ret = COMMON_ERR_INTERNAL_BINDER_ERROR;
+ goto error;
+ }
+
+ /* TODO : Status handling */
+ GList *status_iter = NULL;
+ Status *pStatus = NULL;
+ for (status_iter = pSyncML->status; status_iter != NULL; status_iter = g_list_next(status_iter)) {
+ pStatus = status_iter->data;
+ err = syncml_binder_append(pBinder, PE_STATUS, pStatus);
+ }
+
+ GList *iter = NULL;
+ Command *pCommand = NULL;
+ OMA_DM_Protocol_Element protocol_element = PE_UNDEF;
+ for (iter = pSyncML->commands; iter != NULL; iter = g_list_next(iter)) {
+ pCommand = (Command *) (iter->data);
+
+/* unsigned int estimate_size =0;
+ syncml_binder_get_estimate_doc_size(pBinder, &estimate_size);
+ _DEBUG_INFO(" ESTIMATE SIZE = %d\n", estimate_size);*/
+
+ CommandType type = pCommand->type;
+ switch (type) {
+ case COMMAND_TYPE_UNKNOWN:
+ protocol_element = PE_UNDEF;
+ break;
+ case COMMAND_TYPE_ALERT:
+ protocol_element = PE_ALERT;
+ break;
+ case COMMAND_TYPE_ADD:
+ protocol_element = PE_ADD;
+ break;
+ case COMMAND_TYPE_REPLACE:
+ protocol_element = PE_REPLACE;
+ break;
+ case COMMAND_TYPE_DELETE:
+ protocol_element = PE_DELETE;
+ break;
+ case COMMAND_TYPE_GET:
+ protocol_element = PE_GET;
+ break;
+ case COMMAND_TYPE_RESULTS:
+ protocol_element = PE_RESULTS_START;
+ break;
+ case COMMAND_TYPE_HEADER:
+ protocol_element = PE_HEADER;
+ break;
+ case COMMAND_TYPE_EXEC:
+ protocol_element = PE_EXEC;
+ break;
+ case COMMAND_TYPE_SEQUENCE:
+ protocol_element = PE_SEQUENCE;
+ break;
+ case COMMAND_TYPE_ATOMIC:
+ protocol_element = PE_ATOMIC;
+ break;
+ case COMMAND_TYPE_COPY:
+ protocol_element = PE_COPY;
+ break;
+ default:
+ break;
+ }
+
+ err = syncml_binder_append(pBinder, protocol_element, pCommand);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ ret = COMMON_ERR_INTERNAL_BINDER_ERROR;
+ goto error;
+ }
+
+ if (type == COMMAND_TYPE_RESULTS) {
+ err = syncml_binder_append(pBinder, PE_RESULTS_END, NULL);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ ret = COMMON_ERR_INTERNAL_BINDER_ERROR;
+ goto error;
+ }
+ }
+ }
+
+ if (pSyncML->final == 1) {
+ err = syncml_binder_append(pBinder, PE_FINAL, NULL);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ ret = COMMON_ERR_INTERNAL_BINDER_ERROR;
+ goto error;
+ }
+ }
+
+ err = syncml_binder_append(pBinder, PE_BODY_END, NULL);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ ret = COMMON_ERR_INTERNAL_BINDER_ERROR;
+ goto error;
+ }
+ err = syncml_binder_append(pBinder, PE_SYNCML_END, NULL);
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ ret = COMMON_ERR_INTERNAL_BINDER_ERROR;
+ goto error;
+ }
+ syncml_binder_get_stream(pBinder, msg, msg_size);
+
+ char *xml = NULL;
+ unsigned int xml_len = 0;
+ err = sync_agent_get_xml_from_protocol_binder(pBinder, &xml, &xml_len);
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_INFO(" msg from client \n");
+ if (fputs(xml, stderr) == EOF) {
+ _DEBUG_INFO("debuging test error");
+ }
+ set_xml_to_file((xml), OMA_DM_MSG_PATH);
+ str_free(&xml);
+ }
+
+ syncml_binder_terminate(pBinder);
+
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ ret = COMMON_ERR_INTERNAL_BINDER_ERROR;
+ goto error;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO("error end %d \n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR reverse_syncml_objectbinder(SyncML ** pSyncML, char *recv_msg, unsigned int recv_msg_length, char **xml, unsigned int *xml_len)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((recv_msg) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "recv_msg is NULL!!");
+
+ sync_agent_pb_protocol_binder_function_set_s *pBinder_function_set = NULL;
+
+ sync_agent_pb_error_e err = init_syncml_binder_function_set(&pBinder_function_set);
+ sync_agent_pb_protocol_binder_reverse_info_s *pBinder = NULL;
+ err = reverse_syncml_binder_init(recv_msg, recv_msg_length, SYNC_AGENT_PB_DECODING_WBXML, pBinder_function_set, NULL, &pBinder);
+
+ if (err != SYNC_AGENT_PB_RETURN_OK) {
+ _DEBUG_INFO("reverse_oma_dm_1_2_binder_init error\n");
+ ret = COMMON_ERR_INTERNAL_BINDER_ERROR;
+ }
+
+ /*_DEBUG_INFO( "pBinder = %x\n", pBinder);*/
+
+ /*char* xml = NULL;
+ unsigned int xml_size = 0; */
+ err = sync_agent_get_xml_from_reverse_protocol_binder(pBinder, xml, xml_len);
+ if (err == SYNC_AGENT_PB_RETURN_OK) {
+ fprintf(stderr, " msg from server \n");
+ if (fputs((*xml), stderr) == EOF) {
+ _DEBUG_INFO("debugging test error");
+ }
+ set_xml_to_file((*xml), OMA_DM_MSG_PATH);
+ //str_free(&xml);
+ }
+
+ OMA_DM_Protocol_Element protocol_element = PE_UNDEF;
+ char *protocol_element_name = NULL;
+ Content_Ptr pContent = NULL;
+ int sequence_Atomic = 0;
+ Command *tempCommand = NULL;
+
+ while (err == SYNC_AGENT_PB_RETURN_OK) {
+ err = reverse_syncml_binder_next(pBinder, &protocol_element, &protocol_element_name, &pContent);
+
+ if (err == SYNC_AGENT_PB_RETURN_HAS_NO_MORE_ELEMENT) {
+ break;
+ }
+
+ switch (protocol_element) {
+ case PE_ADD:
+ if (sequence_Atomic != 1)
+ (*pSyncML)->commands = g_list_append((*pSyncML)->commands, pContent);
+ else
+ tempCommand->private.sequence_atomic.commands = g_list_append(tempCommand->private.sequence_atomic.commands, pContent);
+
+ break;
+ case PE_COPY:
+ case PE_DELETE:
+ if (sequence_Atomic != 1)
+ (*pSyncML)->commands = g_list_append((*pSyncML)->commands, pContent);
+ else
+ tempCommand->private.sequence_atomic.commands = g_list_append(tempCommand->private.sequence_atomic.commands, pContent);
+
+ break;
+ case PE_EXEC:
+ case PE_GET:
+ if (sequence_Atomic != 1)
+ (*pSyncML)->commands = g_list_append((*pSyncML)->commands, pContent);
+ else
+ tempCommand->private.sequence_atomic.commands = g_list_append(tempCommand->private.sequence_atomic.commands, pContent);
+
+ break;
+ case PE_SEQUENCE_START:
+ case PE_ATOMIC_START:
+ sequence_Atomic = 1;
+ tempCommand = (Command *) pContent;
+ break;
+ case PE_SEQUENCE_END:
+ case PE_ATOMIC_END:
+ sequence_Atomic = 0;
+ (*pSyncML)->commands = g_list_append((*pSyncML)->commands, tempCommand);
+ tempCommand = NULL;
+ break;
+ case PE_REPLACE:
+ if (sequence_Atomic != 1)
+ (*pSyncML)->commands = g_list_append((*pSyncML)->commands, pContent);
+ else
+ tempCommand->private.sequence_atomic.commands = g_list_append(tempCommand->private.sequence_atomic.commands, pContent);
+
+ break;
+ case PE_ALERT:
+ _DEBUG_INFO("reverse alert command");
+ if (sequence_Atomic != 1)
+ (*pSyncML)->commands = g_list_append((*pSyncML)->commands, pContent);
+ else
+ tempCommand->private.sequence_atomic.commands = g_list_append(tempCommand->private.sequence_atomic.commands, pContent);
+
+ break;
+ case PE_RESULTS_START:
+ (*pSyncML)->commands = g_list_append((*pSyncML)->commands, pContent);
+
+ break;
+ case PE_STATUS:
+ (*pSyncML)->status = g_list_append((*pSyncML)->status, pContent);
+ protocol_element = PE_UNDEF;
+
+ break;
+ case PE_HEADER:
+ (*pSyncML)->hdr = pContent;
+ sync_agent_set_user_data_in_reverse_protocol_binder(pBinder, (*pSyncML)->hdr);
+
+ break;
+ case PE_GENERIC:
+ case PE_FINAL:
+ (*pSyncML)->final = (int)pContent;
+
+ break;
+ default:
+ break;
+ }
+ }
+
+ sync_agent_destroy_reverse_protocol_binder(pBinder);
+
+ if (err != SYNC_AGENT_PB_RETURN_OK && err != SYNC_AGENT_PB_RETURN_HAS_NO_MORE_ELEMENT)
+ ret = COMMON_ERR_INTERNAL_BINDER_ERROR;
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
diff --git a/src/agent/serviceadapter/sa_util.c b/src/agent/serviceadapter/sa_util.c
new file mode 100755
index 0000000..287e960
--- /dev/null
+++ b/src/agent/serviceadapter/sa_util.c
@@ -0,0 +1,394 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*lib*/
+#include <glib.h>
+#include <glib/gprintf.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+/*dm-agent*/
+#include "common/dm_common.h"
+#include "common/util/util.h"
+#include "serviceadapter/sa_util.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DM_SA"
+#endif
+
+#define BUF_SIZE 300
+#define MAX_BUFFER 50
+
+void putCmdIntoList(GList ** commands, GList ** commands_last, void *pCommand)
+{
+ _EXTERN_FUNC_ENTER;
+
+ GList *temp = NULL;
+ if (*commands_last == NULL) {
+ *commands_last = *commands = g_list_append(*commands, pCommand);
+ } else {
+ temp = g_list_append(*commands_last, pCommand);
+ if(temp == NULL) {
+ _DEBUG_ERROR("g_list_append return value NULL!!");
+ }
+ *commands_last = g_list_next(*commands_last);
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+DM_ERROR create_auth_credString(AuthType type, const char *username, const char *password, const unsigned char *nonce, const unsigned int nonce_size, char **pCred)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((username) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "username is NULL!!");
+ retvm_if((password) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "password is NULL!!");
+
+ _DEBUG_INFO(" type : [%d] username :[%s], password :[%s] , nonce : [%s],nonce_size : [%d]", type, username, password, nonce, nonce_size);
+
+ DM_ERROR ret = DM_OK;
+
+ switch (type) {
+ case AUTH_TYPE_BASIC:
+ {
+ char *plain = g_strjoin(":", username, password, NULL);
+ *pCred = g_base64_encode((unsigned char *)plain, strlen(plain));
+ if (*pCred == NULL) {
+ free(plain);
+ ret = COMMON_ERR_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+ free(plain);
+
+ break;
+ }
+ case AUTH_TYPE_MD5:
+ {
+ /* How does syncml:auth-md5 works?
+ *
+ * base64(
+ * md5(
+ * base64(
+ * md5(
+ * username + ":" + password
+ * )
+ * ) +
+ * ":" + nonce
+ * )
+ * )
+ */
+
+ /* Let's determine the string for the comparison. */
+ char *auth = NULL;
+ auth = g_strjoin(":", username, password, NULL);
+ _DEBUG_INFO("[username:password] = %s\n", auth);
+
+ unsigned char *digest = NULL;
+ digest = sync_agent_encrypt_cryptograhic_hash(SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_MD5, auth, strlen(auth));
+ free(auth);
+ *pCred = g_base64_encode(digest, 16);
+ if (*pCred == NULL) {
+ ret = COMMON_ERR_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+
+ _DEBUG_INFO("nonce = %s", nonce);
+ _DEBUG_INFO("nonce_size = %d", nonce_size);
+ int auth_size = strlen(*pCred) + nonce_size + 1;
+ auth = (char *)calloc(strlen(*pCred) + nonce_size + 1 + 1, sizeof(char));
+ if (auth == NULL) {
+ _DEBUG_INFO("alloc fail");
+ _EXTERN_FUNC_EXIT;
+ return COMMON_ERR_ALLOC;
+ }
+ memcpy(auth, *pCred, strlen(*pCred));
+ auth[strlen(*pCred)] = ':';
+ memcpy(auth + strlen(*pCred) + 1, nonce, nonce_size);
+ _DEBUG_INFO("base64[md5[username:password]] = %s\n", *pCred);
+ _DEBUG_INFO("before last base64 encoding = %s\n", auth);
+ free(*pCred);
+
+ digest = sync_agent_encrypt_cryptograhic_hash(SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_MD5, auth, auth_size);
+ _DEBUG_INFO("md5[base64[md5[username:password]]:nonce] = %s\n", digest);
+
+ free(auth);
+ *pCred = g_base64_encode(digest, 16);
+ free(digest);
+ _DEBUG_INFO("base64[md5[base64[md5[username:password]]:nonce]] = %s", *pCred);
+ if (*pCred == NULL) {
+ ret = COMMON_ERR_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+ break;
+ }
+ case AUTH_TYPE_HMAC:
+ {
+ /*do not use cred element */
+ }
+ break;
+ case AUTH_TYPE_UNKNOWN:
+ case AUTH_TYPE_HTTP_BASIC:
+ case AUTH_TYPE_HTTP_DIGEST:
+ case AUTH_TYPE_X509:
+ case AUTH_TYPE_SECURID:
+ case AUTH_TYPE_SAFEWORD:
+ case AUTH_TYPE_DIGIPASS:
+ case AUTH_TYPE_TRANSPORT:
+ _DEBUG_INFO("not support auth type");
+ ret = DM_ERR_FORBIDDEN;
+ goto error;
+ break;
+ default:
+ break;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+ error:
+ _DEBUG_INFO("error : %d\n", ret);
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+DM_ERROR gemerate_hmac(char *username, char *password, unsigned char *nonce, unsigned int nonce_size, char *msg, unsigned int msg_size, char **mac)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((msg) == NULL, COMMON_ERR_IS_NULL, "session is NULL!!");
+ retvm_if((username) == NULL, COMMON_ERR_IS_NULL, "username is NULL!!");
+ retvm_if((password) == NULL, COMMON_ERR_IS_NULL, "password is NULL!!");
+ retvm_if((nonce) == NULL, COMMON_ERR_IS_NULL, "nonce is NULL!!");
+
+ char *resultmd = NULL;
+ unsigned char *resultmd5 = NULL;
+ unsigned char *resultmd6 = NULL;
+ //char md5Digest[16];
+ char buffer[BUF_SIZE];
+ char *temp_result1 = NULL;
+ char *temp_result2 = NULL;
+ char *temp_result3 = NULL;
+ unsigned int size;
+ int len = 0;
+ int str_len = 0;
+/* if (nonce == NULL|| username == NULL|| password == NULL|| msg == NULL)
+ return 0;*/
+
+ /* Logging */
+ _DEBUG_INFO("generate HMAC");
+ //resultmd5 = (unsigned char *)calloc(1, sizeof(char)*17);
+
+ /* H(messageBody) */
+ resultmd = (char *)sync_agent_encrypt_cryptograhic_hash(SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_MD5, (const char *)msg, (int)msg_size);
+ resultmd5 = (unsigned char *)strdup(resultmd);
+
+ size = 16;
+
+ int i = 0;
+ char *digest_msg = (char *)calloc(MAX_BUFFER, sizeof(char));
+ if (digest_msg == NULL) {
+ _DEBUG_INFO("alloc fail");
+ _EXTERN_FUNC_EXIT;
+ return COMMON_ERR_ALLOC;
+ }
+ for (i = 0; i < 16; i++) {
+ snprintf(digest_msg + (i * 2), MAX_BUFFER, "%02x", resultmd5[i]);
+ }
+ _DEBUG_INFO("MD 5 = %s", digest_msg);
+ /* B64(H(messageBody) */
+ temp_result1 = g_base64_encode(resultmd5, size);
+ msg_size = size;
+
+ /* Logging */
+ _DEBUG_INFO("B64(H(messageBody)) : %s", temp_result1);
+
+ /* H(username:password) */
+ str_len = g_strlcpy(buffer, username, (int)sizeof(buffer));
+ if (str_len >= sizeof(buffer)) {
+ _DEBUG_INFO("buffer over flow");
+ ret = COMMON_ERR_BUFFER_OVERFLOW;
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ }
+ len = g_strlcat(buffer, ":", BUF_SIZE);
+ len = g_strlcat(buffer, password, BUF_SIZE);
+ size = strlen(buffer);
+
+ _DEBUG_INFO("username:password: %s", buffer);
+ resultmd5 = sync_agent_encrypt_cryptograhic_hash(SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_MD5, (const char *)buffer, (int)size);
+ size = 16;
+
+ /* B64(H(username:password)) */
+ temp_result2 = g_base64_encode(resultmd5, size);
+ _DEBUG_INFO("B64(H(username:password)) %s", temp_result2);
+
+ /* B64(H(username:password)):nonce:B64(H(message body)) */
+ str_len = g_strlcpy(buffer, (const char *)temp_result2, (int)sizeof(buffer));
+ if (str_len >= sizeof(buffer)) {
+ _DEBUG_INFO("buffer over flow");
+ ret = COMMON_ERR_BUFFER_OVERFLOW;
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ }
+
+ len = g_strlcat(buffer, ":", BUF_SIZE);
+
+ _DEBUG_INFO("B64(H(username:password)): = %s", buffer);
+ size = strlen((const char *)temp_result2) + 1;
+ _DEBUG_INFO("buffer : %s, real size : %d , size : %d\n", buffer, strlen(buffer), size);
+
+ len = g_strlcat(buffer, (const char *)nonce, BUF_SIZE);
+
+ _DEBUG_INFO("B64(H(username:password)):nonce = %s", buffer);
+ size += strlen((const char *)nonce);
+ _DEBUG_INFO("buffer : %s, real size : %d , size : %d\n", buffer, strlen(buffer), size);
+
+ len = g_strlcat(buffer, ":", BUF_SIZE);
+
+ size++;
+ _DEBUG_INFO("buffer : %s, real size : %d , size : %d\n", buffer, strlen(buffer), size);
+
+ len = g_strlcat(buffer, temp_result1, BUF_SIZE);
+
+ size += strlen((const char *)temp_result1);
+ _DEBUG_INFO("B64(H(username:password)):nonce:B64(H(message body)): %s", buffer);
+
+ /* Interim Clean up */
+ str_free((char **)(&temp_result1));
+ str_free((char **)(&temp_result2));
+
+ if (str_len >= BUF_SIZE) {
+ _DEBUG_INFO("buffer over flow");
+ ret = COMMON_ERR_BUFFER_OVERFLOW;
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ }
+
+ /*char *buffer1 = "wUN5aEY1cn4K1AhZnuSg6Q==:12345:stthIupGdabKGLdI7ezeBw==";
+ int size1 = strlen(buffer1);
+ printf("buffer1 : %s, size1 : %d\n", buffer1, size1);
+ */
+ /* H(B64(H(username:password)):nonce:B64(H(message body))) */
+ resultmd6 = sync_agent_encrypt_cryptograhic_hash(SYNC_AGENT_SA_CRYPTOGRAHIC_HASH_FUNTION_MD5, buffer, size);
+ size = 16;
+
+ i = 0;
+ printf("gener : ");
+ for (i = 0; i < size; ++i) {
+ printf(" %02x", resultmd6[i]);
+ }
+ printf("\n");
+
+ /* Return the base 64 of digest */
+ temp_result3 = g_base64_encode(resultmd6, size);
+
+ /* Logging */
+ _DEBUG_INFO("B64(H(B64(H(username:password)):nonce:B64(H(message body)))): %s", temp_result3);
+
+ (*mac) = strdup((const char *)temp_result3);
+ str_free((char **)(&temp_result3));
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
+
+void set_xml_to_file(char *xml, const char *path)
+{
+ _EXTERN_FUNC_ENTER;
+
+ FILE *pFile = NULL;
+
+ if (xml != NULL) {
+ pFile = fopen(path, "a");
+ }
+
+ if (pFile == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return;
+ }
+
+ fputs("==================================================================================", pFile);
+ fputs("\n", pFile);
+ fputs(xml, pFile);
+
+ fclose(pFile);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+DM_ERROR findStgringValue(char *original, char *findParam, char *findSep, char **findValue)
+{
+ _EXTERN_FUNC_ENTER;
+
+ DM_ERROR ret = DM_OK;
+
+ retvm_if((original) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "original is NULL!!");
+ retvm_if((findParam) == NULL, COMMON_ERR_INTERNAL_NOT_DEFINED, "findParam is NULL!!");
+
+ char *findOption = NULL;
+ char *findEnd = NULL;
+ char *findSepEnd = NULL;
+ int valueSize = 0;
+ /*int optionSize = 0;
+ int sepaSize = 0; */
+
+ /*mindt=10&dr=1&maclen=10 */
+ findOption = strstr(original, findParam);
+ if (findOption != NULL) {
+ _DEBUG_INFO(" find Option : %s\n", findOption);
+
+ /*=10&dr=1&maclen=10*/
+ findEnd = strstr(findOption, findSep);
+ if (findEnd != NULL) {
+ /*&dr=1&maclen=10 */
+ findSepEnd = strstr(findOption, UI_OP_SEPARATOR);
+ if (findSepEnd != NULL) {
+ valueSize = strlen(findEnd) - strlen(findSepEnd) - 1;
+ } else {
+ valueSize = strlen(findEnd);
+ }
+ _DEBUG_INFO(" findEnd : %s\n", findEnd);
+ _DEBUG_INFO(" findSepEnd : %s\n", findSepEnd);
+ _DEBUG_INFO(" value size : %d\n", valueSize);
+ } else {
+ _DEBUG_INFO("not found value");
+ _EXTERN_FUNC_EXIT;
+ return ret;
+ }
+ (*findValue) = calloc(1, valueSize + 1);
+ if ((*findValue) == NULL) {
+ _DEBUG_INFO("alloc fail");
+ return COMMON_ERR_ALLOC;
+ }
+ memcpy((*findValue), findEnd + 1, valueSize);
+ (*findValue)[valueSize] = '\0';
+
+ _DEBUG_INFO(" find Value : %s : %d \n", (*findValue), valueSize);
+
+ } else {
+ _DEBUG_INFO(" not found \n");
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+
+}
diff --git a/src/plugins/CMakeLists.sub b/src/plugins/CMakeLists.sub
new file mode 100644
index 0000000..8040b54
--- /dev/null
+++ b/src/plugins/CMakeLists.sub
@@ -0,0 +1,57 @@
+
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set lib name
+SET(LIBNAME "lib${PROJECT_NAME}")
+#SET(LIBDIR "${PREFIX}/lib")
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+STRING(REPLACE ";" " " EXTRA_CFLAGS "${PLUGIN_CFLAGS}")
+
+# add include directories to the build.
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../../include)
+
+# find all source files in a directory.
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SRCS)
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# add a library to the project using the specified source files.
+ADD_LIBRARY(${LIBNAME} SHARED ${SRCS})
+
+# link a target to given libraries from pkg-config.
+TARGET_LINK_LIBRARIES(${LIBNAME} ${PLUGIN_LDFLAGS})
+
+# sets additional compiler flags used to build sources within the target.
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+
+# override the default target name prefix (such as "lib")
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "")
+
+# specify the build version
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES VERSION ${VERSION})
+
+# specify the api version
+SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES SOVERSION ${VERSION_MAJOR})
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+# install library files
+INSTALL(TARGETS ${LIBNAME} DESTINATION ${LIBDIR})
+
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
new file mode 100644
index 0000000..44103cb
--- /dev/null
+++ b/src/plugins/CMakeLists.txt
@@ -0,0 +1,4 @@
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
+
+ADD_SUBDIRECTORY(dm-private)
+ADD_SUBDIRECTORY(dm-public)
diff --git a/src/plugins/dm-private/CMakeLists.txt b/src/plugins/dm-private/CMakeLists.txt
new file mode 100755
index 0000000..1484b27
--- /dev/null
+++ b/src/plugins/dm-private/CMakeLists.txt
@@ -0,0 +1,13 @@
+
+# set plguin name
+SET(PLUGIN_CATEGORY_NAME "dm-private")
+
+# set plugin install path
+SET(LIBDIR "${PREFIX}/lib/sync-agent/${PLUGIN_CATEGORY_NAME}")
+
+ADD_SUBDIRECTORY(dmacc-gcf)
+ADD_SUBDIRECTORY(fumo)
+ADD_SUBDIRECTORY(lawmo)
+ADD_SUBDIRECTORY(multiapps)
+ADD_SUBDIRECTORY(slp-device-dm)
+ADD_SUBDIRECTORY(slp-sysnoti-telephony)
diff --git a/src/plugins/dm-private/dmacc-gcf/CMakeLists.txt b/src/plugins/dm-private/dmacc-gcf/CMakeLists.txt
new file mode 100755
index 0000000..5ad672a
--- /dev/null
+++ b/src/plugins/dm-private/dmacc-gcf/CMakeLists.txt
@@ -0,0 +1,43 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "mo-dmacc-gcf")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+ sync-agent
+ vconf
+ dlog
+ libwbxml2
+ )
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${mo-dmacc-gcf_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${mo-dmacc-gcf_LDFLAGS} -lcrypt")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
diff --git a/src/plugins/dm-private/dmacc-gcf/include/des.h b/src/plugins/dm-private/dmacc-gcf/include/des.h
new file mode 100755
index 0000000..0c28772
--- /dev/null
+++ b/src/plugins/dm-private/dmacc-gcf/include/des.h
@@ -0,0 +1,25 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef DES_H_
+#define DES_H_
+
+void set_key(const char *key);
+void expand_des(char *expansion_key, int exapansion_lehgth);
+void encrpyt_key_to_des(int *bin_plain);
+
+#endif /* DES_H_ */
diff --git a/src/plugins/dm-private/dmacc-gcf/include/password_generator.h b/src/plugins/dm-private/dmacc-gcf/include/password_generator.h
new file mode 100755
index 0000000..67377f6
--- /dev/null
+++ b/src/plugins/dm-private/dmacc-gcf/include/password_generator.h
@@ -0,0 +1,29 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PASSWORD_GENERATOR_H_
+#define PASSWORD_GENERATOR_H_
+
+typedef enum _generate_type {
+ SERVER_PW_KEY,
+ CLIENT_ID_KEY,
+ CLIENT_PW_KEY
+} generate_type;
+
+char *generate_device_password(const char *device_id, const char *server_id, generate_type type);
+
+#endif /* PASSWORD_GENERATOR_H_ */
diff --git a/src/plugins/dm-private/dmacc-gcf/src/password_generator.c b/src/plugins/dm-private/dmacc-gcf/src/password_generator.c
new file mode 100755
index 0000000..871a5fd
--- /dev/null
+++ b/src/plugins/dm-private/dmacc-gcf/src/password_generator.c
@@ -0,0 +1,74 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <glib.h>
+#include <glib/gprintf.h>
+#include <crypt.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+#include "password_generator.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_DMACC_GCF"
+#endif
+
+#define MAX_LENGTH 32
+
+/* general function */
+// RSA ----------------------------------- gcf common - generate_password...
+char *generate_device_password(const char *imei_device_id, const char *server_id, generate_type type)
+{
+
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((imei_device_id) == NULL, 0, "imei_device_id is NULL!!");
+ retvm_if((server_id) == NULL, 0, "server_id is NULL!!");
+
+ char *password = NULL;
+
+ _DEBUG_INFO("imei_device_id = %s, server_id = %s\n", imei_device_id, server_id);
+ password = g_strdup_printf("%s_pw", server_id);
+
+ //// password generate ///
+
+ //////////////////////////
+
+ _EXTERN_FUNC_EXIT;
+
+ return password;
+}
+
+/*
+static void __print__array(char *array, int array_length, char *array_name)
+{
+ _DEBUG_VERBOSE(" ====> Array Name : %s <===== \n", array_name);
+ int i;
+ for (i = 0; i < array_length; i++) {
+ _DEBUG_VERBOSE("index[ %d] = %X, ", i, array[i]);
+ if (i != 0 && 0 == (i % 8)) {
+ _DEBUG_VERBOSE("\n");
+ }
+ }
+ _DEBUG_VERBOSE("\n");
+}
+*/
diff --git a/src/plugins/dm-private/dmacc-gcf/src/plugin_interface.c b/src/plugins/dm-private/dmacc-gcf/src/plugin_interface.c
new file mode 100755
index 0000000..8a05650
--- /dev/null
+++ b/src/plugins/dm-private/dmacc-gcf/src/plugin_interface.c
@@ -0,0 +1,511 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <vconf.h>
+#include <glib.h>
+
+#include <wait.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+#include "password_generator.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_DMACC_GCF"
+#endif
+
+#define CSC_VCONF_KEY_SYNCMLDM_NBFIELD "db/SyncML/oma-dm-service/DevManagement/NbDevManagement"
+#define CSC_VCONF_KEY_SYNCMLDM_ACCNAME "db/SyncML/oma-dm-service/DevManagement/%d/AccName"
+#define CSC_VCONF_KEY_SYNCMLDM_AUTHTYPE "db/SyncML/oma-dm-service/DevManagement/%d/AuthType"
+#define CSC_VCONF_KEY_SYNCMLDM_CLIENTNONCE "db/SyncML/oma-dm-service/DevManagement/%d/ClientNonce"
+#define CSC_VCONF_KEY_SYNCMLDM_SERVADDR "db/SyncML/oma-dm-service/DevManagement/%d/ServAddr"
+#define CSC_VCONF_KEY_SYNCMLDM_SERVID "db/SyncML/oma-dm-service/DevManagement/%d/ServID"
+#define CSC_VCONF_KEY_SYNCMLDM_SERVNONCE "db/SyncML/oma-dm-service/DevManagement/%d/ServNonce"
+#define CSC_VCONF_KEY_SYNCMLDM_SERVPORT "db/SyncML/oma-dm-service/DevManagement/%d/Port"
+#define CSC_VCONF_KEY_SYNCMLDM_SERVPWD "db/SyncML/oma-dm-service/DevManagement/%d/ServPwd"
+#define CSC_VCONF_KEY_SYNCMLDM_PASSWORD "db/SyncML/oma-dm-service/DevManagement/%d/Password"
+
+//#define CSC_GCF_SERVER_NUM 3
+#define CSC_GCF_SERVER_NUM 1
+
+#define ALTER_SYNCMLDM_NBFIELD 3
+#define ALTER_SYNCMLDM_ACCNAME "gcf"
+#define ALTER_SYNCMLDM_AUTHTYPE "DIGEST"
+#define ALTER_SYNCMLDM_CLIENTNONCE "12345"
+#define ALTER_SYNCMLDM_SERVADDR "http://192.168.168.169/dm"
+#define ALTER_SYNCMLDM_SERVID "RSate"
+#define ALTER_SYNCMLDM_SERVNONCE "12345"
+#define ALTER_SYNCMLDM_SERVPORT 80
+#define ALTER_SYNCMLDM_SERVPWD "T1NQIERNIFNlcnZlcg=="
+#define ALTER_SYNCMLDM_PASSWORD ""
+
+#define SERVER_NUM 1
+
+static int _get_index(const char *name);
+
+static char *_get_mo_value_str(const char *vconf_key, int nIndex);
+static int _get_mo_value_int(const char *vconf_key, int nIndex);
+
+static void _set_mo_value_str(const char *vconf_key, int nIndex, char *value);
+static void _set_mo_value_int(const char *vconf_key, int nIndex, int value);
+
+static sync_agent_get_devinfo_cb func_get_dev_info = 0;
+
+EXPORT_API char **sync_agent_plugin_get_server_id_list(int *server_id_list_cnt)
+{
+ _EXTERN_FUNC_ENTER;
+
+ *server_id_list_cnt = 0;
+ char **temp_id_list = (char **)calloc(SERVER_NUM, sizeof(char *));
+ if (temp_id_list == NULL) {
+ return 0;
+ }
+
+ int server_idx = _get_index(ALTER_SYNCMLDM_ACCNAME);
+ char *server_id = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_SERVID, server_idx);
+ if (server_id == NULL) {
+ server_id = strdup(ALTER_SYNCMLDM_SERVID);
+ }
+ *temp_id_list = server_id;
+ *server_id_list_cnt = 1;
+
+ _DEBUG_INFO("server_id = %s\n", server_id);
+
+ _DEBUG_INFO("server_id_list_cnt = %d\n", *server_id_list_cnt);
+
+ _EXTERN_FUNC_EXIT;
+ return temp_id_list;
+}
+
+EXPORT_API int sync_agent_plugin_get_mo_value(const char *mo_full_path, const char *mo_name, char **mo_value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((mo_full_path) == NULL, -1, "mo_full_path is NULL!!");
+ retvm_if((mo_name) == NULL, -1, "mo_name is NULL!!");
+
+ _DEBUG_INFO("mo_name : %s", mo_name);
+ *mo_value = NULL;
+
+ int n_index = _get_index(ALTER_SYNCMLDM_ACCNAME);
+
+ if (!strcmp(mo_name, "AppID")) {
+ *mo_value = strdup("w7");
+
+ } else if (!strcmp(mo_name, "ServerID")) {
+ *mo_value = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_SERVID, n_index);
+ if ((*mo_value) == NULL) {
+ *mo_value = strdup(ALTER_SYNCMLDM_SERVID);
+ _set_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_SERVID, n_index, ALTER_SYNCMLDM_SERVID);
+ }
+
+ } else if (!strcmp(mo_name, "Name")) {
+ *mo_value = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_ACCNAME, n_index);
+ if ((*mo_value) == NULL) {
+ *mo_value = strdup(ALTER_SYNCMLDM_ACCNAME);
+ _set_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_ACCNAME, n_index, ALTER_SYNCMLDM_ACCNAME);
+ }
+
+ } else if (!strcmp(mo_name, "Addr")) { /* ./DMAcc/gcf/AppAddr/MSCserver_AppAddr/Addr */
+ *mo_value = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_SERVADDR, n_index);
+ if ((*mo_value) == NULL) {
+ *mo_value = strdup(ALTER_SYNCMLDM_SERVADDR);
+ _set_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_SERVADDR, n_index, ALTER_SYNCMLDM_SERVADDR);
+ }
+
+ } else if (!strcmp(mo_name, "AddrType")) { /* ./DMAcc/gcf/AppAddr/MSCserver_AppAddr/AddrType */
+ *mo_value = strdup("IPv4");
+
+ } else if (!strcmp(mo_name, "PortNbr")) { /* ./DMAcc/gcf/AppAddr/MSCserver_AppAddr/Port/MSCserver_Port/PortNbr */
+ if (n_index != -1) {
+ int port = _get_mo_value_int(CSC_VCONF_KEY_SYNCMLDM_SERVPORT, n_index);
+ if (port == -1) {
+ port = ALTER_SYNCMLDM_SERVPORT;
+ _set_mo_value_int(CSC_VCONF_KEY_SYNCMLDM_SERVPORT, n_index, ALTER_SYNCMLDM_SERVPORT);
+ }
+ *mo_value = g_strdup_printf("%d", port);
+ }
+
+ } else if (!strcmp(mo_full_path, "./DMAcc/gcf/AppAuth/ServerAppAuth/AAuthLevel")) {
+ *mo_value = strdup("SRVCRED");
+
+ } else if (!strcmp(mo_full_path, "./DMAcc/gcf/AppAuth/ServerAppAuth/AAuthType")) {
+ if (n_index != -1) {
+ int auth_type = _get_mo_value_int(CSC_VCONF_KEY_SYNCMLDM_AUTHTYPE, n_index);
+ if (auth_type == -1) {
+ *mo_value = strdup(ALTER_SYNCMLDM_AUTHTYPE);
+ _set_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_AUTHTYPE, n_index, ALTER_SYNCMLDM_AUTHTYPE);
+ } else if (auth_type == 0) { /* basic */
+ *mo_value = strdup("BASIC");
+ } else if (auth_type == 1) { /* md5 */
+ *mo_value = strdup("DIGEST");
+ } else if (auth_type == 2) { /* hmac */
+ *mo_value = strdup("HMAC");
+ } else {
+ *mo_value = strdup(ALTER_SYNCMLDM_AUTHTYPE);
+ _set_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_AUTHTYPE, n_index, ALTER_SYNCMLDM_AUTHTYPE);
+ }
+ }
+
+ } else if (!strcmp(mo_full_path, "./DMAcc/gcf/AppAuth/ServerAppAuth/AAuthName")) {
+ *mo_value = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_SERVID, n_index);
+ if ((*mo_value) == NULL) {
+ *mo_value = strdup(ALTER_SYNCMLDM_SERVID);
+ _set_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_SERVID, n_index, ALTER_SYNCMLDM_SERVID);
+ }
+
+ } else if (!strcmp(mo_full_path, "./DMAcc/gcf/AppAuth/ServerAppAuth/AAuthSecret")) {
+ /* *mo_value = __get_MO_Value_STR(CSC_VCONF_KEY_SYNCMLDM_SERVPWD, nIndex);
+ if((*mo_value) == NULL) {
+ *mo_value = strdup(ALTER_SYNCMLDM_SERVPWD);
+ } */
+ char *device_id = NULL;
+ if (func_get_dev_info != 0) {
+ func_get_dev_info(2, "DevID", &device_id);
+ if (device_id == NULL) {
+ _DEBUG_INFO("device id is NULL");
+ return -1;
+ }
+ } else {
+ _DEBUG_INFO("pFunc_Get_DevInfo is NULL");
+ return -1;
+ }
+ _DEBUG_INFO("Device Id : %s", device_id);
+
+ char *server_id = 0;
+ server_id = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_SERVID, n_index);
+ if (server_id == NULL) {
+ server_id = strdup(ALTER_SYNCMLDM_SERVID);
+ }
+ _DEBUG_INFO("Server Id : %s", server_id);
+ *mo_value = generate_device_password((const char *)device_id, (const char *)server_id, SERVER_PW_KEY);
+
+ if (*mo_value == NULL) {
+ _DEBUG_INFO("generate device password fail");
+ *mo_value = strdup(ALTER_SYNCMLDM_SERVPWD);
+ }
+
+ _DEBUG_INFO("server pw : %s", *mo_value);
+
+ free(device_id);
+ free(server_id);
+
+ } else if (!strcmp(mo_full_path, "./DMAcc/gcf/AppAuth/ServerAppAuth/AAuthData")) {
+ *mo_value = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_SERVNONCE, n_index);
+ if ((*mo_value) == NULL) {
+ *mo_value = strdup(ALTER_SYNCMLDM_SERVNONCE);
+ _set_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_SERVNONCE, n_index, ALTER_SYNCMLDM_SERVNONCE);
+ }
+
+ } else if (!strcmp(mo_full_path, "./DMAcc/gcf/AppAuth/ClientAppAuth/AAuthLevel")) {
+ *mo_value = strdup("CLCRED");
+
+ } else if (!strcmp(mo_full_path, "./DMAcc/gcf/AppAuth/ClientAppAuth/AAuthType")) {
+ if (n_index != -1) {
+ int auth_type = _get_mo_value_int(CSC_VCONF_KEY_SYNCMLDM_AUTHTYPE, n_index);
+
+ if (auth_type == -1) {
+ *mo_value = strdup(ALTER_SYNCMLDM_AUTHTYPE);
+ _set_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_AUTHTYPE, n_index, ALTER_SYNCMLDM_AUTHTYPE);
+ } else if (auth_type == 0) { /* basic */
+ *mo_value = strdup("BASIC");
+ } else if (auth_type == 1) { /* md5 */
+ *mo_value = strdup("DIGEST");
+ } else if (auth_type == 2) { /* hmac */
+ *mo_value = strdup("HMAC");
+ } else {
+ *mo_value = strdup(ALTER_SYNCMLDM_AUTHTYPE);
+ _set_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_AUTHTYPE, n_index, ALTER_SYNCMLDM_AUTHTYPE);
+ }
+ }
+
+ } else if (!strcmp(mo_full_path, "./DMAcc/gcf/AppAuth/ClientAppAuth/AAuthName")) {
+ char *device_id = NULL;
+ if (func_get_dev_info != NULL) {
+ func_get_dev_info(2, "DevID", &device_id);
+ if (device_id == NULL) {
+ _DEBUG_INFO("device id is NULL");
+ return -1;
+ }
+ } else {
+ _DEBUG_INFO("pFunc_Get_DevInfo is NULL");
+ return -1;
+ }
+ char *server_id = NULL;
+ server_id = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_SERVID, n_index);
+ if (server_id == NULL) {
+ server_id = strdup(ALTER_SYNCMLDM_SERVID);
+ }
+ *mo_value = generate_device_password((const char *)device_id, (const char *)server_id, CLIENT_ID_KEY);
+
+ if (*mo_value == NULL) {
+ _DEBUG_INFO("generate device password fail");
+ *mo_value = strdup(ALTER_SYNCMLDM_SERVPWD);
+ }
+
+ free(device_id);
+ free(server_id);
+
+ /* *mo_value = strdup("IMEI:357584040054001"); */
+ } else if (!strcmp(mo_full_path, "./DMAcc/gcf/AppAuth/ClientAppAuth/AAuthSecret")) {
+
+ char *device_id = NULL;
+ if (func_get_dev_info != NULL) {
+ func_get_dev_info(2, "DevID", &device_id);
+ if (device_id == NULL) {
+ _DEBUG_INFO("device id is NULL");
+ return -1;
+ }
+ } else {
+ _DEBUG_INFO("pFunc_Get_DevInfo is NULL");
+ return -1;
+ }
+ char *server_id = NULL;
+ server_id = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_SERVID, n_index);
+ if (server_id == NULL) {
+ server_id = strdup(ALTER_SYNCMLDM_SERVID);
+ }
+ *mo_value = generate_device_password((const char *)device_id, (const char *)server_id, CLIENT_PW_KEY);
+
+ free(device_id);
+ free(server_id);
+
+ } else if (!strcmp(mo_full_path, "./DMAcc/gcf/AppAuth/ClientAppAuth/AAuthData")) {
+ *mo_value = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_CLIENTNONCE, n_index);
+ if ((*mo_value) == NULL) {
+ *mo_value = strdup(ALTER_SYNCMLDM_CLIENTNONCE);
+ _set_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_CLIENTNONCE, n_index, ALTER_SYNCMLDM_CLIENTNONCE);
+ }
+ } else {
+ _DEBUG_INFO("---------------------------------------------------not pased mo element : %s---------------------------------------------------", mo_full_path);
+ }
+
+ _DEBUG_INFO("mo_value : %s", *mo_value);
+
+ _EXTERN_FUNC_EXIT;
+
+ return 0;
+}
+
+EXPORT_API void sync_agent_set_function_get_devinfo_plugin(sync_agent_get_devinfo_cb func)
+{
+ _EXTERN_FUNC_ENTER;
+
+ func_get_dev_info = func;
+
+ _EXTERN_FUNC_ENTER;
+}
+
+static int _system_command(const char *command)
+{
+ _EXTERN_FUNC_ENTER;
+
+ int pid = 0, status = 0;
+ char *const environ[] = { NULL };
+
+ retvm_if((command) == NULL, -1, "command is NULL!!");
+
+ pid = fork();
+ if (pid == -1) {
+ _DEBUG_INFO("ERROR : fork failed to create a process\n");
+ _EXTERN_FUNC_EXIT;
+ return -1;
+
+ } else if (pid == 0) {
+ char *argv[4];
+ argv[0] = "sh";
+ argv[1] = "-c";
+ argv[2] = (char *)command;
+ argv[3] = 0;
+
+ execve("/bin/sh", argv, environ);
+ abort();
+ } else {
+ do {
+ if (waitpid(pid, &status, 0) == -1) {
+ if (errno != EINTR) {
+ return -1;
+ }
+
+ } else {
+ _EXTERN_FUNC_EXIT;
+ return status;
+ }
+
+ } while (1);
+ }
+ _EXTERN_FUNC_EXIT;
+ return -1;
+}
+
+static int _get_index(const char *name)
+{
+ _INNER_FUNC_ENTER;
+
+ int n_acc_count = 0;
+ if (vconf_get_int(CSC_VCONF_KEY_SYNCMLDM_NBFIELD, &n_acc_count)) {
+ _DEBUG_TRACE("vconf_get_int FAIL");
+ //// return -1;
+ //n_acc_count =ALTER_SYNCMLDM_NBFIELD;
+ //_set_mo_value_int(CSC_VCONF_KEY_SYNCMLDM_NBFIELD, CSC_GCF_SERVER_NUM, ALTER_SYNCMLDM_NBFIELD);
+
+ //////// CSC don't include vconf value.
+ int ret = _system_command("/usr/share/oma-dm-cfg/csc-setting/change_csc_value.sh");
+ if (ret != -1) {
+ _DEBUG_INFO("success");
+ } else {
+ _DEBUG_INFO("fail");
+ }
+ n_acc_count = ALTER_SYNCMLDM_NBFIELD;
+ }
+
+ _DEBUG_TRACE("nAccCount : %d", n_acc_count);
+
+ int i = 0;
+ char *compare_name = NULL;
+ for (; i < n_acc_count; i++) {
+ compare_name = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_ACCNAME, i + 1);
+ if (compare_name == NULL) {
+ continue;
+ } else {
+ _DEBUG_TRACE("[%d] compare_name : %s [%d], name : %s [%d]", i, compare_name, strlen(compare_name), name, strlen(name));
+ if (!strcmp(name, compare_name)) {
+ _DEBUG_TRACE("nIndex : %d", i + 1);
+ return i + 1;
+ }
+ if (compare_name != NULL) {
+ free(compare_name);
+ compare_name = NULL;
+ }
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return CSC_GCF_SERVER_NUM;
+}
+
+static char *_get_mo_value_str(const char *vconf_key, int nIndex)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((vconf_key) == NULL, NULL, "vconf_key is NULL!!");
+
+ if (nIndex == -1) {
+ return 0;
+ }
+
+ char input_vconf_path[200] = { 0, };
+ char rec_idx[8];
+
+ memset(rec_idx, 0x0, sizeof(rec_idx));
+ snprintf(rec_idx, sizeof(rec_idx), "%d", nIndex);
+ snprintf(input_vconf_path, strlen(vconf_key) + strlen(rec_idx) + 1, vconf_key, nIndex);
+
+ char *value = vconf_get_str(input_vconf_path);
+ if (value == NULL) {
+ _DEBUG_TRACE("vconf_get_str FAIL");
+ }
+
+ _INNER_FUNC_ENTER;
+
+ return value;
+}
+
+static int _get_mo_value_int(const char *vconf_key, int nIndex)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((vconf_key) == NULL, -1, "vconf_key is NULL!!");
+
+ char input_vconf_path[200] = { 0, };
+ char rec_idx[8];
+
+ memset(rec_idx, 0x0, sizeof(rec_idx));
+ snprintf(rec_idx, sizeof(rec_idx), "%d", nIndex);
+ snprintf(input_vconf_path, strlen(vconf_key) + strlen(rec_idx) + 1, vconf_key, nIndex);
+
+ int value = -1;
+ if (vconf_get_int(input_vconf_path, &value) == 0) {
+ _DEBUG_TRACE("vconf_get_int : %d", value);
+ } else {
+ _DEBUG_TRACE("vconf_get_int error");
+ }
+
+ _INNER_FUNC_ENTER;
+
+ return value;
+}
+
+static void _set_mo_value_str(const char *vconf_key, int nIndex, char *value)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if((vconf_key) == NULL, "vconf_key is NULL!!");
+
+ char input_vconf_path[200] = { 0, };
+ char rec_idx[8];
+ int result = 0;
+
+ memset(rec_idx, 0x0, sizeof(rec_idx));
+ snprintf(rec_idx, sizeof(rec_idx), "%d", nIndex);
+ snprintf(input_vconf_path, strlen(vconf_key) + strlen(rec_idx) + 1, vconf_key, nIndex);
+
+ result = vconf_set_str(input_vconf_path, value);
+ _DEBUG_TRACE("vconf set reult : %d", result);
+
+ _INNER_FUNC_ENTER;
+
+}
+
+static void _set_mo_value_int(const char *vconf_key, int nIndex, int value)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if((vconf_key) == NULL, "vconf_key is NULL!!");
+
+ char input_vconf_path[200] = { 0, };
+ char rec_idx[8];
+
+ memset(rec_idx, 0x0, sizeof(rec_idx));
+ snprintf(rec_idx, sizeof(rec_idx), "%d", nIndex);
+ snprintf(input_vconf_path, strlen(vconf_key) + strlen(rec_idx) + 1, vconf_key, nIndex);
+
+ vconf_set_int(input_vconf_path, value);
+
+ _INNER_FUNC_EXIT;
+
+}
+
+EXPORT_API int sync_agent_plugin_initialize()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int result = 1;
+
+ _EXTERN_FUNC_EXIT;
+ return result;
+}
diff --git a/src/plugins/dm-private/fumo/CMakeLists.txt b/src/plugins/dm-private/fumo/CMakeLists.txt
new file mode 100755
index 0000000..ae874ea
--- /dev/null
+++ b/src/plugins/dm-private/fumo/CMakeLists.txt
@@ -0,0 +1,47 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "mo-fumo")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+ sync-agent
+ vconf
+ libsoup-2.4
+ dlog
+ libwbxml2
+ tapi
+ capi-system-info
+ capi-telephony-sim
+ )
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${mo-fumo_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${mo-fumo_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub) \ No newline at end of file
diff --git a/src/plugins/dm-private/fumo/src/plugin_interface.c b/src/plugins/dm-private/fumo/src/plugin_interface.c
new file mode 100755
index 0000000..230e15a
--- /dev/null
+++ b/src/plugins/dm-private/fumo/src/plugin_interface.c
@@ -0,0 +1,234 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <vconf.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_FUMO"
+#endif
+
+#define SERVER_NUM 1
+
+static sync_agent_get_devinfo_cb func_get_dev_info = 0;
+
+//static int _get_index(const char *name);
+//static char *_get_mo_value_str(const char *vconf_key, int n_index);
+
+EXPORT_API char **sync_agent_plugin_get_server_id_list(int *server_id_list_cnt)
+{
+ _EXTERN_FUNC_ENTER;
+/*
+ *server_id_list_cnt = 0;
+ char **temp_id_list = (char **)calloc(SERVER_NUM, sizeof(char *));
+ if (temp_id_list == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+
+ char *sever_name = 0;
+ int server_idx = 0;
+ char *server_id = 0;
+
+ int i = 0;
+ for (i = 0; i < SERVER_NUM; i++) {
+
+ switch (i) {
+ case 0:
+ sever_name = ALTER_SYNCMLDM_ACCNAME_1;
+ break;
+ case 1:
+ sever_name = ALTER_SYNCMLDM_ACCNAME_2;
+ break;
+ }
+
+ server_idx = _get_index(sever_name);
+ server_id = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_SERVID, server_idx);
+ if (server_id == NULL) {
+ switch(i){
+ case 0:
+ server_id = strdup(ALTER_SYNCMLDM_SERVID_1);
+ break;
+ case 1:
+ server_id = strdup(ALTER_SYNCMLDM_SERVID_2);
+ break;
+ }
+ }
+ _DEBUG_INFO("Temp_id_list[%d] = %s\n", i, server_id);
+ temp_id_list[i] = server_id;
+ (*server_id_list_cnt)++;
+ }
+ _DEBUG_INFO("server_id_list_cnt = %d\n", *server_id_list_cnt);
+
+ _EXTERN_FUNC_EXIT;
+ return temp_id_list;
+*/
+ *server_id_list_cnt = 1;
+ char **temp_id_list = (char **)calloc(SERVER_NUM, sizeof(char *));
+ if (temp_id_list == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+ }
+ char *server_id = NULL;
+ server_id = strdup("*");
+ *temp_id_list = server_id;
+
+ _DEBUG_INFO("fumo server_id = %s\n", server_id);
+ _DEBUG_INFO("fumo server_id_list_cnt = %d\n", *server_id_list_cnt);
+
+ _EXTERN_FUNC_EXIT;
+ return temp_id_list;
+}
+
+EXPORT_API int sync_agent_plugin_get_mo_value(const char *mo_pull_path, const char *mo_name, char **mo_value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((mo_pull_path) == NULL, -1, "mo_pull_path is NULL!!");
+ retvm_if((mo_name) == NULL, -1, "mo_name is NULL!!");
+
+ _DEBUG_INFO("mo_name : %s", mo_name);
+ *mo_value = NULL;
+
+ if (!strcmp(mo_name, "PkgName")) {
+ /*
+ if (pFunc_Get_DevInfo == NULL) {
+ return -1;
+ }
+ sync_agent_dev_return_e res = pFunc_Get_DevInfo(2, "FwV", mo_value);
+ */
+ } else if (!strcmp(mo_name, "PkgVersion")) {
+ /* Empty */
+ } else if (!strcmp(mo_name, "State")) {
+ *mo_value = strdup("10");
+ }
+
+ _DEBUG_INFO("mo_value : %s", *mo_value);
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+EXPORT_API void sync_agent_plugin_set_function_get_devinfo(sync_agent_get_devinfo_cb func)
+{
+ _EXTERN_FUNC_ENTER;
+
+ func_get_dev_info = func;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API int sync_agent_plugin_initialize()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int result = 1;
+ result = 1; //_req_fumo_server_reg(0);
+/*
+ if (result == -1)
+ goto error;
+*/
+ _EXTERN_FUNC_EXIT;
+
+ return result;
+/*
+ error:
+
+ _EXTERN_FUNC_EXIT;
+ return -1; // Fail
+*/
+}
+
+/*
+static int _get_index(const char *name)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((name) == NULL, -1, "name is NULL!!");
+
+ int n_acc_count = 0;
+ if (vconf_get_int(CSC_VCONF_KEY_SYNCMLDM_NBFIELD, &n_acc_count)) {
+ _DEBUG_TRACE("vconf_get_int FAIL");
+ //return -1;
+ n_acc_count =ALTER_SYNCMLDM_NBFIELD;
+ }
+
+ _DEBUG_TRACE("nAccCount : %d", n_acc_count);
+
+ int i = 0;
+ for (; i < n_acc_count; i++) {
+ char *compare_name = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_ACCNAME, i + 1);
+ if (compare_name == NULL) {
+ switch(i) {
+ case 0:
+ compare_name = ALTER_SYNCMLDM_ACCNAME_1;
+ break;
+ case 1:
+ compare_name = ALTER_SYNCMLDM_ACCNAME_2;
+ break;
+ default :
+ continue;
+ break;
+ }
+ }
+
+ _DEBUG_TRACE("[%d] compare_name : %s [%d], name : %s [%d]", i, compare_name, strlen(compare_name), name, strlen(name));
+ if (!strcmp(name, compare_name)) {
+ _DEBUG_TRACE("nIndex : %d", i + 1);
+ return i + 1;
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+ return -1;
+}
+
+static char *_get_mo_value_str(const char *vconf_key, int n_index)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((vconf_key) == NULL, NULL, "vconf_key is NULL!!");
+
+ if (n_index == -1) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+
+ char input_vconf_path[200] = { 0, };
+ char rec_idx[8];
+
+ memset(rec_idx, 0x0, sizeof(rec_idx));
+ snprintf(rec_idx, sizeof(rec_idx), "%d", n_index);
+ snprintf(input_vconf_path, strlen(vconf_key) + strlen(rec_idx) + 1, vconf_key, n_index);
+
+ char *value = vconf_get_str(input_vconf_path);
+ if (value == NULL) {
+ _DEBUG_TRACE("vconf_get_str FAIL");
+ }
+
+ _INNER_FUNC_EXIT;
+ return value;
+}
+*/
diff --git a/src/plugins/dm-private/lawmo/CMakeLists.txt b/src/plugins/dm-private/lawmo/CMakeLists.txt
new file mode 100755
index 0000000..c479933
--- /dev/null
+++ b/src/plugins/dm-private/lawmo/CMakeLists.txt
@@ -0,0 +1,49 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "mo-lawmo")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+ sync-agent
+ vconf
+ location
+ bundle
+ appsvc
+ aul
+ sysman
+ tapi
+ dlog
+ libwbxml2
+ )
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${mo-lawmo_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${mo-lawmo_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub) \ No newline at end of file
diff --git a/src/plugins/dm-private/lawmo/include/plugin_devexe_error.h b/src/plugins/dm-private/lawmo/include/plugin_devexe_error.h
new file mode 100755
index 0000000..52cd4cd
--- /dev/null
+++ b/src/plugins/dm-private/lawmo/include/plugin_devexe_error.h
@@ -0,0 +1,107 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLUGIN_DEVEXE_ERROR_H_
+#define PLUGIN_DEVEXE_ERROR_H_
+
+/* depend slp-device-plugIn lib */
+typedef enum {
+
+ EXE_SUCCESS = 1,
+ EXE_DEV_FAIL = -1,
+
+ /* standard error */
+ EXE_DEV_DATA_FAIL = -2,
+ EXE_DEV_OPER_NOT_PERFORMED = -3,
+
+ /* vender specific error */
+
+ /*common */
+ EXE_DEV_AMT_STATUS_OFF = -4,
+ EXEC_DEV_SCREEN_OFF = -5,
+
+ /*wipe */
+ EXE_DEV_WIPE_ALL_FAILED = -10,
+ EXE_DEV_EXTERNAL_MEMORY_FAILED = -11,
+ EXE_DEV_SIM_MEMORY_FAILED = -12,
+
+ /*forwarding */
+ EXE_DEV_FORWORDING_ALL_FAILED = -20,
+ EXE_DEV_FORWORDING_CALL_FAILED = -21,
+ EXE_DEV_FORWORDING_SMS_FAILED = -22
+} slp_device_dm_exe_e;
+
+typedef enum {
+
+ OPERATION_SUCCEEDED = 1200,
+ WIPE_OPEARTION_SUCCEEDED_WITH_DATA_WIPED = 1201,
+ WIPE_OPERATION_SUCCEEDED_WITH_BOTH_DATA_AND_ASSOCIATED_WIPE_LIST_WITHIN_MANAGEMENT_TREE_WIPED = 1202,
+
+ /*SUCCESSFUL = VENDOR SPECIFIED */
+ SUCCESSFUL_SAME_STATUS = 1250,
+
+ /*ERROR*/ CLIENT_ERROR = 1400,
+ USER_CANCELLED = 1401,
+
+ /* Lock & Wipe */
+ FULLY_LOCK_DEVICE_FAILED = 1402,
+ PARTIALLY_LOCK_DEVICE_FAILED = 1403,
+ UNLOCK_DEVICE_FAILED = 1404,
+ WIPE_DEVICES_DATA_FAILED = 1405,
+ WIPE_OPERATION_NOT_PERFORMED = 1406,
+
+ CLIENT_TIME_EXPIRED = 1451,
+
+ /* Ring My Phone */
+ AMT_STATUS_OFF = 1452,
+ /* Location */
+
+ /* MasterKey */
+ SCREEN_OFF = 1453,
+
+ /* Wipe */
+ EXTERNAL_AND_SIM_MEMORY_WIPE_FAILED = 1460,
+ EXTERNAL_MEMORY_WIPE_FAILED = 1461,
+ SIM_MEMORY_WIPE_FAILED = 1462,
+
+ /* Forwarding */
+ CALL_AND_SMS_FORWARDING_FAILED = 1470,
+ CALL_FORWARDING_FAILED = 1471,
+ SMS_FORWARDING_FAILED = 1472,
+
+} ext_lawmo_e;
+
+/*
+1400 Client Error
+1401 User Canceled
+1402 Fully Lock Device Failed
+1403 Partially Lock Device Failed
+1404 Unlock Device Failed
+1405 Wipe Device Data Failed
+1406 Wipe Operation Not Performed
+1451 Client Time Expired
+1452 AMT Status Off
+1453 Screen Off
+1460 External and SIM memory wipe Failed
+1461 External memory wipe Failed
+1462 SIM memory wipe Failed
+1470 Call and SMS forwarding Failed
+1471 Call forwarding Failed
+1472 SMS forwarding Failed
+*/
+
+#endif /* PLUGIN_DEVEXE_ERROR_H_ */
diff --git a/src/plugins/dm-private/lawmo/src/plugin_interface.c b/src/plugins/dm-private/lawmo/src/plugin_interface.c
new file mode 100755
index 0000000..cbf5215
--- /dev/null
+++ b/src/plugins/dm-private/lawmo/src/plugin_interface.c
@@ -0,0 +1,687 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <glib.h>
+#include <glib/gprintf.h>
+#include <vconf.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+#include "plugin_devexe_error.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_LAWMO"
+#endif
+
+#define SERVER_NUM 1
+
+#define ROOT "./Ext/OSPS"
+
+typedef enum {
+ FULLY_LOCK,
+ PARTAILLY_LOCK,
+ UNLOCK,
+ FACTORY_RESET,
+ WIPE,
+
+ RING_START,
+ RING_STOP,
+
+ MT_LOCATION,
+ MT_STOP,
+ MT_TRACKING,
+
+ FW_DIVERTREQUEST,
+
+ MK_LOCK
+} lawmo_ext_name_e;
+
+typedef int (*Execute_Device) (int plugin_name, ...);
+typedef struct {
+ lawmo_ext_name_e ext_name;
+ char *main_path; /* path except to root path */
+ Execute_Device func_execute_device;
+} ext_function_s;
+
+static sync_agent_dev_return_e _fully_lock(int platform, int *err_num, int check_operation);
+static sync_agent_dev_return_e _partially_lock(int platform, int *err_num, int check_operation);
+static sync_agent_dev_return_e _unlock(int platform, int *err_num, int check_operation);
+static sync_agent_dev_return_e _factory_reset(int platform, int *err_num, int check_operation);
+static sync_agent_dev_return_e _remote_wipe(int platform, int *err_num, int check_operation);
+static sync_agent_dev_return_e _ring_my_phone_start(int platform, int *err_num, int check_operation);
+static sync_agent_dev_return_e _ring_my_phone_stop(int platform, int *err_num, int check_operation);
+static sync_agent_dev_return_e _mobile_tracking_get_location(int platform, int *err_num, int check_operation);
+static sync_agent_dev_return_e _mobile_tracking_operation_stop(int platform, int *err_num, int check_operation);
+static sync_agent_dev_return_e _mobile_tracking_operation(int platform, int *err_num, int check_operation);
+static sync_agent_dev_return_e _forwarding_diver_request(int platform, int *err_num, int check_operation);
+static sync_agent_dev_return_e _master_key_lock_release(int platform, int *err_num, int check_operation);
+
+static ext_function_s ext_functions[] = {
+
+ /* Lock & Wipe */
+ {FULLY_LOCK, "LAWMO/OSP/Operations/FullyLock", (Execute_Device) _fully_lock},
+ {PARTAILLY_LOCK, "LAWMO/OSP/Operations/PartiallyLock", (Execute_Device) _partially_lock},
+ {UNLOCK, "LAWMO/OSP/Operations/UnLock", (Execute_Device) _unlock},
+ {FACTORY_RESET, "LAWMO/OSP/Operations/FactoryReset", (Execute_Device) _factory_reset},
+ {WIPE, "LAWMO/OSP/Operations/Wipe", (Execute_Device) _remote_wipe},
+ /* TODO : should add the lock&wipe interface */
+
+ /* Ring My Phone */
+ /* TODO */
+ {RING_START, "LAWMO/OSP/Ext/RingMyPhone/Operations/Start", (Execute_Device) _ring_my_phone_start},
+ {RING_STOP, "LAWMO/OSP/Ext/RingMyPhone/Operations/Stop", (Execute_Device) _ring_my_phone_stop},
+
+ /* Location */
+ /* TODO */
+ {MT_LOCATION, "MobileTraking/Operation/Get/Location", (Execute_Device) _mobile_tracking_get_location},
+ {MT_STOP, "MobileTracking/Operations/Stop", (Execute_Device) _mobile_tracking_operation_stop},
+ {MT_TRACKING, "MobileTracking/Operations/Tracking", (Execute_Device) _mobile_tracking_operation},
+
+ /* Forwarding */
+ /* TODO */
+ {FW_DIVERTREQUEST, "Forwarding/Operations/DivertRequest", (Execute_Device) _forwarding_diver_request},
+
+ /* MasterKey */
+ /* TODO */
+ {MK_LOCK, "MasterKey/Operations/LockRelease", (Execute_Device) _master_key_lock_release},
+
+ {0, 0} /* end array */
+};
+
+static sync_agent_get_devinfo_cb func_get_dev_Info = 0;
+
+/* static function */
+static char *_get_main_path(const char *mo_path);
+
+//static int _get_index(const char *name);
+//static char *_get_mo_value_str(const char *vconf_key, int n_index);
+
+EXPORT_API char **sync_agent_plugin_get_server_id_list(int *server_id_list_cnt)
+{
+ _EXTERN_FUNC_ENTER;
+/*
+ *server_id_list_cnt = 0;
+ char **temp_id_list = (char **)calloc(SERVER_NUM, sizeof(char *));
+ if (temp_id_list == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+
+ char *sever_name = 0;
+ int server_idx = 0;
+ char *server_id = 0;
+
+ int i;
+ for (i = 0; i < SERVER_NUM; i++) {
+
+ switch (i) {
+ case 0:
+ sever_name = ALTER_SYNCMLDM_ACCNAME_1;
+ break;
+ case 1:
+ sever_name = ALTER_SYNCMLDM_ACCNAME_2;
+ break;
+ }
+
+ server_idx = _get_index(sever_name);
+ server_id = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_SERVID, server_idx);
+ if (server_id == NULL) {
+ switch(i){
+ case 0:
+ server_id = strdup(ALTER_SYNCMLDM_SERVID_1);
+ break;
+ case 1:
+ server_id = strdup(ALTER_SYNCMLDM_SERVID_2);
+ break;
+ }
+ }
+ _DEBUG_INFO("Temp_id_list[%d] = %s\n", i, server_id);
+ temp_id_list[i] = server_id;
+ (*server_id_list_cnt)++;
+ }
+ _DEBUG_INFO("server_id_list_cnt = %d\n", *server_id_list_cnt);
+
+ _EXTERN_FUNC_EXIT;
+ return temp_id_list;
+*/
+ *server_id_list_cnt = 1;
+ char **temp_id_list = (char **)calloc(SERVER_NUM, sizeof(char *));
+ if (temp_id_list == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+ }
+ char *server_id = NULL;
+ server_id = strdup("*");
+ *temp_id_list = server_id;
+
+ _DEBUG_INFO("lawmo server_id = %s\n", server_id);
+ _DEBUG_INFO("lawmo server_id_list_cnt = %d\n", *server_id_list_cnt);
+
+ _EXTERN_FUNC_EXIT;
+ return temp_id_list;
+}
+
+EXPORT_API int sync_agent_plugin_get_mo_value(const char *mo_pull_path, const char *mo_name, char **mo_value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO("mo_name : %s", mo_name);
+ *mo_value = 0;
+
+ if (mo_pull_path == NULL || mo_name == NULL) {
+ return -1;
+ }
+
+ _DEBUG_INFO("mo_value : %s", *mo_value);
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+EXPORT_API void sync_agent_plugin_set_function_get_devinfo(sync_agent_get_devinfo_cb func)
+{
+ _EXTERN_FUNC_ENTER;
+
+ func_get_dev_Info = func;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API int sync_agent_plugin_initialize()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int result = 0;
+ result = 0; //req_fmm_server_reg(NULL);
+ /*
+ if (result != 0) {
+ goto error;
+ }
+ */
+ _EXTERN_FUNC_EXIT;
+ return 1;
+/*
+ error:
+ _EXTERN_FUNC_EXIT;
+ return -1; // Fail
+*/
+}
+
+EXPORT_API int sync_agent_plugin_execute_ext(const char *mo_path, int *err_num, int check_operation)
+{
+ _EXTERN_FUNC_ENTER;
+
+ if (mo_path == NULL) {
+ _DEBUG_INFO("mo_path is NULL\n");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ _DEBUG_INFO("mo_path = %s\n", mo_path);
+
+ char *main_path = _get_main_path(mo_path);
+ if (main_path == NULL) {
+ _DEBUG_INFO("main_path is NULL\n");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ _DEBUG_INFO("main_path = %s\n", main_path);
+
+ int ret = 1;
+ int slp_exe_ret = 1;
+
+ int i = 0;
+ while (ext_functions[i].main_path != 0 && ext_functions[i].func_execute_device != 0) {
+ _DEBUG_INFO("oper 1 %s", main_path);
+ _DEBUG_INFO("oper 2 %s", ext_functions[i].main_path);
+ if (strcmp(main_path, ext_functions[i].main_path) == 0) {
+ _DEBUG_INFO("%s Part", main_path);
+
+ slp_exe_ret = ext_functions[i].func_execute_device(1, err_num, check_operation);
+ _DEBUG_INFO("execute return : %d", slp_exe_ret);
+
+ if (slp_exe_ret != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ ret = 0;
+ _DEBUG_INFO("--------------------------------------lawmo operation fail : %d---------------------------------\n", (*err_num));
+ } else {
+ //*err_num = __convert_errcode(ext_functions[i].ext_name, slp_exe_ret);
+ _DEBUG_INFO("--------------------------------------lawmo result value : %d---------------------------------\n", (*err_num));
+ }
+ break;
+ } else {
+ _DEBUG_INFO("--------------------------------------not search lawmo operation---------------------------------\n");
+ }
+ i++;
+ }
+
+ if (main_path != NULL)
+ free(main_path);
+
+ _EXTERN_FUNC_EXIT;
+ return ret;
+}
+
+static char *_get_main_path(const char *mo_path)
+{
+ _INNER_FUNC_ENTER;
+
+ int root_length = strlen(ROOT);
+ int mo_path_length = strlen(mo_path);
+
+ char *main_path = 0;
+
+ char *ptr = strstr(mo_path, ROOT);
+ if (ptr != NULL && root_length < mo_path_length) {
+ _DEBUG_TRACE("%s Search Success !!\n", ROOT);
+ main_path = g_strdup_printf("%s", mo_path + (root_length + 1));
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return main_path;
+}
+
+/*
+static int _get_index(const char *name)
+{
+ _INNER_FUNC_ENTER;
+
+ if (name == NULL) {
+ return -1;
+ }
+
+ int n_acc_count = 0;
+ if (vconf_get_int(CSC_VCONF_KEY_SYNCMLDM_NBFIELD, &n_acc_count)) {
+ _DEBUG_TRACE("vconf_get_int FAIL");
+ //return -1;
+ n_acc_count =ALTER_SYNCMLDM_NBFIELD;
+ }
+
+ _DEBUG_TRACE("nAccCount : %d", n_acc_count);
+
+ int i = 0;
+ for (; i < n_acc_count; i++) {
+ char *compare_name = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_ACCNAME, i + 1);
+ if (compare_name == NULL) {
+ switch(i) {
+ case 0:
+ compare_name = ALTER_SYNCMLDM_ACCNAME_1;
+ break;
+ case 1:
+ compare_name = ALTER_SYNCMLDM_ACCNAME_2;
+ break;
+ default :
+ continue;
+ break;
+ }
+ }
+ _DEBUG_TRACE("[%d] compare_name : %s [%d], name : %s [%d]", i, compare_name, strlen(compare_name), name, strlen(name));
+ if (!strcmp(name, compare_name)) {
+ _DEBUG_TRACE("nIndex : %d", i + 1);
+ _INNER_FUNC_EXIT;
+ return i + 1;
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+ return -1;
+}
+
+static char *_get_mo_value_str(const char *vconf_key, int n_index)
+{
+ _INNER_FUNC_ENTER;
+
+ if (n_index == -1) {
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+
+ char input_vconf_path[200] = { 0, };
+ char rec_idx[8];
+
+ memset(rec_idx, 0x0, sizeof(rec_idx));
+ snprintf(rec_idx, sizeof(rec_idx), "%d", n_index);
+ snprintf(input_vconf_path, strlen(vconf_key) + strlen(rec_idx) + 1, vconf_key, n_index);
+
+ char *value = vconf_get_str(input_vconf_path);
+ if (value == NULL) {
+ _DEBUG_TRACE("vconf_get_str FAIL");
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return value;
+}
+*/
+
+static sync_agent_dev_return_e _fully_lock(int platform, int *err_num, int check_operation)
+{
+ _INNER_FUNC_ENTER;
+
+ /* AMT OFF */
+ _DEBUG_TRACE("====================Fully_Lock==================== \n");
+ _DEBUG_TRACE("check_operarion [%d]\n", check_operation);
+
+ int return_value;
+
+ if (check_operation == 1) {
+ _DEBUG_TRACE("checked : 1 =======return 202 =======\n");
+ *err_num = 202;
+ } else {
+
+ return_value = EXE_SUCCESS; //exec_fully_lock();
+ _DEBUG_TRACE("checked : 0 =======return :%d =======\n", return_value);
+ /*
+ if (return_value == EXE_SUCCESS) {
+ *err_num = OPERATION_SUCCEEDED;
+ } else {
+ *err_num = CLIENT_ERROR;
+ }
+ */
+ }
+
+ _INNER_FUNC_EXIT;
+ return SYNC_AGENT_DEV_RETURN_SUCCESS;
+
+}
+
+static sync_agent_dev_return_e _partially_lock(int platform, int *err_num, int check_operation)
+{
+ _INNER_FUNC_ENTER;
+
+ /* AMT OFF */
+ _DEBUG_TRACE("====================Partially_Lock==================== \n");
+ sleep(3);
+ int return_value = OPERATION_SUCCEEDED;
+ /*
+ return PARTIALLY_LOCK_DEVICE_FAILED;
+ sync_agent_execute_dev_function(2, "partial_lock", 0);
+ vconf_get_bool(VCONFKEY_SETAPPL_FIND_MY_MOBILE_REMOTE_CONTROL_BOOL, &rc_status));
+ if(true)
+ return_value = 1200;
+ else
+ return_value = 1452;
+ */
+ *err_num = return_value;
+
+ _INNER_FUNC_EXIT;
+ return SYNC_AGENT_DEV_RETURN_SUCCESS;
+}
+
+static sync_agent_dev_return_e _unlock(int platform, int *err_num, int check_operation)
+{
+ _INNER_FUNC_ENTER;
+
+ /* AMT OFF */
+ _DEBUG_TRACE("====================UnLock==================== \n");
+ _DEBUG_TRACE("check_operarion [%d]\n", check_operation);
+
+ int return_value = OPERATION_SUCCEEDED;
+
+ *err_num = return_value;
+
+ _INNER_FUNC_EXIT;
+ return SYNC_AGENT_DEV_RETURN_SUCCESS;
+}
+
+static sync_agent_dev_return_e _factory_reset(int platform, int *err_num, int check_operation)
+{
+ _INNER_FUNC_ENTER;
+
+ /* AMT OFF */
+ _DEBUG_TRACE("====================Factory_Reset==================== \n");
+ int return_value = OPERATION_SUCCEEDED;
+ sleep(3);
+ /*
+ vconf_get_bool(VCONFKEY_SETAPPL_FIND_MY_MOBILE_REMOTE_CONTROL_BOOL, &rc_status));
+ if(true)
+ return_value = 1200;
+ else
+ return_value = 1452;
+ */
+ *err_num = return_value;
+
+ _INNER_FUNC_EXIT;
+ return SYNC_AGENT_DEV_RETURN_SUCCESS;
+}
+
+static sync_agent_dev_return_e _remote_wipe(int platform, int *err_num, int check_operation)
+{
+ _INNER_FUNC_ENTER;
+ /* AMT OFF */
+ _DEBUG_TRACE("====================Remote_Wipe==================== \n");
+
+ int return_value = 202;
+ if (check_operation == 1) {
+ /*
+ vconf_get_bool(VCONFKEY_SETAPPL_FIND_MY_MOBILE_REMOTE_CONTROL_BOOL, &rc_status));
+ if(true)
+ return_value = 202;
+ else
+ return_value = 1452;
+ */
+ *err_num = return_value;
+ } else {
+ return_value = OPERATION_SUCCEEDED; //exec_wipe_out();
+ g_printf("checked : 0 =======return :%d =======\n", return_value);
+ *err_num = return_value;
+ }
+ /*
+ sync_agent_execute_dev_function(2, "factory_reset", 0);
+ return WIPE_OPERATION_NOT_PERFORMED;
+ return WIPE_DEVICES_DATA_FAILED;
+ return EXTERNAL_AND_SIM_MEMORY_WIPE_FAILED;
+ return EXTERNAL_MEMORY_WIPE_FAILED;
+ return SIM_MEMORY_WIPE_FAILED;
+ */
+ _INNER_FUNC_EXIT;
+ return SYNC_AGENT_DEV_RETURN_SUCCESS;
+}
+
+static sync_agent_dev_return_e _ring_my_phone_start(int platform, int *err_num, int check_operation)
+{
+ _INNER_FUNC_EXIT;
+
+ /* AMT OFF */
+ _DEBUG_TRACE("====================Ring my phone start==================== \n");
+ _DEBUG_TRACE("check_operarion [%d]\n", check_operation);
+
+ int return_value;
+
+ if (check_operation == 1) {
+ /*
+ vconf_get_bool(VCONFKEY_SETAPPL_FIND_MY_MOBILE_REMOTE_CONTROL_BOOL, &rc_status));
+ if(true)
+ return_value = 1200;
+ else
+ return_value = 1452;
+ */
+ *err_num = OPERATION_SUCCEEDED;
+
+ } else {
+ return_value = EXE_SUCCESS; // exec_ring_start();
+ _DEBUG_TRACE("checked : 0 =======return :%d =======\n", return_value);
+ /*
+ if (return_value == EXE_SUCCESS) {
+ *err_num = OPERATION_SUCCEEDED;
+ } else {
+ *err_num = AMT_STATUS_OFF;
+ }
+ */
+ }
+
+ _INNER_FUNC_EXIT;
+ return SYNC_AGENT_DEV_RETURN_SUCCESS;
+}
+
+static sync_agent_dev_return_e _ring_my_phone_stop(int platform, int *err_num, int check_operation)
+{
+ _INNER_FUNC_ENTER;
+ /* AMT OFF */
+ _DEBUG_TRACE("====================Ring my phone stop====================\n");
+ _DEBUG_TRACE("check_operarion [%d]\n", check_operation);
+
+ int return_value = 202;
+ sleep(3);
+
+ if (check_operation == 1) {
+ *err_num = return_value;
+ } else {
+
+ return_value = EXE_SUCCESS; //exec_ring_stop();
+ /*
+ if (return_value == EXE_SUCCESS) {
+ *err_num = OPERATION_SUCCEEDED;
+ } else {
+ *err_num = OPERATION_SUCCEEDED;
+ }
+ */
+ }
+
+ _INNER_FUNC_EXIT;
+ return SYNC_AGENT_DEV_RETURN_SUCCESS;
+}
+
+static sync_agent_dev_return_e _mobile_tracking_get_location(int platform, int *err_num, int check_operation)
+{
+ _INNER_FUNC_ENTER;
+
+ /* AMT OFF */
+ _DEBUG_TRACE("====================MobileTracking_Get_Location====================\n");
+ sleep(3);
+ int return_value = 202;
+ if (check_operation == 1) {
+ /*
+ vconf_get_bool(VCONFKEY_SETAPPL_FIND_MY_MOBILE_REMOTE_CONTROL_BOOL, &rc_status));
+ if(true)
+ return_value = 202;
+ else
+ return_value = 1452;
+ */
+ _DEBUG_TRACE("checked : 1 =======return 202 =======\n");
+ *err_num = return_value;
+ } else {
+ return_value = OPERATION_SUCCEEDED; // exec_location();
+ _DEBUG_TRACE("checked : 0 =======return :%d =======\n", return_value);
+ *err_num = return_value;
+ }
+
+ _INNER_FUNC_EXIT;
+ return SYNC_AGENT_DEV_RETURN_SUCCESS;
+}
+
+static sync_agent_dev_return_e _mobile_tracking_operation_stop(int platform, int *err_num, int check_operation)
+{
+ _INNER_FUNC_ENTER;
+
+ /* AMT OFF */
+ _DEBUG_TRACE("====================MobileTracking_Operation_Stop====================\n");
+ sleep(3);
+
+ *err_num = OPERATION_SUCCEEDED;
+
+ _INNER_FUNC_EXIT;
+ return SYNC_AGENT_DEV_RETURN_SUCCESS;
+}
+
+static sync_agent_dev_return_e _mobile_tracking_operation(int platform, int *err_num, int check_operation)
+{
+ _INNER_FUNC_ENTER;
+ /* AMT OFF */
+ _DEBUG_TRACE("====================MobileTracking_Operation====================\n");
+ sleep(3);
+ int return_value = 202;
+ if (check_operation == 1) {
+ *err_num = return_value;
+ } else {
+ *err_num = OPERATION_SUCCEEDED;
+ }
+
+ _INNER_FUNC_EXIT;
+ return SYNC_AGENT_DEV_RETURN_SUCCESS;
+
+}
+
+static sync_agent_dev_return_e _forwarding_diver_request(int platform, int *err_num, int check_operation)
+{
+ _INNER_FUNC_ENTER;
+
+ /* AMT OFF */
+ _DEBUG_TRACE("====================Forwarding_DiverRequest====================\n");
+ int return_value = 202;
+ if (check_operation == 1) {
+ /*
+ vconf_get_bool(VCONFKEY_SETAPPL_FIND_MY_MOBILE_REMOTE_CONTROL_BOOL, &rc_status));
+ if(true)
+ return_value = 202;
+ else
+ return_value = 1452;
+ */
+ //return return_value;
+ *err_num = return_value;
+ } else {
+ return_value = OPERATION_SUCCEEDED; // exec_call_forwarding();
+ _DEBUG_TRACE("checked : 0 =======return :%d =======\n", return_value);
+ *err_num = return_value;
+ }
+ /*
+ return CALL_AND_SMS_FORWARDING_FAILED;
+ return CALL_FORWARDING_FAILED;
+ return SMS_FORWARDING_FAILED;
+ */
+ //return return_value;
+
+ _INNER_FUNC_EXIT;
+ return SYNC_AGENT_DEV_RETURN_SUCCESS;
+
+}
+
+static sync_agent_dev_return_e _master_key_lock_release(int platform, int *err_num, int check_operation)
+{
+ _INNER_FUNC_ENTER;
+ /* AMT OFF */
+ _DEBUG_TRACE("====================MasterKey_LockRelease====================\n");
+ _DEBUG_TRACE("check_operarion [%d]\n", check_operation);
+ int return_value = 202;
+ /* for test */
+
+ if (check_operation == 1) {
+ *err_num = return_value;
+ } else {
+
+ return_value = EXE_SUCCESS; //exec_unlock_lock();
+ /*
+ if (return_value == EXE_SUCCESS) {
+ *err_num = OPERATION_SUCCEEDED;
+ } else {
+ *err_num = OPERATION_SUCCEEDED;
+ }
+ */
+ }
+
+ _INNER_FUNC_EXIT;
+ return SYNC_AGENT_DEV_RETURN_SUCCESS;
+}
diff --git a/src/plugins/dm-private/multiapps/CMakeLists.txt b/src/plugins/dm-private/multiapps/CMakeLists.txt
new file mode 100755
index 0000000..0c49126
--- /dev/null
+++ b/src/plugins/dm-private/multiapps/CMakeLists.txt
@@ -0,0 +1,43 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "mo-multiapps")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(mo-multiapps REQUIRED
+ sync-agent
+ vconf
+ dlog
+ libwbxml2
+ )
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${mo-multiapps_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${mo-multiapps_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub) \ No newline at end of file
diff --git a/src/plugins/dm-private/multiapps/src/plugin_interface.c b/src/plugins/dm-private/multiapps/src/plugin_interface.c
new file mode 100755
index 0000000..b0cb86d
--- /dev/null
+++ b/src/plugins/dm-private/multiapps/src/plugin_interface.c
@@ -0,0 +1,192 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <glib.h>
+#include <glib/gprintf.h>
+#include <vconf.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_MULTIAPPS"
+#endif
+
+#define SERVER_NUM 1
+/*
+#define CSC_VCONF_KEY_SYNCMLDM_NBFIELD "db/SyncML/oma-dm-service/DevManagement/NbDevManagement"
+#define CSC_VCONF_KEY_SYNCMLDM_ACCNAME "db/SyncML/oma-dm-service/DevManagement/%d/AccName"
+#define CSC_VCONF_KEY_SYNCMLDM_SERVID "db/SyncML/oma-dm-service/DevManagement/%d/ServID"
+
+#define ALTER_SYNCMLDM_NBFIELD 3
+#define SERVER_NUM 1
+#define ALTER_SYNCMLDM_ACCNAME "gcf"
+#define ALTER_SYNCMLDM_SERVID "RSate"
+*/
+
+#define ROOT "./Application"
+
+static sync_agent_get_devinfo_cb func_get_dev_info = 0;
+
+//static int _get_Index(const char *name);
+//static char *_get_MO_Value_STR(const char *vconf_key, int nIndex);
+
+EXPORT_API char **sync_agent_plugin_get_server_id_list(int *server_id_list_cnt)
+{
+ _EXTERN_FUNC_ENTER;
+/*
+ char **temp_id_list = (char **)calloc(SERVER_NUM, sizeof(char *));
+ if (temp_id_list == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+
+ int server_idx = _get_Index(ALTER_SYNCMLDM_ACCNAME);
+ char *server_id = _get_MO_Value_STR(CSC_VCONF_KEY_SYNCMLDM_SERVID, server_idx);
+ if (server_id == NULL) {
+ server_id = strdup(ALTER_SYNCMLDM_SERVID);
+ }
+ *temp_id_list = server_id;
+ *server_id_list_cnt = 1;
+
+ _DEBUG_INFO("server_id = %s\n", server_id);
+ _DEBUG_INFO("server_id_list_cnt = %d\n", *server_id_list_cnt);
+
+ _EXTERN_FUNC_EXIT;
+ return temp_id_list;
+*/
+ *server_id_list_cnt = 1;
+ char **temp_id_list = (char **)calloc(SERVER_NUM, sizeof(char *));
+ if (temp_id_list == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+ }
+ char *server_id = NULL;
+ server_id = strdup("*");
+ *temp_id_list = server_id;
+
+ _DEBUG_INFO("multiapps server_id = %s\n", server_id);
+ _DEBUG_INFO("multiapps server_id_list_cnt = %d\n", *server_id_list_cnt);
+
+ _EXTERN_FUNC_EXIT;
+ return temp_id_list;
+}
+
+EXPORT_API int sync_agent_plugin_get_mo_value(const char *mo_pull_path, const char *mo_name, char **mo_value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((mo_pull_path) == NULL, -1, "mo_pull_path is NULL!!");
+ retvm_if((mo_name) == NULL, -1, "mo_name is NULL!!");
+
+ _DEBUG_INFO("mo_name : %s", mo_name);
+ *mo_value = 0;
+
+ _DEBUG_INFO("mo_value : %s", *mo_value);
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+EXPORT_API void sync_agent_plugin_set_function_get_devinfo(sync_agent_get_devinfo_cb func)
+{
+ _EXTERN_FUNC_ENTER;
+
+ func_get_dev_info = func;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API int sync_agent_plugin_initialize()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int result = 1;
+
+ _EXTERN_FUNC_EXIT;
+ return result;
+}
+
+/*
+static int _get_Index(const char *name)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((name) == NULL, -1, "name is NULL!!");
+
+ int acc_count = 0;
+ if (vconf_get_int(CSC_VCONF_KEY_SYNCMLDM_NBFIELD, &acc_count)) {
+ _DEBUG_TRACE("vconf_get_int FAIL");
+ //return -1;
+ acc_count =ALTER_SYNCMLDM_NBFIELD;
+ }
+
+ _DEBUG_TRACE("nAccCount : %d", acc_count);
+
+ int i = 0;
+ for (; i < acc_count; i++) {
+ char *compare_name = _get_MO_Value_STR(CSC_VCONF_KEY_SYNCMLDM_ACCNAME, i + 1);
+ if (compare_name == NULL) {
+ compare_name = ALTER_SYNCMLDM_ACCNAME;
+ }
+ _DEBUG_TRACE("[%d] compare_name : %s [%d], name : %s [%d]", i, compare_name, strlen(compare_name), name, strlen(name));
+ if (!strcmp(name, compare_name)) {
+ _DEBUG_TRACE("nIndex : %d", i + 1);
+ _INNER_FUNC_EXIT;
+ return i + 1;
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+ return -1;
+}
+
+static char *_get_MO_Value_STR(const char *vconf_key, int nIndex)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((vconf_key) == NULL, NULL, "vconf_key is NULL!!");
+
+ if (nIndex == -1) {
+ _INNER_FUNC_EXIT;
+ return 0;
+ }
+
+ char input_vconf_path[200] = { 0, };
+ char rec_idx[8];
+
+ memset(rec_idx, 0x0, sizeof(rec_idx));
+ snprintf(rec_idx, sizeof(rec_idx), "%d", nIndex);
+ snprintf(input_vconf_path, strlen(vconf_key) + strlen(rec_idx) + 1, vconf_key, nIndex);
+
+ char *value = vconf_get_str(input_vconf_path);
+ if (value == NULL) {
+ _DEBUG_TRACE("vconf_get_str FAIL");
+ }
+
+ _INNER_FUNC_EXIT;
+ return value;
+}
+*/
diff --git a/src/plugins/dm-private/slp-device-dm/CMakeLists.txt b/src/plugins/dm-private/slp-device-dm/CMakeLists.txt
new file mode 100755
index 0000000..0f8050f
--- /dev/null
+++ b/src/plugins/dm-private/slp-device-dm/CMakeLists.txt
@@ -0,0 +1,48 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "di-slp-device-dm")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+ sync-agent
+ glib-2.0
+ vconf
+ tapi
+ pmapi
+ dlog
+ libwbxml2
+ )
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${di-slp-device-dm_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${di-slp-device-dm_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/plugin_slp_device_dm.h DESTINATION include/sync-agent/plugin/)
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub)
diff --git a/src/plugins/dm-private/slp-device-dm/include/plugin_devexe_error.h b/src/plugins/dm-private/slp-device-dm/include/plugin_devexe_error.h
new file mode 100755
index 0000000..cda4e6b
--- /dev/null
+++ b/src/plugins/dm-private/slp-device-dm/include/plugin_devexe_error.h
@@ -0,0 +1,47 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLUGIN_DEVEXE_ERROR_H_
+#define PLUGIN_DEVEXE_ERROR_H_
+
+typedef enum {
+
+ EXE_SUCCESS = 1,
+ EXE_DEV_FAIL = -1,
+
+ /* standard error */
+ EXE_DEV_DATA_FAIL = -2,
+ EXE_DEV_OPER_NOT_PERFORMED = -3,
+
+ /* vender specific error */
+
+ /*common */
+ EXE_DEV_AMT_STATUS_OFF = -4,
+ EXEC_DEV_SCREEN_OFF = -5,
+
+ /*wipe */
+ EXE_DEV_WIPE_ALL_FAILED = -10,
+ EXE_DEV_EXTERNAL_MEMORY_FAILED = -11,
+ EXE_DEV_SIM_MEMORY_FAILED = -12,
+
+ /*forwarding */
+ EXE_DEV_FORWORDING_ALL_FAILED = -20,
+ EXE_DEV_FORWORDING_CALL_FAILED = -21,
+ EXE_DEV_FORWORDING_SMS_FAILED = -22
+} slp_device_dm_exe_e;
+
+#endif /* PLUGIN_DEVEXE_ERROR_H_ */
diff --git a/src/plugins/dm-private/slp-device-dm/include/plugin_slp_device_ctrl.h b/src/plugins/dm-private/slp-device-dm/include/plugin_slp_device_ctrl.h
new file mode 100755
index 0000000..c3b2319
--- /dev/null
+++ b/src/plugins/dm-private/slp-device-dm/include/plugin_slp_device_ctrl.h
@@ -0,0 +1,29 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SLP_DEVICE_CTRL_H_
+#define SLP_DEVICE_CTRL_H_
+
+int slp_device_ctrl_set_fota_flag();
+int slp_device_ctrl_get_fota_update_result();
+int slp_device_ctrl_reboot();
+int slp_device_ctrl_fully_lock();
+int slp_device_ctrl_partially_lock();
+int slp_device_ctrl_unlock();
+int slp_device_ctrl_factory_reset();
+
+#endif /* SLP_DEVICE_CTRL_H_ */
diff --git a/src/plugins/dm-private/slp-device-dm/include/plugin_slp_device_dm.h b/src/plugins/dm-private/slp-device-dm/include/plugin_slp_device_dm.h
new file mode 100755
index 0000000..bcbdc5d
--- /dev/null
+++ b/src/plugins/dm-private/slp-device-dm/include/plugin_slp_device_dm.h
@@ -0,0 +1,81 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLUGIN_SLP_DEVICE_DM_H_
+#define PLUGIN_SLP_DEVICE_DM_H_
+
+/*
+ * list of device information on SLP
+ */
+
+/*
+ * < OMA DM >
+ * 1. DevInfo
+ * - DevID : device id
+ * - Man : manufacture
+ * - Mod : model id or model number
+ * - DmV : OMA DM client version
+ * - Lang : current setting language
+ * - Bearer : bearer
+ *
+ * 2. DevDetail
+ * - KernelV : kernel version
+ * - SwV : software version
+ * - HwV : hardware version
+ * - FwV : firmware version
+ * - ModemV : modem version
+ * - PDAV : PDA version
+ * - OEM : original equipment manufacturer
+ * - DevType : device type
+ * - Bearer : bearer
+ * - FOTADownDir : firmware download directory
+ * - FOTASaveDir : firmware save directory
+ * - Battery : battery level
+ * - MCC :contry code
+ * - CSC:
+ */
+
+/**
+ * @brief Enumerations for state of power manager
+ */
+typedef enum {
+ LCD_NORMAL = 0,
+ LCD_DIM,
+ LCD_OFF,
+ SUSPEND,
+ POWER_OFF,
+ SETALL
+} pm_state_e;
+
+/**
+ * @brief Enumerations for lock state of power manager
+ */
+typedef enum {
+ GOTO_STATE_NOW = 0,
+ STAY_CUR_STATE
+} pm_lock_state_flag_e;
+
+/**
+ * @brief Enumerations for unlock state of power manager
+ */
+typedef enum {
+ SLEEP_MARGIN = 0,
+ RESET_TIMER,
+ KEEP_TIMER
+} pm_unlock_state_flag_e;
+
+#endif /* PLUGIN_SLP_DEVICE_DM_H_ */
diff --git a/src/plugins/dm-private/slp-device-dm/include/plugin_slp_device_info.h b/src/plugins/dm-private/slp-device-dm/include/plugin_slp_device_info.h
new file mode 100755
index 0000000..a1fa0f3
--- /dev/null
+++ b/src/plugins/dm-private/slp-device-dm/include/plugin_slp_device_info.h
@@ -0,0 +1,36 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SAMSUNG_DEVICE_INFO_H_
+#define SAMSUNG_DEVICE_INFO_H_
+
+char *slp_device_info_get_dtd_version();
+char *slp_device_info_get_kernel_version();
+char *slp_device_info_get_msisdn_number();
+char *slp_device_info_get_mcc();
+char *slp_device_info_get_csc();
+
+char *slp_device_info_get_fota_download_dir();
+char *slp_device_info_get_fota_save_dir();
+char *slp_device_info_get_fota_sd_download_dir();
+char *slp_device_info_get_fota_sd_save_dir();
+
+char *slp_device_info_get_opco_info();
+
+char *slp_device_info_get_imsi_info();
+
+#endif /* SAMSUNG_DEVICE_INFO_H_ */
diff --git a/src/plugins/dm-private/slp-device-dm/src/plugin_interface_devexe.c b/src/plugins/dm-private/slp-device-dm/src/plugin_interface_devexe.c
new file mode 100755
index 0000000..9543039
--- /dev/null
+++ b/src/plugins/dm-private/slp-device-dm/src/plugin_interface_devexe.c
@@ -0,0 +1,572 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+#include "plugin_slp_device_dm.h"
+#include "plugin_devexe_error.h"
+#include "plugin_slp_device_ctrl.h"
+
+#include "pmapi.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_DEVICE_SLP_DM"
+#endif
+
+#define DELTA_FILE "delta_hash.txt"
+
+static sync_agent_execute_dev_cb func_execute_dev_function_common = 0;
+
+static int _execute_dev_fota_flag(int memory_type);
+static int _execute_dev_fota_update_result(int *plugin_err);
+static int _execute_dev_reboot();
+static int _execute_dev_fully_lock();
+static int _execute_dev_partially_lock();
+static int _execute_dev_unlock();
+static int _execute_dev_factory_reset();
+static int _execute_dev_wipe();
+static sync_agent_dev_return_e __convert_service_err_to_common_error(int service_err);
+/*static int __find_file_list(const char *folder_path, GSList **file_list);*/
+static int ___find_file(const char *folder_path, const char **file_path);
+static int ___check_filename_md5(char *folder_path, char *file_buffer);
+static int ___check_fimware_delta_validation(char *save_folder);
+static int __control_fimware_delta_file(int memory_type);
+
+static int ___get_download_save_folder(int memory_type, char **download_folder, char **save_folder);
+int _execute_dev_function_common(char *function_name, int args_cnt, va_list ap);
+
+EXPORT_API int sync_agent_plugin_execute_dev_function(char *function_name, int args_cnt, va_list ap)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((function_name) == NULL, 0, "function_name is NULL!!");
+
+ if (!strncmp(function_name, "pm_lock", strlen("pm_lock")) || !strncmp(function_name, "pm_unlock", strlen("pm_unlock")) || !strncmp(function_name, "pm_change", strlen("pm_change"))) {
+
+ _DEBUG_INFO(" Received %s request !!!", function_name);
+ _EXTERN_FUNC_EXIT;
+ return _execute_dev_function_common(function_name, args_cnt, ap);
+
+ } else if (!strncmp(function_name, "fota_flag", strlen("fota_flag"))) {
+
+ int memory_type = va_arg(ap, int);
+
+ _DEBUG_INFO(" Received %s request !!!", function_name);
+ _EXTERN_FUNC_EXIT;
+ return _execute_dev_fota_flag(memory_type);
+
+ } else if (!strncmp(function_name, "fota_result", strlen("fota_result"))) {
+
+ int *plugin_err = va_arg(ap, int *);
+
+ _DEBUG_INFO(" Received %s request !!!", function_name);
+ _EXTERN_FUNC_EXIT;
+ return _execute_dev_fota_update_result(plugin_err);
+
+ } else if (!strncmp(function_name, "reboot", strlen("reboot"))) {
+
+ _DEBUG_INFO(" Received %s request !!!", function_name);
+ _EXTERN_FUNC_EXIT;
+ return _execute_dev_reboot();
+
+ } else if (!strncmp(function_name, "full_lock", strlen("full_lock"))) {
+
+ _DEBUG_INFO(" Received %s request !!!", function_name);
+ return _execute_dev_fully_lock();
+
+ } else if (!strncmp(function_name, "partial_lock", strlen("partial_lock"))) {
+
+ _DEBUG_INFO(" Received %s request !!!", function_name);
+ _EXTERN_FUNC_EXIT;
+ return _execute_dev_partially_lock();
+
+ } else if (!strncmp(function_name, "unlock", strlen("unlock"))) {
+
+ _DEBUG_INFO(" Received %s request !!!", function_name);
+ _EXTERN_FUNC_EXIT;
+ return _execute_dev_unlock();
+
+ } else if (!strncmp(function_name, "factory_reset", strlen("factory_reset"))) {
+
+ _DEBUG_INFO(" Received %s request !!!", function_name);
+ _EXTERN_FUNC_EXIT;
+ return _execute_dev_factory_reset();
+
+ } else if (!strncmp(function_name, "wipe", strlen("wipe"))) {
+
+ _DEBUG_INFO(" Received %s request !!!", function_name);
+ _EXTERN_FUNC_EXIT;
+ return _execute_dev_wipe();
+
+ } else {
+ _DEBUG_INFO("Device function requested not defined in plug-in !!!");
+ goto error_part;
+ }
+
+ error_part:
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+EXPORT_API void sync_agent_plugin_set_common_execute_dev_function(sync_agent_execute_dev_cb func)
+{
+ _EXTERN_FUNC_ENTER;
+
+ func_execute_dev_function_common = func;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+static int _execute_dev_fota_flag(int memory_type)
+{
+ _INNER_FUNC_ENTER;
+
+ /*slp_device_dm_exe_e err = EXE_SUCCESS; */
+
+ int service_ret = 1;
+ service_ret = __control_fimware_delta_file(memory_type);
+ if (service_ret != 1) {
+ _DEBUG_TRACE("__control_fimware_delta_file() Fail");
+ goto error;
+ }
+ _DEBUG_TRACE("control firmware delta file : %d \n", service_ret);
+
+ service_ret = slp_device_ctrl_set_fota_flag();
+ if (service_ret != 0) {
+ _DEBUG_TRACE("slp_device_ctrl_set_FOTA_flag() Fail");
+ }
+
+ error:
+ _INNER_FUNC_EXIT;
+ return __convert_service_err_to_common_error(service_ret);
+}
+
+static int _execute_dev_fota_update_result(int *plugin_err)
+{
+ _INNER_FUNC_ENTER;
+
+ *plugin_err = slp_device_ctrl_get_fota_update_result();
+
+ _INNER_FUNC_EXIT;
+ return __convert_service_err_to_common_error(1);
+}
+
+static int _execute_dev_reboot()
+{
+ _INNER_FUNC_ENTER;
+
+ int service_ret = slp_device_ctrl_reboot();
+
+ _INNER_FUNC_EXIT;
+ return __convert_service_err_to_common_error(service_ret);
+}
+
+static int _execute_dev_fully_lock()
+{
+ _INNER_FUNC_ENTER;
+
+ int service_ret = slp_device_ctrl_fully_lock();
+
+ _INNER_FUNC_EXIT;
+ return __convert_service_err_to_common_error(service_ret);
+}
+
+static int _execute_dev_partially_lock()
+{
+ _INNER_FUNC_ENTER;
+
+ int service_ret = slp_device_ctrl_partially_lock();
+
+ _INNER_FUNC_EXIT;
+ return __convert_service_err_to_common_error(service_ret);
+}
+
+static int _execute_dev_unlock()
+{
+ _INNER_FUNC_ENTER;
+
+ int service_ret = slp_device_ctrl_unlock();
+
+ _INNER_FUNC_EXIT;
+ return __convert_service_err_to_common_error(service_ret);
+}
+
+static int _execute_dev_factory_reset()
+{
+ _INNER_FUNC_ENTER;
+
+ int service_ret = slp_device_ctrl_factory_reset();
+
+ _INNER_FUNC_EXIT;
+ return __convert_service_err_to_common_error(service_ret);
+}
+
+static int _execute_dev_wipe()
+{
+ _INNER_FUNC_ENTER;
+
+ int service_ret = 1;
+
+ _INNER_FUNC_EXIT;
+ return __convert_service_err_to_common_error(service_ret);
+}
+
+/* static function*/
+/*static int __find_file_list(const char *folder_path, GSList **file_list)
+{
+ _DEBUG_VERBOSE(" start");
+ int ret = 1;
+
+ if (folder_path == NULL) {
+ ret = -1;
+ goto error;
+ }
+
+ _DEBUG_VERBOSE(" folder_path = %s", folder_path);
+
+ GSList *fileList = NULL;
+ ret = sync_agent_get_file_list(folder_path, &fileList);
+ if (ret != 1 || fileList == NULL) {
+ ret = -1;
+ goto error;
+ }
+
+ GSList *iter = NULL;
+ char *temp_file_info = NULL;
+ char *temp_file_name = NULL;
+ char *temp_file_path = NULL;
+
+ for (iter = fileList; iter != NULL; iter = g_slist_next(iter)) {
+ temp_file_info = (char *)(iter->data);
+ _DEBUG_VERBOSE(" file_name = %s", temp_file_info);
+
+ temp_file_name = strtok(temp_file_info, ",");
+
+ (*file_list) = g_slist_append((*file_list), temp_file_name);
+ }
+
+ _DEBUG_VERBOSE(" end");
+ return ret;
+error:
+ _DEBUG_VERBOSE(" end error : %d", ret);
+ return ret;
+}*/
+
+static int ___find_file(const char *folder_path, const char **file_path)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((folder_path) == NULL, -1, "folder_path is NULL!!");
+
+ int ret = 1;
+ GSList *fileList = NULL;
+ ret = sync_agent_get_file_list(folder_path, &fileList);
+ if (ret != 1 || fileList == NULL || g_slist_length(fileList) > 1) {
+ ret = -1;
+ goto error;
+ }
+
+ char *temp_file_info = NULL;
+ char *temp_file_name = NULL;
+
+ temp_file_info = (char *)(fileList->data);
+ _DEBUG_VERBOSE(" file_name = %s", temp_file_info);
+
+ const char *delimiter = ",";
+ /*temp_file_name = strtok(temp_file_info, ","); */
+ temp_file_name = strtok(temp_file_info, delimiter);
+ (*file_path) = g_strdup_printf("%s/%s", folder_path, temp_file_name);
+
+ _INNER_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_VERBOSE(" end error : %d", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static int ___check_filename_md5(char *folder_path, char *file_buffer)
+{
+ _INNER_FUNC_ENTER;
+ int ret = 1;
+
+ retvm_if((folder_path) == NULL, -1, "folder_path is NULL!!");
+ retvm_if((file_buffer) == NULL, -1, "file_buffer is NULL!!");
+
+ _DEBUG_VERBOSE(" check_file_folder : %s", folder_path);
+ _DEBUG_VERBOSE(" check_file : %s", file_buffer);
+
+ bool isSame = false;
+ char *check_segment = NULL;
+ char *find_file_name = NULL;
+ unsigned char *find_md5_word = NULL;
+ char *file_path = NULL;
+
+ GSList *filename_md5 = NULL;
+ GSList *filename_md5_iter = NULL;
+
+ const char *delimiter = ":\t\n ";
+ /*check_segment = strtok(file_buffer, ":\t\n "); */
+ check_segment = strtok(file_buffer, delimiter);
+ _DEBUG_VERBOSE(" check_segment : %s", check_segment);
+ filename_md5 = g_slist_append(filename_md5, check_segment);
+
+ while (check_segment != NULL) {
+ /*check_segment = strtok(NULL, ":\t\n "); */
+ check_segment = strtok(NULL, delimiter);
+ if (check_segment == NULL)
+ break;
+ filename_md5 = g_slist_append(filename_md5, check_segment);
+
+ _DEBUG_VERBOSE(" check file : %s", check_segment);
+ }
+
+ for (filename_md5_iter = filename_md5; filename_md5_iter != NULL; filename_md5_iter = g_slist_next(filename_md5_iter)) {
+ if ((filename_md5_iter->data) == NULL) {
+ ret = -1;
+ goto error;
+ }
+
+ find_file_name = (char *)(filename_md5_iter->data);
+ filename_md5_iter = g_slist_next(filename_md5_iter);
+ find_md5_word = (unsigned char *)(filename_md5_iter->data);
+ _DEBUG_VERBOSE(" find_file_name : %s, find_md5 : %s", find_file_name, find_md5_word);
+
+ file_path = g_strdup_printf("%s/%s", folder_path, find_file_name);
+ ret = sync_agent_is_existing_fs(file_path);
+ if (ret != 1) {
+ goto error;
+ }
+
+ ret = sync_agent_file_md5_validation(file_path, (char *)find_md5_word, &isSame);
+ if (ret != 1 || (ret == 1 && isSame == false))
+ goto error;
+ }
+
+ _INNER_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_VERBOSE(" end error : %d", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static int ___check_fimware_delta_validation(char *save_folder)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((save_folder) == NULL, -1, "save_folder is NULL!!");
+
+ int ret = 0;
+ char *required_contents = NULL;
+ unsigned long required_length = 0;
+ char *file_path = NULL;
+ bool isFinal;
+
+ file_path = g_strdup_printf("%s/%s", save_folder, DELTA_FILE);
+ _DEBUG_VERBOSE(" file_path : %s", file_path);
+
+ ret = sync_agent_read_whole_file(file_path, &required_contents, &required_length);
+ if (ret != 1)
+ goto error;
+ _DEBUG_VERBOSE(" file read is %d, required_length is %d ", ret, required_length);
+ _DEBUG_VERBOSE(" file read is %d, isFinal is %d ", ret, isFinal);
+ _DEBUG_VERBOSE(" file content is %s ", required_contents);
+
+ ret = ___check_filename_md5(save_folder, required_contents);
+ if (ret != 1)
+ goto error;
+
+ ret = sync_agent_free_file(&required_contents);
+ if (ret != 1)
+ goto error;
+
+ _INNER_FUNC_EXIT;
+ return ret;
+
+ error:
+
+ _DEBUG_VERBOSE(" end error : %d \n", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static int __control_fimware_delta_file(int memory_type)
+{
+ _INNER_FUNC_ENTER;
+
+ int ret = 1;
+
+ char *download_folder = NULL;
+ char *save_folder = NULL;
+
+ ret = ___get_download_save_folder(memory_type, &download_folder, &save_folder);
+ if (ret != 1)
+ goto error;
+
+ const char *file_path = NULL;
+ ret = ___find_file(download_folder, &file_path);
+ if (ret != 1)
+ goto error;
+
+ /*file_path = g_strdup_printf("%s%s%s", download_folder, "/","0715_0720_FW_delta.tar"); */
+ sync_agent_util_compress_result_e result = sync_agent_uncompress(SYNC_AGENT_UTIL_COMPRESS_TYPE_TAR, file_path, save_folder);
+ if (result != SYNC_AGENT_UTIL_COMPRESS_SUCCESS) {
+ _DEBUG_VERBOSE(" Failed to call sync_agent_uncompress()");
+ ret = -1;
+ goto error;
+ } else {
+ _DEBUG_VERBOSE(" Success to call sync_agent_uncompress()");
+ }
+
+ ret = ___check_fimware_delta_validation(save_folder);
+ if (ret != 1)
+ goto error;
+
+ int fs_error;
+ fs_error = sync_agent_empty_directory_contents(download_folder);
+
+ _INNER_FUNC_EXIT;
+ return ret;
+ error:
+ _DEBUG_VERBOSE(" end error : %d", ret);
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static sync_agent_dev_return_e __convert_service_err_to_common_error(int service_err)
+{
+ _INNER_FUNC_ENTER;
+
+ slp_device_dm_exe_e ret = EXE_SUCCESS;
+
+ switch (service_err) {
+ case 1:
+ ret = EXE_SUCCESS;
+ break;
+ default:
+ ret = EXE_DEV_OPER_NOT_PERFORMED;
+ break;
+ }
+
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+static int ___get_download_save_folder(int memory_type, char **download_folder, char **save_folder)
+{
+ _INNER_FUNC_ENTER;
+
+ int ret = 1;
+ switch (memory_type) {
+ case 0:
+ {
+ sync_agent_dev_return_e dci_down_ret = sync_agent_get_devinfo(2, "FOTADownDir", download_folder);
+ if (dci_down_ret == SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ _DEBUG_VERBOSE(" download = %s\n", *download_folder);
+ } else {
+ ret = -1;
+ goto error;
+ }
+ sync_agent_dev_return_e dci_save_ret = sync_agent_get_devinfo(2, "FOTASaveDir", save_folder);
+ if (dci_save_ret == SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ _DEBUG_VERBOSE(" save = %s: \n", *save_folder);
+ } else {
+ ret = -1;
+ goto error;
+ }
+ }
+ break;
+ case 1:
+ {
+ sync_agent_dev_return_e dci_down_ret = sync_agent_get_devinfo(2, "FOTA_SD_DownDir", download_folder);
+ if (dci_down_ret == SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ _DEBUG_VERBOSE(" download = %s\n", *download_folder);
+ } else {
+ ret = -1;
+ goto error;
+ }
+ sync_agent_dev_return_e dci_save_ret = sync_agent_get_devinfo(2, "FOTA_SD_SaveDir", save_folder);
+ if (dci_save_ret == SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ _DEBUG_VERBOSE(" save = %s: \n", *save_folder);
+ } else {
+ ret = -1;
+ goto error;
+ }
+ }
+ break;
+ default:
+ ret = -1;
+ goto error;
+ break;
+ }
+ _INNER_FUNC_EXIT;
+ return ret;
+ error:
+ _INNER_FUNC_EXIT;
+ return ret;
+}
+
+int _execute_dev_function_common(char *function_name, int args_cnt, va_list ap)
+{
+ if (function_name == NULL) {
+ _DEBUG_TRACE("KEY name is NULL !!!");
+ return 0;
+ }
+
+ sync_agent_dev_return_e ret = SYNC_AGENT_DEV_RETURN_SUCCESS;
+
+ if (!strncmp(function_name, "pm_lock", strlen("pm_lock"))) {
+
+ pm_state_e state = va_arg(ap, pm_state_e);
+ pm_lock_state_flag_e flag = va_arg(ap, pm_lock_state_flag_e);
+ unsigned int timeout = va_arg(ap, unsigned int);
+
+ ret = func_execute_dev_function_common(1, function_name, args_cnt, state, flag, timeout);
+
+ } else if (!strncmp(function_name, "pm_unlock", strlen("pm_unlock"))) {
+
+ pm_state_e state = va_arg(ap, pm_state_e);
+ pm_unlock_state_flag_e flag = va_arg(ap, pm_unlock_state_flag_e);
+
+ ret = func_execute_dev_function_common(1, function_name, args_cnt, state, flag);
+
+ } else if (!strncmp(function_name, "pm_change", strlen("pm_change"))) {
+
+ pm_state_e state = va_arg(ap, pm_state_e);
+
+ ret = func_execute_dev_function_common(1, function_name, args_cnt, state);
+
+ }
+
+ if (ret == SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ _DEBUG_TRACE("pFunc_Execute_Dev_Function_Common SUCCESS !!!");
+ return 1;
+ } else {
+ _DEBUG_TRACE("pFunc_Execute_Dev_Function_Common FAIL !!!");
+ return 0;
+ }
+}
diff --git a/src/plugins/dm-private/slp-device-dm/src/plugin_interface_devinfo.c b/src/plugins/dm-private/slp-device-dm/src/plugin_interface_devinfo.c
new file mode 100755
index 0000000..e71d260
--- /dev/null
+++ b/src/plugins/dm-private/slp-device-dm/src/plugin_interface_devinfo.c
@@ -0,0 +1,455 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include <vconf.h>
+#include <vconf-keys.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+#include "plugin_slp_device_info.h"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_DEVICE_SLP_DM"
+#endif
+
+#define IMEI_LEN 5
+#define FW_VERSION_LEN 20
+#define BUFF_SIZE 1000
+
+/* todo : temporary definition */
+#define HW_VERSION "1.0"
+
+typedef struct {
+ char *info_name;
+ char *vconf_key;
+} dici_name_key_map;
+
+dici_name_key_map dev_key_map[] = {
+ {"SwV", VCONFKEY_TELEPHONY_SWVERSION},
+ {"HwV", VCONFKEY_TELEPHONY_HWVERSION},
+ /*{"Lang", "db/menu_widget/language"}, */
+ {"Lang", VCONFKEY_LANGSET},
+ {NULL, NULL},
+};
+
+static GList *devInfo;
+static sync_agent_get_devinfo_cb func_get_dev_info_common = 0;
+
+static char *_get_dev_info_common(char *key);
+
+EXPORT_API int sync_agent_plugin_load_devinfo()
+{
+ _EXTERN_FUNC_ENTER;
+
+ g_type_init();
+
+ int res = 1;
+
+ devInfo = NULL;
+
+ /* get SwV */
+ sync_agent_plugin_device_info_s *swv = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (swv == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(swv, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ swv->info_name = strdup("SwV");
+ swv->value = _get_dev_info_common(swv->info_name);
+ devInfo = g_list_append(devInfo, swv);
+
+ /* get HwV */
+ sync_agent_plugin_device_info_s *hwv = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (hwv == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(hwv, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ hwv->info_name = strdup("HwV");
+ hwv->value = _get_dev_info_common(hwv->info_name);
+ devInfo = g_list_append(devInfo, hwv);
+
+ /* get Lang */
+ sync_agent_plugin_device_info_s *lang = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (lang == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(lang, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ lang->info_name = strdup("Lang");
+ lang->value = _get_dev_info_common(lang->info_name);
+ devInfo = g_list_append(devInfo, lang);
+
+ /* get DevID */
+ sync_agent_plugin_device_info_s *devId = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (devId == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(devId, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ devId->info_name = strdup("DevID");
+ devId->value = _get_dev_info_common(devId->info_name);
+ devInfo = g_list_append(devInfo, devId);
+ _DEBUG_INFO("mdi ============= \n");
+
+ /* get Manufacture */
+ sync_agent_plugin_device_info_s *man = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (man == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(man, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ man->info_name = strdup("Man");
+ man->value = _get_dev_info_common(man->info_name);
+ devInfo = g_list_append(devInfo, man);
+
+ /* get Model info */
+ sync_agent_plugin_device_info_s *mod = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (mod == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(mod, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ mod->info_name = strdup("Mod");
+ mod->value = _get_dev_info_common(mod->info_name);
+ devInfo = g_list_append(devInfo, mod);
+
+ /* get FwV */
+ sync_agent_plugin_device_info_s *fw = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (fw == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(fw, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ fw->info_name = strdup("FwV");
+ fw->value = _get_dev_info_common(fw->info_name);
+ devInfo = g_list_append(devInfo, fw);
+
+ /* get OEM */
+ sync_agent_plugin_device_info_s *oem = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (oem == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(oem, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ oem->info_name = strdup("OEM");
+ oem->value = _get_dev_info_common(oem->info_name);
+ devInfo = g_list_append(devInfo, oem);
+
+ /* get DevTyp */
+ sync_agent_plugin_device_info_s *dev_type = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (dev_type == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(dev_type, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ dev_type->info_name = strdup("DevTyp");
+ dev_type->value = _get_dev_info_common(dev_type->info_name);
+ devInfo = g_list_append(devInfo, dev_type);
+
+ /* get Modem version */
+ sync_agent_plugin_device_info_s *modem_version = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (modem_version == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(modem_version, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ modem_version->info_name = strdup("ModemV");
+ modem_version->value = _get_dev_info_common(modem_version->info_name);
+ devInfo = g_list_append(devInfo, modem_version);
+
+ /* get PDA version */
+ sync_agent_plugin_device_info_s *pda_version = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (pda_version == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(pda_version, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ pda_version->info_name = strdup("PDAV");
+ pda_version->value = _get_dev_info_common(pda_version->info_name);
+ devInfo = g_list_append(devInfo, pda_version);
+
+ /* get CSC version */
+ sync_agent_plugin_device_info_s *csc_version = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (csc_version == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(csc_version, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ csc_version->info_name = strdup("CSCV");
+ csc_version->value = _get_dev_info_common(csc_version->info_name);
+ devInfo = g_list_append(devInfo, csc_version);
+
+ /* get kernel version */
+ sync_agent_plugin_device_info_s *kernel_version = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (kernel_version == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(kernel_version, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ kernel_version->info_name = strdup("KernelV");
+ kernel_version->value = slp_device_info_get_kernel_version();
+ devInfo = g_list_append(devInfo, kernel_version);
+
+ /* get FOTA_download dir */
+ sync_agent_plugin_device_info_s *fota_download_dir = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (fota_download_dir == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(fota_download_dir, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ fota_download_dir->info_name = strdup("FOTADownDir");
+ fota_download_dir->value = slp_device_info_get_fota_download_dir();
+ devInfo = g_list_append(devInfo, fota_download_dir);
+
+ /* get FOTA save dir */
+ sync_agent_plugin_device_info_s *fota_save_dir = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (fota_save_dir == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(fota_save_dir, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ fota_save_dir->info_name = strdup("FOTASaveDir");
+ fota_save_dir->value = slp_device_info_get_fota_save_dir();
+ devInfo = g_list_append(devInfo, fota_save_dir);
+
+ /* get SD_FOTA_download dir */
+ sync_agent_plugin_device_info_s *fota_sd_download_dir = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (fota_sd_download_dir == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(fota_sd_download_dir, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ fota_sd_download_dir->info_name = strdup("FOTA_SD_DownDir");
+ fota_sd_download_dir->value = slp_device_info_get_fota_sd_download_dir();
+ devInfo = g_list_append(devInfo, fota_sd_download_dir);
+
+ /* get SD_FOTA save dir */
+ sync_agent_plugin_device_info_s *fota_sd_save_dir = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (fota_sd_save_dir == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(fota_sd_save_dir, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ fota_sd_save_dir->info_name = strdup("FOTA_SD_SaveDir");
+ fota_sd_save_dir->value = slp_device_info_get_fota_sd_save_dir();
+ devInfo = g_list_append(devInfo, fota_sd_save_dir);
+
+ /* get DTD version */
+ sync_agent_plugin_device_info_s *dtd_version = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (dtd_version == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(dtd_version, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ dtd_version->info_name = strdup("DTDV");
+ dtd_version->value = slp_device_info_get_dtd_version();
+ devInfo = g_list_append(devInfo, dtd_version);
+
+ /* get OPCO info */
+ sync_agent_plugin_device_info_s *opco_info = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (opco_info == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(opco_info, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ opco_info->info_name = strdup("OPCO");
+ opco_info->value = slp_device_info_get_opco_info();
+ devInfo = g_list_append(devInfo, opco_info);
+
+ /* get PHONE_NUM info */
+ sync_agent_plugin_device_info_s *phone_num = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (phone_num == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(phone_num, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ phone_num->info_name = strdup("PHONE_NUM");
+ phone_num->value = slp_device_info_get_msisdn_number();
+ devInfo = g_list_append(devInfo, phone_num);
+
+ /* get IMSI */
+ sync_agent_plugin_device_info_s *imsi_value = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (imsi_value == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(imsi_value, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ imsi_value->info_name = strdup("IMSI");
+ imsi_value->value = slp_device_info_get_imsi_info();
+ devInfo = g_list_append(devInfo, imsi_value);
+
+ /* get CSC */
+ sync_agent_plugin_device_info_s *csc_value = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (csc_value == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(csc_value, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ csc_value->info_name = strdup("CSC");
+ csc_value->value = slp_device_info_get_csc();
+ devInfo = g_list_append(devInfo, csc_value);
+
+ /* get MCC */
+ sync_agent_plugin_device_info_s *mcc_value = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
+ if (mcc_value == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ memset(mcc_value, 0x00, sizeof(sync_agent_plugin_device_info_s));
+ mcc_value->info_name = strdup("MCC");
+ mcc_value->value = slp_device_info_get_mcc();
+ devInfo = g_list_append(devInfo, mcc_value);
+
+ /* for test */
+ int cnt = 0;
+ GList *iter = NULL;
+ for (iter = devInfo; iter != NULL; iter = g_list_next(iter)) {
+ _DEBUG_INFO("[devInfo_slp_plugIn] cnt : %d, info_name : %s, value : %s\n", cnt, ((sync_agent_plugin_device_info_s *) (iter->data))->info_name, ((sync_agent_plugin_device_info_s *) (iter->data))->value);
+ cnt++;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return res;
+}
+
+EXPORT_API int sync_agent_plugin_get_devinfo(char *info_name, char **value)
+{
+ _EXTERN_FUNC_ENTER;;
+
+ retvm_if((info_name) == NULL, 0, "info_name is NULL!!");
+
+ int res = 1;
+ int is_exist = 0;
+ GList *iter = NULL;
+ sync_agent_plugin_device_info_s *iter_data;
+
+ for (iter = devInfo; iter != NULL; iter = g_list_next(iter)) {
+ iter_data = NULL;
+ iter_data = (sync_agent_plugin_device_info_s *) (iter->data);
+ if (iter_data->info_name != NULL) {
+ if (!strcmp(iter_data->info_name, info_name)) {
+ if (iter_data->value != NULL) {
+
+ *value = strdup(iter_data->value);
+
+ is_exist = 1;
+ break;
+ } else {
+ _DEBUG_INFO("[devInfo_slp_plugIn] %s value is NULL !!\n", info_name);
+ res = 0;
+ _EXTERN_FUNC_EXIT;
+ return res;
+ }
+ }
+ }
+ }
+
+ if (strcmp("Battery", info_name) == 0) {
+ *value = _get_dev_info_common(info_name);
+ if (*value != NULL)
+ is_exist = 1;
+ }
+
+ if (is_exist != 1) {
+ _DEBUG_INFO("[devInfo_slp_plugIn] not exist %s information !!\n", info_name);
+ res = -1;
+ _EXTERN_FUNC_EXIT;
+ return res;
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return res;
+}
+
+EXPORT_API int sync_agent_plugin_clear_devinfo()
+{
+ _EXTERN_FUNC_ENTER;;
+
+ int res = 1;
+
+ GList *iter = NULL;
+ sync_agent_plugin_device_info_s *iter_data;
+
+ if (devInfo != NULL) {
+ for (iter = devInfo; iter != NULL;) {
+ iter_data = NULL;
+ iter_data = ((sync_agent_plugin_device_info_s *) (iter->data));
+ iter = g_list_next(iter);
+ devInfo = g_list_remove(devInfo, iter_data);
+
+ if (iter_data != NULL) {
+ if (((sync_agent_plugin_device_info_s *) (iter_data))->info_name != NULL)
+ free(((sync_agent_plugin_device_info_s *) (iter_data))->info_name);
+ if (((sync_agent_plugin_device_info_s *) (iter_data))->value != NULL)
+ free(((sync_agent_plugin_device_info_s *) (iter_data))->value);
+ free((sync_agent_plugin_device_info_s *) (iter_data));
+ }
+ }
+
+ g_list_free(devInfo);
+ }
+
+ _EXTERN_FUNC_EXIT;
+ return res;
+}
+
+EXPORT_API void sync_agent_plugin_set_common_devinfo_function(sync_agent_get_devinfo_cb func)
+{
+ _EXTERN_FUNC_ENTER;
+
+ func_get_dev_info_common = func;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+static char *_get_dev_info_common(char *key)
+{
+ _INNER_FUNC_ENTER;
+
+ if (key == NULL) {
+ _DEBUG_TRACE("KEY name is NULL !!!");
+ _INNER_FUNC_EXIT;
+ return NULL;
+ }
+
+ char *value = 0;
+ sync_agent_dev_return_e ret = SYNC_AGENT_DEV_RETURN_SUCCESS;
+
+ ret = func_get_dev_info_common(1, key, &value);
+ if (ret == SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ _DEBUG_TRACE(" key = %s, value = %s", key, value);
+ _INNER_FUNC_EXIT;
+ return value;
+ } else {
+ _DEBUG_TRACE(" key = %s has NULL value !!!", key, value);
+ _INNER_FUNC_EXIT;
+ return NULL;
+ }
+}
diff --git a/src/plugins/dm-private/slp-device-dm/src/plugin_slp_device_ctrl.c b/src/plugins/dm-private/slp-device-dm/src/plugin_slp_device_ctrl.c
new file mode 100755
index 0000000..5520214
--- /dev/null
+++ b/src/plugins/dm-private/slp-device-dm/src/plugin_slp_device_ctrl.c
@@ -0,0 +1,474 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <wait.h>
+#include <errno.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+/*#include "package-manager.h"*/
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+#include "plugin_slp_device_ctrl.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_DEVICE_SLP_DM"
+#endif
+
+#define RB_ERR_CODE_MAX_COUNT 16
+
+typedef struct _type_Redbend_OMADM_Table {
+ int result_code;
+ char *str_meanning;
+ char *result_redbend;
+ char *str_redbend;
+} type_redbend_omadm_table_s;
+
+type_redbend_omadm_table_s redbend_omadm_table[RB_ERR_CODE_MAX_COUNT] = {
+ {200, "Successful", "0", "S_RB_SUCCESS"},
+ {410, "Firmware Update Failed", "1", "E_RB_*"}, // juhaki.park
+ {402, "Corrupted Firmware Update Package", "8000000D", "E_RB_PKG_CORRUPTED"},
+ {403, "Firmware Update Package - Device Mismatch", "80000002", "E_RB_BAD_PARAMS"},
+ {403, "Firmware Update Package - Device Mismatch", "80000011", "E_RB_WRONG_UPI_VER"},
+ {403, "Firmware Update Package - Device Mismatch", "80000012", "E_RB_WRONG_UPI_UPDATE"},
+ {403, "Firmware Update Package - Device Mismatch", "80000013", "E_RB_UPDATE_SECTOR_SIG"},
+ {404, "Failed Firmware Update Package Validation", "8001001A", "E_RB_NON_DP_FORMAT_NOT_SUPPORTED"},
+ {404, "Failed Firmware Update Package Validation", "80010025", "E_RB_INVALID_DP_HEADER"},
+ {404, "Failed Firmware Update Package Validation", "80010026", "E_RB_INVALID_DP_WRONG_SIGNATURE"},
+ {404, "Failed Firmware Update Package Validation", "80010027", "E_RB_INVALID_DP"},
+ {405, "Firmware Update Package Not Acceptable", "8000000B", "E_RB_PKG_TOO_SHORT"},
+ {405, "Firmware Update Package Not Acceptable", "8000000C", "E_RB_PKG_TOO_LONG"},
+ {405, "Firmware Update Package Not Acceptable", "8000000E", "E_RB_PKG_NOT_AUTHORIZED"},
+ {410, "Firmware Update Failed", "**", "E_RB_*"},
+ {502, "Firmware update fails due to device out of memory", "8000001E", "E_RB_NOT_ENOUGH_RAM"},
+
+/*{0, NULL, NULL, NULL},*/
+};
+
+static int _system_command(const char *command);
+/*static int __get_mobile_tracker_status();*/
+/*static int __return_pkgmgr_cb(pkg_request_id req_id, const char *pkg_type, const char *pkg_name, const char *key, const char *val, const void *pmsg, void *data);*/
+
+int slp_device_ctrl_set_fota_flag()
+{
+ _EXTERN_FUNC_ENTER;
+
+ /*
+ 2010.09.08 document base
+ ("echo fota_enable > /sys/devices/platform/s3c_samsung_fota/samsung_fota_config");
+ _DEBUG_INFO("echo fota_enable > /sys/devices/platform/s3c_samsung_fota/samsung_fota_config \n");
+ 2011.03.23 document base
+ ("/bin/change-booting-mode.sh --fota /opt/data/fota");
+ */
+
+ _DEBUG_INFO("/bin/change-booting-mode.sh --fota /opt/data/fota/save \n");
+ int ret = _system_command("/bin/change-booting-mode.sh --fota /opt/data/fota/save");
+ if (ret != -1) {
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ } else {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+/*error:
+ return 0;*/
+}
+
+int slp_device_ctrl_get_fota_update_result()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int update_result = 400;
+ FILE *file_des;
+ long lSize = 0; /*prevent */
+ size_t result;
+ file_des = fopen("/opt/result", "rb");
+ int j = 0;
+ bool match_found = false;
+ if (file_des == NULL) {
+ _DEBUG_INFO("fopen fail - result file \n");
+ _EXTERN_FUNC_EXIT;
+ return 400;
+ }
+ fseek(file_des, 0, SEEK_END);
+ lSize = ftell(file_des);
+ if (lSize < 0) {
+ _DEBUG_INFO("ftell nagative return ");
+ if (file_des != NULL)
+ fclose(file_des);
+ _EXTERN_FUNC_EXIT;
+ return 400;
+ }
+ rewind(file_des);
+ char *str_result = NULL;
+ str_result = (char *)calloc(1, lSize + 1);
+ if (str_result == NULL) {
+ if (file_des != NULL)
+ fclose(file_des);
+ _DEBUG_INFO("malloc fail \n");
+ _EXTERN_FUNC_EXIT;
+ return 400;
+ }
+
+ result = fread(str_result, 1, lSize, file_des);
+ if ((result != lSize) || (str_result == NULL)) {
+ if (file_des != NULL)
+ fclose(file_des);
+ _DEBUG_INFO("read fail or str_result == NULL \n");
+
+ if (str_result != NULL)
+ free(str_result);
+
+ _EXTERN_FUNC_EXIT;
+ return 400;
+ }
+ if (str_result[lSize - 1] == '\n')
+ str_result[lSize - 1] = 0;
+
+ for (j = 0; j < RB_ERR_CODE_MAX_COUNT; j++) {
+ if (strlen(str_result) == strlen(redbend_omadm_table[j].result_redbend)) {
+ if ((strcmp(str_result, redbend_omadm_table[j].result_redbend) == 0)) {
+ update_result = redbend_omadm_table[j].result_code;
+ match_found = true;
+ _DEBUG_INFO("Redbend[%s] \n", redbend_omadm_table[j].str_redbend);
+ break; /* If existing error code, break-out from the for-loop. */
+ }
+ }
+ if (!match_found)
+ update_result = 410;
+ }
+
+ if (str_result != NULL)
+ free(str_result);
+
+ if (file_des != NULL)
+ fclose(file_des);
+
+ _DEBUG_INFO("update_result - %d \n", update_result);
+ _EXTERN_FUNC_EXIT;
+ return update_result;
+}
+
+int slp_device_ctrl_reboot()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = _system_command("/sbin/reboot");
+ if (ret != -1) {
+ _EXTERN_FUNC_EXIT;
+ return 1;
+ }
+
+ /*will be insert.. // tel_process_power_command(TAPI_PHONE_POWER_RESET); ?? */
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+int slp_device_ctrl_fully_lock()
+{
+ _EXTERN_FUNC_ENTER;
+
+ /*if (__get_mobile_tracker_status() == 0 ) {
+ _DEBUG_INFO("mobile tracker status OFF \n");
+ return 0;
+ }
+
+ ("/opt/apps/deb.com.samsung.pwlock/bin/pwlock 1 &");
+ ("/bin/sync"); */
+
+ _EXTERN_FUNC_EXIT;
+ return 1;
+}
+
+int slp_device_ctrl_partially_lock()
+{
+ _EXTERN_FUNC_ENTER;
+
+ /*if (__get_mobile_tracker_status() == 0 ) {
+ _DEBUG_INFO("mobile tracker status OFF \n");
+ return 0;
+ }
+
+ ("/opt/apps/deb.com.samsung.pwlock/bin/pwlock 1 &");
+ ("/bin/sync"); */
+
+ _EXTERN_FUNC_EXIT;
+ return 1;
+}
+
+int slp_device_ctrl_unlock()
+{
+ _EXTERN_FUNC_ENTER;
+
+ /*if (__get_mobile_tracker_status() == 0 ) {
+ _DEBUG_INFO("mobile tracker status OFF \n");
+ return 0;
+ }
+
+ ("killall -9 pwlock");
+ ("/bin/sync"); */
+ _EXTERN_FUNC_EXIT;
+ return 1;
+}
+
+int slp_device_ctrl_factory_reset()
+{
+ _EXTERN_FUNC_ENTER;
+
+ /*if (__get_mobile_tracker_status() == 0 ) {
+ _DEBUG_INFO("mobile tracker status OFF \n");
+ return 0;
+ }
+ ("/usr/bin/factory-reset.sh"); // */
+
+ _EXTERN_FUNC_EXIT;
+ return 1;
+}
+
+/* static function */
+static int _system_command(const char *command)
+{
+ _INNER_FUNC_ENTER;
+
+ int pid = 0, status = 0;
+ char *const environ[] = { NULL };
+
+ retvm_if((command) == NULL, -1, "command is NULL!!");
+
+ pid = fork();
+ if (pid == -1) {
+ _DEBUG_TRACE("ERROR : fork failed to create a process\n");
+ _INNER_FUNC_EXIT;
+ return -1;
+
+ } else if (pid == 0) {
+ char *argv[4];
+ argv[0] = "sh";
+ argv[1] = "-c";
+ argv[2] = (char *)command;
+ argv[3] = 0;
+
+ execve("/bin/sh", argv, environ);
+ abort();
+ } else {
+ do {
+ if (waitpid(pid, &status, 0) == -1) {
+ if (errno != EINTR) {
+ return -1;
+ }
+
+ } else {
+ _INNER_FUNC_EXIT;
+ return status;
+ }
+
+ } while (1);
+ }
+ _INNER_FUNC_EXIT;
+ return -1;
+}
+
+/* TODO : holding ( wait until the MDM module is completed ) */
+/*int Execute_Dev_App_Install(char *file_name, char *application_id)
+{
+ if( file_name == NULL )
+ return 0;
+
+ _DEBUG_INFO("file_name[%s] \n", file_name);
+ int result = 0 ;
+
+ int req_id = 0;
+ char *descriptor = NULL;
+ char abs_setup_file[256] = {0,};
+ ecore_init();
+ snprintf(abs_setup_file,sizeof(abs_setup_file),"%s", file_name );
+ _DEBUG_INFO("[%s] , [%s] \n", abs_setup_file, file_name );
+ result = package_manager_install_application(&req_id, descriptor, abs_setup_file, PKG_QUIET PKG_DEFAULT, 0, NULL);
+ LOGTRACE("package_manager_install_application result[%d]\n", result);
+ if( result < PKG_COMMON_OK) {
+ LOGTRACE("Install failed! result[%d] \n", result );
+ snprintf(app_ID, PKG_TYPE_STRING_LEN_MAX+PKG_NAME_STRING_LEN_MAX+PKG_VERSION_STRING_LEN_MAX +2 , "%s" , pFile_name );
+ //pthread_mutex_unlock(&wait_mutex);
+ //return 0;
+ }
+ else{
+ ecore_main_loop_begin();
+ snprintf(app_ID, PKG_TYPE_STRING_LEN_MAX+PKG_NAME_STRING_LEN_MAX+PKG_VERSION_STRING_LEN_MAX +2, "%s" , g_pkg_info.pkg_name );
+ }
+
+ ("/bin/sync");
+
+ if( result == PKG_COMMON_OK ) {
+ _DEBUG_INFO("package_manager_install_application() Success !!\n");
+ result = 0;
+
+ } else {
+ _DEBUG_INFO("package_manager_install_application() Success !!\n");
+ result = 1;
+ }
+
+ return result ; // 1(OK),0(FAIL)
+}*/
+
+/*int Execute_Dev_App_UnInstall(char *application_id)
+{
+ int result = 0 ;
+
+ if( app_ID == NULL )
+ return 0 ; // 1(OK),0(FAIL)
+ LOGTRACE("app_ID[%s] \n", app_ID);
+
+ if( strlen(app_ID) >= 256 ) // Prevent defect
+ {
+ LOGTRACE("strlen[app_ID] >= 256 \n");
+ return 0 ; // 1(OK),0(FAIL)
+ }
+
+#if defined(_D_SLP_PKGMGR_)
+ int req_id = 0;
+ char *descriptor = NULL;
+ char pkg_type[16] = {0,};
+ memcpy(pkg_type,app_ID,3);
+
+ ecore_init();
+ result = package_manager_uninstall_application(&req_id, pkg_type, app_ID , PKG_QUIET PKG_DEFAULT, return_pkgmgr_cb, NULL);
+ if( result < PKG_COMMON_OK)
+ {
+ LOGTRACE("Uninstall failed! result[%d] \n", result);
+ //return 1;
+ }
+ else {
+ ecore_main_loop_begin();
+ }
+#endif
+
+ ("/bin/sync");
+ if( result == PKG_COMMON_OK ) {
+ char return_char[512] = {0,};
+ snprintf(return_char,510,"%s,success,%s", (char*)_D_APP_UNINSTALL_,app_ID ); // Prevent defect
+ QUEUE_sendto ( _D_SYNCML_DM_SERVICE_SOCKET_PATH , (void*) return_char , strlen(return_char) );
+ }
+ else{
+ char return_char[512] = {0,};
+ snprintf(return_char,510,"%s,fail,%s", (char*)_D_APP_UNINSTALL_,app_ID ); // Prevent defect
+ QUEUE_sendto ( _D_SYNCML_DM_SERVICE_SOCKET_PATH , (void*) return_char , strlen(return_char) );
+ }
+
+ return result ; // 1(OK),0(FAIL)
+}*/
+
+/*int Execute_Dev_App_Activate(char *applicaton_id, int activate_status)
+{
+ int result = 0 ;
+
+ if( app_ID == NULL )
+ return 0 ; // 1(OK),0(FAIL)
+ LOGTRACE("appID[%s] activate[%d] \n", app_ID, activate);
+
+ if( strlen(app_ID) >= 256 ) // Prevent defect
+ {
+ LOGTRACE("strlen[app_ID] >= 256 \n");
+ return 0 ; // 1(OK),0(FAIL)
+ }
+
+#if defined(_D_SLP_PKGMGR_)
+ int req_id = 0;
+ char *descriptor = NULL;
+ char pkg_type[16] = {0,};
+ memcpy(pkg_type,app_ID,3);
+
+ ecore_init();
+ result = package_manager_activate_application(&req_id, pkg_type, app_ID , activate, return_pkgmgr_cb, NULL);
+ if( result < PKG_COMMON_OK)
+ {
+ LOGTRACE("Uninstall failed! result[%d] \n", result);
+ //return 1;
+ }
+ else {
+ ecore_main_loop_begin();
+ }
+#endif
+
+ ("/bin/sync");
+ if( result == PKG_COMMON_OK ) {
+ char return_char[512] = {0,};
+ if( activate ) {
+ snprintf(return_char,510,"%s,success,%s", (char*)_D_APP_ACTIVE_,app_ID ); // prevent defect
+ }
+ else {
+ snprintf(return_char,510,"%s,success,%s", (char*)_D_APP_INACTIVE_,app_ID ); // prevent defect
+ }
+
+ QUEUE_sendto ( _D_SYNCML_DM_SERVICE_SOCKET_PATH , (void*) return_char , strlen(return_char) );
+ }
+ else{
+ char return_char[512] = {0,};
+ if( activate ){
+ snprintf(return_char,510,"%s,fail,%s", (char*)_D_APP_ACTIVE_,app_ID ); // prevent defect
+ }
+ else {
+ snprintf(return_char,510,"%s,fail,%s", (char*)_D_APP_INACTIVE_,app_ID ); // prevent defect
+ }
+ QUEUE_sendto ( _D_SYNCML_DM_SERVICE_SOCKET_PATH , (void*) return_char , strlen(return_char) );
+ }
+
+ return result ; // 1(OK),0(FAIL)
+}*/
+
+/*static int __return_pkgmgr_cb(pkg_request_id req_id, const char *pkg_type, const char *pkg_name, const char *key, const char *val, const void *pmsg, void *data)
+{
+ LOGTRACE("return_cb req_id[%d] pkg_type[%s] pkg_name[%s] key[%s] val[%s]\n", req_id, pkg_type, pkg_name, key, val);
+// printf("return_cb req_id[%d] pkg_type[%s] pkg_name[%s] key[%s] val[%s]\n", req_id, pkg_type, pkg_name, key, val);
+
+ if( strncmp(key, "end", strlen("end") ) == 0) {
+ snprintf(g_pkg_info.pkg_type, PKG_TYPE_STRING_LEN_MAX, "%s", pkg_type);
+ snprintf(g_pkg_info.pkg_name, PKG_NAME_STRING_LEN_MAX, "%s", pkg_name);
+ //snprintf(g_pkg_info.pkg_version, PKG_VERSION_STRING_LEN_MAX, "%s", val);
+ //exit(0); ==> exit ���� �׳� process ��ü�� �׾� ����..
+ ecore_main_loop_quit(); // ==> ecore_main_loop_begin() ���� ��� ����
+ //pthread_cond_signal(&wait_cond); // sending signal
+ }
+ else if( strncmp(key, "install_percent", strlen("install_percent") ) == 0) {
+ LOGTRACE("install_percent[%s] \n", val);
+ }
+ return 0; // Prevent defect 25315
+}*/
+
+/*static int __get_mobile_tracker_status()
+{
+ char str_key_name[128] = { 0, };
+ int int_key = 0;
+
+ memset(str_key_name, 0, sizeof(str_key_name));
+ snprintf(str_key_name, sizeof(str_key_name), "%s", VCONFKEY_SETAPPL_STATE_MOBILE_TRACKER_BOOL); //db/setting/mobile_tracker
+
+ if (!vconf_get_bool(str_key_name, &int_key)) {
+ _DEBUG_VERBOSE("%s success , int_key : %d \n", VCONFKEY_SETAPPL_STATE_MOBILE_TRACKER_BOOL, int_key);
+ } else {
+ _DEBUG_VERBOSE("%s failed \n", VCONFKEY_SETAPPL_STATE_MOBILE_TRACKER_BOOL);
+ }
+
+ _DEBUG_VERBOSE(" %s vconf %d value \n", VCONFKEY_SETAPPL_STATE_MOBILE_TRACKER_BOOL, int_key);
+ return int_key;
+}*/
diff --git a/src/plugins/dm-private/slp-device-dm/src/plugin_slp_device_info.c b/src/plugins/dm-private/slp-device-dm/src/plugin_slp_device_info.c
new file mode 100755
index 0000000..074ee4d
--- /dev/null
+++ b/src/plugins/dm-private/slp-device-dm/src/plugin_slp_device_info.c
@@ -0,0 +1,365 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/utsname.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include <tapi_common.h>
+#include <ITapiModem.h>
+#include <ITapiSim.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+#include "plugin_slp_device_info.h"
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_DEVICE_SLP_DM"
+#endif
+
+#define _D_MSC_FIRMWARE_MAXSTRING_ 40
+#define _D_SIZE_64_ 64
+#define _D_SIZE_128_ 128
+
+/* todo : temporary definition */
+#define DTD_VERSION "1.2"
+
+#define OPCO "UK"
+
+#define FOTA_DOWNLOAD_DIR "/opt/data/fota/download"
+#define FOTA_SAVE_DIR "/opt/data/fota/save"
+#define FOTA_SD_DOWNLOAD_DIR "/opt/storage/sdcard/data/fota/download"
+#define FOTA_SD_SAVE_DIR "/opt/storage/sdcard/data/fota/save"
+
+/* ========================================*/
+/* version information
+ * DTD version
+ * kernel version
+ */
+/* ========================================*/
+
+char *slp_device_info_get_dtd_version()
+{
+ _EXTERN_FUNC_ENTER;
+
+ char *dtd_version = (char *)calloc(_D_SIZE_128_, sizeof(char));
+ if (dtd_version == NULL) {
+ _DEBUG_INFO("CALLOC failed !!!");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ /*snprintf(dtd_version, _D_SIZE_128_ - 1, DTD_VERSION, strlen(DTD_VERSION)); */
+ snprintf(dtd_version, _D_SIZE_128_ - 1, "%s", DTD_VERSION);
+ _DEBUG_INFO("DTD version = %s\n", dtd_version);
+
+ _EXTERN_FUNC_EXIT;
+ return dtd_version;
+}
+
+char *slp_device_info_get_kernel_version()
+{
+ _EXTERN_FUNC_ENTER;
+
+ char *kernel_version = (char *)calloc(_D_SIZE_128_, sizeof(char));
+ if (kernel_version == NULL) {
+ _DEBUG_INFO("CALLOC failed !!!");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+
+ struct utsname buf;
+ uname(&buf);
+
+ snprintf(kernel_version, _D_SIZE_128_ - 1, "%s.%s", "K", buf.release);
+
+ _DEBUG_INFO("sysname[%s], nodename[%s], release[%s], version[%s], machine[%s] \n", buf.sysname, buf.nodename, buf.release, buf.version, buf.machine);
+ _EXTERN_FUNC_EXIT;
+ return kernel_version;
+}
+
+char *slp_device_info_get_msisdn_number()
+{
+ _EXTERN_FUNC_ENTER;
+
+ char *get_str;
+ char str_key_name[_D_SIZE_128_ * 2] = { 0, };
+ snprintf(str_key_name, _D_SIZE_128_ * 2, "%s", VCONFKEY_TELEPHONY_SUBSCRIBER_NUMBER);
+ get_str = vconf_get_str(str_key_name);
+ _DEBUG_INFO("MSISDN_number = %s\n", get_str);
+ _EXTERN_FUNC_EXIT;
+ return get_str;
+
+// char *out_msisdn = 0;
+// int MSISDN_LEN = 20;
+// int err = SIM_ERROR_NONE;
+// char *msisdn = 0;
+//
+// out_msisdn = (char*)calloc(MSISDN_LEN, sizeof(char));
+// if (out_msisdn == NULL)
+// goto return_part;
+//
+// err = sim_get_subscriber_number(&msisdn);
+// if (!err && msisdn == NULL) {
+// strncpy(out_msisdn, msisdn, MSISDN_LEN-1);
+// free(msisdn);
+// } else {
+// strncpy(out_msisdn, "", MSISDN_LEN-1);
+// }
+//
+// return_part:
+// _DEBUG_INFO("MSISDN = %s", msisdn);
+// return msisdn;
+}
+
+char *slp_device_info_get_mcc()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int mcc_len = 4;
+ char *mcc = NULL;
+ mcc = (char *)calloc(mcc_len, sizeof(char));
+ if (mcc == NULL) {
+ goto return_part;
+ }
+
+ int b_card_changed = 0;
+ TapiHandle *handle;
+ handle = tel_init(NULL);
+ if (handle == NULL) {
+ _DEBUG_INFO("handle is NULL !!");
+ free(mcc);
+ mcc = NULL;
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+ }
+ TelSimImsiInfo_t imsi;
+ TapiResult_t err_code = TAPI_API_SUCCESS;
+ TelSimCardStatus_t status = TAPI_SIM_STATUS_CARD_ERROR;
+
+ err_code = (TapiResult_t) tel_get_sim_init_info(handle, &status, &b_card_changed);
+ if (err_code == TAPI_API_SUCCESS && status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED) {
+ err_code = (TapiResult_t) tel_get_sim_imsi(handle, &imsi);
+ if (err_code == TAPI_API_SUCCESS) {
+ strncpy(mcc, imsi.szMcc, mcc_len);
+ _DEBUG_INFO("MCC = %s", mcc);
+ _EXTERN_FUNC_EXIT;
+ return mcc;
+ }
+ }
+
+ strncpy(mcc, "0", mcc_len);
+ _DEBUG_INFO("MCC = %s", mcc);
+
+ tel_deinit(handle);
+
+ return_part:
+ _EXTERN_FUNC_EXIT;
+
+ return mcc;
+}
+
+char *slp_device_info_get_csc()
+{
+ _EXTERN_FUNC_ENTER;
+
+ _EXTERN_FUNC_EXIT;
+ return strdup("VD2");
+}
+
+/* ====================================
+ * device directory information
+ * fota download directory
+ * fota save directory
+ * =====================================*/
+
+char *slp_device_info_get_fota_download_dir()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = sync_agent_create_directory(FOTA_DOWNLOAD_DIR);
+ if (ret == 0) {
+ _DEBUG_INFO("existed foler or create foler error");
+ }
+
+ char *fota_download_dir = (char *)calloc(_D_SIZE_128_, sizeof(char));
+ if (fota_download_dir == NULL) {
+ _DEBUG_INFO("CALLOC failed !!!");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ /*snprintf(FOTA_Download_Dir, _D_SIZE_128_ - 1, FOTA_DOWNLOAD_DIR, strlen(FOTA_DOWNLOAD_DIR)); */
+ snprintf(fota_download_dir, _D_SIZE_128_ - 1, "%s", FOTA_DOWNLOAD_DIR);
+
+ _DEBUG_INFO("FOTA Download dir = %s\n", fota_download_dir);
+ _EXTERN_FUNC_EXIT;
+ return fota_download_dir;
+
+}
+
+char *slp_device_info_get_fota_save_dir()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = sync_agent_create_directory(FOTA_SAVE_DIR);
+ if (ret == 0) {
+ _DEBUG_INFO("existed foler or create foler error");
+ }
+
+ char *fota_save_dir = (char *)calloc(_D_SIZE_128_, sizeof(char));
+ if (fota_save_dir == NULL) {
+ _DEBUG_INFO("CALLOC failed !!!");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ /*snprintf(FOTA_Save_Dir, _D_SIZE_128_ - 1, FOTA_SAVE_DIR, strlen(FOTA_SAVE_DIR)); */
+ snprintf(fota_save_dir, _D_SIZE_128_ - 1, "%s", FOTA_SAVE_DIR);
+
+ _DEBUG_INFO("FOTA save dir = %s\n", fota_save_dir);
+ _EXTERN_FUNC_EXIT;
+ return fota_save_dir;
+}
+
+/* ====================================
+ * device directory information
+ * fota sd card download directory
+ * fota sd card save directory
+ * =====================================*/
+
+char *slp_device_info_get_fota_sd_download_dir()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = sync_agent_create_directory(FOTA_SD_DOWNLOAD_DIR);
+ if (ret == 0) {
+ _DEBUG_INFO("existed foler or create foler error");
+ }
+
+ char *fota_sd_download_dir = (char *)calloc(_D_SIZE_128_, sizeof(char));
+ if (fota_sd_download_dir == NULL) {
+ _DEBUG_INFO("CALLOC failed !!!");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ /*snprintf(FOTA_SD_Download_Dir, _D_SIZE_128_ - 1, FOTA_SD_DOWNLOAD_DIR, strlen(FOTA_SD_DOWNLOAD_DIR)); */
+ snprintf(fota_sd_download_dir, _D_SIZE_128_ - 1, "%s", FOTA_SD_DOWNLOAD_DIR);
+
+ _DEBUG_INFO("FOTA SD CARD Download dir = %s\n", fota_sd_download_dir);
+ _EXTERN_FUNC_EXIT;
+ return fota_sd_download_dir;
+}
+
+char *slp_device_info_get_fota_sd_save_dir()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret = sync_agent_create_directory(FOTA_SD_SAVE_DIR);
+ if (ret == 0) {
+ _DEBUG_INFO("existed foler or create foler error");
+ }
+
+ char *fota_sd_save_dir = (char *)calloc(_D_SIZE_128_, sizeof(char));
+ if (fota_sd_save_dir == NULL) {
+ _DEBUG_INFO("CALLOC failed !!!");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ /*snprintf(FOTA_SD_Save_Dir, _D_SIZE_128_ - 1, FOTA_SD_SAVE_DIR, strlen(FOTA_SD_SAVE_DIR)); */
+ snprintf(fota_sd_save_dir, _D_SIZE_128_ - 1, "%s", FOTA_SD_SAVE_DIR);
+
+ _DEBUG_INFO("FOTA SD CARD save dir = %s\n", fota_sd_save_dir);
+ _EXTERN_FUNC_EXIT;
+ return fota_sd_save_dir;
+}
+
+/* ====================================
+ * device etc information
+ * =====================================*/
+
+char *slp_device_info_get_opco_info()
+{
+ _EXTERN_FUNC_ENTER;
+
+ char *opcoInfo = (char *)calloc(_D_SIZE_128_, sizeof(char));
+ if (opcoInfo == NULL) {
+ _DEBUG_INFO("CALLOC failed !!!");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ snprintf(opcoInfo, _D_SIZE_128_ - 1, "%s", OPCO);
+ _DEBUG_INFO("Opco Info = %s\n", opcoInfo);
+ _EXTERN_FUNC_EXIT;
+ return opcoInfo; /* prevent */
+}
+
+char *slp_device_info_get_imsi_info()
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO("Start !!");
+
+ TelSimImsiInfo_t sim_imsi_info;
+ int err_code = -1;
+
+ char imsi_value[30] = { 0, };
+
+ TapiHandle *handle;
+ handle = tel_init(NULL);
+ if (handle == NULL) {
+ _DEBUG_INFO("handle is NULL !!");
+ _DEBUG_INFO("End !!");
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ } else {
+ _DEBUG_INFO("handle : %d", handle);
+ err_code = tel_get_sim_imsi(handle, &sim_imsi_info);
+ }
+
+ if (err_code != TAPI_API_SUCCESS) {
+ _DEBUG_INFO("tel_get_sim_imsi() failed !!, err_code : 0x%02x", err_code);
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ } else {
+ _DEBUG_INFO("tel_get_sim_imsi() success !!");
+
+ if (!strcmp(sim_imsi_info.szMcc, " ") && !strcmp(sim_imsi_info.szMnc, " ") && !strcmp(sim_imsi_info.szMsin, " ")) {
+ _DEBUG_INFO("mcc : %s", sim_imsi_info.szMcc);
+ _DEBUG_INFO("mnc : %s", sim_imsi_info.szMnc);
+ _DEBUG_INFO("msin : %s", sim_imsi_info.szMsin);
+
+ snprintf(imsi_value, sizeof(imsi_value), "%s%s%s", sim_imsi_info.szMcc, sim_imsi_info.szMnc, sim_imsi_info.szMsin);
+ _DEBUG_INFO("IMSI : %s ( %d )", imsi_value, strlen(imsi_value));
+
+ tel_deinit(handle);
+
+ _DEBUG_INFO("End !!");
+ return strdup(imsi_value);
+ } else {
+ _DEBUG_INFO("invalid IMSI value !!");
+ tel_deinit(handle);
+
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
diff --git a/src/plugins/dm-private/slp-sysnoti-telephony/CMakeLists.txt b/src/plugins/dm-private/slp-sysnoti-telephony/CMakeLists.txt
new file mode 100755
index 0000000..291dc1a
--- /dev/null
+++ b/src/plugins/dm-private/slp-sysnoti-telephony/CMakeLists.txt
@@ -0,0 +1,45 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "pm-slp-sysnoti-telephony")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+ sync-agent
+ glib-2.0
+ vconf
+ tapi
+ dlog
+ libwbxml2
+ )
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${pm-slp-sysnoti-telephony_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${pm-slp-sysnoti-telephony_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub) \ No newline at end of file
diff --git a/src/plugins/dm-private/slp-sysnoti-telephony/src/plugin_interface.c b/src/plugins/dm-private/slp-sysnoti-telephony/src/plugin_interface.c
new file mode 100755
index 0000000..1e72f5f
--- /dev/null
+++ b/src/plugins/dm-private/slp-sysnoti-telephony/src/plugin_interface.c
@@ -0,0 +1,298 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib-object.h>
+#include <glib/gprintf.h>
+#include <vconf-keys.h>
+#include <vconf.h>
+
+#include <tapi_common.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_PM_SYSNOTI_TELEPHONY"
+#endif
+
+static TapiHandle *tel_handler = NULL;
+
+static int (*registered_telephony_incoming_cb) (int data_id, void *user_data);
+static int (*registered_telephony_end_cb) (int data_id, void *user_data);
+
+int _register_telephony_noti_event();
+int _unregister_telephony_noti_event();
+static void __tel_alert_status_noti_cb(TapiHandle * handle, const char *noti_id, void *data, void *user_data);
+
+EXPORT_API void sync_agent_plugin_init_service_noti(void *data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retm_if((data) == NULL, "data is NULL!!");
+
+ sync_agent_pm_register_data_s *reg_data = (sync_agent_pm_register_data_s *) data;
+ if (reg_data == NULL) {
+ _DEBUG_INFO("data is NULL !!");
+ goto free_part;
+ }
+
+ g_type_init();
+
+ tel_handler = tel_init(NULL);
+ if (tel_handler == NULL) {
+ _DEBUG_INFO("tel_init() failed !!");
+ goto free_part;
+ }
+
+ int ret = _register_telephony_noti_event();
+ if (ret != 1) {
+ _DEBUG_INFO("register_notiNetworkEvent() failed !!");
+ } else {
+ _DEBUG_INFO("register_notiNetworkEvent() success !!");
+ }
+
+ free_part:
+ if (reg_data != NULL) {
+ if (reg_data->pkg_name != NULL)
+ free(reg_data->pkg_name);
+
+ if (reg_data->additional_data != NULL)
+ free(reg_data->additional_data);
+
+ free(reg_data);
+
+ _DEBUG_INFO("free sync_agent_pm_register_data_s !!");
+ }
+
+ _EXTERN_FUNC_EXIT;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_unregister_service_noti(void)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+ int err = _unregister_telephony_noti_event();
+ if (err != 1) {
+ _DEBUG_INFO("__unregister_telephony_noti_event() failed !!");
+ return SYNC_AGENT_PM_FAIL;
+ } else {
+ _DEBUG_INFO("__unregister_telephony_noti_event() success !!");
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_add_service_data(void *add_data, int *added_data_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+ _DEBUG_INFO("not support this feature !!");
+
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_remove_service_data(int remove_data_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+ _DEBUG_INFO("not support this feature !!");
+
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
+
+EXPORT_API sync_agent_pm_return_e sync_agent_plugin_get_service_data(int get_data_id, void **service_data)
+{
+ _EXTERN_FUNC_ENTER;
+
+ sync_agent_pm_return_e ret = SYNC_AGENT_PM_SUCCESS;
+
+ _DEBUG_INFO("not support this feature !!");
+
+ _EXTERN_FUNC_EXIT;
+
+ return ret;
+}
+
+//void set_user_callback(int callback_counts, ...)
+EXPORT_API void sync_agent_plugin_set_user_callback(int callback_counts, va_list list)
+{
+ _EXTERN_FUNC_ENTER;
+ int i = 0;
+
+ // va_list list;
+ // va_start(list, callback_counts);
+
+ _DEBUG_INFO("callback_counts : %d", callback_counts);
+ for (; i < callback_counts; i++) {
+ switch (i) {
+ case 0:
+ registered_telephony_incoming_cb = va_arg(list, sync_agent_user_callback_cb_plugin);
+ _DEBUG_INFO("set user callback ( for Telephony Incoming ) !!");
+ break;
+ case 1:
+ registered_telephony_end_cb = va_arg(list, sync_agent_user_callback_cb_plugin);
+ _DEBUG_INFO("set user callback ( for Telephony End ) !!");
+ break;
+ default:
+ break;
+ }
+ }
+
+ // va_end(list);
+
+ _EXTERN_FUNC_EXIT;
+}
+
+int _register_telephony_noti_event()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int ret_val = 1;
+ int api_err = 0;
+
+ api_err = tel_register_noti_event(tel_handler, TAPI_NOTI_VOICE_CALL_STATUS_ACTIVE, __tel_alert_status_noti_cb, NULL); /* Tapi BS patch */
+ if (api_err != 0) {
+ _DEBUG_TRACE("tel_register_noti_event( TAPI_NOTI_VOICE_CALL_STATUS_ACTIVE ) failed ( err_code : %d ) !!", api_err);
+ ret_val = -1;
+ } else {
+ _DEBUG_TRACE("tel_register_noti_event( TAPI_NOTI_VOICE_CALL_STATUS_ACTIVE ) success !!");
+ }
+
+ api_err = tel_register_noti_event(tel_handler, TAPI_NOTI_VOICE_CALL_STATUS_IDLE, __tel_alert_status_noti_cb, NULL); /* Tapi BS patch */
+ if (api_err != 0) {
+ _DEBUG_TRACE("tel_register_noti_event( TAPI_NOTI_VOICE_CALL_STATUS_IDLE ) failed ( err_code : %d ) !!", api_err);
+ ret_val = -1;
+ } else {
+ _DEBUG_TRACE("tel_register_noti_event( TAPI_NOTI_VOICE_CALL_STATUS_IDLE ) success !!");
+ }
+
+ api_err = tel_register_noti_event(tel_handler, TAPI_NOTI_VIDEO_CALL_STATUS_ACTIVE, __tel_alert_status_noti_cb, NULL); /* Tapi BS patch */
+ if (api_err != 0) {
+ _DEBUG_TRACE("tel_register_noti_event( TAPI_NOTI_VIDEO_CALL_STATUS_ACTIVE ) failed ( err_code : %d ) !!", api_err);
+ ret_val = -1;
+ } else {
+ _DEBUG_TRACE("tel_register_noti_event( TAPI_NOTI_VIDEO_CALL_STATUS_ACTIVE ) success !!");
+ }
+
+ api_err = tel_register_noti_event(tel_handler, TAPI_NOTI_VIDEO_CALL_STATUS_IDLE, __tel_alert_status_noti_cb, NULL); /* Tapi BS patch */
+ if (api_err != 0) {
+ _DEBUG_TRACE("tel_register_noti_event( TAPI_NOTI_VIDEO_CALL_STATUS_ACTIVE ) failed ( err_code : %d ) !!", api_err);
+ ret_val = -1;
+ } else {
+ _DEBUG_TRACE("tel_register_noti_event( TAPI_NOTI_VIDEO_CALL_STATUS_ACTIVE ) success !!");
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return ret_val;
+}
+
+int _unregister_telephony_noti_event()
+{
+ _EXTERN_FUNC_ENTER;
+
+ int err = 0;
+ int res = 1;
+
+ err = tel_deregister_noti_event(tel_handler, TAPI_NOTI_VOICE_CALL_STATUS_ACTIVE);
+ if (err != 0) {
+ _DEBUG_TRACE("tel_deregister_noti_event( TAPI_NOTI_VOICE_CALL_STATUS_ACTIVE ) failed ( err_code : %d ) !!", err);
+ res = -1;
+ } else {
+ _DEBUG_TRACE("tel_deregister_noti_event( TAPI_NOTI_VOICE_CALL_STATUS_ACTIVE ) success !!");
+ }
+
+ err = tel_deregister_noti_event(tel_handler, TAPI_NOTI_VOICE_CALL_STATUS_IDLE);
+ if (err != 0) {
+ _DEBUG_TRACE("tel_deregister_noti_event( TAPI_NOTI_VOICE_CALL_STATUS_IDLE ) failed ( err_code : %d ) !!", err);
+ res = -1;
+ } else {
+ _DEBUG_TRACE("tel_deregister_noti_event( TAPI_NOTI_VOICE_CALL_STATUS_IDLE ) success !!");
+ }
+
+ err = tel_deregister_noti_event(tel_handler, TAPI_NOTI_VIDEO_CALL_STATUS_ACTIVE);
+ if (err != 0) {
+ _DEBUG_TRACE("tel_deregister_noti_event( TAPI_NOTI_VIDEO_CALL_STATUS_ACTIVE ) failed ( err_code : %d ) !!", err);
+ res = -1;
+ } else {
+ _DEBUG_TRACE("tel_deregister_noti_event( TAPI_NOTI_VIDEO_CALL_STATUS_ACTIVE ) success !!");
+ }
+
+ err = tel_deregister_noti_event(tel_handler, TAPI_NOTI_VIDEO_CALL_STATUS_IDLE);
+ if (err != 0) {
+ _DEBUG_TRACE("tel_deregister_noti_event( TAPI_NOTI_VIDEO_CALL_STATUS_IDLE ) failed ( err_code : %d ) !!", err);
+ res = -1;
+ } else {
+ _DEBUG_TRACE("tel_deregister_noti_event( TAPI_NOTI_VIDEO_CALL_STATUS_IDLE ) success !!");
+ }
+
+ _EXTERN_FUNC_EXIT;
+
+ return res;
+}
+
+static void __tel_alert_status_noti_cb(TapiHandle * handle, const char *noti_id, void *data, void *user_data)
+{
+ _INNER_FUNC_ENTER;
+
+ retm_if((noti_id) == NULL, "noti_id is NULL!!");
+
+ _DEBUG_VERBOSE("NOTI_ID : %s", noti_id);
+
+ if (!strcmp(TAPI_NOTI_VOICE_CALL_STATUS_IDLE, noti_id) || !strcmp(TAPI_NOTI_VIDEO_CALL_STATUS_IDLE, noti_id)) {
+ if (registered_telephony_end_cb != NULL) {
+ registered_telephony_end_cb(0, (void *)user_data);
+ } else {
+ _DEBUG_VERBOSE("not registered registered_telephony_end_cb !!");
+ }
+ _INNER_FUNC_EXIT;
+ return;
+ }
+
+ if (!strcmp(TAPI_NOTI_VOICE_CALL_STATUS_ACTIVE, noti_id) || !strcmp(TAPI_NOTI_VIDEO_CALL_STATUS_ACTIVE, noti_id)) {
+ if (registered_telephony_incoming_cb != NULL) {
+ registered_telephony_incoming_cb(0, (void *)user_data);
+ } else {
+ _DEBUG_VERBOSE("not registered registered_telephony_incoming_cb !!");
+ }
+ _INNER_FUNC_EXIT;
+ return;
+ }
+
+ _INNER_FUNC_EXIT;
+ return;
+}
diff --git a/src/plugins/dm-public/CMakeLists.txt b/src/plugins/dm-public/CMakeLists.txt
new file mode 100755
index 0000000..db3a34a
--- /dev/null
+++ b/src/plugins/dm-public/CMakeLists.txt
@@ -0,0 +1,10 @@
+
+# set plguin name
+SET(PLUGIN_CATEGORY_NAME "dm-public")
+
+# set plugin install path
+SET(LIBDIR "${PREFIX}/lib/sync-agent/${PLUGIN_CATEGORY_NAME}")
+
+ADD_SUBDIRECTORY(devdetail)
+ADD_SUBDIRECTORY(devinfo)
+
diff --git a/src/plugins/dm-public/devdetail/CMakeLists.txt b/src/plugins/dm-public/devdetail/CMakeLists.txt
new file mode 100755
index 0000000..d8d368c
--- /dev/null
+++ b/src/plugins/dm-public/devdetail/CMakeLists.txt
@@ -0,0 +1,43 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "mo-devdetail")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+ sync-agent
+ vconf
+ dlog
+ libwbxml2
+ )
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${mo-devdetail_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${mo-devdetail_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub) \ No newline at end of file
diff --git a/src/plugins/dm-public/devdetail/src/plugin_interface.c b/src/plugins/dm-public/devdetail/src/plugin_interface.c
new file mode 100755
index 0000000..addbdb9
--- /dev/null
+++ b/src/plugins/dm-public/devdetail/src/plugin_interface.c
@@ -0,0 +1,251 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <vconf.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_DEVDETAIL"
+#endif
+
+#define SERVER_NUM 1
+/*
+#define CSC_VCONF_KEY_SYNCMLDM_NBFIELD "db/SyncML/oma-dm-service/DevManagement/NbDevManagement"
+#define CSC_VCONF_KEY_SYNCMLDM_ACCNAME "db/SyncML/oma-dm-service/DevManagement/%d/AccName"
+#define CSC_VCONF_KEY_SYNCMLDM_SERVID "db/SyncML/oma-dm-service/DevManagement/%d/ServID"
+
+#define ALTER_SYNCMLDM_NBFIELD 3
+#define SERVER_NUM 3
+#define ALTER_SYNCMLDM_ACCNAME_1 "MSCTestserver"
+#define ALTER_SYNCMLDM_ACCNAME_2 "MSCServer"
+#define ALTER_SYNCMLDM_ACCNAME_3 "gcf"
+*/
+
+#define MAX_DEPTH "100"
+#define MAX_SEG_LEN "100"
+#define MAX_TOTAL_LEN "1000"
+
+static sync_agent_get_devinfo_cb pfunc_get_dev_info = 0;
+
+//static int _get_index(const char *name);
+//static char *_get_mo_value_str(const char *vconf_key, int n_index);
+
+EXPORT_API char **sync_agent_plugin_get_server_id_list(int *server_id_list_cnt)
+{
+ _EXTERN_FUNC_ENTER;
+/*
+ *server_id_list_cnt = 0;
+ char **temp_id_list = (char **)calloc(SERVER_NUM, sizeof(char *));
+ if (temp_id_list == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+
+ char *sever_name = 0;
+ int server_idx = 0;
+ char *server_id = 0;
+
+ int i;
+ for (i = 0; i < SERVER_NUM; i++) {
+
+ switch (i) {
+ case 0:
+ sever_name = ALTER_SYNCMLDM_ACCNAME_1;
+ break;
+ case 1:
+ sever_name = ALTER_SYNCMLDM_ACCNAME_2;
+ break;
+ case 2:
+ sever_name = ALTER_SYNCMLDM_ACCNAME_3;
+ break;
+ default :
+ continue;
+ break;
+ }
+
+ server_idx = _get_index(sever_name);
+ server_id = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_SERVID, server_idx);
+ if (server_id != NULL) {
+ _DEBUG_INFO("Temp_id_list[%d] = %s\n", i, server_id);
+ temp_id_list[i] = server_id;
+ (*server_id_list_cnt)++;
+ }
+ }
+ _DEBUG_INFO("server_id_list_cnt = %d\n", *server_id_list_cnt);
+ _EXTERN_FUNC_EXIT;
+ return temp_id_list;
+
+*/
+ *server_id_list_cnt = 1;
+ char **temp_id_list = (char **)calloc(SERVER_NUM, sizeof(char *));
+ if (temp_id_list == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+ }
+ char *server_id = NULL;
+ server_id = strdup("*");
+ *temp_id_list = server_id;
+
+ _DEBUG_INFO("devdetail server_id = %s\n", server_id);
+ _DEBUG_INFO("devdetail server_id_list_cnt = %d\n", *server_id_list_cnt);
+
+ _EXTERN_FUNC_EXIT;
+ return temp_id_list;
+}
+
+EXPORT_API int sync_agent_plugin_get_mo_value(const char *mo_pull_path, const char *mo_name, char **mo_value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((mo_pull_path) == NULL, -1, "mo_pull_path is NULL!!");
+ retvm_if((mo_name) == NULL, -1, "mo_name is NULL!!");
+
+ _DEBUG_INFO("mo_name : %s", mo_name);
+ *mo_value = 0;
+
+ if (!strcmp(mo_name, "DevTyp")) {
+ if (pfunc_get_dev_info == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+ pfunc_get_dev_info(2, "DevTyp", mo_value);
+ } else if (!strcmp(mo_name, "Bearer")) {
+ if (pfunc_get_dev_info == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+ pfunc_get_dev_info(2, "Bearer", mo_value);
+ } else if (!strcmp(mo_name, "OEM")) {
+ if (pfunc_get_dev_info == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+ pfunc_get_dev_info(2, "OEM", mo_value);
+ } else if (!strcmp(mo_name, "FwV")) {
+ if (pfunc_get_dev_info == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+ pfunc_get_dev_info(2, "FwV", mo_value);
+ } else if (!strcmp(mo_name, "SwV")) {
+ if (pfunc_get_dev_info == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+ pfunc_get_dev_info(2, "SwV", mo_value);
+ } else if (!strcmp(mo_name, "HwV")) {
+ if (pfunc_get_dev_info == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+ pfunc_get_dev_info(2, "HwV", mo_value);
+ } else if (!strcmp(mo_name, "LrgObj")) {
+ *mo_value = strdup("0");
+ } else if (!strcmp(mo_name, "MaxDepth")) {
+ *mo_value = strdup(MAX_DEPTH);
+ } else if (!strcmp(mo_name, "MaxTotLen")) {
+ *mo_value = strdup(MAX_TOTAL_LEN);
+ } else if (!strcmp(mo_name, "MaxSegLen")) {
+ *mo_value = strdup(MAX_SEG_LEN);
+ }
+
+ _DEBUG_INFO("mo_value : %s", *mo_value);
+
+ _EXTERN_FUNC_EXIT;
+
+ return 0;
+}
+
+EXPORT_API void sync_agent_plugin_set_function_get_devinfo(sync_agent_get_devinfo_cb func)
+{
+ _EXTERN_FUNC_ENTER;
+
+ pfunc_get_dev_info = func;
+
+ _EXTERN_FUNC_EXIT;
+}
+
+/*
+static int _get_index(const char *name)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((name) == NULL, -1, "name is NULL!!");
+
+ int acc_count = 0;
+ if (vconf_get_int(CSC_VCONF_KEY_SYNCMLDM_NBFIELD, &acc_count)) {
+ _DEBUG_TRACE("vconf_get_int FAIL");
+ //return -1;
+ acc_count =ALTER_SYNCMLDM_NBFIELD;
+ }
+
+ _DEBUG_TRACE("acc_count : %d", acc_count);
+
+ int i = 0;
+ for (; i < acc_count; i++) {
+ char *compare_name = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_ACCNAME, i + 1);
+ if (compare_name != NULL) {
+ _DEBUG_TRACE("[%d] compare_name : %s [%d], name : %s [%d]", i, compare_name, strlen(compare_name), name, strlen(name));
+ if (!strcmp(name, compare_name)) {
+ _DEBUG_TRACE("nIndex : %d", i + 1);
+ _INNER_FUNC_EXIT;
+ return i + 1;
+ }
+ }
+ }
+
+ _INNER_FUNC_EXIT;
+ return -1;
+}
+
+static char *_get_mo_value_str(const char *vconf_key, int n_index)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((vconf_key) == NULL, NULL, "vconf_key is NULL!!");
+
+ if (n_index == -1) {
+ return 0;
+ }
+
+ char input_vconf_path[200] = { 0, };
+ char cRecIdx[8];
+
+ memset(cRecIdx, 0x0, sizeof(cRecIdx));
+ snprintf(cRecIdx, sizeof(cRecIdx), "%d", n_index);
+ snprintf(input_vconf_path, strlen(vconf_key) + strlen(cRecIdx) + 1, vconf_key, n_index);
+
+ char *value = vconf_get_str(input_vconf_path);
+ if (value == NULL) {
+ _DEBUG_TRACE("vconf_get_str FAIL");
+ }
+
+ _INNER_FUNC_EXIT;
+
+ return value;
+}
+*/
diff --git a/src/plugins/dm-public/devinfo/CMakeLists.txt b/src/plugins/dm-public/devinfo/CMakeLists.txt
new file mode 100755
index 0000000..f60c049
--- /dev/null
+++ b/src/plugins/dm-public/devinfo/CMakeLists.txt
@@ -0,0 +1,43 @@
+
+#############################################
+#
+# Step 1. Set Variable and Build Dependency
+#
+
+# set plguin name
+SET(PLUGIN_NAME "mo-devinfo")
+
+# set a name for the entire project
+PROJECT(plugin-${PLUGIN_NAME})
+
+# checks for build dependency modules : a pkg-config module for CMake
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${PLUGIN_NAME} REQUIRED
+ sync-agent
+ vconf
+ dlog
+ libwbxml2
+ )
+
+#############################################
+#
+# Step 2. Set Compile Environment
+#
+
+# set extra cflags from build dependency
+SET(PLUGIN_CFLAGS "${mo-devinfo_CFLAGS}")
+
+#############################################
+#
+# Step 3. Set Link Environment
+#
+
+# link a target to given libraries from pkg-config.
+SET(PLUGIN_LDFLAGS "${mo-devinfo_LDFLAGS}")
+
+#############################################
+#
+# Step 4. Install packages
+#
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.sub) \ No newline at end of file
diff --git a/src/plugins/dm-public/devinfo/src/.gitignore b/src/plugins/dm-public/devinfo/src/.gitignore
new file mode 100755
index 0000000..823fc92
--- /dev/null
+++ b/src/plugins/dm-public/devinfo/src/.gitignore
@@ -0,0 +1 @@
+/calendarInterface.c
diff --git a/src/plugins/dm-public/devinfo/src/plugin_interface.c b/src/plugins/dm-public/devinfo/src/plugin_interface.c
new file mode 100755
index 0000000..bd0536d
--- /dev/null
+++ b/src/plugins/dm-public/devinfo/src/plugin_interface.c
@@ -0,0 +1,247 @@
+/*
+ * oma-dm-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <vconf.h>
+
+/*sync-agent*/
+#include <sync_agent.h>
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__ ((visibility("default")))
+#endif
+
+#ifndef OMADM_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "PLUGIN_DEVINF"
+#endif
+
+#define SERVER_NUM 1
+/*
+#define CSC_VCONF_KEY_SYNCMLDM_NBFIELD "db/SyncML/oma-dm-service/DevManagement/NbDevManagement"
+#define CSC_VCONF_KEY_SYNCMLDM_ACCNAME "db/SyncML/oma-dm-service/DevManagement/%d/AccName"
+#define CSC_VCONF_KEY_SYNCMLDM_SERVID "db/SyncML/oma-dm-service/DevManagement/%d/ServID"
+
+#define ALTER_SYNCMLDM_NBFIELD 3
+#define SERVER_NUM 3
+#define ALTER_SYNCMLDM_ACCNAME_1 "MSCTestserver"
+#define ALTER_SYNCMLDM_ACCNAME_2 "MSCServer"
+#define ALTER_SYNCMLDM_ACCNAME_3 "gcf"
+*/
+
+static sync_agent_get_devinfo_cb pfunc_get_dev_info = 0;
+
+//static int _get_index(const char *name);
+//static char *_get_mo_value_str(const char *vconf_key, int n_index);
+
+EXPORT_API char **sync_agent_plugin_get_server_id_list(int *server_id_list_cnt)
+{
+ _EXTERN_FUNC_ENTER;
+/*
+ *server_id_list_cnt = 0;
+ char **temp_id_list = (char **)calloc(SERVER_NUM, sizeof(char *));
+ if (temp_id_list == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return 0;
+ }
+
+ char *sever_name = 0;
+ int server_idx = 0;
+ char *server_id = 0;
+
+ int i;
+ for (i = 0; i < SERVER_NUM; i++) {
+
+ switch (i) {
+ case 0:
+ sever_name = ALTER_SYNCMLDM_ACCNAME_1;
+ break;
+ case 1:
+ sever_name = ALTER_SYNCMLDM_ACCNAME_2;
+ break;
+ case 2:
+ sever_name = ALTER_SYNCMLDM_ACCNAME_3;
+ break;
+ default :
+ continue;
+ break;
+ }
+
+ server_idx = _get_index(sever_name);
+ server_id = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_SERVID, server_idx);
+ if (server_id != NULL) {
+ _DEBUG_INFO("Temp_id_list[%d] = %s\n", i, server_id);
+ temp_id_list[i] = server_id;
+ (*server_id_list_cnt)++;
+ }
+ }
+ _DEBUG_INFO("server_id_list_cnt = %d\n", *server_id_list_cnt);
+ _EXTERN_FUNC_EXIT;
+ return temp_id_list;
+*/
+ *server_id_list_cnt = 1;
+ char **temp_id_list = (char **)calloc(SERVER_NUM, sizeof(char *));
+ if (temp_id_list == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return NULL;
+ }
+ char *server_id = NULL;
+ server_id = strdup("*");
+ *temp_id_list = server_id;
+
+ _DEBUG_INFO("devinfo server_id = %s\n", server_id);
+ _DEBUG_INFO("devinfo server_id_list_cnt = %d\n", *server_id_list_cnt);
+
+ _EXTERN_FUNC_EXIT;
+ return temp_id_list;
+}
+
+EXPORT_API int sync_agent_plugin_get_mo_value(const char *mo_pull_path, const char *mo_name, char **mo_value)
+{
+ _EXTERN_FUNC_ENTER;
+
+ retvm_if((mo_pull_path) == NULL, -1, "mo_pull_path is NULL!!");
+ retvm_if((mo_name) == NULL, -1, "mo_name is NULL!!");
+
+ _DEBUG_INFO("mo_name : %s", mo_name);
+ *mo_value = NULL;
+
+ if (!strcmp(mo_name, "DevId")) {
+ if (pfunc_get_dev_info != NULL) {
+ pfunc_get_dev_info(2, "DevID", mo_value);
+ if (*mo_value == NULL) {
+ _DEBUG_INFO("device id is NULL");
+ return -1;
+ }
+ } else {
+ _DEBUG_INFO("pfunc_get_dev_info is NULL");
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+ } else if (!strcmp(mo_name, "Bearer")) {
+ if (pfunc_get_dev_info == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+ pfunc_get_dev_info(2, "Bearer", mo_value);
+ } else if (!strcmp(mo_name, "Man")) {
+ if (pfunc_get_dev_info == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+ pfunc_get_dev_info(2, "Man", mo_value);
+ } else if (!strcmp(mo_name, "Mod")) {
+ if (pfunc_get_dev_info == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+ pfunc_get_dev_info(2, "Mod", mo_value);
+ } else if (!strcmp(mo_name, "DmV")) {
+ /*
+ if (pfunc_get_dev_info == NULL) {
+ return -1;
+ }
+ sync_agent_dev_return_e res = pfunc_get_dev_info(2, "DmV", mo_value);
+ */
+ /*
+ * todo HardCoding
+ */
+ *mo_value = strdup("1.2");
+ } else if (!strcmp(mo_name, "Lang")) {
+ if (pfunc_get_dev_info == NULL) {
+ _EXTERN_FUNC_EXIT;
+ return -1;
+ }
+ *mo_value = strdup("en-us");
+ /* sync_agent_dev_return_e res = pfunc_get_dev_info(2, "Lang", mo_value); */
+ }
+
+ _DEBUG_INFO("mo_value : %s", *mo_value);
+ _EXTERN_FUNC_EXIT;
+ return 0;
+}
+
+EXPORT_API void sync_agent_plugin_set_function_get_devinfo(sync_agent_get_devinfo_cb func)
+{
+ _EXTERN_FUNC_ENTER;
+
+ pfunc_get_dev_info = func;
+
+ _EXTERN_FUNC_EXIT;
+
+}
+
+/*
+static int _get_index(const char *name)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((name) == NULL, -1, "name is NULL!!");
+
+ int acc_count = 0;
+ if (vconf_get_int(CSC_VCONF_KEY_SYNCMLDM_NBFIELD, &acc_count)) {
+ _DEBUG_TRACE("vconf_get_int FAIL");
+ //return -1;
+ acc_count =ALTER_SYNCMLDM_NBFIELD;
+ }
+
+ _DEBUG_TRACE("acc_count : %d", acc_count);
+
+ int i = 0;
+ for (; i < acc_count; i++) {
+ char *compare_name = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_ACCNAME, i + 1);
+ if (compare_name != NULL) {
+ _DEBUG_TRACE("[%d] compare_name : %s [%d], name : %s [%d]", i, compare_name, strlen(compare_name), name, strlen(name));
+ if (!strcmp(name, compare_name)) {
+ _DEBUG_TRACE("nIndex : %d", i + 1);
+ _INNER_FUNC_EXIT;
+ return i + 1;
+ }
+ }
+ }
+ _INNER_FUNC_EXIT;
+
+ return -1;
+}
+
+static char *_get_mo_value_str(const char *vconf_key, int n_index)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if((vconf_key) == NULL, NULL, "vconf_key is NULL!!");
+
+ if (n_index == -1) {
+ return 0;
+ }
+
+ char input_vconf_path[200] = { 0, };
+ char cRecIdx[8];
+
+ memset(cRecIdx, 0x0, sizeof(cRecIdx));
+ snprintf(cRecIdx, sizeof(cRecIdx), "%d", n_index);
+ snprintf(input_vconf_path, strlen(vconf_key) + strlen(cRecIdx) + 1, vconf_key, n_index);
+
+ char *value = vconf_get_str(input_vconf_path);
+ if (value == NULL) {
+ _DEBUG_TRACE("vconf_get_str FAIL");
+ }
+ _INNER_FUNC_EXIT;
+ return value;
+}
+*/