tizen 2.4 release accepted/tizen_2.4_mobile accepted/tizen/2.4/mobile/20151029.033220 submit/tizen_2.4/20151028.064135 tizen_2.4_mobile_release
authorjk7744.park <jk7744.park@samsung.com>
Mon, 26 Oct 2015 06:44:49 +0000 (15:44 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Mon, 26 Oct 2015 06:44:49 +0000 (15:44 +0900)
51 files changed:
CMakeLists.txt [new file with mode: 0644]
LICENSE.Apache-2.0 [new file with mode: 0644]
NOTICE [new file with mode: 0644]
README [new file with mode: 0644]
doc/service_adaptor_doc.h [new file with mode: 0644]
doc/service_adaptor_plugin_doc.h [new file with mode: 0644]
doc/service_adaptor_storage_doc.h [new file with mode: 0644]
include/dbus/dbus_client.h [new file with mode: 0644]
include/dbus/dbus_client_auth.h [new file with mode: 0644]
include/dbus/dbus_client_contact.h [new file with mode: 0644]
include/dbus/dbus_client_layer.h [new file with mode: 0644]
include/dbus/dbus_client_message.h [new file with mode: 0644]
include/dbus/dbus_client_push.h [new file with mode: 0644]
include/dbus/dbus_client_shop.h [new file with mode: 0644]
include/dbus/dbus_client_storage.h [new file with mode: 0644]
include/private/service-adaptor-client-auth.h [new file with mode: 0644]
include/private/service-adaptor-client-contact.h [new file with mode: 0644]
include/private/service-adaptor-client-message.h [new file with mode: 0644]
include/private/service-adaptor-client-push.h [new file with mode: 0644]
include/private/service-adaptor-client-shop.h [new file with mode: 0644]
include/private/service-adaptor-client-storage.h [new file with mode: 0644]
include/private/service-adaptor-client.h [new file with mode: 0644]
include/service_adaptor_client.h [new file with mode: 0644]
include/service_adaptor_client_log.h [new file with mode: 0644]
include/service_adaptor_client_plugin.h [new file with mode: 0644]
include/service_adaptor_client_private.h [new file with mode: 0644]
include/service_adaptor_client_storage.h [new file with mode: 0644]
include/service_adaptor_client_storage_internal.h [new file with mode: 0644]
include/service_adaptor_client_type.h [new file with mode: 0644]
include/util/service_adaptor_client_util.h [new file with mode: 0644]
packaging/service-adaptor-client.spec [new file with mode: 0644]
service-adaptor-client.manifest [new file with mode: 0644]
service-adaptor-client.pc.in [new file with mode: 0644]
src/dbus/dbus_client.c [new file with mode: 0644]
src/dbus/dbus_client_auth.c [new file with mode: 0644]
src/dbus/dbus_client_contact.c [new file with mode: 0644]
src/dbus/dbus_client_layer.c [new file with mode: 0644]
src/dbus/dbus_client_message.c [new file with mode: 0644]
src/dbus/dbus_client_push.c [new file with mode: 0644]
src/dbus/dbus_client_shop.c [new file with mode: 0644]
src/dbus/dbus_client_storage.c [new file with mode: 0644]
src/service_adaptor_client.c [new file with mode: 0644]
src/service_adaptor_client_auth.c [new file with mode: 0644]
src/service_adaptor_client_contact.c [new file with mode: 0644]
src/service_adaptor_client_message.c [new file with mode: 0644]
src/service_adaptor_client_push.c [new file with mode: 0644]
src/service_adaptor_client_shop.c [new file with mode: 0644]
src/service_adaptor_client_storage.c [new file with mode: 0644]
src/util/service_adaptor_client_util.c [new file with mode: 0644]
test/CMakeLists.txt [new file with mode: 0644]
test/main.c [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..349f5af
--- /dev/null
@@ -0,0 +1,71 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(service-adaptor-client C)
+
+SET(PACKAGE     ${PROJECT_NAME})
+SET(PKGNAME     "${PROJECT_NAME}")
+#SET(PREFIX      ${CMAKE_INSTALL_PREFIX})
+SET(PREFIX      "/usr")
+#SET(BINDIR      "${PREFIX}/bin")
+SET(LIBDIR      "${PREFIX}/lib")
+SET(INCLUDEDIR  "/usr/include")
+
+FILE(GLOB SRCS src/*.c
+              src/dbus/*.c
+               src/util/*.c)
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+        SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+ADD_DEFINITIONS(-DPUSH_DEBUG)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/dbus)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+ dlog
+ glib-2.0
+ gobject-2.0
+ gio-2.0
+ gthread-2.0
+#capi-telephony
+ service-adaptor
+ capi-base-common
+ capi-appfw-application
+ security-privilege-checker
+ security-server
+ bundle)
+
+FOREACH(flag ${pkgs_CFLAGS})
+        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -Werror -std=gnu99 -D_GNU_SOURCE -DVSERVICE_CHANNEL_SVC_DLL -DVSERVICE_CHANNEL_SVC_DLL_EXPORTS")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+#ADD_SUBDIRECTORY(test)
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS} )
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} service-adaptor-client)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIBDIR})
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/service_adaptor_client.h DESTINATION /usr/include/)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/service_adaptor_client_plugin.h DESTINATION /usr/include/)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/service_adaptor_client_storage.h DESTINATION /usr/include/)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/service_adaptor_client_storage_internal.h DESTINATION /usr/include/)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/service_adaptor_client_type.h DESTINATION /usr/include/service-adaptor-client/)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/service_adaptor_client_log.h DESTINATION /usr/include/service-adaptor-client/)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/private/service-adaptor-client.h DESTINATION /usr/include/service-adaptor-client/)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/private/service-adaptor-client-auth.h DESTINATION /usr/include/service-adaptor-client/)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/private/service-adaptor-client-storage.h DESTINATION /usr/include/service-adaptor-client/)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/private/service-adaptor-client-message.h DESTINATION /usr/include/service-adaptor-client/)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/private/service-adaptor-client-push.h DESTINATION /usr/include/service-adaptor-client/)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/private/service-adaptor-client-shop.h DESTINATION /usr/include/service-adaptor-client/)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/include/private/service-adaptor-client-contact.h DESTINATION /usr/include/service-adaptor-client/)
+
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/service-adaptor-client.pc.in ${CMAKE_SOURCE_DIR}/service-adaptor-client.pc @ONLY)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/service-adaptor-client.pc DESTINATION ${LIBDIR}/pkgconfig)
diff --git a/LICENSE.Apache-2.0 b/LICENSE.Apache-2.0
new file mode 100644 (file)
index 0000000..d645695
--- /dev/null
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..579ba56
--- /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.Apache-2.0 file for Apache License terms and conditions.
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/doc/service_adaptor_doc.h b/doc/service_adaptor_doc.h
new file mode 100644 (file)
index 0000000..f0c27ac
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 __TIZEN_SOCIAL_SERVICE_ADAPTOR_MODULE_DOC_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_MODULE_DOC_H__
+
+
+/**
+ * @ingroup    CAPI_SOCIAL_FRAMEWORK
+ * @defgroup   SERVICE_ADAPTOR_MODULE Service Adaptor
+ * @brief      The @ref SERVICE_ADAPTOR_MODULE API provides developer with common interfaces like using local service for various service infra.
+ *
+ * @section    SERVICE_ADAPTOR_MODULE_HEADER Required Header
+ *  \#include <service_adaptor_client.h>
+ * @section    SERVICE_ADAPTOR_MODULE_OVERVIEW Overview
+ * Developers can use functions easily and commonly be provided from various service infra.
+ * <br>When you want use another service infra, you can use same interfaces if you change just initalize setting.
+ * <br>Service adaptor provides functions kind of Auth, Storage and it will provides more kinds of service infra.
+ * <table>
+ * <tr>
+ *     <th>API</th>
+ *     <th>Description</th>
+ * </tr>
+ * <tr>
+ *     <td>@ref SERVICE_PLUGIN_MODULE</td>
+ *     <td> Provide functions for handling service plugin</td>
+ * </tr>
+ * </table>
+ * \n
+ */
+
+
+#endif /*__TIZEN_SOCIAL_SERVICE_ADAPTOR_MODULE_DOC_H__*/
diff --git a/doc/service_adaptor_plugin_doc.h b/doc/service_adaptor_plugin_doc.h
new file mode 100644 (file)
index 0000000..a9a0485
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 __TIZEN_SOCIAL_SERVICE_PLUGIN_MODULE_DOC_H__
+#define __TIZEN_SOCIAL_SERVICE_PLUGIN_MODULE_DOC_H__
+
+
+/**
+ * @ingroup    SERVICE_ADAPTOR_MODULE
+ * @defgroup   SERVICE_PLUGIN_MODULE Service Plugin
+ * @brief      The @ref SERVICE_PLUGIN_MODULE API provides functions to manage the <b>plugin set</b>'s property and state
+ *
+ * @section    SERVICE_PLUGIN_MODULE_HEADER Required Header
+ *  \#include <service_adaptor_client.h>
+ * @section    SERVICE_PLUGIN_MODULE_OVERVIEW Overview
+ * The #service_plugin_h can gets using @ref SERVICE_ADAPTOR_MODULE API.
+ * <br>It means kind of plugin set, the APIs can set property for using service and handling service plugin.
+ * <table>
+ * <tr>
+ *     <th>API</th>
+ *     <th>Description</th>
+ * </tr>
+ * <tr>
+ *     <td>@ref SERVICE_ADAPTOR_STORAGE_MODULE</td>
+ *     <td> Provide functions for access and manage storage service</td>
+ * </tr>
+ * </table>
+ * \n
+ */
+
+
+#endif /*__TIZEN_SOCIAL_SERVICE_PLUGIN_MODULE_DOC_H__*/
diff --git a/doc/service_adaptor_storage_doc.h b/doc/service_adaptor_storage_doc.h
new file mode 100644 (file)
index 0000000..8d1c7a3
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT 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 __TIZEN_SOCIAL_SERVICE_ADAPTOR_STORAGE_DOC_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_STORAGE_DOC_H__
+
+
+/**
+ * @ingroup    SERVICE_PLUGIN_MODULE
+ * @defgroup   SERVICE_ADAPTOR_STORAGE_MODULE Storage
+ * @brief      Provide functions for access and managing storage service
+ * @section    SERVICE_ADAPTOR_STORAGE_MODULE_HEADER Require Header
+ * \#include <service_adaptor_client.h>
+ * @section    SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW Overview
+ * It privides common APIs for using various service infra
+ * <div>
+ * In this APIs, there are needed two kind of path types.
+ * One is <b>"Logical path"</b> and the other is <b>"Physical path"</b>.<br>
+ * <div>
+ * <p>First, <b>"Logical path"</b> type means path of "root file system".<br>
+ * It starts from root path(= '/') and you can use this path like linux.<br>
+ * For example, "/folder1/image1.jpg"<br><br>
+ * </div>
+ * <div>
+ * <p>Second, <b>"Physical path"</b> type means specfic uri that be used for cloud server.<br>
+ * Some clouds use same with "Logical path", but some clouds use specfic key or url.<br>
+ * For example, "/" is "ZmNhMWY2MTZlY2M1NDg4OGJmZDY4O", "/folder1" is "2JI32UNJDWQEQWQWEADSSAD"<br>
+ * </div>
+ * Under the @ref SERVICE_ADAPTOR_STORAGE_MODULE APIs, the path parameters are used these types.<br>
+ * </div>
+ */
+
+
+#endif /*__TIZEN_SOCIAL_SERVICE_ADAPTOR_STORAGE_DOC_H__*/
diff --git a/include/dbus/dbus_client.h b/include/dbus/dbus_client.h
new file mode 100644 (file)
index 0000000..de74949
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: dbus-client.h
+ * Desc: D-Bbus IPC client APIs
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ *     @file           dbus-client.h
+ *     @brief          Defines interface of D-Bus IPC
+ *     @version        0.1
+ */
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_private.h"
+
+#define __safe_add_string(x)   (x==NULL)?"":x
+
+#define SECURITY_SERVER_COOKIE_BUFFER_SIZE     21
+
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+
+GDBusProxy *_dbus_get_sac_interface_proxy();
+
+/**
+ * @brief Service Adaptor D-Bus client initialization.
+ */
+int _dbus_client_service_adaptor_init();
+
+/**
+ * @brief Service Adaptor D-Bus client deinitialization.
+ */
+void _dbus_client_service_adaptor_deinit();
+
+
+/**
+ * @brief Adds string into variant builder
+ */
+void __safe_g_variant_builder_add_string(GVariantBuilder *builder,
+                                               const char *data);
+
+/**
+ * @brief Adds string into array variant builder
+ */
+void __safe_g_variant_builder_add_array_string(GVariantBuilder *builder,
+                                               const char *data);
+
+/**
+ * @brief Returns NULL point if string is ""
+ */
+char *ipc_g_variant_dup_string(GVariant *string);
+
+/**
+ * @brief
+ * @param[out]
+ * @param[out]
+ * @return
+ * @pre This function requires opened DBus connection by service-adaptor-client.c
+ */
+int _dbus_connect_service_adaptor(service_adaptor_error_s *error);
+
+int _dbus_get_plugin_list(plugin_entry_t ***plugin_list, unsigned int *plugins_len, service_adaptor_error_s *error);
+
+int _dbus_is_login_required(service_plugin_h plugin, bool *required, service_adaptor_error_s *error);
+
+int _dbus_request_login(service_plugin_h plugin, void *callback, void *user_data, service_adaptor_error_s *error);
+
+int _dbus_start_service(service_plugin_h plugin, int service_flag, const char *security_cookie, service_adaptor_error_s *error);
+
+int _dbus_external_request(const char *service_name,
+                                               int service_flag,
+                                               const char *api_uri,
+                                               unsigned char *input_str,
+                                               int input_len,
+                                               unsigned char **output_str,
+                                               int *output_len,
+                                               service_adaptor_error_s *error);
+
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_H__ */
diff --git a/include/dbus/dbus_client_auth.h b/include/dbus/dbus_client_auth.h
new file mode 100644 (file)
index 0000000..459c2a0
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: dbus-client-auth.h
+ * Desc: D-Bbus IPC client APIs for auth
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ *     @file           dbus-client-auth.h
+ *     @brief          Defines interface of D-Bus IPC
+ *     @version        0.1
+ */
+
+#ifndef __DBUS_CLIENT_AUTH_H__
+#define __DBUS_CLIENT_AUTH_H__
+
+#include <glib.h>
+#include "service_adaptor_client_type.h"
+#include "private/service-adaptor-client-auth.h"
+
+/**
+ * @brief
+ * @param[out]
+ * @param[out]
+ * @return
+ * @pre This function requires opened DBus connection by service-adaptor-client-auth.c
+ */
+int _dbus_get_auth_plugin_list(GList **plugin_list,
+                                               const char *imsi,
+                                               service_adaptor_error_s *error);
+
+int _dbus_set_auth(const char *service_name,
+                                               const char *imsi,
+                                               const char *name,
+                                               const char *app_id,
+                                               const char *app_secret,
+                                               unsigned int service_id,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+#endif /* __DBUS_CLIENT_AUTH_H__ */
+
diff --git a/include/dbus/dbus_client_contact.h b/include/dbus/dbus_client_contact.h
new file mode 100644 (file)
index 0000000..4feefc4
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: dbus-client-contact.h
+ * Desc: D-Bbus IPC client APIs for contact
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ *     @file           dbus-client-contact.h
+ *     @brief          Defines interface of D-Bus IPC
+ *     @version        0.1
+ */
+
+#ifndef __DBUS_CLIENT_CONTACT_H__
+#define __DBUS_CLIENT_CONTACT_H__
+
+#include <glib.h>
+#include "service_adaptor_client_type.h"
+#include "private/service-adaptor-client-contact.h"
+
+#define CONTACT_PROFILE_IMAGE_PATH_LEN 2048
+
+typedef struct _service_adaptor_profile_image_s
+{
+       service_adaptor_contact_request_type_e type;
+       int index;
+       char path[CONTACT_PROFILE_IMAGE_PATH_LEN];
+} service_adaptor_profile_image_s;
+
+
+/**
+ * @brief
+ * @param[out]
+ * @param[out]
+ * @return
+ * @pre This function requires opened DBus connection by service-adaptor-client-contact.c
+ */
+int _dbus_set_new_contact_list(const char *service_name,
+                                               service_adaptor_contact_req_s *contact_req,
+                                               void *user_data,
+                                               service_adaptor_contact_res_s **contact_res,
+                                               void **server_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_set_contact_list(const char *service_name,
+                                               service_adaptor_contact_req_s *contact_req,
+                                               void *user_data,
+                                               service_adaptor_contact_res_s **contact_res,
+                                               void **server_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_get_contact_list(const char *service_name,
+                                               service_adaptor_contact_res_s **contact_res,
+                                               void **server_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_get_contact_infos_polling(const char *service_name,
+                                               service_adaptor_contact_req_s *contact_req,
+                                               void *user_data,
+                                               service_adaptor_contact_res_s **contact_res,
+                                               void **server_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_set_me_profile_with_push(const char *service_name,
+                                               service_adaptor_profile_req_s *profile_req,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_get_profile(const char *service_name,
+                                               service_adaptor_profile_req_s *profile_req,
+                                               void *user_data,
+                                               service_adaptor_profile_res_s **profile_res,
+                                               void **server_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_set_profile_image_meta_with_push(const char *service_name,
+                                               service_adaptor_profile_image_h *images,
+                                               unsigned int images_len,
+                                               void *user_data,
+                                               service_adaptor_profile_image_h **failed_images,
+                                               unsigned int *failed_images_len,
+                                               void **server_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_delete_me_profile_image_meta_with_push(const char *service_name,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_set_me_profile_privacy(const char *service_name,
+                                               service_adaptor_privacy_req_s *privacy_req,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_get_me_profile_privacy(const char *service_name,
+                                               service_adaptor_privacy_res_s **privacy_res,
+                                               void **server_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_set_me_presence_with_push(const char *service_name,
+                                               service_adaptor_presence_req_s *presence_req,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_set_me_presence_on_off_with_push(const char *service_name,
+                                               service_adaptor_presence_req_s *presence_req,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_set_me_profile_type(const char *service_name,
+                                               int type,
+                                               char **url,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+#endif /* __DBUS_CLIENT_CONTACT_H__ */
+
diff --git a/include/dbus/dbus_client_layer.h b/include/dbus/dbus_client_layer.h
new file mode 100644 (file)
index 0000000..da20576
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: dbus-client-layer.h
+ * Desc: D-Bbus IPC client
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ *     @file           dbus-client-layer.h
+ *     @brief          Defines interface of D-Bus IPC
+ *     @version        0.1
+ */
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_LAYER_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_LAYER_H__
+
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+ * @brief Initialize D-Bus IPC client layer.
+ *
+ * Initialize D-Bus IPC client layer. Must be called once at startup before any call to Service Adaptor
+ * client API is made.
+ * @return 0 on success, -1 on error.
+ */
+int _dbus_client_layer_init();
+
+/**
+ * @brief Deinitialize D-Bus IPC client layer.
+ *
+ * Deinitialize D-Bus IPC client layer. Should be run once at shutdown.
+ */
+void _dbus_client_layer_deinit();
+
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_LAYER_H__ */
diff --git a/include/dbus/dbus_client_message.h b/include/dbus/dbus_client_message.h
new file mode 100644 (file)
index 0000000..805cf4c
--- /dev/null
@@ -0,0 +1,183 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: dbus-client-message.h
+ * Desc: D-Bbus IPC client APIs for message
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ *     @file           dbus-client-message.h
+ *     @brief          Defines interface of D-Bus IPC
+ *     @version        0.1
+ */
+
+#ifndef __DBUS_CLIENT_MESSAGE_H__
+#define __DBUS_CLIENT_MESSAGE_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+#include "service_adaptor_client_type.h"
+#include "private/service-adaptor-client-message.h"
+
+void on_message_signal(GDBusProxy *proxy,
+                                               gchar *sender_name,
+                                               gchar *signal_name,
+                                               GVariant *parameters,
+                                               gpointer user_data);
+
+/**
+ * @brief
+ * @param[out]
+ * @param[out]
+ * @return
+ * @pre This function requires opened DBus connection by service-adaptor-client-messaging.c
+ */
+int _dbus_request_create_chatroom(const char *service_name,
+                                               long long int request_id,
+                                               int chat_type,
+                                               long long int *receivers,
+                                               unsigned int receivers_len,
+                                               const char *chatroom_title,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_request_change_chatroom_meta(const char *service_name,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               const char *chatroom_title,
+                                               int default_message_ttl,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_request_chat(const char *service_name,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               service_adaptor_chat_msg_s **chat_msgs,
+                                               unsigned int chat_msgs_len,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_request_allow_chat(const char *service_name,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               bool is_auto_allow,
+                                               int max_count,
+                                               bool need_delivery_ack,
+                                               unsigned long long last_delivery_ack_timestamp,
+                                               bool need_read_ack,
+                                               unsigned long long last_read_ack_timestamp,
+                                               bool need_ordered_chat_member_list,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_request_all_unread_message(const char *service_name,
+                                               long long int request_id,
+                                               int max_count,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_reply_forward_online_message(const char *service_name,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               bool mark_as_read,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_reply_forward_unread_message(const char *service_name,
+                                               long long int request_id,
+                                               const char *next_pagination_key,
+                                               int max_count,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_request_read_message(const char *service_name,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               service_adaptor_inbox_message_s *inbox_msg,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_request_invite_chat(const char *service_name,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               long long int *inviting_members,
+                                               unsigned int inviting_members_len,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_request_end_chat(const char *service_name,
+                                               long long int request_id,
+                                               service_adaptor_end_chat_s **end_chats,
+                                               unsigned int end_chats_len,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_request_unseal_message(const char *service_name,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               long long int sender_id,
+                                               long long int message_id,
+                                               const char *message_detail,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_request_save_call_log(const char *service_name,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               const char *call_id,
+                                               const char *call_log_type,
+                                               long long int call_sender_id,
+                                               long long int call_receiver_id,
+                                               int conversaction_second,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_request_current_time(const char *service_name,
+                                               long long int request_id,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_request_get_connection_policy(const char *service_name,
+                                               service_adaptor_connection_policy_e *policy,
+                                               service_adaptor_error_s *error);
+
+int _dbus_request_set_connection_policy(const char *service_name,
+                                               service_adaptor_connection_policy_e *policy,
+                                               service_adaptor_error_s *error);
+
+int _dbus_get_chat_id_list(const char *service_name,
+                                               service_adaptor_phone_number_s **phone_numbers,
+                                               unsigned int phone_numbers_len,
+                                               void *user_data,
+                                               service_adaptor_chat_id_s ***chat_ids,
+                                               unsigned int *chat_ids_len,
+                                               void **server_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_get_msisdn_list(const char *service_name,
+                                               long long int *chat_ids,
+                                               unsigned int chat_ids_len,
+                                               void *user_data,
+                                               service_adaptor_chat_id_s ***msisdns,
+                                               unsigned int *msisdns_len,
+                                               void **server_data,
+                                               service_adaptor_error_s *error);
+
+#endif /* __DBUS_CLIENT_MESSAGE_H__ */
+
diff --git a/include/dbus/dbus_client_push.h b/include/dbus/dbus_client_push.h
new file mode 100644 (file)
index 0000000..92a52e3
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: dbus-client-push.h
+ * Desc: D-Bbus IPC client APIs for auth
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ *     @file           dbus-client-push.h
+ *     @brief          Defines interface of D-Bus IPC
+ *     @version        0.1
+ */
+
+#ifndef __DBUS_CLIENT_PUSH_H__
+#define __DBUS_CLIENT_PUSH_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+#include "service_adaptor_client_type.h"
+#include "private/service-adaptor-client-push.h"
+
+void on_push_signal(GDBusProxy *proxy,
+                                               gchar *sender_name,
+                                               gchar *signal_name,
+                                               GVariant *parameters,
+                                               gpointer user_data);
+
+/**
+ * @brief
+ * @param[out]
+ * @param[out]
+ * @return
+ * @pre This function requires opened DBus connection by service-adaptor-client-push.c
+ */
+
+int _dbus_push_register(const char *file_name,
+                                               service_adaptor_error_s *error);
+
+int _dbus_push_deregister(const char *file_name,
+                                               service_adaptor_error_s *error);
+#endif /* __DBUS_CLIENT_PUSH_H__ */
+
diff --git a/include/dbus/dbus_client_shop.h b/include/dbus/dbus_client_shop.h
new file mode 100644 (file)
index 0000000..3fb2f4a
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: dbus-client-shop.h
+ * Desc: D-Bbus IPC client APIs for shop
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ *     @file           dbus-client-shop.h
+ *     @brief          Defines interface of D-Bus IPC
+ *     @version        0.1
+ */
+
+#ifndef __DBUS_CLIENT_SHOP_H__
+#define __DBUS_CLIENT_SHOP_H__
+
+#include <glib.h>
+#include "service_adaptor_client_type.h"
+#include "private/service-adaptor-client-shop.h"
+
+/**
+ * @brief
+ * @param[out]
+ * @param[out]
+ * @return
+ * @pre This function requires opened DBus connection by service-adaptor-client-shop.c
+ */
+int _dbus_get_item_list(const char *service_name,
+                                               service_adaptor_shop_info_s *info,
+                                               void *user_data,
+                                               service_adaptor_shop_item_s ***items,
+                                               unsigned int *items_len,
+                                               void **server_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_download_item_package(const char *service_name,
+                                               service_adaptor_shop_info_s *info,
+                                               void *user_data,
+                                               service_adaptor_shop_item_s **item,
+                                               void **server_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_download_sticker(const char *service_name,
+                                               service_adaptor_shop_info_s *info,
+                                               void *user_data,
+                                               service_adaptor_shop_item_s **item,
+                                               void **server_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_get_panel_url(const char *service_name,
+                                               service_adaptor_shop_info_s *info,
+                                               void *user_data,
+                                               service_adaptor_shop_item_s **item,
+                                               void **server_data,
+                                               service_adaptor_error_s *error);
+
+#endif /* __DBUS_CLIENT_SHOP_H__ */
+
diff --git a/include/dbus/dbus_client_storage.h b/include/dbus/dbus_client_storage.h
new file mode 100644 (file)
index 0000000..f3cda1f
--- /dev/null
@@ -0,0 +1,262 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: dbus-client-storage.h
+ * Desc: D-Bbus IPC client APIs for storage
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ *     @file           dbus-client-storage.h
+ *     @brief          Defines interface of D-Bus IPC
+ *     @version        0.1
+ */
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_STORAGE_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_STORAGE_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_storage.h"
+#include "service_adaptor_client_storage_internal.h"
+
+//////////////////////// private feature
+#include "private/service-adaptor-client-storage.h"
+//////////////////////// private feature
+
+void on_storage_signal(GDBusProxy *proxy,
+                                               gchar *sender_name,
+                                               gchar *signal_name,
+                                               GVariant *parameters,
+                                               gpointer user_data);
+
+/**
+ * @brief
+ * @param[out]
+ * @param[out]
+ * @return
+ * @pre This function requires opened DBus connection by service-adaptor-client-storage.c
+ */
+int _dbus_download_file(const char *service_name,
+                                               const char *server_path,
+                                               const char *download_path,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_download_thumbnail(const char *service_name,
+                                               const char *server_path,
+                                               const char *download_path,
+                                               int thumbnail_size,
+                                               service_adaptor_error_s *error);
+
+int _dbus_download_file_async(const char *service_name,
+                                               const char *server_path,
+                                               const char *download_path,
+                                               service_storage_file_h *file_handle,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_upload_file(const char *service_name,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               service_storage_file_h *file_info,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_upload_file_async(const char *service_name,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               service_storage_file_h *file_handle,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_get_root_folder_path(const char *service_name,
+                                               char **root_folder_path,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_make_directory(const char *service_name,
+                                               const char *folder_path,
+                                               service_storage_file_h *file_info,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_remove_file(const char *service_name,
+                                               const char *file_path,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_remove_directory(const char *service_name,
+                                               const char *folder_path,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_move_file(const char *service_name,
+                                               const char *src_file_path,
+                                               const char *dst_file_path,
+                                               service_storage_file_h *file_info,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_move_directory(const char *service_name,
+                                               const char *src_folder_path,
+                                               const char *dst_folder_path,
+                                               service_storage_file_h *file_info,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_get_file_list(const char *service_name,
+                                               const char *parent_path,
+                                               service_storage_file_h **file_info_list,
+                                               unsigned int *file_info_list_len,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_open_upload_file(const char *_service_name,
+                                               const char *_file_path,
+                                               const char *_upload_path,
+                                               long long int *_task_id,
+                                               service_adaptor_error_s *error);
+
+int _dbus_open_download_file(const char *_service_name,
+                                               const char *_storage_path,
+                                               const char *_download_path,
+                                               long long int *_task_id,
+                                               service_adaptor_error_s *error);
+
+int _dbus_open_download_thumbnail(const char *_service_name,
+                                               const char *_storage_path,
+                                               const char *_download_path,
+                                               int _thumbnail_size,
+                                               long long int *_task_id,
+                                               service_adaptor_error_s *error);
+
+int _dbus_close_file_task(const char *_service_name,
+                                               long long int _task_id,
+                                               service_adaptor_error_s *error);
+
+int _dbus_start_upload_file(const char *_service_name,
+                                               long long int _task_id,
+                                               const char *_storage_path,
+                                               bool _need_progress,
+                                               bool _need_state,
+                                               service_adaptor_error_s *error);
+
+int _dbus_start_download_file(const char *_service_name,
+                                               long long int _task_id,
+                                               const char *_storage_path,
+                                               bool _need_progress,
+                                               bool _need_state,
+                                               service_adaptor_error_s *error);
+
+int _dbus_start_download_thumbnail(const char *_service_name,
+                                               long long int _task_id,
+                                               const char *_storage_path,
+                                               int thumbnail_size,
+                                               bool _need_progress,
+                                               bool _need_state,
+                                               service_adaptor_error_s *error);
+
+int _dbus_cancel_upload_file(const char *_service_name,
+                                               long long int _task_id,
+                                               service_adaptor_error_s *error);
+
+int _dbus_cancel_download_file(const char *_service_name,
+                                               long long int _task_id,
+                                               service_adaptor_error_s *error);
+
+int _dbus_cancel_download_thumbnail(const char *_service_name,
+                                               long long int _task_id,
+                                               service_adaptor_error_s *error);
+
+
+
+
+///////////////////// private feature
+
+
+int _private_dbus_download_file_async(const char *service_name,
+                                               const char *server_path,
+                                               const char *download_path,
+                                               service_adaptor_file_h *file_handle,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _private_dbus_upload_file_async(const char *service_name,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               service_adaptor_file_h *file_handle,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+
+
+int _dbus_download_file_publish(const char *service_name,
+                                               const char *server_path,
+                                               const char *download_path,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_download_file_publish_async(const char *service_name,
+                                               const char *server_path,
+                                               const char *download_path,
+                                               service_adaptor_file_h *file_handle,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_upload_file_publish(const char *service_name,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               char **publish_url,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_upload_file_publish_async(const char *service_name,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               service_adaptor_file_h *file_handle,
+                                               void *user_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_get_file_status(const char *service_name,
+                                               service_adaptor_file_h file_handle,
+                                               service_adaptor_file_status_s **status,
+                                               void **server_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_cancel_file_transfer(const char *service_name,
+                                               service_adaptor_file_h file_handle,
+                                               void **server_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_pause_file_transfer(const char *service_name,
+                                               service_adaptor_file_h file_handle,
+                                               void **server_data,
+                                               service_adaptor_error_s *error);
+
+int _dbus_resume_file_transfer(const char *service_name,
+                                               service_adaptor_file_h file_handle,
+                                               void **server_data,
+                                               service_adaptor_error_s *error);
+
+
+
+///////////////////// private feature
+
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_STORAGE_H__ */
diff --git a/include/private/service-adaptor-client-auth.h b/include/private/service-adaptor-client-auth.h
new file mode 100644 (file)
index 0000000..94af9b8
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: service-adaptor-client-auth.h
+ * Desc: Service Adaptor APIs
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ *     @file           service-adaptor-client-auth.h
+ *     @brief          Defines interface of Service Adaptor's Auth
+ *     @version        0.1
+ */
+
+#ifndef __PRIVATE_SERVICE_ADAPTOR_CLIENT_AUTH_H__
+#define __PRIVATE_SERVICE_ADAPTOR_CLIENT_AUTH_H__
+
+#include "service-adaptor-client.h"
+#include "service_adaptor_client_type.h"
+
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+* @brief Gets Auth Plugin List
+*
+* @param[in]   handle          the handle which is returned in service_adaptor_connect
+* @param[out]  plugins         list of auth plugins including plugin name and available
+* @param[out]  plugins_len     length of plugins
+* @param[out]  error_code      specifies error code
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_auth_plugin(service_adaptor_h handle,
+                                               service_adaptor_plugin_h **plugins,
+                                               unsigned int *plugins_len,
+                                               service_adaptor_error_s **error_code);
+
+/**
+* @brief Sets Plugin
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   plugin_handle   The handle which is returned in service_adaptor_get_auth_plugin
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_auth_plugin(service_adaptor_h handle,
+                                               service_adaptor_plugin_h plugin_handle);
+
+/**
+* @brief Requests Channel Auth
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   service_name    specifies service name like "com.serviceadaptor.message"
+* @param[in]   app_id          specifies app id
+* @param[in]   app_secret      specifies app secret
+* @param[in]    service_id      specifies service id (0: contact, 1: free message)
+* @param[in]   imsi            specifies imsi
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED Need authorization
+* @retval #SERVICE_ADAPTOR_ERROR_NETWORK Failed by network
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_adaptor_set_auth(service_adaptor_h handle,
+                                               const char *service_name,
+                                               const char *app_id,
+                                               const char *app_secret,
+                                               unsigned int service_id,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+#endif /* __PRIVATE_SERVICE_ADAPTOR_CLIENT_AUTH_H__ */
diff --git a/include/private/service-adaptor-client-contact.h b/include/private/service-adaptor-client-contact.h
new file mode 100644 (file)
index 0000000..7518465
--- /dev/null
@@ -0,0 +1,422 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: service-adaptor-client-contact.h
+ * Desc: Service Adaptor APIs
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ *     @file           service-adaptor-client-contact.h
+ *     @brief          Defines interface of Service Adaptor's Contact
+ *     @version        0.1
+ */
+
+#ifndef __SERVICE_ADAPTOR_CLIENT_CONTACT_H__
+#define __SERVICE_ADAPTOR_CLIENT_CONTACT_H__
+
+#include "service-adaptor-client.h"
+#include "service_adaptor_client_type.h"
+#include "service-adaptor-client-storage.h"
+
+typedef struct _service_adaptor_profile_image_s *service_adaptor_profile_image_h;
+
+/**
+* @brief Describes contact infromation for request
+*/
+typedef struct _service_adaptor_contact_info_req_s
+{
+       char *tp;               /**< specifies status as none*/
+       char *id;               /**< specifies status as none*/
+       char *pn;               /**< specifies status as none*/
+       char *nm;               /**< specifies status as none*/
+       char *cc;               /**< specifies status as none*/
+} service_adaptor_contact_info_req_s;
+
+/**
+* @brief Describes request infromation about contact
+*/
+typedef struct _service_adaptor_contact_req_s
+{
+       long long int tt;                               /**< specifies status as none*/
+       service_adaptor_contact_info_req_s **cts;       /**< specifies status as none*/
+       unsigned int cts_len;                           /**< specifies status as none*/
+} service_adaptor_contact_req_s;
+
+/**
+* @brief Describes contact infromation for response
+*/
+typedef struct _service_adaptor_contact_info_res_s
+{
+       char *duid;             /**< specifies status as none*/
+       char *id;               /**< specifies status as none*/
+       char *msisdn;           /**< specifies status as none*/
+       char *ty;               /**< specifies status as none*/
+       char *cc;               /**< specifies status as none*/
+       char *pn;               /**< specifies status as none*/
+       char *nm;               /**< specifies status as none*/
+       char **evnt;            /**< specifies status as none*/
+       unsigned int evnt_len;  /**< specifies status as none*/
+//     char *img;              /**< specifies status as none*/
+       service_adaptor_profile_image_h *images;
+       unsigned int images_len;
+       char **adrs;            /**< specifies status as none*/
+       unsigned int adrs_len;  /**< specifies status as none*/
+       char **mail;            /**< specifies status as none*/
+       unsigned int mail_len;  /**< specifies status as none*/
+       char *org;              /**< specifies status as none*/
+       char *prsc;             /**< specifies status as none*/
+       char *status;           /**< specifies status as none*/
+       unsigned int sids;      /**< specifies status as none*/
+       int profile_type;
+       char *profile_url;
+} service_adaptor_contact_info_res_s;
+
+/**
+* @brief Describes response infromation about contact
+*/
+typedef struct _service_adaptor_contact_res_s
+{
+       long long int tt;                               /**< specifies status as none*/
+       service_adaptor_contact_info_res_s **cts;       /**< specifies status as none*/
+       unsigned int cts_len;                           /**< specifies status as none*/
+} service_adaptor_contact_res_s;
+
+/**
+* @brief Describes request infromation about profile
+*/
+typedef struct _service_adaptor_profile_req_s
+{
+       char *cc;               /**< specifies status as none*/
+       char *pn;               /**< specifies status as none*/
+       char *nm;               /**< specifies status as none*/
+       char **evnt;            /**< specifies status as none*/
+       unsigned int evnt_len;  /**< specifies status as none*/
+       char *img;              /**< specifies status as none*/
+       char **adrs;            /**< specifies status as none*/
+       unsigned int adrs_len;  /**< specifies status as none*/
+       char **mail;            /**< specifies status as none*/
+       unsigned int mail_len;  /**< specifies status as none*/
+       char *org;              /**< specifies status as none*/
+       char *prsc;             /**< specifies status as none*/
+       char *status;           /**< status message*/
+} service_adaptor_profile_req_s;
+
+/**
+* @brief Describes response infromation about profile
+*/
+typedef struct _service_adaptor_profile_res_s
+{
+       char *nm;               /**< specifies status as none*/
+       char *img;              /**< specifies status as none*/
+       char *prsc;             /**< specifies status as none*/
+       char *status;           /**< specifies status as none*/
+} service_adaptor_profile_res_s;
+
+/**
+* @brief Describes privacy infromation for request
+*/
+typedef struct _service_adaptor_privacy_info_req_s
+{
+       char *cc;               /**< specifies status as none*/
+       char *pn;               /**< specifies status as none*/
+} service_adaptor_privacy_info_req_s;
+
+/**
+* @brief Describes request infromation about privacy
+*/
+typedef struct _service_adaptor_privacy_req_s
+{
+       unsigned int lvl;                               /**< specifies status as none*/
+       service_adaptor_privacy_info_req_s **cts;       /**< specifies status as none*/
+       unsigned int cts_len;                           /**< specifies status as none*/
+} service_adaptor_privacy_req_s;
+
+/**
+* @brief Describes response infromation about privacy
+*/
+typedef struct _service_adaptor_privacy_res_s
+{
+       unsigned int lvl;       /**< specifies status as none*/
+       unsigned int prscon;    /**< specifies status as none*/
+} service_adaptor_privacy_res_s;
+
+/**
+* @brief Describes presence infromation for request
+*/
+typedef struct _service_adaptor_presence_req_s
+{
+       char *prsc;             /**< specifies status as none*/
+       char *status;           /**< specifies status as none*/
+       unsigned int prscon;    /**< specifies status as none*/
+} service_adaptor_presence_req_s;
+
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+* @brief Resets contact information in Contact Server and
+*        uploads native contact information of device to the server
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   contact_req     request information about contact
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @param[out]  contact_res     response information about contact
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_new_contact_list(service_adaptor_h handle,
+                                               service_adaptor_contact_req_s *contact_req,
+                                               void *user_data,
+                                               service_adaptor_contact_res_s **contact_res,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+
+/**
+* @brief Synchronizes native contact information of device with Contact Server
+*        according to [type] field of each contact
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   contact_req     request information about contact
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @param[out]  contact_res     response information about contact
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_contact_list(service_adaptor_h handle,
+                                               service_adaptor_contact_req_s *contact_req,
+                                               void *user_data,
+                                               service_adaptor_contact_res_s **contact_res,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+
+/**
+* @brief Gets profile and service registration information of each contact
+*        (only contacts agreed to share with me are returned)
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[out]  contact_res     response information about contact
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_contact_infos_latest(service_adaptor_h handle,
+                                               service_adaptor_contact_res_s **contact_res,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+
+/**
+* @brief Gets profiles and service registration information of contacts
+*        that have been updated since last update
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   contact_req     request information about contact
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @param[out]  contact_res     response information about contact
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_contact_infos_polling(service_adaptor_h handle,
+                                               service_adaptor_contact_req_s *contact_req,
+                                               void *user_data,
+                                               service_adaptor_contact_res_s **contact_res,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+
+/**
+* @brief Sets or updates device’s profile to server
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   profile_req     request information about profile
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_me_profile_with_push(service_adaptor_h handle,
+                                               service_adaptor_profile_req_s *profile_req,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Gets the profile information of a contact which is correspondent with
+*        country code (optional) and phone number (mandatory)
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   profile_req     request information about profile
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @param[out]  profile_res     response information about profile
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_profile(service_adaptor_h handle,
+                                               service_adaptor_profile_req_s *profile_req,
+                                               void *user_data,
+                                               service_adaptor_profile_res_s **profile_res,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+
+/**
+* @brief Uploads profile image meta to File Server and sets my profile image to Profile Server
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   file_paths      file information for request
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @param[out]  server_paths    file information for response
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_profile_image_meta_with_push(service_adaptor_h handle,
+                                               service_adaptor_profile_image_h *images,
+                                               unsigned int images_len,
+                                               void *user_data,
+                                               service_adaptor_profile_image_h **failed_images,
+                                               unsigned int *failed_images_len,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+
+/**
+* @brief Deletes profile image meta from Profile Server
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   server_paths    file information responsed by xxx_set_profile_image_meta_with_push()
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_delete_me_profile_image_meta_with_push(service_adaptor_h handle,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Sets the level of privacy, the scope of people to be opened
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   privacy_req     request information about privacy
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_me_profile_privacy(service_adaptor_h handle,
+                                               service_adaptor_privacy_req_s *privacy_req,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Gets my profile’s privacy level
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[out]  privacy_res     response information about privacy
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_me_profile_privacy(service_adaptor_h handle,
+                                               service_adaptor_privacy_res_s **privacy_res,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+
+/**
+* @brief Sets my presence information to Presence Server
+*
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   presence_req    request information about presence
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_me_presence_with_push(service_adaptor_h handle,
+                                               service_adaptor_presence_req_s *presence_req,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Sets my presence ON/OFF information to Presence Server
+*
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   presence_req    request information about presence
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_me_presence_on_off_with_push(service_adaptor_h handle,
+                                               service_adaptor_presence_req_s *presence_req,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Sets my profile type to Presence Server
+*
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   profile_type    the profile types, this value is following a server spec
+* @param[out]  profile_url     the profile web url, this value is optional output value
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+* @remarks      @a profile_url must be released using free()
+*/
+int service_adaptor_set_me_profile_type(service_adaptor_h handle,
+                                               int profile_type,
+                                               char **profile_url,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+typedef enum
+{
+       SERVICE_ADAPTOR_CONTACT_SET     = 1,
+       SERVICE_ADAPTOR_CONTACT_DELETE  = 2,
+} service_adaptor_contact_request_type_e;
+
+int service_adaptor_profile_image_create (service_adaptor_profile_image_h *image);
+
+int service_adaptor_profile_image_set_element (service_adaptor_profile_image_h image,
+                                               service_adaptor_contact_request_type_e req_type,
+                                               int index,
+                                               const char *path);
+
+int service_adaptor_profile_image_get_index (service_adaptor_profile_image_h image, int *index);
+
+int service_adaptor_profile_image_get_url (service_adaptor_profile_image_h image, char **url);
+
+int service_adaptor_profile_image_get_req_type (service_adaptor_profile_image_h image, int *req_type);
+
+void service_adaptor_profile_image_destroy (service_adaptor_profile_image_h image);
+
+
+
+#endif /* __SERVICE_ADAPTOR_CLIENT_CONTACT_H__ */
diff --git a/include/private/service-adaptor-client-message.h b/include/private/service-adaptor-client-message.h
new file mode 100644 (file)
index 0000000..58d8f8e
--- /dev/null
@@ -0,0 +1,897 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: service-adaptor-client-message.h
+ * Desc: Service Adaptor APIs
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ *     @file           service-adaptor-client-message.h
+ *     @brief          Defines interface of Service Adaptor's Messaging
+ *     @version        0.1
+ */
+
+#ifndef __SERVICE_ADAPTOR_CLIENT_MESSAGE_H__
+#define __SERVICE_ADAPTOR_CLIENT_MESSAGE_H__
+
+#include <stdbool.h>
+#include "service-adaptor-client.h"
+#include "service_adaptor_client_type.h"
+
+typedef enum _service_adaptor_connection_policy_e
+{
+       SERVICE_ADAPTOR_CONNECTION_POLICY_AUTO          = 0,
+       SERVICE_ADAPTOR_CONNECTION_POLICY_CONNECT       = 1,
+       SERVICE_ADAPTOR_CONNECTION_POLICY_DISCONNECT    = 2,
+} service_adaptor_connection_policy_e;
+/**
+* @brief Describes infromation about violation users of wrong receivers
+*/
+typedef struct _service_adaptor_did_violation_users_s
+{
+       long long int usera;
+       long long int userb;
+} service_adaptor_did_violation_users_s;
+
+/**
+* @brief Describes infromation about wrong receivers
+*/
+typedef struct _service_adaptor_wrong_receiver_s
+{
+       long long int *invalid_receivers;               /**< specifies status as none*/
+       unsigned int invalid_receivers_len;             /**< specifies status as none*/
+       long long int *interrupted_receivers;           /**< specifies status as none*/
+       unsigned int interrupted_receivers_len;         /**< specifies status as none*/
+       long long int *disabled_receivers;              /**< specifies status as none*/
+       unsigned int disabled_receivers_len;            /**< specifies status as none*/
+       long long int *existing_chatmembers;            /**< specifies status as none*/
+       unsigned int existing_chatmembers_len;          /**< specifies status as none*/
+       service_adaptor_did_violation_users_s **did_violation_users;    /**< specifies status as none*/
+       unsigned int did_violation_users_len;           /**< specifies status as none*/
+       long long int *invitation_denieds;
+       unsigned int invitation_denieds_len;
+
+} service_adaptor_wrong_receiver_s;
+
+/**
+* @brief Describes infromation about chat message
+*/
+typedef struct _service_adaptor_chat_msg_s
+{
+       long long int msg_id;           /**< specifies status as none*/
+       int msg_type;                   /**< specifies status as none*/
+       char *chatmsg;                  /**< specifies status as none*/
+       int message_ttl;                /**< specifies status as none*/
+} service_adaptor_chat_msg_s;
+
+/**
+* @brief Describes infromation about processed message
+*/
+typedef struct _service_adaptor_processed_msg_s
+{
+       long long int msg_id;           /**< specifies status as none*/
+       long long int sent_time;        /**< specifies status as none*/
+} service_adaptor_processed_msg_s;
+
+/**
+* @brief Describes infromation about delivery ack
+*/
+typedef struct _service_adaptor_delivery_ack_s
+{
+       long long int user_id;
+       long long int msg_id;
+       long long int timestamp;
+} service_adaptor_delivery_ack_s;
+
+/**
+* @brief Describes infromation about read_ack
+*/
+typedef struct _service_adaptor_read_ack_s
+{
+       long long int user_id;          /**< specifies status as none*/
+       long long int msg_id;           /**< specifies status as none*/
+       long long int timestamp;        /**< specifies status as none*/
+} service_adaptor_read_ack_s;
+
+/**
+* @brief Describes infromation about ordered chat member
+*/
+typedef struct _service_adaptor_ordered_chat_member_s
+{
+       long long int user_id;          /**< specifies status as none*/
+       bool available;                 /**< specifies status as none*/
+       char *name;                     /**< specifies status as none*/
+} service_adaptor_ordered_chat_member_s;
+
+/**
+* @brief Describes infromation about inbox message
+*/
+typedef struct _service_adaptor_inbox_message_s
+{
+       long long int msg_id;           /**< specifies status as none*/
+       int msg_type;                   /**< specifies status as none*/
+       long long int sender;           /**< specifies status as none*/
+       long long int receiver;         /**< specifies status as none*/
+       long long int sent_time;        /**< specifies status as none*/
+       char *chat_msg;                 /**< specifies status as none*/
+       long long int chatroom_id;      /**< specifies status as none*/
+       int chat_type;                  /**< specifies status as none*/
+       int message_ttl;                /**< specifies status as none*/
+} service_adaptor_inbox_message_s;
+
+/**
+* @brief Describes infromation about end chat
+*/
+typedef struct _service_adaptor_end_chat_s
+{
+       long long int chatroom_id;      /**< specifies status as none*/
+       bool deny_invitation;
+} service_adaptor_end_chat_s;
+
+/**
+* @brief Describes infromation about phone number
+*/
+typedef struct _service_adaptor_phone_number_s
+{
+       char *phonenumber;              /**< specifies status as none*/
+       char *ccc;                      /**< specifies status as none*/
+} service_adaptor_phone_number_s;
+
+/**
+* @brief Describes infromation about chat id
+*/
+typedef struct _service_adaptor_chat_id_s
+{
+       long long int chatid;           /**< specifies status as none*/
+       char *msisdn;                   /**< specifies status as none*/
+} service_adaptor_chat_id_s;
+
+#ifdef NOT_IN_USE
+
+/**
+* @brief Callback for service_adaptor_request_channel_auth API
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   request_id      specifies request id
+* @param[in]   error_code      specifies error code
+* @param[in]   server_data     specifies server_data passed in API
+* @return      void
+* @pre service_adaptor_request_channel_auth will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_channel_auth_cb)(service_adaptor_h handle,
+                                               long long int request_id,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_client_echo API
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   request_id      specifies request id
+* @param[in]   error_code      specifies error code
+* @param[in]   server_data     specifies server_data passed in API
+* @return      void
+* @pre service_adaptor_request_client_echo will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_client_echo_cb)(service_adaptor_h handle,
+                                               long long int request_id,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data);
+
+#endif /* NOT_IN_USE */
+
+typedef void (*service_adaptor_reply_channel_disconnected_cb)(service_adaptor_h handle,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_create_chatroom API
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   request_id      specifies request id
+* @param[in]   chatroom_id     specifies created chatroom Id
+* @param[in]   wrong_receiver  specifies invalid_receivers and disabled_receivers
+* @param[in]   error_code      specifies error code
+* @param[in]   server_data     specifies server_data passed in API
+* @return      void
+* @pre service_adaptor_request_create_chatroom will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_create_chatroom_cb)(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               int default_message_ttl,
+                                               service_adaptor_wrong_receiver_s *wrong_receiver,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data);
+
+typedef void (*service_adaptor_reply_change_chatroom_meta_cb)(service_adaptor_h handle,
+                                                        long long int request_id,
+                                                        long long int chatroom_id,
+                                                       service_adaptor_error_s *error_code,
+                                                        void *server_data);
+
+
+/**
+* @brief Callback for service_adaptor_request_chat API
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   request_id      specifies request id
+* @param[in]   chatroom_id     specifies created chatroom Id
+* @param[in]   processed_msgs  specifies processed messages
+* @param[in]   processed_msgs_len      specifies length of processed_msgs
+* @param[in]   error_code      specifies error code
+* @param[in]   server_data     specifies server_data passed in API
+* @return      void
+* @pre service_adaptor_request_chat will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_chat_cb)(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               service_adaptor_processed_msg_s **processed_msgs,
+                                               unsigned int processed_msgs_len,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_allow_chat API
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   request_id      specifies request id
+* @param[in]   chatroom_id     specifies created chatroom Id
+* @param[in]   read_acks       specifies read_acks
+* @param[in]   read_acks_len   specifies length of read_acks
+* @param[in]   ordered_chat_members            specifies ordered chat members
+* @param[in]   ordered_chat_members_len        specifies length of ordered_chat_members
+* @param[in]   error_code      specifies error code
+* @param[in]   server_data     specifies server_data passed in API
+* @return      void
+* @pre service_adaptor_request_allow_chat will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_allow_chat_cb)(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               service_adaptor_delivery_ack_s **delivery_acks,
+                                               unsigned int delivery_acks_len,
+                                               unsigned long long last_delivery_ack_timestamp,
+                                               service_adaptor_read_ack_s **read_acks,
+                                               unsigned int read_acks_len,
+                                               unsigned long long last_read_ack_timestamp,
+                                               service_adaptor_ordered_chat_member_s **ordered_chat_members,
+                                               unsigned int ordered_chat_members_len,
+                                               const char *chatroom_title,
+                                               int default_message_ttl,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_all_unread_message API
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   request_id      specifies request id
+* @param[in]   error_code      specifies error code
+* @param[in]   server_data     specifies server_data passed in API
+* @return      void
+* @pre service_adaptor_request_all_unread_message will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_all_unread_message_cb)(service_adaptor_h handle,
+                                               long long int request_id,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data);
+
+/**
+* @brief Callback for service_adaptor_register_forward_online_message_listener API
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   request_id      specifies request id
+* @param[in]   chatroom_id     specifies created chatroom Id
+* @param[in]   chat_type       specifies type of chat
+* @param[in]   inbox_msg       specifies inbox message
+* @param[in]   error_code      specifies error code
+* @param[in]   server_data     specifies server_data passed in API
+* @return      void
+* @pre service_adaptor_register_forward_online_message_listener will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_request_forward_online_message_cb)(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               int chat_type,
+                                               service_adaptor_inbox_message_s *inbox_msg,
+                                               bool skip_reply,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data);
+
+/**
+* @brief Callback for service_adaptor_register_forward_online_message_listener API
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   request_id      specifies request id
+* @param[in]   inbox_msgs      specifies inbox message
+* @param[in]   inbox_msgs_len  specifies length of inbox message
+* @param[in]   next_pagination_key     specifies pagination function's next page value
+* @param[in]   error_code      specifies error code
+* @param[in]   server_data     specifies server_data passed in API
+* @return      void
+* @pre service_adaptor_register_forward_online_message_listener will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_request_forward_unread_message_cb)(service_adaptor_h handle,
+                                               long long int request_id,
+                                               service_adaptor_inbox_message_s **inbox_msgs,
+                                               unsigned int inbox_msgs_len,
+                                               const char *next_pagination_key,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_read_message API
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   request_id      specifies request id
+* @param[in]   chatroom_id     specifies created chatroom Id
+* @param[in]   error_code      specifies error code
+* @param[in]   server_data     specifies server_data passed in API
+* @return      void
+* @pre service_adaptor_request_read_message will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_read_message_cb)(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_invite_chat API
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   request_id      specifies request id
+* @param[in]   chatroom_id     specifies created chatroom Id
+* @param[in]   sent_time       specifies "InviteRequest" time received from server
+* @param[in]   wrong_receiver  specifies invalid_receivers and disabled_receivers
+* @param[in]   error_code      specifies error code
+* @param[in]   server_data     specifies server_data passed in API
+* @return      void
+* @pre service_adaptor_request_invite_chat will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_invite_chat_cb)(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               long long int sent_time,
+                                               service_adaptor_wrong_receiver_s *wrong_receiver,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_end_chat API
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   request_id      specifies request id
+* @param[in]   error_code      specifies error code
+* @param[in]   server_data     specifies server_data passed in API
+* @return      void
+* @pre service_adaptor_request_end_chat will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_end_chat_cb)(service_adaptor_h handle,
+                                               long long int request_id,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_unseal_message API
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   request_id      specifies request id
+* @param[in]   chatroom_id     specifies chatroom id
+* @param[in]   error_code      specifies error code
+* @param[in]   server_data     specifies server_data passed in API
+* @return      void
+* @pre service_adaptor_request_unseal_message will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_unseal_message_cb)(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data);
+
+
+/**
+* @brief Callback for service_adaptor_request_save_call_log API
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   request_id      specifies request id
+* @param[in]   error_code      specifies error code
+* @param[in]   server_data     specifies server_data passed in API
+* @return      void
+* @pre service_adaptor_request_save_call_log will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_save_call_log_cb)(service_adaptor_h handle,
+                                               long long int request_id,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_current_time API
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   request_id      specifies request id
+* @param[in]   current_time_millis     specifies current time (ms)
+* @param[in]   error_code      specifies error code
+* @param[in]   server_data     specifies server_data passed in API
+* @return      void
+* @pre service_adaptor_request_current_time will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_current_time_cb)(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int current_time_millis,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data);
+
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+
+#ifdef NOT_IN_USE
+/**
+* @brief Requests Channel Auth
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   request_id      specifies packet Id
+* @param[in]   uid             specifies DUID
+* @param[in]   duid            specifies DUID
+* @param[in]   appid           specifies appid
+* @param[in]   access_token    specifies access token
+* @param[in]   callback        the callback function to invoke
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_channel_auth(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int uid,
+                                               long long int duid,
+                                               const char *appid,
+                                               const char *access_token,
+                                               service_adaptor_reply_channel_auth_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Requests Client Echo
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   request_id      specifies packet Id
+* @param[in]   callback        the callback function to invoke
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_client_echo(service_adaptor_h handle,
+                                               long long int request_id,
+                                               service_adaptor_reply_client_echo_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+#endif /* NOT_IN_USE */
+
+/**
+* @brief Requests Creating Chatroom
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   request_id      specifies packet Id
+* @param[in]   chat_type       specifies type of chat (Single: 0, Group: 1)
+* @param[in]   receivers       specifies receivers
+* @param[in]   receivers_len   specifies length of receivers
+* @param[in]   callback        the callback function to invoke
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_create_chatroom(service_adaptor_h handle,
+                                               long long int request_id,
+                                               int chat_type,
+                                               long long int *receivers,
+                                               unsigned int receivers_len,
+                                               const char *chatroom_title,
+                                               service_adaptor_reply_create_chatroom_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+int service_adaptor_request_change_chatroom_meta(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               const char *chatroom_title,
+                                               int default_message_ttl,
+                                               service_adaptor_reply_change_chatroom_meta_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Requests Chat
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   request_id      specifies packet Id
+* @param[in]   chatroom_id     specifies created chatroom Id
+* @param[in]   chat_msgs       specifies information of chat message
+* @param[in]   chat_msgs_len   specifies length of chat_msgs
+* @param[in]   callback        the callback function to invoke
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_chat(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               service_adaptor_chat_msg_s **chat_msgs,
+                                               unsigned int chat_msgs_len,
+                                               service_adaptor_reply_chat_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Allows Chat
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   request_id      specifies packet Id
+* @param[in]   chatroom_id     specifies created chatroom Id
+* @param[in]   max_count       specifies the number of message
+* @param[in]   need_delivery_ack               specifies requesting delivery ask's data
+* @param[in]   last_delivery_ack_timestamp     specifies last delivery ask's timestamp
+* @param[in]   need_read_ack                   specifies requesting read_ack's data
+* @param[in]   last_read_ack_timestamp specifies last read_ack's timestamp
+* @param[in]   need_ordered_chat_member_list   specifies requesting ordered member list
+* @param[in]   callback        the callback function to invoke
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_allow_chat(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               bool is_auto_allow,
+                                               int max_count,
+                                               bool need_delivery_ack,
+                                               unsigned long long last_delivery_ack_timestamp,
+                                               bool need_read_ack,
+                                               unsigned long long last_read_ack_timestamp,
+                                               bool need_ordered_chat_member_list,
+                                               service_adaptor_reply_allow_chat_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Requests All Unread Message
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   request_id      specifies packet Id
+* @param[in]   max_count       specifies the number of message
+* @param[in]   callback        the callback function to invoke
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_all_unread_message(service_adaptor_h handle,
+                                               long long int request_id,
+                                               int max_count,
+                                               service_adaptor_reply_all_unread_message_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+
+int service_adaptor_register_channel_disconnected_listener(service_adaptor_h handle,
+                                               service_adaptor_reply_channel_disconnected_cb callback,
+                                               void *user_data);
+
+int service_adaptor_unregister_channel_disconnected_listener(service_adaptor_h handle,
+                                               void *user_data);
+
+
+/**
+* @brief Registers Forward Online Message Listener
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   callback        the callback function to invoke
+* @param[in]   user_data       specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_register_forward_online_message_listener(service_adaptor_h handle,
+                                               service_adaptor_request_forward_online_message_cb callback,
+                                               void *user_data);
+
+/**
+* @brief Unregisters Forward Online Message Listener
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   user_data       specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_unregister_forward_online_message_listener(service_adaptor_h handle,
+                                               void *user_data);
+
+/**
+* @brief Requests Forward Online Message
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   request_id      specifies packet Id
+* @param[in]   chatroom_id     specifies created chatroom Id
+* @param[in]   mark_as_read    specifies mark as read
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_reply_forward_online_message(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               bool mark_as_read,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Registers Forward Unread Message Listener
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   callback        the callback function to invoke
+* @param[in]   user_data       specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_register_forward_unread_message_listener(service_adaptor_h handle,
+                                               service_adaptor_request_forward_unread_message_cb callback,
+                                               void *user_data);
+
+/**
+* @brief Unregisters Forward Unread Message Listener
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   user_data       specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_unregister_forward_unread_message_listener(service_adaptor_h handle,
+                                               void *user_data);
+
+/**
+* @brief Requests Forward Unread Message
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   request_id      specifies packet Id
+* @param[in]   next_pagination_key     specifies pagination function's next page value
+* @param[in]   max_count       specifies the number of message
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_reply_forward_unread_message(service_adaptor_h handle,
+                                               long long int request_id,
+                                               const char *next_pagination_key,
+                                               int max_count,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Requests Read Message
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   request_id      specifies packet Id
+* @param[in]   chatroom_id     specifies created chatroom Id
+* @param[in]   inbox_msg       specifies inbox message
+* @param[in]   callback        the callback function to invoke
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_read_message(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               service_adaptor_inbox_message_s *inbox_msg,
+                                               service_adaptor_reply_read_message_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Requests Invite Chat
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   request_id      specifies packet Id
+* @param[in]   chatroom_id     specifies created chatroom Id
+* @param[in]   inviting_members        specifies invited user id
+* @param[in]   inviting_members_len    specifies length of invited user id
+* @param[in]   callback        the callback function to invoke
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_invite_chat(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               long long int *inviting_members,
+                                               unsigned int inviting_members_len,
+                                               service_adaptor_reply_invite_chat_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Requests End Chat
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   request_id      specifies packet Id
+* @param[in]   end_chats       specifies list of created chatroom id
+* @param[in]   end_chats_len   specifies length of end_chats
+* @param[in]   callback        the callback function to invoke
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_end_chat(service_adaptor_h handle,
+                                               long long int request_id,
+                                               service_adaptor_end_chat_s **end_chats,
+                                               unsigned int end_chats_len,
+                                               service_adaptor_reply_end_chat_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Requests Unseal Message
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   request_id      specifies packet Id
+* @param[in]   chatroom_id     specifies chatroom Id
+* @param[in]   sender_id       specifies message sender Id for 'Unseal Message'
+* @param[in]   message_id      specifies message Id for 'Unseal Message'
+* @param[in]   callback        the callback function to invoke
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_unseal_message(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               long long int sender_id,
+                                               long long int message_id,
+                                               const char *message_detail,
+                                               service_adaptor_reply_unseal_message_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Requests Save Call Log
+*
+* @param[in]   handle                  specifies Service Adaptor handle
+* @param[in]   request_id              specifies packet Id
+* @param[in]   chatroom_id             specifies chatroom Id
+* @param[in]   call_id                 specifies unique call Id
+* @param[in]   call_log_type           specifies call log type string
+* @param[in]   call_sender_id          specifies caller's unique Id
+* @param[in]   call_receiver_id        specifies callee's unique Id
+* @param[in]   conversaction_second    specifies calling time
+* @param[in]   callback                the callback function to invoke
+* @param[out]  error_code              specifies error code
+* @param[in]   user_data               specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_save_call_log(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               const char *call_id,
+                                               const char *call_log_type,
+                                               long long int call_sender_id,
+                                               long long int call_receiver_id,
+                                               int conversaction_second,
+                                               service_adaptor_reply_save_call_log_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Requests Current Time
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   request_id      specifies packet Id
+* @param[in]   callback        the callback function to invoke
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_current_time(service_adaptor_h handle,
+                                               long long int request_id,
+                                               service_adaptor_reply_current_time_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+
+int service_adaptor_request_get_connection_policy(service_adaptor_h handle,
+                                               service_adaptor_connection_policy_e *policy,
+                                               service_adaptor_error_s **error_code);
+
+int service_adaptor_request_set_connection_policy(service_adaptor_h handle,
+                                               service_adaptor_connection_policy_e *policy,
+                                               service_adaptor_error_s **error_code);
+/**
+* @brief Requests chat id based on phone number
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   phone_numbers           list of phone number
+* @param[in]   phone_numbers_len       length of phone_numbers
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @param[out]  chat_ids        list of chat id
+* @param[out]  chat_ids_len    length of chat_ids
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_chat_id_list(service_adaptor_h handle,
+                                               service_adaptor_phone_number_s **phone_numbers,
+                                               unsigned int phone_numbers_len,
+                                               void *user_data,
+                                               service_adaptor_chat_id_s ***chat_ids,
+                                               unsigned int *chat_ids_len,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+
+/**
+* @brief Requests MSISDN based on User ID
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   chat_ids        list of chat id
+* @param[in]   chat_ids_len    length of chat_ids
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @param[out]  msisdns         list of msisdn
+* @param[out]  msisdns_len     length of msisdns
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_msisdn_list(service_adaptor_h handle,
+                                               long long int *chat_ids,
+                                               unsigned int chat_ids_len,
+                                               void *user_data,
+                                               service_adaptor_chat_id_s ***msisdns,
+                                               unsigned int *msisdns_len,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+
+#endif /* __SERVICE_ADAPTOR_CLIENT_MESSAGE_H__ */
diff --git a/include/private/service-adaptor-client-push.h b/include/private/service-adaptor-client-push.h
new file mode 100644 (file)
index 0000000..1e63d72
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: service-adaptor-client-push.h
+ * Desc: Service Adaptor APIs
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ *     @file           service-adaptor-client-push.h
+ *     @brief          Defines interface of Service Adaptor's Push
+ *     @version        0.1
+ */
+
+#ifndef __SERVICE_ADAPTOR_CLIENT_PUSH_H__
+#define __SERVICE_ADAPTOR_CLIENT_PUSH_H__
+
+#include "service-adaptor-client.h"
+#include "service_adaptor_client_type.h"
+
+/**
+* @brief Describes push information
+*/
+typedef struct _service_adaptor_push_notification_s
+{
+       char *data;                     /**< specifies status as none*/
+       char *message;                  /**< specifies status as none*/
+       long long int time;             /**< specifies status as none*/
+} service_adaptor_push_notification_s;
+
+/**
+* @brief Callback for service_adaptor_connect_push_service API
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   noti_info       specifies push_notification information
+* @param[in]   error_code      specifies error code
+* @param[in]   user_data       specifies user_data passed in service_adaptor_connect_push_service API
+* @return      void
+* @pre service_adaptor_connect_push_service will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_push_notification_cb)(service_adaptor_h handle,
+                                               service_adaptor_push_notification_s *noti_info,
+                                               service_adaptor_error_s *error_code,
+                                               void *user_data);
+
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+* @brief Registers a callback function to receive push notification from push service
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   callback        the callback function to invoke
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_connect_push_service(service_adaptor_h handle,
+                                               service_adaptor_push_notification_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Deregisters the callback function that had been registered to push service
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_disconnect_push_service(service_adaptor_h handle);
+
+
+int service_adaptor_register_push_service(service_adaptor_h handle,
+                                               const char *service_file_name);
+
+int service_adaptor_deregister_push_service(service_adaptor_h handle,
+                                               const char *service_file_name);
+
+#endif /* __SERVICE_ADAPTOR_CLIENT_PUSH_H__ */
diff --git a/include/private/service-adaptor-client-shop.h b/include/private/service-adaptor-client-shop.h
new file mode 100644 (file)
index 0000000..95b426d
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: service-adaptor-client-shop.h
+ * Desc: Service Adaptor APIs
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ *     @file           service-adaptor-client-shop.h
+ *     @brief          Defines interface of Service Adaptor's Shop
+ *     @version        0.1
+ */
+
+#ifndef __SERVICE_ADAPTOR_CLIENT_SHOP_H__
+#define __SERVICE_ADAPTOR_CLIENT_SHOP_H__
+
+#include "service-adaptor-client.h"
+#include "service_adaptor_client_type.h"
+
+/**
+* @brief Describes infromation about shop
+*/
+typedef struct _service_adaptor_shop_info_s
+{
+       int category_id;                /**< specifies category id of item*/
+       long item_id;                   /**< specifies item id*/
+       long sticker_id;                /**< specifies sticker id*/
+       char *lang_cd;                  /**< specifies display language type*/
+       char *cntry_cd;                 /**< specifies country code*/
+       int rwidth;                     /**< specifies device resolution width*/
+       int rheight;                    /**< specifies device resolution height*/
+       int start_idx;                  /**< default value : 0*/
+       int count;                      /**< default value : 5*/
+} service_adaptor_shop_info_s;
+
+/**
+* @brief Describes infromation about item
+*/
+typedef struct _service_adaptor_shop_item_s
+{
+       long item_id;                   /**< specifies category id of item*/
+       int category_id;                /**< specifies category id of item*/
+       long *sticker_ids;              /**< specifies category id of item*/
+       unsigned int sticker_ids_len;   /**< specifies category id of item*/
+       char *title;                    /**< specifies category id of item*/
+       char *character;                /**< specifies category id of item*/
+       int version;                    /**< specifies category id of item*/
+       char *download_url;             /**< specifies category id of item*/
+       char *panel_url;                /**< specifies category id of item*/
+       char *sticker_url;              /**< specifies category id of item*/
+       long file_size;                 /**< specifies category id of item*/
+       int count;                      /**< specifies category id of item*/
+       char *character_code;           /**< specifies category id of item*/
+       long long int startdate;        /**< specifies category id of item*/
+       long long int enddate;          /**< specifies category id of item*/
+       long long int expired_date;     /**< specifies category id of item*/
+       long long int valid_period;     /**< specifies category id of item*/
+} service_adaptor_shop_item_s;
+
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+* @brief Requests List of Item
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   info            specifies shop information
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @param[in]   items           specifies list of items
+* @param[in]   items_len       specifies length of items
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_item_list(service_adaptor_h handle,
+                                               service_adaptor_shop_info_s *info,
+                                               void *user_data,
+                                               service_adaptor_shop_item_s ***items,
+                                               unsigned int *items_len,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+
+/**
+* @brief Requests Item Information for Download
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   info            specifies shop information
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @param[in]   item            specifies item
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_download_item_package(service_adaptor_h handle,
+                                               service_adaptor_shop_info_s *info,
+                                               void *user_data,
+                                               service_adaptor_shop_item_s **item,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+
+/**
+* @brief Requests Download of Item
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   info            specifies shop information
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @param[in]   item            specifies item
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_download_sticker(service_adaptor_h handle,
+                                               service_adaptor_shop_info_s *info,
+                                               void *user_data,
+                                               service_adaptor_shop_item_s **item,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+
+/**
+* @brief Requests Item Panel URL
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   info            specifies shop information
+* @param[in]   user_data       specifies user_data (json) passed in API
+* @param[in]   item            specifies item
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_panel_url(service_adaptor_h handle,
+                                               service_adaptor_shop_info_s *info,
+                                               void *user_data,
+                                               service_adaptor_shop_item_s **item,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+
+#endif /* __SERVICE_ADAPTOR_CLIENT_SHOP_H__ */
diff --git a/include/private/service-adaptor-client-storage.h b/include/private/service-adaptor-client-storage.h
new file mode 100644 (file)
index 0000000..5432d81
--- /dev/null
@@ -0,0 +1,402 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: service-adaptor-client-storage.h
+ * Desc: Service Adaptor APIs
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ *     @file           service-adaptor-client-storage.h
+ *     @brief          Defines interface of Service Adaptor's Storage
+ *     @version        0.1
+ */
+
+#ifndef __PRIVATE_SERVICE_ADAPTOR_CLIENT_STORAGE_H__
+#define __PRIVATE_SERVICE_ADAPTOR_CLIENT_STORAGE_H__
+
+#include "service-adaptor-client.h"
+
+typedef enum _service_adaptor_file_status_code_e
+{
+       SERVICE_ADAPTOR_TRANSFER_STATUS_PROGRESS        = 1,
+       SERVICE_ADAPTOR_TRANSFER_STATUS_RESUME          = 1,
+       SERVICE_ADAPTOR_TRANSFER_STATUS_PAUSE           = 2,
+       SERVICE_ADAPTOR_TRANSFER_STATUS_CANCEL          = 3,    // canceled by request
+       SERVICE_ADAPTOR_TRANSFER_STATUS_STOPPED         = 4,    // canceled by system
+       SERVICE_ADAPTOR_TRANSFER_STATUS_FINISHED        = 5
+} service_adaptor_file_status_code_e;
+
+typedef enum _service_adaptor_thumbnail_size_e
+{
+       SERVICE_ADAPTOR_THUMBNAIL_XSMALL                = 96,
+       SERVICE_ADAPTOR_THUMBNAIL_SMALL                 = 200,
+       SERVICE_ADAPTOR_THUMBNAIL_MEDIUM                = 500,
+       SERVICE_ADAPTOR_THUMBNAIL_LARGE                 = 760
+} service_adaptor_thumbnail_size_e;
+
+/**
+* @brief Describes file description about download and upload
+*/
+typedef struct _service_adaptor_file_s
+{
+       int file_description;           /**< specifies status as none*/
+} service_adaptor_file_s;
+
+/**
+* @brief Describes file infromation about download and upload
+*/
+typedef struct _service_adaptor_file_path_s
+{
+       char **file_paths;              /**< specifies status as none*/
+       unsigned int file_paths_len;    /**< specifies status as none*/
+} service_adaptor_file_path_s;
+
+/**
+* @brief Describes file status about transfer
+*/
+typedef struct _service_adaptor_file_status_s
+{
+       long long int total_size;                       /**< specifies status as none*/
+       long long int transferred_size;                 /**< specifies status as none*/
+       service_adaptor_file_status_code_e status;      /**< specifies status as none*/
+} service_adaptor_file_status_s;
+
+/**
+* @brief The handle for File Description
+*/
+typedef service_adaptor_file_s *service_adaptor_file_h;
+
+/**
+* @brief Callback for file upload and download API
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   file_handle     specifies file description
+* @param[in]   transferred_size        specifies transferred size
+* @param[in]   total_size      specifies total size
+* @param[in]   error_code      specifies error code
+* @param[in]   user_data       specifies user_data passed in API
+* @return      void
+* @pre service_adaptor_request_channel_auth will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_file_progress_cb)(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               unsigned long long transferred_size,
+                                               unsigned long long total_size,
+                                               service_adaptor_error_s *error_code,
+                                               void *user_data);
+
+/**
+* @brief Callback for file transfer completion
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   file_handle     specifies file description
+* @param[in]   publish_url     specifies publish url for another user
+* @param[in]   error_code      specifies error code
+* @param[in]   user_data       specifies user_data passed in API
+* @return      void
+* @pre service_adaptor_request_channel_auth will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_file_transfer_completion_cb)(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               char *publish_url,
+                                               service_adaptor_error_s *error_code,
+                                               void *user_data);
+
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+* @brief Registers File Progress Listener
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   callback        the callback function to invoke
+* @param[in]   user_data       specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_register_file_progress_listener(service_adaptor_h handle,
+                                               service_adaptor_file_progress_cb callback,
+                                               void *user_data);
+
+/**
+* @brief Unregisters File Progress Listener
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   user_data       specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_unregister_file_progress_listener(service_adaptor_h handle,
+                                               void *user_data);
+
+/**
+* @brief Registers File Transfer Completion Listener
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   callback        the callback function to invoke
+* @param[in]   user_data       specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_register_file_transfer_completion_listener(service_adaptor_h handle,
+                                               service_adaptor_file_transfer_completion_cb callback,
+                                               void *user_data);
+
+/**
+* @brief Unregisters File Transfer Completion Listener
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   user_data       specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_unregister_file_transfer_completion_listener(service_adaptor_h handle,
+                                               void *user_data);
+
+/**
+* @brief Downloads a server file and writes it to local file
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   server_path     specifies server url of file to download
+* @param[in]   download_path   specifies local path where we expect downloaded file to be written
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_download_file(service_adaptor_h handle,
+                                               const char *server_path,
+                                               const char *download_path,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Downloads a server file and writes it to local file (Async)
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   server_path     specifies server url of file to download
+* @param[in]   download_path   specifies local path where we expect downloaded file to be written
+* @param[out]  file_handle     specifies file description
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_download_file_async(service_adaptor_h handle,
+                                               const char *server_path,
+                                               const char *download_path,
+                                               service_adaptor_file_h *file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Uploads a local file to server path
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   upload_path     specifies local path for upload
+* @param[in]   server_path     specifies server url of file to download
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_upload_file(service_adaptor_h handle,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Uploads a local file to server path (Async)
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   upload_path     specifies local path for upload
+* @param[in]   server_path     specifies server url of file to download
+* @param[out]  file_handle     specifies file description
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_upload_file_async(service_adaptor_h handle,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               service_adaptor_file_h *file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Downloads a server file and writes it to local file
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   publish_url     specifies publish url of file to download
+* @param[in]   download_path   specifies local path where we expect downloaded file to be written
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_download_file_publish(service_adaptor_h handle,
+                                               const char *publish_url,
+                                               const char *download_path,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Downloads a server file and writes it to local file (Async)
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   publish_url     specifies publish url of file to download
+* @param[in]   download_path   specifies local path where we expect downloaded file to be written
+* @param[out]  file_handle     specifies file description
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_download_file_publish_async(service_adaptor_h handle,
+                                               const char *publish_url,
+                                               const char *download_path,
+                                               service_adaptor_file_h *file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Uploads a local file to server path
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   upload_path     specifies local path for upload
+* @param[in]   server_path     specifies server url of file to download
+* @param[out]  publish_url     specifies publish url
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_upload_file_publish(service_adaptor_h handle,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               char **publish_url,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Uploads a local file to server path (Async)
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   upload_path     specifies local path for upload
+* @param[in]   server_path     specifies server url of file to download
+* @param[out]  file_handle     specifies file description
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_upload_file_publish_async(service_adaptor_h handle,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               service_adaptor_file_h *file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Downloads a thumbnail file and writes it to local file
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   publish_url     specifies publish url of file to download
+* @param[in]   download_path   specifies local path where we expect downloaded file to be written
+* @param[in]   size            specifies size of thumbnail
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_download_thumbnail_publish(service_adaptor_h handle,
+                                               const char *publish_url,
+                                               const char *download_path,
+                                               service_adaptor_thumbnail_size_e size,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+
+/**
+* @brief Requests File Status
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   file_handle     specifies file description
+* @param[out]  status          specifies status of file transfer
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) received from Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_get_file_status(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               service_adaptor_file_status_s **status,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+
+/**
+* @brief Cancels File Transfer
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   file_handle     specifies file description
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) received from Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_cancel_file_transfer(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+
+/**
+* @brief Pause File Transfer
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   file_handle     specifies file description
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) received from Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_pause_file_transfer(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+
+/**
+* @brief Resume File Transfer
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   file_handle     specifies file description
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) received from Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_resume_file_transfer(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+
+#endif /* __PRIVATE_SERVICE_ADAPTOR_CLIENT_STORAGE_H__ */
diff --git a/include/private/service-adaptor-client.h b/include/private/service-adaptor-client.h
new file mode 100644 (file)
index 0000000..1ef0a9a
--- /dev/null
@@ -0,0 +1,244 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: service-adaptor-client.h
+ * Desc: Service Adaptor APIs
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ *     @file           service-adaptor-client.h
+ *     @brief          Defines interface of Service Adaptor
+ *     @version        0.1
+ */
+
+#ifndef __PRIVATE_SERVICE_ADAPTOR_CLIENT_H__
+#define __PRIVATE_SERVICE_ADAPTOR_CLIENT_H__
+
+#include <stdbool.h>
+#include <service_adaptor_client.h>
+#include "service_adaptor_client_type.h"
+
+/**
+ * @brief Enumerations of result code for Service Adaptor
+ */
+typedef enum _service_adaptor_result_e
+{
+       SERVICE_ADAPTOR_RESULT_SUCCEEDED                = SERVICE_ADAPTOR_ERROR_NONE,   /**< specifies status as none*/
+       SERVICE_ADAPTOR_RESULT_FAILED                   = -1,   /**< specifies status as none*/
+       SERVICE_ADAPTOR_RESULT_CANCELED                 = -2    /**< specifies status as none*/
+} __service_adaptor_result_e;  /*TODO deplicate*/
+
+typedef int service_adaptor_result_e; /* For version compatibility */
+
+/**
+ * @brief Enumerations of error code for Service Adaptor
+ */
+typedef enum _private_service_adaptor_error_e
+{
+       SERVICE_ADAPTOR_ERROR_LAUNCH                    = 1,    /**< 1 ~ 99: internal error*/
+       SERVICE_ADAPTOR_ERROR_INIT                      = 2,
+       SERVICE_ADAPTOR_ERROR_DEINIT                    = 3,
+       SERVICE_ADAPTOR_ERROR_CREATE                    = 4,
+       SERVICE_ADAPTOR_ERROR_DESTROY                   = 5,
+       SERVICE_ADAPTOR_ERROR_START                     = 6,
+       SERVICE_ADAPTOR_ERROR_STOP                      = 7,
+       SERVICE_ADAPTOR_ERROR_CONNECT                   = 8,
+       SERVICE_ADAPTOR_ERROR_DISCONNECT                = 9,
+       SERVICE_ADAPTOR_ERROR_NOT_FOUND                 = 10,
+       SERVICE_ADAPTOR_ERROR_CORRUPTED                 = 11,
+       SERVICE_ADAPTOR_ERROR_UNSUPPORTED               = 12,
+       SERVICE_ADAPTOR_ERROR_INVALID_HANDLE            = 13,
+       SERVICE_ADAPTOR_ERROR_INVALID_ARGUMENT          = 14,
+       SERVICE_ADAPTOR_ERROR_INVALID_ARGUMENT_TYPE     = 15,
+       SERVICE_ADAPTOR_ERROR_ADAPTOR_INTERNAL          = 17,
+       SERVICE_ADAPTOR_ERROR_PLUGIN_INTERNAL           = 18,
+       SERVICE_ADAPTOR_ERROR_SERVER_INTERNAL           = 19,
+       SERVICE_ADAPTOR_ERROR_DBUS                      = 20,
+       SERVICE_ADAPTOR_ERROR_CALLBACK_TIME_OUT         = 21,
+       SERVICE_ADAPTOR_ERROR_INTERNAL_MAX              = 99,
+
+       SERVICE_ADAPTOR_ERROR_NETWORK                   = TIZEN_ERROR_SERVICE_ADAPTOR | 0xf1,
+} private_service_adaptor_error_e;
+
+/**
+ * @brief Type of service in plugin (ext internal)
+ */
+typedef enum
+{
+       SERVICE_PLUGIN_SERVICE_CONTACT  = (0x01 << 2),          /**< Contact service type flag */
+       SERVICE_PLUGIN_SERVICE_MESSAGE  = (0x01 << 3),          /**< Message service type flag */
+       SERVICE_PLUGIN_SERVICE_SHOP     = (0x01 << 4),          /**< Shop service type flag */
+       SERVICE_PLUGIN_SERVICE_PUSH     = (0x01 << 5),          /**< Push service type flag */
+} internal_service_plugin_service_type_e;
+
+/**
+* @brief Describes infromation about plugin
+*/
+typedef struct _service_adaptor_plugin_s
+{
+       char *name;                             /**< specifies status as none*/
+       bool login;                             /**< specifies status as none*/
+} service_adaptor_plugin_s;
+
+/**
+* @brief The handle for Service Adaptor error
+*/
+typedef service_adaptor_plugin_s *service_adaptor_plugin_h;
+
+/**
+* @brief Callback for service_adaptor_connect API
+*
+* @param[in]   signal          specifies signal code
+* @param[in]   msg             specifies signal message
+* @return       void.
+* @pre service_adaptor_connect() will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_signal_cb)(service_adaptor_h handle,
+                                               service_adaptor_signal_code_e signal,
+                                               char *msg);
+
+/**
+* @brief Callback for getting async external operation result
+*
+* @param[in]    result          Result code for async operation (see #service_adaptor_error_e)
+* @param[in]   out_params      Created bundle, if the special API returns optional values, get result from this bundle (reference to plugin's SPEC)
+* @param[in]    user_data       Passed data from request function
+* @remarks      You can get the error detail from #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() API. Error codes and messages are described in Service Plugin.
+* @remarks      The @a result values #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @remarks      The @a result values #SERVICE_ADAPTOR_ERROR_NO_DATA There is no data
+* @remarks      The @a result values #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @remarks      The @a result values #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @remarks      The @a result values #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see         #service_adaptor_error_e
+* @see         service_adaptor_external_request_async()
+* @see          service_adaptor_get_last_result()
+* @see          service_adaptor_get_last_error_message()
+* @return       void
+* @pre  #service_adaptor_external_request_async() will invoke this callback.
+*/
+typedef void (*service_adaptor_external_response_cb)(int result,
+                                               bundle *out_params,
+                                               void *user_data);
+
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+* @brief Connects Service Adaptor
+*
+* @param[out]  handle          specifies Service Adaptor handle
+* @param[in]   callback        the callback function to invoke
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_connect(service_adaptor_h *handle,
+                                               service_adaptor_signal_cb callback);
+
+/**
+* @brief Disconnects Service Adaptor
+*
+* @param[in]   handle          the handle which is returned in service_adaptor_connect
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_disconnect(service_adaptor_h handle);
+
+/**
+* @brief Sets IMSI
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   imsi            specifies Mobile station identification number
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_imsi(service_adaptor_h handle,
+                                               const char *imsi);
+
+int service_adaptor_set_plugin(service_adaptor_h handle,
+                                               const char *plugin_uri);
+
+/**
+* @brief Free the list of auth plugin
+*
+* @param[in]   plugins         specifies the list of auth plugin
+* @param[in]   plugins_len     specifies length of auth plugins
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_free_plugins(service_adaptor_plugin_h *plugins,
+                                               unsigned int plugins_len);
+
+/**
+* @brief Requests external API to plugin directly (Sync)
+* @since_tizen 2.4
+* @param[in]   handle          The handle of service-adaptor
+* @param[in]   service_flag    The special API direction to specific plugin (refer to #service_plugin_service_type_e)
+* @param[in]   api_uri         The special API signature that is described plugin's SPEC
+* @param[in]   in_params       Created bundle, if the special API needs optional parameter, insert to bundle (refer to plugin's SPEC)
+* @param[in]   out_params      Created bundle, if the special API returns optional values, get result from this bundle (refer to plugin's SPEC)
+* @remarks      @a in_params must be created using bundle_create()
+* @remarks      @a out_params must be released memory using bundle_free()
+* @remarks      You can get the error detail from #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() API. Error codes and messages are described in Service Plugin.
+* @see          service_adaptor_get_last_result()
+* @see          service_adaptor_get_last_error_message() (refer to #service_plugin_service_type_e)
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_adaptor_external_request(service_adaptor_h handle,
+                                               int service_flag,
+                                               const char *api_uri,
+                                               bundle *in_params,
+                                               bundle **out_params);
+
+/**
+* @brief Requests external API to plugin directly (Async)
+* @since_tizen 2.4
+* @param[in]   handle          The handle of service-adaptor
+* @param[in]   service_flag    The special API direction to specific plugin
+* @param[in]   api_uri         The special API signature that is descrypted plugin's SPEC
+* @param[in]   in_params       Created bundle, if the special API needs optional parameter, insert to bundle (reference to plugin's SPEC)
+* @param[in]   callback        The callback for getting result this operation
+* @param[in]   user_data       The user data to be passed to the callback function
+* @remarks      You can get the error detail from #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() API. Error codes and messages are described in Service Plugin.
+* @see          service_adaptor_get_last_result()
+* @see          service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @post #service_adaptor_external_response_cb() will be invoked
+*/
+int service_adaptor_external_request_async(service_adaptor_h handle,
+                                               int service_flag,
+                                               const char *api_uri,
+                                               bundle *in_params,
+                                               service_adaptor_external_response_cb callback,
+                                               void *user_data);
+
+#endif /* __PRIVATE_SERVICE_ADAPTOR_CLIENT_H__ */
diff --git a/include/service_adaptor_client.h b/include/service_adaptor_client.h
new file mode 100644 (file)
index 0000000..1921f94
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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 __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_H__
+
+#include <tizen.h>
+#include <bundle.h>
+#include <service_adaptor_client_plugin.h>
+#include <service_adaptor_client_storage.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef TIZEN_ERROR_SERVICE_ADAPTOR
+#define TIZEN_ERROR_SERVICE_ADAPTOR     -0x02F30000
+#endif
+
+/**
+ * @file service_adaptor_client.h
+ */
+
+/**
+ * @addtogroup SERVICE_ADAPTOR_MODULE
+
+ * @{
+ */
+
+
+/**
+ * @brief Enumerations of result code for Service Adaptor
+ * @since_tizen 2.4
+ */
+typedef enum
+{
+       SERVICE_ADAPTOR_ERROR_NONE                      = TIZEN_ERROR_NONE,                     /**< Success */
+       SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED             = TIZEN_ERROR_NOT_SUPPORTED,            /**< Service plugin does not support API */
+       SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER         = TIZEN_ERROR_INVALID_PARAMETER,        /**< The parameter is invalid */
+       SERVICE_ADAPTOR_ERROR_TIMED_OUT                 = TIZEN_ERROR_TIMED_OUT,                /**< API time out */
+       SERVICE_ADAPTOR_ERROR_NO_DATA                   = TIZEN_ERROR_NO_DATA,                  /**< There is no data available */
+       SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED         = TIZEN_ERROR_PERMISSION_DENIED,        /**< Permission denied */
+       SERVICE_ADAPTOR_ERROR_UNKNOWN                   = TIZEN_ERROR_UNKNOWN,                  /**< Unknown error */
+       SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE              = TIZEN_ERROR_SERVICE_ADAPTOR | 0x01,   /**< IPC Connection unstabled */
+       SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED             = TIZEN_ERROR_SERVICE_ADAPTOR | 0x02,   /**< The error occured from Plugin, See detail from service_adaptor_get_last_result() and Plugin SPEC */
+       SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED            = TIZEN_ERROR_SERVICE_ADAPTOR | 0x03,   /**< Need Authorization */
+       SERVICE_ADAPTOR_ERROR_INVALID_STATE             = TIZEN_ERROR_SERVICE_ADAPTOR | 0x04,   /**< The handle state is invalid for processing API */
+}service_adaptor_error_e;
+
+/**
+* @brief The handle for connection and managing plugin handle of Service Adaptor
+* @details The handle can be created by service_adaptor_create()<br>
+*  When a handle is no longer needed, use service_adaptor_destroy()
+* @since_tizen 2.4
+*
+* @see #service_adaptor_create()
+* @see #service_adaptor_destroy()
+*/
+typedef struct _service_adaptor_s *service_adaptor_h;
+
+/**
+* @since_tizen 2.4
+* @brief Callback for service_adaptor_foreach_plugin API
+*
+* @param[in]   plugin_uri      The service plugin's unique uri, this value be set by plugin
+* @param[in]   service_mask    Masked value for <b>installed</b> service plugins, this value can be masked multiple enum (#service_plugin_service_type_e)
+* @param[in]   user_data       Passed data from #service_adaptor_foreach_plugin()
+* @remarks     @a service_mask check using 'bit and' operation with #service_plugin_service_type_e
+* @remarks     - for example,
+* @remarks     &nbsp;&nbsp;&nbsp;&nbsp;        if(@a service_mask & SERVICE_PLUGIN_SERVICE_STORAGE)
+* @remarks     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;        { @a USING_STORAGE_CODE }
+* @remarks Do not release memory of @a plugin_uri
+* @see         service_plugin_service_type_e
+* @return @c true to continue with the next iteration of the loop,
+*         otherwise @c false to break out of the loop
+* @pre service_adaptor_foreach_plugin() will invoke this callback.
+*/
+typedef bool (*service_adaptor_plugin_cb)(char *plugin_uri,
+                                               int service_mask,
+                                               void *user_data);
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+* @brief Create Service Adaptor
+* @since_tizen 2.4
+*
+* @param[out]  service_adaptor The Service Adaptor handle
+* @remarks     @a service_adaptor must be released memory using service_adaptor_destroy(), when a program no longer needs any function of Service Adaptor
+* @see         service_adaptor_destroy()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_adaptor_create(service_adaptor_h *service_adaptor);
+
+/**
+* @brief       Destroy Service Adaptor
+* @details     It must called after a program no longer needs any function of Service Adaptor
+* @since_tizen 2.4
+*
+* @param[in]   service_adaptor The handle of Service Adaptor
+* @see         service_adaptor_create()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre @a service_adaptor must be issued by service_adaptor_create()
+*/
+int service_adaptor_destroy(service_adaptor_h service_adaptor);
+
+/**
+* @brief Foreach the list of plugin
+* @details Iterate to all installed plugin
+* @since_tizen 2.4
+*
+* @param[in]   service_adaptor The handle of Service Adaptor
+* @param[in]   callback        The callback for foreach plugin
+* @param[in]   user_data       Passed data to callback
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no available plugins
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre @a service_adaptor must be issued by service_adaptor_create()
+*/
+int service_adaptor_foreach_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_plugin_cb callback,
+                                               void *user_data);
+
+/**
+* @brief Create service plugin handle
+* @details Create plugin handle using @a plugin_uri
+* @since_tizen 2.4
+*
+* @param[in]   service_adaptor The handle of Service Adaptor
+* @param[in]   plugin_uri      The specfic string for use plugin, this values are set by plugin
+* @param[out]  plugin          The handle for use Plugin APIs
+* @remarks     @a plugin must be released memory using service_plugin_destroy() when you no longer needs plugin's API
+* @see         service_plugin_destroy()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre @a service_adaptor must be issued by service_adaptor_create()
+*/
+int service_adaptor_create_plugin(service_adaptor_h service_adaptor,
+                                               const char *plugin_uri,
+                                               service_plugin_h *plugin);
+
+/**
+* @brief Gets service specfic last result
+* @details This function retrieves the last error code that be issued from plugin.<br>
+*  When if API function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, gets using this function.
+* @since_tizen 2.4
+*
+* @param[out]  err     The error number that is defined service plugin SPEC
+* @remarks     Thread safe functions
+* @remarks     The result number's detail specification is defined service plugin or provider.
+* @remarks     The detail error message can be got using service_adaptor_get_last_error_message()
+* @see         service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no result
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_adaptor_get_last_result(int *err);
+
+/**
+* @brief Gets service specfic last result error message
+* @details This function retrieves the last error code that be issued from plugin.<br>
+*  When if API function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, gets using this function.
+* @since_tizen 2.4
+*
+* @param[out]  message The error message that is defined service plugin SPEC
+* @remarks     @a message must be released using free()
+* @remarks     Thread safe functions
+* @remarks     The result string's detail specification is defined service plugin or provider.
+* @see         service_adaptor_get_last_result()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no error message
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_adaptor_get_last_error_message(char **message);
+
+/**
+* @brief Gets Plugin Property
+* @since_tizen 2.4
+*
+* @param[in]   plugin  The handle for use Plugin APIs
+* @param[in]   key     The key of plugin property
+* @param[out]  value   The value of plugin property that matched @a key
+* @remarks     Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
+* @remarks     @a value must be released using free()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no property
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see SERVICE_PLUGIN_PROPERTY_APP_KEY
+* @see SERVICE_PLUGIN_PROPERTY_APP_SECRET
+* @see SERVICE_PLUGIN_PROPERTY_USER_ID
+*/
+int service_plugin_get_property(service_plugin_h plugin,
+                                               const char *key,
+                                               char **value);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_H__ */
diff --git a/include/service_adaptor_client_log.h b/include/service_adaptor_client_log.h
new file mode 100644 (file)
index 0000000..294e484
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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 __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_LOG_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_LOG_H__
+
+/**
+ *  HOW TO USE IT:
+ *  First you need to set platform logging on the device:
+ *
+ *    # dlogctrl set platformlog 1
+ *
+ *  After reboot you are able to see logs from this application, when you launch dlogutil with a proper filter e.g.:
+ *
+ *    # dlogutil SERVICE_ADAPTOR:D
+ *
+ *  You may use different logging levels as: D (debug), I (info), W (warning), E (error) or F (fatal).
+ *  Higher level messages are included by default e.g. dlogutil CLOUDBOX:W prints warnings but also errors and fatal messages.
+ */
+
+#include <unistd.h>
+#include <linux/unistd.h>
+
+/* These defines must be located before #include <dlog.h> */
+#define TIZEN_ENGINEER_MODE
+// TODO: Investigate why this macro is defined somewhere else
+#ifndef TIZEN_DEBUG_ENABLE
+#define TIZEN_DEBUG_ENABLE
+#endif
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+/* Literal to filter logs from dlogutil */
+#define LOG_TAG "SERVICE_ADAPTOR_CLIENT"
+
+#include <dlog.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+       /**
+        *  Colors of font
+        */
+#define FONT_COLOR_RESET      "\033[0m"
+#define FONT_COLOR_BLACK      "\033[30m"             /* Black */
+#define FONT_COLOR_RED        "\033[31m"             /* Red */
+#define FONT_COLOR_GREEN      "\033[32m"             /* Green */
+#define FONT_COLOR_YELLOW     "\033[33m"             /* Yellow */
+#define FONT_COLOR_BLUE       "\033[34m"             /* Blue */
+#define FONT_COLOR_PURPLE     "\033[35m"             /* Purple */
+#define FONT_COLOR_CYAN       "\033[36m"             /* Cyan */
+#define FONT_COLOR_WHITE      "\033[37m"             /* White */
+#define FONT_COLOR_BOLDBLACK  "\033[1m\033[30m"      /* Bold Black */
+#define FONT_COLOR_BOLDRED    "\033[1m\033[31m"      /* Bold Red */
+#define FONT_COLOR_BOLDGREEN  "\033[1m\033[32m"      /* Bold Green */
+#define FONT_COLOR_BOLDYELLOW "\033[1m\033[33m"      /* Bold Yellow */
+#define FONT_COLOR_BOLDBLUE   "\033[1m\033[34m"      /* Bold Blue */
+#define FONT_COLOR_BOLDPURPLE "\033[1m\033[35m"      /* Bold Purple */
+#define FONT_COLOR_BOLDCYAN   "\033[1m\033[36m"      /* Bold Cyan */
+#define FONT_COLOR_BOLDWHITE  "\033[1m\033[37m"      /* Bold White */
+
+/**
+ *  Gets thread ID
+ */
+#define sac_gettid() ((int)syscall(__NR_gettid))
+
+/**
+ *  @brief Macro for returning value if expression is satisfied
+ *  @param[in]  expr Expression to be checked
+ *  @param[out] val  Value to be returned when expression is true
+ */
+#define sac_retv_if(expr, val) do { \
+            if(expr) { \
+                LOGE(FONT_COLOR_PURPLE"[%d]"FONT_COLOR_RESET, sac_gettid());    \
+                return (val); \
+            } \
+        } while (0)
+
+/**
+ * @brief Prints debug messages
+ * @param[in]  fmt  Format of data to be displayed
+ * @param[in]  args Arguments to be displayed
+ */
+#define sac_debug(fmt, arg...) do { \
+            LOGD(FONT_COLOR_GREEN"[%d]"fmt""FONT_COLOR_RESET, sac_gettid(), ##arg);     \
+        } while (0)
+
+/**
+ * @brief Prints info messages
+ * @param[in]  fmt  Format of data to be displayed
+ * @param[in]  args Arguments to be displayed
+ */
+#define sac_info(fmt, arg...) do { \
+            LOGI(FONT_COLOR_BLUE"[%d]"fmt""FONT_COLOR_RESET, sac_gettid() ,##arg);     \
+        } while (0)
+
+/**
+ * @brief Prints warning messages
+ * @param[in]  fmt  Format of data to be displayed
+ * @param[in]  args Arguments to be displayed
+ */
+#define sac_warning(fmt, arg...) do { \
+            LOGW(FONT_COLOR_YELLOW"[%d]"fmt""FONT_COLOR_RESET,sac_gettid(), ##arg);     \
+        } while (0)
+
+/**
+ * @brief Prints error messages
+ * @param[in]  fmt  Format of data to be displayed
+ * @param[in]  args Arguments to be displayed
+ */
+#define sac_error(fmt, arg...) do { \
+            LOGE(FONT_COLOR_RED"[%d]"fmt""FONT_COLOR_RESET,sac_gettid(), ##arg);     \
+        } while (0)
+
+/**
+ * @brief Prints fatal messages
+ * @param[in]  fmt  Format of data to be displayed
+ * @param[in]  args Arguments to be displayed
+ */
+#define sac_fatal(fmt, arg...) do { \
+            LOGF(FONT_COLOR_BOLDRED"[%d]"fmt""FONT_COLOR_RESET,sac_gettid(), ##arg);     \
+        } while (0)
+
+/**
+ * @brief Prints debug message on entry to particular function
+ * @param[in]  fmt  Format of data to be displayed
+ * @param[in]  args Arguments to be displayed
+ */
+#define sac_debug_func(fmt, arg...) do { \
+            LOGD(FONT_COLOR_CYAN"[%d]"fmt""FONT_COLOR_RESET, sac_gettid(), ##arg);     \
+        } while (0)
+
+#define sac_api_start()        do { \
+                       sac_info("API start <%s>", __FUNCTION__); \
+               } while (0)
+
+#define sac_api_start_msg(req_id)      do { \
+                       sac_info("API start <%s> : req_is(%lld)", __FUNCTION__, (long long int)req_id); \
+               } while (0)
+
+#define sac_api_end(ret) do { \
+                       sac_info("API end <%s> : %d", __FUNCTION__, (int)ret); \
+               } while (0)
+
+#define FUNC_START()   do{sac_debug_func(FONT_COLOR_BOLDBLACK">>>>>>>> Start\n%s"FONT_COLOR_RESET, __FUNCTION__);}while(0)
+#define FUNC_STEP()    do{sac_debug_func(FONT_COLOR_BOLDBLACK"====== Step\n%s"FONT_COLOR_RESET, __FUNCTION__);}while(0)
+#define FUNC_STOP()    do{sac_debug_func(FONT_COLOR_BOLDBLACK"<<==<<== Stop\n%s"FONT_COLOR_RESET, __FUNCTION__);}while(0)
+#define FUNC_END()     do{sac_debug_func(FONT_COLOR_BOLDBLACK"<<<<<<<< End\n%s"FONT_COLOR_RESET, __FUNCTION__);}while(0)
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_LOG_H__ */
diff --git a/include/service_adaptor_client_plugin.h b/include/service_adaptor_client_plugin.h
new file mode 100644 (file)
index 0000000..bc9585c
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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 __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_PLUGIN_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_PLUGIN_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup SERVICE_PLUGIN_MODULE
+
+ * @{
+ */
+
+/**
+ * @brief Type of service in plugin
+ * @since_tizen 2.4
+ */
+typedef enum
+{
+       SERVICE_PLUGIN_SERVICE_AUTH     = (0x01 << 0),          /**< Auth service type flag */
+       SERVICE_PLUGIN_SERVICE_STORAGE  = (0x01 << 1),          /**< Storage service type flag */
+}service_plugin_service_type_e;
+
+/**
+* @brief Definition for the service_plugin property: The application id be issued from service provider for 3rd party developer.
+* @since_tizen 2.4
+*
+* @see service_plugin_add_property()
+* @see service_plugin_remove_property()
+* @see service_plugin_get_property()
+ */
+#define SERVICE_PLUGIN_PROPERTY_APP_KEY                "http://tizen.org/service-adaptor/plugin/property/app_key"
+
+/**
+* @brief Definition for the service_plugin property: The application password be issued from service provider for 3rd party developer.
+* @since_tizen 2.4
+*
+* @see service_plugin_add_property()
+* @see service_plugin_remove_property()
+* @see service_plugin_get_property()
+*/
+#define SERVICE_PLUGIN_PROPERTY_APP_SECRET     "http://tizen.org/service-adaptor/plugin/property/app_secret"
+
+/**
+* @brief Definition for the service_plugin property: The user id for using specific service.
+* @since_tizen 2.4
+*
+* @see service_plugin_add_property()
+* @see service_plugin_remove_property()
+* @see service_plugin_get_property()
+*/
+#define SERVICE_PLUGIN_PROPERTY_USER_ID                "http://tizen.org/service-adaptor/plugin/property/user_id"
+
+
+/**
+* @brief The Plugn handle for Service Adaptor
+* @details The handle can be created by service_adaptor_create_plugin()<br>
+*  When a handle is no longer needed, use service_plugin_destroy()
+* @since_tizen 2.4
+*
+* @see service_adaptor_create_plugin()
+* @see service_plugin_destroy()
+*/
+typedef struct _service_plugin_s *service_plugin_h;
+
+/**
+* @brief       Destroy Service Adaptor
+* @details     It must called after a program no longer needs APIs of specfic plugin
+* @since_tizen 2.4
+*
+* @param[in]   plugin  The handle for use Plugin APIs
+* @see service_adaptor_create_plugin()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre @a plugin must be issued by service_adaptor_create_plugin()
+*/
+int service_plugin_destroy(service_plugin_h plugin);
+
+/**
+* @brief Add Plugin Property
+* @details The plguin property is used for plugin's basic or optional requirement.<br>
+*  This value is not used in Adaptor layer, but it can be uesd to important Key for plugin with service provider.<br>
+* @since_tizen 2.4
+*
+* @param[in]   plugin  The handle for use Plugin APIs
+* @param[in]   key     The key of plugin property
+* @param[in]   value   The value of plugin property that matched @a key
+* @remarks     Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
+* @remarks     If the @a key already exists in the property its current value is replaced with the new @a value.
+* @remarks     @a plugin must be released memory using #service_plugin_destroy() when you no longer needs plugin's API
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see SERVICE_PLUGIN_PROPERTY_APP_KEY
+* @see SERVICE_PLUGIN_PROPERTY_APP_SECRET
+* @see SERVICE_PLUGIN_PROPERTY_USER_ID
+* @pre @a plugin must be issued by service_adaptor_create_plugin()
+*/
+int service_plugin_add_property(service_plugin_h plugin,
+                                               const char *key,
+                                               const char *value);
+
+/**
+* @brief Remove Plugin Property
+* @since_tizen 2.4
+*
+* @param[in]   plugin  The handle for use Plugin APIs
+* @param[in]   key     The key of plugin property
+* @remarks     Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see SERVICE_PLUGIN_PROPERTY_APP_KEY
+* @see SERVICE_PLUGIN_PROPERTY_APP_SECRET
+* @see SERVICE_PLUGIN_PROPERTY_USER_ID
+*/
+int service_plugin_remove_property(service_plugin_h plugin,
+                                               const char *key);
+
+/**
+* @brief Gets Plugin Property
+* @since_tizen 2.4
+*
+* @param[in]   plugin  The handle for use Plugin APIs
+* @param[in]   key     The key of plugin property
+* @param[out]  value   The value of plugin property that matched @a key
+* @remarks     Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
+* @remarks     @a value must be released using free()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no property
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see SERVICE_PLUGIN_PROPERTY_APP_KEY
+* @see SERVICE_PLUGIN_PROPERTY_APP_SECRET
+* @see SERVICE_PLUGIN_PROPERTY_USER_ID
+* @pre The function get property already set by service_adaptor_set_plugin_property()
+*/
+int service_plugin_get_property(service_plugin_h plugin,
+                                               const char *key,
+                                               char **value);
+
+/**
+* @brief Requests start initalization for service plugin
+* @since_tizen 2.4
+*
+* @param[in]   plugin          The handle for use Plugin APIs
+* @param[in]   service_mask    The flag for use service plugins, this flag can be masked multiple enum (#service_plugin_service_type_e)
+* @remarks     @a service_mask must be input using 'bit or' operation with #service_plugin_service_type_e
+* @remarks     - for example,
+* @remarks     &nbsp;&nbsp;&nbsp;&nbsp;        <b>int</b> @a service_mask |= SERVIE_PLUGIN_SERVICE_AUTH;
+* @remarks     &nbsp;&nbsp;&nbsp;&nbsp;        @a service_mask |= SERVICE_PLUGIN_SERVICE_STORAGE;
+* @remarks     &nbsp;&nbsp;&nbsp;&nbsp;        <b>int</b> ret = service_plugin_start(@a m_plugin, @a service_mask);
+* @remarks     If a program needs to stop plugin manually, use #service_plugin_stop(). <br>But in #service_plugin_destroy(), automatically stop service plugin
+* @see         service_plugin_service_type_e
+* @see         service_plugin_stop()
+* @return 0 on success, otherwise a negative error value
+* @return If return value is #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED, request authorization to signup application
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED Need authorization
+* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_plugin_start(service_plugin_h plugin,
+                                               int service_mask);
+
+/**
+* @brief Requests stop manually for service plugin
+* @since_tizen 2.4
+*
+* @param[in]   plugin          The handle for use Plugin APIs
+* @remarks     If a program needs to stop plugin manually, use this function. <br>But in #service_plugin_destroy(), automatically stop service plugin
+* @remarks     @a plugin must be released memory using #service_plugin_destroy() when you no longer needs plugin's API
+* @see         service_plugin_start()
+* @see         service_plugin_destroy()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre service_plugin_start()
+*/
+int service_plugin_stop(service_plugin_h plugin);
+
+/**
+ * @}
+ */
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_PLUGIN_H__ */
diff --git a/include/service_adaptor_client_private.h b/include/service_adaptor_client_private.h
new file mode 100644 (file)
index 0000000..63c579f
--- /dev/null
@@ -0,0 +1,225 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: service_adaptor_client_storage_private.h
+ * Desc: Service Adaptor APIs
+ * Created on: Feb, 2015
+ * Auth: Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_PRIVATE_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_PRIVATE_H__
+
+#if defined _WIN32 || defined __CYGWIN__
+       #define DLL_IMPORT __declspec(dllimport)
+       #define DLL_EXPORT __declspec(dllexport)
+       #define DLL_LOCAL
+#else
+       #if __GNUC__ >= 4
+               #define DLL_IMPORT __attribute__ ((visibility ("default")))
+               #define DLL_EXPORT __attribute__ ((visibility ("default")))
+               #define DLL_LOCAL  __attribute__ ((visibility ("hidden")))
+       #else
+               #define DLL_IMPORT
+               #define DLL_EXPORT
+               #define DLL_LOCAL
+       #endif
+#endif
+
+#ifdef SERVICE_ADAPTOR_CLIENT_DLL
+       #ifdef SERVICE_ADAPTOR_CLIENT_DLL_EXPORTS
+               #define SERVICE_ADAPTOR_CLIENT_PUBLIC_API DLL_EXPORT
+       #else
+               #define SERVICE_ADAPTOR_CLIENT_PUBLIC_API DLL_IMPORT
+       #endif
+       #define SERVICE_ADAPTOR_CLIENT_LOCAL_API DLL_LOCAL
+#else
+       #define SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+       #define SERVICE_ADAPTOR_CLIENT_LOCAL_API
+#endif
+
+#include "service_adaptor_client.h"
+#include "service_adaptor_client_type.h"
+#include "private/service-adaptor-client.h"
+#include <glib.h>
+
+/**
+* @brief Describes infromation about Service Adaptor
+*/
+struct _service_adaptor_s
+{
+       void *on_signal;
+
+//     struct _service_plugin_s **plugins; //TODO
+//     int plugin_count;       // TODO
+
+/////////////////////// private feature
+       char *service_name;                     /**< specifies status as none*/
+       char *user_id;                          /**< specifies status as none*/
+       char *app_id;                           /**< specifies status as none*/
+       unsigned int service_id;
+       char *imsi;                             /**< specifies status as none*/
+       GMutex set_auth_mutex;
+
+       service_adaptor_plugin_s *plugin;       /**< specifies status as none*/
+/////////////////////// private feature
+};
+
+typedef struct _plugin_entry_s
+{
+       char *plugin_uri;
+       int installed_mask;
+}plugin_entry_t;
+
+typedef enum _client_app_type_e
+{
+       CLIENT_APP_TYPE_APPLICATION = 1,
+       CLIENT_APP_TYPE_ETC = 0,
+}client_app_type_e;
+
+struct _service_plugin_s
+{
+       struct _service_adaptor_s *adaptor;
+
+       char *service_handle_name;
+       void *optional_property;
+       char *plugin_uri;
+       int enabled_mask;
+       client_app_type_e app_type;
+};
+
+
+
+
+
+/**
+* @brief Callback for getting login result
+* @since_tizen 2.4
+*
+* @param[in]    result          Result code for login request (see #service_adaptor_error_e)
+* @param[in]    user_data       Passed data from request function
+* @remarks      The @a result values #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @remarks      The @a result values #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @remarks      The @a result values #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_NETWORK_UNREACHABLE Failed by network issue
+* @remarks      The @a result values #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see #service_adaptor_error_e
+* @see service_plugin_request_login()
+* @pre  #service_plugin_request_login() will invoke this callback.
+*/
+typedef void (*service_plugin_login_cb)(int result,
+                                               void *user_data);
+
+
+
+/**
+* @brief Set callback for changing state of Service Adaptor
+* @since_tizen 2.4
+*
+* @param[in]   service_adaptor The handle of Service Adaptor
+* @param[in]   callback        The callback function to receive message from service adaptor daemon
+* @param[in]   user_data       Passed data to callback
+* @remarks     @a service_adaptor must be released memory using service_adaptor_destroy() when you finish using service adaptor
+* @see         service_adaptor_destroy()
+* @see         service_adaptor_signal_cb()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_HANDLE Invalid handle
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre @a service_adaptor must be issued by service_adaptor_create()
+*/
+int service_adaptor_set_state_changed_cb(service_adaptor_h service_adaptor,
+                                               service_adaptor_signal_cb callback,
+                                               void *user_data);
+
+/**
+* @brief Set callback for changing state of Service Adaptor
+* @since_tizen 2.4
+*
+* @param[in]   service_adaptor The handle of Service Adaptor
+* @remarks     @a service_adaptor must be released memory using service_adaptor_destroy() when you finish using service adaptor
+* @see         service_adaptor_destroy()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_HANDLE Invalid handle
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre @a service_adaptor must be issued by service_adaptor_create()
+*/
+int service_adaptor_unset_state_changed_cb(service_adaptor_h service_adaptor);
+
+/**
+* @brief Gets whether a plugin is logined or not logined
+* @details 'Login' includes both authentication(sign-in by user) and authorization (allowed by user) <br>
+* If plugin does not need authentication or authorization, service_plugin_is_login_required() API's result is true on anytime.
+* @since_tizen 2.4
+*
+* @param[in]   plugin          The handle for use Plugin APIs
+* @param[out]  required        true on login required, otherwise false
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+*/
+int service_plugin_is_login_required(service_plugin_h plugin,
+                                               bool *required);
+
+/**
+* @brief Requests login to plugin
+* @details 'Login' includes both authentication(sign-in by user) and authorization (allowed by user) <br>
+* If the plugin does not logined by user, you must request login using this API.<br>
+* You can check whether logined or not using service_plugin_is_login_required().<br>
+* If not logined, you will be failed #service_plugin_start().<br>
+* Of caurse, if plugin does not need authentication or authorization, service_plugin_is_login_required() API's result is true on anytime.
+* @since_tizen 2.4
+*
+* @param[in]    plugin          The handle for use Plugin APIs
+* @param[in]    callback        The callback for getting result this operation
+* @param[in]    user_data       The user data to be passed to the callback function
+* @see          service_plugin_start()
+* @see          service_plugin_login_cb()
+* @see          service_adaptor_get_last_result()
+* @see          service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @post #service_plugin_login_cb() will be invoked
+*/
+int service_plugin_request_login(service_plugin_h plugin,
+                                               service_plugin_login_cb callback,
+                                               void *user_data);
+
+/**
+* @brief The type for Service Adaptor
+*/
+typedef struct _service_adaptor_s service_adaptor_s;
+
+typedef struct _service_plugin_s service_plugin_s;
+
+void _service_adaptor_set_last_result (int code, const char *message);
+
+#define service_adaptor_set_last_result(code, msg)     do { \
+                                                               sac_error("Error occured (%d)(%s)", (int)(code), (msg)); \
+                                                               _service_adaptor_set_last_result((code), (msg)); \
+                                                       } while (0)
+
+#endif /*__TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_PRIVATE_H__*/
diff --git a/include/service_adaptor_client_storage.h b/include/service_adaptor_client_storage.h
new file mode 100644 (file)
index 0000000..fcdb135
--- /dev/null
@@ -0,0 +1,642 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: service_adaptor_client_storage.h
+ * Desc: Service Adaptor APIs
+ * Created on: Oct, 2014
+ * Author: Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ *     @file           service_adaptor_client_storage.h
+ *     @brief          Defines interface of Service Adaptor's Storage
+ *     @version        0.1
+ */
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_STORAGE_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_STORAGE_H__
+
+#include <service_adaptor_client_plugin.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file service_adaptor_client_storage.h
+ */
+
+/**
+ * @addtogroup  SERVICE_ADAPTOR_STORAGE_MODULE
+
+ * @{
+ */
+
+/**
+* @brief The handle of async task for storage service
+* @since_tizen 2.4
+*
+* @see #service_storage_create_download_task()
+* @see #service_storage_create_upload_task()
+*/
+typedef struct _service_storage_task_s *service_storage_task_h;
+
+/**
+* @brief The handle of file or directory in storage
+* @since_tizen 2.4
+*
+* @see #service_storage_file_clone()
+* @see #service_storage_file_destroy()
+*/
+typedef struct _service_storage_file_s *service_storage_file_h;
+
+/**
+* @brief The list handle of file or directory in storage
+* @since_tizen 2.4
+*
+* @see #service_storage_file_list_clone()
+* @see #service_storage_file_list_destroy()
+*/
+typedef struct _service_storage_file_list_s *service_storage_file_list_h;
+
+/**
+ * @brief Type of storage task
+ * @since_tizen 2.4
+ */
+typedef enum
+{
+       SERVICE_STORAGE_TASK_IN_PROGRESS        = 1,    /**< The task is progressing */
+       SERVICE_STORAGE_TASK_COMPLETED          = 2,    /**< The task was completed */
+       SERVICE_STORAGE_TASK_CANCELED           = 3,    /**< The task was canceled */
+       SERVICE_STORAGE_TASK_FAILED             = 4,    /**< The task was failed */
+} service_storage_task_state_e;
+
+/**
+* @brief Callback for changing state of storage task
+* @since_tizen 2.4
+*
+* @param[in]   state           The state of storage task
+* @param[in]   user_data       The user data passed from #service_storage_set_task_state_changed_cb()
+* @see #service_storage_unset_task_state_changed_cb()
+* @pre #service_storage_set_task_state_changed_cb() will invoke this callback.
+*/
+typedef void (*service_storage_task_state_cb)(service_storage_task_state_e state,
+                                               void *user_data);
+
+/**
+* @brief Callback for progress of storage task
+* @since_tizen 2.4
+*
+* @param[in]   progress        The progressed amount of storage task
+* @param[in]   total           The total amount of storage task
+* @param[in]   user_data       The user data passed from #service_storage_set_task_progress_cb()
+* @see #service_storage_unset_task_progress_cb()
+* @pre #service_storage_set_task_progress_cb() will invoke this callback.
+*/
+typedef void (*service_storage_task_progress_cb)(unsigned long long progress,
+                                               unsigned long long total,
+                                               void *user_data);
+
+/**
+* @brief Callback for getting async storage operation result
+* @since_tizen 2.4
+*
+* @param[in]   result          Result code for storage async operation (see #service_adaptor_error_e)
+* @param[in]   user_data       Passed data from request function
+* @remarks     If the @a result value is #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see #service_adaptor_error_e
+* @see service_storage_remove()
+* @pre #service_storage_remove() will invoke this callback.
+*/
+typedef void (*service_storage_result_cb)(int result,
+                                               void *user_data);
+
+
+/**
+* @brief Callback for getting file list API
+* @since_tizen 2.4
+*
+* @param[in]   result          Result code for #service_storage_get_file_list() (see #service_adaptor_error_e)
+* @param[in]   list            The handle of file list
+* @param[in]   user_data       Passed data from #service_storage_get_file_list()
+* @remarks     If the @a result value is #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see #service_adaptor_error_e
+* @see #service_storage_file_list_h
+* @pre #service_storage_get_file_list() will invoke this callback.
+*/
+typedef void (*service_storage_file_list_cb)(int result,
+                                               service_storage_file_list_h list,
+                                               void *user_data);
+
+/**
+* @brief Callback for service_storage_file_list_foreach_file API
+* @since_tizen 2.4
+*
+* @param[in]   file            The handle of file
+* @param[in]   user_data       Passed data from #service_storage_file_list_foreach_file()
+* @see #service_storage_file_h
+* @return @c true to continue with the next iteration of the loop,
+*         otherwise @c false to break out of the loop
+* @pre #service_storage_file_list_foreach_file() will invoke this callback.
+*/
+typedef bool (*service_storage_file_cb)(service_storage_file_h file,
+                                               void *user_data);
+
+/**
+* @brief Gets file list from storage, asynchronously.
+* @since_tizen 2.4
+* @privlevel   public
+* @privilege   %http://tizen.org/privilege/internet
+*
+* @param[in]   plugin          The handle for use Plugin APIs
+* @param[in]   dir_path        The dir path (Physical path)
+* @param[in]   callback        The callback for getting file list
+* @param[in]   user_data       The user data to be passed to the callback function
+* @remarks     For the @a dir_path, "/" means root path.
+* @remarks     Reference details for <b>"Logical path"</b> and <b>"Physical path"</b> at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page
+* @see         service_plugin_start()
+* @see         service_storage_file_list_cb()
+* @see         service_adaptor_get_last_result()
+* @see         service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED Permission denied
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre API prerequires #service_plugin_start()
+* @post        #service_storage_file_list_cb() will be invoked
+*/
+int service_storage_get_file_list(service_plugin_h plugin,
+                                               const char *dir_path,
+                                               service_storage_file_list_cb callback,
+                                               void *user_data);
+
+/**
+* @brief Removes file or directory in storage
+* @since_tizen 2.4
+* @privlevel   public
+* @privilege   %http://tizen.org/privilege/internet
+*
+* @param[in]   plugin          The handle for use Plugin APIs
+* @param[in]   remove_path     The target file or directory for remove (Physical path)
+* @param[in]   callback        The callback for getting result this operation
+* @param[in]   user_data       The user data to be passed to the callback function
+* @remarks     If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @remarks     Reference details for <b>"Logical path"</b> and <b>"Physical path"</b> at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page
+* @see         service_plugin_start()
+* @see         service_storage_result_cb()
+* @see         service_adaptor_get_last_result()
+* @see         service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED Permission denied
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre API prerequires #service_plugin_start()
+* @post        #service_storage_result_cb() will be invoked
+*/
+int service_storage_remove(service_plugin_h plugin,
+                                               const char *remove_path,
+                                               service_storage_result_cb callback,
+                                               void *user_data);
+
+/**
+* @brief Creates storage task for upload file to storage
+* @since_tizen 2.4
+* @privlevel   public
+* @privilege   %http://tizen.org/privilege/internet
+*
+* @param[in]   plugin          The handle for use Plugin APIs
+* @param[in]   file_path       The upload file path in local (Logical path)
+* @param[in]   upload_path     The upload target path in storage (Physical path)
+* @param[out]  task            The handle of download task
+* @remarks     @a task must be released memory using service_storage_destroy_task() when the task no longer run
+* @remarks     If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @remarks     Reference details for <b>"Logical path"</b> and <b>"Physical path"</b> at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page
+* @remarks     http://tizen.org/privilege/mediastorage is needed if @a file_path is relevant to media storage.
+* @remarks     http://tizen.org/privilege/externalstorage is needed if @a file_path is relevant to external storage.
+* @see         service_plugin_start()
+* @see         service_storage_destroy_task()
+* @see         service_adaptor_get_last_result()
+* @see         service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED Permission denied
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files
+* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre API prerequires #service_plugin_start()
+*/
+int service_storage_create_upload_task(service_plugin_h plugin,
+                                               const char *file_path,
+                                               const char *upload_path,
+                                               service_storage_task_h *task);
+
+/**
+* @brief Creates storage task for download file from storage
+* @since_tizen 2.4
+* @privlevel   public
+* @privilege   %http://tizen.org/privilege/internet
+*
+* @param[in]   plugin          The handle for use Plugin APIs
+* @param[in]   storage_path    The source file path in storage (Physical path)
+* @param[in]   download_path   The download path in local (Logical path)
+* @param[out]  task            The handle of download task
+* @remarks     @a task must be released memory using service_storage_destroy_task() when the task no longer run
+* @remarks     If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @remarks     Reference details for <b>"Logical path"</b> and <b>"Physical path"</b> at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page
+* @remarks     http://tizen.org/privilege/mediastorage is needed if @a download_path is relevant to media storage.
+* @remarks     http://tizen.org/privilege/externalstorage is needed if @a download_path is relevant to external storage.
+* @see         service_plugin_start()
+* @see         service_storage_destroy_task()
+* @see         service_adaptor_get_last_result()
+* @see         service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED Permission denied
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files
+* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre API prerequires #service_plugin_start()
+*/
+int service_storage_create_download_task(service_plugin_h plugin,
+                                               const char *storage_path,
+                                               const char *download_path,
+                                               service_storage_task_h *task);
+
+/**
+* @brief Creates storage task for download thumbnail from storage
+* @since_tizen 2.4
+* @privlevel   public
+* @privilege   %http://tizen.org/privilege/internet
+*
+* @param[in]   plugin                  The handle for use Plugin APIs
+* @param[in]   storage_path            The source file path in storage (Physical path)
+* @param[in]   download_path           The download path in local (Logical path)
+* @param[in]   thumbnail_size          The size <b>level</b> of thumbnail, the level is defined service plugin SPEC
+* @param[out]  task            The handle of download task
+* @remarks     If @a thumbnail_size is <b>0</b>, gets default size thumbnail, the default size must be defined plugin SPEC
+* @remarks     If @a thumbnail_size is <b>-1</b>, gets minimum size thumbnail be supported plugin
+* @remarks     If @a thumbnail_size is <b>-2</b>, gets maximum size thumbnail be supported plugin
+* @remarks     @a task must be released memory using service_storage_destroy_task() when the task no longer run
+* @remarks     If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @remarks     Reference details for <b>"Logical path"</b> and <b>"Physical path"</b> at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page
+* @remarks     http://tizen.org/privilege/mediastorage is needed if @a download_path is relevant to media storage.
+* @remarks     http://tizen.org/privilege/externalstorage is needed if @a download_path is relevant to external storage.
+* @see         service_plugin_start()
+* @see         service_adaptor_get_last_result()
+* @see         service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED Permission denied
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no thumbnail data
+* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre API prerequires #service_plugin_start()
+*/
+int service_storage_create_download_thumbnail_task (service_plugin_h plugin,
+                                               const char *storage_path,
+                                               const char *download_path,
+                                               int thumbnail_size,
+                                               service_storage_task_h *task);
+
+/**
+* @brief Destroys storage task
+* @since_tizen 2.4
+*
+* @param[in]   task            The handle of storage task
+* @remarks     If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @see         service_storage_create_download_task()
+* @see         service_storage_create_upload_task()
+* @see         service_adaptor_get_last_result()
+* @see         service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_storage_destroy_task(service_storage_task_h task);
+
+/**
+* @brief Starts storage task, asynchronously.
+* @since_tizen 2.4
+*
+* @param[in]   task    The handle of storage task
+* @remarks     If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @see         service_storage_create_upload_task()
+* @see         service_storage_create_download_task()
+* @see         service_storage_create_download_thumbnail_task()
+* @see         service_adaptor_get_last_result()
+* @see         service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_storage_start_task(service_storage_task_h task);
+
+/**
+* @brief Cancels storage task, asynchronously.
+* @since_tizen 2.4
+*
+* @param[in]   task    The handle of storage task
+* @remarks     @a task must be released memory using service_storage_destroy_task() when the task no longer run
+* @remarks     If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @see         service_storage_start_task()
+* @see         service_adaptor_get_last_result()
+* @see         service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_storage_cancel_task(service_storage_task_h task);
+
+/**
+* @brief Sets a callback function to be invoked when progress of the task running.
+* @since_tizen 2.4
+*
+* @param[in]   task            The handle of storage task
+* @param[in]   callback        The callback function to register
+* @param[in]   user_data       The user data to be passed to the callback function
+* @remarks     This function must be called before starting task (see #service_storage_start_task())
+* @remarks     If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @see         service_storage_start_task()
+* @see         service_adaptor_get_last_result()
+* @see         service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @post        #service_storage_task_progress_cb() will be invoked
+*/
+int service_storage_set_task_progress_cb(service_storage_task_h task,
+                                               service_storage_task_progress_cb callback,
+                                               void *user_data);
+
+/**
+* @brief Unsets the progress callback function.
+* @since_tizen 2.4
+*
+* @param[in]   task            The handle of storage task
+* @remarks     This function must be called before starting task (see #service_storage_start_task())
+* @see         service_storage_start_task()
+* @see         service_storage_set_task_progress_cb()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_unset_task_progress_cb(service_storage_task_h task);
+
+
+/**
+* @brief Sets a callback function to be invoked when change of the task running state.
+* @since_tizen 2.4
+*
+* @param[in]   task            The handle of storage task
+* @param[in]   callback        The callback function to register
+* @param[in]   user_data       The user data to be passed to the callback function
+* @remarks     This function must be called before starting task (see #service_storage_start_task())
+* @remarks     If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @see         service_storage_start_task()
+* @see         service_adaptor_get_last_result()
+* @see         service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @post        #service_storage_task_state_cb() will be invoked
+*/
+int service_storage_set_task_state_changed_cb(service_storage_task_h task,
+                                               service_storage_task_state_cb callback,
+                                               void *user_data);
+
+/**
+* @brief Unsets the state changed callback function.
+* @since_tizen 2.4
+*
+* @param[in]   task            The handle of storage task
+* @remarks     This function must be called before starting task (see #service_storage_start_task())
+* @see         service_storage_start_task()
+* @see         service_storage_set_task_progress_cb()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_unset_task_state_changed_cb(service_storage_task_h task);
+
+/**
+* @brief Clones the file list handle
+* @since_tizen 2.4
+*
+* @param[in]   src_list        The source handle
+* @param[out]  dst_list        The destination handle
+* @remarks     @a file must be released memory using service_storage_file_list_destroy() when you no longer needs this handle
+* @see service_storage_file_list_h
+* @see service_storage_file_list_destroy()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_file_list_clone(service_storage_file_list_h src_list,
+                                               service_storage_file_list_h *dst_list);
+
+/**
+* @brief Destroys the file list handle
+* @since_tizen 2.4
+*
+* @param[in]   list            The file list handle
+* @remarks     It must be used for cloned file list handle
+* @see service_storage_file_list_h
+* @see service_storage_file_list_clone()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_file_list_destroy(service_storage_file_list_h list);
+
+/**
+* @brief Gets length of the file list handle
+* @since_tizen 2.4
+*
+* @param[in]   list            The file list handle
+* @param[out]  length          The length of the file list handle
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_file_list_get_length(service_storage_file_list_h list,
+                                               int *length);
+
+/**
+* @brief Foreach All of the file from file list
+* @since_tizen 2.4
+*
+* @param[in]   list            The file list handle
+* @param[in]   callback        The callback for foreach file
+* @param[in]   user_data       Passed data to callback
+* @see         #service_storage_file_cb
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files
+*/
+int service_storage_file_list_foreach_file(service_storage_file_list_h list,
+                                               service_storage_file_cb callback,
+                                               void *user_data);
+
+/**
+* @brief Clones the file handle
+* @since_tizen 2.4
+*
+* @param[in]   src_file        The source handle
+* @param[out]  dst_file        The destination handle
+* @remarks     @a file must be released memory using service_storage_file_destroy() when you no longer needs this handle
+* @see #service_storage_file_h
+* @see #service_storage_file_destroy()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_file_clone(service_storage_file_h src_file,
+                                               service_storage_file_h *dst_file);
+
+/**
+* @brief Destroys the file handle
+* @details This function must be used for cloned file handle.
+* @since_tizen 2.4
+*
+* @param[in]   file            The handle of file or directory in storage
+* @see service_storage_file_h
+* @see service_storage_file_clone()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_file_destroy(service_storage_file_h file);
+
+/**
+* @brief Gets whether directory or file for file handle
+* @since_tizen 2.4
+*
+* @param[in]   file            The handle of file or directory in storage
+* @param[out]  is_dir          true on directory, false on file
+* @see service_storage_file_h
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_file_is_dir(service_storage_file_h file,
+                                               bool *is_dir);
+
+/**
+* @brief Gets size of handle
+* @since_tizen 2.4
+*
+* @param[in]   file            The handle of file or directory in storage
+* @param[out]  size            The size of file (byte)
+* @see service_storage_file_h
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_file_get_size(service_storage_file_h file,
+                                               unsigned long long *size);
+
+/**
+* @brief Gets logical path from file handle
+* @since_tizen 2.4
+*
+* @param[in]   file            The handle of file or directory in storage
+* @param[out]  path            The logical path of file
+* @remarks     @a path must be released using free()
+* @remarks     Reference details for <b>"Logical path"</b> and <b>"Physical path"</b> at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page
+* @see #service_storage_file_h
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no data
+*/
+int service_storage_file_get_logical_path(service_storage_file_h file,
+                                               char **path);
+
+/**
+* @brief Gets physical path from file handle
+* @since_tizen 2.4
+*
+* @param[in]   file            The handle of file or directory in storage
+* @param[out]  path            The physical path of file
+* @remarks     @a path must be released using free()
+* @remarks     Reference details for <b>"Logical path"</b> and <b>"Physical path"</b> at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page
+* @see #service_storage_file_h
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no data
+*/
+int service_storage_file_get_physical_path(service_storage_file_h file,
+                                               char **path);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_STORAGE_H__ */
diff --git a/include/service_adaptor_client_storage_internal.h b/include/service_adaptor_client_storage_internal.h
new file mode 100644 (file)
index 0000000..c8a4af7
--- /dev/null
@@ -0,0 +1,723 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: service_adaptor_client_storage_private.h
+ * Desc: Service Adaptor APIs
+ * Created on: Feb, 2015
+ * Auth: Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+/**
+ *     @file           service_adaptor_client_storage_internal.h
+ *     @brief          Defines interface of Service Adaptor's Storage
+ *     @version        0.1
+ */
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_STORAGE_INTERNAL_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_STORAGE_INTERNAL_H__
+
+#include "service_adaptor_client.h"
+#include "service_adaptor_client_storage.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Storage adaptor content type
+ */
+typedef enum _service_storage_file_content_type_e
+{
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_DEFAULT               = -1,    // initalize value
+
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_IMGAE                 = 160,
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_VIDEO                 = 161,
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_SOUND                 = 162,
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_MUSIC                 = 163,
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_OTHER                 = 164,
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_DOCUMENT              = 165,
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_THUMBNAIL             = 166,
+
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_CHUNK_MASK            = 320,
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_IMGAE_CHUNK           = 480,
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_VIDEO_CHUNK           = 481,
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_SOUND_CHUNK           = 482,
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_MUSIC_CHUNK           = 483,
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_OTHER_CHUNK           = 484,
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_DOCUMENT_CHUNK        = 485,
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_THUMBNAIL_CHUNK       = 486,
+
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_FOLDER                = 1024,
+       SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_METADATA              = 2048,
+} service_storage_content_type_e;
+
+typedef struct _service_storage_media_meta_s
+{
+       char *mime_type;
+       char *title;
+       char *album;
+       char *artist;
+       char *genere;
+       char *recorded_date;
+       int width;
+       int height;
+       int duration;
+       char *copyright;
+       char *track_num;
+       char *description;
+       char *composer;
+       char *year;
+       int bitrate;
+       int samplerate;
+       int channel;
+       char *extra_media_meta;
+} service_storage_media_meta_s;
+
+typedef struct _service_storage_cloud_meta_s
+{
+       char *service_name;
+       unsigned long long usage_byte;
+       unsigned long long quota_byte;
+       char *extra_cloud_meta;
+} service_storage_cloud_meta_s;
+
+/**
+* @brief Describes file information description
+*/
+struct _service_storage_file_s
+{
+       char    *plugin_name;           /**< specifies plugin name generated file_info */
+       char    *object_id;             /**< specifies file object id be used in storage */
+       char    *storage_path;          /**< specifies file path in storage */
+       unsigned long long file_size;   /**< specifies file size (recomend byte)*/
+       unsigned long long created_time;        /**< specifies timestamp */
+       unsigned long long modified_time;       /**< specifies timestamp */
+       int     file_info_index;        /**< specifies file info index (wide use; e.g : chunk upload, multi download)*/
+       service_storage_content_type_e content_type; /**< specifies file content type (reference service_adaptor_file_content_type_e)  */
+
+       service_storage_media_meta_s *media_meta;
+       service_storage_cloud_meta_s *cloud_meta;
+       char    *extra_file_info;               /**< specifies content name in metadata */
+};
+
+
+typedef struct _service_storage_file_s service_storage_file_s;
+
+/**
+* @brief The handle for File Description
+*/
+typedef struct _service_storage_file_s *service_storage_file_h;
+
+
+
+/**
+* @brief Callback for file upload and download API
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   file_handle     specifies file description
+* @param[in]   transferred_size        specifies transferred size
+* @param[in]   total_size      specifies total size
+* @param[in]   error_code      specifies error code
+* @param[in]   user_data       specifies user_data passed in API
+* @return      void
+* @pre service_adaptor_request_channel_auth will invoke this callback.
+* @see
+*/
+/*
+typedef void(* service_adaptor_file_progress_cb)(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               unsigned long long transferred_size,
+                                               unsigned long long total_size,
+                                               service_adaptor_error_s *error_code,
+                                               void *user_data);
+*/
+/**
+* @brief Callback for file transfer completion
+*
+* @param[in]   handle          specifies Service Adaptor handle. use this handle to get internal data
+* @param[in]   file_handle     specifies file description
+* @param[in]   publish_url     specifies publish url for another user
+* @param[in]   error_code      specifies error code
+* @param[in]   user_data       specifies user_data passed in API
+* @return      void
+* @pre service_adaptor_request_channel_auth will invoke this callback.
+* @see
+*/
+/*
+typedef void(* service_adaptor_file_transfer_completion_cb)(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               char *publish_url,
+                                               service_adaptor_error_s *error_code,
+                                               void *user_data);
+
+*/
+
+/**
+* @brief Create memory for service_storage_file_h
+* @since_tizen 2.4
+*
+* @param[in]   void
+* @return service_storage_file_h
+* @retval Allocated and filled default value file_info's pointer
+*/
+service_storage_file_h service_storage_create_file_info(void);
+
+/**
+* @brief Release memory for service_storage_file_h
+* @since_tizen 2.4
+*
+* @param[in]   file_info       specifies Service Adaptor file information handle
+* @return service_storage_file_h
+* @retval released file_info's pointer
+*/
+int service_storage_unref_file_info(service_storage_file_h *file_info);
+
+
+
+/**
+* @brief Registers File Progress Listener
+* @since_tizen 2.4
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   callback        the callback function to invoke
+* @param[in]   user_data       specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_adaptor_register_file_progress_listener(service_adaptor_h handle,
+                                               service_adaptor_file_progress_cb callback,
+                                               void *user_data);
+*/
+/**
+* @brief Unregisters File Progress Listener
+* @since_tizen 2.4
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   user_data       specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_adaptor_unregister_file_progress_listener(service_adaptor_h handle,
+                                               void *user_data);
+*/
+/**
+* @brief Registers File Transfer Completion Listener
+* @since_tizen 2.4
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   callback        the callback function to invoke
+* @param[in]   user_data       specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_adaptor_register_file_transfer_completion_listener(service_adaptor_h handle,
+                                               service_adaptor_file_transfer_completion_cb callback,
+                                               void *user_data);
+*/
+/**
+* @brief Unregisters File Transfer Completion Listener
+* @since_tizen 2.4
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   user_data       specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_adaptor_unregister_file_transfer_completion_listener(service_adaptor_h handle,
+                                               void *user_data);
+
+*/
+/**
+* @brief Downloads a server file and writes it to local file (Async)
+* @since_tizen 2.4
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   server_path     specifies server url of file to download
+* @param[in]   download_path   specifies local path where we expect downloaded file to be written
+* @param[out]  file_handle     specifies file description
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_download_file_async(service_adaptor_h handle,
+                                               const char *storage_path,
+                                               const char *local_path,
+                                               service_adaptor_file_h *file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+*/
+
+
+/**
+* @brief Uploads a local file to server path (Async)
+* @since_tizen 2.4
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   upload_path     specifies local path for upload
+* @param[in]   server_path     specifies server url of file to download
+* @param[out]  file_handle     specifies file description
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_upload_file_async(service_adaptor_h handle,
+                                               const char *local_path,
+                                               const char *storage_path,
+                                               service_adaptor_file_h *file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+*/
+
+
+
+/**
+* @brief Downloads a server file and writes it to local file
+* @since_tizen 2.4
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   publish_url     specifies publish url of file to download
+* @param[in]   download_path   specifies local path where we expect downloaded file to be written
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_download_file_publish(service_adaptor_h handle,
+                                               const char *publish_url,
+                                               const char *local_path,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+*/
+/**
+* @brief Downloads a server file and writes it to local file (Async)
+* @since_tizen 2.4
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   publish_url     specifies publish url of file to download
+* @param[in]   download_path   specifies local path where we expect downloaded file to be written
+* @param[out]  file_handle     specifies file description
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_download_file_publish_async(service_adaptor_h handle,
+                                               const char *publish_url,
+                                               const char *local_path,
+                                               service_adaptor_file_h *file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+*/
+/**
+* @brief Uploads a local file to server path
+* @since_tizen 2.4
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   upload_path     specifies local path for upload
+* @param[in]   server_path     specifies server url of file to download
+* @param[out]  publish_url     specifies publish url
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+
+/*
+int service_storage_upload_file_publish(service_adaptor_h handle,
+                                               const char *local_path,
+                                               const char *storage_path,
+                                               char **publish_url,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+*/
+/**
+* @brief Uploads a local file to server path (Async)
+* @since_tizen 2.4
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   upload_path     specifies local path for upload
+* @param[in]   server_path     specifies server url of file to download
+* @param[out]  file_handle     specifies file description
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_upload_file_publish_async(service_adaptor_h handle,
+                                               const char *local_path,
+                                               const char *storage_path,
+                                               service_adaptor_file_h *file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+*/
+/**
+* @brief Downloads a thumbnail file and writes it to local file
+* @since_tizen 2.4
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   publish_url     specifies publish url of file to download
+* @param[in]   download_path   specifies local path where we expect downloaded file to be written
+* @param[in]   size            specifies size of thumbnail
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_download_thumbnail_publish(service_adaptor_h handle,
+                                               const char *publish_url,
+                                               const char *local_path,
+                                               storage_adaptor_thumbnail_size_e size,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data);
+*/
+/**
+* @brief Requests File Status
+* @since_tizen 2.4
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   file_handle     specifies file description
+* @param[out]  status          specifies status of file transfer
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) received from Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_get_file_status(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               service_adaptor_file_status_s **status,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+*/
+
+/**
+* @brief Cancels File Transfer
+* @since_tizen 2.4
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   file_handle     specifies file description
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) received from Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_cancel_file_transfer(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+*/
+/**
+* @brief Pause File Transfer
+* @since_tizen 2.4
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   file_handle     specifies file description
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) received from Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_pause_file_transfer(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+*/
+/**
+* @brief Resume File Transfer
+* @since_tizen 2.4
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   file_handle     specifies file description
+* @param[out]  error_code      specifies error code
+* @param[out]  server_data     specifies server_data (json) received from Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_resume_file_transfer(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data);
+*/
+
+
+
+
+/**
+* @brief Downloads a server file and writes it to local file
+* @since_tizen 2.4
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   server_path     specifies server url of file to download
+* @param[in]   download_path   specifies local path where we expect downloaded file to be written
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @remarks     'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see         service_adaptor_error_s
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+
+int service_storage_download_file(service_plugin_h handle,
+                                               const char *storage_path,
+                                               const char *local_path);
+
+/**
+* @brief Requests download thumbnail from storage (internal)
+* @since_tizen 2.4
+*
+* @param[in]   plugin                  The handle for use Plugin APIs
+* @param[in]   storage_path            The source file path in storage (Physical path)
+* @param[in]   download_path           The download path in local (Logical path)
+* @param[in]   thumbnail_size          The size <b>level</b> of thumbnail, the level is defined service plugin SPEC
+* @remarks     If @a thumbnail_size is <b>0</b>, gets default size thumbnail, the default size must be defined plugin SPEC
+* @remarks     If @a thumbnail_size is <b>-1</b>, gets minimum size thumbnail be supported plugin
+* @remarks     If @a thumbnail_size is <b>-2</b>, gets maximum size thumbnail be supported plugin
+* @remarks     If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @remarks     Reference details for <b>"Logical path"</b> and <b>"Physical path"</b> at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page
+* @see         service_plugin_start()
+* @see         service_adaptor_get_last_result()
+* @see         service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no thumbnail data
+* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre API prerequires #service_plugin_start()
+*/
+int service_storage_download_thumbnail(service_plugin_h handle,
+                                               const char *storage_path,
+                                               const char *local_path,
+                                               int thumbnail_size);
+
+/**
+* @brief Uploads a local file to server path
+* @since_tizen 2.4
+* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
+* @see service_storage_file_h
+* @see service_storage_unref_file_info
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   upload_path     specifies local path for upload
+* @param[in]   server_path     specifies server url of file to download
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @remarks     'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see         service_adaptor_error_s
+* @remarks     'file_info' is needed memory free using 'service_storage_unref_file_info()'
+* @see         service_storage_unref_file_info()
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+int service_storage_upload_file(service_plugin_h handle,
+                                               const char *local_path,
+                                               const char *storage_path,
+                                               service_storage_file_h *file_info);
+/**
+* @brief Get root diretory path
+* @since_tizen 2.4
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[out]  dir_path        specifies be mounted path
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @remarks     'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see         service_adaptor_error_s
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+int service_storage_get_root_directory(service_plugin_h handle,
+                                               char **dir_path);
+
+/**
+* @brief Make directory in storage
+* @since_tizen 2.4
+* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
+* @see service_storage_file_h
+* @see service_storage_unref_file_info
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   dir_path        specifies directory path will be made
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @remarks     'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see         service_adaptor_error_s
+* @remarks     'file_info' is needed memory free using 'service_storage_unref_file_info()'
+* @see         service_storage_unref_file_info()
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+int service_storage_make_directory(service_plugin_h handle,
+                                               const char *dir_path,
+                                               service_storage_file_h *file_info);
+
+/**
+* @brief Remove file in storage
+* @since_tizen 2.4
+* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
+* @see service_storage_file_h
+* @see service_storage_unref_file_info
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   file_path       specifies file path will be removed
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @remarks     'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see         service_adaptor_error_s
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+int service_storage_remove_file(service_plugin_h handle,
+                                               const char *file_path);
+
+/**
+* @brief Remove directory in storage
+* @since_tizen 2.4
+* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
+* @see service_storage_file_h
+* @see service_storage_unref_file_info
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   file_path       specifies directory path will be removed
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @remarks     'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see         service_adaptor_error_s
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+int service_storage_remove_directory(service_plugin_h handle,
+                                               const char *dir_path);
+
+/**
+* @brief Move file in storage
+* @since_tizen 2.4
+* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
+* @see service_storage_file_h
+* @see service_storage_unref_file_info
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   src_file_path   specifies source file path will move
+* @param[in]   dst_file_path   specifies destination file path will be moved
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @remarks     'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see         service_adaptor_error_s
+* @remarks     'file_info' is needed memory free using 'service_storage_unref_file_info()'
+* @see         service_storage_unref_file_info()
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+int service_storage_move_file(service_plugin_h handle,
+                                               const char *src_file_path,
+                                               const char *dst_file_path,
+                                               service_storage_file_h *file_info);
+
+/**
+* @brief Move directory in storage
+* @since_tizen 2.4
+* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
+* @see service_storage_file_h
+* @see service_storage_unref_file_info
+*
+* @param[in]   handle          specifies Service Adaptor handle
+* @param[in]   src_file_path   specifies source directory path will move
+* @param[in]   dst_file_path   specifies destination directory path will be moved
+* @param[out]  error_code      specifies error code
+* @param[in]   user_data       specifies user_data (json) passed in Server API
+* @remarks     'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see         service_adaptor_error_s
+* @remarks     'file_info' is needed memory free using 'service_storage_unref_file_info()'
+* @see         service_storage_unref_file_info()
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+int service_storage_move_directory(service_plugin_h handle,
+                                               const char *src_dir_path,
+                                               const char *dst_dir_path,
+                                               service_storage_file_h *file_info);
+
+/**
+* @brief Get directory entries in storage
+* @since_tizen 2.4
+*
+* @param[in]   handle                  specifies Service Adaptor handle
+* @param[in]   dir_path                specifies parent directory path
+* @param[out]  file_info_list          specifies file_info entries in 'dir_path'
+* @param[out]  file_info_list_len      specifies file_info entries count
+* @param[out]  error_code              specifies error code
+* @param[in]   user_data               specifies user_data (json) passed in Server API
+* @remarks     'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see         service_adaptor_error_s
+* @remarks     'file_info_list[<index>]' is needed memory free using 'service_storage_unref_file_info()'
+* @see         service_storage_unref_file_info()
+* @remarks     'file_info_list' is needed memory free using 'free()' after free for each element
+* @see         free()
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+int service_storage_get_directory_entries(service_plugin_h handle,
+                                               const char *dir_path,
+                                               service_storage_file_h **file_info_list,
+                                               unsigned int *file_info_list_len);
+
+
+/**
+* @brief Gets result after finishing storage task
+* @since_tizen 2.4
+*
+* @param[in]   task            The handle of storage task
+* @param[out]  result          The result information
+* @remarks     This function must be called after complete to specfic task
+* @remarks     When the <b>upload task</b> was finished, @a result is filled to #service_storage_file_h
+* @remarks     If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @see         service_storage_start_task()
+* @see         service_adaptor_get_last_result()
+* @see         service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED Permission denied
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre API prerequires #service_plugin_start()
+*/
+int service_storage_get_task_result(service_storage_task_h task,
+                                               void **result);
+
+#ifdef __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /*__TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_STORAGE_INTERNAL_H__*/
diff --git a/include/service_adaptor_client_type.h b/include/service_adaptor_client_type.h
new file mode 100644 (file)
index 0000000..af3ab76
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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 __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_TYPE_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_TYPE_H__
+
+#include <stdint.h>
+#include "service_adaptor_client.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define TASK_MESSAGE_FORWARD_ONLINE_MESSAGE    -100
+#define TASK_MESSAGE_FORWARD_UNREAD_MESSAGE    -101
+#define TASK_MESSAGE_CHANNEL_DISCONNECTED_MESSAGE      -102
+
+///////////////// private feature
+#define PRIVATE_SIGNAL_FILE_PROGRESS_ID                        11000
+#define PRIVATE_SIGNAL_FILE_TRANSFER_COMPLETION_ID     11001
+///////////////// private feature
+
+#define SIGNAL_STORAGE_FILE_PROGRESS_ID                1000
+#define SIGNAL_STORAGE_FILE_STATE_CHANGED_ID   1001
+#define SIGNAL_SERVICE_ADAPTOR                 9000
+
+//////////////////////////////////////////////////////////////////////////////////
+///// Signal Task area
+//////////////////////
+
+typedef struct _service_storage_task_s
+{
+       char *service_handle_name;
+       long long int task_id;  // file_uid (matched fd)
+       void *param1;
+       void *param2;
+       void *param3;
+
+       int operation;          // 1: upload, 2: download, 3:thumbnail (TEMP)
+       int state;
+       service_storage_task_state_cb state_callback;
+       void *state_user_data;
+       service_storage_task_progress_cb progress_callback;
+       void *progress_user_data;
+}service_storage_task_t;
+
+/**
+* @brief Describes infromation about task
+*/
+typedef struct _service_adaptor_task_s
+{
+       int64_t id;                     /**< specifies status as none*/
+       uint32_t callback;              /**< specifies status as none*/
+       void *handle;                   /**< specifies status as none*/
+       void *user_data;
+} service_adaptor_task_s;
+
+/**
+* @brief Describes infromation about Service Adaptor's error
+* @remarks 'msg' is need free()
+*/
+typedef struct _service_adaptor_error_s
+{
+       long long int code;                     /**< specifies status as none*/
+       char *msg;                              /**< specifies status as none*/
+} service_adaptor_error_s;
+
+#define __SAFE_STRDUP(x)        (x) ? strdup((x)) : NULL
+#define __SAFE_FREE(x)         do { free(x); (x) = NULL; } while (0)
+#define _assign_error_code(src, tgt)   do { \
+                                               sac_error("Error occured a : (%lld) (%s)", (long long int)((src)->code), (src)->msg); \
+                                               __assign_error_code((src), (tgt)); \
+                                       } while (0)
+
+#define _set_error_code(tgt, code, msg)        do { \
+                                               sac_error("Error occured b : (%d) (%s)", (int)(code), (msg)); \
+                                               __set_error_code((tgt), (code), (msg)); \
+                                       } while (0)
+
+
+/**
+* @brief The handle for Task
+*/
+typedef service_adaptor_task_s *service_adaptor_task_h;
+
+int _queue_add_task(int64_t id,
+                                               uint32_t callback,
+                                               void *handle,
+                                               void *user_data);
+
+int _queue_del_task(service_adaptor_task_h task);
+
+service_adaptor_task_h _queue_get_task(int64_t id);
+
+void _queue_clear_task(void);
+
+int _signal_queue_add_task(int64_t id,
+                                               uint32_t callback,
+                                               void *handle,
+                                               void *user_data);
+
+service_adaptor_task_h _signal_queue_get_task(int64_t id);
+
+int _signal_queue_del_task(service_adaptor_task_h task);
+
+void _signal_queue_clear_task(void);
+
+int service_adaptor_check_handle_validate(service_adaptor_h handle);
+
+
+/**
+ * @brief Enumerations of signal code for Service Adaptor
+ */
+typedef enum _service_adaptor_signal_code_e
+{
+       SERVICE_ADAPTOR_SIGNAL_INITIALIZED              = 1,    /* Service adaptor finished initalization */
+       SERVICE_ADAPTOR_SIGNAL_NEW_PLUGIN               = 2,    /* New Plugins loaded in a running time */
+       SERVICE_ADAPTOR_SIGNAL_ACTIVATE_PLUGIN          = 3,    /* Some Plugins be activated by policy or user atholization or etc */
+       SERVICE_ADAPTOR_SIGNAL_SHUTDOWN                 = 4,    /* Service adaptor was shutdowned by unsuspected issue */
+} service_adaptor_signal_code_e;
+
+//////////////////////
+///// Signal Task area
+//////////////////////////////////////////////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////////////////////////////////
+///// Storage Task area
+//////////////////////
+
+
+//////////////////////
+///// Storage Task area
+//////////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifdef __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_TYPE_H__ */
diff --git a/include/util/service_adaptor_client_util.h b/include/util/service_adaptor_client_util.h
new file mode 100644 (file)
index 0000000..c613ff1
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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 __TIZEN_SOCIAL_SERVICE_ADAPTOR_UTIL_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_UTIL_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include "service_adaptor_client_type.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char *_safe_strdup(const char *str);
+
+void __set_error_code(service_adaptor_error_s **error_code, int code, const char *msg);
+
+void __assign_error_code(service_adaptor_error_s *source_error, service_adaptor_error_s **target_error);
+
+int _get_result_code(long long int error_code);
+
+void _create_raw_data_from_plugin_property(void *property, GVariantBuilder **builder);
+
+static const int dbus_default_timeout_msec = 5000;
+
+#define sac_safe_add_string(str)       ((str) ? (str) : "")
+
+#define        ipc_check_proxy(proxy)  do { \
+               if (NULL == (proxy)) { \
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE; \
+                       error->msg = strdup("D-Bus interface proxy has NOT been initialized"); \
+                       return SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE; \
+               } \
+       } while (0)
+
+int _ipc_get_simple_result(GVariant *call_result, GError *g_error, service_adaptor_error_s *error);
+
+#define _ipc_get_complex_result(expected_type, __DO_WORK)      do { \
+       if (NULL == call_result) { \
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE; \
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE; \
+\
+               if (NULL != g_error) { \
+                       sac_error("G_IO_ERROR DEBUG (%d)", (int)(g_error->code)); \
+                       if (g_error->code == G_IO_ERROR_TIMED_OUT) { \
+                               ret = SERVICE_ADAPTOR_ERROR_TIMED_OUT; \
+                       } \
+                       error->msg = __SAFE_STRDUP(g_error->message); \
+                       g_error_free(g_error); \
+               } \
+       } else { \
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE((expected_type)))) { \
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE; \
+                       error->msg = strdup("D-Bus return type error"); \
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE; \
+               } else { \
+                       GVariant *call_result_struct[3]; \
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0); \
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1); \
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2); \
+\
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]); \
+\
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) { \
+                               error->code = remote_call_result; \
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]); \
+                               ret = _get_result_code(remote_call_result); \
+                       } else { \
+                               __DO_WORK \
+                       } \
+\
+                       g_variant_unref(call_result_struct[0]); \
+                       g_variant_unref(call_result_struct[1]); \
+                       g_variant_unref(call_result_struct[2]); \
+               } \
+\
+               g_variant_unref(call_result); \
+       } \
+} while (0)
+
+#define sac_check_param_null(val, val_name) {\
+       if (NULL == (val)) {\
+               sac_error ("\"%s\" is NULL, return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER(%d)", \
+                               (const char *)val_name, (int)SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);\
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;\
+       }\
+}
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_UTIL_H__ */
diff --git a/packaging/service-adaptor-client.spec b/packaging/service-adaptor-client.spec
new file mode 100644 (file)
index 0000000..e7ce50c
--- /dev/null
@@ -0,0 +1,61 @@
+Name:       service-adaptor-client
+Summary:    Service Adaptor API
+Version:    1.0.1
+Release:    1
+Group:      Social & Content
+License:    Apache-2.0
+Source0:    %{name}-%{version}.tar.gz
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(gobject-2.0)
+BuildRequires:  pkgconfig(gio-2.0)
+BuildRequires:  pkgconfig(gthread-2.0)
+BuildRequires:  pkgconfig(capi-base-common)
+BuildRequires:  pkgconfig(capi-appfw-application)
+BuildRequires:  pkgconfig(service-adaptor)
+BuildRequires:  pkgconfig(security-privilege-checker)
+BuildRequires:  pkgconfig(security-server)
+BuildRequires:  pkgconfig(bundle)
+BuildRequires:  service-adaptor-devel
+
+BuildRequires:  cmake
+
+%description
+Service Adaptor API
+
+%package -n service-adaptor-client-devel
+Summary:    Headers for Service Adaptor Client
+Group:      Development/Libraries
+Requires:   service-adaptor-client = %{version}-%{release}
+
+%description -n service-adaptor-client-devel
+This package contains the header and pc files.
+
+%prep
+%setup -q
+
+%build
+export PREFIX="/usr/apps/service-adaptor-client"
+export CFLAGS+=" -fPIC"
+export LDFLAGS+=" -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed -Wl,--hash-style=both"
+
+cmake . -DCMAKE_INSTALL_PREFIX="$PREFIX" -DVERSION=%{version} -DPACKAGE_NAME=%{name}
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+
+%files
+%manifest service-adaptor-client.manifest
+%defattr(-,root,root,-)
+%{_libdir}/libservice-adaptor-client.so
+#%{_bindir}/service-adaptor-client-test
+
+%files -n service-adaptor-client-devel
+%defattr(-,root,root,-)
+%{_includedir}/*.h
+%{_includedir}/service-adaptor-client/*.h
+%{_libdir}/pkgconfig/service-adaptor-client.pc
diff --git a/service-adaptor-client.manifest b/service-adaptor-client.manifest
new file mode 100644 (file)
index 0000000..007582e
--- /dev/null
@@ -0,0 +1,10 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+       <assign>
+               <filesystem path="/usr/lib/libservice-adaptor-client.so" exec_label="none" label="_"/>
+       </assign>
+
+</manifest>
+
diff --git a/service-adaptor-client.pc.in b/service-adaptor-client.pc.in
new file mode 100644 (file)
index 0000000..ee945df
--- /dev/null
@@ -0,0 +1,10 @@
+prefix=@PREFIX@
+libdir=@PREFIX@/lib
+includedir=@PREFIX@/include
+
+Name: @PACKAGE_NAME@
+Description: Service Adaptor API
+Requires: glib-2.0 gobject-2.0 gio-2.0 gthread-2.0 capi-base-common bundle
+Version: @VERSION@
+Libs: -L${libdir} -lservice-adaptor-client
+Cflags: -I${includedir}/service-adaptor-client
diff --git a/src/dbus/dbus_client.c b/src/dbus/dbus_client.c
new file mode 100644 (file)
index 0000000..511133e
--- /dev/null
@@ -0,0 +1,1047 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: dbus-client.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "service_adaptor_client_private.h"
+#include "dbus_client.h"
+#include "dbus_client_storage.h"
+#include "dbus_client_message.h"
+#include "dbus_client_push.h"
+#include "service-adaptor/dbus-server.h"
+
+#include "private/service-adaptor-client.h"
+#include "util/service_adaptor_client_util.h"
+
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/**
+ * Service Adaptor D-Bus client thread data
+ */
+typedef struct {
+       GMutex connection_mutex;        /* Mutex used to protect connection status data */
+       GCond connection_cond;          /* Conditional variable used to signal that connection was established */
+       int connection_cond_signaled;   /* Additional variable used to signal that connection was established */
+} dbus_service_adaptor_client_thread_data_s;
+
+/**
+ * D-Bus client thread.
+ */
+static GThread *dbusClientThread = NULL;
+
+/**
+ * D-Bus client thread main loop context.
+ */
+static GMainContext *dbusClientMainContext = NULL;
+
+/**
+ * D-Bus client thread main loop.
+ */
+static GMainLoop *dbusClientMainLoop = NULL;
+
+/**
+ * Service Adaptor D-Bus bus watcher id.
+ */
+static guint watcher_id = 0;
+
+/**
+ * D-Bus connection to vService Channel
+ */
+static GDBusConnection *connection = NULL;
+
+/**
+ * D-Bus proxy to Service Adaptor Client interface
+ */
+static GDBusProxy *sac_interface_proxy = NULL;
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+struct _internal_service_signal_data_s {
+       uint64_t code;
+       char *msg;
+       service_adaptor_task_h task;
+};
+
+static void *_on_dbus_disappeared_cb(void *data);
+
+/**
+ * @brief D-Bus client thread function.
+ *
+ * D-Bus client thread function. It initialises all client D-Bus interfaces.
+ * @param data Data passed to thread.
+ * @return Result data from thread (always NULL in this implementation).
+ */
+static gpointer __dbus_service_adaptor_client_thread(gpointer data);
+
+/**
+ * @brief Initialises Service Adaptor D-Bus client internal structures.
+ *
+ * Initialises Service Adaptor D-Bus client internal structures.
+ * @param thread_data Pointer to thread data used to signal that connection was successfully established.
+ * @return 0 on success, error code when some structures could not be initialised.
+ */
+static int __dbus_connection_init(dbus_service_adaptor_client_thread_data_s *thread_data);
+
+/**
+ * @brief Deinitialises Service Adaptor D-Bus client internal structures.
+ *
+ * Deinitialises Service Adaptor D-Bus client internal structures.
+ */
+static void __dbus_connection_deinit();
+
+/**
+ * @brief Service Adaptor availability callback function.
+ *
+ * Service Adaptor availability callback function. Called when Service Adaptor appears at D-Bus bus.
+ * @param connection D-Bus connection.
+ * @param name The name being watched.
+ * @param name_owner Unique name of the owner of the name being watched.
+ * @param user_data User data passed to g_bus_watch_name().
+ */
+static void on_name_appeared(GDBusConnection *connection,
+                                               const gchar *name,
+                                               const gchar *name_owner,
+                                               gpointer user_data);
+
+/**
+ * @brief Service Adaptor availability callback function.
+ *
+ * Service Adaptor availability callback function. Called when Service Adaptor disappears from D-Bus bus.
+ * @param connection D-Bus connection.
+ * @param name he name being watched.
+ * @param user_data User data passed to g_bus_watch_name().
+ */
+static void on_name_vanished(GDBusConnection *connection,
+                                               const gchar *name,
+                                               gpointer user_data);
+
+/**
+ * @brief Service Adaptor signals handler.
+ *
+ * Service Adaptor signals handler. It is called when Service Adaptor sends signal over D-Bus.
+ * @param proxy D-Bus proxy object.
+ * @param sender_name The unique bus name of the remote caller.
+ * @param signal_name Signal name.
+ * @param parameters Signal parameters.
+ * @param user_data The user_data gpointer.
+ */
+static void on_signal(GDBusProxy *proxy,
+                                               gchar *sender_name,
+                                               gchar *signal_name,
+                                               GVariant *parameters,
+                                               gpointer user_data);
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+static gpointer __dbus_service_adaptor_client_thread(gpointer data)
+{
+       FUNC_START();
+       int ret = 0;
+
+       dbusClientMainContext = g_main_context_new();
+       dbusClientMainLoop = g_main_loop_new(dbusClientMainContext, FALSE);
+       g_main_context_push_thread_default(dbusClientMainContext);
+
+       ret = __dbus_connection_init(data);
+
+       if (0 == ret) {
+               g_main_loop_run(dbusClientMainLoop);
+               __dbus_connection_deinit();
+       } else {
+               /* Already released dbus setting (=__dbus_connection_deinit()) */
+       }
+
+       g_main_context_pop_thread_default(dbusClientMainContext);
+       g_main_loop_unref(dbusClientMainLoop);
+       dbusClientMainLoop = NULL;
+       g_main_context_unref(dbusClientMainContext);
+       dbusClientMainContext = NULL;
+
+       FUNC_END();
+       return data;
+}
+
+static int __dbus_connection_init(dbus_service_adaptor_client_thread_data_s *thread_data)
+{
+       FUNC_START();
+       GError *error = NULL;
+
+       if ((NULL != connection) || (sac_interface_proxy)) {
+               FUNC_STOP();
+               return -1;
+       }
+
+       connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+
+       if (NULL == connection) {
+               g_error_free(error);
+
+               FUNC_STOP();
+               return -1;
+       } else {
+               sac_interface_proxy = g_dbus_proxy_new_sync(connection,
+                               G_DBUS_PROXY_FLAGS_NONE,
+                               NULL,
+                               SERVICE_ADAPTOR_BUS_NAME,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               NULL,
+                               &error);
+
+               if (NULL == sac_interface_proxy) {
+                       g_error_free(error);
+
+                       g_object_unref(connection);
+                       connection = NULL;
+
+                       FUNC_STOP();
+                       return -1;
+               }
+       }
+
+       watcher_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
+                       SERVICE_ADAPTOR_BUS_NAME,
+                       G_BUS_NAME_WATCHER_FLAGS_NONE,
+                       on_name_appeared,
+                       on_name_vanished,
+                       thread_data,
+                       NULL);
+
+       if (0 == watcher_id) {
+               g_object_unref(sac_interface_proxy);
+               sac_interface_proxy = NULL;
+
+               g_object_unref(connection);
+               connection = NULL;
+
+               FUNC_STOP();
+               return -1;
+       }
+
+       int res = g_signal_connect(sac_interface_proxy,
+                       "g-signal",
+                       G_CALLBACK(on_signal),
+                       NULL);
+
+       if (0 == res) {
+               g_object_unref(sac_interface_proxy);
+               sac_interface_proxy = NULL;
+
+               g_object_unref(connection);
+               connection = NULL;
+
+               g_bus_unwatch_name(watcher_id);
+               watcher_id = 0;
+
+               FUNC_STOP();
+               return -1;
+       }
+
+       FUNC_END();
+       return 0;
+}
+
+static void __dbus_connection_deinit()
+{
+       FUNC_START();
+       if (NULL != sac_interface_proxy) {
+               g_object_unref(sac_interface_proxy);
+               sac_interface_proxy = NULL;
+       }
+
+       if (NULL != connection) {
+               g_object_unref(connection);
+               connection = NULL;
+       }
+
+       if (0 != watcher_id) {
+               g_bus_unwatch_name(watcher_id);
+               watcher_id = 0;
+       }
+}
+
+static void on_name_appeared(GDBusConnection *connection,
+                                               const gchar *name,
+                                               const gchar *name_owner,
+                                               gpointer user_data)
+{
+       FUNC_START();
+       dbus_service_adaptor_client_thread_data_s *thread_data = (dbus_service_adaptor_client_thread_data_s *)user_data;
+
+       if (NULL != thread_data) {
+               g_mutex_lock(&thread_data->connection_mutex);
+               thread_data->connection_cond_signaled = 1;
+               g_cond_signal(&thread_data->connection_cond);
+               g_mutex_unlock(&thread_data->connection_mutex);
+       }
+       FUNC_END();
+}
+
+static void on_name_vanished(GDBusConnection *connection,
+                                               const gchar *name,
+                                               gpointer user_data)
+{
+       FUNC_START();
+       dbus_service_adaptor_client_thread_data_s *thread_data = (dbus_service_adaptor_client_thread_data_s *)user_data;
+
+       if ((NULL != thread_data) && (thread_data->connection_cond_signaled)) { /* appeared -> vanished */
+               if (0 != watcher_id) {
+                       g_bus_unwatch_name(watcher_id);
+                       watcher_id = 0;
+               }
+               pthread_t th;
+               pthread_create(&th, NULL, _on_dbus_disappeared_cb, NULL);
+       }
+       FUNC_END();
+}
+
+static void _service_signal_emitter(void *data)
+{
+       FUNC_START();
+       struct _internal_service_signal_data_s *signal_context =
+               (struct _internal_service_signal_data_s *) data;
+
+       service_adaptor_signal_cb callback = (service_adaptor_signal_cb) signal_context->task->callback;
+
+       if (NULL != callback) {
+               callback(signal_context->task->handle, (service_adaptor_signal_code_e) signal_context->code, signal_context->msg);/*, signal_context->task->user_data); */
+       }
+
+       g_free(signal_context->msg);
+       g_free(signal_context);
+       signal_context = NULL;
+
+       g_thread_unref(g_thread_self());
+       FUNC_END();
+}
+
+static void on_service_signal(GDBusProxy *proxy,
+                                               gchar *sender_name,
+                                               gchar *signal_name,
+                                               GVariant *parameters,
+                                               gpointer user_data)
+{
+       FUNC_START();
+
+       if (0 == g_strcmp0(signal_name, DBUS_SERVICE_ADAPTOR_SIGNAL)) {
+               service_adaptor_task_h task = _signal_queue_get_task(SIGNAL_SERVICE_ADAPTOR);
+
+               if (NULL == task) {
+                       FUNC_STOP();
+                       return;
+               }
+
+               struct _internal_service_signal_data_s *signal_context =
+                       (struct _internal_service_signal_data_s *)g_malloc0(sizeof(struct _internal_service_signal_data_s));
+
+               if (NULL == signal_context) {
+                       FUNC_STOP();
+                       return;
+               } else {
+                       signal_context->msg = NULL;
+                       signal_context->task = NULL;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 0);
+               call_result[1] = g_variant_get_child_value(parameters, 1);
+
+               signal_context->code = g_variant_get_uint64(call_result[0]);
+               signal_context->msg = ipc_g_variant_dup_string(call_result[1]);
+               signal_context->task = task;
+
+
+               GError *worker_error = NULL;
+               g_thread_try_new("service-adaptor-client-signal-emitter", (GThreadFunc) _service_signal_emitter,
+                               (void *) signal_context, &worker_error);
+
+               g_clear_error(&worker_error);
+               worker_error = NULL;
+       }
+
+       FUNC_END();
+}
+
+static void on_signal(GDBusProxy *proxy,
+                                               gchar *sender_name,
+                                               gchar *signal_name,
+                                               GVariant *parameters,
+                                               gpointer user_data)
+{
+       if (0 == strncmp(signal_name, DBUS_SERVICE_ADAPTOR, DBUS_NAME_LENGTH)) {
+               on_service_signal(proxy,
+                               sender_name,
+                               signal_name,
+                               parameters,
+                               user_data);
+       } else if (0 == strncmp(signal_name, DBUS_MESSAGE_ADAPTOR, DBUS_NAME_LENGTH)) {
+               on_message_signal(proxy,
+                               sender_name,
+                               signal_name,
+                               parameters,
+                               user_data);
+       } else if (0 == strncmp(signal_name, DBUS_STORAGE_ADAPTOR, DBUS_NAME_LENGTH)) {
+               on_storage_signal(proxy,
+                               sender_name,
+                               signal_name,
+                               parameters,
+                               user_data);
+       } else if (0 == strncmp(signal_name, DBUS_PUSH_ADAPTOR, DBUS_NAME_LENGTH)) {
+               on_push_signal(proxy,
+                               sender_name,
+                               signal_name,
+                               parameters,
+                               user_data);
+       }
+
+}
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+GDBusProxy *_dbus_get_sac_interface_proxy()
+{
+       return sac_interface_proxy;
+}
+
+/**    @brie
+ *     @return int
+ *     @remarks :
+ */
+int _dbus_client_service_adaptor_init()
+{
+       FUNC_START();
+#if !GLIB_CHECK_VERSION(2, 32, 0)
+       g_thread_init(NULL);
+#endif
+#if !GLIB_CHECK_VERSION(2, 35, 0)
+       g_type_init();
+#endif
+
+       if (NULL != dbusClientThread) {
+               /* D-Bus client thread is already running */
+               FUNC_STOP();
+               return -1;
+       }
+
+       dbus_service_adaptor_client_thread_data_s *thread_data =
+                       (dbus_service_adaptor_client_thread_data_s *) calloc(1, sizeof(dbus_service_adaptor_client_thread_data_s));
+
+       if (NULL == thread_data) {
+               FUNC_STOP();
+               return -1;
+       }
+
+       g_mutex_init(&thread_data->connection_mutex);
+       g_cond_init(&thread_data->connection_cond);
+       thread_data->connection_cond_signaled = 0;
+
+       dbusClientThread = g_thread_new("Service Adaptor D-Bus Client Thread", __dbus_service_adaptor_client_thread, thread_data);
+
+       gint64 timeout = g_get_monotonic_time() + 15 * G_TIME_SPAN_SECOND;
+       g_mutex_lock(&thread_data->connection_mutex);
+       while (!thread_data->connection_cond_signaled) {
+               if (!g_cond_wait_until(&thread_data->connection_cond, &thread_data->connection_mutex, timeout)) {
+                       /* timeout */
+                       g_mutex_unlock(&thread_data->connection_mutex);
+
+                       FUNC_STOP();
+                       return -1;
+               }
+       }
+       g_mutex_unlock(&thread_data->connection_mutex);
+
+       FUNC_END();
+       return 0;
+}
+
+/**    @brief
+ *     @return void
+ *     @remarks :
+ */
+void _dbus_client_service_adaptor_deinit()
+{
+       FUNC_START();
+       if (NULL != dbusClientMainLoop) {
+               if (g_main_loop_is_running(dbusClientMainLoop)) {
+                       g_main_loop_quit(dbusClientMainLoop);
+               }
+       }
+
+       if (NULL != dbusClientThread) {
+               gpointer data = g_thread_join(dbusClientThread);
+               if (NULL != data) {     /* thread passed data must be free here */
+                       free(data);
+               }
+               dbusClientThread = NULL;
+       }
+
+       if (NULL != dbusClientMainLoop) {
+               g_main_loop_unref(dbusClientMainLoop);
+               dbusClientMainLoop = NULL;
+       }
+
+       if (NULL != dbusClientMainContext) {
+               g_main_context_pop_thread_default(dbusClientMainContext);
+               g_main_context_unref(dbusClientMainContext);
+               dbusClientMainContext = NULL;
+       }
+
+       _queue_clear_task();
+       _signal_queue_clear_task();
+       FUNC_END();
+}
+
+/**
+ * Adds string into variant builder
+ * @param builder Builder
+ * @param data String to be added
+ */
+void __safe_g_variant_builder_add_string(GVariantBuilder *builder,
+                                               const char *data)
+{
+       if (NULL == data) {
+               g_variant_builder_add(builder, "s", "");
+       } else {
+               g_variant_builder_add(builder, "s", data);
+       }
+}
+
+void __safe_g_variant_builder_add_array_string(GVariantBuilder *builder,
+                                               const char *data)
+{
+       if (NULL == data) {
+               g_variant_builder_add(builder, "(s)", "");
+       } else {
+               g_variant_builder_add(builder, "(s)", data);
+       }
+}
+
+char *ipc_g_variant_dup_string(GVariant *string)
+{
+       char *ret = g_variant_dup_string(string, NULL);
+
+       if (0 == strcmp(ret, "")) {
+               free(ret);
+               ret = NULL;
+       }
+
+       return ret;
+}
+
+/**    @brief
+ *     @return service_adaptor_error_s
+ *     @remarks :
+ */
+int _dbus_connect_service_adaptor(service_adaptor_error_s *error)
+{
+       FUNC_START();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_CONNECT_SERVICE_ADAPTOR_METHOD,
+                       NULL,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       -1,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[2];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+                               ret = SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED;
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       FUNC_END();
+       return ret;
+}
+
+
+int _dbus_get_plugin_list(plugin_entry_t ***plugin_list,
+                                               unsigned int *plugins_len,
+                                               service_adaptor_error_s *error)
+{
+       FUNC_START();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_GET_AUTH_PLUGIN_LIST_METHOD,
+                       g_variant_new("(s)",
+                                       "temp_todo_remove"), /*TODO */
+                       G_DBUS_CALL_FLAGS_NONE,
+                       -1,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(plugin_list_type)))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED;
+                       } else {
+                               gsize list_count = g_variant_n_children(call_result_struct[0]);
+
+                               *plugins_len = (unsigned int) (list_count);
+                               plugin_entry_t **plugins = NULL;
+                               plugins = (plugin_entry_t **) calloc((*plugins_len), sizeof(plugin_entry_t *));
+
+                               if (NULL != plugins) {
+                                       for (gsize i = 0; i < list_count; i++) {
+                                               GVariant *plugin_info_struct[service_adaptor_plugin_s_type_length];
+                                               GVariant *plugin_info_entry_v = g_variant_get_child_value(call_result_struct[0], i);
+
+                                               for (size_t j = 0; j < service_adaptor_plugin_s_type_length; j++) {
+                                                       plugin_info_struct[j] = g_variant_get_child_value(plugin_info_entry_v, j);
+                                               }
+
+                                               plugins[i] = (plugin_entry_t *) calloc(1, sizeof(plugin_entry_t));
+
+                                               int idx = 0;
+                                               plugins[i]->plugin_uri = ipc_g_variant_dup_string(plugin_info_struct[idx++]);
+                                               plugins[i]->installed_mask = g_variant_get_int32(plugin_info_struct[idx++]);
+
+                                               for (size_t j = 0; j < service_adaptor_plugin_s_type_length; j++) {
+                                                       g_variant_unref(plugin_info_struct[j]);
+                                               }
+                                       }
+                                       *plugin_list = plugins;
+                               } else {
+                                       *plugins_len = (unsigned int) 0;
+                                       ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+                               }
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       FUNC_END();
+       return ret;
+}
+
+int _dbus_is_login_required(service_plugin_h plugin,
+                                               bool *required,
+                                               service_adaptor_error_s *error)
+{
+       FUNC_START();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariantBuilder *builder_in = NULL;
+       _create_raw_data_from_plugin_property((void *)(plugin->optional_property), &builder_in);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_IS_AUTH_METHOD,
+                       g_variant_new("(" service_adaptor_is_auth_req_s_type ")",
+                                       plugin->plugin_uri,
+                                       builder_in),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       bool is_auth = false;
+
+       _ipc_get_complex_result(MAKE_RETURN_TYPE("(b)"),
+
+               GVariant *res_info_struct = g_variant_get_child_value(call_result_struct[0], 0);
+               is_auth = g_variant_get_boolean(res_info_struct);
+               g_variant_unref(res_info_struct);
+       );
+
+       *required = !is_auth;
+
+       return ret;
+}
+
+struct __login_request_context {
+       void *callback;
+       void *user_data;
+};
+
+static void __dbus_login_result_callback(GObject *source_object,
+                                               GAsyncResult *res,
+                                               gpointer user_data)
+{
+
+       service_adaptor_error_s error = {0LL, NULL};
+       GError *g_error = NULL;
+
+       GVariant *result_obj = g_dbus_proxy_call_finish(_dbus_get_sac_interface_proxy(), res, &g_error);
+       int result = _ipc_get_simple_result(result_obj, g_error, &error);
+       if (SERVICE_ADAPTOR_ERROR_NONE != result) {
+               service_adaptor_set_last_result(error.code, error.msg);
+       }
+
+       struct __login_request_context *context = (struct __login_request_context *)user_data;
+       service_plugin_login_cb callback = (service_plugin_login_cb)(context->callback);
+
+       callback(result, context->user_data);
+
+       free(context);
+       if (g_error) {
+               g_error_free(g_error);
+       }
+}
+
+int _dbus_request_login(service_plugin_h plugin,
+                                               void *callback,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       FUNC_START();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       struct __login_request_context *context = (struct __login_request_context *)calloc(1, sizeof(struct __login_request_context));
+       if (NULL == context) {
+               error->code = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+               error->msg = strdup("Memory allocation failed");
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+       context->callback = callback;
+       context->user_data = user_data;
+
+       GVariantBuilder *builder_in = NULL;
+       _create_raw_data_from_plugin_property((void *)(plugin->optional_property), &builder_in);
+
+       g_dbus_proxy_call(sac_interface_proxy,
+                       DBUS_JOIN_METHOD,
+                       g_variant_new("(" service_adaptor_join_req_s_type ")",
+                                       plugin->plugin_uri,
+                                       builder_in),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       __dbus_login_result_callback,
+                       (void *)context);
+
+       return ret;
+}
+
+int _dbus_start_service(service_plugin_h plugin,
+                                               int service_flag,
+                                               const char *security_cookie,
+                                               service_adaptor_error_s *error)
+{
+       FUNC_START();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       char *app_id = NULL;
+       char *app_secret = NULL;
+       char *user_id = NULL;
+       char *user_password = "";
+
+       if (NULL != plugin->optional_property) {
+               app_id = (char *) g_hash_table_lookup((GHashTable *)plugin->optional_property, (gconstpointer) SERVICE_PLUGIN_PROPERTY_APP_KEY);
+               app_secret = (char *) g_hash_table_lookup((GHashTable *)plugin->optional_property, (gconstpointer) SERVICE_PLUGIN_PROPERTY_APP_SECRET);
+               user_id = (char *) g_hash_table_lookup((GHashTable *)plugin->optional_property, (gconstpointer) SERVICE_PLUGIN_PROPERTY_USER_ID);
+       }
+
+       GVariantBuilder *builder_in = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+       for (int k = 0; k < (SECURITY_SERVER_COOKIE_BUFFER_SIZE - 1); k++) {
+               g_variant_builder_add(builder_in, "(y)", (guchar)security_cookie[k]);
+       }
+
+       GVariantBuilder *builder_property = NULL;
+       _create_raw_data_from_plugin_property((void *)(plugin->optional_property), &builder_property);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_SET_AUTH_METHOD,
+                       g_variant_new("(" service_adaptor_set_auth_s_type ")",
+                                       builder_in,
+                                       builder_property,
+                                       plugin->service_handle_name,
+                                       plugin->plugin_uri,
+                                       app_id ? app_id : "",
+                                       app_secret ? app_secret : "",
+                                       user_id ? user_id : "",
+                                       user_password,
+                                       service_flag),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       -1,
+                       NULL,
+                       &g_error);
+
+       g_variant_builder_unref(builder_in);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[2];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+                               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_external_request(const char *service_name,
+                                               int service_flag,
+                                               const char *api_uri,
+                                               unsigned char *input_str,
+                                               int input_len,
+                                               unsigned char **output_str,
+                                               int *output_len,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariantBuilder *builder_in = g_variant_builder_new(G_VARIANT_TYPE(service_adaptor_raw_data_s_type));
+       for (int k = 0; k < input_len; k++) {
+               g_variant_builder_add(builder_in, "(y)", (guchar)input_str[k]);
+       }
+
+       sac_debug_func("input_str_len(%d)", input_len);
+       /* sac_debug_func("input_str(%s)", input_str); */
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_EXTERNAL_REQ_METHOD,
+                       g_variant_new("(" private_service_adaptor_external_req_s_type ")",
+                                       service_name,
+                                       (int32_t) service_flag,
+                                       api_uri,
+                                       builder_in),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       -1,
+                       NULL,
+                       &g_error);
+
+       g_variant_builder_unref(builder_in);
+
+       sac_debug("%s API sent", PRIVATE_DBUS_EXTERNAL_REQ_METHOD);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(service_adaptor_raw_data_s_type)))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       FUNC_STEP();
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED;
+                       } else {
+
+                               int raw_data_len = g_variant_n_children(call_result_struct[0]);
+                               unsigned char *raw_data = (unsigned char *) calloc((raw_data_len + 1), sizeof(unsigned char));
+
+                               if (NULL != raw_data) {
+                                       for (int k = 0; k < raw_data_len; k++) {
+                                               g_variant_get_child(call_result_struct[0], k, "(y)", &(raw_data[k]));
+                                       }
+                                       *output_str = raw_data;
+                                       *output_len = raw_data_len;
+                               }
+                               sac_debug_func("output_str_len(%d)", raw_data_len);
+                               /* sac_debug_func("output_str(%s)", raw_data); */
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+static void *_on_dbus_disappeared_cb(void *data)
+{
+       FUNC_START();
+       __dbus_connection_deinit();
+       service_adaptor_task_h task = _signal_queue_get_task(SIGNAL_SERVICE_ADAPTOR);
+
+       if (NULL == task) {
+               FUNC_STOP();
+               return NULL;
+       }
+
+       struct _internal_service_signal_data_s *signal_context =
+               (struct _internal_service_signal_data_s *)g_malloc0(sizeof(struct _internal_service_signal_data_s));
+
+       if (NULL == signal_context) {
+               FUNC_STOP();
+               return NULL;
+       } else {
+               signal_context->msg = NULL;
+               signal_context->task = NULL;
+       }
+
+       signal_context->code = (int64_t) SERVICE_ADAPTOR_SIGNAL_SHUTDOWN;
+       signal_context->msg = strdup("Service-adaptor DBus interface was vanished");
+       signal_context->task = task;
+
+       GError *worker_error = NULL;
+       g_thread_try_new("service-adaptor-client-signal-emitter", (GThreadFunc) _service_signal_emitter,
+                       (void *) signal_context, &worker_error);
+
+       g_clear_error(&worker_error);
+       worker_error = NULL;
+
+       FUNC_END();
+       return NULL;
+}
diff --git a/src/dbus/dbus_client_auth.c b/src/dbus/dbus_client_auth.c
new file mode 100644 (file)
index 0000000..ef2d199
--- /dev/null
@@ -0,0 +1,212 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: dbus-client-auth.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include "dbus_client.h"
+#include "dbus_client_auth.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "service-adaptor/dbus-server.h"
+#include "private/service-adaptor-client-auth.h"
+
+#include "util/service_adaptor_client_util.h"
+
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+/**    @brief
+ *     @return service_adaptor_error_s
+ *     @remarks :
+ */
+int _dbus_get_auth_plugin_list(GList **plugin_list,
+                                               const char *imsi,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_GET_AUTH_PLUGIN_LIST_METHOD,
+                       g_variant_new("(s)",
+                                       imsi),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       -1,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_plugin_list_type)))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED;
+                       } else {
+                               gsize list_count = g_variant_n_children(call_result_struct[0]);
+
+                               for (gsize i = 0; i < list_count; i++) {
+                                       GVariant *plugin_info_struct[private_service_adaptor_plugin_s_type_length];
+                                       GVariant *plugin_info_entry_v = g_variant_get_child_value(call_result_struct[0], i);
+                                       service_adaptor_plugin_s *info = (service_adaptor_plugin_s *) g_malloc0(sizeof(service_adaptor_plugin_s));
+
+                                       for (size_t j = 0; j < private_service_adaptor_plugin_s_type_length; j++) {
+                                               plugin_info_struct[j] = g_variant_get_child_value(plugin_info_entry_v, j);
+                                       }
+
+                                       int idx = 0;
+                                       info->name = ipc_g_variant_dup_string(plugin_info_struct[idx++]);
+                                       info->login = g_variant_get_boolean(plugin_info_struct[idx++]);
+
+                                       for (size_t j = 0; j < private_service_adaptor_plugin_s_type_length; j++) {
+                                               g_variant_unref(plugin_info_struct[j]);
+                                       }
+
+                                       *plugin_list = g_list_append(*plugin_list, info);
+                               }
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+/**    @brief
+ *     @return service_adaptor_error_s
+ *     @remarks :
+ */
+int _dbus_set_auth(const char *service_name,
+                                               const char *imsi,
+                                               const char *plugin_name,
+                                               const char *app_id,
+                                               const char *app_secret,
+                                               unsigned int service_id,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_SET_AUTH_METHOD,
+                       g_variant_new("(" private_service_adaptor_set_auth_s_type ")",
+                                       service_name, imsi, plugin_name, app_id, app_secret, "", "", service_id),
+                       G_DBUS_CALL_FLAGS_NONE,
+                       -1,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       sac_error("G_IO_ERROR DEBUG (%d)", (int)(g_error->code));
+                       if (g_error->code == G_IO_ERROR_TIMED_OUT) {
+                               error->code = SERVICE_ADAPTOR_ERROR_NETWORK;
+                               ret = SERVICE_ADAPTOR_ERROR_NETWORK;
+                       }
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[2];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+                               ret = _get_result_code(remote_call_result);
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
diff --git a/src/dbus/dbus_client_contact.c b/src/dbus/dbus_client_contact.c
new file mode 100644 (file)
index 0000000..fffda91
--- /dev/null
@@ -0,0 +1,1322 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: dbus-client-contact.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include "dbus_client.h"
+#include "dbus_client_contact.h"
+#include "service-adaptor/dbus-server.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "private/service-adaptor-client-contact.h"
+
+#include "util/service_adaptor_client_util.h"
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+static void __safe_g_variant_builder_add_contact_string(GVariantBuilder *builder,
+                                               const char *data)
+{
+       if (NULL == data) {
+               g_variant_builder_add(builder, "s", "");
+       } else {
+               char *_data = g_strconcat(" ", data, NULL);
+               g_variant_builder_add(builder, "s", _data);
+               free(_data);
+       }
+}
+
+static char *__safe_dup_contact_string(char *data)
+{
+       char *str = __safe_add_string(data);
+       char *ret = NULL;
+       if (0 < strlen(str)) {
+               ret = g_strconcat(" ", str, NULL);
+       } else {
+               ret = strdup(str);
+       }
+
+       return ret;
+}
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+GVariant *__create_contact_req_type(const char *service_name,
+                                               service_adaptor_contact_req_s *contact_req,
+                                               void *user_data)
+{
+       GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE(private_contact_info_req_list_type));
+
+       for (int i = 0; i < contact_req->cts_len; i++) {
+               g_variant_builder_open(builder, G_VARIANT_TYPE(private_service_adaptor_contact_info_req_s_type));
+               __safe_g_variant_builder_add_string(builder, contact_req->cts[i]->tp);
+               __safe_g_variant_builder_add_string(builder, contact_req->cts[i]->id);
+               __safe_g_variant_builder_add_string(builder, contact_req->cts[i]->pn);
+               __safe_g_variant_builder_add_contact_string(builder, contact_req->cts[i]->nm);
+               __safe_g_variant_builder_add_string(builder, contact_req->cts[i]->cc);
+               g_variant_builder_close(builder);
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_contact_req_s_type ")", __safe_add_string(service_name), contact_req->tt, builder, contact_req->cts_len);
+
+       g_variant_builder_unref(builder);
+
+       return request;
+}
+
+void __get_contact_res_type(GVariant *call_result_struct,
+                                               service_adaptor_contact_res_s **contact_res,
+                                               void **server_data)
+{
+       GVariant *res_info_struct[private_service_adaptor_contact_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_contact_res_s_type_length; j++) {
+               res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+       }
+
+       int idx = 0;
+       *contact_res = (service_adaptor_contact_res_s *) calloc(1, sizeof(service_adaptor_contact_res_s));
+
+       if (NULL != (*contact_res)) {
+               (*contact_res)->tt = g_variant_get_int64(res_info_struct[idx++]);
+               sac_info("tt : %lld", (*contact_res)->tt);
+
+               /* cts list */
+               gsize cts_count = g_variant_n_children(res_info_struct[idx]);
+               sac_info("cts count : %d", (int)cts_count);
+
+               if (0 == cts_count) {
+                       (*contact_res)->cts_len = 0;
+                       sac_info("cts len : %u", (*contact_res)->cts_len);
+
+                       for (size_t j = 0; j < private_service_adaptor_contact_res_s_type_length; j++) {
+                               g_variant_unref(res_info_struct[j]);
+                       }
+                       return;
+               }
+
+               (*contact_res)->cts = (service_adaptor_contact_info_res_s **) calloc(cts_count, sizeof(service_adaptor_contact_info_res_s*));
+
+               if (NULL == ((*contact_res)->cts)) {
+                       sac_error("Critical : Memory allocation failed");
+                       (*contact_res)->cts_len = 0;
+
+                       for (size_t j = 0; j < private_service_adaptor_contact_res_s_type_length; j++) {
+                               g_variant_unref(res_info_struct[j]);
+                       }
+                       return;
+               }
+               for (gsize i = 0; i < cts_count; i++) {
+                       GVariant *cts_info_struct[private_service_adaptor_contact_info_res_s_type_length];
+                       GVariant *cts_info_entry_v = g_variant_get_child_value(res_info_struct[idx], i);
+
+                       (*contact_res)->cts[i] = (service_adaptor_contact_info_res_s *) calloc(1, sizeof(service_adaptor_contact_info_res_s));
+
+                       if (NULL != ((*contact_res)->cts[i])) {
+                               for (size_t j = 0; j < private_service_adaptor_contact_info_res_s_type_length; j++) {
+                                       cts_info_struct[j] = g_variant_get_child_value(cts_info_entry_v, j);
+                               }
+
+                               int idx2 = 0;
+                               (*contact_res)->cts[i]->duid = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+                               (*contact_res)->cts[i]->id = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+                               (*contact_res)->cts[i]->msisdn = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+                               (*contact_res)->cts[i]->ty = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+                               (*contact_res)->cts[i]->cc = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+                               (*contact_res)->cts[i]->pn = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+                               (*contact_res)->cts[i]->nm = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+
+                               /* evnt list */
+                               gsize evnt_count = g_variant_n_children(cts_info_struct[idx2]);
+                               (*contact_res)->cts[i]->evnt = (char **) calloc(evnt_count, sizeof(char *));
+
+                               if (NULL != ((*contact_res)->cts[i]->evnt)) {
+                                       for (gsize k = 0; k < evnt_count; k++) {
+                                               GVariant *evnt_info_struct;
+                                               GVariant *evnt_info_entry_v = g_variant_get_child_value(cts_info_struct[idx2], k);
+                                               evnt_info_struct = g_variant_get_child_value(evnt_info_entry_v, 0);
+
+                                               (*contact_res)->cts[i]->evnt[k] = ipc_g_variant_dup_string(evnt_info_struct);
+
+                                               g_variant_unref(evnt_info_struct);
+                                       }
+                               }
+                               idx2++;
+                               /* evnt list */
+
+                               (*contact_res)->cts[i]->evnt_len = g_variant_get_uint32(cts_info_struct[idx2++]);
+
+                               /* image list */
+                               gsize img_count = g_variant_n_children(cts_info_struct[idx2]);
+                               sac_info("img_count : %d", (int)img_count);
+                               (*contact_res)->cts[i]->images = (service_adaptor_profile_image_h *) calloc(img_count, sizeof(service_adaptor_profile_image_h));
+
+                               if (NULL != ((*contact_res)->cts[i]->images)) {
+                                       for (gsize k = 0; k < img_count; k++) {
+                                               (*contact_res)->cts[i]->images[k] = (service_adaptor_profile_image_h) calloc(1, sizeof(struct _service_adaptor_profile_image_s));
+                                               if (NULL != (*contact_res)->cts[i]->images[k]) {
+                                                       GVariant *img_info_struct[2];
+                                                       GVariant *img_info_entry_v = g_variant_get_child_value(cts_info_struct[idx2], k);
+                                                       img_info_struct[0] = g_variant_get_child_value(img_info_entry_v, 0);
+
+                                                       img_info_struct[1] = g_variant_get_child_value(img_info_entry_v, 1);
+
+                                                       (*contact_res)->cts[i]->images[k]->index = g_variant_get_int32(img_info_struct[0]);
+                                                       sac_info("Test (image index : %d)", (*contact_res)->cts[i]->images[k]->index);
+                                                       char *path = ipc_g_variant_dup_string(img_info_struct[1]);
+                                                       sac_info("Test (path : %s)", path);
+
+                                                       if (NULL != path) {
+                                                               strncpy((*contact_res)->cts[i]->images[k]->path, path, (CONTACT_PROFILE_IMAGE_PATH_LEN - 1));
+                                                       }
+
+                                                       g_variant_unref(img_info_struct[0]);
+                                                       g_variant_unref(img_info_struct[1]);
+                                               }
+                                       }
+                               }
+                               idx2++;
+                               /* image list */
+
+                               (*contact_res)->cts[i]->images_len = g_variant_get_uint32(cts_info_struct[idx2++]);
+
+
+                               /*(*contact_res)->cts[i]->img = ipc_g_variant_dup_string(cts_info_struct[idx2++]);*/
+
+                               /* adrs list */
+                               gsize adrs_count = g_variant_n_children(cts_info_struct[idx2]);
+                               (*contact_res)->cts[i]->adrs = (char **) calloc(adrs_count, sizeof(char *));
+
+                               if (NULL != ((*contact_res)->cts[i]->adrs)) {
+                                       for (gsize k = 0; k < adrs_count; k++) {
+                                               GVariant *adrs_info_struct;
+                                               GVariant *adrs_info_entry_v = g_variant_get_child_value(cts_info_struct[idx2], k);
+                                               adrs_info_struct = g_variant_get_child_value(adrs_info_entry_v, 0);
+
+                                               (*contact_res)->cts[i]->adrs[k] = ipc_g_variant_dup_string(adrs_info_struct);
+
+                                               g_variant_unref(adrs_info_struct);
+                                       }
+                               }
+                               idx2++;
+                               /* adrs list */
+
+                               (*contact_res)->cts[i]->adrs_len = g_variant_get_uint32(cts_info_struct[idx2++]);
+
+                               /* mail list */
+                               gsize mail_count = g_variant_n_children(cts_info_struct[idx2]);
+                               (*contact_res)->cts[i]->mail = (char **) calloc(mail_count, sizeof(char *));
+
+                               if (NULL != ((*contact_res)->cts[i]->mail)) {
+                                       for (gsize k = 0; k < mail_count; k++) {
+                                               GVariant *mail_info_struct;
+                                               GVariant *mail_info_entry_v = g_variant_get_child_value(cts_info_struct[idx2], k);
+                                               mail_info_struct = g_variant_get_child_value(mail_info_entry_v, 0);
+
+                                               (*contact_res)->cts[i]->mail[k] = ipc_g_variant_dup_string(mail_info_struct);
+
+                                               g_variant_unref(mail_info_struct);
+                                       }
+                               }
+                               idx2++;
+                               /* mail list */
+
+                               (*contact_res)->cts[i]->mail_len = g_variant_get_uint32(cts_info_struct[idx2++]);
+                               (*contact_res)->cts[i]->org = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+                               (*contact_res)->cts[i]->prsc = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+                               (*contact_res)->cts[i]->status = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+                               (*contact_res)->cts[i]->sids = g_variant_get_uint32(cts_info_struct[idx2++]);
+                               (*contact_res)->cts[i]->profile_type = g_variant_get_int32(cts_info_struct[idx2++]);
+                               (*contact_res)->cts[i]->profile_url = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+
+                               for (size_t j = 0; j < private_service_adaptor_contact_info_res_s_type_length; j++) {
+                                       g_variant_unref(cts_info_struct[j]);
+                               }
+                       }
+               }
+               idx++;
+               /* cts list */
+
+               (*contact_res)->cts_len = g_variant_get_uint32(res_info_struct[idx++]);
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_contact_res_s_type_length; j++) {
+               g_variant_unref(res_info_struct[j]);
+       }
+}
+
+GVariant *__create_profile_req_type(const char *service_name,
+                                               service_adaptor_profile_req_s *profile_req,
+                                               void *user_data)
+{
+       GVariantBuilder *evnt_builder = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
+
+       for (gsize j = 0; j < profile_req->evnt_len; j++) {
+               __safe_g_variant_builder_add_array_string(evnt_builder, profile_req->evnt[j]);
+       }
+
+       GVariantBuilder *adrs_builder = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
+
+       for (gsize j = 0; j < profile_req->adrs_len; j++) {
+               __safe_g_variant_builder_add_array_string(adrs_builder, profile_req->adrs[j]);
+       }
+
+       GVariantBuilder *mail_builder = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
+
+       for (gsize j = 0; j < profile_req->mail_len; j++) {
+               __safe_g_variant_builder_add_array_string(mail_builder, profile_req->mail[j]);
+       }
+
+       char *converted_nm = __safe_dup_contact_string(profile_req->nm);
+       GVariant *request = g_variant_new("(" private_service_adaptor_profile_req_s_type ")", __safe_add_string(service_name),
+                       __safe_add_string(profile_req->cc), __safe_add_string(profile_req->pn), converted_nm,
+                       evnt_builder, profile_req->evnt_len,
+                       __safe_add_string(profile_req->img),
+                       adrs_builder, profile_req->adrs_len, mail_builder, profile_req->mail_len,
+                       __safe_add_string(profile_req->org), __safe_add_string(profile_req->prsc), __safe_add_string(profile_req->status));
+       free(converted_nm);
+
+       g_variant_builder_unref(evnt_builder);
+       g_variant_builder_unref(adrs_builder);
+       g_variant_builder_unref(mail_builder);
+
+       return request;
+}
+
+void __get_profile_res_type(GVariant *call_result_struct,
+                                               service_adaptor_profile_res_s **profile_res,
+                                               void **server_data)
+{
+       GVariant *res_info_struct[private_service_adaptor_profile_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_profile_res_s_type_length; j++) {
+               res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+       }
+
+       int idx = 0;
+       *profile_res = (service_adaptor_profile_res_s *) calloc(1, sizeof(service_adaptor_profile_res_s));
+       if (NULL != *profile_res) {
+               (*profile_res)->nm = ipc_g_variant_dup_string(res_info_struct[idx++]);
+               (*profile_res)->img = ipc_g_variant_dup_string(res_info_struct[idx++]);
+               (*profile_res)->prsc = ipc_g_variant_dup_string(res_info_struct[idx++]);
+               (*profile_res)->status = ipc_g_variant_dup_string(res_info_struct[idx++]);
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_profile_res_s_type_length; j++) {
+               g_variant_unref(res_info_struct[j]);
+       }
+}
+
+GVariant *__create_del_me_profile_req_type(const char *service_name,
+                                               void *user_data)
+{
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_essential_s_type ")", __safe_add_string(service_name));
+
+
+       return request;
+}
+
+
+GVariant *__create_file_path_req_type(const char *service_name,
+                                               service_adaptor_profile_image_h *images,
+                                               unsigned int images_len,
+                                               void *user_data)
+{
+
+
+       if (NULL == images) {
+               images_len = 0;
+       }
+
+       GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(iis)"));
+
+       for (int j = 0; j < images_len; j++) {
+               sac_debug_func("[DBG] Set me profile image meta Params %dth [DBG]", j);
+               sac_debug_func("type (%d) index (%d) path (%s)", images[j]->type, images[j]->index, images[j]->path);
+               g_variant_builder_add(builder, "(iis)", (int32_t)(images[j]->type), (int32_t)images[j]->index, __safe_add_string(images[j]->path));
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_contact_profile_image_req_s_type ")", __safe_add_string(service_name),  builder, images_len);
+
+       g_variant_builder_unref(builder);
+
+       return request;
+}
+
+void __get_failed_image_meta_res_type(GVariant *call_result_struct,
+                                               service_adaptor_profile_image_h **images,
+                                               unsigned int *images_len)
+{
+       GVariant *res_info_struct[private_service_adaptor_contact_profile_image_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_contact_profile_image_req_s_type_length; j++) {
+               res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+       }
+       int idx = 0;
+       idx++;  /* skip first value */
+       gsize list_count = g_variant_n_children(res_info_struct[idx]);
+
+       if (0 < list_count) {
+               *images = (service_adaptor_profile_image_h *) calloc(list_count, sizeof(service_adaptor_profile_image_h));
+               if (NULL == (*images)) {
+                       sac_error("Critical : Memory allocation failed!!");
+               } else {
+                       for (int i = 0; i < list_count; i++) {
+                               (*images)[i] = (service_adaptor_profile_image_h)calloc(1, sizeof(struct _service_adaptor_profile_image_s));
+                               if (NULL == ((*images)[i])) {
+                                       sac_error("Critical : Memory allocation failed!!");
+                               } else {
+                                       GVariant *path_info_struct[3] = {NULL, };
+                                       GVariant *path_info_entry_v = g_variant_get_child_value(res_info_struct[idx], i);
+                                       path_info_struct[0] = g_variant_get_child_value(path_info_entry_v, 0);
+                                       path_info_struct[1] = g_variant_get_child_value(path_info_entry_v, 1);
+                                       path_info_struct[2] = g_variant_get_child_value(path_info_entry_v, 2);
+
+                                       ((*images)[i])->type    = g_variant_get_int32(path_info_struct[0]);
+                                       ((*images)[i])->index   = g_variant_get_int32(path_info_struct[1]);
+                                       char *path              = ipc_g_variant_dup_string(path_info_struct[2]);;
+                                       snprintf(((*images)[i])->path, 2048, "%s", (path ? path : ""));
+                                       free(path);
+
+                                       g_variant_unref(path_info_struct[0]);
+                                       g_variant_unref(path_info_struct[1]);
+                                       g_variant_unref(path_info_struct[2]);
+                               }
+                       }
+               }
+       }
+       idx++;
+
+       *images_len = g_variant_get_uint32(res_info_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_contact_profile_image_req_s_type_length; j++) {
+               g_variant_unref(res_info_struct[j]);
+       }
+}
+
+GVariant *__create_privacy_req_type(const char *service_name,
+                                               service_adaptor_privacy_req_s *privacy_req,
+                                               void *user_data)
+{
+       GVariantBuilder *cts_builder = g_variant_builder_new(G_VARIANT_TYPE("a(ss)"));
+
+       for (gsize j = 0; j < privacy_req->cts_len; j++) {
+               g_variant_builder_open(cts_builder, G_VARIANT_TYPE("(ss)"));
+               __safe_g_variant_builder_add_string(cts_builder, privacy_req->cts[j]->cc);
+               __safe_g_variant_builder_add_string(cts_builder, privacy_req->cts[j]->pn);
+               g_variant_builder_close(cts_builder);
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_privacy_req_s_type ")", __safe_add_string(service_name), privacy_req->lvl, cts_builder, privacy_req->cts_len);
+
+       g_variant_builder_unref(cts_builder);
+
+       return request;
+}
+
+void __get_privacy_res_type(GVariant *call_result_struct,
+                                               service_adaptor_privacy_res_s **privacy_res,
+                                               void **server_data)
+{
+       GVariant *res_info_struct[private_service_adaptor_privacy_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_privacy_res_s_type_length; j++) {
+               res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+       }
+
+       int idx = 0;
+       *privacy_res = (service_adaptor_privacy_res_s *) calloc(1, sizeof(service_adaptor_privacy_res_s));
+       if (NULL != *privacy_res) {
+               (*privacy_res)->lvl = g_variant_get_uint32(res_info_struct[idx++]);
+               (*privacy_res)->prscon = g_variant_get_uint32(res_info_struct[idx++]);
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_privacy_res_s_type_length; j++) {
+               g_variant_unref(res_info_struct[j]);
+       }
+}
+
+void __get_profile_type_res_type(GVariant *call_result_struct,
+                                               char **url)
+{
+       GVariant *res_info_struct = NULL;
+
+       res_info_struct = g_variant_get_child_value(call_result_struct, 0);
+
+       *url = ipc_g_variant_dup_string(res_info_struct);
+
+       g_variant_unref(res_info_struct);
+}
+
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+/**    @brief
+ *     @return service_adaptor_error_s
+ *     @remarks :
+ */
+int _dbus_set_new_contact_list(const char *service_name,
+                                               service_adaptor_contact_req_s *contact_req,
+                                               void *user_data,
+                                               service_adaptor_contact_res_s **contact_res,
+                                               void **server_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = __create_contact_req_type(service_name, contact_req, user_data);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_SET_NEW_CONTACT_LIST_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_contact_res_s_type)))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = _get_result_code(remote_call_result);
+                       } else {
+                               if (NULL != contact_res) {
+                                       __get_contact_res_type(call_result_struct[0], contact_res, server_data);
+                               }
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_set_contact_list(const char *service_name,
+                                               service_adaptor_contact_req_s *contact_req,
+                                               void *user_data,
+                                               service_adaptor_contact_res_s **contact_res,
+                                               void **server_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = __create_contact_req_type(service_name, contact_req, user_data);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_SET_CONTACT_LIST_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_contact_res_s_type)))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = _get_result_code(remote_call_result);
+                       } else {
+                               if (NULL != contact_res) {
+                                       __get_contact_res_type(call_result_struct[0], contact_res, server_data);
+                               }
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_get_contact_list(const char *service_name,
+                                               service_adaptor_contact_res_s **contact_res,
+                                               void **server_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_essential_s_type ")", __safe_add_string(service_name));
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_GET_CONTACT_LIST_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_contact_res_s_type)))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = _get_result_code(remote_call_result);
+                       } else {
+                               if (NULL != contact_res) {
+                                       __get_contact_res_type(call_result_struct[0], contact_res, server_data);
+                               }
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_get_contact_infos_polling(const char *service_name,
+                                               service_adaptor_contact_req_s *contact_req,
+                                               void *user_data,
+                                               service_adaptor_contact_res_s **contact_res,
+                                               void **server_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = __create_contact_req_type(service_name, contact_req, user_data);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_GET_CONTACT_INFOS_POLLING_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_contact_res_s_type)))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = _get_result_code(remote_call_result);
+                       } else {
+                               if (NULL != contact_res) {
+                                       __get_contact_res_type(call_result_struct[0], contact_res, server_data);
+                               }
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_set_me_profile_with_push(const char *service_name,
+                                               service_adaptor_profile_req_s *profile_req,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = __create_profile_req_type(service_name, profile_req, user_data);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_SET_ME_PROFILE_WITH_PUSH_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[2];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+                               ret = _get_result_code(remote_call_result);
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_get_profile(const char *service_name,
+                                               service_adaptor_profile_req_s *profile_req,
+                                               void *user_data,
+                                               service_adaptor_profile_res_s **profile_res,
+                                               void **server_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = __create_profile_req_type(service_name, profile_req, user_data);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_GET_PROFILE_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_profile_res_s_type)))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = _get_result_code(remote_call_result);
+                       } else {
+                               if (NULL != profile_res) {
+                                       __get_profile_res_type(call_result_struct[0], profile_res, server_data);
+                               }
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_set_profile_image_meta_with_push(const char *service_name,
+                                               service_adaptor_profile_image_h *images,
+                                               unsigned int images_len,
+                                               void *user_data,
+                                               service_adaptor_profile_image_h **failed_images,
+                                               unsigned int *failed_images_len,
+                                               void **server_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = __create_file_path_req_type(service_name, images, images_len, user_data);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_SET_PROFILE_IMAGE_META_WITH_PUSH_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_contact_profile_image_req_s_type)))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = _get_result_code(remote_call_result);
+                               if ((NULL != failed_images) && (NULL != failed_images_len)) {
+                                       __get_failed_image_meta_res_type(call_result_struct[0], failed_images, failed_images_len);
+                               }
+                       } else {
+                               /* __get_failed_image_meta_res_type(call_result_struct[0], failed_images, failed_images_len); */
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_delete_me_profile_image_meta_with_push(const char *service_name,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = __create_del_me_profile_req_type(service_name, user_data);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_DEL_ME_PROFILE_IMAGE_META_WITH_PUSH_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[2];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+                               ret = _get_result_code(remote_call_result);
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_set_me_profile_privacy(const char *service_name,
+                                               service_adaptor_privacy_req_s *privacy_req,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = __create_privacy_req_type(service_name, privacy_req, user_data);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_SET_ME_PROFILE_PRIVACY_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[2];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+                               ret = _get_result_code(remote_call_result);
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_get_me_profile_privacy(const char *service_name,
+                                               service_adaptor_privacy_res_s **privacy_res,
+                                               void **server_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_essential_s_type ")", __safe_add_string(service_name));
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_GET_PROFILE_PRIVACY_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_privacy_res_s_type)))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = _get_result_code(remote_call_result);
+                       } else {
+                               if (NULL != privacy_res) {
+                                       __get_privacy_res_type(call_result_struct[0], privacy_res, server_data);
+                               }
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_set_me_presence_with_push(const char *service_name,
+                                               service_adaptor_presence_req_s *presence_req,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_presence_req_s_type ")",
+               __safe_add_string(service_name), __safe_add_string(presence_req->prsc),
+               __safe_add_string(presence_req->status), presence_req->prscon);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_SET_ME_PRESENCE_WITH_PUSH_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[2];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+                               ret = _get_result_code(remote_call_result);
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_set_me_presence_on_off_with_push(const char *service_name,
+                                               service_adaptor_presence_req_s *presence_req,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_presence_req_s_type ")", __safe_add_string(service_name), __safe_add_string(presence_req->prsc), __safe_add_string(presence_req->status), presence_req->prscon);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_SET_ME_PRESENCE_ON_OFF_WITH_PUSH_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[2];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+                               ret = _get_result_code(remote_call_result);
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+
+int _dbus_set_me_profile_type(const char *service_name,
+                                               int type,
+                                               char **url,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_set_me_profile_type_req_s_type ")", __safe_add_string(service_name), type);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_SET_ME_PROFILE_TYPE_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_essential_s_type)))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = _get_result_code(remote_call_result);
+                       } else {
+                               __get_profile_type_res_type(call_result_struct[0], url);
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
diff --git a/src/dbus/dbus_client_layer.c b/src/dbus/dbus_client_layer.c
new file mode 100644 (file)
index 0000000..6c04a9e
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: dbus_client_layer.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include "dbus_client_layer.h"
+#include "dbus_client.h"
+
+int _dbus_client_layer_init()
+{
+       int ret = _dbus_client_service_adaptor_init();
+
+       if (0 != ret) {
+               _dbus_client_service_adaptor_deinit();
+               return ret;
+       }
+
+       return 0;
+}
+
+void _dbus_client_layer_deinit()
+{
+       _dbus_client_service_adaptor_deinit();
+}
+
diff --git a/src/dbus/dbus_client_message.c b/src/dbus/dbus_client_message.c
new file mode 100644 (file)
index 0000000..f25ca4a
--- /dev/null
@@ -0,0 +1,2562 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: dbus-client-message.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include "dbus_client.h"
+#include "dbus_client_message.h"
+#include "service-adaptor/dbus-server.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "private/service-adaptor-client-message.h"
+
+#include "util/service_adaptor_client_util.h"
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+#define __FREE_ERROR_CODE(err) do { if (err) free(err->msg); free(err); (err) = NULL; } while (0)
+
+#define __FREE_POINTER_ARRAY(__arr, __len)     do { \
+                                               if ((NULL != (__arr)) && (0 < (__len))) { \
+                                                       for (int __idx = 0; __idx < (__len); __idx++) { \
+                                                               __SAFE_FREE(__arr[__idx]); \
+                                                       } \
+                                                       __SAFE_FREE((__arr)); \
+                                               } } while (0)
+
+#define __ipc_get_simple_error_code()  do { \
+                       GVariant *call_result_struct[2]; \
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0); \
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1); \
+\
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]); \
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) { \
+                               error->code = remote_call_result; \
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[1]); \
+                               ret = _get_result_code(remote_call_result); \
+                       } \
+                       g_variant_unref(call_result_struct[0]); \
+                       g_variant_unref(call_result_struct[1]); \
+               } while (0)
+
+void __free_wrong_receiver_s(service_adaptor_wrong_receiver_s *wrong_receiver)
+{
+       __SAFE_FREE(wrong_receiver->invalid_receivers);
+       __SAFE_FREE(wrong_receiver->interrupted_receivers);
+       __SAFE_FREE(wrong_receiver->disabled_receivers);
+       __SAFE_FREE(wrong_receiver->existing_chatmembers);
+       __FREE_POINTER_ARRAY(wrong_receiver->did_violation_users, wrong_receiver->did_violation_users_len);
+       __SAFE_FREE(wrong_receiver->invitation_denieds);
+}
+
+void __free_ordered_chat_member_s_list(service_adaptor_ordered_chat_member_s **ordered_chat_members, unsigned int ordered_chat_members_len)
+{
+       if ((NULL != ordered_chat_members) && (0 < ordered_chat_members_len)) {
+               for (int i = 0; i < ordered_chat_members_len; i++) {
+                       if (NULL != ordered_chat_members[i]) {
+                               __SAFE_FREE(ordered_chat_members[i]->name);
+                               __SAFE_FREE(ordered_chat_members[i]);
+                       }
+               }
+       }
+}
+void __free_inbox_message_s_list(service_adaptor_inbox_message_s **inbox_messages, unsigned int inbox_messages_len)
+{
+       if ((NULL != inbox_messages) && (0 < inbox_messages_len)) {
+               for (int i = 0; i < inbox_messages_len; i++) {
+                       if (NULL != inbox_messages[i]) {
+                               __SAFE_FREE(inbox_messages[i]->chat_msg);
+                               __SAFE_FREE(inbox_messages[i]);
+                       }
+               }
+       }
+}
+void __get_create_chatroom_res_type(GVariant *parameters,
+                                               int64_t *request_id,
+                                               int64_t *chatroom_id,
+                                               int *default_message_ttl,
+                                               service_adaptor_wrong_receiver_s *wrong_receiver)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[private_service_adaptor_create_chatroom_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_create_chatroom_res_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *request_id = g_variant_get_int64(res_struct[idx++]);
+       *chatroom_id = g_variant_get_int64(res_struct[idx++]);
+       *default_message_ttl = g_variant_get_int32(res_struct[idx++]);
+
+       GVariant *res_info_struct[private_service_adaptor_wrong_receiver_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_wrong_receiver_s_type_length; j++) {
+               res_info_struct[j] = g_variant_get_child_value(res_struct[idx], j);
+       }
+
+       int idx2 = 0;
+
+       gsize invalid_count = g_variant_n_children(res_info_struct[idx2]);
+       wrong_receiver->invalid_receivers = (int64_t *) calloc(invalid_count, sizeof(int64_t));
+
+       if (NULL != wrong_receiver->invalid_receivers) {
+               for (gsize i = 0; i < invalid_count; i++) {
+                       GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+                       GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+                       wrong_receiver->invalid_receivers[i] = g_variant_get_int64(info_struct);
+
+                       g_variant_unref(info_struct);
+               }
+               idx2++;
+               wrong_receiver->invalid_receivers_len = g_variant_get_uint32(res_info_struct[idx2++]);
+       } else {
+               wrong_receiver->invalid_receivers_len = 0U;
+               idx2++;
+               idx2++;
+       }
+
+       gsize interrupted_count = g_variant_n_children(res_info_struct[idx2]);
+       wrong_receiver->interrupted_receivers = (int64_t *) calloc(interrupted_count, sizeof(int64_t));
+
+       if (NULL != wrong_receiver->interrupted_receivers) {
+               for (gsize i = 0; i < interrupted_count; i++) {
+                       GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+                       GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+                       wrong_receiver->interrupted_receivers[i] = g_variant_get_int64(info_struct);
+
+                       g_variant_unref(info_struct);
+               }
+               idx2++;
+               wrong_receiver->interrupted_receivers_len = g_variant_get_uint32(res_info_struct[idx2++]);
+       } else {
+               wrong_receiver->interrupted_receivers_len = 0U;
+               idx2++;
+               idx2++;
+       }
+
+       gsize disabled_count = g_variant_n_children(res_info_struct[idx2]);
+       wrong_receiver->disabled_receivers = (int64_t *) calloc(disabled_count, sizeof(int64_t));
+
+       if (NULL != wrong_receiver->disabled_receivers) {
+               for (gsize i = 0; i < disabled_count; i++) {
+                       GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+                       GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+                       wrong_receiver->disabled_receivers[i] = g_variant_get_int64(info_struct);
+
+                       g_variant_unref(info_struct);
+               }
+               idx2++;
+               wrong_receiver->disabled_receivers_len = g_variant_get_uint32(res_info_struct[idx2++]);
+       } else {
+               wrong_receiver->disabled_receivers_len = 0U;
+               idx2++;
+               idx2++;
+       }
+
+       gsize existing_count = g_variant_n_children(res_info_struct[idx2]);
+       wrong_receiver->existing_chatmembers = (int64_t *) calloc(existing_count, sizeof(int64_t));
+
+       if (NULL != wrong_receiver->existing_chatmembers) {
+               for (gsize i = 0; i < existing_count; i++) {
+                       GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+                       GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+                       wrong_receiver->existing_chatmembers[i] = g_variant_get_int64(info_struct);
+
+                       g_variant_unref(info_struct);
+               }
+               idx2++;
+               wrong_receiver->existing_chatmembers_len = g_variant_get_uint32(res_info_struct[idx2++]);
+       } else {
+               wrong_receiver->existing_chatmembers_len = 0U;
+               idx2++;
+               idx2++;
+       }
+
+       gsize did_violation_users_count = g_variant_n_children(res_info_struct[idx2]);
+       wrong_receiver->did_violation_users = (service_adaptor_did_violation_users_s **) calloc(did_violation_users_count, sizeof(service_adaptor_did_violation_users_s *));
+
+       if (NULL != wrong_receiver->did_violation_users) {
+               for (gsize i = 0; i < did_violation_users_count; i++) {
+                       GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+                       GVariant *info_struct[private_service_adaptor_did_violation_users_s_type_length];
+
+                       for (size_t j = 0; j < private_service_adaptor_did_violation_users_s_type_length; j++) {
+                               info_struct[j] = g_variant_get_child_value(info_entry_v, j);
+                       }
+
+                       int idx3 = 0;
+                       wrong_receiver->did_violation_users[i] = (service_adaptor_did_violation_users_s *) calloc(1, sizeof(service_adaptor_did_violation_users_s));
+                       if (NULL != wrong_receiver->did_violation_users[i]) {
+                               wrong_receiver->did_violation_users[i]->usera = g_variant_get_int64(info_struct[idx3++]);
+                               wrong_receiver->did_violation_users[i]->userb = g_variant_get_int64(info_struct[idx3++]);
+                       }
+
+                       for (size_t j = 0; j < private_service_adaptor_did_violation_users_s_type_length; j++) {
+                               g_variant_unref(info_struct[j]);
+                       }
+               }
+               idx2++;
+               wrong_receiver->did_violation_users_len = g_variant_get_uint32(res_info_struct[idx2++]);
+       } else {
+               wrong_receiver->did_violation_users_len = 0U;
+               idx2++;
+               idx2++;
+       }
+
+       gsize denieds_count = g_variant_n_children(res_info_struct[idx2]);
+       wrong_receiver->invitation_denieds = (int64_t *) calloc(denieds_count, sizeof(int64_t));
+
+       if (NULL != wrong_receiver->invitation_denieds) {
+               for (gsize i = 0; i < denieds_count; i++) {
+                       GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+                       GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+                       wrong_receiver->invitation_denieds[i] = g_variant_get_int64(info_struct);
+
+                       g_variant_unref(info_struct);
+               }
+               idx2++;
+               wrong_receiver->invitation_denieds_len = g_variant_get_uint32(res_info_struct[idx2++]);
+       } else {
+               wrong_receiver->invitation_denieds_len = 0U;
+               idx2++;
+               idx2++;
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_wrong_receiver_s_type_length; j++) {
+               g_variant_unref(res_info_struct[j]);
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_create_chatroom_res_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+
+void __get_change_chatroom_meta_res_type(GVariant *parameters,
+                                               int64_t *request_id,
+                                               int64_t *chatroom_id)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[private_service_adaptor_change_chatroom_meta_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_change_chatroom_meta_res_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *request_id = g_variant_get_int64(res_struct[idx++]);
+       *chatroom_id = g_variant_get_int64(res_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_change_chatroom_meta_res_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+
+void __get_chat_res_type(GVariant *parameters,
+                                               int64_t *request_id,
+                                               int64_t *chatroom_id,
+                                               service_adaptor_processed_msg_s ***processed_msgs,
+                                               unsigned int *processed_msgs_len)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[private_service_adaptor_chat_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_chat_res_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *request_id = g_variant_get_int64(res_struct[idx++]);
+       *chatroom_id = g_variant_get_int64(res_struct[idx++]);
+
+       gsize list_count = g_variant_n_children(res_struct[idx]);
+
+       *processed_msgs = (service_adaptor_processed_msg_s **) calloc(list_count, sizeof(service_adaptor_processed_msg_s *));
+
+       if (NULL != *processed_msgs) {
+               for (gsize i = 0; i < list_count; i++) {
+                       GVariant *info_struct[private_service_adaptor_processed_msg_s_type_length];
+                       GVariant *info_entry_v = g_variant_get_child_value(res_struct[idx], i);
+
+                       (*processed_msgs)[i] = (service_adaptor_processed_msg_s *) calloc(1, sizeof(service_adaptor_processed_msg_s));
+
+                       if (NULL != (*processed_msgs)[i]) {
+                               for (size_t j = 0; j < private_service_adaptor_processed_msg_s_type_length; j++) {
+                                       info_struct[j] = g_variant_get_child_value(info_entry_v, j);
+                               }
+
+                               int idx2 = 0;
+                               (*processed_msgs)[i]->msg_id = g_variant_get_int64(info_struct[idx2++]);
+                               (*processed_msgs)[i]->sent_time = g_variant_get_int64(info_struct[idx2++]);
+
+                               for (size_t j = 0; j < private_service_adaptor_processed_msg_s_type_length; j++) {
+                                       g_variant_unref(info_struct[j]);
+                               }
+                       }
+               }
+               idx++;
+               *processed_msgs_len = g_variant_get_uint32(res_struct[idx++]);
+       } else {
+               *processed_msgs_len = 0U;
+               idx++;
+               idx++;
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_chat_res_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+
+void __get_allow_chat_res_type(GVariant *parameters,
+                                               int64_t *request_id,
+                                               int64_t *chatroom_id,
+                                               service_adaptor_delivery_ack_s ***delivery_acks,
+                                               unsigned int *delivery_acks_len,
+                                               unsigned long long *last_delivery_acks_timestamp,
+                                               service_adaptor_read_ack_s ***read_acks,
+                                               unsigned int *read_acks_len,
+                                               unsigned long long *last_read_acks_timestamp,
+                                               service_adaptor_ordered_chat_member_s ***ordered_chat_members,
+                                               unsigned int *ordered_chat_members_len,
+                                               char **chatroom_title,
+                                               int *default_message_ttl)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[private_service_adaptor_allow_chat_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_allow_chat_res_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *request_id = g_variant_get_int64(res_struct[idx++]);
+       *chatroom_id = g_variant_get_int64(res_struct[idx++]);
+
+       gsize delivery_acks_count = g_variant_n_children(res_struct[idx]);
+       *delivery_acks = (service_adaptor_delivery_ack_s **) calloc(delivery_acks_count, sizeof(service_adaptor_delivery_ack_s *));
+
+       if (NULL != *delivery_acks) {
+               for (gsize i = 0; i < delivery_acks_count; i++) {
+                       GVariant *info_struct[private_service_adaptor_delivery_ack_s_type_length];
+                       GVariant *info_entry_v = g_variant_get_child_value(res_struct[idx], i);
+
+                       (*delivery_acks)[i] = (service_adaptor_delivery_ack_s *) calloc(1, sizeof(service_adaptor_delivery_ack_s));
+
+                       if (NULL == (*delivery_acks)[i]) {
+                               continue;
+                       }
+
+                       for (size_t j = 0; j < private_service_adaptor_delivery_ack_s_type_length; j++) {
+                               info_struct[j] = g_variant_get_child_value(info_entry_v, j);
+                       }
+
+                       int idx2 = 0;
+                       (*delivery_acks)[i]->user_id = g_variant_get_int64(info_struct[idx2++]);
+                       (*delivery_acks)[i]->msg_id = g_variant_get_int64(info_struct[idx2++]);
+                       (*delivery_acks)[i]->timestamp = g_variant_get_uint64(info_struct[idx2++]);
+
+                       for (size_t j = 0; j < private_service_adaptor_delivery_ack_s_type_length; j++) {
+                               g_variant_unref(info_struct[j]);
+                       }
+               }
+               idx++;
+
+               *delivery_acks_len = g_variant_get_uint32(res_struct[idx++]);
+       } else {
+               *delivery_acks_len = 0U;
+               idx++;
+               idx++;
+       }
+       *last_delivery_acks_timestamp = g_variant_get_uint64(res_struct[idx++]);
+
+       gsize read_acks_count = g_variant_n_children(res_struct[idx]);
+       *read_acks = (service_adaptor_read_ack_s **) calloc(read_acks_count, sizeof(service_adaptor_read_ack_s *));
+
+       if (NULL != *read_acks) {
+               for (gsize i = 0; i < read_acks_count; i++) {
+                       GVariant *info_struct[private_service_adaptor_read_ack_s_type_length];
+                       GVariant *info_entry_v = g_variant_get_child_value(res_struct[idx], i);
+
+                       (*read_acks)[i] = (service_adaptor_read_ack_s *) calloc(1, sizeof(service_adaptor_read_ack_s));
+                       if (NULL == (*read_acks)[i]) {
+                               continue;
+                       }
+
+                       for (size_t j = 0; j < private_service_adaptor_read_ack_s_type_length; j++) {
+                               info_struct[j] = g_variant_get_child_value(info_entry_v, j);
+                       }
+
+                       int idx2 = 0;
+                       (*read_acks)[i]->user_id = g_variant_get_int64(info_struct[idx2++]);
+                       (*read_acks)[i]->msg_id = g_variant_get_int64(info_struct[idx2++]);
+                       (*read_acks)[i]->timestamp = g_variant_get_uint64(info_struct[idx2++]);
+
+                       for (size_t j = 0; j < private_service_adaptor_read_ack_s_type_length; j++) {
+                               g_variant_unref(info_struct[j]);
+                       }
+               }
+               idx++;
+
+               *read_acks_len = g_variant_get_uint32(res_struct[idx++]);
+       } else {
+               *read_acks_len = 0U;
+       }
+       *last_read_acks_timestamp = g_variant_get_uint64(res_struct[idx++]);
+
+       gsize ordered_chat_member_count = g_variant_n_children(res_struct[idx]);
+       *ordered_chat_members = (service_adaptor_ordered_chat_member_s **) calloc(ordered_chat_member_count, sizeof(service_adaptor_ordered_chat_member_s *));
+
+       if (NULL != *ordered_chat_members) {
+               for (gsize i = 0; i < ordered_chat_member_count; i++) {
+                       GVariant *info_struct[private_service_adaptor_ordered_chat_member_s_type_length];
+                       GVariant *info_entry_v = g_variant_get_child_value(res_struct[idx], i);
+
+                       (*ordered_chat_members)[i] = (service_adaptor_ordered_chat_member_s *) calloc(1, sizeof(service_adaptor_ordered_chat_member_s));
+
+                       if (NULL != (*ordered_chat_members)[i]) {
+                               for (size_t j = 0; j < private_service_adaptor_ordered_chat_member_s_type_length; j++) {
+                                       info_struct[j] = g_variant_get_child_value(info_entry_v, j);
+                               }
+
+                               int idx2 = 0;
+                               (*ordered_chat_members)[i]->user_id = g_variant_get_int64(info_struct[idx2++]);
+                               (*ordered_chat_members)[i]->available = g_variant_get_boolean(info_struct[idx2++]);
+                               (*ordered_chat_members)[i]->name = ipc_g_variant_dup_string(info_struct[idx2++]);
+
+                               for (size_t j = 0; j < private_service_adaptor_ordered_chat_member_s_type_length; j++) {
+                                       g_variant_unref(info_struct[j]);
+                               }
+                       }
+               }
+               idx++;
+               *ordered_chat_members_len = g_variant_get_uint32(res_struct[idx++]);
+       } else {
+               *ordered_chat_members_len = 0U;
+               idx++;
+               idx++;
+       }
+       *chatroom_title = ipc_g_variant_dup_string(res_struct[idx++]);
+       *default_message_ttl = g_variant_get_int32(res_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_allow_chat_res_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+
+void __get_all_unread_message_res_type(GVariant *parameters,
+                                               int64_t *request_id)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[private_service_adaptor_all_unread_message_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_all_unread_message_res_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *request_id = g_variant_get_int64(res_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_all_unread_message_res_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+void __get_channel_disconnected_res_type(GVariant *parameters,
+                                               char **service_name)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[private_service_adaptor_channel_disconnected_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_channel_disconnected_res_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(res_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_channel_disconnected_res_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+
+
+void __get_forward_online_message_req_type(GVariant *parameters,
+                                               int64_t *request_id,
+                                               int64_t *chatroom_id,
+                                               int *chat_type,
+                                               service_adaptor_inbox_message_s *inbox_msg,
+                                               bool *skip_reply)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[private_service_adaptor_forward_online_message_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_forward_online_message_req_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *request_id = g_variant_get_int64(res_struct[idx++]);
+       *chatroom_id = g_variant_get_int64(res_struct[idx++]);
+       *chat_type = g_variant_get_int32(res_struct[idx++]);
+
+       GVariant *res_info_struct[private_service_adaptor_inbox_message_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_inbox_message_s_type_length; j++) {
+               res_info_struct[j] = g_variant_get_child_value(res_struct[idx], j);
+       }
+
+       int idx2 = 0;
+
+       inbox_msg->msg_id = g_variant_get_int64(res_info_struct[idx2++]);
+       inbox_msg->msg_type = g_variant_get_int32(res_info_struct[idx2++]);
+       inbox_msg->sender = g_variant_get_int64(res_info_struct[idx2++]);
+       inbox_msg->receiver = g_variant_get_int64(res_info_struct[idx2++]);
+       inbox_msg->sent_time = g_variant_get_int64(res_info_struct[idx2++]);
+       inbox_msg->chat_msg = ipc_g_variant_dup_string(res_info_struct[idx2++]);
+       inbox_msg->chatroom_id = g_variant_get_int64(res_info_struct[idx2++]);
+       inbox_msg->chat_type = g_variant_get_int32(res_info_struct[idx2++]);
+       inbox_msg->message_ttl = g_variant_get_int32(res_info_struct[idx2++]);
+
+       for (size_t j = 0; j < private_service_adaptor_inbox_message_s_type_length; j++) {
+               g_variant_unref(res_info_struct[j]);
+       }
+       idx++;
+
+       *skip_reply = g_variant_get_boolean(res_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_forward_online_message_req_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+
+void __get_forward_unread_message_req_type(GVariant *parameters,
+                                               int64_t *request_id,
+                                               service_adaptor_inbox_message_s ***inbox_msgs,
+                                               unsigned int *inbox_msgs_len,
+                                               char **next_pagination_key)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[private_service_adaptor_forward_unread_message_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_forward_unread_message_req_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *request_id = g_variant_get_int64(res_struct[idx++]);
+
+       gsize list_count = g_variant_n_children(res_struct[idx]);
+
+       *inbox_msgs = (service_adaptor_inbox_message_s **) calloc(list_count, sizeof(service_adaptor_inbox_message_s *));
+
+       if (NULL != *inbox_msgs) {
+               for (gsize i = 0; i < list_count; i++) {
+                       GVariant *info_struct[private_service_adaptor_inbox_message_s_type_length];
+                       GVariant *info_entry_v = g_variant_get_child_value(res_struct[idx], i);
+
+                       (*inbox_msgs)[i] = (service_adaptor_inbox_message_s *) calloc(1, sizeof(service_adaptor_inbox_message_s));
+
+                       if (NULL != (*inbox_msgs)[i]) {
+                               for (size_t j = 0; j < private_service_adaptor_inbox_message_s_type_length; j++) {
+                                       info_struct[j] = g_variant_get_child_value(info_entry_v, j);
+                               }
+
+                               int idx2 = 0;
+                               (*inbox_msgs)[i]->msg_id = g_variant_get_int64(info_struct[idx2++]);
+                               (*inbox_msgs)[i]->msg_type = g_variant_get_int32(info_struct[idx2++]);
+                               (*inbox_msgs)[i]->sender = g_variant_get_int64(info_struct[idx2++]);
+                               (*inbox_msgs)[i]->receiver = g_variant_get_int64(info_struct[idx2++]);
+                               (*inbox_msgs)[i]->sent_time = g_variant_get_int64(info_struct[idx2++]);
+                               (*inbox_msgs)[i]->chat_msg = ipc_g_variant_dup_string(info_struct[idx2++]);
+                               (*inbox_msgs)[i]->chatroom_id = g_variant_get_int64(info_struct[idx2++]);
+                               (*inbox_msgs)[i]->chat_type = g_variant_get_int32(info_struct[idx2++]);
+                               (*inbox_msgs)[i]->message_ttl = g_variant_get_int32(info_struct[idx2++]);
+
+                               for (size_t j = 0; j < private_service_adaptor_inbox_message_s_type_length; j++) {
+                                       g_variant_unref(info_struct[j]);
+                               }
+                       }
+               }
+               idx++;
+               *inbox_msgs_len = g_variant_get_uint32(res_struct[idx++]);
+       } else {
+               *inbox_msgs_len = 0U;
+               idx++;
+               idx++;
+       }
+       *next_pagination_key = ipc_g_variant_dup_string(res_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_forward_unread_message_req_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+
+void __get_read_message_res_type(GVariant *parameters,
+                                               int64_t *request_id,
+                                               int64_t *chatroom_id)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[private_service_adaptor_read_message_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_read_message_res_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *request_id = g_variant_get_int64(res_struct[idx++]);
+       *chatroom_id = g_variant_get_int64(res_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_read_message_res_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+
+void __get_invite_chat_res_type(GVariant *parameters,
+                                               int64_t *request_id,
+                                               int64_t *chatroom_id,
+                                               int64_t *sent_time,
+                                               service_adaptor_wrong_receiver_s *wrong_receiver)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[private_service_adaptor_invite_chat_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_invite_chat_res_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *request_id = g_variant_get_int64(res_struct[idx++]);
+       *chatroom_id = g_variant_get_int64(res_struct[idx++]);
+       *sent_time = g_variant_get_int64(res_struct[idx++]);
+
+       GVariant *res_info_struct[private_service_adaptor_wrong_receiver_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_wrong_receiver_s_type_length; j++) {
+               res_info_struct[j] = g_variant_get_child_value(res_struct[idx], j);
+       }
+
+       int idx2 = 0;
+
+       gsize invalid_count = g_variant_n_children(res_info_struct[idx2]);
+       wrong_receiver->invalid_receivers = (int64_t *) calloc(invalid_count, sizeof(int64_t));
+
+       if (NULL != wrong_receiver->invalid_receivers) {
+               for (gsize i = 0; i < invalid_count; i++) {
+                       GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+                       GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+                       wrong_receiver->invalid_receivers[i] = g_variant_get_int64(info_struct);
+
+                       g_variant_unref(info_struct);
+               }
+               idx2++;
+               wrong_receiver->invalid_receivers_len = g_variant_get_uint32(res_info_struct[idx2++]);
+       } else {
+               wrong_receiver->invalid_receivers_len = 0U;
+               idx2++;
+               idx2++;
+       }
+
+       gsize interrupted_count = g_variant_n_children(res_info_struct[idx2]);
+       wrong_receiver->interrupted_receivers = (int64_t *) calloc(interrupted_count, sizeof(int64_t));
+
+       if (NULL != wrong_receiver->interrupted_receivers) {
+               for (gsize i = 0; i < interrupted_count; i++) {
+                       GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+                       GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+                       wrong_receiver->interrupted_receivers[i] = g_variant_get_int64(info_struct);
+
+                       g_variant_unref(info_struct);
+               }
+               idx2++;
+               wrong_receiver->interrupted_receivers_len = g_variant_get_uint32(res_info_struct[idx2++]);
+       } else {
+               wrong_receiver->interrupted_receivers_len = 0U;
+               idx2++;
+               idx2++;
+       }
+
+       gsize disabled_count = g_variant_n_children(res_info_struct[idx2]);
+       wrong_receiver->disabled_receivers = (int64_t *) calloc(disabled_count, sizeof(int64_t));
+
+       if (NULL != wrong_receiver->disabled_receivers) {
+               for (gsize i = 0; i < disabled_count; i++) {
+                       GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+                       GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+                       wrong_receiver->disabled_receivers[i] = g_variant_get_int64(info_struct);
+
+                       g_variant_unref(info_struct);
+               }
+               idx2++;
+               wrong_receiver->disabled_receivers_len = g_variant_get_uint32(res_info_struct[idx2++]);
+       } else {
+               wrong_receiver->disabled_receivers_len = 0U;
+               idx2++;
+               idx2++;
+       }
+
+       gsize existing_count = g_variant_n_children(res_info_struct[idx2]);
+       wrong_receiver->existing_chatmembers = (int64_t *) calloc(existing_count, sizeof(int64_t));
+
+       if (NULL != wrong_receiver->existing_chatmembers) {
+               for (gsize i = 0; i < existing_count; i++) {
+                       GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+                       GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+                       wrong_receiver->existing_chatmembers[i] = g_variant_get_int64(info_struct);
+
+                       g_variant_unref(info_struct);
+               }
+               idx2++;
+               wrong_receiver->existing_chatmembers_len = g_variant_get_uint32(res_info_struct[idx2++]);
+       } else {
+               wrong_receiver->existing_chatmembers_len = 0U;
+               idx2++;
+               idx2++;
+       }
+
+       gsize did_violation_count = g_variant_n_children(res_info_struct[idx2]);
+       wrong_receiver->did_violation_users = (service_adaptor_did_violation_users_s **) calloc(did_violation_count, sizeof(service_adaptor_did_violation_users_s *));
+
+       if (NULL != wrong_receiver->did_violation_users) {
+               for (gsize i = 0; i < did_violation_count; i++) {
+                       GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+                       GVariant *info_struct[private_service_adaptor_did_violation_users_s_type_length];
+
+                       for (size_t j = 0; j < private_service_adaptor_did_violation_users_s_type_length; j++) {
+                               info_struct[j] = g_variant_get_child_value(info_entry_v, j);
+                       }
+
+                       int idx3 = 0;
+
+                       wrong_receiver->did_violation_users[i] = (service_adaptor_did_violation_users_s *) calloc(1, sizeof(service_adaptor_did_violation_users_s));
+                       if (NULL != wrong_receiver->did_violation_users[i]) {
+                               wrong_receiver->did_violation_users[i]->usera = g_variant_get_int64(info_struct[idx3++]);
+                               wrong_receiver->did_violation_users[i]->userb = g_variant_get_int64(info_struct[idx3++]);
+                       }
+
+                       for (size_t j = 0; j < private_service_adaptor_did_violation_users_s_type_length; j++) {
+                               g_variant_unref(info_struct[j]);
+                       }
+               }
+               idx2++;
+               wrong_receiver->did_violation_users_len = g_variant_get_uint32(res_info_struct[idx2++]);
+       } else {
+               wrong_receiver->did_violation_users_len = 0U;
+               idx2++;
+               idx2++;
+       }
+
+       gsize denieds_count = g_variant_n_children(res_info_struct[idx2]);
+       wrong_receiver->invitation_denieds = (int64_t *) calloc(denieds_count, sizeof(int64_t));
+
+       if (NULL != wrong_receiver->invitation_denieds) {
+               for (gsize i = 0; i < denieds_count; i++) {
+                       GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+                       GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+                       wrong_receiver->invitation_denieds[i] = g_variant_get_int64(info_struct);
+
+                       g_variant_unref(info_struct);
+               }
+               idx2++;
+               wrong_receiver->invitation_denieds_len = g_variant_get_uint32(res_info_struct[idx2++]);
+       } else {
+               wrong_receiver->invitation_denieds_len = 0U;
+               idx2++;
+               idx2++;
+       }
+
+
+       for (size_t j = 0; j < private_service_adaptor_wrong_receiver_s_type_length; j++) {
+               g_variant_unref(res_info_struct[j]);
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_invite_chat_res_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+
+void __get_end_chat_res_type(GVariant *parameters,
+                                               int64_t *request_id)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[private_service_adaptor_end_chat_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_end_chat_res_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *request_id = g_variant_get_int64(res_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_end_chat_res_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+
+void __get_unseal_message_res_type(GVariant *parameters,
+                                               int64_t *request_id,
+                                               int64_t *chatroom_id)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[private_service_adaptor_unseal_message_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_unseal_message_res_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *request_id = g_variant_get_int64(res_struct[idx++]);
+       *chatroom_id = g_variant_get_int64(res_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_unseal_message_res_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+void __get_save_call_log_res_type(GVariant *parameters,
+                                               int64_t *request_id)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[private_service_adaptor_save_call_log_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_save_call_log_res_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *request_id = g_variant_get_int64(res_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_save_call_log_res_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+
+void __get_current_time_res_type(GVariant *parameters,
+                                               int64_t *request_id,
+                                               int64_t *current_time_millis)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[private_service_adaptor_current_time_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_current_time_res_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *request_id = g_variant_get_int64(res_struct[idx++]);
+       *current_time_millis = g_variant_get_int64(res_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_current_time_res_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+
+void __get_chat_id_list_res_type(GVariant *call_result_struct,
+                                               service_adaptor_chat_id_s ***chat_ids,
+                                               unsigned int *chat_ids_len,
+                                               void **server_data)
+{
+       GVariant *res_info_struct[private_service_adaptor_chat_id_list_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_chat_id_list_res_s_type_length; j++) {
+               res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+       }
+
+       int idx = 0;
+       gsize list_count = g_variant_n_children(res_info_struct[idx]);
+
+       *chat_ids = (service_adaptor_chat_id_s **) calloc(list_count, sizeof(service_adaptor_chat_id_s *));
+
+       if (NULL != *chat_ids) {
+               for (gsize i = 0; i < list_count; i++) {
+                       GVariant *list_info_struct[private_service_adaptor_chat_id_s_type_length];
+                       GVariant *list_info_entry_v = g_variant_get_child_value(res_info_struct[idx], i);
+                       (*chat_ids)[i] = (service_adaptor_chat_id_s *) calloc(1, sizeof(service_adaptor_chat_id_s));
+
+                       if (NULL != (*chat_ids)[i]) {
+                               for (size_t j = 0; j < private_service_adaptor_chat_id_s_type_length; j++) {
+                                       list_info_struct[j] = g_variant_get_child_value(list_info_entry_v, j);
+                               }
+
+                               int idx2 = 0;
+                               (*chat_ids)[i]->chatid = g_variant_get_int64(list_info_struct[idx2++]);
+                               (*chat_ids)[i]->msisdn = ipc_g_variant_dup_string(list_info_struct[idx2++]);
+
+                               for (size_t j = 0; j < private_service_adaptor_chat_id_s_type_length; j++) {
+                                       g_variant_unref(list_info_struct[j]);
+                               }
+                       }
+               }
+               idx++;
+               *chat_ids_len = g_variant_get_uint32(res_info_struct[idx++]);
+       } else {
+               *chat_ids_len = 0U;
+               idx++;
+               idx++;
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_chat_id_list_res_s_type_length; j++) {
+               g_variant_unref(res_info_struct[j]);
+       }
+}
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+void on_message_signal(GDBusProxy *proxy,
+                                               gchar *sender_name,
+                                               gchar *signal_name,
+                                               GVariant *parameters,
+                                               gpointer user_data)
+{
+       if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_CREATE_CHATROOM_SIGNAL)) {
+               int64_t request_id = 0;
+               int64_t chatroom_id = 0;
+               int default_message_ttl = 0;
+               service_adaptor_wrong_receiver_s wrong_receiver;
+               service_adaptor_error_s *error_code = NULL;
+
+               __get_create_chatroom_res_type(parameters, &request_id, &chatroom_id, &default_message_ttl, &wrong_receiver);
+
+               service_adaptor_task_h task = _queue_get_task(request_id);
+
+               if (NULL == task) {
+                       __free_wrong_receiver_s(&wrong_receiver);
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                       error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+                       if (NULL != error_code) {
+                               error_code->code = remote_call_result;
+                               error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+                       }
+               }
+
+               service_adaptor_reply_create_chatroom_cb callback = (service_adaptor_reply_create_chatroom_cb) task->callback;
+
+               if (NULL != callback) {
+                       callback(task->handle, request_id, chatroom_id, default_message_ttl, &wrong_receiver, error_code, task->user_data);
+               }
+
+               _queue_del_task(task);
+               __free_wrong_receiver_s(&wrong_receiver);
+               __FREE_ERROR_CODE(error_code);
+       } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_CHANGE_CHATROOM_META_SIGNAL)) {
+               int64_t request_id = 0;
+               int64_t chatroom_id = 0;
+               service_adaptor_error_s *error_code = NULL;
+
+               __get_change_chatroom_meta_res_type(parameters, &request_id, &chatroom_id);
+
+               service_adaptor_task_h task = _queue_get_task(request_id);
+
+               if (NULL == task) {
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                       error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+                       if (NULL != error_code) {
+                               error_code->code = remote_call_result;
+                               error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+                       }
+               }
+
+               service_adaptor_reply_change_chatroom_meta_cb callback = (service_adaptor_reply_change_chatroom_meta_cb) task->callback;
+
+               if (NULL != callback) {
+                       callback(task->handle, request_id, chatroom_id, error_code, task->user_data);
+               }
+               __FREE_ERROR_CODE(error_code);
+
+               _queue_del_task(task);
+       } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_CHAT_SIGNAL)) {
+               int64_t request_id = 0;
+               int64_t chatroom_id = 0;
+               service_adaptor_processed_msg_s **processed_msgs = NULL;
+               unsigned int processed_msgs_len = 0;
+               service_adaptor_error_s *error_code = NULL;
+
+               __get_chat_res_type(parameters, &request_id, &chatroom_id, &processed_msgs, &processed_msgs_len);
+
+               service_adaptor_task_h task = _queue_get_task(request_id);
+
+               if (NULL == task) {
+                       __FREE_POINTER_ARRAY(processed_msgs, processed_msgs_len);
+                       __SAFE_FREE(processed_msgs);
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                       error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+                       if (NULL != error_code) {
+                               error_code->code = remote_call_result;
+                               error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+                       }
+               }
+
+               service_adaptor_reply_chat_cb callback = (service_adaptor_reply_chat_cb) task->callback;
+
+               if (NULL != callback) {
+                       callback(task->handle, request_id, chatroom_id, processed_msgs, processed_msgs_len, error_code, task->user_data);
+               }
+               __FREE_POINTER_ARRAY(processed_msgs, processed_msgs_len);
+               __SAFE_FREE(processed_msgs);
+               __FREE_ERROR_CODE(error_code);
+
+               _queue_del_task(task);
+       } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_ALLOW_CHAT_SIGNAL)) {
+               int64_t request_id = 0;
+               int64_t chatroom_id = 0;
+               service_adaptor_delivery_ack_s **delivery_acks = NULL;
+               unsigned int delivery_acks_len = 0;
+               unsigned long long last_delivery_acks_timestamp = 0;
+               service_adaptor_read_ack_s **read_acks = NULL;
+               unsigned int read_acks_len = 0;
+               unsigned long long last_read_acks_timestamp = 0;
+               service_adaptor_ordered_chat_member_s **ordered_chat_members = NULL;
+               unsigned int ordered_chat_members_len = 0;
+               char *chatroom_title = NULL;
+               int default_message_ttl = 0;
+               service_adaptor_error_s *error_code = NULL;
+
+
+               __get_allow_chat_res_type(parameters, &request_id, &chatroom_id,
+                               &delivery_acks, &delivery_acks_len, &last_delivery_acks_timestamp,
+                               &read_acks, &read_acks_len, &last_read_acks_timestamp,
+                               &ordered_chat_members, &ordered_chat_members_len,
+                               &chatroom_title, &default_message_ttl);
+
+               service_adaptor_task_h task = _queue_get_task(request_id);
+
+               if (NULL == task) {
+                       __FREE_POINTER_ARRAY(delivery_acks, delivery_acks_len);
+                       __SAFE_FREE(delivery_acks);
+                       __FREE_POINTER_ARRAY(read_acks, read_acks_len);
+                       __SAFE_FREE(read_acks);
+                       __free_ordered_chat_member_s_list(ordered_chat_members, ordered_chat_members_len);
+                       __SAFE_FREE(ordered_chat_members);
+                       __SAFE_FREE(chatroom_title);
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                       error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+                       if (NULL != error_code) {
+                               error_code->code = remote_call_result;
+                               error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+                       }
+               }
+
+               service_adaptor_reply_allow_chat_cb callback = (service_adaptor_reply_allow_chat_cb) task->callback;
+               if (NULL != callback) {
+                       callback(task->handle, request_id, chatroom_id,
+                                       delivery_acks, delivery_acks_len, last_delivery_acks_timestamp,
+                                       read_acks, read_acks_len, last_read_acks_timestamp,
+                                       ordered_chat_members, ordered_chat_members_len,
+                                       chatroom_title, default_message_ttl, error_code, task->user_data);
+               }
+               __FREE_POINTER_ARRAY(delivery_acks, delivery_acks_len);
+               __SAFE_FREE(delivery_acks);
+               __FREE_POINTER_ARRAY(read_acks, read_acks_len);
+               __SAFE_FREE(read_acks);
+               __free_ordered_chat_member_s_list(ordered_chat_members, ordered_chat_members_len);
+               __SAFE_FREE(ordered_chat_members);
+               __SAFE_FREE(chatroom_title);
+               __FREE_ERROR_CODE(error_code);
+
+               _queue_del_task(task);
+       } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_ALL_UNREAD_MESSAGE_SIGNAL)) {
+               int64_t request_id = 0;
+               service_adaptor_error_s *error_code = NULL;
+
+               __get_all_unread_message_res_type(parameters, &request_id);
+
+               service_adaptor_task_h task = _queue_get_task(request_id);
+
+               if (NULL == task) {
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                       error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+                       if (NULL != error_code) {
+                               error_code->code = remote_call_result;
+                               error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+                       }
+               }
+
+               service_adaptor_reply_all_unread_message_cb callback = (service_adaptor_reply_all_unread_message_cb) task->callback;
+
+               if (NULL != callback) {
+                       callback(task->handle, request_id, error_code, task->user_data);
+               }
+               __FREE_ERROR_CODE(error_code);
+
+               _queue_del_task(task);
+       } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REQUEST_FORWARD_ONLINE_MESSAGE_SIGNAL)) {
+               int64_t request_id = 0;
+               int64_t chatroom_id = 0;
+               int chat_type = 0;
+               service_adaptor_inbox_message_s inbox_msg;
+               bool skip_reply = false;
+               service_adaptor_error_s *error_code = NULL;
+
+               __get_forward_online_message_req_type(parameters, &request_id, &chatroom_id, &chat_type, &inbox_msg, &skip_reply);
+
+               service_adaptor_task_h task = _queue_get_task(-100);
+
+               if (NULL == task) {
+                       __SAFE_FREE(inbox_msg.chat_msg);
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                       error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+                       if (NULL != error_code) {
+                               error_code->code = remote_call_result;
+                               error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+                       }
+               }
+
+               service_adaptor_request_forward_online_message_cb callback = (service_adaptor_request_forward_online_message_cb) task->callback;
+
+               if (NULL != callback) {
+                       callback(task->handle, request_id, chatroom_id, chat_type, &inbox_msg, skip_reply, error_code, task->user_data);
+               }
+               __SAFE_FREE(inbox_msg.chat_msg);
+               __FREE_ERROR_CODE(error_code);
+       } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REQUEST_FORWARD_UNREAD_MESSAGE_SIGNAL)) {
+               int64_t request_id = 0;
+               service_adaptor_inbox_message_s **inbox_msgs = NULL;
+               uint32_t inbox_msgs_len = 0;
+               char *next_pagination_key = NULL;
+               service_adaptor_error_s *error_code = NULL;
+
+               __get_forward_unread_message_req_type(parameters, &request_id, &inbox_msgs, &inbox_msgs_len, &next_pagination_key);
+
+               service_adaptor_task_h task = _queue_get_task(-101);
+
+               if (NULL == task) {
+                       __SAFE_FREE(next_pagination_key);
+                       __free_inbox_message_s_list(inbox_msgs, inbox_msgs_len);
+                       __SAFE_FREE(inbox_msgs);
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                       error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+                       if (NULL != error_code) {
+                               error_code->code = remote_call_result;
+                               error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+                       }
+               }
+
+               service_adaptor_request_forward_unread_message_cb callback = (service_adaptor_request_forward_unread_message_cb) task->callback;
+
+               if (NULL != callback) {
+                       callback(task->handle, request_id, inbox_msgs, inbox_msgs_len, next_pagination_key, error_code, task->user_data);
+               }
+               __SAFE_FREE(next_pagination_key);
+               __free_inbox_message_s_list(inbox_msgs, inbox_msgs_len);
+               __SAFE_FREE(inbox_msgs);
+               __FREE_ERROR_CODE(error_code);
+       } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_CHANNEL_DISCONNECTED_SIGNAL)) {
+               char *service_name = NULL;
+               service_adaptor_error_s *error_code = NULL;
+
+               __get_channel_disconnected_res_type(parameters, &service_name);
+
+               service_adaptor_task_h task = _queue_get_task(-102);
+
+               if (NULL == task) {
+                       __SAFE_FREE(service_name);
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                       error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+                       if (NULL != error_code) {
+                               error_code->code = remote_call_result;
+                               error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+                       }
+               }
+
+               service_adaptor_reply_channel_disconnected_cb callback = (service_adaptor_reply_channel_disconnected_cb) task->callback;
+
+               if ((NULL != callback) && (NULL != task->handle) && (NULL != ((service_adaptor_h)task->handle)->service_name) && (NULL != service_name)
+                               && (0 == strncmp(((service_adaptor_h)task->handle)->service_name, service_name, strlen(((service_adaptor_h)task->handle)->service_name)))) {
+                       callback(task->handle, error_code, task->user_data);
+               }
+               __SAFE_FREE(service_name);
+               __FREE_ERROR_CODE(error_code);
+       } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_READ_MESSAGE_SIGNAL)) {
+               int64_t request_id = 0;
+               int64_t chatroom_id = 0;
+               service_adaptor_error_s *error_code = NULL;
+
+               __get_read_message_res_type(parameters, &request_id, &chatroom_id);
+
+               service_adaptor_task_h task = _queue_get_task(request_id);
+
+               if (NULL == task) {
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                       error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+                       if (NULL != error_code) {
+                               error_code->code = remote_call_result;
+                               error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+                       }
+               }
+
+               service_adaptor_reply_read_message_cb callback = (service_adaptor_reply_read_message_cb) task->callback;
+               if (NULL != callback) {
+                       callback(task->handle, request_id, chatroom_id, error_code, task->user_data);
+               }
+               __FREE_ERROR_CODE(error_code);
+
+               _queue_del_task(task);
+       } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_INVITE_CHAT_SIGNAL)) {
+               int64_t request_id = 0;
+               int64_t chatroom_id = 0;
+               int64_t sent_time = 0;
+               service_adaptor_wrong_receiver_s wrong_receiver;
+               service_adaptor_error_s *error_code = NULL;
+
+               __get_invite_chat_res_type(parameters, &request_id, &chatroom_id, &sent_time, &wrong_receiver);
+
+               service_adaptor_task_h task = _queue_get_task(request_id);
+
+               if (NULL == task) {
+                       __free_wrong_receiver_s(&wrong_receiver);
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                       error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+                       if (NULL != error_code) {
+                               error_code->code = remote_call_result;
+                               error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+                       }
+               }
+
+               service_adaptor_reply_invite_chat_cb callback = (service_adaptor_reply_invite_chat_cb) task->callback;
+               if (NULL != callback) {
+                       callback(task->handle, request_id, chatroom_id, sent_time, &wrong_receiver, error_code, task->user_data);
+               }
+
+               __free_wrong_receiver_s(&wrong_receiver);
+               __FREE_ERROR_CODE(error_code);
+               _queue_del_task(task);
+       } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_END_CHAT_SIGNAL)) {
+               int64_t request_id = 0;
+               service_adaptor_error_s *error_code = NULL;
+
+               __get_end_chat_res_type(parameters, &request_id);
+
+               service_adaptor_task_h task = _queue_get_task(request_id);
+
+               if (NULL == task) {
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                       error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+                       if (NULL != error_code) {
+                               error_code->code = remote_call_result;
+                               error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+                       }
+               }
+
+               service_adaptor_reply_end_chat_cb callback = (service_adaptor_reply_end_chat_cb) task->callback;
+               if (NULL != callback) {
+                       callback(task->handle, request_id, error_code, task->user_data);
+               }
+               __FREE_ERROR_CODE(error_code);
+
+               _queue_del_task(task);
+       } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_UNSEAL_MESSAGE_SIGNAL)) {
+               int64_t request_id = 0;
+               int64_t chatroom_id = 0;
+               service_adaptor_error_s *error_code = NULL;
+
+               __get_unseal_message_res_type(parameters, &request_id, &chatroom_id);
+
+               service_adaptor_task_h task = _queue_get_task(request_id);
+
+               if (NULL == task) {
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                       error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+                       if (NULL != error_code) {
+                               error_code->code = remote_call_result;
+                               error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+                       }
+               }
+
+               service_adaptor_reply_unseal_message_cb callback = (service_adaptor_reply_unseal_message_cb) task->callback;
+               if (NULL != callback) {
+                       callback(task->handle, request_id, chatroom_id, error_code, task->user_data);
+               }
+               __FREE_ERROR_CODE(error_code);
+
+               _queue_del_task(task);
+       } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_SAVE_CALL_LOG_SIGNAL)) {
+               int64_t request_id = 0;
+               service_adaptor_error_s *error_code = NULL;
+
+               __get_save_call_log_res_type(parameters, &request_id);
+
+               service_adaptor_task_h task = _queue_get_task(request_id);
+
+               if (NULL == task) {
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                       error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+                       if (NULL != error_code) {
+                               error_code->code = remote_call_result;
+                               error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+                       }
+               }
+
+               service_adaptor_reply_save_call_log_cb callback = (service_adaptor_reply_save_call_log_cb) task->callback;
+               if (NULL != callback) {
+                       callback(task->handle, request_id, error_code, task->user_data);
+               }
+               __FREE_ERROR_CODE(error_code);
+
+               _queue_del_task(task);
+       } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_CURRENT_TIME_SIGNAL)) {
+               int64_t request_id = 0;
+               int64_t current_time_millis = 0;
+               service_adaptor_error_s *error_code = NULL;
+
+               __get_current_time_res_type(parameters, &request_id, &current_time_millis);
+
+               service_adaptor_task_h task = _queue_get_task(request_id);
+
+               if (NULL == task) {
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                       error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+                       if (NULL != error_code) {
+                               error_code->code = remote_call_result;
+                               error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+                       }
+               }
+
+               service_adaptor_reply_current_time_cb callback = (service_adaptor_reply_current_time_cb) task->callback;
+               if (NULL != callback) {
+                       callback(task->handle, request_id, current_time_millis, error_code, task->user_data);
+               }
+               __FREE_ERROR_CODE(error_code);
+
+               _queue_del_task(task);
+       }
+}
+
+/**    @brief
+ *     @return service_adaptor_error_s
+ *     @remarks :
+ */
+int _dbus_request_create_chatroom(const char *service_name,
+                                               long long int request_id,
+                                               int chat_type,
+                                               long long int *receivers,
+                                               unsigned int receivers_len,
+                                               const char *chatroom_title,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == receivers) || (1 > receivers_len)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(x)"));
+
+       for (int i = 0; i < receivers_len; i++) {
+               g_variant_builder_add(builder, "(x)", receivers[i]);
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_create_chatroom_req_s_type ")", __safe_add_string(service_name),
+                       request_id, chat_type, builder, receivers_len, __safe_add_string(chatroom_title));
+
+       g_variant_builder_unref(builder);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_REQUEST_CREATE_CHATROOM_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+               } else {
+                       __ipc_get_simple_error_code();
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+/**    @brief
+ *     @return service_adaptor_error_s
+ *     @remarks :
+ */
+int _dbus_request_change_chatroom_meta(const char *service_name,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               const char *chatroom_title,
+                                               int default_message_ttl,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+       ipc_check_proxy(sac_interface_proxy);
+
+       if (NULL == service_name) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_change_chatroom_meta_req_s_type ")", __safe_add_string(service_name),
+                       request_id, chatroom_id,  __safe_add_string(chatroom_title), default_message_ttl);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_REQUEST_CHANGE_CHATROOM_META_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+               } else {
+                       __ipc_get_simple_error_code();
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+
+int _dbus_request_chat(const char *service_name,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               service_adaptor_chat_msg_s **chat_msgs,
+                                               unsigned int chat_msgs_len,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (chat_msgs == NULL) || (1 > chat_msgs_len)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a" private_service_adaptor_chat_msg_s_type));
+
+       for (int i = 0; i < chat_msgs_len; i++) {
+               g_variant_builder_open(builder, G_VARIANT_TYPE(private_service_adaptor_chat_msg_s_type));
+               g_variant_builder_add(builder, "x", chat_msgs[i]->msg_id);
+               g_variant_builder_add(builder, "i", chat_msgs[i]->msg_type);
+               __safe_g_variant_builder_add_string(builder, chat_msgs[i]->chatmsg);
+               g_variant_builder_add(builder, "i", chat_msgs[i]->message_ttl);
+               g_variant_builder_close(builder);
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_chat_req_s_type ")", __safe_add_string(service_name), request_id, chatroom_id, builder, chat_msgs_len);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_REQUEST_CHAT_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+               } else {
+                       __ipc_get_simple_error_code();
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_request_allow_chat(const char *service_name,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               bool is_auto_allow,
+                                               int max_count,
+                                               bool need_delivery_ack,
+                                               unsigned long long last_delivery_ack_timestamp,
+                                               bool need_read_ack,
+                                               unsigned long long last_read_ack_timestamp,
+                                               bool need_ordered_chat_member_list,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_allow_chat_req_s_type ")",
+                       __safe_add_string(service_name), request_id, chatroom_id, is_auto_allow, max_count,
+                       need_delivery_ack, last_delivery_ack_timestamp,
+                       need_read_ack, last_read_ack_timestamp, need_ordered_chat_member_list);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_REQUEST_ALLOW_CHAT_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+               } else {
+                       __ipc_get_simple_error_code();
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_request_all_unread_message(const char *service_name,
+                                               long long int request_id,
+                                               int max_count,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_all_unread_message_req_s_type ")", __safe_add_string(service_name), request_id, max_count);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_REQUEST_ALL_UNREAD_MESSAGE_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+               } else {
+                       __ipc_get_simple_error_code();
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_reply_forward_online_message(const char *service_name,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               bool mark_as_read,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_forward_online_message_res_s_type ")", __safe_add_string(service_name), request_id, chatroom_id, mark_as_read);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_REPLY_FORWARD_ONLINE_MESSAGE_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+               } else {
+                       __ipc_get_simple_error_code();
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_reply_forward_unread_message(const char *service_name,
+                                               long long int request_id,
+                                               const char *next_pagination_key,
+                                               int max_count,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_forward_unread_message_res_s_type ")", __safe_add_string(service_name), request_id, __safe_add_string(next_pagination_key), max_count);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_REPLY_FORWARD_UNREAD_MESSAGE_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+               } else {
+                       __ipc_get_simple_error_code();
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_request_read_message(const char *service_name,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               service_adaptor_inbox_message_s *inbox_msg,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == inbox_msg)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_read_message_req_s_type ")", __safe_add_string(service_name), request_id, chatroom_id, inbox_msg->msg_id, inbox_msg->msg_type, inbox_msg->sender, inbox_msg->receiver, inbox_msg->sent_time, __safe_add_string(inbox_msg->chat_msg), inbox_msg->chatroom_id, inbox_msg->chat_type, inbox_msg->message_ttl);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_REQUEST_READ_MESSAGE_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+               } else {
+                       __ipc_get_simple_error_code();
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_request_invite_chat(const char *service_name,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               long long int *inviting_members,
+                                               unsigned int inviting_members_len,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == inviting_members) || (1 > inviting_members_len)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(x)"));
+
+       for (int i = 0; i < inviting_members_len; i++) {
+               g_variant_builder_add(builder, "(x)", inviting_members[i]);
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_invite_chat_req_s_type ")", __safe_add_string(service_name), request_id, chatroom_id, builder, inviting_members_len);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_REQUEST_INVITE_CHAT_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+               } else {
+                       __ipc_get_simple_error_code();
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_request_end_chat(const char *service_name,
+                                               long long int request_id,
+                                               service_adaptor_end_chat_s **end_chats,
+                                               unsigned int end_chats_len,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == end_chats) || (1 > end_chats_len)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a" private_service_adaptor_end_chat_s_type));
+
+       for (int i = 0; i < end_chats_len; i++) {
+               g_variant_builder_add(builder, private_service_adaptor_end_chat_s_type, end_chats[i]->chatroom_id, end_chats[i]->deny_invitation);
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_end_chat_req_s_type ")", __safe_add_string(service_name), request_id, builder, end_chats_len);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_REQUEST_END_CHAT_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+               } else {
+                       __ipc_get_simple_error_code();
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+
+int _dbus_request_unseal_message(const char *service_name,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               long long int sender_id,
+                                               long long int message_id,
+                                               const char *message_detail,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_unseal_message_req_s_type ")", __safe_add_string(service_name),
+                       request_id, chatroom_id, sender_id, message_id, __safe_add_string(message_detail));
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_REQUEST_UNSEAL_MESSAGE_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+               } else {
+                       __ipc_get_simple_error_code();
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+
+int _dbus_request_save_call_log(const char *service_name,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               const char *call_id,
+                                               const char *call_log_type,
+                                               long long int call_sender_id,
+                                               long long int call_receiver_id,
+                                               int conversaction_second,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_save_call_log_req_s_type ")", __safe_add_string(service_name),
+                       request_id, chatroom_id, call_id, call_log_type, call_sender_id, call_receiver_id, conversaction_second);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_REQUEST_SAVE_CALL_LOG_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+               } else {
+                       __ipc_get_simple_error_code();
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_request_current_time(const char *service_name,
+                                               long long int request_id,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_current_time_req_s_type ")", __safe_add_string(service_name), request_id);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_REQUEST_CURRENT_TIME_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+               } else {
+                       __ipc_get_simple_error_code();
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_request_get_connection_policy(const char *service_name,
+                                               service_adaptor_connection_policy_e *policy,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_get_connection_policy_req_s_type ")", __safe_add_string(service_name));
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_REQUEST_GET_CONNECTION_POLICY_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result,
+                               G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_connection_policy_res_s_type)))) {
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       GVariant *gv_policy = g_variant_get_child_value(call_result_struct[0], 0);
+                       *policy = (int) g_variant_get_int32(gv_policy);
+                       g_variant_unref(gv_policy);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = _get_result_code(remote_call_result);
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_request_set_connection_policy(const char *service_name,
+                                               service_adaptor_connection_policy_e *policy,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_set_connection_policy_req_s_type ")", __safe_add_string(service_name), (int32_t)*policy);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_REQUEST_SET_CONNECTION_POLICY_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result,
+                               G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_connection_policy_res_s_type)))) {
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       GVariant *gv_policy = g_variant_get_child_value(call_result_struct[0], 0);
+                       *policy = (int) g_variant_get_int32(gv_policy);
+                       g_variant_unref(gv_policy);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = _get_result_code(remote_call_result);
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_get_chat_id_list(const char *service_name,
+                                               service_adaptor_phone_number_s **phone_numbers,
+                                               unsigned int phone_numbers_len,
+                                               void *user_data,
+                                               service_adaptor_chat_id_s ***chat_ids,
+                                               unsigned int *chat_ids_len,
+                                               void **server_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == phone_numbers) || (1 > phone_numbers_len)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a" private_service_adaptor_phone_number_s_type));
+
+       for (int i = 0; i < phone_numbers_len; i++) {
+               g_variant_builder_open(builder, G_VARIANT_TYPE(private_service_adaptor_phone_number_s_type));
+               __safe_g_variant_builder_add_string(builder, phone_numbers[i]->phonenumber);
+               __safe_g_variant_builder_add_string(builder, phone_numbers[i]->ccc);
+               g_variant_builder_close(builder);
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_chat_id_list_req_s_type ")", __safe_add_string(service_name), builder, phone_numbers_len);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_GET_CHAT_ID_LIST_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_chat_id_list_res_s_type)))) {
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = _get_result_code(remote_call_result);
+                       } else {
+                               if ((NULL != chat_ids) && (NULL != chat_ids_len)) {
+                                       __get_chat_id_list_res_type(call_result_struct[0], chat_ids, chat_ids_len, server_data);
+                               }
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_get_msisdn_list(const char *service_name,
+                                               long long int *chat_ids,
+                                               unsigned int chat_ids_len,
+                                               void *user_data,
+                                               service_adaptor_chat_id_s ***msisdns,
+                                               unsigned int *msisdns_len,
+                                               void **server_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == chat_ids) || (1 > chat_ids_len)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(x)"));
+
+       for (int i = 0; i < chat_ids_len; i++) {
+               g_variant_builder_add(builder, "(x)", chat_ids[i]);
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_msisdn_list_req_s_type ")", __safe_add_string(service_name), builder, chat_ids_len);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_GET_MSISDN_LIST_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_chat_id_list_res_s_type)))) {
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = _get_result_code(remote_call_result);
+                       } else {
+                               if ((NULL != msisdns) && (NULL != msisdns_len)) {
+                                       __get_chat_id_list_res_type(call_result_struct[0], msisdns, msisdns_len, server_data);
+                               }
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
diff --git a/src/dbus/dbus_client_push.c b/src/dbus/dbus_client_push.c
new file mode 100644 (file)
index 0000000..7822911
--- /dev/null
@@ -0,0 +1,202 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: dbus-client-push.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include "dbus_client.h"
+#include "dbus_client_push.h"
+#include "service-adaptor/dbus-server.h"
+#include "service_adaptor_client_type.h"
+#include "private/service-adaptor-client-push.h"
+#include "service_adaptor_client_log.h"
+
+#include "util/service_adaptor_client_util.h"
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+#define __SAFE_FREE(x)          do { free(x); (x) = NULL; } while (0)
+
+void __get_push_data_type(GVariant *parameters,
+                                               uint32_t *service_id,
+                                               service_adaptor_push_notification_s *noti_info)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[private_service_adaptor_push_data_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_push_data_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_id = g_variant_get_uint32(res_struct[idx++]);
+       noti_info->data = ipc_g_variant_dup_string(res_struct[idx++]);
+       noti_info->message = ipc_g_variant_dup_string(res_struct[idx++]);
+       noti_info->time = g_variant_get_int64(res_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_push_data_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+void on_push_signal(GDBusProxy *proxy,
+                                               gchar *sender_name,
+                                               gchar *signal_name,
+                                               GVariant *parameters,
+                                               gpointer user_data)
+{
+       if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_PUSH_DATA_SIGNAL)) {
+               uint32_t service_id = 0;
+               service_adaptor_push_notification_s noti_info;
+               service_adaptor_error_s *error_code = NULL;
+               service_adaptor_error_s error;
+               error.msg = NULL;
+               __get_push_data_type(parameters, &service_id, &noti_info);
+
+               service_adaptor_task_h task = _signal_queue_get_task(service_id);
+
+               sac_debug("==on_push_signal== task(%p) service_id(%u)", task, service_id);
+
+               if (NULL == task) {
+                       __SAFE_FREE(noti_info.data);
+                       __SAFE_FREE(noti_info.message);
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                       error_code = &error;
+
+                       if (NULL != error_code) {
+                               error_code->code = remote_call_result;
+                               error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+                       }
+               }
+
+               sac_debug("push data : %s", noti_info.data);
+               sac_debug("push message : %s", noti_info.message);
+               sac_debug("push time : %lld", noti_info.time);
+
+               service_adaptor_push_notification_cb callback = (service_adaptor_push_notification_cb) task->callback;
+
+               if (NULL != callback) {
+                       callback(task->handle, &noti_info, error_code, task->user_data);
+               }
+               __SAFE_FREE(noti_info.data);
+               __SAFE_FREE(noti_info.message);
+               __SAFE_FREE(error.msg);
+       }
+}
+
+static int __dbus_push_simple_operation(const char *file_name,
+                                               service_adaptor_error_s *error,
+                                               const char *method_name)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_push_register_req_s_type ")", file_name);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       method_name,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[2];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+                               ret = SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED;
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_push_register(const char *file_name,
+                                               service_adaptor_error_s *error)
+{
+       return __dbus_push_simple_operation(file_name, error, PRIVATE_DBUS_PUSH_REGISTER_METHOD);
+}
+
+int _dbus_push_deregister(const char *file_name,
+                                               service_adaptor_error_s *error)
+{
+       return __dbus_push_simple_operation(file_name, error, PRIVATE_DBUS_PUSH_DEREGISTER_METHOD);
+}
diff --git a/src/dbus/dbus_client_shop.c b/src/dbus/dbus_client_shop.c
new file mode 100644 (file)
index 0000000..99df4f4
--- /dev/null
@@ -0,0 +1,461 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: dbus-client-shop.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include "dbus_client.h"
+#include "dbus_client_shop.h"
+#include "service-adaptor/dbus-server.h"
+#include "service_adaptor_client_type.h"
+#include "private/service-adaptor-client-shop.h"
+
+#include "util/service_adaptor_client_util.h"
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+void __get_item_list_res_type(GVariant *call_result_struct,
+                                               service_adaptor_shop_item_s ***items,
+                                               unsigned int *items_len,
+                                               void **server_data)
+{
+       GVariant *res_info_struct[private_service_adaptor_shop_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_shop_res_s_type_length; j++) {
+               res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+       }
+
+       int idx = 0;
+       gsize item_count = g_variant_n_children(res_info_struct[idx]);
+
+       *items = (service_adaptor_shop_item_s **) g_malloc0(sizeof(service_adaptor_shop_item_s *) * item_count);
+
+       for (gsize i = 0; i < item_count; i++) {
+               GVariant *item_info_struct[private_service_adaptor_shop_item_s_type_length];
+               GVariant *item_info_entry_v = g_variant_get_child_value(res_info_struct[idx], i);
+               (*items)[i] = (service_adaptor_shop_item_s *) g_malloc0(sizeof(service_adaptor_shop_item_s));
+
+               for (size_t j = 0; j < private_service_adaptor_shop_item_s_type_length; j++) {
+                       item_info_struct[j] = g_variant_get_child_value(item_info_entry_v, j);
+               }
+
+               int idx2 = 0;
+               (*items)[i]->item_id = g_variant_get_int32(item_info_struct[idx2++]);
+               (*items)[i]->category_id = g_variant_get_int32(item_info_struct[idx2++]);
+
+               gsize ids_count = g_variant_n_children(item_info_struct[idx2]);
+               (*items)[i]->sticker_ids = (long *) g_malloc0(sizeof(long) * ids_count);
+
+               for (gsize k = 0; k < ids_count; k++) {
+                       GVariant *ids_info_entry_v = g_variant_get_child_value(item_info_struct[idx2], k);
+                       GVariant *ids_info_struct = g_variant_get_child_value(ids_info_entry_v, 0);;
+
+                       (*items)[i]->sticker_ids[k] = g_variant_get_int32(ids_info_struct);
+
+                       g_variant_unref(ids_info_struct);
+               }
+               idx2++;
+
+               (*items)[i]->sticker_ids_len    = g_variant_get_uint32(item_info_struct[idx2++]);
+               (*items)[i]->title              = ipc_g_variant_dup_string(item_info_struct[idx2++]);
+               (*items)[i]->character          = ipc_g_variant_dup_string(item_info_struct[idx2++]);
+               (*items)[i]->version            = g_variant_get_int32(item_info_struct[idx2++]);
+               (*items)[i]->download_url       = ipc_g_variant_dup_string(item_info_struct[idx2++]);
+               (*items)[i]->panel_url          = ipc_g_variant_dup_string(item_info_struct[idx2++]);
+               (*items)[i]->sticker_url        = ipc_g_variant_dup_string(item_info_struct[idx2++]);
+               (*items)[i]->file_size          = g_variant_get_int32(item_info_struct[idx2++]);
+               (*items)[i]->count              = g_variant_get_int32(item_info_struct[idx2++]);
+               (*items)[i]->character_code     = ipc_g_variant_dup_string(item_info_struct[idx2++]);
+               (*items)[i]->startdate          = (long long int) g_variant_get_int64(item_info_struct[idx2++]);
+               (*items)[i]->enddate            = (long long int) g_variant_get_int64(item_info_struct[idx2++]);
+               (*items)[i]->expired_date       = (long long int) g_variant_get_int64(item_info_struct[idx2++]);
+               (*items)[i]->valid_period       = (long long int) g_variant_get_int64(item_info_struct[idx2++]);
+
+               for (size_t j = 0; j < private_service_adaptor_shop_item_s_type_length; j++) {
+                       g_variant_unref(item_info_struct[j]);
+               }
+       }
+       idx++;
+
+       *items_len = g_variant_get_uint32(res_info_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_shop_res_s_type_length; j++) {
+               g_variant_unref(res_info_struct[j]);
+       }
+}
+
+GVariant *__create_shop_req_type(const char *service_name,
+                                               service_adaptor_shop_info_s *info,
+                                               void *user_data)
+{
+       GVariant *request = g_variant_new("(" private_service_adaptor_shop_req_s_type ")", __safe_add_string(service_name), info->category_id, info->item_id, info->sticker_id, __safe_add_string(info->lang_cd), __safe_add_string(info->cntry_cd), info->rwidth, info->rheight, info->start_idx, info->count);
+
+       return request;
+}
+
+void __get_shop_res_type(GVariant *call_result_struct,
+                                               service_adaptor_shop_item_s **item,
+                                               void **server_data)
+{
+       GVariant *res_info_struct[private_service_adaptor_shop_item_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_shop_item_s_type_length; j++) {
+               res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+       }
+
+       int idx = 0;
+       *item = (service_adaptor_shop_item_s *) calloc(1, sizeof(service_adaptor_shop_item_s));
+       if (NULL != *item) {
+               (*item)->item_id = g_variant_get_int32(res_info_struct[idx++]);
+               (*item)->category_id = g_variant_get_int32(res_info_struct[idx++]);
+
+               gsize ids_count = g_variant_n_children(res_info_struct[idx]);
+               (*item)->sticker_ids = (long *) calloc(ids_count, sizeof(long));
+
+               if (NULL != (*item)->sticker_ids) {
+                       for (gsize i = 0; i < ids_count; i++) {
+                               GVariant *ids_info_entry_v = g_variant_get_child_value(res_info_struct[idx], i);
+                               GVariant *ids_info_struct = g_variant_get_child_value(ids_info_entry_v, 0);;
+
+                               (*item)->sticker_ids[i] = g_variant_get_int32(ids_info_struct);
+
+                               g_variant_unref(ids_info_struct);
+                       }
+                       idx++;
+                       (*item)->sticker_ids_len = g_variant_get_uint32(res_info_struct[idx++]);
+               } else {
+                       (*item)->sticker_ids_len = 0U;
+                       idx++;
+                       idx++;
+               }
+               (*item)->title = ipc_g_variant_dup_string(res_info_struct[idx++]);
+               (*item)->character = ipc_g_variant_dup_string(res_info_struct[idx++]);
+               (*item)->version = g_variant_get_int32(res_info_struct[idx++]);
+               (*item)->download_url = ipc_g_variant_dup_string(res_info_struct[idx++]);
+               (*item)->panel_url = ipc_g_variant_dup_string(res_info_struct[idx++]);
+               (*item)->sticker_url = ipc_g_variant_dup_string(res_info_struct[idx++]);
+               (*item)->file_size = g_variant_get_int32(res_info_struct[idx++]);
+               (*item)->count = g_variant_get_int32(res_info_struct[idx++]);
+               (*item)->character_code = ipc_g_variant_dup_string(res_info_struct[idx++]);
+               (*item)->startdate = g_variant_get_int64(res_info_struct[idx++]);
+               (*item)->enddate = g_variant_get_int64(res_info_struct[idx++]);
+               (*item)->expired_date = g_variant_get_int64(res_info_struct[idx++]);
+               (*item)->valid_period = g_variant_get_int64(res_info_struct[idx++]);
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_shop_item_s_type_length; j++) {
+               g_variant_unref(res_info_struct[j]);
+       }
+}
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+/**    @brief
+ *     @return service_adaptor_error_s
+ *     @remarks :
+ */
+int _dbus_get_item_list(const char *service_name,
+                                               service_adaptor_shop_info_s *info,
+                                               void *user_data,
+                                               service_adaptor_shop_item_s ***items,
+                                               unsigned int *items_len,
+                                               void **server_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = __create_shop_req_type(service_name, info, user_data);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_GET_ITEM_LIST_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_shop_res_s_type)))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = _get_result_code(remote_call_result);
+                       } else {
+                               if ((NULL != items) && (NULL != items_len)) {
+                                       __get_item_list_res_type(call_result_struct[0], items, items_len, server_data);
+                               }
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_download_item_package(const char *service_name,
+                                               service_adaptor_shop_info_s *info,
+                                               void *user_data,
+                                               service_adaptor_shop_item_s **item,
+                                               void **server_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = __create_shop_req_type(service_name, info, user_data);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_DOWNLOAD_ITEM_PACKAGE_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_shop_item_s_type)))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = _get_result_code(remote_call_result);
+                       } else {
+                               if (NULL != item) {
+                                       __get_shop_res_type(call_result_struct[0], item, server_data);
+                               }
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_download_sticker(const char *service_name,
+                                               service_adaptor_shop_info_s *info,
+                                               void *user_data,
+                                               service_adaptor_shop_item_s **item,
+                                               void **server_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = __create_shop_req_type(service_name, info, user_data);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_DOWNLOAD_STICKER_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_shop_item_s_type)))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = _get_result_code(remote_call_result);
+                       } else {
+                               if (NULL != item) {
+                                       __get_shop_res_type(call_result_struct[0], item, server_data);
+                               }
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+int _dbus_get_panel_url(const char *service_name,
+                                               service_adaptor_shop_info_s *info,
+                                               void *user_data,
+                                               service_adaptor_shop_item_s **item,
+                                               void **server_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = __create_shop_req_type(service_name, info, user_data);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_GET_PANEL_URL_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+               if (NULL != g_error) {
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_shop_item_s_type)))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[3];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+                       call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+                               ret = _get_result_code(remote_call_result);
+                       } else {
+                               if (NULL != item) {
+                                       __get_shop_res_type(call_result_struct[0], item, server_data);
+                               }
+                       }
+
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+                       g_variant_unref(call_result_struct[2]);
+               }
+
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
diff --git a/src/dbus/dbus_client_storage.c b/src/dbus/dbus_client_storage.c
new file mode 100644 (file)
index 0000000..c1b6dbb
--- /dev/null
@@ -0,0 +1,1552 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: dbus-client-storage.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include "dbus_client.h"
+#include "dbus_client_storage.h"
+#include "service-adaptor/dbus-server.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "service-adaptor/dbus-server.h"
+#include "service_adaptor_client_storage.h"
+#include "service_adaptor_client_storage_internal.h"
+
+#include "private/service-adaptor-client.h"
+#include "private/service-adaptor-client-storage.h"
+
+#include "util/service_adaptor_client_util.h"
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+/******************************************************************************
+                               private feature
+******************************************************************************/
+
+void __private_get_file_progress_type(GVariant *parameters,
+                                               service_adaptor_file_h *file_handle,
+                                               uint64_t *progress_size,
+                                               uint64_t *total_size)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[private_service_adaptor_file_progress_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_file_progress_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *file_handle = (service_adaptor_file_h) calloc(1, sizeof(service_adaptor_file_s));
+       if (NULL != *file_handle) {
+               (*file_handle)->file_description = g_variant_get_int32(res_struct[idx]);
+       }
+       idx++;
+       *progress_size = g_variant_get_uint64(res_struct[idx++]);
+       *total_size = g_variant_get_uint64(res_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_file_progress_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+
+void __private_get_file_transfer_completion_type(GVariant *parameters,
+                                               service_adaptor_file_h *file_handle,
+                                               char **publish_url)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[private_service_adaptor_file_transfer_completion_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_file_transfer_completion_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *file_handle = (service_adaptor_file_h) calloc(1, sizeof(service_adaptor_file_s));
+       if (NULL != *file_handle) {
+               (*file_handle)->file_description = g_variant_get_int32(res_struct[idx]);
+       }
+       idx++;
+       *publish_url = ipc_g_variant_dup_string(res_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_file_transfer_completion_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+
+void __private_get_file_status_res_type(GVariant *call_result_struct,
+                                               service_adaptor_file_status_s **status,
+                                               void **server_data)
+{
+       GVariant *res_info_struct[private_service_adaptor_file_status_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_file_status_res_s_type_length; j++) {
+               res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+       }
+
+       int idx = 0;
+       *status = (service_adaptor_file_status_s *) calloc(1, sizeof(service_adaptor_file_status_s));
+       if (NULL != *status) {
+               (*status)->total_size = g_variant_get_int64(res_info_struct[idx++]);
+               (*status)->transferred_size = g_variant_get_int64(res_info_struct[idx++]);
+               (*status)->status = g_variant_get_int64(res_info_struct[idx++]);
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_file_status_res_s_type_length; j++) {
+               g_variant_unref(res_info_struct[j]);
+       }
+}
+
+void __private_get_file_handle_res_type(GVariant *call_result,
+                                               service_adaptor_file_h *file_handle,
+                                               service_adaptor_error_s *error,
+                                               int *ret)
+{
+       if (NULL != file_handle) {
+               if (((*file_handle) = (service_adaptor_file_h) calloc(1, sizeof(struct _service_adaptor_file_s)))) {
+                       GVariant *fd = g_variant_get_child_value(call_result, 0);
+                       (*file_handle)->file_description = g_variant_get_int32(fd);
+               } else {
+                       *ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+                       error->code = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+                       error->msg = strdup("Critical : Memory allocation failed");
+               }
+       }
+}
+
+/******************************************************************************
+                               private feature
+******************************************************************************/
+
+void __get_file_progress_type(GVariant *parameters,
+                                               long long int *_file_uid,
+                                               unsigned long long *_progress_size,
+                                               unsigned long long *_total_size)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[service_adaptor_file_progress_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_file_progress_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       do {
+               GVariant *fd_res_struct[service_adaptor_file_descriptor_s_type_length];
+               for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+                       fd_res_struct[k] = g_variant_get_child_value(res_struct[idx], k);
+               }
+               int fd_idx = 0;
+               *_file_uid = (long long int) g_variant_get_int64(fd_res_struct[fd_idx++]);
+
+               for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+                       g_variant_unref(fd_res_struct[k]);
+               }
+               idx++;
+       } while (0);
+
+       *_progress_size = (unsigned long long) g_variant_get_uint64(res_struct[idx++]);
+       *_total_size = (unsigned long long) g_variant_get_uint64(res_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_file_progress_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+
+void __get_file_transfer_state_changed_type(GVariant *parameters,
+                                               long long int *_file_uid,
+                                               int *_state)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *res_struct[service_adaptor_file_transfer_state_changed_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_file_transfer_state_changed_s_type_length; j++) {
+               res_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       do {
+               GVariant *fd_res_struct[service_adaptor_file_descriptor_s_type_length];
+               for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+                       fd_res_struct[k] = g_variant_get_child_value(res_struct[idx], k);
+               }
+               int fd_idx = 0;
+               *_file_uid = (long long int) g_variant_get_int64(fd_res_struct[fd_idx++]);
+
+               for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+                       g_variant_unref(fd_res_struct[k]);
+               }
+               idx++;
+       } while (0);
+
+       *_state = (int) g_variant_get_int32(res_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_file_transfer_state_changed_s_type_length; j++) {
+               g_variant_unref(res_struct[j]);
+       }
+}
+
+void __get_file_info_s_type(GVariant *call_result_struct,
+                                               service_storage_file_h *file_info)
+{
+       service_storage_file_h _file_info = NULL;
+       GVariant *res_info_struct[service_adaptor_file_info_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_file_info_s_type_length; j++) {
+               res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+       }
+
+       int idx1 = 0, idx2 = 0, idx3 = 0;
+       _file_info = service_storage_create_file_info();
+       if (NULL == _file_info) {
+               *file_info = NULL;
+
+               for (size_t j = 0; j < service_adaptor_file_info_s_type_length; j++) {
+                       g_variant_unref(res_info_struct[j]);
+               }
+               return;
+       }
+
+       _file_info->plugin_name                 = ipc_g_variant_dup_string(res_info_struct[idx1++]);
+       _file_info->object_id                   = ipc_g_variant_dup_string(res_info_struct[idx1++]);
+       _file_info->storage_path                = ipc_g_variant_dup_string(res_info_struct[idx1++]);
+       _file_info->file_size                   = g_variant_get_uint64(res_info_struct[idx1++]);
+       _file_info->created_time                = g_variant_get_uint64(res_info_struct[idx1++]);
+       _file_info->modified_time               = g_variant_get_uint64(res_info_struct[idx1++]);
+       _file_info->file_info_index             = g_variant_get_int32(res_info_struct[idx1++]);
+       _file_info->content_type                = g_variant_get_int32(res_info_struct[idx1++]);
+
+       GVariant *media_meta_info[service_adaptor_content_meta_s_type_length];
+       do {    /* get media_meta */
+               for (size_t k = 0; k < service_adaptor_content_meta_s_type_length; k++) {
+                       media_meta_info[k] = g_variant_get_child_value(res_info_struct[idx1], k);
+               }
+
+               _file_info->media_meta->mime_type               = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+               _file_info->media_meta->title                   = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+               _file_info->media_meta->album                   = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+               _file_info->media_meta->artist                  = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+               _file_info->media_meta->genere                  = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+               _file_info->media_meta->recorded_date           = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+               _file_info->media_meta->width                   = g_variant_get_int32(media_meta_info[idx2++]);
+               _file_info->media_meta->height                  = g_variant_get_int32(media_meta_info[idx2++]);
+               _file_info->media_meta->duration                = g_variant_get_int32(media_meta_info[idx2++]);
+               _file_info->media_meta->copyright               = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+               _file_info->media_meta->track_num               = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+               _file_info->media_meta->description             = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+               _file_info->media_meta->composer                = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+               _file_info->media_meta->year                    = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+               _file_info->media_meta->bitrate                 = g_variant_get_int32(media_meta_info[idx2++]);
+               _file_info->media_meta->samplerate              = g_variant_get_int32(media_meta_info[idx2++]);
+               _file_info->media_meta->channel                 = g_variant_get_int32(media_meta_info[idx2++]);
+               _file_info->media_meta->extra_media_meta        = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+
+               for (size_t k = 0; k < service_adaptor_content_meta_s_type_length; k++) {
+                       g_variant_unref(media_meta_info[k]);
+               }
+       } while (0);
+       idx1++;
+
+       GVariant *cloud_meta_info[service_adaptor_cloud_meta_s_type_length];
+       do { /* get cloud_meta */
+               for (size_t l = 0; l < service_adaptor_cloud_meta_s_type_length; l++) {
+                       cloud_meta_info[l] = g_variant_get_child_value(res_info_struct[idx1], l);
+               }
+
+               _file_info->cloud_meta->service_name            = ipc_g_variant_dup_string(cloud_meta_info[idx3++]);
+               _file_info->cloud_meta->usage_byte              = g_variant_get_uint64(cloud_meta_info[idx3++]);
+               _file_info->cloud_meta->quota_byte              = g_variant_get_uint64(cloud_meta_info[idx3++]);
+               _file_info->cloud_meta->extra_cloud_meta        = ipc_g_variant_dup_string(cloud_meta_info[idx3++]);
+
+               for (size_t l = 0; l < service_adaptor_cloud_meta_s_type_length; l++) {
+                       g_variant_unref(cloud_meta_info[l]);
+               }
+       } while (0);
+       idx1++;
+
+
+       _file_info->extra_file_info     = ipc_g_variant_dup_string(res_info_struct[idx1++]);
+
+       for (size_t j = 0; j < service_adaptor_file_info_s_type_length; j++) {
+               g_variant_unref(res_info_struct[j]);
+       }
+
+       *file_info = _file_info;
+}
+
+
+void __get_get_root_folder_path_res_type(GVariant *call_result_struct,
+                                               char **root_folder_path)
+{
+       GVariant *res_info_struct[service_adaptor_get_root_folder_path_res_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_get_root_folder_path_res_s_type_length; j++) {
+               res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+       }
+
+       int idx = 0;
+       *root_folder_path = ipc_g_variant_dup_string(res_info_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_get_root_folder_path_res_s_type_length; j++) {
+               g_variant_unref(res_info_struct[j]);
+       }
+}
+
+void __get_get_file_list_res_type(GVariant *in_parameters,
+                                               service_storage_file_h **file_info_list,
+                                               unsigned int *file_info_list_len)
+{
+       GVariant *res_info_struct[service_adaptor_get_file_list_res_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_get_file_list_res_s_type_length; j++) {
+               res_info_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       gsize list_count = g_variant_n_children(res_info_struct[idx]);
+       *file_info_list = (service_storage_file_s **) calloc(list_count, sizeof(service_storage_file_s *));
+
+       if (NULL != *file_info_list) {
+               for (gsize i = 0; i < list_count; i++) {
+                       GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx], i);
+
+                       __get_file_info_s_type(info_entry_v, &((*file_info_list)[i]));
+
+                       g_variant_unref(info_entry_v);
+               }
+               idx++;
+               *file_info_list_len = g_variant_get_uint32(res_info_struct[idx++]);
+       } else {
+               *file_info_list_len = 0U;
+       }
+
+       for (size_t j = 0; j < service_adaptor_get_file_list_res_s_type_length; j++) {
+               g_variant_unref(res_info_struct[j]);
+       }
+}
+
+void __get_file_descriptor_s_type(GVariant *call_result_struct,
+                                               long long int *_file_uid)
+{
+       GVariant *res_info_struct[service_adaptor_file_descriptor_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_file_descriptor_s_type_length; j++) {
+               res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+       }
+
+       int idx = 0;
+       *_file_uid = (long long int) g_variant_get_int64(res_info_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_file_descriptor_s_type_length; j++) {
+               g_variant_unref(res_info_struct[j]);
+       }
+}
+
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+void on_storage_signal(GDBusProxy *proxy,
+                                               gchar *sender_name,
+                                               gchar *signal_name,
+                                               GVariant *parameters,
+                                               gpointer user_data)
+{
+       if (0 == g_strcmp0(signal_name, DBUS_STORAGE_FILE_PROGRESS_SIGNAL)) {
+               long long int file_uid = 0;
+               unsigned long long progress_size = 0;
+               unsigned long long total_size = 0;
+
+               __get_file_progress_type(parameters, &file_uid, &progress_size, &total_size);
+
+               service_adaptor_task_h task = _queue_get_task(file_uid);
+
+               if (NULL == task) {
+                       sac_warning("Callback task get failed");
+                       return;
+               } else if (NULL == task->handle) {
+                       sac_warning("Callback task->handle get failed");
+                       return;
+               } else {
+                       service_storage_task_h storage_task = (service_storage_task_h) task->handle;
+
+                       if (NULL != storage_task->progress_callback) {
+                               sac_debug("Call progress callback[%lld] (%llu/%llu byte)", file_uid, progress_size, total_size);
+                               storage_task->progress_callback(progress_size, total_size, storage_task->progress_user_data);
+                       }
+               }
+       } else if (0 == g_strcmp0(signal_name, DBUS_STORAGE_FILE_TRANSFER_STATE_CHANGED_SIGNAL)) {
+               long long int file_uid = 0;
+               int state = 0;
+
+               __get_file_transfer_state_changed_type(parameters, &file_uid, &state);
+
+               /* Convert to sac enum from sa enum */
+               service_storage_task_state_e _state;
+               switch (state) {
+               case SERVICE_ADAPTOR_FILE_TRANSFER_STATE_IN_PROGRESS:
+                       _state = SERVICE_STORAGE_TASK_IN_PROGRESS;
+                       break;
+               case SERVICE_ADAPTOR_FILE_TRANSFER_STATE_COMPLETED:
+                       _state = SERVICE_STORAGE_TASK_COMPLETED;
+                       break;
+               case SERVICE_ADAPTOR_FILE_TRANSFER_STATE_CANCELED:
+                       _state = SERVICE_STORAGE_TASK_CANCELED;
+                       break;
+               case SERVICE_ADAPTOR_FILE_TRANSFER_STATE_FAILED:
+                       _state = SERVICE_STORAGE_TASK_FAILED;
+                       break;
+               default:
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+               char *remote_call_message = ipc_g_variant_dup_string(call_result[1]);
+
+               service_adaptor_set_last_result((int) remote_call_result, remote_call_message);
+               free(remote_call_message);
+
+               service_adaptor_task_h task = _queue_get_task(file_uid);
+
+               if (NULL == task) {
+                       sac_warning("Callback task get failed");
+                       return;
+               } else if (NULL == task->handle) {
+                       sac_warning("Callback task->handle get failed");
+                       return;
+               } else {
+                       service_storage_task_h storage_task = (service_storage_task_h) task->handle;
+
+                       if (NULL != storage_task->state_callback) {
+                               sac_debug("Call state callback[%lld] (%d state)", file_uid, _state);
+                               storage_task->state_callback(_state, storage_task->state_user_data);
+                       }
+               }
+       } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_STORAGE_FILE_PROGRESS_SIGNAL)) {
+/******************************************************************************
+                               private feature
+******************************************************************************/
+               service_adaptor_file_h file_handle = NULL;
+               uint64_t progress_size = 0;
+               uint64_t total_size = 0;
+               service_adaptor_error_s *error_code = NULL;
+
+               __private_get_file_progress_type(parameters, &file_handle, &progress_size, &total_size);
+
+               service_adaptor_task_h task = _signal_queue_get_task(PRIVATE_SIGNAL_FILE_PROGRESS_ID);
+
+               if (NULL == task) {
+                       free(file_handle);
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                       error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+                       if (NULL != error_code) {
+                               error_code->code = remote_call_result;
+                               error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+                       }
+               }
+
+               service_adaptor_file_progress_cb callback = (service_adaptor_file_progress_cb) task->callback;
+
+               if (NULL != callback) {
+                       callback(task->handle, file_handle, progress_size, total_size, error_code, task->user_data);
+               }
+               if (NULL != error_code) {
+                       free(error_code->msg);
+                       free(error_code);
+               }
+               free(file_handle);
+       } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_STORAGE_FILE_TRANSFER_COMPLETION_SIGNAL)) {
+               service_adaptor_file_h file_handle = NULL;
+               char *publish_url = NULL;
+               service_adaptor_error_s *error_code = NULL;
+
+               __private_get_file_transfer_completion_type(parameters, &file_handle, &publish_url);
+
+               service_adaptor_task_h task = _signal_queue_get_task(PRIVATE_SIGNAL_FILE_TRANSFER_COMPLETION_ID);
+
+               if (NULL == task) {
+                       free(file_handle);
+                       return;
+               }
+
+               GVariant *call_result[2];
+               call_result[0] = g_variant_get_child_value(parameters, 1);
+               call_result[1] = g_variant_get_child_value(parameters, 2);
+
+               uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                       error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+                       if (NULL != error_code) {
+                               error_code->code = remote_call_result;
+                               error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+                       }
+               }
+
+               service_adaptor_file_transfer_completion_cb callback = (service_adaptor_file_transfer_completion_cb) task->callback;
+
+               if (NULL != callback) {
+                       callback(task->handle, file_handle, publish_url, error_code, task->user_data);
+               }
+               if (NULL != error_code) {
+                       free(error_code->msg);
+                       free(error_code);
+               }
+               free(file_handle);
+       }
+
+/******************************************************************************
+                               private feature
+******************************************************************************/
+
+
+}
+
+/**    @brief
+ *     @return service_adaptor_error_s
+ *     @remarks :
+ */
+int _dbus_download_file(const char *service_name,
+                                               const char *server_path,
+                                               const char *download_path,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == server_path) || (NULL == download_path)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), server_path, download_path);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_DOWNLOAD_FILE_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       ret = _ipc_get_simple_result(call_result, g_error, error);
+
+       return ret;
+}
+
+/**    @brief
+ *     @return service_adaptor_error_s
+ *     @remarks :
+ */
+int _dbus_download_thumbnail(const char *service_name,
+                                               const char *server_path,
+                                               const char *download_path,
+                                               int thumbnail_size,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("(" service_adaptor_download_thumbnail_req_s_type ")", service_name, server_path, download_path, (int32_t)thumbnail_size);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_DOWNLOAD_THUMBNAIL_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       ret = _ipc_get_simple_result(call_result, g_error, error);
+
+       return ret;
+}
+
+int _dbus_upload_file(const char *service_name,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               service_storage_file_h *file_info,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+       service_storage_file_h _file_info = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == upload_path) || (NULL == server_path)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), upload_path, server_path);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_UPLOAD_FILE_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_info_s_type),
+               __get_file_info_s_type(call_result_struct[0], &_file_info);
+               *file_info = _file_info;
+       );
+
+       return ret;
+}
+
+int _dbus_get_root_folder_path(const char *service_name,
+                                               char **root_folder_path,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == root_folder_path)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" service_adaptor_get_root_folder_path_req_s_type ")", __safe_add_string(service_name));
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_GET_ROOT_FOLDER_PATH_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_get_root_folder_path_res_s_type),
+               __get_get_root_folder_path_res_type(call_result_struct[0], root_folder_path);
+       );
+
+       return ret;
+}
+
+
+int _dbus_make_directory(const char *service_name,
+                                               const char *folder_path,
+                                               service_storage_file_h *file_info,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+       service_storage_file_h _file_info = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == folder_path)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" service_adaptor_make_directory_req_s_type ")", service_name, folder_path);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_MAKE_DIRECTORY_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_info_s_type),
+               __get_file_info_s_type(call_result_struct[0], &_file_info);
+               *file_info = _file_info;
+       );
+
+       return ret;
+
+}
+
+int _dbus_remove_file(const char *service_name,
+                                               const char *file_path,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("(" service_adaptor_remove_file_req_s_type ")", service_name, file_path);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_REMOVE_FILE_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       ret = _ipc_get_simple_result(call_result, g_error, error);
+
+       return ret;
+
+
+}
+
+int _dbus_remove_directory(const char *service_name,
+                                               const char *folder_path,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("(" service_adaptor_remove_directory_req_s_type ")", service_name, folder_path);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_REMOVE_DIRECTORY_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       ret = _ipc_get_simple_result(call_result, g_error, error);
+
+       return ret;
+
+
+}
+
+int _dbus_move_file(const char *service_name,
+                                               const char *src_file_path,
+                                               const char *dst_file_path,
+                                               service_storage_file_h *file_info,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+       service_storage_file_h _file_info = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("(" service_adaptor_move_file_req_s_type ")",
+                       service_name, src_file_path, dst_file_path);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_MOVE_FILE_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_info_s_type),
+               __get_file_info_s_type(call_result_struct[0], &_file_info);
+               *file_info = _file_info;
+       );
+
+       return ret;
+
+
+}
+
+int _dbus_move_directory(const char *service_name,
+                                               const char *src_folder_path,
+                                               const char *dst_folder_path,
+                                               service_storage_file_h *file_info,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+       service_storage_file_h _file_info = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("(" service_adaptor_move_directory_req_s_type ")", __safe_add_string(service_name), __safe_add_string(src_folder_path), __safe_add_string(dst_folder_path));
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_MOVE_DIRECTORY_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_info_s_type),
+               __get_file_info_s_type(call_result_struct[0], &_file_info);
+               *file_info = _file_info;
+       );
+
+       return ret;
+}
+
+int _dbus_get_file_list(const char *service_name,
+                                               const char *parent_path,
+                                               service_storage_file_h **file_info_list,
+                                               unsigned int *file_info_list_len,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("(" service_adaptor_get_file_list_req_s_type ")", service_name, parent_path);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_GET_FILE_LIST_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_get_file_list_res_s_type),
+               __get_get_file_list_res_type(call_result_struct[0], file_info_list, file_info_list_len);
+       );
+
+       return ret;
+}
+
+int _dbus_open_upload_file(const char *_service_name,
+                                               const char *_file_path,
+                                               const char *_upload_path,
+                                               long long int *_task_id,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("(" service_adaptor_open_upload_file_req_s_type ")", _service_name, _file_path, _upload_path);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_OPEN_UPLOAD_FILE_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_descriptor_s_type),
+               long long int file_uid = 0;
+               __get_file_descriptor_s_type(call_result_struct[0], &file_uid);
+               *_task_id = file_uid;
+       );
+
+       return ret;
+}
+
+int _dbus_open_download_file(const char *_service_name,
+                                               const char *_storage_path,
+                                               const char *_download_path,
+                                               long long int *_task_id,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("(" service_adaptor_open_download_file_req_s_type ")", _service_name, _storage_path, _download_path);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_OPEN_DOWNLOAD_FILE_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_descriptor_s_type),
+               long long int file_uid = 0;
+               __get_file_descriptor_s_type(call_result_struct[0], &file_uid);
+               *_task_id = file_uid;
+       );
+
+       return ret;
+}
+
+int _dbus_open_download_thumbnail(const char *_service_name,
+                                               const char *_storage_path,
+                                               const char *_download_path,
+                                               int _thumbnail_size,
+                                               long long int *_task_id,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("(" service_adaptor_open_download_thumbnail_req_s_type ")", _service_name, _storage_path, _download_path, _thumbnail_size);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_OPEN_DOWNLOAD_THUMBNAIL_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_descriptor_s_type),
+               long long int file_uid = 0;
+               __get_file_descriptor_s_type(call_result_struct[0], &file_uid);
+               *_task_id = file_uid;
+       );
+
+       return ret;
+}
+
+int __dbus_send_simple_fd_for_task(GVariant *request,
+                                               const char *_method_name,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       _method_name,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       ret = _ipc_get_simple_result(call_result, g_error, error);
+
+       return ret;
+}
+
+
+int _dbus_close_file_task(const char *_service_name,
+                                               long long int _task_id,
+                                               service_adaptor_error_s *error)
+{
+       GVariant *request = g_variant_new("("service_adaptor_close_file_req_s_type")", _service_name, (int64_t)_task_id);
+
+       return __dbus_send_simple_fd_for_task(request, DBUS_CLOSE_FILE_METHOD, error);
+}
+
+int _dbus_cancel_upload_file(const char *_service_name,
+                                               long long int _task_id,
+                                               service_adaptor_error_s *error)
+{
+       GVariant *request = g_variant_new("("service_adaptor_cancel_file_task_req_s_type")", _service_name, (int64_t)_task_id);
+
+       return __dbus_send_simple_fd_for_task(request, DBUS_CANCEL_UPLOAD_FILE_METHOD, error);
+}
+
+int _dbus_cancel_download_file(const char *_service_name,
+                                               long long int _task_id,
+                                               service_adaptor_error_s *error)
+{
+       GVariant *request = g_variant_new("("service_adaptor_cancel_file_task_req_s_type")", _service_name, (int64_t)_task_id);
+
+       return __dbus_send_simple_fd_for_task(request, DBUS_CANCEL_DOWNLOAD_FILE_METHOD, error);
+}
+
+int _dbus_cancel_download_thumbnail(const char *_service_name,
+                                               long long int _task_id,
+                                               service_adaptor_error_s *error)
+{
+       GVariant *request = g_variant_new("("service_adaptor_cancel_file_task_req_s_type")", _service_name, (int64_t)_task_id);
+
+       return __dbus_send_simple_fd_for_task(request, DBUS_CANCEL_DOWNLOAD_THUMBNAIL_METHOD, error);
+}
+
+
+
+
+
+int _dbus_start_upload_file(const char *_service_name,
+                                               long long int _task_id,
+                                               const char *_storage_path,
+                                               bool _need_progress,
+                                               bool _need_state,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("("service_adaptor_start_upload_file_req_s_type")", _service_name, (int64_t)_task_id, _storage_path, _need_progress, _need_state);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_START_UPLOAD_FILE_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       ret = _ipc_get_simple_result(call_result, g_error, error);
+
+       return ret;
+}
+
+
+int _dbus_start_download_file(const char *_service_name,
+                                               long long int _task_id,
+                                               const char *_storage_path,
+                                               bool _need_progress,
+                                               bool _need_state,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("("service_adaptor_start_download_file_req_s_type")", _service_name, (int64_t)_task_id, _storage_path, _need_progress, _need_state);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_START_DOWNLOAD_FILE_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       ret = _ipc_get_simple_result(call_result, g_error, error);
+
+       return ret;
+}
+
+
+int _dbus_start_download_thumbnail(const char *_service_name,
+                                               long long int _task_id,
+                                               const char *_storage_path,
+                                               int _thumbnail_size,
+                                               bool _need_progress,
+                                               bool _need_state,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       GVariant *request = g_variant_new("("service_adaptor_start_download_thumbnail_req_s_type")", _service_name, (int64_t)_task_id, _storage_path, (int32_t)_thumbnail_size, _need_progress, _need_state);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       DBUS_START_DOWNLOAD_THUMBNAIL_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       ret = _ipc_get_simple_result(call_result, g_error, error);
+
+       return ret;
+}
+
+
+/******************************************************************************
+                               private feature
+******************************************************************************/
+
+
+int _private_dbus_upload_file_async(const char *service_name,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               service_adaptor_file_h *file_handle,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == upload_path) || (NULL == server_path)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), upload_path, server_path);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_UPLOAD_FILE_ASYNC_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_s_type),
+               __private_get_file_handle_res_type(call_result_struct[0], file_handle, error, &ret);
+       );
+
+       return ret;
+}
+
+
+
+int _private_dbus_download_file_async(const char *service_name,
+                                               const char *server_path,
+                                               const char *download_path,
+                                               service_adaptor_file_h *file_handle,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == server_path) || (NULL == download_path)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), server_path, download_path);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_DOWNLOAD_FILE_ASYNC_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_s_type),
+               __private_get_file_handle_res_type(call_result_struct[0], file_handle, error, &ret);
+       );
+
+       return ret;
+}
+
+
+
+
+/**    @brief
+ *     @return service_adaptor_error_s
+ *     @remarks :
+ */
+int _dbus_download_file_publish(const char *service_name,
+                                               const char *server_path,
+                                               const char *download_path,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == server_path) || (NULL == download_path)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), server_path, download_path);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_DOWNLOAD_FILE_PUBLISH_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       ret = _ipc_get_simple_result(call_result, g_error, error);
+
+       return ret;
+}
+
+int _dbus_download_file_publish_async(const char *service_name,
+                                               const char *server_path,
+                                               const char *download_path,
+                                               service_adaptor_file_h *file_handle,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == server_path) || (NULL == download_path)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), server_path, download_path);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_DOWNLOAD_FILE_PUBLISH_ASYNC_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_s_type),
+               __private_get_file_handle_res_type(call_result_struct[0], file_handle, error, &ret);
+       );
+
+       return ret;
+}
+
+int _dbus_upload_file_publish(const char *service_name,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               char **publish_url,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == upload_path) || (NULL == server_path)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), upload_path, server_path);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_UPLOAD_FILE_PUBLISH_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_publish_s_type),
+               if (NULL != publish_url) {
+                       GVariant *url = g_variant_get_child_value(call_result_struct[0], 0);
+                       *publish_url = ipc_g_variant_dup_string(url);
+               }
+       );
+
+       return ret;
+}
+
+int _dbus_upload_file_publish_async(const char *service_name,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               service_adaptor_file_h *file_handle,
+                                               void *user_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == upload_path) || (NULL == server_path)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), upload_path, server_path);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_UPLOAD_FILE_PUBLISH_ASYNC_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_s_type),
+               __private_get_file_handle_res_type(call_result_struct[0], file_handle, error, &ret);
+       );
+
+       return ret;
+}
+
+int _dbus_get_file_status(const char *service_name,
+                                               service_adaptor_file_h file_handle,
+                                               service_adaptor_file_status_s **status,
+                                               void **server_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == file_handle)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_file_status_req_s_type ")", __safe_add_string(service_name), file_handle->file_description);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_GET_FILE_STATUS_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_status_res_s_type),
+               if (NULL != status) {
+                       __private_get_file_status_res_type(call_result_struct[0], status, server_data);
+               }
+       );
+
+       return ret;
+}
+
+int _dbus_cancel_file_transfer(const char *service_name,
+                                               service_adaptor_file_h file_handle,
+                                               void **server_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == file_handle)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_file_status_req_s_type ")", __safe_add_string(service_name), file_handle->file_description);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_CANCEL_FILE_TRANSFER_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       ret = _ipc_get_simple_result(call_result, g_error, error);
+
+       return ret;
+}
+
+int _dbus_pause_file_transfer(const char *service_name,
+                                               service_adaptor_file_h file_handle,
+                                               void **server_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == file_handle)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_file_status_req_s_type ")", __safe_add_string(service_name), file_handle->file_description);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_PAUSE_FILE_TRANSFER_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       ret = _ipc_get_simple_result(call_result, g_error, error);
+
+       return ret;
+}
+
+int _dbus_resume_file_transfer(const char *service_name,
+                                               service_adaptor_file_h file_handle,
+                                               void **server_data,
+                                               service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GError *g_error = NULL;
+       GVariant *call_result = NULL;
+
+       GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+       ipc_check_proxy(sac_interface_proxy);
+
+       if ((NULL == service_name) || (NULL == file_handle)) {
+               error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error->msg = strdup("Invalid Param");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       GVariant *request = g_variant_new("(" private_service_adaptor_file_status_req_s_type ")", __safe_add_string(service_name), file_handle->file_description);
+
+       call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+                       PRIVATE_DBUS_RESUME_FILE_TRANSFER_METHOD,
+                       request,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &g_error);
+
+       ret = _ipc_get_simple_result(call_result, g_error, error);
+
+       return ret;
+}
+
+
+/******************************************************************************
+                               private feature
+******************************************************************************/
diff --git a/src/service_adaptor_client.c b/src/service_adaptor_client.c
new file mode 100644 (file)
index 0000000..b0fbcb8
--- /dev/null
@@ -0,0 +1,1104 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+
+#include <glib.h>
+#include <tizen.h>
+#include <security-server.h>
+/* #include <app.h> */
+#include <app_common.h>
+/* #include <app_manager.h> */
+
+#include "service_adaptor_client.h"
+#include "service_adaptor_client_plugin.h"
+#include "service_adaptor_client_private.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "dbus_client.h"
+#include "dbus_client_layer.h"
+#include "service-adaptor/dbus-server.h"
+
+#include "util/service_adaptor_client_util.h"
+/************************* private feature */
+#include "private/service-adaptor-client.h"
+/************************* private feature */
+
+#define ERROR_MSG_MAX_LEN 2048
+
+static __thread int last_error_code = 0;
+static __thread char last_error_message[ERROR_MSG_MAX_LEN] = "";
+
+/**
+ * Work Queue about async functions
+ */
+GList *g_service_adaptor_task_queue = NULL;
+GList *g_service_adaptor_signal_queue = NULL;
+
+/**
+ * Connection counter. It is needed to allow multiple connections from single process.
+ */
+static int connections_counter = 0;
+
+static GMutex connections_counter_mutex;
+
+static service_adaptor_h g_service_adaptor = NULL;
+
+/**    @brief  Adds Task in Queue
+ *     @return int
+ *     @remarks :
+ */
+int _queue_add_task(int64_t _id,
+                                               uint32_t _callback,
+                                               void *_handle,
+                                               void *user_data)
+{
+       FUNC_START();
+
+       service_adaptor_task_h task = (service_adaptor_task_h) g_malloc0(sizeof(service_adaptor_task_s));
+
+       if (NULL == task) {
+               FUNC_STOP();
+               return -1;
+       }
+
+       task->id = _id;
+       task->callback = _callback;
+       task->handle = _handle;
+       task->user_data = user_data;
+
+       g_service_adaptor_task_queue = g_list_append(g_service_adaptor_task_queue, task);
+
+       FUNC_END();
+       return 0;
+}
+
+/**    @brief  Adds Task in Queue
+ *     @return int
+ *     @remarks :
+ */
+int _queue_del_task(service_adaptor_task_h _task)
+{
+       FUNC_START();
+       service_adaptor_task_h target = NULL;
+
+       for (GList *list = g_list_first(g_service_adaptor_task_queue); list != NULL; list = g_list_next(list)) {
+               service_adaptor_task_h data = (service_adaptor_task_h) list->data;
+
+               if ((NULL != data) && (_task == data)) {
+                       target = data;
+                       break;
+               }
+       }
+
+       if (NULL != target) {
+               g_service_adaptor_task_queue = g_list_remove(g_service_adaptor_task_queue, target);
+               g_free(target);
+               target = NULL;
+       }
+
+       FUNC_END();
+       return 0;
+}
+
+/**    @brief  Adds Task in Queue
+ *     @return service_adaptor_task_h
+ *     @remarks :
+ */
+service_adaptor_task_h _queue_get_task(int64_t id)
+{
+       FUNC_START();
+       service_adaptor_task_h target = NULL;
+
+       for (GList *list = g_list_first(g_service_adaptor_task_queue); list != NULL; list = g_list_next(list)) {
+               service_adaptor_task_h data = (service_adaptor_task_h) list->data;
+
+               if ((NULL != data) && (id == data->id)) {
+                       target = data;
+                       break;
+               }
+       }
+
+       FUNC_END();
+       return target;
+}
+
+/**    @brief  Clears Task in Queue
+ *     @return void
+ *     @remarks :
+ */
+void _queue_clear_task()
+{
+       FUNC_START();
+       if (NULL != g_service_adaptor_task_queue) {
+               g_list_free(g_service_adaptor_task_queue);
+       }
+       g_service_adaptor_task_queue = NULL;
+}
+
+/**     @brief  Adds Task in Queue
+ *      @return int
+ *      @remarks :
+ */
+int _signal_queue_add_task(int64_t _id,
+                                               uint32_t _callback,
+                                               void *_handle,
+                                               void *user_data)
+{
+       FUNC_START();
+
+       service_adaptor_task_h task = (service_adaptor_task_h) g_malloc0(sizeof(service_adaptor_task_s));
+
+       if (NULL == task) {
+               FUNC_STOP();
+               return -1;
+       }
+
+       task->id = _id;
+       task->callback = _callback;
+       task->handle = _handle;
+       task->user_data = user_data;
+
+       g_service_adaptor_signal_queue = g_list_append(g_service_adaptor_signal_queue, task);
+
+       FUNC_END();
+       return 0;
+}
+
+/**     @brief  Adds Task in Queue
+ *      @return service_adaptor_task_h
+ *      @remarks :
+ */
+service_adaptor_task_h _signal_queue_get_task(int64_t _id)
+{
+       FUNC_START();
+       service_adaptor_task_h target = NULL;
+
+       for (GList *list = g_list_first(g_service_adaptor_signal_queue); list != NULL; list = g_list_next(list)) {
+               service_adaptor_task_h data = (service_adaptor_task_h) list->data;
+
+               if ((NULL != data) && (_id == data->id)) {
+                       target = data;
+                       break;
+               }
+       }
+
+       FUNC_END();
+       return target;
+}
+
+/**     @brief  Adds Task in Queue
+ *      @return int
+ *      @remarks :
+ */
+int _signal_queue_del_task(service_adaptor_task_h _task)
+{
+       FUNC_START();
+       service_adaptor_task_h target = NULL;
+
+       for (GList *list = g_list_first(g_service_adaptor_signal_queue); list != NULL; list = g_list_next(list)) {
+               service_adaptor_task_h data = (service_adaptor_task_h) list->data;
+
+               if ((NULL != data) && (_task == data)) {
+                       target = data;
+                       break;
+               }
+       }
+
+       if (NULL != target) {
+               g_service_adaptor_signal_queue = g_list_remove(g_service_adaptor_signal_queue, target);
+               g_free(target);
+               target = NULL;
+       }
+
+       FUNC_END();
+       return 0;
+}
+
+/**     @brief  Adds Task in Queue
+ *      @return int
+ *      @remarks :
+ */
+int _signal_queue_del_task_by_id(int id)
+{
+       FUNC_START();
+       service_adaptor_task_h target = NULL;
+
+       int i, len = g_list_length(g_service_adaptor_signal_queue);
+       for (i = 0; i < len; i++) {
+               for (GList *list = g_list_first(g_service_adaptor_signal_queue); list != NULL; list = g_list_next(list)) {
+                       service_adaptor_task_h data = (service_adaptor_task_h) list->data;
+
+                       if ((NULL != data) && (id == data->id)) {
+                               target = data;
+                               break;
+                       }
+               }
+
+               if (NULL != target) {
+                       g_service_adaptor_signal_queue = g_list_remove(g_service_adaptor_signal_queue, target);
+                       g_free(target);
+               }
+       }
+
+       FUNC_END();
+       return 0;
+}
+
+/**     @brief  Clears Task in Queue
+ *      @return void
+ *      @remarks :
+ */
+void _signal_queue_clear_task()
+{
+       FUNC_START();
+       if (NULL != g_service_adaptor_signal_queue) {
+               g_list_free(g_service_adaptor_signal_queue);
+       }
+       g_service_adaptor_signal_queue = NULL;
+       FUNC_END();
+}
+
+int service_adaptor_check_handle_validate(service_adaptor_h handle)
+{
+       if ((NULL == handle) || (NULL == g_service_adaptor)) {
+               sac_error("The handle is invalid <user(%p) adaptor(%p)>", handle, g_service_adaptor);
+               return -1;
+       } else if (handle != g_service_adaptor) {
+               sac_error("The handle is invalid <user(%p) adaptor(%p)>", handle, g_service_adaptor);
+               return -2;
+       } else {
+               return 0;
+       }
+}
+
+void _service_adaptor_set_last_result(int code, const char *message)
+{
+       FUNC_START();
+       last_error_code = code;
+
+       memset(last_error_message, 0x00, ERROR_MSG_MAX_LEN);
+
+       if (NULL != message) {
+               strncpy(last_error_message, message, ERROR_MSG_MAX_LEN-1);
+       }
+       FUNC_END();
+}
+
+int service_adaptor_get_last_result(int *err)
+{
+       FUNC_START();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if (NULL == err) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+       *err = last_error_code;
+
+       FUNC_END();
+       return ret;
+}
+
+int service_adaptor_get_last_error_message(char **message)
+{
+       FUNC_START();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if (NULL == message) {
+               ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       } else if (0 >= strlen(last_error_message)) {
+               ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
+       } else {
+               *message = strdup(last_error_message);
+               ret = SERVICE_ADAPTOR_ERROR_NONE;
+       }
+
+       FUNC_END();
+       return ret;
+}
+
+/**    @brief  Connects Service Adaptor
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_create(service_adaptor_h *handle)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_h service = NULL;
+
+       g_mutex_lock(&connections_counter_mutex);
+
+       if (NULL == handle) {
+               g_mutex_unlock(&connections_counter_mutex);
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (0 < connections_counter) {
+               g_mutex_unlock(&connections_counter_mutex);
+
+               return SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED;
+       }
+
+       service = (service_adaptor_h) calloc(1, sizeof(service_adaptor_s));
+
+       if (NULL == service) {
+               service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_UNKNOWN, "Memory allocation failed");
+               g_mutex_unlock(&connections_counter_mutex);
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       int trd = 0;
+       char fingerprint[50] = {0, };
+       snprintf(fingerprint, 50, "%s/%d", SERVICE_ADAPTOR_START_KEY_PATH, getpid());
+       sac_debug("Trigger open : %s", fingerprint);
+       trd = open(fingerprint, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
+       if (0 > trd) {
+               sac_error("Trigger open failed (%d)", trd);
+               free(service);
+               g_mutex_unlock(&connections_counter_mutex);
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       int dbus_ret = _dbus_client_layer_init();
+
+       if (0 == dbus_ret) {
+               connections_counter = connections_counter + 1;
+       }
+
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       ret = _dbus_connect_service_adaptor(&error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(service);
+               close(trd);
+               remove(fingerprint);
+
+               g_mutex_unlock(&connections_counter_mutex);
+               free(error.msg);
+               return ret;
+       }
+
+       service->on_signal = NULL;
+
+/*     service->plugins = NULL; */
+/*     service->plugin_count = 0; */
+
+       *handle = service;
+       g_service_adaptor = service;
+
+       close(trd);
+       remove(fingerprint);
+
+       g_mutex_unlock(&connections_counter_mutex);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Disconnects Service Adaptor
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_destroy(service_adaptor_h handle)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if (NULL == handle) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       g_mutex_lock(&connections_counter_mutex);
+
+       if (0 >= connections_counter) {
+               connections_counter = 0;
+               g_service_adaptor = NULL;
+               g_mutex_unlock(&connections_counter_mutex);
+
+               ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+               return ret;
+       }
+
+       if (NULL != handle) {
+               free(handle);
+               handle = NULL;
+       }
+
+       connections_counter = connections_counter - 1;
+
+       if (0 == connections_counter) {
+               _dbus_client_layer_deinit();
+       }
+
+       g_service_adaptor = NULL;
+       g_mutex_unlock(&connections_counter_mutex);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Connects Service Adaptor
+ *     @return int
+ *     @remarks :
+ */
+int service_adaptor_set_state_changed_cb(service_adaptor_h handle,
+                                               service_adaptor_signal_cb callback,
+                                               void *user_data)
+{
+       FUNC_START();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if (NULL == handle) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       handle->on_signal = callback;
+       _signal_queue_add_task(SIGNAL_SERVICE_ADAPTOR, (uint32_t) callback, handle, user_data);
+
+       FUNC_END();
+       return ret;
+}
+
+int service_adaptor_unset_state_changed_cb(service_adaptor_h handle)
+{
+       FUNC_START();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if (NULL == handle) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       handle->on_signal = NULL;
+
+       FUNC_END();
+       return ret;
+}
+
+
+int service_adaptor_foreach_plugin(service_adaptor_h handle,
+                                               service_adaptor_plugin_cb callback,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       if (NULL == handle) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+       if (NULL == callback) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       plugin_entry_t **plugin_uris = NULL;
+       unsigned int plugins_len = 0;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+       ret = _dbus_get_plugin_list(&plugin_uris, &plugins_len, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       } else if ((NULL != plugin_uris) && (0 < plugins_len)) {
+               int i;
+               bool is_continue = true;
+               for (i = 0; i < plugins_len; i++) {
+                       if (is_continue) {
+                               is_continue = callback(plugin_uris[i]->plugin_uri, plugin_uris[i]->installed_mask, user_data);
+                       }
+                       free(plugin_uris[i]->plugin_uri);
+                       free(plugin_uris[i]);
+               }
+       } else {
+               ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
+       }
+       free(plugin_uris);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_adaptor_create_plugin(service_adaptor_h handle,
+                                               const char *plugin_uri,
+                                               service_plugin_h *plugin)
+{
+       sac_info("API Called <%s>", __FUNCTION__);
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       if ((NULL == handle) || (NULL == plugin) || (NULL == plugin_uri)) {
+               ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       } else {
+               service_plugin_h _plugin = (service_plugin_h) calloc(1, sizeof(service_plugin_s));
+               char *_plugin_uri = strdup(plugin_uri);
+               if ((NULL != _plugin) && (NULL != _plugin_uri)) {
+                       _plugin->adaptor = handle;
+                       _plugin->service_handle_name = NULL;
+                       _plugin->optional_property = (void *)g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
+
+                       _plugin->plugin_uri = _plugin_uri;
+                       _plugin->enabled_mask = 0;
+
+                       *plugin = _plugin;
+               } else {
+                       free(_plugin);
+                       free(_plugin_uri);
+                       sac_error("Critical : Memory allocation failed.");
+                       ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_plugin_destroy(service_plugin_h plugin)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       if (NULL == plugin) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       } else {
+               plugin->adaptor = NULL;
+               if (NULL != plugin->optional_property) {
+                       g_hash_table_destroy((GHashTable *)(plugin->optional_property));
+                       plugin->optional_property = NULL;
+               }
+               free(plugin->service_handle_name);
+               free(plugin->plugin_uri);
+               free(plugin);
+       }
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_plugin_add_property(service_plugin_h handle,
+                                               const char *key,
+                                               const char *value)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       if ((NULL == handle) || (NULL == handle->optional_property)) {
+               ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       } else if ((NULL == key) || (0 >= strlen(key))) {
+               ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       } else if ((NULL == value) || (0 >= strlen(value))) {
+               ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       } else {
+               g_hash_table_insert((GHashTable *)(handle->optional_property), strdup(key), strdup(value));
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_plugin_remove_property(service_plugin_h handle,
+                                               const char *key)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       if ((NULL == handle) || (NULL == handle->optional_property)) {
+               ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       } else if ((NULL == key) || (0 >= strlen(key))) {
+               ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       } else {
+               g_hash_table_remove((GHashTable *)(handle->optional_property), key);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_plugin_get_property(service_plugin_h handle,
+                                               const char *key,
+                                               char **value)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       if (NULL == handle) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if ((NULL == key) || (0 >= strlen(key)) || (NULL == value)) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       void *property = (void *)g_hash_table_lookup((GHashTable *)(handle->optional_property), (gconstpointer *)key);
+       if (NULL == property) {
+               ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
+       } else {
+               *value = strdup((char *) property);
+       }
+/*
+       GHashTableIter iter;
+       gpointer iter_key;
+       gpointer iter_value;
+       g_hash_table_iter_init(&iter, (GHashTable *)(handle->optional_property));
+       while (g_hash_table_iter_next(&iter, &iter_key, &iter_value)) {
+               if (NULL != iter_key) {
+                       if (0 == strcmp((char *)iter_key, key)) {
+                               ret = SERVICE_ADAPTOR_ERROR_NONE;
+                               *value = strdup((char *)iter_value);
+                               break;
+                       }
+               }
+       }
+*/
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_plugin_start(service_plugin_h handle,
+                                               int service_flag)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       int app_ret = 0;
+       char *service_handle_name = NULL;
+       char security_cookie[SECURITY_SERVER_COOKIE_BUFFER_SIZE] = {0, };
+
+       char *tizen_app_id = NULL;
+       char *type = NULL;
+
+       if (NULL == handle) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       app_ret = app_get_id(&tizen_app_id);
+
+       if (app_ret || (NULL == tizen_app_id)) {
+               char executable_path[1000];
+               int executable_path_len = 0;
+               executable_path_len = readlink("/proc/self/exe", executable_path, 1000);
+               tizen_app_id = strndup(executable_path, executable_path_len);
+               type = strdup("etc");
+               handle->app_type = CLIENT_APP_TYPE_ETC;
+       } else {
+               type = strdup("app");
+               handle->app_type = CLIENT_APP_TYPE_APPLICATION;
+       }
+
+       if (NULL == tizen_app_id) {
+               free(type);
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       service_handle_name = g_strconcat(tizen_app_id, "?type=", type, "&plugin=", handle->plugin_uri, NULL);
+
+       free(tizen_app_id);
+       free(type);
+
+       if (NULL == service_handle_name) {
+               sac_error("handle name get failed");
+               service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_UNKNOWN, "handle name get failed");
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       int sec_ret = security_server_request_cookie(security_cookie, SECURITY_SERVER_COOKIE_BUFFER_SIZE);
+       sac_debug_func("security_cookie : %s (%d)", security_cookie, sec_ret);
+
+       if (('\0' == security_cookie[0]) || sec_ret) {
+               sac_error("cookie get failed");
+               service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_UNKNOWN, "security cookie get failed");
+               free(service_handle_name);
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       handle->service_handle_name = service_handle_name;
+       sac_info("handle name :%s", handle->service_handle_name);
+       sac_info("uri :%s mask : %d", handle->plugin_uri, handle->enabled_mask);
+
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       ret = _dbus_start_service(handle, service_flag, security_cookie, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_plugin_stop(service_plugin_h handle)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       if (NULL == handle) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+
+int service_plugin_is_login_required(service_plugin_h plugin,
+                                               bool *required)
+{
+       sac_api_start();
+       sac_check_param_null(plugin, "plugin");
+       sac_check_param_null(required, "required");
+
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error = {0ULL, NULL};
+       bool _required = false;
+
+       ret = _dbus_is_login_required(plugin, &_required, &error);
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_plugin_request_login(service_plugin_h plugin,
+                                               service_plugin_login_cb callback,
+                                               void *user_data)
+{
+       sac_api_start();
+       sac_check_param_null(plugin, "plugin");
+       sac_check_param_null(callback, "callback");
+
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error = {0ULL, NULL};
+
+       ret = _dbus_request_login(plugin, (void *)callback, user_data, &error);
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/************************* private feature */
+
+/**    @brief  Connects Service Adaptor
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_connect(service_adaptor_h *handle,
+                                               service_adaptor_signal_cb callback)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_h service = NULL;
+
+       g_mutex_lock(&connections_counter_mutex);
+
+       if (NULL == handle) {
+               g_mutex_unlock(&connections_counter_mutex);
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (0 < connections_counter) {
+               sac_error("Handle already connected");
+               g_mutex_unlock(&connections_counter_mutex);
+
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       service = (service_adaptor_h) calloc(1, sizeof(service_adaptor_s));
+
+       if (NULL == service) {
+               service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_UNKNOWN, "Memory allocation failed");
+               g_mutex_unlock(&connections_counter_mutex);
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       int trd = 0;
+       char fingerprint[50] = {0, };
+       snprintf(fingerprint, 50, "%s/%d", SERVICE_ADAPTOR_START_KEY_PATH, getpid());
+       sac_debug("Trigger open : %s", fingerprint);
+       trd = open(fingerprint, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
+       if (0 > trd) {
+               sac_error("Trigger open failed (%d)", trd);
+               free(service);
+               g_mutex_unlock(&connections_counter_mutex);
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       int dbus_ret = _dbus_client_layer_init();
+
+       if (0 == dbus_ret) {
+               sac_info("Proxy creation success");
+       }
+
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       ret = _dbus_connect_service_adaptor(&error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(service);
+               close(trd);
+               remove(fingerprint);
+
+               g_mutex_unlock(&connections_counter_mutex);
+               free(error.msg);
+               return ret;
+       }
+
+       service->service_name = NULL;
+       service->user_id = NULL;
+       service->app_id = NULL;
+       service->service_id = 0;
+       service->imsi = NULL;
+       service->on_signal = callback;
+       service->plugin = NULL;
+       g_mutex_init(&service->set_auth_mutex);
+
+       *handle = service;
+       g_service_adaptor = service;
+       sac_info("Connects success handle (%p) instance (%p)", handle, service);
+       connections_counter = connections_counter + 1;
+
+       _signal_queue_add_task(SIGNAL_SERVICE_ADAPTOR, (uint32_t) callback, *handle, NULL);
+
+       close(trd);
+       remove(fingerprint);
+       g_mutex_unlock(&connections_counter_mutex);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Disconnects Service Adaptor
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_disconnect(service_adaptor_h handle)
+{
+       sac_api_start();
+       if (NULL == handle) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       g_mutex_lock(&connections_counter_mutex);
+
+       if (0 >= connections_counter) {
+               connections_counter = 0;
+               g_service_adaptor = NULL;
+               g_mutex_unlock(&connections_counter_mutex);
+
+               ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+               return ret;
+       }
+
+       if (NULL != handle) {
+               __SAFE_FREE(handle->service_name);
+               __SAFE_FREE(handle->user_id);
+
+               __SAFE_FREE(handle->app_id);
+               __SAFE_FREE(handle->imsi);
+
+               if (NULL != handle->plugin) {
+                       __SAFE_FREE(handle->plugin->name);
+               }
+
+               __SAFE_FREE(handle->plugin);
+               handle->on_signal = NULL;
+               __SAFE_FREE(handle);
+       }
+
+       connections_counter = connections_counter - 1;
+
+       if (0 == connections_counter) {
+               _dbus_client_layer_deinit();
+       }
+
+       g_service_adaptor = NULL;
+       g_mutex_unlock(&connections_counter_mutex);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Sets IMSI
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_imsi(service_adaptor_h handle,
+                                               const char *imsi)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if ((NULL == handle) || (NULL == imsi)) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL != handle->imsi) {
+               free(handle->imsi);
+               handle->imsi = NULL;
+       }
+
+       handle->imsi = _safe_strdup(imsi);
+       if (NULL == handle->imsi) {
+               ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_adaptor_set_plugin(service_adaptor_h handle,
+                                               const char *plugin_uri)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if ((NULL == handle) || (NULL == plugin_uri)) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       service_adaptor_plugin_h plugin = NULL;
+       plugin = (service_adaptor_plugin_h) calloc(1, sizeof(service_adaptor_plugin_s));
+       char *_plugin_uri = strdup(plugin_uri);
+       if ((NULL == plugin) || (NULL == _plugin_uri)) {
+               free(plugin);
+               free(_plugin_uri);
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       plugin->name = _plugin_uri;
+       plugin->login = true;
+
+       handle->plugin = plugin;
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Free plugins
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_free_plugins(service_adaptor_plugin_h * plugins,
+                                               unsigned int plugins_len)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       if ((NULL == plugins) || (0U == plugins_len)) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       for (int i = 0; i < plugins_len; i++) {
+               if (NULL == plugins[i]) {
+                       continue;
+               }
+
+               free(plugins[i]->name);
+               free(plugins[i]);
+       }
+
+       free(plugins);
+       plugins = NULL;
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_adaptor_external_request(service_adaptor_h handle,
+                                               int service_flag,
+                                               const char *api_uri,
+                                               bundle *in_params,
+                                               bundle **out_params)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (0 == service_flag) || (NULL == api_uri) || (NULL == in_params) || (NULL == out_params)) {
+               service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER,
+                               "Invalid Argument : Not null params");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (service_adaptor_check_handle_validate(handle)) {
+               service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle (Not connected handle)");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+/*
+       if (NULL == handle->service_name) {
+               service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid State");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+*/
+
+       unsigned char *input_str = NULL;
+       unsigned char *output_str = NULL;
+       int input_len = 0;
+       int output_len = 0;
+
+       ret = bundle_encode(in_params, &input_str, &input_len);
+
+       ret = _dbus_external_request(sac_safe_add_string(handle->service_name), service_flag, api_uri, input_str, input_len, &output_str, &output_len, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_set_last_result(error.code, error.msg);
+       } else {
+               *out_params = bundle_decode(output_str, output_len);
+               if (NULL == *out_params) {
+                       ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_adaptor_external_request_async(service_adaptor_h handle,
+                                               int service_flag,
+                                               const char *api_uri,
+                                               bundle *in_params,
+                                               service_adaptor_external_response_cb callback,
+                                               void *user_data)
+{
+       service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED, "Not supported yet (TBD)");
+       return SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED;
+}
+/************************* private feature */
diff --git a/src/service_adaptor_client_auth.c b/src/service_adaptor_client_auth.c
new file mode 100644 (file)
index 0000000..2982fdd
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: service-adaptor-client-auth.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "private/service-adaptor-client-auth.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "dbus_client.h"
+#include "dbus_client_auth.h"
+
+#include "util/service_adaptor_client_util.h"
+/**    @brief  Gets Auth Plugin List
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_auth_plugin(service_adaptor_h handle,
+                                               service_adaptor_plugin_h **plugins,
+                                               unsigned int *plugins_len,
+                                               service_adaptor_error_s **error_code)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+       GList *plugin_list = NULL;
+       int len = 0;
+
+       if ((NULL == handle) || (NULL == plugins) || (0 == plugins_len)) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _dbus_get_auth_plugin_list(&plugin_list, handle->imsi ? handle->imsi : "", &error);
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       int size = g_list_length(plugin_list);
+       service_adaptor_plugin_h *plugins_array = (service_adaptor_plugin_h *) calloc(size, sizeof(service_adaptor_plugin_h));
+
+       if (NULL == plugins_array) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_UNKNOWN, "Memory allocation failed");
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       for (GList *list = g_list_first(plugin_list); list != NULL; list = g_list_next(list)) {
+               service_adaptor_plugin_h plugin = (service_adaptor_plugin_h) list->data;
+
+               if (NULL == plugin) {
+                       continue;
+               }
+
+               plugins_array[len] = (service_adaptor_plugin_h) calloc(1, sizeof(service_adaptor_plugin_s));
+               if (NULL != plugins_array[len]) {
+                       plugins_array[len]->name = _safe_strdup(plugin->name);
+                       plugins_array[len]->login = plugin->login;
+               }
+               len++;
+       }
+
+       *plugins = plugins_array;
+       *plugins_len = size;
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**     @brief  Logins Auth Plugin using appId and appSecret
+ *      @return int
+ *      @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_auth_plugin(service_adaptor_h handle,
+                                               service_adaptor_plugin_h plugin_handle)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_plugin_h plugin = NULL;
+
+       if ((NULL == handle) || (NULL == plugin_handle) || (NULL == plugin_handle->name)) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       plugin = (service_adaptor_plugin_h) calloc(1, sizeof(service_adaptor_plugin_s));
+
+       if (NULL == plugin) {
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       plugin->name = _safe_strdup(plugin_handle->name);
+       plugin->login = plugin_handle->login;
+
+       handle->plugin = plugin;
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Renuests Channel Auth
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_auth(service_adaptor_h handle,
+                                               const char *service_name,
+                                               const char *app_id,
+                                               const char *app_secret,
+                                               unsigned int service_id,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->imsi) || (NULL == handle->plugin) || (NULL == handle->plugin->name) || (NULL == service_name) || (NULL == app_id) || (NULL == app_secret)) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL != handle->service_name) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Duplicated handle usage (Destroy and create new handle)");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       char *_service_name = strdup(service_name);
+       char *_app_id = strdup(app_id);
+       if ((NULL == _service_name) || (NULL == _app_id)) {
+               free(_service_name);
+               free(_app_id);
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_UNKNOWN, "Memory allocation failed");
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       sac_debug("set_auth mutex lock");
+       g_mutex_lock(&handle->set_auth_mutex);
+       ret = _dbus_set_auth(service_name, handle->imsi, handle->plugin->name, app_id, app_secret, service_id, user_data, &error);
+       g_mutex_unlock(&handle->set_auth_mutex);
+       sac_debug("set_auth mutex unlock");
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               sac_info("set_auth API failed: %d (%s)", ret, _service_name);
+               free(_service_name);
+               free(_app_id);
+               _assign_error_code(&error, error_code);
+       } else {
+               sac_info("set_auth API success (%s)", _service_name);
+               handle->service_name = _service_name;
+               handle->app_id = _app_id;
+               handle->service_id = service_id;
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
diff --git a/src/service_adaptor_client_contact.c b/src/service_adaptor_client_contact.c
new file mode 100644 (file)
index 0000000..56b7cbd
--- /dev/null
@@ -0,0 +1,600 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: service-adaptor-client-contact.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "private/service-adaptor-client-contact.h"
+#include "dbus_client.h"
+#include "dbus_client_contact.h"
+
+#include "util/service_adaptor_client_util.h"
+/**    @brief  Resets contact information in Contact Server and
+ *             uploads native contact information of device to the server
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_new_contact_list(service_adaptor_h handle,
+                                               service_adaptor_contact_req_s *contact_req,
+                                               void *user_data,
+                                               service_adaptor_contact_res_s **contact_res,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == contact_req)) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_name) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_set_new_contact_list(handle->service_name, contact_req, user_data, contact_res, server_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Synchronizes native contact information of device with Contact Server
+ *             according to [type] field of each contact
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_contact_list(service_adaptor_h handle,
+                                               service_adaptor_contact_req_s *contact_req,
+                                               void *user_data,
+                                               service_adaptor_contact_res_s **contact_res,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == contact_req)) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_name) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_set_contact_list(handle->service_name, contact_req, user_data, contact_res, server_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Gets profile and service registration information of each contact
+ *             (only contacts agreed to share with me are returned)
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_contact_infos_latest(service_adaptor_h handle,
+                                               service_adaptor_contact_res_s **contact_res,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == contact_res)) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_name) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_get_contact_list(handle->service_name, contact_res, server_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Gets profiles and service registration information of contacts
+ *             that have been updated since last update
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_contact_infos_polling(service_adaptor_h handle,
+                                               service_adaptor_contact_req_s *contact_req,
+                                               void *user_data,
+                                               service_adaptor_contact_res_s **contact_res,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == contact_req)) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_name) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_get_contact_infos_polling(handle->service_name, contact_req, user_data, contact_res, server_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Sets or updates device’s profile to server
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_me_profile_with_push(service_adaptor_h handle,
+                                               service_adaptor_profile_req_s *profile_req,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == profile_req)) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_name) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_set_me_profile_with_push(handle->service_name, profile_req, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Gets the profile information of a contact which is correspondent with
+ *             country code (optional) and phone number (mandatory)
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_profile(service_adaptor_h handle,
+                                               service_adaptor_profile_req_s *profile_req,
+                                               void *user_data,
+                                               service_adaptor_profile_res_s **profile_res,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == profile_req) || (NULL == profile_res)) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_name) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_get_profile(handle->service_name, profile_req, user_data,
+                       profile_res, server_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Uploads profile image meta to File Server and sets my profile image to Profile Server
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_profile_image_meta_with_push(service_adaptor_h handle,
+                                               service_adaptor_profile_image_h *images,
+                                               unsigned int images_len,
+                                               void *user_data,
+                                               service_adaptor_profile_image_h **failed_images,
+                                               unsigned int *failed_images_len,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == images)) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_name) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_set_profile_image_meta_with_push(handle->service_name,
+                       images, images_len, user_data, failed_images, failed_images_len, server_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Deletes profile image meta from Profile Server
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_delete_me_profile_image_meta_with_push(service_adaptor_h handle,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin)) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_name) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_delete_me_profile_image_meta_with_push(handle->service_name, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Sets the level of privacy, the scope of people to be opened
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_me_profile_privacy(service_adaptor_h handle,
+                                               service_adaptor_privacy_req_s *privacy_req,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == privacy_req)) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_name) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_set_me_profile_privacy(handle->service_name, privacy_req, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Gets my profile’s privacy level
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_me_profile_privacy(service_adaptor_h handle,
+                                               service_adaptor_privacy_res_s **privacy_res,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == privacy_res)) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_name) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_get_me_profile_privacy(handle->service_name, privacy_res, server_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Sets my presence information to Presence Server
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_me_presence_with_push(service_adaptor_h handle,
+                                               service_adaptor_presence_req_s *presence_req,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == presence_req)) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_name) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_set_me_presence_with_push(handle->service_name, presence_req, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Sets my presence ON/OFF information to Presence Server
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_me_presence_on_off_with_push(service_adaptor_h handle,
+                                               service_adaptor_presence_req_s *presence_req,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == presence_req)) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_name) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_set_me_presence_on_off_with_push(handle->service_name,
+                       presence_req, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_adaptor_set_me_profile_type(service_adaptor_h handle,
+                                               int profile_type,
+                                               char **profile_url,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == profile_url)) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_name) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_set_me_profile_type(handle->service_name,
+                       profile_type, profile_url, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+
+
+int service_adaptor_profile_image_create(service_adaptor_profile_image_h *image)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       if (NULL == image) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       *image = (service_adaptor_profile_image_h)calloc(1, sizeof(struct _service_adaptor_profile_image_s));
+
+       if (NULL == *image) {
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       memset((*image)->path, 0, 2048);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_adaptor_profile_image_set_element(service_adaptor_profile_image_h image,
+                                               service_adaptor_contact_request_type_e req_type,
+                                               int index,
+                                               const char *path)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       if ((NULL == image) || (NULL == path)) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       image->type = req_type;
+       image->index = index;
+       strncpy(image->path, path, (CONTACT_PROFILE_IMAGE_PATH_LEN - 1));
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_adaptor_profile_image_get_index(service_adaptor_profile_image_h image, int *index)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       if ((NULL == image) || (NULL == index)) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       *index = image->index;
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_adaptor_profile_image_get_url(service_adaptor_profile_image_h image, char **url)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       if ((NULL == image) || (NULL == url)) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if ('\0' == image->path[0]) {
+               *url = NULL;
+               ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
+       } else {
+               *url = strdup(image->path);
+               if (*url == NULL) {
+                       ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_adaptor_profile_image_get_req_type(service_adaptor_profile_image_h image, int *req_type)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       if ((NULL == image) || (NULL == req_type)) {
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       *req_type = image->type;
+
+       sac_api_end(ret);
+       return ret;
+}
+
+void service_adaptor_profile_image_destroy(service_adaptor_profile_image_h image)
+{
+       free(image);
+}
+
diff --git a/src/service_adaptor_client_message.c b/src/service_adaptor_client_message.c
new file mode 100644 (file)
index 0000000..e71a04b
--- /dev/null
@@ -0,0 +1,1045 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: service-adaptor-client-messaging.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "private/service-adaptor-client-message.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "dbus_client.h"
+#include "dbus_client_message.h"
+
+#include "util/service_adaptor_client_util.h"
+/**    @brief  Requests Creating Chatroom
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_create_chatroom(service_adaptor_h handle,
+                                               long long int request_id,
+                                               int chat_type,
+                                               long long int *receivers,
+                                               unsigned int receivers_len,
+                                               const char *chatroom_title,
+                                               service_adaptor_reply_create_chatroom_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start_msg(request_id);
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (0 > chat_type) || (1 < chat_type) ||
+                       (NULL == chatroom_title) || (NULL == receivers) || (1 > receivers_len)) {
+               if (NULL != error_code) {
+                       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+                       if (NULL != _error) {
+                               _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+                               _error->msg = strdup("Invalid Argument");
+                       }
+                       *error_code = _error;
+               }
+
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+       error.code = SERVICE_ADAPTOR_ERROR_NONE;
+       error.msg = NULL;
+       ret = _dbus_request_create_chatroom(handle->service_name, request_id, chat_type, receivers, receivers_len, chatroom_title, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if ((NULL != _error) && (NULL != error_code)) {
+                       _error->code = error.code;
+                       _error->msg = error.msg;
+                       *error_code = _error;
+               } else {
+                       free(_error);
+                       free(error.msg);
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests Changing Chatroom metadata
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_change_chatroom_meta(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               const char *chatroom_title,
+                                               int default_message_ttl,
+                                               service_adaptor_reply_change_chatroom_meta_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+
+{
+       sac_api_start_msg(request_id);
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin)) {
+               if (NULL != error_code) {
+                       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+                       if (NULL != _error) {
+                               _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+                               _error->msg = strdup("Invalid Argument");
+                       }
+                       *error_code = _error;
+               }
+
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+       error.code = SERVICE_ADAPTOR_ERROR_NONE;
+       error.msg = NULL;
+       ret = _dbus_request_change_chatroom_meta(handle->service_name, request_id, chatroom_id, chatroom_title, default_message_ttl, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if ((NULL != _error) && (NULL != error_code)) {
+                       _error->code = error.code;
+                       _error->msg = error.msg;
+                       *error_code = _error;
+               } else {
+                       free(_error);
+                       free(error.msg);
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+
+/**    @brief  Requests Chat
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_chat(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               service_adaptor_chat_msg_s **chat_msgs,
+                                               unsigned int chat_msgs_len,
+                                               service_adaptor_reply_chat_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start_msg(request_id);
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == chat_msgs) || (1 > chat_msgs_len)) {
+               if (NULL != error_code) {
+                       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+                       if (NULL != _error) {
+                               _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+                               _error->msg = strdup("Invalid Argument");
+                       }
+                       *error_code = _error;
+               }
+
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+       error.code = SERVICE_ADAPTOR_ERROR_NONE;
+       error.msg = NULL;
+       ret = _dbus_request_chat(handle->service_name, request_id, chatroom_id, chat_msgs, chat_msgs_len, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if ((NULL != _error) && (NULL != error_code)) {
+                       _error->code = error.code;
+                       _error->msg = error.msg;
+                       *error_code = _error;
+               } else {
+                       free(_error);
+                       free(error.msg);
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests Allow Chat
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_allow_chat(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               bool is_auto_allow,
+                                               int max_count,
+                                               bool need_delivery_ack,
+                                               unsigned long long last_delivery_ack_timestamp,
+                                               bool need_read_ack,
+                                               unsigned long long last_read_ack_timestamp,
+                                               bool need_ordered_chat_member_list,
+                                               service_adaptor_reply_allow_chat_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start_msg(request_id);
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin)) {
+               if (NULL != error_code) {
+                       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+                       if (NULL != _error) {
+                               _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+                               _error->msg = strdup("Invalid Argument");
+                       }
+                       *error_code = _error;
+               }
+
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+       error.code = SERVICE_ADAPTOR_ERROR_NONE;
+       error.msg = NULL;
+       ret = _dbus_request_allow_chat(handle->service_name, request_id, chatroom_id, is_auto_allow, max_count,
+                       need_delivery_ack, last_delivery_ack_timestamp, need_read_ack, last_read_ack_timestamp,
+                       need_ordered_chat_member_list, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if ((NULL != _error) && (NULL != error_code)) {
+                       _error->code = error.code;
+                       _error->msg = error.msg;
+                       *error_code = _error;
+               } else {
+                       free(_error);
+                       free(error.msg);
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests All Unread Message
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_all_unread_message(service_adaptor_h handle,
+                                               long long int request_id,
+                                               int max_count,
+                                               service_adaptor_reply_all_unread_message_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start_msg(request_id);
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin)) {
+               if (NULL != error_code) {
+                       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+                       if (NULL != _error) {
+                               _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+                               _error->msg = strdup("Invalid Argument");
+                       }
+                       *error_code = _error;
+               }
+
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+       error.code = SERVICE_ADAPTOR_ERROR_NONE;
+       error.msg = NULL;
+       ret = _dbus_request_all_unread_message(handle->service_name, request_id, max_count, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if ((NULL != _error) && (NULL != error_code)) {
+                       _error->code = error.code;
+                       _error->msg = error.msg;
+                       *error_code = _error;
+               } else {
+                       free(_error);
+                       free(error.msg);
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Registers Forward Online Message Listener
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_register_channel_disconnected_listener(service_adaptor_h handle,
+                                               service_adaptor_reply_channel_disconnected_cb callback,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       _queue_add_task(TASK_MESSAGE_CHANNEL_DISCONNECTED_MESSAGE, (uint32_t) callback, handle, user_data);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Unregisters Forward Online Message Listener
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_unregister_channel_disconnected_listener(service_adaptor_h handle,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       service_adaptor_task_h task = _queue_get_task(TASK_MESSAGE_CHANNEL_DISCONNECTED_MESSAGE);
+
+       if (NULL == task) {
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       _queue_del_task(task);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+
+
+/**    @brief  Registers Forward Online Message Listener
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_register_forward_online_message_listener(service_adaptor_h handle,
+                                               service_adaptor_request_forward_online_message_cb callback,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       _queue_add_task(TASK_MESSAGE_FORWARD_ONLINE_MESSAGE, (uint32_t) callback, handle, user_data);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Unregisters Forward Online Message Listener
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_unregister_forward_online_message_listener(service_adaptor_h handle,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       service_adaptor_task_h task = _queue_get_task(TASK_MESSAGE_FORWARD_ONLINE_MESSAGE);
+
+       if (NULL == task) {
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       _queue_del_task(task);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests Forward Online Message
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_reply_forward_online_message(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               bool mark_as_read,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start_msg(request_id);
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin)) {
+               if (NULL != error_code) {
+                       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+                       if (NULL != _error) {
+                               _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+                               _error->msg = strdup("Invalid Argument");
+                       }
+                       *error_code = _error;
+               }
+
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       error.code = SERVICE_ADAPTOR_ERROR_NONE;
+       error.msg = NULL;
+       ret = _dbus_reply_forward_online_message(handle->service_name, request_id, chatroom_id, mark_as_read, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if ((NULL != _error) && (NULL != error_code)) {
+                       _error->code = error.code;
+                       _error->msg = error.msg;
+                       *error_code = _error;
+               } else {
+                       free(_error);
+                       free(error.msg);
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Registers Forward Unread Message Listener
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_register_forward_unread_message_listener(service_adaptor_h handle,
+                                               service_adaptor_request_forward_unread_message_cb callback,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       _queue_add_task(TASK_MESSAGE_FORWARD_UNREAD_MESSAGE, (uint32_t) callback, handle, user_data);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Unregisters Forward Unread Message Listener
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_unregister_forward_unread_message_listener(service_adaptor_h handle,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       service_adaptor_task_h task = _queue_get_task(TASK_MESSAGE_FORWARD_UNREAD_MESSAGE);
+
+       if (NULL == task) {
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       _queue_del_task(task);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests Forward Unread Message
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_reply_forward_unread_message(service_adaptor_h handle,
+                                               long long int request_id,
+                                               const char *next_pagination_key,
+                                               int max_count,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start_msg(request_id);
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin)) {
+               if (NULL != error_code) {
+                       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+                       if (NULL != _error) {
+                               _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+                               _error->msg = strdup("Invalid Argument");
+                       }
+                       *error_code = _error;
+               }
+
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       error.code = SERVICE_ADAPTOR_ERROR_NONE;
+       error.msg = NULL;
+       ret = _dbus_reply_forward_unread_message(handle->service_name, request_id, next_pagination_key, max_count, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if ((NULL != _error) && (NULL != error_code)) {
+                       _error->code = error.code;
+                       _error->msg = error.msg;
+                       *error_code = _error;
+               } else {
+                       free(_error);
+                       free(error.msg);
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests Read Message
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_read_message(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               service_adaptor_inbox_message_s *inbox_msg,
+                                               service_adaptor_reply_read_message_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start_msg(request_id);
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == inbox_msg)) {
+               if (NULL != error_code) {
+                       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+                       if (NULL != _error) {
+                               _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+                               _error->msg = strdup("Invalid Argument");
+                       }
+                       *error_code = _error;
+               }
+
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       error.code = SERVICE_ADAPTOR_ERROR_NONE;
+       error.msg = NULL;
+       ret = _dbus_request_read_message(handle->service_name, request_id, chatroom_id, inbox_msg, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if ((NULL != _error) && (NULL != error_code)) {
+                       _error->code = error.code;
+                       _error->msg = error.msg;
+                       *error_code = _error;
+               } else {
+                       free(_error);
+                       free(error.msg);
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests Invite Chat
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_invite_chat(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               long long int *inviting_members,
+                                               unsigned int inviting_members_len,
+                                               service_adaptor_reply_invite_chat_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start_msg(request_id);
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == inviting_members) || (1 > inviting_members_len)) {
+               if (NULL != error_code) {
+                       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+                       if (NULL != _error) {
+                               _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+                               _error->msg = strdup("Invalid Argument");
+                       }
+                       *error_code = _error;
+               }
+
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+       error.code = SERVICE_ADAPTOR_ERROR_NONE;
+       error.msg = NULL;
+       ret = _dbus_request_invite_chat(handle->service_name, request_id, chatroom_id, inviting_members, inviting_members_len, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if ((NULL != _error) && (NULL != error_code)) {
+                       _error->code = error.code;
+                       _error->msg = error.msg;
+                       *error_code = _error;
+               } else {
+                       free(_error);
+                       free(error.msg);
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests End Chat
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_end_chat(service_adaptor_h handle,
+                                               long long int request_id,
+                                               service_adaptor_end_chat_s **end_chats,
+                                               unsigned int end_chats_len,
+                                               service_adaptor_reply_end_chat_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start_msg(request_id);
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == end_chats) || (1 > end_chats_len)) {
+               if (NULL != error_code) {
+                       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+                       if (NULL != _error) {
+                               _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+                               _error->msg = strdup("Invalid Argument");
+                       }
+                       *error_code = _error;
+               }
+
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+       error.code = SERVICE_ADAPTOR_ERROR_NONE;
+       error.msg = NULL;
+       ret = _dbus_request_end_chat(handle->service_name, request_id, end_chats, end_chats_len, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if ((NULL != _error) && (NULL != error_code)) {
+                       _error->code = error.code;
+                       _error->msg = error.msg;
+                       *error_code = _error;
+               } else {
+                       free(_error);
+                       free(error.msg);
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests Unseal Message
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_unseal_message(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               long long int sender_id,
+                                               long long int message_id,
+                                               const char *message_detail,
+                                               service_adaptor_reply_unseal_message_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start_msg(request_id);
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == message_detail)) {
+               if (NULL != error_code) {
+                       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+                       if (NULL != _error) {
+                               _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+                               _error->msg = strdup("Invalid Argument");
+                       }
+                       *error_code = _error;
+               }
+
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+       error.code = SERVICE_ADAPTOR_ERROR_NONE;
+       error.msg = NULL;
+       ret = _dbus_request_unseal_message(handle->service_name, request_id, chatroom_id,
+                       sender_id, message_id, message_detail, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if ((NULL != _error) && (NULL != error_code)) {
+                       _error->code = error.code;
+                       _error->msg = error.msg;
+                       *error_code = _error;
+               } else {
+                       free(_error);
+                       free(error.msg);
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests Save Call Log
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_save_call_log(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               const char *call_id,
+                                               const char *call_log_type,
+                                               long long int call_sender_id,
+                                               long long int call_receiver_id,
+                                               int conversaction_second,
+                                               service_adaptor_reply_save_call_log_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start_msg(request_id);
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin)) {
+               if (NULL != error_code) {
+                       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+                       if (NULL != _error) {
+                               _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+                               _error->msg = strdup("Invalid Argument");
+                       }
+                       *error_code = _error;
+               }
+
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+       error.code = SERVICE_ADAPTOR_ERROR_NONE;
+       error.msg = NULL;
+       ret = _dbus_request_save_call_log(handle->service_name, request_id, chatroom_id,
+                       call_id, call_log_type, call_sender_id, call_receiver_id,
+                       conversaction_second, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if ((NULL != _error) && (NULL != error_code)) {
+                       _error->code = error.code;
+                       _error->msg = error.msg;
+                       *error_code = _error;
+               } else {
+                       free(_error);
+                       free(error.msg);
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests Current Time
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_current_time(service_adaptor_h handle,
+                                               long long int request_id,
+                                               service_adaptor_reply_current_time_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start_msg(request_id);
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin)) {
+               if (NULL != error_code) {
+                       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+                       if (NULL != _error) {
+                               _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+                               _error->msg = strdup("Invalid Argument");
+                       }
+                       *error_code = _error;
+               }
+
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+       error.code = SERVICE_ADAPTOR_ERROR_NONE;
+       error.msg = NULL;
+       ret = _dbus_request_current_time(handle->service_name, request_id, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if ((NULL != _error) && (NULL != error_code)) {
+                       _error->code = error.code;
+                       _error->msg = error.msg;
+                       *error_code = _error;
+               } else {
+                       free(_error);
+                       free(error.msg);
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_get_connection_policy(service_adaptor_h handle,
+                                               service_adaptor_connection_policy_e *policy,
+                                               service_adaptor_error_s **error_code)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == policy)) {
+               if (NULL != error_code) {
+                       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+                       if (NULL != _error) {
+                               _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+                               _error->msg = strdup("Invalid Argument");
+                       }
+                       *error_code = _error;
+               }
+
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       error.code = SERVICE_ADAPTOR_ERROR_NONE;
+       error.msg = NULL;
+       ret = _dbus_request_get_connection_policy(handle->service_name, policy, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if ((NULL != _error) && (NULL != error_code)) {
+                       _error->code = error.code;
+                       _error->msg = error.msg;
+                       *error_code = _error;
+               } else {
+                       free(_error);
+                       free(error.msg);
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_set_connection_policy(service_adaptor_h handle,
+                                               service_adaptor_connection_policy_e *policy,
+                                               service_adaptor_error_s **error_code)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == policy)) {
+               if (NULL != error_code) {
+                       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+                       if (NULL != _error) {
+                               _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+                               _error->msg = strdup("Invalid Argument");
+                       }
+                       *error_code = _error;
+               }
+
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       error.code = SERVICE_ADAPTOR_ERROR_NONE;
+       error.msg = NULL;
+       ret = _dbus_request_set_connection_policy(handle->service_name, policy, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if ((NULL != _error) && (NULL != error_code)) {
+                       _error->code = error.code;
+                       _error->msg = error.msg;
+                       *error_code = _error;
+               } else {
+                       free(_error);
+                       free(error.msg);
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+
+
+/**    @brief  Requests chat id based on phone number
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_chat_id_list(service_adaptor_h handle,
+                                               service_adaptor_phone_number_s **phone_numbers,
+                                               unsigned int phone_numbers_len,
+                                               void *user_data,
+                                               service_adaptor_chat_id_s ***chat_ids,
+                                               unsigned int *chat_ids_len,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == phone_numbers) || (1 > phone_numbers_len) || (NULL == chat_ids) || (NULL == chat_ids_len)) {
+               if (NULL != error_code) {
+                       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+                       if (NULL != _error) {
+                               _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+                               _error->msg = strdup("Invalid Argument");
+                       }
+                       *error_code = _error;
+               }
+
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (service_adaptor_check_handle_validate(handle)) {
+               service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle (Please success set_auth first)");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       error.code = SERVICE_ADAPTOR_ERROR_NONE;
+       error.msg = NULL;
+       ret = _dbus_get_chat_id_list(handle->service_name, phone_numbers, phone_numbers_len, user_data, chat_ids, chat_ids_len, server_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if ((NULL != _error) && (NULL != error_code)) {
+                       _error->code = error.code;
+                       _error->msg = error.msg;
+                       *error_code = _error;
+               } else {
+                       free(_error);
+                       free(error.msg);
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests MSISDN based on User ID
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_msisdn_list(service_adaptor_h handle,
+                                               long long int *chat_ids,
+                                               unsigned int chat_ids_len,
+                                               void *user_data,
+                                               service_adaptor_chat_id_s ***msisdns,
+                                               unsigned int *msisdns_len,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == chat_ids) || (1 > chat_ids_len) || (NULL == msisdns) || (msisdns_len == NULL)) {
+               if (NULL != error_code) {
+                       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+                       if (NULL != _error) {
+                               _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+                               _error->msg = strdup("Invalid Argument");
+                       }
+                       *error_code = _error;
+               }
+
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       error.code = SERVICE_ADAPTOR_ERROR_NONE;
+       error.msg = NULL;
+       ret = _dbus_get_msisdn_list(handle->service_name, chat_ids, chat_ids_len, user_data, msisdns, msisdns_len, server_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if ((NULL != _error) && (NULL != error_code)) {
+                       _error->code = error.code;
+                       _error->msg = error.msg;
+                       *error_code = _error;
+               } else {
+                       free(_error);
+                       free(error.msg);
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
diff --git a/src/service_adaptor_client_push.c b/src/service_adaptor_client_push.c
new file mode 100644 (file)
index 0000000..7587514
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: service-adaptor-client-push.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <glib.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "private/service-adaptor-client-push.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_private.h"
+#include "service_adaptor_client_log.h"
+#include "dbus/dbus_client_push.h"
+
+#include "util/service_adaptor_client_util.h"
+/**    @brief  Registers a callback function to receive push notification from push service
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_connect_push_service(service_adaptor_h handle,
+                                               service_adaptor_push_notification_cb callback,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if ((NULL == handle) || (NULL == callback)) {
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Parameter");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       sac_debug("Connect push service : service_id(%d)", handle->service_id);
+
+       _signal_queue_add_task(handle->service_id, (uint32_t) callback, handle, user_data);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Deregisters the callback function that had been registered to push service
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_disconnect_push_service(service_adaptor_h handle)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if (NULL == handle) {
+               service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invlid parameters");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       service_adaptor_task_h task = _signal_queue_get_task(handle->service_id);
+
+       if (NULL == task) {
+               return SERVICE_ADAPTOR_ERROR_NONE;
+       }
+
+       sac_debug("Disconnect push service : service_id(%d)", handle->service_id);
+
+       _signal_queue_del_task(task);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_register_push_service(service_adaptor_h handle,
+                                               const char *service_file_name)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == service_file_name)) {
+               service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invlid parameters");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _dbus_push_register(service_file_name, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               sac_error("Error occured (%lld)(%s)", error.code, error.msg);
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_deregister_push_service(service_adaptor_h handle,
+                                               const char *service_file_name)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == service_file_name)) {
+               service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invlid parameters");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _dbus_push_deregister(service_file_name, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               sac_error("Error occured (%lld)(%s)", error.code, error.msg);
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
diff --git a/src/service_adaptor_client_shop.c b/src/service_adaptor_client_shop.c
new file mode 100644 (file)
index 0000000..dce84e6
--- /dev/null
@@ -0,0 +1,192 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: service-adaptor-client-shop.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "private/service-adaptor-client-shop.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "dbus_client.h"
+#include "dbus_client_shop.h"
+
+#include "util/service_adaptor_client_util.h"
+/**    @brief  Requests List of Item
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_item_list(service_adaptor_h handle,
+                                               service_adaptor_shop_info_s *info,
+                                               void *user_data,
+                                               service_adaptor_shop_item_s ***items,
+                                               unsigned int *items_len,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == info) || (NULL == items)) {
+               sac_error("Invalid Parameter");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Parameter");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_name) {
+               sac_error("The service_name is NULL");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_get_item_list(handle->service_name, info, user_data, items, items_len, server_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests Item Information for Download
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_download_item_package(service_adaptor_h handle,
+                                               service_adaptor_shop_info_s *info,
+                                               void *user_data,
+                                               service_adaptor_shop_item_s **item,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == info) || (NULL == item)) {
+               sac_error("Invalid Parameter");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Parameter");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_name) {
+               sac_error("The service_name is NULL");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_download_item_package(handle->service_name, info, user_data, item, server_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests Download of Item
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_download_sticker(service_adaptor_h handle,
+                                               service_adaptor_shop_info_s *info,
+                                               void *user_data,
+                                               service_adaptor_shop_item_s **item,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == info) || (NULL == item)) {
+               sac_error("Invalid Parameter");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Parameter");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_name) {
+               sac_error("The service_name is NULL");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_download_sticker(handle->service_name, info, user_data, item, server_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests Item Panel URL
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_panel_url(service_adaptor_h handle,
+                                               service_adaptor_shop_info_s *info,
+                                               void *user_data,
+                                               service_adaptor_shop_item_s **item,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == info) || (NULL == item)) {
+               sac_error("Invalid Parameter");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Parameter");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_name) {
+               sac_error("The service_name is NULL");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_get_panel_url(handle->service_name, info, user_data, item, server_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
diff --git a/src/service_adaptor_client_storage.c b/src/service_adaptor_client_storage.c
new file mode 100644 (file)
index 0000000..dc9a9bc
--- /dev/null
@@ -0,0 +1,1915 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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: service-adaptor-client-storage.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <privilege_checker.h>
+
+#include "service_adaptor_client_private.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "service_adaptor_client_storage.h"
+#include "service_adaptor_client_storage_internal.h"
+#include "dbus_client.h"
+#include "dbus_client_storage.h"
+
+#include "util/service_adaptor_client_util.h"
+
+/****************** private feature */
+#include "private/service-adaptor-client-storage.h"
+/****************** private feature */
+
+#define SAFE_STRDUP(src) (src) ? strdup(src) : NULL
+
+#define ASYNC_OPERATION_UPLOAD_FILE 1
+#define ASYNC_OPERATION_DOWNLOAD_FILE 2
+#define ASYNC_OPERATION_DOWNLOAD_THUMBNAIL 3
+
+#define TIZEN_PRIVILEGE_NAME_INTERNET  "http://tizen.org/privilege/internet"
+
+struct _service_storage_file_list_s {
+       service_storage_file_h *list;
+       int length;
+};
+
+/**
+* @brief Release memory for service_storage_file_h
+*
+* @param[in]    void
+* @return service_storage_file_h
+* @retval Allocated and filled default value file_info's pointer
+*/
+service_storage_file_h service_storage_create_file_info(void)
+{
+       FUNC_START();
+       service_storage_file_h _file_info = NULL;
+       _file_info = (service_storage_file_h) calloc(1, sizeof(struct _service_storage_file_s));
+
+       service_storage_media_meta_s *_media_meta = NULL;
+       _media_meta = (service_storage_media_meta_s *) calloc(1, sizeof(service_storage_media_meta_s));
+
+       service_storage_cloud_meta_s *_cloud_meta = NULL;
+       _cloud_meta = (service_storage_cloud_meta_s *) calloc(1, sizeof(service_storage_cloud_meta_s));
+
+       if ((NULL == _file_info) || (NULL == _media_meta) || (NULL == _cloud_meta)) {
+               free(_file_info);
+               free(_media_meta);
+               free(_cloud_meta);
+
+               FUNC_STOP();
+               return NULL;
+       }
+
+       _media_meta->mime_type          = NULL;
+       _media_meta->title              = NULL;
+       _media_meta->album              = NULL;
+       _media_meta->artist             = NULL;
+       _media_meta->genere             = NULL;
+       _media_meta->recorded_date      = NULL;
+       _media_meta->width              = -1;
+       _media_meta->height             = -1;
+       _media_meta->duration           = -1;
+       _media_meta->copyright          = NULL;
+       _media_meta->track_num          = NULL;
+       _media_meta->description        = NULL;
+       _media_meta->composer           = NULL;
+       _media_meta->year               = NULL;
+       _media_meta->bitrate            = -1;
+       _media_meta->samplerate         = -1;
+       _media_meta->channel            = -1;
+       _media_meta->extra_media_meta   = NULL;
+
+       _cloud_meta->service_name       = NULL;
+       _cloud_meta->usage_byte         = 0ULL;
+       _cloud_meta->quota_byte         = 0ULL;
+       _cloud_meta->extra_cloud_meta   = NULL;
+
+       _file_info->plugin_name         = NULL;
+       _file_info->object_id           = NULL;
+       _file_info->storage_path        = NULL;
+       _file_info->file_size           = 0ULL;
+       _file_info->created_time        = 0ULL;
+       _file_info->modified_time       = 0ULL;
+       _file_info->file_info_index     = -1;
+       _file_info->content_type        = SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_DEFAULT;
+       _file_info->media_meta          = _media_meta;
+       _file_info->cloud_meta          = _cloud_meta;
+       _file_info->extra_file_info     = NULL;
+
+       FUNC_END();
+       return _file_info;
+}
+
+/**
+* @brief Release memory for service_storage_file_h
+*
+* @param[in]    file_info       specifies Service Adaptor file information handle
+* @return service_storage_file_h
+* @retval released file_info's pointer
+*/
+int service_storage_unref_file_info(service_storage_file_h *file_info)
+{
+       FUNC_START();
+       if (NULL == file_info) {
+               FUNC_STOP();
+               return 1;
+       }
+
+       if (NULL == *file_info) {
+               FUNC_STOP();
+               return 0;
+       }
+       service_storage_file_h _file_info = *file_info;
+
+       free(_file_info->plugin_name);
+       free(_file_info->object_id);
+       free(_file_info->storage_path);
+       free(_file_info->extra_file_info);
+
+       service_storage_media_meta_s *_media_meta = _file_info->media_meta;
+
+       if (NULL != _media_meta) {
+               free(_media_meta->mime_type);
+               free(_media_meta->title);
+               free(_media_meta->album);
+               free(_media_meta->artist);
+               free(_media_meta->genere);
+               free(_media_meta->recorded_date);
+               free(_media_meta->copyright);
+               free(_media_meta->track_num);
+               free(_media_meta->description);
+               free(_media_meta->composer);
+               free(_media_meta->year);
+               free(_media_meta->extra_media_meta);
+       }
+
+       service_storage_cloud_meta_s *_cloud_meta = _file_info->cloud_meta;
+
+       if (NULL != _cloud_meta) {
+               free(_cloud_meta->service_name);
+               free(_cloud_meta->extra_cloud_meta);
+       }
+
+       free((*file_info)->media_meta);
+       free((*file_info)->cloud_meta);
+       free(*file_info);
+       *file_info = NULL;
+
+       FUNC_END();
+       return 0;
+}
+
+
+/**    @brief  Uploads a server file and writes it to local file
+ *     @return int
+ *     @remarks :
+ */
+int service_storage_upload_file(service_plugin_h handle,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               service_storage_file_h *file_info)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == upload_path) || (NULL == server_path)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_handle_name) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_upload_file(handle->service_handle_name, upload_path, server_path, file_info, NULL, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests
+ *     @return int
+ *     @remarks :
+ */
+int service_storage_get_root_directory(service_plugin_h handle,
+                                               char **root_folder_path)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if (NULL == handle) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_handle_name) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_get_root_folder_path(handle->service_handle_name, root_folder_path, NULL, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests
+ *     @return int
+ *     @remarks :
+ */
+int service_storage_make_directory(service_plugin_h handle,
+                                               const char *folder_path,
+                                               service_storage_file_h *file_info)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if (NULL == handle) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_handle_name) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_make_directory(handle->service_handle_name, folder_path, file_info, NULL, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+
+/**    @brief  Requests
+ *     @return int
+ *     @remarks :
+ */
+int service_storage_remove_file(service_plugin_h handle,
+                                               const char *file_path)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == file_path)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_handle_name) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_remove_file(handle->service_handle_name, file_path, NULL, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+
+/**    @brief  Requests
+ *     @return int
+ *     @remarks :
+ */
+int service_storage_remove_directory(service_plugin_h handle,
+                                               const char *folder_path)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == folder_path)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_handle_name) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_remove_directory(handle->service_handle_name, folder_path, NULL, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+
+/**    @brief  Requests
+ *     @return int
+ *     @remarks :
+ */
+int service_storage_move_file(service_plugin_h handle,
+                                               const char *src_file_path,
+                                               const char *dst_file_path,
+                                               service_storage_file_h *file_info)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == src_file_path) || (NULL == dst_file_path)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_handle_name) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_move_file(handle->service_handle_name, src_file_path, dst_file_path, file_info, NULL, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+
+/**    @brief  Requests
+ *     @return int
+ *     @remarks :
+ */
+int service_storage_move_directory(service_plugin_h handle,
+                                               const char *src_folder_path,
+                                               const char *dst_folder_path,
+                                               service_storage_file_h *file_info)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == src_folder_path) || (NULL == dst_folder_path) || (NULL == file_info)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_handle_name) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_move_directory(handle->service_handle_name, src_folder_path, dst_folder_path, file_info, NULL, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/**    @brief  Requests
+ *     @return int
+ *     @remarks :
+ */
+int service_storage_get_directory_entries(service_plugin_h handle,
+                                               const char *parent_path,
+                                               service_storage_file_h **file_info_list,
+                                               unsigned int *file_info_list_len)
+
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == parent_path) || (NULL == file_info_list) || (NULL == file_info_list_len)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_handle_name) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_get_file_list(handle->service_handle_name, parent_path, file_info_list, file_info_list_len, NULL, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_storage_download_file(service_plugin_h handle,
+                                               const char *cloud_path,
+                                               const char *download_path)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == cloud_path) || (NULL == download_path)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_handle_name) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_download_file(handle->service_handle_name, cloud_path, download_path, NULL, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_storage_download_thumbnail(service_plugin_h handle,
+                                               const char *storage_path,
+                                               const char *local_path,
+                                               int thumbnail_size)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == storage_path) || (NULL == local_path)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == handle->service_handle_name) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       ret = _dbus_download_thumbnail(handle->service_handle_name, storage_path, local_path, thumbnail_size, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+/******* Async implementation */
+
+int service_storage_create_upload_task(service_plugin_h plugin,
+                                               const char *file_path,
+                                               const char *upload_path,
+                                               service_storage_task_h *task)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == plugin) || (NULL == file_path) || (NULL == upload_path) || (NULL == task)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == plugin->service_handle_name) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       if (CLIENT_APP_TYPE_APPLICATION == plugin->app_type) {
+               int privilege_ret = 0;
+               privilege_ret = privilege_checker_check_privilege(TIZEN_PRIVILEGE_NAME_INTERNET);
+               if (PRIVILEGE_CHECKER_ERR_NONE != privilege_ret) {
+                       sac_error("Privilege check error (ret : %d)", privilege_ret);
+                       return SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED;
+               }
+       }
+
+
+       service_storage_task_h _task = (service_storage_task_h) calloc(1, sizeof(service_storage_task_t));
+       if (NULL == _task) {
+               ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+               service_adaptor_set_last_result(ret, "Memory allocation failed");
+               return ret;
+       }
+
+       long long int task_id = 0;
+       ret = _dbus_open_upload_file(plugin->service_handle_name, file_path, upload_path, &task_id, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+               free(_task);
+       } else {
+               _task->service_handle_name = strdup(plugin->service_handle_name);
+               _task->task_id = task_id;
+               _task->operation = ASYNC_OPERATION_UPLOAD_FILE;
+               _task->state_callback = NULL;
+               _task->state_user_data = NULL;
+               _task->progress_callback = NULL;
+               _task->progress_user_data = NULL;
+
+               _task->param1 = (void *)strdup(file_path);
+               _task->param2 = (void *)strdup(upload_path);
+               _task->param3 = NULL;
+
+               *task = _task;
+
+               service_adaptor_task_h callback_task = NULL;
+               while ((callback_task = _queue_get_task((int64_t)_task->task_id))) {
+                       _queue_del_task(callback_task);
+                       callback_task = NULL;
+               }
+               _queue_add_task((int64_t)_task->task_id,
+                               (uint32_t) NULL, (void *) _task, NULL);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+
+int service_storage_create_download_task(service_plugin_h plugin,
+                                               const char *storage_path,
+                                               const char *download_path,
+                                               service_storage_task_h *task)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == plugin) || (NULL == storage_path) || (NULL == download_path) || (NULL == task)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == plugin->service_handle_name) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       if (CLIENT_APP_TYPE_APPLICATION == plugin->app_type) {
+               int privilege_ret = 0;
+               privilege_ret = privilege_checker_check_privilege(TIZEN_PRIVILEGE_NAME_INTERNET);
+               if (PRIVILEGE_CHECKER_ERR_NONE != privilege_ret) {
+                       sac_error("Privilege check error (ret : %d)", privilege_ret);
+                       return SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED;
+               }
+       }
+
+       service_storage_task_h _task = (service_storage_task_h) calloc(1, sizeof(service_storage_task_t));
+       if (NULL == _task) {
+               ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+               service_adaptor_set_last_result(ret, "Memory allocation failed");
+               return ret;
+       }
+
+       long long int task_id = 0;
+       ret = _dbus_open_download_file(plugin->service_handle_name, storage_path, download_path, &task_id, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+               free(_task);
+       } else {
+               _task->service_handle_name = strdup(plugin->service_handle_name);
+               _task->task_id = task_id;
+               _task->operation = ASYNC_OPERATION_DOWNLOAD_FILE;
+               _task->state_callback = NULL;
+               _task->state_user_data = NULL;
+               _task->progress_callback = NULL;
+               _task->progress_user_data = NULL;
+
+               _task->param1 = (void *)strdup(storage_path);
+               _task->param2 = (void *)strdup(download_path);
+               _task->param3 = NULL;
+
+               *task = _task;
+
+               service_adaptor_task_h callback_task = NULL;
+               while ((callback_task = _queue_get_task((int64_t)_task->task_id))) {
+                       _queue_del_task(callback_task);
+                       callback_task = NULL;
+               }
+               _queue_add_task((int64_t)_task->task_id,
+                               (uint32_t) NULL, (void *) _task, NULL);
+       }
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_storage_create_download_thumbnail_task(service_plugin_h plugin,
+                                               const char *storage_path,
+                                               const char *download_path,
+                                               int thumbnail_size,
+                                               service_storage_task_h *task)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == plugin) || (NULL == storage_path) || (NULL == download_path) || (NULL == task)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == plugin->service_handle_name) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       if (CLIENT_APP_TYPE_APPLICATION == plugin->app_type) {
+               int privilege_ret = 0;
+               privilege_ret = privilege_checker_check_privilege(TIZEN_PRIVILEGE_NAME_INTERNET);
+               if (PRIVILEGE_CHECKER_ERR_NONE != privilege_ret) {
+                       sac_error("Privilege check error (ret : %d)", privilege_ret);
+                       return SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED;
+               }
+       }
+
+       service_storage_task_h _task = (service_storage_task_h) calloc(1, sizeof(service_storage_task_t));
+       int *t_size = (int *)calloc(1, sizeof(int));
+       if ((NULL == _task) || (NULL == t_size)) {
+               ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+               service_adaptor_set_last_result(ret, "Memory allocation failed");
+               free(_task);
+               free(t_size);
+               return ret;
+       }
+
+       long long int task_id = 0;
+       ret = _dbus_open_download_thumbnail(plugin->service_handle_name, storage_path, download_path, thumbnail_size, &task_id, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+               free(_task);
+               free(t_size);
+       } else {
+               _task->service_handle_name = strdup(plugin->service_handle_name);
+               _task->task_id = task_id;
+               _task->operation = ASYNC_OPERATION_DOWNLOAD_THUMBNAIL;
+               _task->state_callback = NULL;
+               _task->state_user_data = NULL;
+               _task->progress_callback = NULL;
+               _task->progress_user_data = NULL;
+
+               _task->param1 = (void *)strdup(storage_path);
+               _task->param2 = (void *)strdup(download_path);
+               *t_size = thumbnail_size;
+               _task->param3 = (void *)t_size;
+
+               *task = _task;
+
+               service_adaptor_task_h callback_task = NULL;
+               while ((callback_task = _queue_get_task((int64_t)_task->task_id))) {
+                       _queue_del_task(callback_task);
+                       callback_task = NULL;
+               }
+               _queue_add_task((int64_t)_task->task_id,
+                               (uint32_t) NULL, (void *) _task, NULL);
+
+       }
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_storage_destroy_task(service_storage_task_h task)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if (NULL == task) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _dbus_close_file_task(task->service_handle_name, task->task_id, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       service_adaptor_task_h callback_task = NULL;
+       while ((callback_task = _queue_get_task((int64_t)task->task_id))) {
+               _queue_del_task(callback_task);
+               callback_task = NULL;
+       }
+
+       free(task->service_handle_name);
+       free(task->param1);
+       free(task->param2);
+       free(task->param3);
+       free(task);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_storage_start_task(service_storage_task_h task)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if (NULL == task) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       switch (task->operation) {
+       case ASYNC_OPERATION_UPLOAD_FILE:
+               sac_info("Start upload async task");
+               ret = _dbus_start_upload_file(task->service_handle_name,
+                               task->task_id, (char *)task->param2,
+                               task->progress_callback ? true : false, task->state_callback ? true : false, &error);
+       break;
+       case ASYNC_OPERATION_DOWNLOAD_FILE:
+               sac_info("Start download async task");
+               ret = _dbus_start_download_file(task->service_handle_name,
+                               task->task_id, (char *)task->param1,
+                               task->progress_callback ? true : false, task->state_callback ? true : false, &error);
+       break;
+
+       case ASYNC_OPERATION_DOWNLOAD_THUMBNAIL:
+               sac_info("Start download thumbnail async task");
+               ret = _dbus_start_download_thumbnail(task->service_handle_name,
+                               task->task_id, (char *)task->param1, *((int *)task->param3),
+                               task->progress_callback ? true : false, task->state_callback ? true : false, &error);
+       break;
+
+       default:
+               sac_info("Invalid async task");
+               ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error.code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error.msg = strdup("Invalid async task operation");
+       break;
+       }
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_storage_cancel_task(service_storage_task_h task)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if (NULL == task) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       switch (task->operation) {
+       case ASYNC_OPERATION_UPLOAD_FILE:
+               sac_info("Start upload async task");
+               ret = _dbus_cancel_upload_file(task->service_handle_name,
+                               task->task_id, &error);
+       break;
+       case ASYNC_OPERATION_DOWNLOAD_FILE:
+               sac_info("Start download async task");
+               ret = _dbus_cancel_download_file(task->service_handle_name,
+                               task->task_id, &error);
+       break;
+
+       case ASYNC_OPERATION_DOWNLOAD_THUMBNAIL:
+               sac_info("Start download thumbnail async task");
+               ret = _dbus_cancel_download_thumbnail(task->service_handle_name,
+                               task->task_id, &error);
+       break;
+
+       default:
+               sac_info("Invalid async task");
+               ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error.code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+               error.msg = strdup("Invalid async task operation");
+       break;
+       }
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       sac_api_end(ret);
+       return ret;
+
+}
+
+int service_storage_set_task_progress_cb(service_storage_task_h task,
+                                               service_storage_task_progress_cb callback,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if ((NULL == task) || (NULL == callback)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       task->progress_callback = callback;
+       task->progress_user_data = user_data;
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_storage_unset_task_progress_cb(service_storage_task_h task)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if (NULL == task) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       task->progress_callback = NULL;
+       task->progress_user_data = NULL;
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_storage_set_task_state_changed_cb(service_storage_task_h task,
+                                               service_storage_task_state_cb callback,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if ((NULL == task) || (NULL == callback)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       task->state_callback = callback;
+       task->state_user_data = user_data;
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_storage_unset_task_state_changed_cb(service_storage_task_h task)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if (NULL == task) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       task->state_callback = NULL;
+       task->state_user_data = NULL;
+
+       sac_api_end(ret);
+       return ret;
+}
+
+struct __async_wrapper_context {
+       service_plugin_h plugin;
+       char *path;
+       void *callback;
+       void *user_data;
+};
+
+void *_get_file_list_runnable(void *_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       struct __async_wrapper_context *_params = (struct __async_wrapper_context *)_data;
+
+       service_storage_file_list_h file_list = NULL;
+
+       service_adaptor_error_s error;
+       error.msg = NULL;
+       service_storage_file_h *files = NULL;
+       unsigned int files_len = 0;
+
+       ret = _dbus_get_file_list(_params->plugin->service_handle_name, _params->path, &files, &files_len, NULL, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+               if ((NULL != files) && (0 < files_len)) {
+                       int i;
+                       for (i = 0; i < files_len; i++) {
+                               service_storage_unref_file_info(&files[i]);
+                       }
+                       free(files);
+                       files = NULL;
+               }
+       } else {
+               if (0 < files_len) {
+                       file_list = (service_storage_file_list_h) calloc(1, sizeof(struct _service_storage_file_list_s));
+                       if (NULL == file_list) {
+                               sac_error("Critical : Memory allocation failed");
+                               ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+                       } else {
+                               file_list->list = files;
+                               file_list->length = (int) files_len;
+                       }
+               } else {
+                       ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
+               }
+       }
+
+       ((service_storage_file_list_cb)_params->callback)(ret, file_list, _params->user_data);
+
+       int i;
+       for (i = 0; i < files_len; i++) {
+               service_storage_unref_file_info(&files[i]);
+       }
+       free(files);
+       free(file_list);
+
+       free(_params->path);
+       free(_params);
+
+       sac_api_end(ret);
+       return NULL;
+}
+
+int service_storage_get_file_list(service_plugin_h plugin,
+                                               const char *dir_path,
+                                               service_storage_file_list_cb callback,
+                                               void *user_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if ((NULL == plugin) || (NULL == callback) || (NULL == dir_path)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == plugin->service_handle_name) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       if (CLIENT_APP_TYPE_APPLICATION == plugin->app_type) {
+               int privilege_ret = 0;
+               privilege_ret = privilege_checker_check_privilege(TIZEN_PRIVILEGE_NAME_INTERNET);
+               if (PRIVILEGE_CHECKER_ERR_NONE != privilege_ret) {
+                       sac_error("Privilege check error (ret : %d)", privilege_ret);
+                       return SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED;
+               }
+       }
+
+       struct __async_wrapper_context *params = NULL;
+       params = (struct __async_wrapper_context *) calloc(1, sizeof(struct __async_wrapper_context));
+
+       if (NULL == params) {
+               sac_warning("Memory allocation failed");
+               ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       } else {
+               params->plugin = plugin;
+               params->path = strdup(dir_path);
+               params->callback = (void *)callback;
+               params->user_data = user_data;
+
+               int thread_ret = 0;
+               pthread_t get_list_thread;
+               thread_ret = pthread_create(&get_list_thread, NULL, _get_file_list_runnable, (void *)params);
+
+               if (thread_ret) {
+                       sac_warning("Thread create failed");
+                       ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+                       free(params->path);
+                       free(params);
+               }
+       }
+
+       return ret;
+}
+
+int service_storage_file_list_clone(service_storage_file_list_h src_list,
+                                               service_storage_file_list_h *dst_list)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if ((NULL == src_list) || (NULL == dst_list)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       service_storage_file_list_h _list = NULL;
+       _list = (service_storage_file_list_h) calloc(1, sizeof(struct _service_storage_file_list_s));
+       if (NULL == _list) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+       _list->length = src_list->length;
+       _list->list = (service_storage_file_h *) calloc(_list->length, sizeof(struct _service_storage_file_s *));
+       if (NULL == _list->list) {
+               free(_list);
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       int i = 0;
+       for (i = 0; i < _list->length; i++) {
+               service_storage_file_h file = NULL;
+               service_storage_file_clone(src_list->list[i], &file);
+               _list->list[i] = file;
+       }
+
+       *dst_list = _list;
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_storage_file_list_destroy(service_storage_file_list_h list)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if (NULL == list) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       int i;
+       for (i = 0; i < list->length; i++) {
+               service_storage_file_destroy(list->list[i]);
+       }
+       free(list);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_storage_file_clone(service_storage_file_h src_file,
+                                               service_storage_file_h *dst_file)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if ((NULL == src_file) || (NULL == dst_file)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       service_storage_file_h src = src_file;
+       service_storage_file_h new_file = service_storage_create_file_info();
+
+       if (NULL == new_file) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       if (NULL != src->media_meta) {
+               new_file->media_meta->mime_type =
+                       SAFE_STRDUP(src->media_meta->mime_type);
+               new_file->media_meta->title =
+                       SAFE_STRDUP(src->media_meta->title);
+               new_file->media_meta->album =
+                       SAFE_STRDUP(src->media_meta->album);
+               new_file->media_meta->artist =
+                       SAFE_STRDUP(src->media_meta->artist);
+               new_file->media_meta->genere =
+                       SAFE_STRDUP(src->media_meta->genere);
+               new_file->media_meta->recorded_date =
+                       SAFE_STRDUP(src->media_meta->recorded_date);
+               new_file->media_meta->width =
+                       src->media_meta->width;
+               new_file->media_meta->height =
+                       src->media_meta->height;
+               new_file->media_meta->duration =
+                       src->media_meta->duration;
+               new_file->media_meta->copyright =
+                       SAFE_STRDUP(src->media_meta->copyright);
+               new_file->media_meta->track_num =
+                       SAFE_STRDUP(src->media_meta->track_num);
+               new_file->media_meta->description =
+                       SAFE_STRDUP(src->media_meta->description);
+               new_file->media_meta->composer =
+                       SAFE_STRDUP(src->media_meta->composer);
+               new_file->media_meta->year =
+                       SAFE_STRDUP(src->media_meta->year);
+               new_file->media_meta->bitrate =
+                       src->media_meta->bitrate;
+               new_file->media_meta->samplerate =
+                       src->media_meta->samplerate;
+               new_file->media_meta->channel =
+                       src->media_meta->channel;
+               new_file->media_meta->extra_media_meta =
+                       SAFE_STRDUP(src->media_meta->extra_media_meta);
+       }
+
+       if (NULL != src->cloud_meta) {
+               new_file->cloud_meta->service_name =
+                       SAFE_STRDUP(src->cloud_meta->service_name);
+               new_file->cloud_meta->usage_byte =
+                       src->cloud_meta->usage_byte;
+               new_file->cloud_meta->quota_byte =
+                       src->cloud_meta->quota_byte;
+               new_file->cloud_meta->extra_cloud_meta =
+                       SAFE_STRDUP(src->cloud_meta->extra_cloud_meta);
+       }
+
+       new_file->plugin_name =
+               SAFE_STRDUP(src->plugin_name);
+       new_file->object_id =
+               SAFE_STRDUP(src->object_id);
+       new_file->storage_path =
+               SAFE_STRDUP(src->storage_path);
+       new_file->file_size =
+               src->file_size;
+       new_file->created_time =
+               src->created_time;
+       new_file->modified_time =
+               src->modified_time;
+       new_file->file_info_index =
+               src->file_info_index;
+       new_file->content_type =
+               src->content_type;
+       new_file->extra_file_info =
+               SAFE_STRDUP(src->extra_file_info);
+
+       *dst_file = new_file;
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_storage_file_destroy(service_storage_file_h file)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if (NULL == file) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+       service_storage_file_h file_info = file;
+       service_storage_unref_file_info(&file_info);
+
+       return ret;
+}
+
+int service_storage_file_list_get_length(service_storage_file_list_h list,
+                                               int *length)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if ((NULL == list) || (NULL == length)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       *length = list->length;
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_storage_file_list_foreach_file(service_storage_file_list_h list,
+                                               service_storage_file_cb callback,
+                                               void *user_data)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if ((NULL == list) || (NULL == callback)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (0 > list->length) {
+               ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
+       } else {
+               int i;
+               bool is_continue = true;
+               for (i = 0; i < list->length; i++) {
+                       if (is_continue) {
+                               is_continue = callback(list->list[i], user_data);
+                       }
+               }
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_storage_file_get_logical_path(service_storage_file_h file,
+                                               char **path)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if ((NULL == file) || (NULL == path)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       *path = SAFE_STRDUP(file->storage_path);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_storage_file_get_physical_path(service_storage_file_h file,
+                                               char **path)
+{
+
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if ((NULL == file) || (NULL == path)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       *path = SAFE_STRDUP(file->object_id);
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_storage_file_is_dir(service_storage_file_h file,
+                                               bool *is_dir)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if ((NULL == file) || (NULL == is_dir)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_FOLDER == file->content_type) {
+               *is_dir = true;
+       } else {
+               *is_dir = false;
+       }
+
+       sac_api_end(ret);
+       return ret;
+}
+
+int service_storage_file_get_size(service_storage_file_h file,
+                                               unsigned long long *size)
+{
+       sac_api_start();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if ((NULL == file) || (NULL == size)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       *size = file->file_size;
+
+       sac_api_end(ret);
+       return ret;
+}
+
+void *_remove_runnable(void *_data)
+{
+       FUNC_START();
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       struct __async_wrapper_context *_params = (struct __async_wrapper_context *)_data;
+
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       ret = _dbus_remove_file(_params->plugin->service_handle_name, _params->path, NULL, &error);
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_set_last_result(error.code, error.msg);
+               free(error.msg);
+       }
+
+       ((service_storage_result_cb)_params->callback)(ret, _params->user_data);
+
+       free(_params->path);
+       free(_params);
+
+       FUNC_END();
+       return NULL;
+}
+
+
+
+int service_storage_remove(service_plugin_h plugin,
+                                               const char *remove_path,
+                                               service_storage_result_cb callback,
+                                               void *user_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if ((NULL == plugin) || (NULL == callback) || (NULL == remove_path)) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       if (NULL == plugin->service_handle_name) {
+               FUNC_STOP();
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       }
+
+       if (CLIENT_APP_TYPE_APPLICATION == plugin->app_type) {
+               int privilege_ret = 0;
+               privilege_ret = privilege_checker_check_privilege(TIZEN_PRIVILEGE_NAME_INTERNET);
+               if (PRIVILEGE_CHECKER_ERR_NONE != privilege_ret) {
+                       sac_error("Privilege check error (ret : %d)", privilege_ret);
+                       return SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED;
+               }
+       }
+
+       struct __async_wrapper_context *params = NULL;
+       params = (struct __async_wrapper_context *) calloc(1, sizeof(struct __async_wrapper_context));
+
+       if (NULL == params) {
+               sac_warning("Memory allocation failed");
+               ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       } else {
+               params->plugin = plugin;
+               params->path = strdup(remove_path);
+               params->callback = (void *)callback;
+               params->user_data = user_data;
+
+               int thread_ret = 0;
+               pthread_t remove_thread;
+               thread_ret = pthread_create(&remove_thread, NULL, _remove_runnable, (void *)params);
+
+               if (thread_ret) {
+                       sac_warning("Thread create failed");
+                       ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+                       free(params->path);
+                       free(params);
+               }
+       }
+
+       return ret;
+
+}
+
+
+
+
+/******************************** private feature */
+
+
+/**    @brief  Registers File Progress Listener
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_register_file_progress_listener(service_adaptor_h handle,
+                                               service_adaptor_file_progress_cb callback,
+                                               void *user_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       _signal_queue_add_task(PRIVATE_SIGNAL_FILE_PROGRESS_ID, (uint32_t) callback, handle, user_data);
+
+       return ret;
+}
+
+/**    @brief  Unregisters File Progress Listener
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_unregister_file_progress_listener(service_adaptor_h handle,
+                                               void *user_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       service_adaptor_task_h task = _signal_queue_get_task(PRIVATE_SIGNAL_FILE_PROGRESS_ID);
+
+       if (NULL == task) {
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       _signal_queue_del_task(task);
+
+       return ret;
+}
+
+/**    @brief  Registers File Transfer Completion Listener
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_register_file_transfer_completion_listener(service_adaptor_h handle,
+                                               service_adaptor_file_transfer_completion_cb callback,
+                                               void *user_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       _signal_queue_add_task(PRIVATE_SIGNAL_FILE_TRANSFER_COMPLETION_ID, (uint32_t) callback, handle, user_data);
+
+       return ret;
+}
+
+/**    @brief  Unregisters Forward Online Message Listener
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_unregister_file_transfer_completion_listener(service_adaptor_h handle,
+                                               void *user_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       service_adaptor_task_h task = _signal_queue_get_task(PRIVATE_SIGNAL_FILE_TRANSFER_COMPLETION_ID);
+
+       if (NULL == task) {
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+
+       _signal_queue_del_task(task);
+
+       return ret;
+}
+
+/**    @brief  Downloads a server file and writes it to local file
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_download_file(service_adaptor_h handle,
+                                               const char *server_path,
+                                               const char *download_path,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == server_path) || (NULL == download_path)) {
+               sac_error("Invalid Parameter");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _dbus_download_file(handle->service_name, server_path, download_path, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       return ret;
+}
+
+/**    @brief  Downloads a server file and writes it to local file (Async)
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_download_file_async(service_adaptor_h handle,
+                                               const char *server_path,
+                                               const char *download_path,
+                                               service_adaptor_file_h *file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == server_path) || (NULL == download_path)) {
+               sac_error("Invalid Parameter");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _private_dbus_download_file_async(handle->service_name, server_path, download_path, file_handle, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       return ret;
+}
+
+/**    @brief  Uploads a server file and writes it to local file
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_upload_file(service_adaptor_h handle,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == upload_path) || (NULL == server_path)) {
+               sac_error("Invalid Parameter");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       service_storage_file_h file = NULL;
+       ret = _dbus_upload_file(handle->service_name, upload_path, server_path, &file, user_data, &error);
+       service_storage_unref_file_info(&file);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       return ret;
+}
+
+/**    @brief  Uploads a server file and writes it to local file (Async)
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_upload_file_async(service_adaptor_h handle,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               service_adaptor_file_h *file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == upload_path) || (NULL == server_path)) {
+               sac_error("Invalid Parameter");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _private_dbus_upload_file_async(handle->service_name, upload_path, server_path, file_handle, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       return ret;
+}
+
+/**    @brief  Downloads a server file and writes it to local file
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_download_file_publish(service_adaptor_h handle,
+                                               const char *publish_url,
+                                               const char *download_path,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == publish_url) || (NULL == download_path)) {
+               sac_error("Invalid Parameter");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _dbus_download_file_publish(handle->service_name, publish_url, download_path, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       return ret;
+}
+
+/**    @brief  Downloads a server file and writes it to local file (Async)
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_download_file_publish_async(service_adaptor_h handle,
+                                               const char *publish_url,
+                                               const char *download_path,
+                                               service_adaptor_file_h *file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == publish_url) || (NULL == download_path)) {
+               sac_error("Invalid Parameter");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _dbus_download_file_publish_async(handle->service_name, publish_url, download_path, file_handle, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       return ret;
+}
+
+/**    @brief  Uploads a server file and writes it to local file
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_upload_file_publish(service_adaptor_h handle,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               char **publish_url,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == upload_path) || (NULL == server_path) || (NULL == publish_url)) {
+               sac_error("Invalid Parameter");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _dbus_upload_file_publish(handle->service_name, upload_path, server_path, publish_url, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       return ret;
+}
+
+/**    @brief  Uploads a server file and writes it to local file (Async)
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_upload_file_publish_async(service_adaptor_h handle,
+                                               const char *upload_path,
+                                               const char *server_path,
+                                               service_adaptor_file_h *file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == upload_path) || (NULL == server_path)) {
+               sac_error("Invalid Parameter");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _dbus_upload_file_publish_async(handle->service_name, upload_path, server_path, file_handle, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       return ret;
+}
+
+/**    @brief  Downloads a thumbnail file and writes it to local file
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_download_thumbnail_publish(service_adaptor_h handle,
+                                               const char *publish_url,
+                                               const char *download_path,
+                                               service_adaptor_thumbnail_size_e size,
+                                               service_adaptor_error_s **error_code,
+                                               void *user_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+       char thumbnail_url[2048] = {0,};
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == publish_url) || (NULL == download_path)) {
+               sac_error("Invalid Parameter");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       char public_token[1024], auth_code[1024];
+       sscanf(publish_url, "%[^'?']?auth_code=%s", public_token, auth_code);
+       snprintf(thumbnail_url, 2048, "%s_%d?auth_code=%s", public_token, size, auth_code);
+
+       ret = _dbus_download_file_publish(handle->service_name, thumbnail_url, download_path, user_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       return ret;
+}
+
+/**    @brief  Requests File Status
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_file_status(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               service_adaptor_file_status_s **status,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == file_handle) || (NULL == status)) {
+               sac_error("Invalid Parameter");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _dbus_get_file_status(handle->service_name, file_handle, status, server_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       return ret;
+}
+
+/**    @brief  Cancels File Transfer
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_cancel_file_transfer(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == file_handle)) {
+               sac_error("Invalid Parameter");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _dbus_cancel_file_transfer(handle->service_name, file_handle, server_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       return ret;
+}
+
+/**    @brief  Pause File Transfer
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_pause_file_transfer(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == file_handle)) {
+               sac_error("Invalid Parameter");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _dbus_pause_file_transfer(handle->service_name, file_handle, server_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       return ret;
+}
+
+/**    @brief  Resume File Transfer
+ *     @return int
+ *     @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_resume_file_transfer(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               service_adaptor_error_s **error_code,
+                                               void **server_data)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       service_adaptor_error_s error;
+       error.msg = NULL;
+
+       if ((NULL == handle) || (NULL == handle->plugin) || (NULL == file_handle)) {
+               sac_error("Invalid Parameter");
+               _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _dbus_resume_file_transfer(handle->service_name, file_handle, server_data, &error);
+
+       if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+               _assign_error_code(&error, error_code);
+       }
+
+       return ret;
+}
+
+/******************************** private feature */
diff --git a/src/util/service_adaptor_client_util.c b/src/util/service_adaptor_client_util.c
new file mode 100644 (file)
index 0000000..72f45fb
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT 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 <gio/gio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include "service_adaptor_client_log.h"
+#include "service-adaptor/dbus-server.h"
+#include "dbus_client.h"
+#include "util/service_adaptor_client_util.h"
+
+#include <bundle.h>
+
+/**    @brief  NULL-pointer safe string duplication function
+ *             This function will not crash if source string pointer is NULL. It is user's
+ *             responsibility to free the result pointer.
+ *     @param str pointer to string which should be duplicated
+ *     @return pointer to the duplicated string
+ *     @remarks :
+ */
+char *_safe_strdup(const char *str)
+{
+       if (NULL == str) {
+               return NULL;
+       } else {
+               return strdup(str);
+       }
+}
+
+void __set_error_code(service_adaptor_error_s **error_code, int code, const char *msg)
+{
+       if (NULL != error_code) {
+               service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+               if (NULL != _error) {
+                       _error->code = code;
+                       _error->msg = strdup(msg);
+               }
+               *error_code = _error;
+       }
+}
+
+void __assign_error_code(service_adaptor_error_s *source_error, service_adaptor_error_s **target_error)
+{
+       service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+       if ((NULL != _error) && (NULL != target_error)) {
+               _error->code = source_error->code;
+               _error->msg = source_error->msg;
+               *target_error = _error;
+       } else {
+               free(_error);
+               free(source_error->msg);
+       }
+}
+
+int _get_result_code(long long int error_code)
+{
+       switch (error_code) {
+               case SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_NONE:
+                       return SERVICE_ADAPTOR_ERROR_NONE;
+               case SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_COMMON_NO_DATA:
+                       sac_error("SERVICE_ADAPTOR_ERROR_NO_DATA");
+                       return SERVICE_ADAPTOR_ERROR_NO_DATA;
+               case SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_COMMON_TIMED_OUT:
+                       sac_error("SERVICE_ADAPTOR_ERROR_TIMED_OUT");
+                       return SERVICE_ADAPTOR_ERROR_TIMED_OUT;
+               case SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_COMMON_NOT_SUPPORTED:
+                       sac_error("SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED");
+                       return SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED;
+               case SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_COMMON_PERMISSION_DENIED:
+                       sac_error("SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED");
+                       return SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED;
+
+               case SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_AUTH_NOT_AUTHORIZED:
+                       sac_error("SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED");
+                       return SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED;
+
+               case SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_MESSAGE_NETWORK:
+                       sac_error("SERVICE_ADAPTOR_ERROR_NETWORK");
+                       return SERVICE_ADAPTOR_ERROR_NETWORK;
+
+               default:
+                       sac_error("SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED");
+                       return SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED;
+       }
+}
+
+
+int _ipc_get_simple_result(GVariant *call_result, GError *g_error, service_adaptor_error_s *error)
+{
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if (NULL == call_result) {
+               error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               if (NULL != g_error) {
+                       sac_error("G_IO_ERROR DEBUG (%d)", (int)(g_error->code));
+                       if (g_error->code == G_IO_ERROR_TIMED_OUT) {
+                               ret = SERVICE_ADAPTOR_ERROR_TIMED_OUT;
+                       }
+                       error->msg = __SAFE_STRDUP(g_error->message);
+                       g_error_free(g_error);
+               }
+       } else {
+               if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+                       error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+                       error->msg = strdup("D-Bus return type error");
+                       ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+               } else {
+                       GVariant *call_result_struct[2];
+                       call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+                       call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+                       uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+                       if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+                               error->code = remote_call_result;
+                               error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+                               ret = _get_result_code(remote_call_result);
+                       }
+                       g_variant_unref(call_result_struct[0]);
+                       g_variant_unref(call_result_struct[1]);
+               }
+               g_variant_unref(call_result);
+       }
+
+       return ret;
+}
+
+static void __g_hash_iterator(gpointer key, gpointer value, gpointer user_data)
+{
+       if (key && value && user_data) {
+               bundle_add_str((bundle *)user_data, (const char *)key, (const char *)value);
+       }
+}
+
+void _create_raw_data_from_plugin_property(void *property, GVariantBuilder **builder)
+{
+       if ((NULL == property) || (NULL == builder)) {
+               return;
+       }
+
+       *builder = g_variant_builder_new(G_VARIANT_TYPE(service_adaptor_raw_data_s_type));
+
+       bundle *bd = bundle_create();
+
+       if (NULL != bd) {
+               g_hash_table_foreach((GHashTable *)property, __g_hash_iterator, (gpointer)bd);
+               unsigned char *input_str = NULL;
+               int input_len = 0;
+
+               int ret = bundle_encode(bd, &input_str, &input_len);
+               if (!ret && input_str && input_len) {
+                       for (int k = 0; k < input_len; k++) {
+                               g_variant_builder_add((*builder), "(y)", (guchar)input_str[k]);
+                       }
+               }
+
+               sac_debug_func("input_str_len(%d)", input_len);
+               free(input_str);
+               input_str = NULL;
+               bundle_free(bd);
+               bd = NULL;
+       }
+}
+
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..702358a
--- /dev/null
@@ -0,0 +1,55 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(service-adaptor-client-test C)
+
+SET(SRCS ${CMAKE_SOURCE_DIR}/test/main.c ${CMAKE_SOURCE_DIR}/src/service-adaptor-client.c ${CMAKE_SOURCE_DIR}/src/service-adaptor-client-auth.c ${CMAKE_SOURCE_DIR}/src/service-adaptor-client-contact.c ${CMAKE_SOURCE_DIR}/src/service-adaptor-client-message.c ${CMAKE_SOURCE_DIR}/src/service-adaptor-client-shop.c ${CMAKE_SOURCE_DIR}/src/service-adaptor-client-storage.c ${CMAKE_SOURCE_DIR}/src/service-adaptor-client-push.c ${CMAKE_SOURCE_DIR}/src/dbus/dbus-client-layer.c ${CMAKE_SOURCE_DIR}/src/dbus/dbus-client.c ${CMAKE_SOURCE_DIR}/src/dbus/dbus-client-auth.c ${CMAKE_SOURCE_DIR}/src/dbus/dbus-client-contact.c ${CMAKE_SOURCE_DIR}/src/dbus/dbus-client-message.c ${CMAKE_SOURCE_DIR}/src/dbus/dbus-client-shop.c ${CMAKE_SOURCE_DIR}/src/dbus/dbus-client-storage.c ${CMAKE_SOURCE_DIR}/src/dbus/dbus-client-push.c)
+
+SET(VENDOR      "tizen")
+SET(PKGPREFIX   "org.${VENDOR}")
+SET(PACKAGE     ${PROJECT_NAME})
+SET(PKGNAME     "${PKGPREFIX}.${PACKAGE}")
+SET(PREFIX      ${CMAKE_INSTALL_PREFIX})
+SET(PREFIX      "/usr")
+SET(BINDIR      "${PREFIX}/bin")
+SET(LIBDIR     "${PREFIX}/lib")
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+       SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc/dbus)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+       glib-2.0
+#      org.tizen.service-adaptor-client
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -std=gnu99 -D_GNU_SOURCE")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+       ADD_DEFINITIONS("-DTARGET")
+       MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
+ADD_DEFINITIONS("-DPACKAGE_PREFIX=\"${PKGPREFIX}\"")
+ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
+ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} "-lm -ldl -lrt")
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
diff --git a/test/main.c b/test/main.c
new file mode 100644 (file)
index 0000000..20a7468
--- /dev/null
@@ -0,0 +1,1932 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <stdio.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <glib-object.h>
+#include <glib-unix.h>
+#include <string.h>        /* strlen() */
+#include <fcntl.h>         /* O_WRONLY */
+#include <unistd.h>        /* write(), close() */
+#include <telephony.h>
+#include <sys/time.h>
+
+#include <service_adaptor_client.h>
+#include <service_adaptor_client_auth.h>
+#include <service-adaptor-client-contact.h>
+#include <service-adaptor-client-message.h>
+#include <service-adaptor-client-shop.h>
+#include <service_adaptor_client_storage.h>
+#include <service_adaptor_client_storage_private.h>
+#include <service-adaptor-client-push.h>
+
+#define __CONTACT_TEST__
+/*#define __CONTACT_SIM2_TEST__ */
+/*#define __CONTACT_PUSH_SET_TEST__ */
+/*#define __CONTACT_PUSH_GET_TEST__ */
+#define __MESSAGE_TEST__
+#define __MESSAGE_STORAGE_TEST__
+/*#define __MESSAGE_SIM2_TEST__ */
+/*#define __MESSAGE_SEND_TEST__ */
+/*#define __MESSAGE_RECEIVE_TEST__ */
+#define __SHOP_TEST__
+
+service_adaptor_h g_handle = NULL;
+long long int g_chatroom_id = 0;
+
+void api_test(service_adaptor_h handle);
+
+char **_get_imsi()
+{
+       telephony_handle_list_s list;
+       char **imsi_list = (char **) g_malloc0(sizeof(char*)*2);
+       char *sim_operator = NULL;
+       char *msin = NULL;
+       int i = 0;
+
+       if ((TELEPHONY_ERROR_NONE != telephony_init(&list)) || (0 == list.count)) {
+               return NULL;
+       }
+
+       for (i = 0; i < list.count; i++) {
+               if (TELEPHONY_ERROR_NONE != telephony_sim_get_operator(list.handle[i], &sim_operator)
+                               || TELEPHONY_ERROR_NONE != telephony_sim_get_msin(list.handle[i], &msin)) {
+                       if (sim_operator) {
+                               free(sim_operator);
+                               sim_operator = NULL;
+                       }
+
+                       imsi_list[i] = NULL;
+               } else {
+                       imsi_list[i] = g_strconcat(sim_operator, msin, NULL);
+                       free(sim_operator);
+                       free(msin);
+               }
+       }
+
+       telephony_deinit(&list);
+
+       return imsi_list;
+}
+
+void display_contact_response(service_adaptor_contact_res_s *response)
+{
+       if (0 != response->tt) {
+               printf("tt : %lld \n", response->tt);
+       }
+
+       for (int i = 0; i < response->cts_len; i++) {
+               printf(" duid : %s \n", response->cts[i]->duid);
+               printf(" id : %s \n", response->cts[i]->id);
+               printf(" msisdn : %s \n", response->cts[i]->msisdn);
+               printf(" ty : %s \n", response->cts[i]->ty);
+               printf(" cc : %s \n", response->cts[i]->cc);
+               printf(" pn : %s \n", response->cts[i]->pn);
+               printf(" nm : %s \n", response->cts[i]->nm);
+               printf(" img : %s \n", response->cts[i]->img);
+               printf(" org : %s \n", response->cts[i]->org);
+
+               printf(" prsc : %s \n", response->cts[i]->prsc);
+               printf(" status : %s \n", response->cts[i]->status);
+               printf(" sids : %d \n", response->cts[i]->sids);
+
+               for (int j = 0; j < response->cts[i]->evnt_len; j++) {
+                       printf("evnt[%d] : %s \n", j, response->cts[i]->evnt[j]);
+               }
+               for (int j = 0; j < response->cts[i]->adrs_len; j++) {
+                       printf("adrs[%d] : %s \n", j, response->cts[i]->adrs[j]);
+               }
+
+               for (int j = 0; j < response->cts[i]->mail_len; j++) {
+                       printf("mail[%d] : %s \n", j, response->cts[i]->mail[j]);
+               }
+       }
+}
+
+/* signal callback */
+void my_signal_cb(service_adaptor_h handle, service_adaptor_signal_code_e signal, char *msg)
+{
+       printf("signal(%d): %s\n", signal, msg);
+
+       if (SERVICE_ADAPTOR_SIGNAL_INITIALIZED == signal) {
+               printf("SERVICE_ADAPTOR_SIGNAL_INITIALIZED\n");
+       } else if ((SERVICE_ADAPTOR_SIGNAL_ACTIVATE_PLUGIN == signal) && (0 == strncmp(msg, "ORCA", 4))) {
+               api_test(handle);
+       }
+}
+
+/* message callback */
+void my_reply_create_chatroom_cb(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               service_adaptor_wrong_receiver_s *wrong_receiver,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data)
+{
+       if (NULL != error_code) {
+               printf("error (reply create chatroom) (%lld): %s\n", error_code->code, error_code->msg);
+
+               if (NULL != wrong_receiver) {
+                       for (gsize j = 0; j < wrong_receiver->invalid_receivers_len; j++) {
+                               printf("invalid_receivers: %lld\n", wrong_receiver->invalid_receivers[j]);
+                       }
+
+                       for (gsize j = 0; j < wrong_receiver->interrupted_receivers_len; j++) {
+                       printf("interrupted_receivers: %lld\n", wrong_receiver->interrupted_receivers[j]);
+                       }
+
+                       for (gsize j = 0; j < wrong_receiver->disabled_receivers_len; j++) {
+                               printf("disabled_receivers: %lld\n", wrong_receiver->disabled_receivers[j]);
+                       }
+
+                       for (gsize j = 0; j < wrong_receiver->existing_chatmembers_len; j++) {
+                               printf("existing_chatmembers: %lld\n", wrong_receiver->existing_chatmembers[j]);
+                       }
+
+                       for (gsize j = 0; j < wrong_receiver->did_violation_users_len; j++) {
+                               printf("did_violation_users - usera: %lld, userb: %lld\n", wrong_receiver->did_violation_users[j]->usera, wrong_receiver->did_violation_users[j]->userb);
+                       }
+               }
+
+               return;
+       }
+
+       printf("reply create chatroom: (%lld)\n", request_id);
+       printf("chatroom id: (%lld)\n", chatroom_id);
+
+       g_chatroom_id = chatroom_id;
+}
+
+void my_reply_chat_cb(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               service_adaptor_processed_msg_s **processed_msgs,
+                                               unsigned int processed_msgs_len,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data)
+{
+       if (NULL != error_code) {
+               printf("error (reply chat) (%lld): %s\n", error_code->code, error_code->msg);
+               return;
+       }
+
+       printf("reply chat: (%lld)\n", request_id);
+
+       for (int i = 0; i < processed_msgs_len; i++) {
+               printf("msg id: (%lld), sent time: (%lld)\n", processed_msgs[i]->msg_id, processed_msgs[i]->sent_time);
+       }
+}
+
+void my_reply_allow_chat_cb(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               service_adaptor_delivery_ack_s **delivery_acks,
+                                               unsigned int delivery_acks_len,
+                                               service_adaptor_read_ack_s **read_acks,
+                                               unsigned int read_acks_len,
+                                               service_adaptor_ordered_chat_member_s **ordered_chat_members,
+                                               unsigned int ordered_chat_members_len,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data)
+{
+       if (NULL != error_code) {
+               printf("error (reply allow chat) (%lld): %s\n", error_code->code, error_code->msg);
+               return;
+       }
+
+       printf("reply allow chat: (%lld)\n", request_id);
+       printf("read_acks: (%u)\n", read_acks_len);
+       printf("deliveryacks: (%u)\n", delivery_acks_len);
+}
+
+void my_reply_all_unread_message_cb(service_adaptor_h handle,
+                                               long long int request_id,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data)
+{
+       if (NULL != error_code) {
+               printf("error (reply all unread message) (%lld): %s\n", error_code->code, error_code->msg);
+               return;
+       }
+
+       printf("reply all unread message: (%lld)\n", request_id);
+}
+
+void my_request_forward_online_message_cb(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               int chat_type,
+                                               service_adaptor_inbox_message_s *inbox_msg,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data)
+{
+       if (NULL != error_code) {
+               printf("error (request forward online message) (%lld): %s\n", error_code->code, error_code->msg);
+               return;
+       }
+
+       printf("request forward online message: (%lld)\n", request_id);
+       printf("chatroom id: (%lld)\n", chatroom_id);
+
+       /* call reply_forward_online_message */
+       bool mark_as_read = false;
+       service_adaptor_error_s *error = NULL;
+       service_adaptor_reply_forward_online_message(handle, request_id, chatroom_id, mark_as_read, &error, NULL);
+}
+
+void my_request_forward_unread_message_cb(service_adaptor_h handle,
+                                               long long int request_id,
+                                               service_adaptor_inbox_message_s **inbox_msgs,
+                                               unsigned int inbox_msgs_len,
+                                               const char *next_pagination_key,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data)
+{
+       if (NULL != error_code) {
+               printf("error (request forward unread message) (%lld): %s\n", error_code->code, error_code->msg);
+               return;
+       }
+
+       printf("request forward unread message: (%lld)\n", request_id);
+
+       for (int i = 0; i < inbox_msgs_len; i++) {
+               printf("inbox: msgid(%lld), msgtype(%d), sender(%lld), receiver(%lld), senttime(%lld), chatmsg(%s), chatroomid(%lld), chattype(%d) bomb_ttl(%lld)\n", inbox_msgs[i]->msg_id, inbox_msgs[i]->msg_type, inbox_msgs[i]->sender, inbox_msgs[i]->receiver, inbox_msgs[i]->sent_time, inbox_msgs[i]->chat_msg, inbox_msgs[i]->chatroom_id, inbox_msgs[i]->chat_type, inbox_msgs[i]->bomb_ttl);
+       }
+
+       /* call reply_forward_unread_message */
+       int max_count = 100;
+       service_adaptor_error_s *error = NULL;
+       service_adaptor_reply_forward_unread_message(handle, request_id, next_pagination_key, max_count, &error, NULL);
+}
+
+void my_reply_read_message_cb(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data)
+{
+       if (NULL != error_code) {
+               printf("error (reply read message) (%lld): %s\n", error_code->code, error_code->msg);
+               return;
+       }
+
+       printf("reply read message: (%lld)\n", request_id);
+       printf("chatroom id: (%lld)\n", chatroom_id);
+}
+
+void my_reply_invite_chat_cb(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               long long int sent_time,
+                                               service_adaptor_wrong_receiver_s *wrong_receiver,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data)
+{
+       if (NULL != error_code) {
+               printf("error (reply invite chat) (%lld): %s\n", error_code->code, error_code->msg);
+
+               if (NULL != wrong_receiver) {
+                       for (gsize j = 0; j < wrong_receiver->invalid_receivers_len; j++) {
+                               printf("invalid_receivers: %lld\n", wrong_receiver->invalid_receivers[j]);
+                       }
+
+                       for (gsize j = 0; j < wrong_receiver->interrupted_receivers_len; j++) {
+                               printf("interrupted_receivers: %lld\n", wrong_receiver->interrupted_receivers[j]);
+                       }
+
+                       for (gsize j = 0; j < wrong_receiver->disabled_receivers_len; j++) {
+                               printf("disabled_receivers: %lld\n", wrong_receiver->disabled_receivers[j]);
+                       }
+
+                       for (gsize j = 0; j < wrong_receiver->existing_chatmembers_len; j++) {
+                               printf("existing_chatmembers: %lld\n", wrong_receiver->existing_chatmembers[j]);
+                       }
+
+                       for (gsize j = 0; j < wrong_receiver->did_violation_users_len; j++) {
+                               printf("did_violation_users - usera : %lld\n", wrong_receiver->did_violation_users[j]->usera);
+                               printf("did_violation_users - userb : %lld\n", wrong_receiver->did_violation_users[j]->userb);
+                       }
+               }
+
+               return;
+       }
+
+       printf("reply invite chat: (%lld)\n", request_id);
+       printf("chatroom id: (%lld)\n", chatroom_id);
+}
+
+void my_reply_end_chat_cb(service_adaptor_h handle,
+                                               long long int request_id,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data)
+{
+       if (NULL != error_code) {
+               printf("error (reply end chat) (%lld): %s\n", error_code->code, error_code->msg);
+               return;
+       }
+
+       printf("reply end chat: (%lld)\n", request_id);
+}
+
+void my_reply_current_time_cb(service_adaptor_h handle,
+                                               long long int request_id,
+                                               long long int current_time_millis,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data)
+{
+       if (NULL != error_code) {
+               printf("error (reply current time) (%lld): %s\n", error_code->code, error_code->msg);
+               return;
+       }
+
+       printf("reply current time: (%lld)\n", request_id);
+       printf("current time: (%lld)\n", current_time_millis);
+}
+
+/* storage callback */
+void my_file_progress_cb(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               unsigned long long transferred_size,
+                                               unsigned long long total_size,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data)
+{
+       if (NULL != error_code) {
+               printf("error (progress) (%lld): %s\n", error_code->code, error_code->msg);
+               return;
+       }
+
+       printf("progress(%d): (%llu) / (%llu)\n", file_handle->file_description, transferred_size, total_size);
+}
+
+void my_file_transfer_completion_cb(service_adaptor_h handle,
+                                               service_adaptor_file_h file_handle,
+                                               char *publish_url,
+                                               service_adaptor_error_s *error_code,
+                                               void *server_data)
+{
+       if (NULL != error_code) {
+               printf("error (file_transfer_completion) (%lld): %s\n", error_code->code, error_code->msg);
+               return;
+       }
+
+       if (NULL == file_handle) {
+               printf("Cannot get file handle\n");
+               return;
+       }
+
+       printf("file_transfer_completion: (%d) (%s)\n", file_handle->file_description,  publish_url);
+}
+
+/* push callback */
+void my_push_notification_cb(service_adaptor_h handle,
+                                               service_adaptor_push_notification_s *noti_info,
+                                               service_adaptor_error_s *error_code,
+                                               void *user_data)
+{
+       if (NULL != error_code) {
+               printf("error (push notification) (%lld): %s\n", error_code->code, error_code->msg);
+               return;
+       }
+
+       printf("my_push_notification_cb\n");
+
+       if (NULL == noti_info) {
+               return;
+       }
+
+       printf("app data: (%s) (%s) (%lld)\n", noti_info->data, noti_info->message, noti_info->time);
+}
+
+/* contact_api_test */
+service_adaptor_result_e contact_api_test(service_adaptor_h handle)
+{
+       service_adaptor_result_e ret = SERVICE_ADAPTOR_RESULT_SUCCEEDED;
+       service_adaptor_error_s *error_code = NULL;
+       unsigned int service_id = 0;
+       printf("service_adaptor_contact\n");
+
+       /* auth (input your app_id and app_secret, 5th param - contact: 0, message: 1, shop: 2, storage: 3) */
+       ret = service_adaptor_auth_set_service_info(handle, "37y6zxadz2", service_id);
+       ret = service_adaptor_auth_start_service(handle, "com.serviceadaptor.contact1", "E052DDAE0B03821AB1F485E2D9008DFD", "UNUSE_PASSWORD", &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+               return ret;
+       }
+
+       /* connect push */
+       ret = service_adaptor_connect_push_service(handle, my_push_notification_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       /* create contact request info */
+       service_adaptor_contact_req_s *contact_req = (service_adaptor_contact_req_s *) g_malloc0(sizeof(service_adaptor_contact_req_s));
+       contact_req->tt = 0;
+       contact_req->cts = (service_adaptor_contact_info_req_s **) g_malloc0(sizeof(service_adaptor_contact_info_req_s *) * 2);
+       contact_req->cts[0] = (service_adaptor_contact_info_req_s *) g_malloc0(sizeof(service_adaptor_contact_info_req_s));
+       contact_req->cts[0]->tp = NULL;
+       contact_req->cts[0]->id = strdup("1");
+       contact_req->cts[0]->pn = strdup("01048210267");
+       contact_req->cts[0]->nm = strdup("blackphone1");
+       contact_req->cts[0]->cc = strdup("82");
+
+       contact_req->cts[1] = (service_adaptor_contact_info_req_s *) g_malloc0(sizeof(service_adaptor_contact_info_req_s));
+       contact_req->cts[1]->tp = NULL;
+       contact_req->cts[1]->id = strdup("2");
+       contact_req->cts[1]->pn = strdup("01041278499");
+       contact_req->cts[1]->nm = strdup("pushtest2");
+       contact_req->cts[1]->cc = strdup("82");
+       contact_req->cts_len = 2;
+
+       service_adaptor_contact_res_s *contact_res = NULL;
+
+       printf("service_adaptor_set_new_contact_list\n");
+       ret = service_adaptor_set_new_contact_list(handle, contact_req, NULL, &contact_res, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               display_contact_response(contact_res);
+       }
+
+       /* need to free the memory space of contact_res */
+
+       contact_req->cts[0]->tp = strdup("S");
+       contact_req->cts[1]->tp = strdup("S");
+       printf("service_adaptor_set_contact_list\n");
+       ret = service_adaptor_set_contact_list(handle, contact_req, NULL, &contact_res, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               display_contact_response(contact_res);
+       }
+
+       /* need to free the memory space of contact_res */
+
+       printf("service_adaptor_get_contact_infos_latest\n");
+       ret = service_adaptor_get_contact_infos_latest(handle, &contact_res, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               display_contact_response(contact_res);
+       }
+
+       /* need to free the memory space of contact_res */
+
+       contact_req->tt = 343242152532125;
+       printf("service_adaptor_get_contact_infos_polling\n");
+       ret = service_adaptor_get_contact_infos_polling(handle, contact_req, NULL, &contact_res, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               display_contact_response(contact_res);
+       }
+
+       /* need to free the memory space of contact_req */
+       /* need to free the memory space of contact_res */
+
+       /* create profile request info */
+       service_adaptor_profile_req_s *profile_req = (service_adaptor_profile_req_s *) g_malloc0(sizeof(service_adaptor_profile_req_s));
+       profile_req->cc = NULL;
+       profile_req->pn = NULL;
+       profile_req->nm = strdup("myphone8499");
+       profile_req->evnt = (char **) g_malloc0(sizeof(char *)*1);
+       profile_req->evnt[0] = strdup("{ \"ty\" : \"1\",\"d1\" : \"19880103\" , \"d2\" : \"19880103\"}");
+       profile_req->evnt_len = 1;
+       profile_req->img = strdup("111");
+       profile_req->adrs = (char **) g_malloc0(sizeof(char *)*1);
+       profile_req->adrs[0] = strdup("{\"ty\":\"1\", \"d1\":\"416 suwon\", \"d2\":\"3dong\"}");
+       profile_req->adrs_len = 1;
+       profile_req->mail = (char **) g_malloc0(sizeof(char *)*1);
+       profile_req->mail[0] = strdup("{\"ty\" : \"1\" , \"d1\":\"19880103@naver.com\", \"d2\":\"19880103@naver.com\"}");
+       profile_req->mail_len = 1;
+       profile_req->org = strdup("{\"com\":\"samsung\", \"pst\":\"eng\",\"depart\":\"swc\"}");
+       profile_req->prsc = "1001";
+       profile_req->status = "meeting";
+
+       service_adaptor_profile_res_s *profile_res = NULL;
+
+       printf("service_adaptor_set_me_profile_with_push\n");
+       ret = service_adaptor_set_me_profile_with_push(handle, profile_req, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       profile_req->cc = strdup("82");
+       profile_req->pn = strdup("01048210267");
+       printf("service_adaptor_get_profile\n");
+       ret = service_adaptor_get_profile(handle, profile_req, NULL, &profile_res, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               printf("(%s) (%s) (%s) (%s)\n", profile_res->nm, profile_res->img, profile_res->prsc, profile_res->status);
+       }
+
+       /* need to free the memory space of profile_req */
+       /* need to free the memory space of profile_res */
+
+       /* file */
+       service_adaptor_file_path_s *file_paths = (service_adaptor_file_path_s *) g_malloc0(sizeof(service_adaptor_file_path_s));
+       file_paths->file_paths = (char **) g_malloc0(sizeof(char *) * 1);
+       file_paths->file_paths[0] = strdup("/opt/usr/media/Images/Image_03.jpg");
+/*     file_paths->file_paths[0] = strdup("/opt/usr/share/media/.thumb/thumb_default.png"); */
+       file_paths->file_paths_len = 1;
+
+       service_adaptor_file_path_s *server_paths = NULL;
+
+       printf("service_adaptor_set_profile_image_meta_with_push\n");
+       ret = service_adaptor_set_profile_image_meta_with_push(handle, file_paths, NULL, &server_paths, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               if (server_paths->file_paths_len > 0) {
+                       printf("(%s) (%d)\n", server_paths->file_paths[0], server_paths->file_paths_len);
+               }
+       }
+
+       /* need to free the memory space of file_paths */
+
+       printf("service_adaptor_delete_me_profile_image_meta_with_push\n");
+       ret = service_adaptor_delete_me_profile_image_meta_with_push(handle, server_paths, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       /* need to free the memory space of server_paths */
+
+       /* create privacy request info */
+       service_adaptor_privacy_req_s *privacy_req = (service_adaptor_privacy_req_s *) g_malloc0(sizeof(service_adaptor_privacy_req_s));
+       privacy_req->lvl = 0;
+       privacy_req->cts = (service_adaptor_privacy_info_req_s **) g_malloc0(sizeof(service_adaptor_privacy_info_req_s *) * 2);
+       privacy_req->cts[0] = (service_adaptor_privacy_info_req_s *) g_malloc0(sizeof(service_adaptor_privacy_info_req_s));
+       privacy_req->cts[0]->cc = NULL;
+       privacy_req->cts[0]->pn = strdup("01041278499");
+       privacy_req->cts[1] = (service_adaptor_privacy_info_req_s *) g_malloc0(sizeof(service_adaptor_privacy_info_req_s));
+       privacy_req->cts[1]->cc = strdup("82");
+       privacy_req->cts[1]->pn = strdup("01012345678");
+       privacy_req->cts_len = 2;
+
+       service_adaptor_privacy_res_s *privacy_res = NULL;
+
+       printf("service_adaptor_set_me_profile_privacy\n");
+       ret = service_adaptor_set_me_profile_privacy(handle, privacy_req, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       printf("service_adaptor_get_me_profile_privacy\n");
+       ret = service_adaptor_get_me_profile_privacy(handle, &privacy_res, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               printf("(%u) (%u)\n", privacy_res->lvl, privacy_res->prscon);
+       }
+
+       /* need to free the memory space of privacy_req */
+       /* need to free the memory space of privacy_res */
+
+       /* create presence request info */
+       service_adaptor_presence_req_s *presence_req = (service_adaptor_presence_req_s *) g_malloc0(sizeof(service_adaptor_presence_req_s));
+       presence_req->prsc = "1001";
+       presence_req->status = "business trip";
+       presence_req->prscon = 0;
+
+       printf("service_adaptor_set_me_presence_with_push\n");
+       ret = service_adaptor_set_me_presence_with_push(handle, presence_req, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       presence_req->prscon = 1;
+       printf("service_adaptor_set_me_presence_on_off_with_push\n");
+       ret = service_adaptor_set_me_presence_on_off_with_push(handle, presence_req, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       free(presence_req);
+       presence_req = NULL;
+
+       /* disconnect push */
+       service_adaptor_disconnect_push_service(handle);
+
+       return ret;
+}
+
+/* contact_api_push_set_test */
+service_adaptor_result_e contact_api_push_set_test(service_adaptor_h handle)
+{
+       service_adaptor_result_e ret = SERVICE_ADAPTOR_RESULT_SUCCEEDED;
+       service_adaptor_error_s *error_code = NULL;
+       unsigned int service_id = 0;
+       printf("service_adaptor_contact\n");
+
+       /* auth (input your app_id and app_secret, 5th param - contact: 0, message: 1, shop: 2, storage: 3) */
+       ret = service_adaptor_auth_set_service_info(handle, "37y6zxadz2", service_id);
+       ret = service_adaptor_auth_start_service(handle, "com.serviceadaptor.contact2", "E052DDAE0B03821AB1F485E2D9008DFD", "UNUSE_PASSWORD", &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+               return ret;
+       }
+
+       /* connect push */
+       ret = service_adaptor_connect_push_service(handle, my_push_notification_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       /* create contact request info */
+       service_adaptor_contact_req_s *contact_req = (service_adaptor_contact_req_s *) g_malloc0(sizeof(service_adaptor_contact_req_s));
+       contact_req->tt = 0;
+       contact_req->cts = (service_adaptor_contact_info_req_s **) g_malloc0(sizeof(service_adaptor_contact_info_req_s *) * 1);
+       contact_req->cts[0] = (service_adaptor_contact_info_req_s *) g_malloc0(sizeof(service_adaptor_contact_info_req_s));
+       contact_req->cts[0]->tp = NULL;
+       contact_req->cts[0]->id = strdup("1");
+       contact_req->cts[0]->pn = strdup("01063159662");
+       contact_req->cts[0]->nm = strdup("jiwon kim");
+       contact_req->cts[0]->cc = strdup("82");
+       contact_req->cts_len = 1;
+
+       service_adaptor_contact_res_s *contact_res = NULL;
+
+       printf("service_adaptor_set_new_contact_list\n");
+       ret = service_adaptor_set_new_contact_list(handle, contact_req, NULL, &contact_res, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               display_contact_response(contact_res);
+       }
+
+       /* need to free the memory space of contact_res */
+
+       contact_req->cts[0]->tp = strdup("S");
+       printf("service_adaptor_set_contact_list\n");
+       ret = service_adaptor_set_contact_list(handle, contact_req, NULL, &contact_res, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               display_contact_response(contact_res);
+       }
+
+       /* need to free the memory space of contact_res */
+
+       /* create privacy request info */
+       service_adaptor_privacy_req_s *privacy_req = (service_adaptor_privacy_req_s *) g_malloc0(sizeof(service_adaptor_privacy_req_s));
+       privacy_req->lvl = 0;
+       privacy_req->cts = NULL;
+       privacy_req->cts_len = 0;
+
+       printf("service_adaptor_set_me_profile_privacy\n");
+       ret = service_adaptor_set_me_profile_privacy(handle, privacy_req, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       /* create profile request info */
+       service_adaptor_profile_req_s *profile_req = (service_adaptor_profile_req_s *) g_malloc0(sizeof(service_adaptor_profile_req_s));
+       profile_req->cc = NULL;
+       profile_req->pn = NULL;
+       profile_req->nm = strdup("change number");
+       profile_req->evnt = NULL;
+       profile_req->evnt_len = 0;
+       profile_req->img = NULL;
+       profile_req->adrs = NULL;
+       profile_req->adrs_len = 0;
+       profile_req->mail = NULL;
+       profile_req->mail_len = 0;
+       profile_req->org = NULL;
+       profile_req->prsc = "1001";
+       profile_req->status = "meeting";
+
+       printf("service_adaptor_set_me_profile_with_push\n");
+       ret = service_adaptor_set_me_profile_with_push(handle, profile_req, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       /* need to free the memory space of profile_req */
+
+       /* disconnect push */
+       service_adaptor_disconnect_push_service(handle);
+
+       return ret;
+}
+
+/* contact_api_push_get_test */
+service_adaptor_result_e contact_api_push_get_test(service_adaptor_h handle)
+{
+       service_adaptor_result_e ret = SERVICE_ADAPTOR_RESULT_SUCCEEDED;
+       service_adaptor_error_s *error_code = NULL;
+       unsigned int service_id = 0;
+       printf("service_adaptor_contact\n");
+
+       /* auth (input your app_id and app_secret, 5th param - contact: 0, message: 1, shop: 2, storage: 3) */
+       ret = service_adaptor_auth_set_service_info(handle, "37y6zxadz2", service_id);
+       ret = service_adaptor_auth_start_service(handle, "com.serviceadaptor.contact3", "E052DDAE0B03821AB1F485E2D9008DFD", "UNUSE_PASSWORD", &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+               return ret;
+       }
+
+       /* connect push */
+       ret = service_adaptor_connect_push_service(handle, my_push_notification_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       /* create contact request info */
+       service_adaptor_contact_req_s *contact_req = (service_adaptor_contact_req_s *) g_malloc0(sizeof(service_adaptor_contact_req_s));
+       contact_req->tt = 0;
+       contact_req->cts = (service_adaptor_contact_info_req_s **) g_malloc0(sizeof(service_adaptor_contact_info_req_s *) * 1);
+       contact_req->cts[0] = (service_adaptor_contact_info_req_s *) g_malloc0(sizeof(service_adaptor_contact_info_req_s));
+       contact_req->cts[0]->tp = NULL;
+       contact_req->cts[0]->id = strdup("1");
+       contact_req->cts[0]->pn = strdup("01021603009");
+       contact_req->cts[0]->nm = strdup("yongjin kim");
+       contact_req->cts[0]->cc = strdup("82");
+       contact_req->cts_len = 1;
+
+       service_adaptor_contact_res_s *contact_res = NULL;
+
+       printf("service_adaptor_set_new_contact_list\n");
+       ret = service_adaptor_set_new_contact_list(handle, contact_req, NULL, &contact_res, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               display_contact_response(contact_res);
+       }
+
+       /* need to free the memory space of contact_res */
+
+       contact_req->cts[0]->tp = strdup("S");
+       printf("service_adaptor_set_contact_list\n");
+       ret = service_adaptor_set_contact_list(handle, contact_req, NULL, &contact_res, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               display_contact_response(contact_res);
+       }
+
+       /* need to free the memory space of contact_res */
+
+       /* create privacy request info */
+       service_adaptor_privacy_req_s *privacy_req = (service_adaptor_privacy_req_s *) g_malloc0(sizeof(service_adaptor_privacy_req_s));
+       privacy_req->lvl = 0;
+       privacy_req->cts = NULL;
+       privacy_req->cts_len = 0;
+
+       printf("service_adaptor_set_me_profile_privacy\n");
+       ret = service_adaptor_set_me_profile_privacy(handle, privacy_req, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       /* disconnect push */
+       service_adaptor_disconnect_push_service(handle);
+
+       return ret;
+}
+
+/* message_api_test */
+service_adaptor_result_e message_api_test(service_adaptor_h handle)
+{
+       service_adaptor_result_e ret = SERVICE_ADAPTOR_RESULT_SUCCEEDED;
+       service_adaptor_error_s *error_code = NULL;
+       unsigned int service_id = 1;
+       printf("service_adaptor_message\n");
+
+       /* auth (input your app_id and app_secret, 5th param - contact: 0, message: 1, shop: 2, storage: 3) */
+       ret = service_adaptor_auth_set_service_info(handle, "az51t5bhq6", service_id);
+       ret = service_adaptor_auth_start_service(handle, "com.serviceadaptor.message1", "7F879A9FD481520514AC3DDE0D6DF097", "UNUSE_PASSWORD", &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+               return ret;
+       }
+
+       /* connect push */
+       ret = service_adaptor_connect_push_service(handle, my_push_notification_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       /* register listener function called by message server */
+       printf("service_adaptor_message: register listener\n");
+       ret = service_adaptor_register_forward_online_message_listener(handle, my_request_forward_online_message_cb, NULL);
+       ret = service_adaptor_register_forward_unread_message_listener(handle, my_request_forward_unread_message_cb, NULL);
+
+       /* chat id list */
+       service_adaptor_phone_number_s **phone_numbers = (service_adaptor_phone_number_s **) g_malloc0(sizeof(service_adaptor_phone_number_s *) * 1);
+       phone_numbers[0] = (service_adaptor_phone_number_s *) g_malloc0(sizeof(service_adaptor_phone_number_s));
+       phone_numbers[0]->phonenumber = strdup("01021600201");
+       phone_numbers[0]->ccc = strdup("82");
+       unsigned int phone_numbers_len = 1;
+       service_adaptor_chat_id_s **chat_ids = NULL;
+       unsigned int chat_ids_len = 0;
+       printf("service_adaptor_message: chat_id_list\n");
+       ret = service_adaptor_get_chat_id_list(handle, phone_numbers, phone_numbers_len, NULL, &chat_ids, &chat_ids_len, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               for (int i = 0; i < chat_ids_len; i++) {
+                       printf("chatid: (%lld)\n", chat_ids[i]->chatid);
+               }
+       }
+
+       /* need to free the memory space of phone_numbers */
+
+       /* msisdn list */
+       long long int *chat_list = NULL;
+
+       if (0 < chat_ids_len) {
+               chat_list = (long long int *) g_malloc0(sizeof(long long int) * chat_ids_len);
+
+               for (int i = 0; i < chat_ids_len; i++) {
+                       chat_list[i] = chat_ids[i]->chatid;
+               }
+       } else {
+               return SERVICE_ADAPTOR_RESULT_FAILED;
+       }
+
+       service_adaptor_chat_id_s **msisdns = NULL;
+       unsigned int msisdns_len = 0;
+       printf("service_adaptor_message: msisdn_list\n");
+       ret = service_adaptor_get_msisdn_list(handle, chat_list, chat_ids_len, NULL, &msisdns, &msisdns_len, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       for (int i = 0; i < msisdns_len; i++) {
+               printf("msisdn: (%s)\n", msisdns[i]->msisdn);
+       }
+
+       /* need to free the memory space of chat_list */
+       /* need to free the memory space of msisdns */
+
+       /* create chatroom */
+       struct timeval tv;
+       long long int req_id;
+       long long int *receivers;
+       int room_chat_type = 1;         /* 0: SINGLE, 1: GROUP */
+       unsigned int receivers_len = chat_ids_len;
+
+       receivers = (long long int *) g_malloc0(sizeof(long long int) * receivers_len);
+
+       for (int i = 0; i < chat_ids_len; i++) {
+               receivers[i] = chat_ids[i]->chatid;
+       }
+
+       gettimeofday(&tv, NULL);
+       req_id = (long long int) tv.tv_usec;
+       printf("service_adaptor_message: create_chatroom (%lld)\n", req_id);
+       ret = service_adaptor_request_create_chatroom(handle, req_id, room_chat_type, receivers, receivers_len, my_reply_create_chatroom_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+       sleep(3);
+
+       /* request chat */
+       unsigned int chat_msgs_len = 1;
+
+       gettimeofday(&tv, NULL);
+       req_id = (long long int) tv.tv_usec;
+       service_adaptor_chat_msg_s **chat_msgs = (service_adaptor_chat_msg_s **) g_malloc0(sizeof(service_adaptor_chat_msg_s *) * 1);
+       chat_msgs[0] = (service_adaptor_chat_msg_s *) g_malloc0(sizeof(service_adaptor_chat_msg_s));
+       gettimeofday(&tv, NULL);
+       chat_msgs[0]->msg_id = (long long int) tv.tv_usec;
+       chat_msgs[0]->msg_type = 0;     /* TEXT */
+       chat_msgs[0]->chatmsg = strdup("111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111");
+       chat_msgs[0]->bomb_ttl = 3;     /* sec */
+       printf("service_adaptor_message: chat (%lld)\n", req_id);
+       ret = service_adaptor_request_chat(handle, req_id, g_chatroom_id, chat_msgs, chat_msgs_len, my_reply_chat_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+       /* need to free the memory space of chat_msgs */
+       sleep(3);
+
+       /* allow chat */
+       gettimeofday(&tv, NULL);
+       req_id = (long long int) tv.tv_usec;
+       printf("service_adaptor_message: allow_chat (%lld)\n", req_id);
+       ret = service_adaptor_request_allow_chat(handle, req_id, g_chatroom_id, 500, false, 0, false, 0, false, my_reply_allow_chat_cb, &error_code, NULL);
+
+       int m_max_count = 500;
+       bool is_need_delivery_ack = true;
+       long long int m_delivery_ack_timestamp = 123;
+       bool is_need_watemark = false;
+       long m_last_water_timestamp = 0;
+       bool is_need_ordered_chat_member_list = false;
+       ret = service_adaptor_request_allow_chat(handle,
+                       req_id, g_chatroom_id, m_max_count, is_need_delivery_ack, m_delivery_ack_timestamp,
+                       is_need_watemark, m_last_water_timestamp, is_need_ordered_chat_member_list,
+                       my_reply_allow_chat_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+       sleep(3);
+
+       /* all unread message */
+       printf("service_adaptor_message: all_unread_message\n");
+       gettimeofday(&tv, NULL);
+       req_id = (long long int) tv.tv_usec;
+       ret = service_adaptor_request_all_unread_message(handle, req_id, 500, my_reply_all_unread_message_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+       sleep(3);
+
+       /* read message */
+       gettimeofday(&tv, NULL);
+       req_id = (long long int) tv.tv_usec;
+       service_adaptor_inbox_message_s *inbox_msg = (service_adaptor_inbox_message_s *) g_malloc0(sizeof(service_adaptor_inbox_message_s));
+       inbox_msg->msg_id = 12345674532135;
+       inbox_msg->msg_type = 0;
+       inbox_msg->sender = 84102410152;
+       inbox_msg->sent_time = 1306142372833;
+       printf("service_adaptor_message: read_message\n");
+       ret = service_adaptor_request_read_message(handle, req_id, g_chatroom_id, inbox_msg, my_reply_read_message_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+       /* need to free the memory space of inbox_msg */
+       sleep(3);
+
+       /* invite chat */
+       gettimeofday(&tv, NULL);
+       req_id = (long long int) tv.tv_usec;
+       long long int inviting_members[] = {15312646460933272};
+       unsigned int inviting_members_len = 1;
+       printf("service_adaptor_message: invite_chat\n");
+       ret = service_adaptor_request_invite_chat(handle, req_id, g_chatroom_id, inviting_members, inviting_members_len, my_reply_invite_chat_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+       sleep(3);
+
+       /* end chat */
+       gettimeofday(&tv, NULL);
+       req_id = (long long int) tv.tv_usec;
+       service_adaptor_end_chat_s **end_chats = (service_adaptor_end_chat_s **) g_malloc0(sizeof(service_adaptor_end_chat_s *) * 1);
+       end_chats[0] = (service_adaptor_end_chat_s *) g_malloc0(sizeof(service_adaptor_end_chat_s));
+       end_chats[0]->chatroom_id = g_chatroom_id;
+       unsigned int end_chats_len = 1;
+       printf("service_adaptor_message: end_chat\n");
+       ret = service_adaptor_request_end_chat(handle, req_id, end_chats, end_chats_len, my_reply_end_chat_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+       /* need to free the memory space of end_chats */
+       sleep(3);
+
+       /* current time */
+       gettimeofday(&tv, NULL);
+       req_id = (long long int) tv.tv_usec;
+       printf("service_adaptor_message: current_time\n");
+       ret = service_adaptor_request_current_time(handle, req_id, my_reply_current_time_cb, &error_code, NULL);
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+       sleep(3);
+
+       /* unregister listener function */
+       printf("service_adaptor_message: unregister listener\n");
+       ret = service_adaptor_unregister_forward_online_message_listener(handle, NULL);
+       ret = service_adaptor_unregister_forward_unread_message_listener(handle, NULL);
+
+       /* disconnect push */
+       service_adaptor_disconnect_push_service(handle);
+
+       return ret;
+}
+
+/* message_api_send_test */
+service_adaptor_result_e message_api_send_test(service_adaptor_h handle)
+{
+       service_adaptor_result_e ret = SERVICE_ADAPTOR_RESULT_SUCCEEDED;
+       service_adaptor_error_s *error_code = NULL;
+       unsigned int service_id = 1;
+       printf("service_adaptor_message\n");
+
+       /* auth (input your app_id and app_secret, 5th param - contact: 0, message: 1, shop: 2, storage: 3) */
+       ret = service_adaptor_auth_set_service_info(handle, "az51t5bhq6", service_id);
+       ret = service_adaptor_auth_start_service(handle, "com.serviceadaptor.message2", "7F879A9FD481520514AC3DDE0D6DF097", "UNUSE_PASSWORD", &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+               return ret;
+       }
+
+       /* connect push */
+       ret = service_adaptor_connect_push_service(handle, my_push_notification_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       /* register listener function called by message server */
+       printf("service_adaptor_message: register listener\n");
+       ret = service_adaptor_register_forward_online_message_listener(handle, my_request_forward_online_message_cb, NULL);
+       ret = service_adaptor_register_forward_unread_message_listener(handle, my_request_forward_unread_message_cb, NULL);
+
+       /* create chatroom */
+       struct timeval tv;
+       long long int req_id;
+       long long int receivers[1];
+       int room_chat_type = 0;
+       unsigned int receivers_len = 1;
+       gettimeofday(&tv, NULL);
+       req_id = (long long int) tv.tv_usec;
+       receivers[0] = 13956279163683992;
+       printf("service_adaptor_message: create_chatroom (%lld)\n", req_id);
+       ret = service_adaptor_request_create_chatroom(handle, req_id, room_chat_type, receivers, receivers_len, my_reply_create_chatroom_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+       sleep(3);
+
+       /* request chat */
+       unsigned int chat_msgs_len = 1;
+       gettimeofday(&tv, NULL);
+       req_id = (long long int) tv.tv_usec;
+       service_adaptor_chat_msg_s **chat_msgs = (service_adaptor_chat_msg_s **) g_malloc0(sizeof(service_adaptor_chat_msg_s *) * 1);
+       chat_msgs[0] = (service_adaptor_chat_msg_s *) g_malloc0(sizeof(service_adaptor_chat_msg_s));
+       gettimeofday(&tv, NULL);
+       chat_msgs[0]->msg_id = (long long int) tv.tv_usec;
+       chat_msgs[0]->msg_type = 0;     /* TEXT */
+       chat_msgs[0]->chatmsg = strdup("Hello world");
+       printf("service_adaptor_message: chat (%lld)\n", req_id);
+       ret = service_adaptor_request_chat(handle, req_id, g_chatroom_id, chat_msgs, chat_msgs_len, my_reply_chat_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+       /* need to free the memory space of chat_msgs */
+       sleep(20);
+
+       /* end chat */
+       gettimeofday(&tv, NULL);
+       req_id = (long long int) tv.tv_usec;
+       service_adaptor_end_chat_s **end_chats = (service_adaptor_end_chat_s **) g_malloc0(sizeof(service_adaptor_end_chat_s *) * 1);
+       end_chats[0] = (service_adaptor_end_chat_s *) g_malloc0(sizeof(service_adaptor_end_chat_s));
+       end_chats[0]->chatroom_id = g_chatroom_id;
+       unsigned int end_chats_len = 1;
+       printf("service_adaptor_message: end_chat\n");
+       ret = service_adaptor_request_end_chat(handle, req_id, end_chats, end_chats_len, my_reply_end_chat_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+       /* need to free the memory space of end_chats */
+       sleep(3);
+
+       /* unregister listener function */
+       printf("service_adaptor_message: unregister listener\n");
+       ret = service_adaptor_unregister_forward_online_message_listener(handle, NULL);
+       ret = service_adaptor_unregister_forward_unread_message_listener(handle, NULL);
+
+       /* disconnect push */
+       service_adaptor_disconnect_push_service(handle);
+
+       return ret;
+}
+
+/* message_api_receive_test */
+service_adaptor_result_e message_api_receive_test(service_adaptor_h handle)
+{
+       service_adaptor_result_e ret = SERVICE_ADAPTOR_RESULT_SUCCEEDED;
+       service_adaptor_error_s *error_code = NULL;
+       unsigned int service_id = 1;
+       printf("service_adaptor_message\n");
+
+       /* auth (input your app_id and app_secret, 5th param - contact: 0, message: 1, shop: 2, storage: 3) */
+       ret = service_adaptor_auth_set_service_info(handle, "az51t5bhq6", service_id);
+       ret = service_adaptor_auth_start_service(handle, "com.serviceadaptor.message3", "7F879A9FD481520514AC3DDE0D6DF097", "UNUSE_PASSWORD", &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+               return ret;
+       }
+
+       /* connect push */
+       ret = service_adaptor_connect_push_service(handle, my_push_notification_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       /* register listener function called by message server */
+       printf("service_adaptor_message: register listener\n");
+       ret = service_adaptor_register_forward_online_message_listener(handle, my_request_forward_online_message_cb, NULL);
+       ret = service_adaptor_register_forward_unread_message_listener(handle, my_request_forward_unread_message_cb, NULL);
+
+       /* assign chatroom_id known by send_test */
+       g_chatroom_id = 13961141538521088;
+
+       /* allow chat */
+       struct timeval tv;
+       long long int req_id;
+       gettimeofday(&tv, NULL);
+       req_id = (long long int) tv.tv_usec;
+       printf("service_adaptor_message: allow_chat (%lld)\n", req_id);
+       ret = service_adaptor_request_allow_chat(handle, req_id, g_chatroom_id, 500, false, 0, false, 0, false, my_reply_allow_chat_cb, &error_code, NULL);
+
+       int m_max_count = 500;
+       bool is_need_delivery_ack = false;
+       long long int m_delivery_ack_timestamp = 0;
+       bool is_need_watemark = false;
+       long m_last_water_timestamp = 0;
+       bool is_need_ordered_chat_member_list = false;
+       ret = service_adaptor_request_allow_chat(handle,
+                       req_id, g_chatroom_id, m_max_count, is_need_delivery_ack, m_delivery_ack_timestamp,
+                       is_need_watemark, m_last_water_timestamp, is_need_ordered_chat_member_list,
+                       my_reply_allow_chat_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+       sleep(3);
+
+
+       /* request chat */
+       unsigned int chat_msgs_len = 1;
+       gettimeofday(&tv, NULL);
+       req_id = (long long int) tv.tv_usec;
+       service_adaptor_chat_msg_s **chat_msgs = (service_adaptor_chat_msg_s **) g_malloc0(sizeof(service_adaptor_chat_msg_s *) * 1);
+       chat_msgs[0] = (service_adaptor_chat_msg_s *) g_malloc0(sizeof(service_adaptor_chat_msg_s));
+       gettimeofday(&tv, NULL);
+       chat_msgs[0]->msg_id = (long long int) tv.tv_usec;
+       chat_msgs[0]->msg_type = 0;     /* TEXT */
+       chat_msgs[0]->chatmsg = strdup("Hello world");
+       printf("service_adaptor_message: chat (%lld)\n", req_id);
+       ret = service_adaptor_request_chat(handle, req_id, g_chatroom_id, chat_msgs, chat_msgs_len, my_reply_chat_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+       /* need to free the memory space of chat_msgs */
+       sleep(3);
+
+       /* end chat */
+       gettimeofday(&tv, NULL);
+       req_id = (long long int) tv.tv_usec;
+       service_adaptor_end_chat_s **end_chats = (service_adaptor_end_chat_s **) g_malloc0(sizeof(service_adaptor_end_chat_s *) * 1);
+       end_chats[0] = (service_adaptor_end_chat_s *) g_malloc0(sizeof(service_adaptor_end_chat_s));
+       end_chats[0]->chatroom_id = g_chatroom_id;
+       unsigned int end_chats_len = 1;
+       printf("service_adaptor_message: end_chat\n");
+       ret = service_adaptor_request_end_chat(handle, req_id, end_chats, end_chats_len, my_reply_end_chat_cb, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+       /* need to free the memory space of end_chats */
+       sleep(3);
+
+       /* unregister listener function */
+       printf("service_adaptor_message: unregister listener\n");
+       ret = service_adaptor_unregister_forward_online_message_listener(handle, NULL);
+       ret = service_adaptor_unregister_forward_unread_message_listener(handle, NULL);
+
+       /* disconnect push */
+       service_adaptor_disconnect_push_service(handle);
+
+       return ret;
+}
+
+/* storage_api_test */
+service_adaptor_result_e storage_api_test(service_adaptor_h handle)
+{
+       service_adaptor_result_e ret = SERVICE_ADAPTOR_RESULT_SUCCEEDED;
+       service_adaptor_error_s *error_code = NULL;
+       printf("service_adaptor_storage\n");
+
+       /* register listener function called by service adaptor */
+       printf("service_adaptor_storage: register listener\n");
+       ret = service_adaptor_register_file_progress_listener(handle, my_file_progress_cb, NULL);
+       ret = service_adaptor_register_file_transfer_completion_listener(handle, my_file_transfer_completion_cb, NULL);
+
+       /* upload a file directly */
+       char *upload_path = "/opt/usr/share/media/.thumb/thumb_default.png";
+       char *server_path = "/test/thumb_default.png";
+       char *server_path_async = "/test/thumb_default2.png";
+       service_adaptor_file_h up_file_handle = NULL;
+       service_adaptor_storage_file_info_h file_info = NULL;
+       printf("service_adaptor_storage: upload\n");
+       ret = service_adaptor_storage_upload_file(handle, upload_path, server_path, &file_info, &error_code, NULL);
+       service_adaptor_storage_unref_file_info(&file_info);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       printf("service_adaptor_storage: upload async\n");
+       ret = service_adaptor_storage_upload_file_async(handle, upload_path, server_path_async, &up_file_handle, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               printf("fd: (%d)\n", up_file_handle->file_description);
+       }
+       sleep(3);
+
+       free(up_file_handle);
+       up_file_handle = NULL;
+
+       /* download a file directly */
+       char *download_path = "/opt/usr/media/Images/thumb_default.png";
+       char *download_path_async = "/opt/usr/media/Images/thumb_default_async.png";
+       service_adaptor_file_h dn_file_handle = NULL;
+       printf("service_adaptor_storage: download\n");
+       ret = service_adaptor_storage_download_file(handle, server_path, download_path, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       printf("service_adaptor_storage: download async\n");
+       ret = service_adaptor_storage_download_file_async(handle, server_path_async, download_path_async, &dn_file_handle, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               printf("fd: (%d)\n", dn_file_handle->file_description);
+       }
+
+       /* file status (pause, get, resume, cancel) */
+       if (NULL != dn_file_handle) {
+               service_adaptor_file_status_s *status = NULL;
+               printf("service_adaptor_storage: pause\n");
+               ret = service_adaptor_storage_pause_file_transfer(handle, dn_file_handle, &error_code, NULL);
+
+               if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                       printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               }
+
+               printf("service_adaptor_storage: file status\n");
+               ret = service_adaptor_storage_get_file_status(handle, dn_file_handle, &status, &error_code, NULL);
+
+               if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                       printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       printf("total: (%lld), transfer: (%lld), status: (%d)\n", status->total_size, status->transferred_size, status->status);
+               }
+
+               free(status);
+               status = NULL;
+
+               printf("service_adaptor_storage: resume\n");
+               ret = service_adaptor_storage_resume_file_transfer(handle, dn_file_handle, &error_code, NULL);
+
+               if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                       printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               }
+
+               printf("service_adaptor_storage: cancel\n");
+               ret = service_adaptor_storage_cancel_file_transfer(handle, dn_file_handle, &error_code, NULL);
+
+               if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                       printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               }
+
+               free(dn_file_handle);
+               dn_file_handle = NULL;
+       }
+
+       /* upload a file using publish url */
+       char *publish_upload_path = "/opt/usr/share/media/.thumb/thumb_default.png";
+       char *publish_server_path = "/publish/thumb_default.png";
+       char *publish_server_path_async = "/publish/thumb_default2.png";
+       char *publish_url = NULL;
+       service_adaptor_file_h publish_up_file_handle = NULL;
+       printf("service_adaptor_storage: upload publish\n");
+       ret = service_adaptor_storage_upload_file_publish(handle, publish_upload_path, publish_server_path, &publish_url, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       }
+
+       printf("service_adaptor_storage: upload publish async\n");
+       ret = service_adaptor_storage_upload_file_publish_async(handle, publish_upload_path, publish_server_path_async, &publish_up_file_handle, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               printf("fd: (%d)\n", publish_up_file_handle->file_description);
+       }
+       sleep(3);
+
+       free(publish_up_file_handle);
+       publish_up_file_handle = NULL;
+
+       /* download a file using publish url */
+       if (NULL != publish_url) {
+               printf("service_adaptor_storage: download publish\n");
+               char *publish_download_path = "/opt/usr/media/Images/thumb_default_publish.png";
+               char *publish_download_thumb_path = "/opt/usr/media/Images/thumb_default_publish_thumb.png";
+               char *publish_download_path_async = "/opt/usr/media/Images/thumb_default_publish_async.png";
+               service_adaptor_file_h publish_dn_file_handle = NULL;
+               ret = service_adaptor_storage_download_file_publish(handle, publish_url, publish_download_path, &error_code, NULL);
+
+               if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                       printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               }
+
+               printf("service_adaptor_storage: download thumbnail\n");
+               ret = service_adaptor_storage_download_thumbnail_publish(handle, publish_url, publish_download_thumb_path, STORAGE_ADAPTOR_THUMBNAIL_SMALL, &error_code, NULL);
+
+               if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                       printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               }
+
+               printf("service_adaptor_storage: download publish async\n");
+               ret = service_adaptor_storage_download_file_publish_async(handle, publish_url, publish_download_path_async, &publish_dn_file_handle, &error_code, NULL);
+
+               if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                       printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       printf("fd: (%d)\n", publish_dn_file_handle->file_description);
+               }
+
+               /* file status (pause, get, resume, cancel) */
+               if (NULL != publish_dn_file_handle) {
+                       service_adaptor_file_status_s *status = NULL;
+                       printf("service_adaptor_storage: pause\n");
+                       ret = service_adaptor_storage_pause_file_transfer(handle, publish_dn_file_handle, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+                               free(error_code->msg);
+                               free(error_code);
+                               error_code = NULL;
+                       }
+
+                       printf("service_adaptor_storage: file status\n");
+                       ret = service_adaptor_storage_get_file_status(handle, publish_dn_file_handle, &status, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+                               free(error_code->msg);
+                               free(error_code);
+                               error_code = NULL;
+                       } else {
+                               printf("total: (%lld), transfer: (%lld), status: (%d)\n", status->total_size, status->transferred_size, status->status);
+                       }
+
+                       free(status);
+                       status = NULL;
+
+                       printf("service_adaptor_storage: resume\n");
+                       ret = service_adaptor_storage_resume_file_transfer(handle, publish_dn_file_handle, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+                               free(error_code->msg);
+                               free(error_code);
+                               error_code = NULL;
+                       }
+
+                       printf("service_adaptor_storage: cancel\n");
+                       ret = service_adaptor_storage_cancel_file_transfer(handle, publish_dn_file_handle, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+                               free(error_code->msg);
+                               free(error_code);
+                               error_code = NULL;
+                       }
+
+                       free(publish_dn_file_handle);
+                       publish_dn_file_handle = NULL;
+               }
+
+               free(publish_url);
+               publish_url = NULL;
+       }
+
+       /* unregister listener function */
+       printf("service_adaptor_storage: unregister listener\n");
+       ret = service_adaptor_unregister_file_progress_listener(handle, NULL);
+       ret = service_adaptor_unregister_file_transfer_completion_listener(handle, NULL);
+
+       return ret;
+}
+
+/* shop_api_test */
+service_adaptor_result_e shop_api_test(service_adaptor_h handle)
+{
+       service_adaptor_result_e ret = SERVICE_ADAPTOR_RESULT_SUCCEEDED;
+       service_adaptor_error_s *error_code = NULL;
+       unsigned int service_id = 2;
+       printf("service_adaptor_shop\n");
+
+       /* auth (input your app_id and app_secret, 5th param - contact: 0, message: 1, shop: 2, storage: 3) */
+       ret = service_adaptor_auth_set_service_info(handle, "bgjvf8u6zi", service_id);
+       ret = service_adaptor_auth_start_service(handle, "com.serviceadaptor.shop1", "C95EEC78ABB2CEE5514391B0B11BFD9C", "UNUSE_PASSWORD", &error_code, NULL);
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+               return ret;
+       }
+
+       /* shop item list */
+       service_adaptor_shop_info_s *info = (service_adaptor_shop_info_s *) g_malloc0(sizeof(service_adaptor_shop_info_s));
+       info->category_id = 1;
+       info->item_id = 101;
+       info->sticker_id = 201;
+       info->lang_cd = strdup("ko");
+       info->cntry_cd = strdup("kr");
+       info->rwidth = 640;
+       info->rheight = 480;
+       info->start_idx = 0;
+       info->count = 5;
+       service_adaptor_shop_item_s **items = NULL;
+       unsigned int items_len = 0;
+       printf("service_adaptor_shop: item list\n");
+       ret = service_adaptor_get_item_list(handle, info, NULL, &items, &items_len, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               for (int i = 0; i < items_len; i++) {
+                       printf("title: (%s)\n", items[i]->title);
+               }
+       }
+
+       /* need to free the memory space of items */
+
+       /* get download url of item package */
+       service_adaptor_shop_item_s *item = NULL;
+       printf("service_adaptor_shop: download item package\n");
+       ret = service_adaptor_download_item_package(handle, info, NULL, &item, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               printf("download_url: (%s)\n", item->download_url);
+       }
+
+       /* need to free the memory space of item */
+
+       /* get download url of sticker */
+       item = NULL;
+       printf("service_adaptor_shop: download sticker\n");
+       ret = service_adaptor_download_sticker(handle, info, NULL, &item, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               printf("sticker_url: (%s)\n", item->sticker_url);
+       }
+
+       /* need to free the memory space of item */
+
+       /* get panel url */
+       item = NULL;
+       printf("service_adaptor_shop: get panel url\n");
+       ret = service_adaptor_get_panel_url(handle, info, NULL, &item, &error_code, NULL);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+       } else {
+               printf("panel_url: (%s)\n", item->panel_url);
+       }
+
+       /* need to free the memory space of info */
+       /* need to free the memory space of item */
+
+       return ret;
+}
+
+/* api_test */
+void api_test(service_adaptor_h handle)
+{
+       service_adaptor_result_e ret = SERVICE_ADAPTOR_RESULT_SUCCEEDED;
+       service_adaptor_plugin_h *plugins = NULL;
+       unsigned int plugins_len = 0;
+       service_adaptor_error_s *error_code = NULL;
+
+       printf("START\n");
+
+       /* Common */
+       /* 1. set imsi of SIM0 or SIM1 */
+       char **imsi = _get_imsi();
+       printf("set imsi\n");
+       if (NULL == imsi) {
+               printf("No inserted sim");
+               printf("insert temp value (\"TESTSIMNUM\"))");
+               imsi = (char **) malloc(sizeof(char *)*2);
+               imsi[0] = strdup("TESTSIMNUM");
+               imsi[1] = strdup("TESTSIMNUM2");
+       }
+       service_adaptor_auth_set_device_info(handle, imsi[0]);
+
+       /* 2. get the list of auth plugin */
+       printf("get plugins\n");
+       ret = service_adaptor_auth_get_plugins(handle, &plugins, &plugins_len, &error_code);
+
+       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+               printf("FAILED (%lld): %s\n", error_code->code, error_code->msg);
+               free(error_code->msg);
+               free(error_code);
+               error_code = NULL;
+               g_handle = NULL;
+               return;
+       }
+
+       printf("find plugin : count(%d)\n", plugins_len);
+       for (int i = 0; i < plugins_len; i++) {
+/*             printf("plugin: %s, %d\n", plugins[i]->name, plugins[i]->login); */
+
+               /* 3. set a auth plugin which you wish to use */
+               /* you already know the name of auth plugin (Contact: "CONTACT", Message: "MESSAGE") */
+               char *p_name = NULL;
+               bool p_is_login = false;
+               service_adaptor_get_plugin_info(plugins[i], &p_name, &p_is_login);
+               printf("name : %s, login (%d)\n", p_name, p_is_login ? 1 : 0);
+               if ((0 == strncmp(p_name, "CONTACT", 7)) && (true == p_is_login)) {
+                       service_adaptor_auth_assign_plugin(handle, plugins[i]);
+#ifdef __CONTACT_TEST__
+                       /* Contact */
+                       ret = contact_api_test(handle);
+
+                       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                               printf("Failed Contact API\n");
+                       }
+#endif
+#ifdef __CONTACT_PUSH_SET_TEST__
+                       /* Contact Push */
+                       ret = contact_api_push_set_test(handle);
+
+                       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                               printf("Failed Contact API\n");
+                       }
+#endif
+#ifdef __CONTACT_PUSH_GET_TEST__
+                       /* Contact Push */
+                       ret = contact_api_push_get_test(handle);
+
+                       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                               printf("Failed Contact API\n");
+                       }
+#endif
+#ifdef __CONTACT_SIM2_TEST__
+                       service_adaptor_auth_set_device_info(handle, imsi[1]);
+
+                       /* Message */
+                       ret = contact_api_test(handle);
+
+                       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                               printf("Failed Message API\n");
+                       }
+#endif
+               } else if ((0 == strncmp(p_name, "MESSAGE", 7)) && (true == p_is_login)) {
+                       service_adaptor_auth_assign_plugin(handle, plugins[i]);
+#ifdef __MESSAGE_TEST__
+                       /* Message */
+                       ret = message_api_test(handle);
+
+                       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                               printf("Failed Message API\n");
+                       }
+#endif
+#ifdef __MESSAGE_SEND_TEST__
+                       /* Message Send */
+                       ret = message_api_send_test(handle);
+
+                       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                               printf("Failed Message API\n");
+                       }
+#endif
+#ifdef __MESSAGE_RECEIVE_TEST__
+                       /* Message Receive */
+                       ret = message_api_receive_test(handle);
+
+                       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                               printf("Failed Message API\n");
+                       }
+#endif
+#ifdef __MESSAGE_STORAGE_TEST__
+                       /* Storage */
+                       ret = storage_api_test(handle);
+
+                       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                               printf("Failed Storage API\n");
+                       }
+#endif
+#ifdef __MESSAGE_SIM2_TEST__
+                       service_adaptor_auth_set_device_info(handle, imsi[1]);
+
+                       /* Message */
+                       ret = message_api_test(handle);
+
+                       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                               printf("Failed Message API\n");
+                       }
+#endif
+               } else if ((0 == strncmp(p_name, "SHOP", 4)) && (true == p_is_login)) {
+                       service_adaptor_auth_assign_plugin(handle, plugins[i]);
+#ifdef __SHOP_TEST__
+                       /* Shop */
+                       ret = shop_api_test(handle);
+
+                       if (SERVICE_ADAPTOR_RESULT_SUCCEEDED != ret) {
+                               printf("Failed Shop API\n");
+                       }
+#endif
+               }
+               free(p_name);
+               p_name = NULL;
+               p_is_login = false;
+
+       }
+
+       service_adaptor_unref_plugins(plugins, plugins_len);
+
+       g_free(imsi[0]);
+       g_free(imsi[1]);
+
+       printf("END\n");
+}
+
+static gint sigterm_callback(void *data)
+{
+       /* disconnect push */
+       service_adaptor_disconnect(g_handle);
+
+       g_main_loop_quit((GMainLoop *)data);
+       return FALSE;
+}
+
+int main()
+{
+       GMainLoop *loop;
+       service_adaptor_h handle = NULL;
+#if !GLIB_CHECK_VERSION(2, 32, 0)
+       g_thread_init(NULL);
+#endif
+#if !GLIB_CHECK_VERSION(2, 35, 0)
+       g_type_init();
+#endif
+
+       /* 1. get client handle of service adaptor and register signal callback */
+       service_adaptor_result_e ret = SERVICE_ADAPTOR_RESULT_SUCCEEDED;
+       ret = service_adaptor_connect(&handle, my_signal_cb);
+
+       if (ret != SERVICE_ADAPTOR_RESULT_SUCCEEDED) {
+               printf("Could NOT connect to service adaptor\n");
+               return 0;
+       }
+
+       g_handle = handle;
+
+       api_test(handle);
+
+       /* mainloop of main thread */
+       loop = g_main_loop_new(NULL, FALSE);
+
+       /* installing signal handlers */
+       g_unix_signal_add_full(G_PRIORITY_HIGH, SIGINT,
+                       sigterm_callback, loop, NULL);
+       g_unix_signal_add_full(G_PRIORITY_HIGH, SIGTERM,
+                       sigterm_callback, loop, NULL);
+
+       /* start application's main loop */
+       g_main_loop_run(loop);
+
+       /* cleanup after mainloop */
+       g_main_loop_unref(loop);
+
+       return 0;
+}