tizen 2.4 release accepted/tizen_2.4_mobile accepted/tizen/2.4/mobile/20151029.033229 submit/tizen_2.4/20151028.064132 tizen_2.4_mobile_release
authorjk7744.park <jk7744.park@samsung.com>
Mon, 26 Oct 2015 06:44:33 +0000 (15:44 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Mon, 26 Oct 2015 06:44:33 +0000 (15:44 +0900)
52 files changed:
CMakeLists.txt [new file with mode: 0644]
LICENSE.Apache-2.0 [new file with mode: 0644]
NOTICE [new file with mode: 0644]
inc/dbus/dbus-auth-adaptor.h [new file with mode: 0644]
inc/dbus/dbus-contact-adaptor.h [new file with mode: 0644]
inc/dbus/dbus-ipc.h [new file with mode: 0644]
inc/dbus/dbus-message-adaptor.h [new file with mode: 0644]
inc/dbus/dbus-push-adaptor.h [new file with mode: 0644]
inc/dbus/dbus-server-type.h [new file with mode: 0644]
inc/dbus/dbus-server.h [new file with mode: 0644]
inc/dbus/dbus-service-adaptor.h [new file with mode: 0644]
inc/dbus/dbus-shop-adaptor.h [new file with mode: 0644]
inc/dbus/dbus-storage-adaptor.h [new file with mode: 0644]
inc/dbus/dbus-util.h [new file with mode: 0644]
inc/service-adaptor-auth.h [new file with mode: 0644]
inc/service-adaptor-contact.h [new file with mode: 0644]
inc/service-adaptor-log.h [new file with mode: 0644]
inc/service-adaptor-message.h [new file with mode: 0644]
inc/service-adaptor-plugin.h [new file with mode: 0644]
inc/service-adaptor-push.h [new file with mode: 0644]
inc/service-adaptor-shop.h [new file with mode: 0644]
inc/service-adaptor-storage.h [new file with mode: 0644]
inc/service-adaptor-type.h [new file with mode: 0644]
inc/service-adaptor.h [new file with mode: 0644]
inc/util/client_checker.h [new file with mode: 0644]
inc/util/service_file_manager.h [new file with mode: 0644]
org.tizen.serviceadaptor.client.service.in [new file with mode: 0644]
packaging/org.tizen.serviceadaptor.client.conf [new file with mode: 0644]
packaging/service-adaptor.service [new file with mode: 0644]
packaging/service-adaptor.spec [new file with mode: 0644]
service-adaptor.manifest.in [new file with mode: 0644]
service-adaptor.pc.in [new file with mode: 0644]
src/dbus/dbus-auth-adaptor.c [new file with mode: 0644]
src/dbus/dbus-contact-adaptor.c [new file with mode: 0644]
src/dbus/dbus-ipc.c [new file with mode: 0644]
src/dbus/dbus-message-adaptor.c [new file with mode: 0644]
src/dbus/dbus-push-adaptor.c [new file with mode: 0644]
src/dbus/dbus-server.c [new file with mode: 0644]
src/dbus/dbus-service-adaptor.c [new file with mode: 0644]
src/dbus/dbus-shop-adaptor.c [new file with mode: 0644]
src/dbus/dbus-storage-adaptor.c [new file with mode: 0644]
src/dbus/dbus-util.c [new file with mode: 0644]
src/service-adaptor-auth.c [new file with mode: 0644]
src/service-adaptor-contact.c [new file with mode: 0644]
src/service-adaptor-message.c [new file with mode: 0644]
src/service-adaptor-plugin.c [new file with mode: 0644]
src/service-adaptor-push.c [new file with mode: 0644]
src/service-adaptor-shop.c [new file with mode: 0644]
src/service-adaptor-storage.c [new file with mode: 0644]
src/service-adaptor.c [new file with mode: 0644]
src/util/client_checker.c [new file with mode: 0644]
src/util/service_file_manager.c [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3ea1a22
--- /dev/null
@@ -0,0 +1,93 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(service-adaptor C)
+
+SET(VENDOR      "tizen")
+SET(PKGPREFIX   "org.${VENDOR}")
+SET(PACKAGE     ${PROJECT_NAME})
+SET(PKGNAME     "${PKGPREFIX}.${PACKAGE}")
+SET(PREFIX      ${CMAKE_INSTALL_PREFIX})
+SET(BINDIR      "${PREFIX}/bin")
+SET(LIBDIR     "${PREFIX}/lib")
+SET(DATADIR    "/usr/share")
+SET(INCLUDEDIR "/usr/include")
+SET(SVC_FILE_SRC ${CMAKE_SVC_FILE_SRC})
+SET(SVC_FILE_TGT ${CMAKE_SVC_FILE_TGT})
+
+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}")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc/dbus)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/inc/util)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+       glib-2.0
+       gobject-2.0
+       gio-2.0
+       gthread-2.0
+       dlog
+       capi-appfw-application
+       auth-adaptor
+       push-adaptor
+       contact-adaptor
+       storage-adaptor
+       message-adaptor
+       shop-adaptor
+       capi-base-common
+       capi-appfw-app-manager
+        capi-appfw-package-manager
+       libsmack
+       security-server
+       bundle
+
+       plugin-config
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE -Wall -Werror -std=gnu99 -D_GNU_SOURCE")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -fPIE")
+SET(CMAKE_C_FLAGS_RELEASE "-O2 -fPIE")
+
+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}\"")
+#ADD_DEFINITIONS("-DSERVICE_ADAPTOR_DEBUG_TIME_CHECK")
+ADD_DEFINITIONS("-DSERVICE_ADAPTOR_DEBUG_CONTEXT")
+
+ADD_EXECUTABLE(${EXECUTABLE_NAME} ${SRCS})
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+TARGET_LINK_LIBRARIES(${EXECUTABLE_NAME} ${pkgs_LDFLAGS} "-lm -ldl -lrt")
+
+INSTALL(TARGETS ${EXECUTABLE_NAME} DESTINATION ${BINDIR})
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/packaging/${SVC_FILE_SRC} ${CMAKE_SOURCE_DIR}/packaging/${SVC_FILE_TGT} @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/packaging/${SVC_FILE_TGT} DESTINATION /usr/lib/systemd/system/)
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/org.tizen.serviceadaptor.client.service.in ${CMAKE_SOURCE_DIR}/org.tizen.serviceadaptor.client.service @ONLY)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/org.tizen.serviceadaptor.client.service DESTINATION ${DATADIR}/dbus-1/system-services)
+
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/inc/service-adaptor.h DESTINATION /usr/include/service-adaptor/)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/inc/dbus/dbus-server.h DESTINATION /usr/include/service-adaptor/)
+
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/service-adaptor.pc.in ${CMAKE_SOURCE_DIR}/service-adaptor.pc @ONLY)
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/service-adaptor.pc DESTINATION /usr/lib/pkgconfig)
+
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/service-adaptor.manifest.in ${CMAKE_SOURCE_DIR}/service-adaptor.manifest @ONLY)
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/inc/dbus/dbus-auth-adaptor.h b/inc/dbus/dbus-auth-adaptor.h
new file mode 100644 (file)
index 0000000..d2fc9ec
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+* 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 __DBUS_AUTH_ADAPTOR_H__
+#define __DBUS_AUTH_ADAPTOR_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+
+void auth_adaptor_method_call(GDBusConnection *connection,
+                                               const gchar *sender,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *method_name,
+                                               GVariant *parameters,
+                                               GDBusMethodInvocation *invocation,
+                                               gpointer user_data);
+
+void auth_external_method_call(const char *service_name,
+                                               const char *api_uri,
+                                               const unsigned char *req_data,
+                                               int req_len,
+                                               unsigned char **res_data,
+                                               int *res_len,
+                                               int *ret_code,
+                                               char *ret_msg);
+
+#endif /* __DBUS_AUTH_ADAPTOR_H__ */
diff --git a/inc/dbus/dbus-contact-adaptor.h b/inc/dbus/dbus-contact-adaptor.h
new file mode 100644 (file)
index 0000000..9a8160a
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+* 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 __DBUS_CONTACT_ADAPTOR_H__
+#define __DBUS_CONTACT_ADAPTOR_H__
+
+void contact_adaptor_method_call(GDBusConnection *connection,
+                                               const gchar *sender,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *method_name,
+                                               GVariant *parameters,
+                                               GDBusMethodInvocation *invocation,
+                                               gpointer user_data);
+
+#endif /* __DBUS_CONTACT_ADAPTOR_H__ */
diff --git a/inc/dbus/dbus-ipc.h b/inc/dbus/dbus-ipc.h
new file mode 100644 (file)
index 0000000..b4d4c40
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+* 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 __DBUS_IPC_H__
+#define __DBUS_IPC_H__
+
+/**
+ * @brief Initialise D-Bus IPC server layer.
+ *
+ * Initialise D-Bus IPC server layer. Must be called once at startup to provide D-Bus interface for clients.
+ * is made.
+ * @return 0 on success, -1 on error.
+ */
+int dbus_ipc_server_layer_init();
+
+/**
+ * @brief Deinitialise D-Bus IPC server layer.
+ *
+ * Deinitialise D-Bus IPC server layer. Should be run once at shutdown.
+ */
+void dbus_ipc_server_layer_deinit();
+
+#endif /* __DBUS_IPC_H__ */
+// EOF
diff --git a/inc/dbus/dbus-message-adaptor.h b/inc/dbus/dbus-message-adaptor.h
new file mode 100644 (file)
index 0000000..694fe24
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+* 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 __DBUS_MESSAGE_ADAPTOR_H__
+#define __DBUS_MESSAGE_ADAPTOR_H__
+
+void message_adaptor_method_call(GDBusConnection *connection,
+                                               const gchar *sender,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *method_name,
+                                               GVariant *parameters,
+                                               GDBusMethodInvocation *invocation,
+                                               gpointer user_data);
+
+service_adaptor_internal_error_code_e dbus_reply_create_chatroom_callback(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               int default_message_ttl,
+                                               message_adaptor_wrong_receiver_s *wrong_receiver,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data);
+
+service_adaptor_internal_error_code_e dbus_reply_change_chatroom_meta_callback(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data);
+
+service_adaptor_internal_error_code_e dbus_reply_chat_callback(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               message_adaptor_processed_msg_s **processed_msgs,
+                                               unsigned int processed_msgs_len,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data);
+
+service_adaptor_internal_error_code_e dbus_reply_allow_chat_callback(int64_t request_id,
+                                               long long int chatroom_id,
+                                               message_adaptor_delivery_ack_s **delivery_acks,
+                                               unsigned int delivery_acks_len,
+                                               unsigned long long last_delivery_acks_timestamp,
+                                               message_adaptor_read_ack_s **read_acks,
+                                               unsigned int read_acks_len,
+                                               unsigned long long last_read_acks_timestamp,
+                                               message_adaptor_ordered_chat_member_s **ordered_chat_members,
+                                               unsigned int ordered_chat_members_len,
+                                               const char *chatroom_title,
+                                               int default_message_ttl,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data);
+
+service_adaptor_internal_error_code_e dbus_reply_all_unread_message_callback(int64_t request_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data);
+
+service_adaptor_internal_error_code_e dbus_request_forward_online_message_callback(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               int chat_type,
+                                               message_adaptor_inbox_message_s *inbox_msg,
+                                               bool skip_reply,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data);
+
+service_adaptor_internal_error_code_e dbus_request_forward_unread_message_callback(int64_t request_id,
+                                               message_adaptor_inbox_message_s **inbox_msgs,
+                                               unsigned int inbox_msgs_len,
+                                               char *next_pagination_key,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data);
+
+service_adaptor_internal_error_code_e dbus_reply_read_message_callback(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data);
+
+service_adaptor_internal_error_code_e dbus_reply_invite_chat_callback(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               int64_t sent_time,
+                                               message_adaptor_wrong_receiver_s *wrong_receiver,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data);
+
+service_adaptor_internal_error_code_e dbus_reply_end_chat_callback(int64_t request_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data);
+
+service_adaptor_internal_error_code_e dbus_reply_unseal_message_callback(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data);
+
+service_adaptor_internal_error_code_e dbus_reply_save_call_log_callback(int64_t request_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data);
+
+service_adaptor_internal_error_code_e dbus_reply_current_time_callback(int64_t request_id,
+                                               int64_t current_time_millis,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data);
+
+service_adaptor_internal_error_code_e dbus_reply_message_channel_disconnected_callback(const char *service_name,
+                                               message_adaptor_error_code_t *error_code);
+
+#endif /* __DBUS_MESSAGE_ADAPTOR_H__ */
diff --git a/inc/dbus/dbus-push-adaptor.h b/inc/dbus/dbus-push-adaptor.h
new file mode 100644 (file)
index 0000000..9b1e849
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+* 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 __DBUS_PUSH_ADAPTOR_H__
+#define __DBUS_PUSH_ADAPTOR_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+
+void push_adaptor_method_call(GDBusConnection *connection,
+                                               const gchar *sender,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *method_name,
+                                               GVariant *parameters,
+                                               GDBusMethodInvocation *invocation,
+                                               gpointer user_data);
+
+void dbus_send_to_push_with_activation(int bus_type,
+                                                const char *bus_name,
+                                                const char *object_path,
+                                                const char *interface,
+                                                const char *method,
+                                                void **proxy,
+                                                long long int timestamp,
+                                                const char *data,
+                                                const char *message);
+
+#endif /* __DBUS_PUSH_ADAPTOR_H__ */
+
diff --git a/inc/dbus/dbus-server-type.h b/inc/dbus/dbus-server-type.h
new file mode 100644 (file)
index 0000000..bb62862
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+* 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 __DBUS_SERVER_TYPE_H__
+#define __DBUS_SERVER_TYPE_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+
+/**
+ * @brief Initialises D-Bus server.
+ *
+ * Initialises D-Bus server. Must by called on startup.
+ * @return 0 on success, -1 on error.
+ */
+int dbus_server_init();
+
+/**
+ * @brief Deinitialises D-Bus server.
+ *
+ * Deinitialises D-Bus server. Must by called on shutdown.
+ */
+void dbus_server_deinit();
+
+GDBusConnection *dbus_get_connection();
+
+#endif /* __DBUS_SERVER_TYPE_H__ */
diff --git a/inc/dbus/dbus-server.h b/inc/dbus/dbus-server.h
new file mode 100644 (file)
index 0000000..c80e5fb
--- /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.
+*/
+
+#ifndef __DBUS_SERVER_H__
+#define __DBUS_SERVER_H__
+
+/**
+ * Service Adaptor D-Bus server bus name.
+ */
+#define SERVICE_ADAPTOR_BUS_NAME "org.tizen.serviceadaptor.client"
+
+/**
+ * Service Adaptor D-Bus server object path.
+ */
+#define SERVICE_ADAPTOR_OBJECT_PATH "/org/tizen/serviceadaptor/client"
+
+/**
+ * Service Adaptor D-Bus interface.
+ */
+#define SERVICE_ADAPTOR_INTERFACE "org.tizen.serviceadaptor.client.interface"
+
+/**
+ * Service Adaptor Activation start key path
+ */
+#define SERVICE_ADAPTOR_START_KEY_PATH         "/opt/share/service-adaptor/.fingerprint"
+
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+///////////////////
+///////////////////               private feature
+///////////////////
+
+#define private_service_adaptor_essential_s_type_length 1
+#define private_service_adaptor_essential_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       ")"
+
+#define private_service_adaptor_external_req_s_type_length 4
+#define private_service_adaptor_external_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "i" /* int32 service_flag */ \
+       "s" /* char * api_uri */ \
+       service_adaptor_raw_data_s_type \
+       ")"
+
+#define private_service_adaptor_plugin_s_type_length 2
+#define private_service_adaptor_plugin_s_type \
+       "(" \
+       "s" /* char * name */ \
+       "b" /* bool login */ \
+       ")"
+
+#define private_service_adaptor_set_auth_s_type_length 8
+#define private_service_adaptor_set_auth_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "s" /* char * imsi */ \
+       "s" /* char * cluster_name */ \
+       "s" /* char * app_id */ \
+       "s" /* char * app_secret */ \
+       "s" /* char * user_id */ \
+       "s" /* char * user_password */ \
+       "u" /* uint32 service_id */ \
+       ")"
+
+#define private_service_adaptor_contact_info_req_s_type_length 5
+#define private_service_adaptor_contact_info_req_s_type \
+       "(" \
+       "s" /* char * tp  */ \
+       "s" /* char * id */ \
+       "s" /* char * pn */ \
+       "s" /* char * nm */ \
+       "s" /* char * cc */ \
+       ")"
+
+#define private_service_adaptor_contact_req_s_type_length 4
+#define private_service_adaptor_contact_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "x" /* int64 tt */ \
+       "a" private_service_adaptor_contact_info_req_s_type \
+       "u" /* uint32 cts_len */ \
+       ")"
+
+#define private_service_adaptor_contact_info_res_s_type_length 21
+#define private_service_adaptor_contact_info_res_s_type \
+       "(" \
+       "s" /* char * duid  */ \
+       "s" /* char * id */ \
+       "s" /* char * msisdn */ \
+       "s" /* char * ty */ \
+       "s" /* char * cc */ \
+       "s" /* char * pn */ \
+       "s" /* char * nm */ \
+       "a(s)" /* char ** evnt */ \
+       "u" /* uint32 evnt_len */ \
+       "a(is)" /* char * imgs */ \
+       "u" /* uint32 imgs_len */ \
+       "a(s)" /* char ** adrs */ \
+       "u" /* uint32 adrs_len */ \
+       "a(s)" /* char ** mail */ \
+       "u" /* uint32 mail_len */ \
+       "s" /* char * org */ \
+       "s" /* char * prsc */ \
+       "s" /* char * status */ \
+       "u" /* uint32 sids */ \
+       "i" /* int32_t profile_type */ \
+       "s" /* char * profile_url */ \
+       ")"
+
+#define private_service_adaptor_contact_res_s_type_length 3
+#define private_service_adaptor_contact_res_s_type \
+       "(" \
+       "x" /* int64 tt */ \
+       "a" private_service_adaptor_contact_info_res_s_type \
+       "u" /* uint32 cts_len */ \
+       ")"
+
+#define private_service_adaptor_profile_req_s_type_length 14
+#define private_service_adaptor_profile_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "s" /* char * cc */ \
+       "s" /* char * pn */ \
+       "s" /* char * nm */ \
+       "a(s)" /* char ** evnt */ \
+       "u" /* uint32 evnt_len */ \
+       "s" /* char * img */ \
+       "a(s)" /* char ** adrs */ \
+       "u" /* uint32 adrs_len */ \
+       "a(s)" /* char ** mail */ \
+       "u" /* uint32 mail_len */ \
+       "s" /* char * org */ \
+       "s" /* char * prsc */ \
+       "s" /* char * status */ \
+       ")"
+
+#define private_service_adaptor_profile_res_s_type_length 4
+#define private_service_adaptor_profile_res_s_type \
+       "(" \
+       "s" /* char * nm */ \
+       "s" /* char * img */ \
+       "s" /* char * prsc */ \
+       "s" /* char * status */ \
+       ")"
+
+#define private_service_adaptor_privacy_info_req_s_type_length 2
+#define private_service_adaptor_privacy_info_req_s_type \
+       "(" \
+       "s" /* char * cc */ \
+       "s" /* char * pn */ \
+       ")"
+
+#define private_service_adaptor_privacy_req_s_type_length 4
+#define private_service_adaptor_privacy_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "u" /* uint32 lvl */ \
+       "a" private_service_adaptor_privacy_info_req_s_type \
+       "u" /* uint32 cts_len */ \
+       ")"
+
+#define private_service_adaptor_privacy_res_s_type_length 2
+#define private_service_adaptor_privacy_res_s_type \
+       "(" \
+       "u" /* uint32 lvl */ \
+       "u" /* uint32 prscon */ \
+       ")"
+
+#define private_service_adaptor_presence_req_s_type_length 4
+#define private_service_adaptor_presence_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "s" /* char * prsc */ \
+       "s" /* char * status */ \
+       "u" /* uint32 prscon */ \
+       ")"
+
+#define private_service_adaptor_contact_profile_image_req_s_type_length 3
+#define private_service_adaptor_contact_profile_image_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "a(iis)" /* images array */ \
+       "u" /* uint32 images length */ \
+       ")"
+
+#define private_service_adaptor_set_me_profile_type_req_s_type_length 2
+#define private_service_adaptor_set_me_profile_type_req_s_type \
+       "(" \
+       "s" /* */ \
+       "i" /* */ \
+       ")"
+
+
+#define private_service_adaptor_file_path_req_s_type_length 3
+#define private_service_adaptor_file_path_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "a(s)" /* char ** file_paths */ \
+       "u" /* uint32 file_paths_len */ \
+       ")"
+
+#define private_service_adaptor_file_path_res_s_type_length 2
+#define private_service_adaptor_file_path_res_s_type \
+       "(" \
+       "a(s)" /* char ** file_paths */ \
+       "u" /* uint32 file_paths_len */ \
+       ")"
+
+#define private_service_adaptor_file_s_type_length 1
+#define private_service_adaptor_file_s_type \
+       "(" \
+       "i" /* int32 file_description */ \
+       ")"
+
+#define private_service_adaptor_file_publish_s_type_length 1
+#define private_service_adaptor_file_publish_s_type \
+       "(" \
+       "s" /* char * publish_url */ \
+       ")"
+
+#define private_service_adaptor_file_transfer_req_s_type_length 3
+#define private_service_adaptor_file_transfer_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "s" /* char * server_path */ \
+       "s" /* char * download_path */ \
+       ")"
+
+#define private_service_adaptor_file_status_req_s_type_length 2
+#define private_service_adaptor_file_status_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "i" /* int32 file_description */ \
+       ")"
+
+#define private_service_adaptor_file_status_res_s_type_length 3
+#define private_service_adaptor_file_status_res_s_type \
+       "(" \
+       "x" /* int64 total_size */ \
+       "x" /* int64 transferred_size */ \
+       "x" /* int64 status */ \
+       ")"
+
+#define private_service_adaptor_did_violation_users_s_type_length 2
+#define private_service_adaptor_did_violation_users_s_type \
+       "(" \
+       "x" /* int64 usera */ \
+       "x" /* int64 userb */ \
+       ")"
+
+#define private_service_adaptor_wrong_receiver_s_type_length 12
+#define private_service_adaptor_wrong_receiver_s_type \
+       "(" \
+       "a(x)" /* int64 * invalid_receivers */ \
+       "u" /* uint32 invalid_receivers_len */ \
+       "a(x)" /* int64 * interrupted_receivers */ \
+       "u" /* uint32 interrupted_receivers_len */ \
+       "a(x)" /* int64 * disabled_receivers */ \
+       "u" /* uint32 disabled_receivers_len */ \
+       "a(x)" /* int64 * existing_chatmembers */ \
+       "u" /* uint32 existing_chatmembers_len */ \
+       "a" private_service_adaptor_did_violation_users_s_type \
+       "u" /* uint32 did_violation_users_len */ \
+       "a(x)" /* int64 * invitation_denieds */ \
+       "u" /* uint32 invitation_denieds_len */ \
+       ")"
+
+#define private_service_adaptor_chat_msg_s_type_length 4
+#define private_service_adaptor_chat_msg_s_type \
+       "(" \
+       "x" /* int64 msg_id */ \
+       "i" /* int msg_type */ \
+       "s" /* char * chatmsg */ \
+       "i" /* int32 message_ttl */ \
+       ")"
+
+#define private_service_adaptor_processed_msg_s_type_length 2
+#define private_service_adaptor_processed_msg_s_type \
+       "(" \
+       "x" /* int64 msg_id */ \
+       "x" /* int64 sent_time */ \
+       ")"
+
+#define private_service_adaptor_delivery_ack_s_type_length 3
+#define private_service_adaptor_delivery_ack_s_type \
+       "(" \
+       "x" /* int64 user_id */ \
+       "x" /* int64 msg_id */ \
+       "t" /* int64 timestamp */ \
+       ")"
+
+#define private_service_adaptor_read_ack_s_type_length 3
+#define private_service_adaptor_read_ack_s_type \
+       "(" \
+       "x" /* int64 user_id */ \
+       "x" /* int64 msg_id */ \
+       "t" /* int64 timestamp */ \
+       ")"
+
+#define private_service_adaptor_ordered_chat_member_s_type_length 3
+#define private_service_adaptor_ordered_chat_member_s_type \
+       "(" \
+       "x" /* int64 user_id */ \
+       "b" /* bool available */ \
+       "s" /* char * name */ \
+       ")"
+
+#define private_service_adaptor_inbox_message_s_type_length 9
+#define private_service_adaptor_inbox_message_s_type \
+       "(" \
+       "x" /* int64 msg_id */ \
+       "i" /* int msg_type */ \
+       "x" /* int64 sender */ \
+       "x" /* int64 receiver */ \
+       "x" /* int64 sent_time */ \
+       "s" /* char * chat_msg */ \
+       "x" /* int64 chatroom_id */ \
+       "i" /* int chat_type */ \
+       "i" /* int32 message_ttl */ \
+       ")"
+
+#define private_service_adaptor_end_chat_s_type_length 2
+#define private_service_adaptor_end_chat_s_type \
+       "(" \
+       "x" /* int64 chatroom_id */ \
+       "b" /* boolean deny_invitation */ \
+       ")"
+
+#define private_service_adaptor_phone_number_s_type_length 2
+#define private_service_adaptor_phone_number_s_type \
+       "(" \
+       "s" /* char * phonenumber */ \
+       "s" /* char * ccc */ \
+       ")"
+
+#define private_service_adaptor_chat_id_s_type_length 2
+#define private_service_adaptor_chat_id_s_type \
+       "(" \
+       "x" /* int64 chatid */ \
+       "s" /* char * msisdn */ \
+       ")"
+
+#define private_service_adaptor_create_chatroom_req_s_type_length 6
+#define private_service_adaptor_create_chatroom_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "x" /* int64 request_id */ \
+       "i" /* int chat_type */ \
+       "a(x)" /* int64 * receivers */ \
+       "u" /* uint32 receivers_len */ \
+       "s" /* char * chatroom_title */ \
+       ")"
+
+#define private_service_adaptor_create_chatroom_res_s_type_length 4
+#define private_service_adaptor_create_chatroom_res_s_type \
+       "(" \
+       "x" /* int64 request_id */ \
+       "x" /* int64 chatroom_id */ \
+       "i" /* int32 default_message_ttl */ \
+       private_service_adaptor_wrong_receiver_s_type \
+       ")"
+
+#define private_service_adaptor_change_chatroom_meta_req_s_type_length 5
+#define private_service_adaptor_change_chatroom_meta_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "x" /* int64 request_id */ \
+       "x" /* int64 chatroom_id */ \
+       "s" /* char * chatroom_title */ \
+       "i" /* int32 default_message_ttl */ \
+       ")"
+
+#define private_service_adaptor_change_chatroom_meta_res_s_type_length 2
+#define private_service_adaptor_change_chatroom_meta_res_s_type \
+       "(" \
+       "x" /* int64 request_id */ \
+       "x" /* int64 chatroom_id */ \
+       ")"
+
+#define private_service_adaptor_chat_req_s_type_length 5
+#define private_service_adaptor_chat_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "x" /* int64 request_id */ \
+       "x" /* int64 chatroom_id */ \
+       "a" private_service_adaptor_chat_msg_s_type \
+       "u" /* uint32 chat_msgs_len */ \
+       ")"
+
+#define private_service_adaptor_chat_res_s_type_length 4
+#define private_service_adaptor_chat_res_s_type \
+       "(" \
+       "x" /* int64 request_id */ \
+       "x" /* int64 chatroom_id */ \
+       "a" private_service_adaptor_processed_msg_s_type \
+       "u" /* uint32 processed_msgs_len */ \
+       ")"
+
+#define private_service_adaptor_allow_chat_req_s_type_length 10
+#define private_service_adaptor_allow_chat_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "x" /* int64 request_id */ \
+       "x" /* int64 chatroom_id */ \
+       "b" /* bool is_auth_allow */ \
+       "i" /* int max_count */ \
+       "b" /* bool need_delivery_ack */ \
+       "t" /* long need_delivery_ack_timestamp */ \
+       "b" /* bool need_read_ack */ \
+       "t" /* long last_read_ack_timestamp */ \
+       "b" /* bool need_ordered_chat_member_list */ \
+       ")"
+
+#define private_service_adaptor_allow_chat_res_s_type_length 12
+#define private_service_adaptor_allow_chat_res_s_type \
+       "(" \
+       "x" /* int64 request_id */ \
+       "x" /* int64 chatroom_id */ \
+       "a" private_service_adaptor_delivery_ack_s_type \
+       "u" /* uint32 delivery_acks_len */ \
+       "t" /* uint64 last_delivery_acks_timestamp */ \
+       "a" private_service_adaptor_read_ack_s_type \
+       "u" /* uint32 read_acks_len */ \
+       "t" /* uint64 last_read_acks_timestamp */ \
+       "a" private_service_adaptor_ordered_chat_member_s_type \
+       "u" /* uint32 ordered_chat_members_len */ \
+       "s" /* char * chatroom_title */ \
+       "i" /* int32 default_message_ttl */ \
+       ")"
+
+#define private_service_adaptor_all_unread_message_req_s_type_length 3
+#define private_service_adaptor_all_unread_message_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "x" /* int64 request_id */ \
+       "i" /* int max_count */ \
+       ")"
+
+#define private_service_adaptor_all_unread_message_res_s_type_length 1
+#define private_service_adaptor_all_unread_message_res_s_type \
+       "(" \
+       "x" /* int64 request_id */ \
+       ")"
+
+#define private_service_adaptor_forward_online_message_req_s_type_length 5
+#define private_service_adaptor_forward_online_message_req_s_type \
+       "(" \
+       "x" /* int64 request_id */ \
+       "x" /* int64 chatroom_id */ \
+       "i" /* int chat_type */ \
+       private_service_adaptor_inbox_message_s_type \
+       "b" /* bool skip_reply */ \
+       ")"
+
+#define private_service_adaptor_forward_online_message_res_s_type_length 4
+#define private_service_adaptor_forward_online_message_res_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "x" /* int64 request_id */ \
+       "x" /* int64 chatroom_id */ \
+       "b" /* bool mark_as_read */ \
+       ")"
+
+#define private_service_adaptor_forward_unread_message_req_s_type_length 4
+#define private_service_adaptor_forward_unread_message_req_s_type \
+       "(" \
+       "x" /* int64 request_id */ \
+       "a" private_service_adaptor_inbox_message_s_type \
+       "u" /* uint32 inbox_msgs_len */ \
+       "s" /* char * next_pagination_key */ \
+       ")"
+
+#define private_service_adaptor_forward_unread_message_res_s_type_length 4
+#define private_service_adaptor_forward_unread_message_res_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "x" /* int64 request_id */ \
+       "s" /* char * next_pagination_key */ \
+       "i" /* int max_count */ \
+       ")"
+
+#define private_service_adaptor_read_message_req_s_type_length 4
+#define private_service_adaptor_read_message_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "x" /* int64 request_id */ \
+       "x" /* int64 chatroom_id */ \
+       private_service_adaptor_inbox_message_s_type \
+       ")"
+
+#define private_service_adaptor_read_message_res_s_type_length 2
+#define private_service_adaptor_read_message_res_s_type \
+       "(" \
+       "x" /* int64 request_id */ \
+       "x" /* int64 chatroom_id */ \
+       ")"
+
+#define private_service_adaptor_invite_chat_req_s_type_length 5
+#define private_service_adaptor_invite_chat_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "x" /* int64 request_id */ \
+       "x" /* int64 chatroom_id */ \
+       "a(x)" /* int64 *inviting_members */ \
+       "u" /* uint32 inviting_members_len */ \
+       ")"
+
+#define private_service_adaptor_invite_chat_res_s_type_length 4
+#define private_service_adaptor_invite_chat_res_s_type \
+       "(" \
+       "x" /* int64 request_id */ \
+       "x" /* int64 chatroom_id */ \
+       "x" /* int64 sent_time */ \
+       private_service_adaptor_wrong_receiver_s_type \
+       ")"
+
+#define private_service_adaptor_end_chat_req_s_type_length 4
+#define private_service_adaptor_end_chat_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "x" /* int64 request_id */ \
+       "a" private_service_adaptor_end_chat_s_type \
+       "u" /* uint32 end_chats_len */ \
+       ")"
+
+#define private_service_adaptor_end_chat_res_s_type_length 1
+#define private_service_adaptor_end_chat_res_s_type \
+       "(" \
+       "x" /* int64 request_id */ \
+       ")"
+
+#define private_service_adaptor_unseal_message_req_s_type_length 6
+#define private_service_adaptor_unseal_message_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "x" /* int64 request_id */ \
+       "x" /* int64 chatroom_id */ \
+       "x" /* int64 sender_id */ \
+       "x" /* int64 message_id */ \
+       "s" /* char * message_detail */ \
+       ")"
+
+#define private_service_adaptor_unseal_message_res_s_type_length 2
+#define private_service_adaptor_unseal_message_res_s_type \
+       "(" \
+       "x" /* int64 request_id */ \
+       "x" /* int64 chatroom_id */ \
+       ")"
+
+#define private_service_adaptor_save_call_log_req_s_type_length 8
+#define private_service_adaptor_save_call_log_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "x" /* int64 request_id */ \
+       "x" /* int64 chatroom_id */ \
+       "s" /* char * call_id */ \
+       "s" /* char * call_log_type */ \
+       "x" /* int64 call_sender_id */ \
+       "x" /* int64 call_receiver_id */ \
+       "i" /* int conversaction_second */ \
+       ")"
+
+#define private_service_adaptor_save_call_log_res_s_type_length 1
+#define private_service_adaptor_save_call_log_res_s_type \
+       "(" \
+       "x" /* int64 request_id */ \
+       ")"
+
+#define private_service_adaptor_current_time_req_s_type_length 2
+#define private_service_adaptor_current_time_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "x" /* int64 request_id */ \
+       ")"
+
+#define private_service_adaptor_current_time_res_s_type_length 2
+#define private_service_adaptor_current_time_res_s_type \
+       "(" \
+       "x" /* int64 request_id */ \
+       "x" /* int64 current_time_millis */ \
+       ")"
+
+#define private_service_adaptor_get_connection_policy_req_s_type_length 1
+#define private_service_adaptor_get_connection_policy_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       ")"
+
+#define private_service_adaptor_set_connection_policy_req_s_type_length 2
+#define private_service_adaptor_set_connection_policy_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "i" /* int32 connection_policy */ \
+       ")"
+
+#define private_service_adaptor_connection_policy_res_s_type_length 1
+#define private_service_adaptor_connection_policy_res_s_type \
+       "(" \
+       "i" /* int32 connection_policy */ \
+       ")"
+
+#define private_service_adaptor_channel_disconnected_res_s_type_length 1
+#define private_service_adaptor_channel_disconnected_res_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       ")"
+
+#define private_service_adaptor_chat_id_list_req_s_type_length 3
+#define private_service_adaptor_chat_id_list_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "a" private_service_adaptor_phone_number_s_type \
+       "u" /* uint32 phone_number_len */ \
+       ")"
+
+#define private_service_adaptor_chat_id_list_res_s_type_length 2
+#define private_service_adaptor_chat_id_list_res_s_type \
+       "(" \
+       "a" private_service_adaptor_chat_id_s_type \
+       "u" /* uint32 chat_ids_len */ \
+       ")"
+
+#define private_service_adaptor_msisdn_list_req_s_type_length 3
+#define private_service_adaptor_msisdn_list_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "a(x)" /* int64 * chat_ids */ \
+       "u" /* uint32 chat_ids_len */ \
+       ")"
+
+#define private_service_adaptor_msisdn_list_res_s_type_length 2
+#define private_service_adaptor_msisdn_list_res_s_type \
+       "(" \
+       "a" private_service_adaptor_chat_id_s_type \
+       "u" /* uint32 msisdns_len */ \
+       ")"
+
+#define private_service_adaptor_shop_info_s_type_length 9
+#define private_service_adaptor_shop_info_s_type \
+       "(" \
+       "i" /* int category_id */ \
+       "i" /* long item_id */ \
+       "i" /* long sticker_id */ \
+       "s" /* char * lang_cd */ \
+       "s" /* char * cntry_cd */ \
+       "i" /* int rwidth */ \
+       "i" /* int rheight */ \
+       "i" /* int start_idx */ \
+       "i" /* int count */ \
+       ")"
+
+#define private_service_adaptor_shop_item_s_type_length 17
+#define private_service_adaptor_shop_item_s_type \
+       "(" \
+       "i" /* long item_id */ \
+       "i" /* int category_id */ \
+       "a(i)" /* long * sticker_ids */ \
+       "u" /* uint32 sticker_ids_len */ \
+       "s" /* char * title */ \
+       "s" /* char * character */ \
+       "i" /* int version */ \
+       "s" /* char * download_url */ \
+       "s" /* char * panel_url */ \
+       "s" /* char * sticker_url */ \
+       "i" /* long file_size */ \
+       "i" /* int count */ \
+       "s" /* char * character_code */ \
+       "x" /* int64 startdate */ \
+       "x" /* int64 enddate */ \
+       "x" /* int64 expired_date */ \
+       "x" /* int64 valid_period */ \
+       ")"
+
+#define private_service_adaptor_shop_req_s_type_length 2
+#define private_service_adaptor_shop_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       private_service_adaptor_shop_info_s_type \
+       ")"
+
+#define private_service_adaptor_shop_res_s_type_length 2
+#define private_service_adaptor_shop_res_s_type \
+       "(" \
+       "a" private_service_adaptor_shop_item_s_type \
+       "u" /* uint32 items_len */ \
+       ")"
+
+#define private_service_adaptor_file_progress_s_type_length 3
+#define private_service_adaptor_file_progress_s_type \
+       "(" \
+       "i" /* int32 file_description */ \
+       "t" /* uint64 progress_size */ \
+       "t" /* uint64 total_size */ \
+       ")"
+
+#define private_service_adaptor_file_transfer_completion_s_type_length 2
+#define private_service_adaptor_file_transfer_completion_s_type \
+       "(" \
+       "i" /* int32 file_description */ \
+       "s" /* char * publish_url */ \
+       ")"
+
+#define private_service_adaptor_push_data_s_type_length 4
+#define private_service_adaptor_push_data_s_type \
+       "(" \
+       "u" /* uint32 service_id */ \
+       "s" /* char * data */ \
+       "s" /* char * msg */ \
+       "x" /* int64 time_stamp */ \
+       ")"
+
+#define private_service_adaptor_push_register_req_s_type_length 1
+#define private_service_adaptor_push_register_req_s_type \
+       "(" \
+       "s" /* char *service_file_name */ \
+       ")"
+
+#define private_service_adaptor_push_deregister_req_s_type_length 1
+#define private_service_adaptor_push_deregister_req_s_type \
+       "(" \
+       "s" /* char *service_file_name */ \
+       ")"
+
+///////////////////
+///////////////////               private feature
+///////////////////
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+///////////////////
+///////////////////               public feature
+///////////////////
+
+
+#define service_adaptor_essential_s_type_length 1
+#define service_adaptor_essential_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       ")"
+
+#define service_adaptor_plugin_s_type_length 2
+#define service_adaptor_plugin_s_type \
+       "(" \
+       "s" /* char * plugin_uri */ \
+       "i" /* int32_t installed_mask */ \
+       ")"
+
+#define service_adaptor_is_auth_req_s_type_length 2
+#define service_adaptor_is_auth_req_s_type \
+       "(" \
+       "s" /* char * plugin_uri */ \
+       service_adaptor_raw_data_s_type \
+       ")"
+
+#define service_adaptor_join_req_s_type_length 2
+#define service_adaptor_join_req_s_type \
+       "(" \
+       "s" /* char * plugin_uri */ \
+       service_adaptor_raw_data_s_type \
+       ")"
+
+#define service_adaptor_set_auth_s_type_length 9
+#define service_adaptor_set_auth_s_type \
+       "(" \
+       "a(y)" /* char array security_cookie */ \
+       "a(y)" /* char array plugin_property */ \
+       "s" /* char * service_name */ \
+       "s" /* char * plugin_uri */ \
+       "s" /* char * app_id */ \
+       "s" /* char * app_secret */ \
+       "s" /* char * user_id */ \
+       "s" /* char * user_password */ \
+       "i" /* int32_t enable_mask */ \
+       ")"
+
+#define service_adaptor_raw_data_s_type \
+       "a(y)" /* unsigned char * raw_data*/ \
+
+#define service_adaptor_file_path_req_s_type_length 3
+#define service_adaptor_file_path_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "a(s)" /* char ** file_paths */ \
+       "u" /* uint32 file_paths_len */ \
+       ")"
+
+#define service_adaptor_file_path_res_s_type_length 2
+#define service_adaptor_file_path_res_s_type \
+       "(" \
+       "a(s)" /* char ** file_paths */ \
+       "u" /* uint32 file_paths_len */ \
+       ")"
+
+#define service_adaptor_file_s_type_length 1
+#define service_adaptor_file_s_type \
+       "(" \
+       "i" /* int32 file_description */ \
+       ")"
+
+#define service_adaptor_content_meta_s_type_length 18
+#define service_adaptor_content_meta_s_type \
+       "(" \
+       "s" /* char * mime_type  */ \
+       "s" /* char * title  */ \
+       "s" /* char * album  */ \
+       "s" /* char * artist  */ \
+       "s" /* char * genere  */ \
+       "s" /* char * recorded_date  */ \
+       "i" /* int32  width */ \
+       "i" /* int32  height */ \
+       "i" /* int32  duration */ \
+       "s" /* char * copyright  */ \
+       "s" /* char * track_num  */ \
+       "s" /* char * description  */ \
+       "s" /* char * composer  */ \
+       "s" /* char * year  */ \
+       "i" /* int32  bitrate */ \
+       "i" /* int32  samplerate */ \
+       "i" /* int32  channel */ \
+       "s" /* char * extra_media_meta  */ \
+       ")"
+
+#define service_adaptor_cloud_meta_s_type_length 4
+#define service_adaptor_cloud_meta_s_type \
+       "(" \
+       "s" /* char * service_name  */ \
+       "t" /* uint64  usage_byte */ \
+       "t" /* uint64  quota_byte */ \
+       "s" /* char *  extra_cloud_meta */ \
+       ")"
+
+#define service_adaptor_file_info_s_type_length 11
+#define service_adaptor_file_info_s_type \
+       "(" \
+       "s" /* char * plugin_name  */ \
+       "s" /* char * object_id  */ \
+       "s" /* char * storage_path  */ \
+       "t" /* uint64  file_size */ \
+       "t" /* uint64  created_time */ \
+       "t" /* uint64  modified_time */ \
+       "i" /* int32  file_info_index */ \
+       "i" /* int32  content_type */ \
+       service_adaptor_content_meta_s_type \
+       service_adaptor_cloud_meta_s_type \
+       "s" /* char *  extra_file_info */ \
+       ")"
+
+#define service_adaptor_file_publish_s_type_length 1
+#define service_adaptor_file_publish_s_type \
+       "(" \
+       "s" /* char * publish_url */ \
+       ")"
+
+#define service_adaptor_file_transfer_req_s_type_length 3
+#define service_adaptor_file_transfer_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "s" /* char * server_path */ \
+       "s" /* char * download_path */ \
+       ")"
+
+#define service_adaptor_download_thumbnail_req_s_type_length 4
+#define service_adaptor_download_thumbnail_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "s" /* char * server_path */ \
+       "s" /* char * download_path */ \
+       "i" /* int32 thumbnail_size */ \
+       ")"
+
+#define service_adaptor_file_status_req_s_type_length 2
+#define service_adaptor_file_status_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "i" /* int32 file_description */ \
+       ")"
+
+#define service_adaptor_file_status_res_s_type_length 3
+#define service_adaptor_file_status_res_s_type \
+       "(" \
+       "x" /* int64 total_size */ \
+       "x" /* int64 transferred_size */ \
+       "x" /* int64 status */ \
+       ")"
+#define service_adaptor_get_root_folder_path_req_s_type_length 1
+#define service_adaptor_get_root_folder_path_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       ")"
+#define service_adaptor_get_root_folder_path_res_s_type_length 1
+#define service_adaptor_get_root_folder_path_res_s_type \
+       "(" \
+       "s" /* char * root_folder_path */ \
+       ")"
+#define service_adaptor_make_directory_req_s_type_length 2
+#define service_adaptor_make_directory_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "s" /* char * folder_path */ \
+       ")"
+#define service_adaptor_remove_file_req_s_type_length 2
+#define service_adaptor_remove_file_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "s" /* char * file_path */ \
+       ")"
+#define service_adaptor_remove_directory_req_s_type_length 2
+#define service_adaptor_remove_directory_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "s" /* char * folder_path */ \
+       ")"
+#define service_adaptor_move_file_req_s_type_length 3
+#define service_adaptor_move_file_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "s" /* char * src_file_path */ \
+       "s" /* char * dst_file_path */ \
+       ")"
+#define service_adaptor_move_directory_req_s_type_length 3
+#define service_adaptor_move_directory_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "s" /* char * src_folder_path */ \
+       "s" /* char * dst_folder_path */ \
+       ")"
+#define service_adaptor_get_file_list_req_s_type_length 2
+#define service_adaptor_get_file_list_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "s" /* char * parent_path */ \
+       ")"
+#define service_adaptor_open_upload_file_req_s_type_length 3
+#define service_adaptor_open_upload_file_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "s" /* char * local_path */ \
+       "s" /* char * upload_path */ \
+       ")"
+#define service_adaptor_open_download_file_req_s_type_length 3
+#define service_adaptor_open_download_file_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "s" /* char * storage_path */ \
+       "s" /* char * local_path */ \
+       ")"
+#define service_adaptor_open_download_thumbnail_req_s_type_length 4
+#define service_adaptor_open_download_thumbnail_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       "s" /* char * storage_path */ \
+       "s" /* char * local_path */ \
+       "i" /* int32_t thumbnail_size */ \
+       ")"
+#define service_adaptor_close_file_req_s_type_length 2
+#define service_adaptor_close_file_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       service_adaptor_file_descriptor_s_type \
+       ")"
+// jwkim async5
+#define service_adaptor_start_upload_file_req_s_type_length 5
+#define service_adaptor_start_upload_file_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       service_adaptor_file_descriptor_s_type \
+       "s" /* char * storage_path */ \
+       "b" /* bool need_progress */ \
+       "b" /* bool need_state */ \
+       ")"
+#define service_adaptor_start_download_file_req_s_type_length 5
+#define service_adaptor_start_download_file_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       service_adaptor_file_descriptor_s_type \
+       "s" /* char * storage_path */ \
+       "b" /* bool need_progress */ \
+       "b" /* bool need_state */ \
+       ")"
+#define service_adaptor_start_download_thumbnail_req_s_type_length 6
+#define service_adaptor_start_download_thumbnail_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       service_adaptor_file_descriptor_s_type \
+       "s" /* char * storage_path */ \
+       "i" /* int32_t thumbnail_size */ \
+       "b" /* bool need_progress */ \
+       "b" /* bool need_state */ \
+       ")"
+
+#define service_adaptor_cancel_file_task_req_s_type_length 2
+#define service_adaptor_cancel_file_task_req_s_type \
+       "(" \
+       "s" /* char * service_name */ \
+       service_adaptor_file_descriptor_s_type \
+       ")"
+
+#define service_adaptor_file_descriptor_s_type_length 1
+#define service_adaptor_file_descriptor_s_type \
+       "(" \
+       "x" /* int64_t file_uid */ \
+       ")"
+
+#define service_adaptor_get_file_list_res_s_type_length 2
+#define service_adaptor_get_file_list_res_s_type \
+       "(" \
+       "a" service_adaptor_file_info_s_type \
+       "u" /* uint32 file_info_len */ \
+       ")"
+
+#define service_adaptor_file_progress_s_type_length 3
+#define service_adaptor_file_progress_s_type \
+       "(" \
+       service_adaptor_file_descriptor_s_type \
+       "t" /* uint64 progress_size */ \
+       "t" /* uint64 total_size */ \
+       ")"
+
+#define service_adaptor_file_transfer_state_changed_s_type_length 2
+#define service_adaptor_file_transfer_state_changed_s_type \
+       "(" \
+       service_adaptor_file_descriptor_s_type \
+       "i" /* int32_t state */ \
+       ")"
+
+#define service_adaptor_push_data_s_type_length 4
+#define service_adaptor_push_data_s_type \
+       "(" \
+       "u" /* uint32 service_id */ \
+       "s" /* char * data */ \
+       "s" /* char * msg */ \
+       "x" /* int64 time_stamp */ \
+       ")"
+
+///////////////////
+///////////////////               public feature
+///////////////////
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+///////////////////
+///////////////////               private feature
+///////////////////
+
+/**
+ * array of structures
+ */
+#define private_plugin_list_type                       "a(sb)"
+#define private_contact_info_req_list_type             "a" private_service_adaptor_contact_info_req_s_type
+#define private_contact_info_res_list_type             "a" private_service_adaptor_contact_info_res_s_type
+#define private_shop_item_res_list_type                        "a" private_service_adaptor_shop_item_s_type
+#define private_message_chat_id_list_type              "a" private_service_adaptor_chat_id_s_type
+#define private_message_processed_msg_list_type                "a" private_service_adaptor_processed_msg_s_type
+#define private_message_did_violation_users_list_type  "a" private_service_adaptor_did_violation_users_s_type
+#define private_message_delivery_ack_list_type         "a" private_service_adaptor_delivery_ack_s_type
+#define private_message_read_ack_list_type             "a" private_service_adaptor_read_ack_s_type
+#define private_message_ordered_chat_member_list_type  "a" private_service_adaptor_ordered_chat_member_s_type
+#define private_message_inbox_message_list_type                "a" private_service_adaptor_inbox_message_s_type
+
+
+///////////////////
+///////////////////               private feature
+///////////////////
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+///////////////////
+///////////////////               public feature
+///////////////////
+
+
+#define plugin_list_type                       "a" service_adaptor_plugin_s_type
+#define storage_file_info_list_type            "a" service_adaptor_file_info_s_type
+
+///////////////////
+///////////////////               public feature
+///////////////////
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+///////////////////
+///////////////////               common
+///////////////////
+
+
+/**
+ * append error code to the type
+ */
+#define MAKE_RETURN_TYPE(x)                    "(" x "ts)"
+
+/**
+ * DBus APIs
+ */
+#define DBUS_SERVICE_ADAPTOR   "dbus_00"
+#define DBUS_AUTH_ADAPTOR      "dbus_01"
+#define DBUS_CONTACT_ADAPTOR   "dbus_02"
+#define DBUS_MESSAGE_ADAPTOR   "dbus_03"
+#define DBUS_DISCOVERY_ADAPTOR "dbus_04"
+#define DBUS_SHOP_ADAPTOR      "dbus_05"
+#define DBUS_STORAGE_ADAPTOR   "dbus_06"
+#define DBUS_PUSH_ADAPTOR      "dbus_07"
+#define DBUS_NAME_LENGTH       7
+
+
+///////////////////
+///////////////////               common
+///////////////////
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+///////////////////
+///////////////////               private feature
+///////////////////
+
+
+#define PRIVATE_DBUS_CONNECT_SERVICE_ADAPTOR_METHOD            DBUS_SERVICE_ADAPTOR "_private""_connect_service_adaptor"
+#define PRIVATE_DBUS_EXTERNAL_REQ_METHOD                       DBUS_SERVICE_ADAPTOR "_private" "_ext_req"
+
+#define PRIVATE_DBUS_GET_AUTH_PLUGIN_LIST_METHOD               DBUS_AUTH_ADAPTOR "_private" "_get_auth_plugin_list"
+#define PRIVATE_DBUS_SET_AUTH_METHOD                           DBUS_AUTH_ADAPTOR "_private" "_set_auth"
+
+#define PRIVATE_DBUS_SET_NEW_CONTACT_LIST_METHOD               DBUS_CONTACT_ADAPTOR "_private" "_set_new_contact_list"
+#define PRIVATE_DBUS_SET_CONTACT_LIST_METHOD                   DBUS_CONTACT_ADAPTOR "_private" "_set_contact_list"
+#define PRIVATE_DBUS_GET_CONTACT_LIST_METHOD                   DBUS_CONTACT_ADAPTOR "_private" "_get_contact_list"
+#define PRIVATE_DBUS_GET_CONTACT_INFOS_POLLING_METHOD          DBUS_CONTACT_ADAPTOR "_private" "_get_contact_infos_polling"
+#define PRIVATE_DBUS_SET_ME_PROFILE_WITH_PUSH_METHOD           DBUS_CONTACT_ADAPTOR "_private" "_set_me_profile_with_push"
+#define PRIVATE_DBUS_GET_PROFILE_METHOD                                DBUS_CONTACT_ADAPTOR "_private" "_get_profile"
+#define PRIVATE_DBUS_SET_PROFILE_IMAGE_META_WITH_PUSH_METHOD   DBUS_CONTACT_ADAPTOR "_private" "_set_profile_image_meta_with_push"
+#define PRIVATE_DBUS_DEL_ME_PROFILE_IMAGE_META_WITH_PUSH_METHOD        DBUS_CONTACT_ADAPTOR "_private" "_del_me_profile_image_meta_with_push"
+#define PRIVATE_DBUS_SET_ME_PROFILE_PRIVACY_METHOD             DBUS_CONTACT_ADAPTOR "_private" "_set_me_profile_privacy"
+#define PRIVATE_DBUS_GET_PROFILE_PRIVACY_METHOD                        DBUS_CONTACT_ADAPTOR "_private" "_get_profile_privacy"
+#define PRIVATE_DBUS_SET_ME_PRESENCE_WITH_PUSH_METHOD          DBUS_CONTACT_ADAPTOR "_private" "_set_me_presence_with_push"
+#define PRIVATE_DBUS_SET_ME_PRESENCE_ON_OFF_WITH_PUSH_METHOD   DBUS_CONTACT_ADAPTOR "_private" "_set_me_presence_on_off_with_push"
+#define PRIVATE_DBUS_SET_ME_PROFILE_TYPE_METHOD                        DBUS_CONTACT_ADAPTOR "_private" "_set_me_profile_type"
+
+#define PRIVATE_DBUS_REQUEST_CREATE_CHATROOM_METHOD            DBUS_MESSAGE_ADAPTOR "_private" "_request_create_chatroom"
+#define PRIVATE_DBUS_REQUEST_CHANGE_CHATROOM_META_METHOD       DBUS_MESSAGE_ADAPTOR "_private" "_request_change_chatroom_meta"
+#define PRIVATE_DBUS_REQUEST_CHAT_METHOD                       DBUS_MESSAGE_ADAPTOR "_private" "_request_chat"
+#define PRIVATE_DBUS_REQUEST_ALLOW_CHAT_METHOD                 DBUS_MESSAGE_ADAPTOR "_private" "_request_allow_chat"
+#define PRIVATE_DBUS_REQUEST_ALL_UNREAD_MESSAGE_METHOD         DBUS_MESSAGE_ADAPTOR "_private" "_request_all_unread_message"
+#define PRIVATE_DBUS_REPLY_FORWARD_ONLINE_MESSAGE_METHOD       DBUS_MESSAGE_ADAPTOR "_private" "_reply_forward_online_message"
+#define PRIVATE_DBUS_REPLY_FORWARD_UNREAD_MESSAGE_METHOD       DBUS_MESSAGE_ADAPTOR "_private" "_reply_forward_unread_message"
+#define PRIVATE_DBUS_REQUEST_READ_MESSAGE_METHOD               DBUS_MESSAGE_ADAPTOR "_private" "_request_read_message"
+#define PRIVATE_DBUS_REQUEST_INVITE_CHAT_METHOD                        DBUS_MESSAGE_ADAPTOR "_private" "_request_invite_chat"
+#define PRIVATE_DBUS_REQUEST_END_CHAT_METHOD                   DBUS_MESSAGE_ADAPTOR "_private" "_request_end_chat"
+#define PRIVATE_DBUS_REQUEST_UNSEAL_MESSAGE_METHOD             DBUS_MESSAGE_ADAPTOR "_private" "_request_unseal_message"
+#define PRIVATE_DBUS_REQUEST_SAVE_CALL_LOG_METHOD              DBUS_MESSAGE_ADAPTOR "_private" "_request_save_call_log"
+#define PRIVATE_DBUS_REQUEST_CURRENT_TIME_METHOD               DBUS_MESSAGE_ADAPTOR "_private" "_request_current_time"
+#define PRIVATE_DBUS_REQUEST_GET_CONNECTION_POLICY_METHOD      DBUS_MESSAGE_ADAPTOR "_private" "_request_get_connection_policy"
+#define PRIVATE_DBUS_REQUEST_SET_CONNECTION_POLICY_METHOD      DBUS_MESSAGE_ADAPTOR "_private" "_request_set_connection_policy"
+#define PRIVATE_DBUS_GET_CHAT_ID_LIST_METHOD                   DBUS_MESSAGE_ADAPTOR "_private" "_get_chat_id_list"
+#define PRIVATE_DBUS_GET_MSISDN_LIST_METHOD                    DBUS_MESSAGE_ADAPTOR "_private" "_get_msisdn_list"
+
+#define PRIVATE_DBUS_GET_ITEM_LIST_METHOD                      DBUS_SHOP_ADAPTOR "_private" "_get_item_list"
+#define PRIVATE_DBUS_DOWNLOAD_ITEM_PACKAGE_METHOD              DBUS_SHOP_ADAPTOR "_private" "_download_item_package"
+#define PRIVATE_DBUS_DOWNLOAD_STICKER_METHOD                   DBUS_SHOP_ADAPTOR "_private" "_download_sticker"
+#define PRIVATE_DBUS_GET_PANEL_URL_METHOD                      DBUS_SHOP_ADAPTOR "_private" "_get_panel_url"
+
+#define PRIVATE_DBUS_DOWNLOAD_FILE_METHOD                      DBUS_STORAGE_ADAPTOR "_private" "_download_file"
+#define PRIVATE_DBUS_DOWNLOAD_FILE_ASYNC_METHOD                        DBUS_STORAGE_ADAPTOR "_private" "_download_file_async"
+#define PRIVATE_DBUS_UPLOAD_FILE_METHOD                                DBUS_STORAGE_ADAPTOR "_private" "_upload_file"
+#define PRIVATE_DBUS_UPLOAD_FILE_ASYNC_METHOD                  DBUS_STORAGE_ADAPTOR "_private" "_upload_file_async"
+#define PRIVATE_DBUS_GET_FILE_STATUS_METHOD                    DBUS_STORAGE_ADAPTOR "_private" "_get_file_status"
+#define PRIVATE_DBUS_CANCEL_FILE_TRANSFER_METHOD               DBUS_STORAGE_ADAPTOR "_private" "_cancel_file_transfer"
+#define PRIVATE_DBUS_PAUSE_FILE_TRANSFER_METHOD                        DBUS_STORAGE_ADAPTOR "_private" "_pause_file_transfer"
+#define PRIVATE_DBUS_RESUME_FILE_TRANSFER_METHOD               DBUS_STORAGE_ADAPTOR "_private" "_resume_file_transfer"
+#define PRIVATE_DBUS_DOWNLOAD_FILE_PUBLISH_METHOD              DBUS_STORAGE_ADAPTOR "_private" "_download_file_publish"
+#define PRIVATE_DBUS_DOWNLOAD_FILE_PUBLISH_ASYNC_METHOD                DBUS_STORAGE_ADAPTOR "_private" "_download_file_publish_async"
+#define PRIVATE_DBUS_UPLOAD_FILE_PUBLISH_METHOD                        DBUS_STORAGE_ADAPTOR "_private" "_upload_file_publish"
+#define PRIVATE_DBUS_UPLOAD_FILE_PUBLISH_ASYNC_METHOD          DBUS_STORAGE_ADAPTOR "_private" "_upload_file_publish_async"
+
+#define PRIVATE_DBUS_REPLY_CREATE_CHATROOM_SIGNAL              DBUS_MESSAGE_ADAPTOR "_private" "_reply_create_chatroom"
+#define PRIVATE_DBUS_REPLY_CHANGE_CHATROOM_META_SIGNAL         DBUS_MESSAGE_ADAPTOR "_private" "_reply_change_chatroom_meta"
+#define PRIVATE_DBUS_REPLY_CHAT_SIGNAL                         DBUS_MESSAGE_ADAPTOR "_private" "_reply_chat"
+#define PRIVATE_DBUS_REPLY_ALLOW_CHAT_SIGNAL                   DBUS_MESSAGE_ADAPTOR "_private" "_reply_allow_chat"
+#define PRIVATE_DBUS_REPLY_ALL_UNREAD_MESSAGE_SIGNAL           DBUS_MESSAGE_ADAPTOR "_private" "_reply_all_unread_message"
+#define PRIVATE_DBUS_REQUEST_FORWARD_ONLINE_MESSAGE_SIGNAL     DBUS_MESSAGE_ADAPTOR "_private" "_request_forward_online_message"
+#define PRIVATE_DBUS_REQUEST_FORWARD_UNREAD_MESSAGE_SIGNAL     DBUS_MESSAGE_ADAPTOR "_private" "_request_forward_unread_message"
+#define PRIVATE_DBUS_REPLY_READ_MESSAGE_SIGNAL                 DBUS_MESSAGE_ADAPTOR "_private" "_reply_read_message"
+#define PRIVATE_DBUS_REPLY_INVITE_CHAT_SIGNAL                  DBUS_MESSAGE_ADAPTOR "_private" "_reply_invite_chat"
+#define PRIVATE_DBUS_REPLY_END_CHAT_SIGNAL                     DBUS_MESSAGE_ADAPTOR "_private" "_reply_end_chat"
+#define PRIVATE_DBUS_REPLY_UNSEAL_MESSAGE_SIGNAL               DBUS_MESSAGE_ADAPTOR "_private" "_reply_unseal_message"
+#define PRIVATE_DBUS_REPLY_SAVE_CALL_LOG_SIGNAL                        DBUS_MESSAGE_ADAPTOR "_private" "_reply_save_call_log"
+#define PRIVATE_DBUS_REPLY_CURRENT_TIME_SIGNAL                 DBUS_MESSAGE_ADAPTOR "_private" "_reply_current_time"
+#define PRIVATE_DBUS_REPLY_CHANNEL_DISCONNECTED_SIGNAL         DBUS_MESSAGE_ADAPTOR "_private" "_reply_channel_disconnected"
+
+#define PRIVATE_DBUS_STORAGE_FILE_PROGRESS_SIGNAL              DBUS_STORAGE_ADAPTOR "_private" "_storage_file_progress"
+#define PRIVATE_DBUS_STORAGE_FILE_TRANSFER_COMPLETION_SIGNAL   DBUS_STORAGE_ADAPTOR "_private" "_storage_file_transfer_completion"
+
+#define PRIVATE_DBUS_PUSH_DATA_SIGNAL                          DBUS_PUSH_ADAPTOR "_private" "_push_data"
+#define PRIVATE_DBUS_PUSH_REGISTER_METHOD                      DBUS_PUSH_ADAPTOR "_private" "_push_register"
+#define PRIVATE_DBUS_PUSH_DEREGISTER_METHOD                    DBUS_PUSH_ADAPTOR "_private" "_push_deregister"
+
+#define PRIVATE_DBUS_SERVICE_ADAPTOR_SIGNAL                    DBUS_SERVICE_ADAPTOR "_private" "_service_adaptor_signal"
+
+
+///////////////////
+///////////////////               private feature
+///////////////////
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+///////////////////
+///////////////////               public feature
+///////////////////
+
+#define DBUS_CONNECT_SERVICE_ADAPTOR_METHOD            DBUS_SERVICE_ADAPTOR "_connect_service_adaptor"
+
+#define DBUS_GET_AUTH_PLUGIN_LIST_METHOD               DBUS_AUTH_ADAPTOR "_get_auth_plugin_list"
+#define DBUS_IS_AUTH_METHOD                            DBUS_AUTH_ADAPTOR "_is_auth"
+#define DBUS_JOIN_METHOD                               DBUS_AUTH_ADAPTOR "_join"
+#define DBUS_SET_AUTH_METHOD                           DBUS_AUTH_ADAPTOR "_set_auth"
+
+#define DBUS_DOWNLOAD_FILE_METHOD                      DBUS_STORAGE_ADAPTOR "_download_file"
+#define DBUS_DOWNLOAD_THUMBNAIL_METHOD                 DBUS_STORAGE_ADAPTOR "_download_thumbnail"
+#define DBUS_UPLOAD_FILE_METHOD                                DBUS_STORAGE_ADAPTOR "_upload_file"
+#define DBUS_GET_ROOT_FOLDER_PATH_METHOD               DBUS_STORAGE_ADAPTOR "_get_root_folder_path"
+#define DBUS_MAKE_DIRECTORY_METHOD                     DBUS_STORAGE_ADAPTOR "_make_directory"
+#define DBUS_REMOVE_FILE_METHOD                                DBUS_STORAGE_ADAPTOR "_remove_file"
+#define DBUS_REMOVE_DIRECTORY_METHOD                   DBUS_STORAGE_ADAPTOR "_remove_directory"
+#define DBUS_GET_METADATA_METHOD                       DBUS_STORAGE_ADAPTOR "_get_metadata"
+#define DBUS_GET_LIST_METHOD                           DBUS_STORAGE_ADAPTOR "_get_list"
+#define DBUS_MOVE_FILE_METHOD                          DBUS_STORAGE_ADAPTOR "_move_file"
+#define DBUS_MOVE_DIRECTORY_METHOD                     DBUS_STORAGE_ADAPTOR "_move_directory"
+#define DBUS_GET_FILE_LIST_METHOD                      DBUS_STORAGE_ADAPTOR "_get_file_list"
+
+#define DBUS_OPEN_UPLOAD_FILE_METHOD                   DBUS_STORAGE_ADAPTOR "_open_upload_file"
+#define DBUS_OPEN_DOWNLOAD_FILE_METHOD                 DBUS_STORAGE_ADAPTOR "_open_download_file"
+#define DBUS_OPEN_DOWNLOAD_THUMBNAIL_METHOD            DBUS_STORAGE_ADAPTOR "_open_download_thumbnail"
+#define DBUS_CLOSE_FILE_METHOD                         DBUS_STORAGE_ADAPTOR "_close_file"
+#define DBUS_START_UPLOAD_FILE_METHOD                  DBUS_STORAGE_ADAPTOR "_start_upload_file"
+#define DBUS_START_DOWNLOAD_FILE_METHOD                        DBUS_STORAGE_ADAPTOR "_start_download_file"
+#define DBUS_START_DOWNLOAD_THUMBNAIL_METHOD           DBUS_STORAGE_ADAPTOR "_start_dowlnoad_thumbnail"
+#define DBUS_CANCEL_UPLOAD_FILE_METHOD                 DBUS_STORAGE_ADAPTOR "_cancel_upload_file"
+#define DBUS_CANCEL_DOWNLOAD_FILE_METHOD               DBUS_STORAGE_ADAPTOR "_cancel_download_file"
+#define DBUS_CANCEL_DOWNLOAD_THUMBNAIL_METHOD          DBUS_STORAGE_ADAPTOR "_cancel_download_thumbnail"
+
+#define DBUS_STORAGE_FILE_PROGRESS_SIGNAL              DBUS_STORAGE_ADAPTOR "_storage_file_progress"
+#define DBUS_STORAGE_FILE_TRANSFER_STATE_CHANGED_SIGNAL        DBUS_STORAGE_ADAPTOR "_storage_file_transfer_state_changed"
+#define DBUS_STORAGE_FILE_TRANSFER_COMPLETION_SIGNAL   DBUS_STORAGE_ADAPTOR "_storage_file_transfer_completion"
+
+#define DBUS_PUSH_DATA_SIGNAL                          DBUS_PUSH_ADAPTOR "_push_data"
+
+#define DBUS_SERVICE_ADAPTOR_SIGNAL                    DBUS_SERVICE_ADAPTOR "_service_adaptor_signal"
+
+/* Extention enum define */
+#define SERVICE_ADAPTOR_FILE_TRANSFER_STATE_IN_PROGRESS 1
+#define SERVICE_ADAPTOR_FILE_TRANSFER_STATE_COMPLETED 2
+#define SERVICE_ADAPTOR_FILE_TRANSFER_STATE_CANCELED 3
+#define SERVICE_ADAPTOR_FILE_TRANSFER_STATE_FAILED 4
+
+
+///////////////////
+///////////////////               public feature
+///////////////////
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+///////////////////
+///////////////////               private feature
+///////////////////
+
+typedef enum
+{
+       SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_NONE                       = 0,
+       SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_COMMON_NO_DATA             = 101,
+       SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_COMMON_TIMED_OUT           = 102,
+       SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_COMMON_NOT_SUPPORTED       = 103,
+       SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_COMMON_PERMISSION_DENIED   = 104,
+       SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_AUTH_NOT_AUTHORIZED        = 201,
+       SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_MESSAGE_NETWORK            = 601,
+} service_adaptor_protocol_return_code_e;
+
+typedef enum
+{
+       SERVICE_ADAPTOR_PROTOCOL_SERVICE_TYPE_AUTH              = (0x01 << 0),
+       SERVICE_ADAPTOR_PROTOCOL_SERVICE_TYPE_STORAGE           = (0x01 << 1),
+       SERVICE_ADAPTOR_PROTOCOL_SERVICE_TYPE_CONTACT           = (0x01 << 2),
+       SERVICE_ADAPTOR_PROTOCOL_SERVICE_TYPE_MESSAGE           = (0x01 << 3),
+       SERVICE_ADAPTOR_PROTOCOL_SERVICE_TYPE_SHOP              = (0x01 << 4),
+       SERVICE_ADAPTOR_PROTOCOL_SERVICE_TYPE_PUSH              = (0x01 << 5),
+} service_adaptor_protocol_service_type_e;
+
+///////////////////
+///////////////////               private feature
+///////////////////
+/////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////
+
+#endif /* __DBUS_SERVER_H__ */
diff --git a/inc/dbus/dbus-service-adaptor.h b/inc/dbus/dbus-service-adaptor.h
new file mode 100644 (file)
index 0000000..ec913eb
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+* 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 __DBUS_SERVICE_ADAPTOR_H__
+#define __DBUS_SERVICE_ADAPTOR_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+
+void service_adaptor_method_call(GDBusConnection *connection,
+                                               const gchar *sender,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *method_name,
+                                               GVariant *parameters,
+                                               GDBusMethodInvocation *invocation,
+                                               gpointer user_data);
+
+service_adaptor_internal_error_code_e dbus_push_data_callback(uint32_t service_id,
+                                               push_adaptor_notification_data_h app_data,
+                                               service_adaptor_internal_error_h error_code,
+                                               void *server_data);
+
+service_adaptor_internal_error_code_e dbus_service_adaptor_signal_callback(service_adaptor_internal_signal_code_e signal_code,
+                                               const char *signal_msg);
+
+#endif /* __DBUS_SERVICE_ADAPTOR_H__ */
diff --git a/inc/dbus/dbus-shop-adaptor.h b/inc/dbus/dbus-shop-adaptor.h
new file mode 100644 (file)
index 0000000..4369dd1
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+* 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 __DBUS_SHOP_ADAPTOR_H__
+#define __DBUS_SHOP_ADAPTOR_H__
+
+void shop_adaptor_method_call(GDBusConnection *connection,
+                                               const gchar *sender,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *method_name,
+                                               GVariant *parameters,
+                                               GDBusMethodInvocation *invocation,
+                                               gpointer user_data);
+
+#endif /* __DBUS_SHOP_ADAPTOR_H__ */
diff --git a/inc/dbus/dbus-storage-adaptor.h b/inc/dbus/dbus-storage-adaptor.h
new file mode 100644 (file)
index 0000000..3e6fafb
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+* 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 __DBUS_STORAGE_ADAPTOR_H__
+#define __DBUS_STORAGE_ADAPTOR_H__
+
+void storage_adaptor_method_call(GDBusConnection *connection,
+                                               const gchar *sender,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *method_name,
+                                               GVariant *parameters,
+                                               GDBusMethodInvocation *invocation,
+                                               gpointer user_data);
+
+// private feature
+service_adaptor_internal_error_code_e private_dbus_storage_file_progress_callback(int32_t fd,
+                                               uint64_t progress_size,
+                                               uint64_t total_size,
+                                               storage_adaptor_error_code_h error_code,
+                                               void *server_data);
+
+service_adaptor_internal_error_code_e private_dbus_storage_file_transfer_completion_callback(int32_t fd,
+                                               char *publish_url,
+                                               storage_adaptor_error_code_h error_code,
+                                               void *server_data);
+
+// public feature
+service_adaptor_internal_error_code_e dbus_storage_file_progress_callback(long long int file_uid,
+                                               unsigned long long progress_size,
+                                               unsigned long long total_size);
+
+service_adaptor_internal_error_code_e dbus_storage_file_transfer_state_changed_callback(long long int file_uid,
+                                               storage_adaptor_transfer_state_e state,
+                                               storage_adaptor_error_code_h _error_code);
+
+#endif /* __DBUS_STORAGE_ADAPTOR_H__ */
diff --git a/inc/dbus/dbus-util.h b/inc/dbus/dbus-util.h
new file mode 100644 (file)
index 0000000..69b019c
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+* 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 __DBUS_UTIL_H__
+#define __DBUS_UTIL_H__
+
+#include <glib.h>
+
+#define __safe_add_string(x)   (x==NULL)?"":x
+
+void free_string(gpointer data);
+void safe_g_variant_builder_add_string(GVariantBuilder *builder, const char *data);
+void safe_g_variant_builder_add_array_string(GVariantBuilder *builder, const char *data);
+char *ipc_g_variant_dup_string(GVariant *string);
+
+#endif /* __DBUS_UTIL_H__ */
diff --git a/inc/service-adaptor-auth.h b/inc/service-adaptor-auth.h
new file mode 100644 (file)
index 0000000..318164e
--- /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 __SERVICE_ADAPTOR_AUTH_H__
+#define __SERVICE_ADAPTOR_AUTH_H__
+
+#include "service-adaptor-type.h"
+#include "auth-adaptor.h"
+
+auth_adaptor_h service_adaptor_get_auth_adaptor(service_adaptor_h service_adaptor);
+
+auth_adaptor_plugin_context_h service_adaptor_get_auth_context(service_adaptor_h service_adaptor,
+                                               const char* imsi,
+                                               const char *app_id);
+
+service_adaptor_internal_error_code_e service_adaptor_connect_auth_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_context_info_s *context_info,
+                                               const char *service_name,
+                                               const char *plugin_uri,
+                                               const char *user_password,
+                                               const char *app_secret,
+                                               service_adaptor_service_context_h *service,
+                                               char *ret_msg);
+
+service_adaptor_internal_error_code_e service_adaptor_disconnect_auth_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service);
+
+auth_adaptor_h service_adaptor_create_auth();
+
+auth_adaptor_listener_h service_adaptor_register_auth_listener(auth_adaptor_h auth_adaptor);
+
+#endif /* __SERVICE_ADAPTOR_AUTH_H__ */
diff --git a/inc/service-adaptor-contact.h b/inc/service-adaptor-contact.h
new file mode 100644 (file)
index 0000000..6f93867
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+* 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 __SERVICE_ADAPTOR_CONTACT_H__
+#define __SERVICE_ADAPTOR_CONTACT_H__
+
+#include "service-adaptor-type.h"
+#include "contact-adaptor.h"
+
+contact_adaptor_h service_adaptor_get_contact_adaptor(service_adaptor_h service_adaptor);
+
+service_adaptor_internal_error_code_e service_adaptor_connect_contact_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service,
+                                               char *ret_msg);
+
+service_adaptor_internal_error_code_e service_adaptor_disconnect_contact_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service);
+
+contact_adaptor_h service_adaptor_create_contact();
+
+contact_adaptor_listener_h service_adaptor_register_contact_listener(contact_adaptor_h contact_adaptor);
+
+#endif /* __SERVICE_ADAPTOR_CONTACT_H__ */
diff --git a/inc/service-adaptor-log.h b/inc/service-adaptor-log.h
new file mode 100644 (file)
index 0000000..af87d08
--- /dev/null
@@ -0,0 +1,167 @@
+/*
+* 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 __SERVICE_ADAPTOR_LOG_H__
+#define __SERVICE_ADAPTOR_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"
+
+#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 service_adaptor_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 service_adaptor_retv_if(expr, val) do { \
+            if(expr) { \
+                LOGE(FONT_COLOR_PURPLE"[%d]"FONT_COLOR_RESET, service_adaptor_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 service_adaptor_debug(fmt, arg...) do { \
+            LOGD(FONT_COLOR_GREEN"[%d]"fmt""FONT_COLOR_RESET, service_adaptor_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 service_adaptor_info(fmt, arg...) do { \
+            LOGI(FONT_COLOR_BLUE"[%d]"fmt""FONT_COLOR_RESET, service_adaptor_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 service_adaptor_warning(fmt, arg...) do { \
+            LOGW(FONT_COLOR_YELLOW"[%d]"fmt""FONT_COLOR_RESET,service_adaptor_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 service_adaptor_error(fmt, arg...) do { \
+            LOGE(FONT_COLOR_RED"[%d]"fmt""FONT_COLOR_RESET,service_adaptor_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 service_adaptor_fatal(fmt, arg...) do { \
+            LOGF(FONT_COLOR_BOLDRED"[%d]"fmt""FONT_COLOR_RESET,service_adaptor_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 service_adaptor_debug_func(fmt, arg...) do { \
+            LOGD(FONT_COLOR_CYAN"[%d]"fmt""FONT_COLOR_RESET, service_adaptor_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 service_adaptor_debug_secure(fmt, arg...) do { \
+            SECURE_LOGD(FONT_COLOR_CYAN"[%d]"fmt""FONT_COLOR_RESET, service_adaptor_gettid(), ##arg);     \
+        } while (0)
+
+#define FUNC_START() do{service_adaptor_debug_func("\033[1m\033[32m""Start >>%s>>\n""\033[0m", __FUNCTION__);}while(0)
+#define FUNC_STEP() do{service_adaptor_debug_func("\033[1m\033[32m""Step logging >>%s<<\n""\033[0m", __FUNCTION__);}while(0)
+#define FUNC_END() do{service_adaptor_debug_func("\033[1m\033[36m""End <<%s<<\n""\033[0m", __FUNCTION__);}while(0)
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /* __SERVICE_ADAPTOR_LOG_H__ */
diff --git a/inc/service-adaptor-message.h b/inc/service-adaptor-message.h
new file mode 100644 (file)
index 0000000..f3109bb
--- /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 __SERVICE_ADAPTOR_MESSAGE_H__
+#define __SERVICE_ADAPTOR_MESSAGE_H__
+
+#include "service-adaptor-type.h"
+#include "message-adaptor.h"
+
+message_adaptor_h service_adaptor_get_message_adaptor(service_adaptor_h service_adaptor);
+
+service_adaptor_internal_error_code_e service_adaptor_connect_message_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service,
+                                               char *ret_msg);
+
+service_adaptor_internal_error_code_e service_adaptor_disconnect_message_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service);
+
+service_adaptor_internal_error_code_e service_adaptor_message_connection_create(message_adaptor_plugin_h plugin,
+                                               message_adaptor_plugin_context_h context,
+                                               message_adaptor_error_code_h *error);
+
+service_adaptor_internal_error_code_e service_adaptor_message_set_connection(message_adaptor_plugin_h plugin,
+                                               message_adaptor_plugin_context_h message_context,
+                                               message_connection_policy_e policy,
+                                               message_adaptor_error_code_t **error_code);
+
+message_adaptor_h service_adaptor_create_message();
+
+message_adaptor_listener_h service_adaptor_register_message_listener(message_adaptor_h message_adaptor);
+
+#endif /* __SERVICE_ADAPTOR_MESSAGE_ADAPTOR_H__ */
diff --git a/inc/service-adaptor-plugin.h b/inc/service-adaptor-plugin.h
new file mode 100644 (file)
index 0000000..ace8744
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+* 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 __SERVICE_ADAPTOR_PLUGIN_H__
+#define __SERVICE_ADAPTOR_PLUGIN_H__
+
+#include <tizen.h>
+#include "service-adaptor-type.h"
+
+// TODO It will be re-define another header
+#define SERVICE_ADAPTOR_3RD_PARTY_METADATA_KEY_VERSION "http://tizen.org/service-adaptor/version"
+#define SERVICE_ADAPTOR_3RD_PARTY_METADATA_KEY_AUTH            "http://tizen.org/service-adaptor/auth"
+#define SERVICE_ADAPTOR_3RD_PARTY_METADATA_KEY_STORAGE "http://tizen.org/service-adaptor/storage"
+
+
+service_adaptor_internal_error_code_e service_adaptor_set_package_installed_callback(service_adaptor_h _service_adaptor);
+
+service_adaptor_internal_error_code_e service_adaptor_scan_all_packages(service_adaptor_h _service_adaptor);
+
+service_adaptor_internal_error_code_e service_adaptor_scan_all_packages_async(service_adaptor_h _service_adaptor);
+
+#endif /* __SERVICE_ADAPTOR_PLUGIN_H__ */
diff --git a/inc/service-adaptor-push.h b/inc/service-adaptor-push.h
new file mode 100644 (file)
index 0000000..c8884a8
--- /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.
+*/
+
+#ifndef __SERVICE_ADAPTOR_PUSH_H__
+#define __SERVICE_ADAPTOR_PUSH_H__
+
+#include "service-adaptor-type.h"
+#include "push-adaptor.h"
+
+
+typedef struct _push_activate_s
+{
+       /* service_file_name (unique) */
+       char *file_name;
+
+       /* push info */
+       char *plugin_uri;
+       char *app_id;
+       char *session_info;
+
+       /* bus info */
+       int bus_type;
+       char *bus_name;
+       char *object_path;
+       char *interface;
+       char *method;
+       void *proxy;
+
+       /* general */
+       char *exec;
+} push_activate_t;
+typedef push_activate_t *push_activate_h;
+
+
+push_adaptor_h service_adaptor_get_push_adaptor(service_adaptor_h service_adaptor);
+
+push_adaptor_plugin_context_h service_adaptor_get_push_context(service_adaptor_h service_adaptor,
+                                               const char *imsi,
+                                               const char *app_id);
+
+service_adaptor_internal_error_code_e service_adaptor_connect_push_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service,
+                                               char *ret_msg);
+
+service_adaptor_internal_error_code_e service_adaptor_disconnect_push_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service);
+
+service_adaptor_internal_error_code_e service_adaptor_reconnect_push_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service);
+
+push_adaptor_h service_adaptor_create_push();
+
+push_adaptor_listener_h service_adaptor_register_push_listener(push_adaptor_h push_adaptor);
+
+service_adaptor_internal_error_code_e service_adaptor_push_register(const char *service_file, char **error_msg);
+
+service_adaptor_internal_error_code_e service_adaptor_push_deregister(const char *service_file, char **error_msg);
+
+service_adaptor_internal_error_code_e service_adaptor_ref_enabled_push_services(push_activate_h **services, int *services_len);
+
+#endif /* __SERVICE_ADAPTOR_PUSH_H__ */
diff --git a/inc/service-adaptor-shop.h b/inc/service-adaptor-shop.h
new file mode 100644 (file)
index 0000000..44201ae
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+* 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 __SERVICE_ADAPTOR_SHOP_H__
+#define __SERVICE_ADAPTOR_SHOP_H__
+
+#include "service-adaptor-type.h"
+#include "shop-adaptor.h"
+
+shop_adaptor_h service_adaptor_get_shop_adaptor(service_adaptor_h service_adaptor);
+
+service_adaptor_internal_error_code_e service_adaptor_connect_shop_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service,
+                                               char *ret_msg);
+
+service_adaptor_internal_error_code_e service_adaptor_disconnect_shop_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service);
+
+shop_adaptor_h service_adaptor_create_shop();
+
+shop_adaptor_listener_h service_adaptor_register_shop_listener(shop_adaptor_h shop_adaptor);
+
+#endif /* __SERVICE_ADAPTOR_SHOP_H__ */
diff --git a/inc/service-adaptor-storage.h b/inc/service-adaptor-storage.h
new file mode 100644 (file)
index 0000000..5499454
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+* 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 __SERVICE_ADAPTOR_STORAGE_H__
+#define __SERVICE_ADAPTOR_STORAGE_H__
+
+#include "service-adaptor-type.h"
+#include "storage-adaptor.h"
+
+storage_adaptor_h service_adaptor_get_storage_adaptor(service_adaptor_h service_adaptor);
+
+service_adaptor_internal_error_code_e service_adaptor_connect_storage_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service,
+                                               const char *app_secret,
+                                               char *ret_msg);
+
+service_adaptor_internal_error_code_e service_adaptor_disconnect_storage_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service);
+
+storage_adaptor_h service_adaptor_create_storage();
+
+storage_adaptor_listener_h service_adaptor_register_storage_listener(storage_adaptor_h storage_adaptor);
+
+#endif /* __SERVICE_ADAPTOR_STORAGE_H__ */
diff --git a/inc/service-adaptor-type.h b/inc/service-adaptor-type.h
new file mode 100644 (file)
index 0000000..1158c9b
--- /dev/null
@@ -0,0 +1,174 @@
+/*
+* 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 __SERVICE_ADAPTOR_TYPE_H__
+#define __SERVICE_ADAPTOR_TYPE_H__
+
+#include <stdio.h>
+#include "service-adaptor.h"
+#include "auth-adaptor.h"
+#include "contact-adaptor.h"
+#include "message-adaptor.h"
+#include "shop-adaptor.h"
+#include "storage-adaptor.h"
+#include "push-adaptor.h"
+
+#define service_adaptor_safe_free(p) safe_free((void**)&(p))
+
+#define SERVICE_ADAPTOR_OPERATION_PUSH_NOTI_TO_APPCONTROL "http://tizen.org/serviceadaptor/operation/v1/push"
+
+typedef struct _service_adaptor_context_info_s
+{
+       char *user_id;
+       char *app_id;
+       unsigned int service_id;
+       char *imsi;
+       char *duid;
+       char *msisdn;
+       char *access_token;
+       char *refresh_token;
+       void *property;
+} service_adaptor_context_info_s;
+
+typedef struct _service_adaptor_service_context_s
+{
+       char *service_name;             // com.serviceadaptor.service1
+       char *plugin_uri;
+
+       int authenticated;
+       int connected;
+
+       service_adaptor_context_info_s *context_info;
+
+       GMutex service_context_mutex;
+       GCond service_context_cond;
+       GHashTable *server_info;
+
+       auth_adaptor_plugin_context_h           auth_context;
+       contact_adaptor_plugin_context_h        contact_context;
+       message_adaptor_plugin_context_h        message_context;
+       shop_adaptor_plugin_context_h           shop_context;
+       storage_adaptor_plugin_context_h        storage_context;
+       push_adaptor_plugin_context_h           push_context;
+} service_adaptor_service_context_s;
+typedef struct _service_adaptor_service_context_s *service_adaptor_service_context_h;
+
+typedef struct _service_adaptor_s
+{
+       int started;
+
+       GMutex service_adaptor_mutex;
+       GCond service_adaptor_cond;
+
+       auth_adaptor_h                  auth_handle;
+       contact_adaptor_h               contact_handle;
+       message_adaptor_h               message_handle;
+       shop_adaptor_h                  shop_handle;
+       storage_adaptor_h               storage_handle;
+       push_adaptor_h                  push_handle;
+
+       auth_adaptor_listener_h         auth_listener;
+       contact_adaptor_listener_h      contact_listener;
+       message_adaptor_listener_h      message_listener;
+       shop_adaptor_listener_h         shop_listener;
+       storage_adaptor_listener_h      storage_listener;
+       push_adaptor_listener_h         push_listener;
+
+       GList *service_list;            // service_adaptor_service_context_h
+} service_adaptor_s;
+typedef struct _service_adaptor_s *service_adaptor_h;
+
+// Gets service adaptor handle
+service_adaptor_h service_adaptor_get_handle();
+
+service_adaptor_internal_error_code_e service_adaptor_init();
+void service_adaptor_deinit(service_adaptor_h service_adaptor);
+
+// Gets adaptor context
+service_adaptor_service_context_h service_adaptor_get_service_context(service_adaptor_h service_adaptor,
+                                               const char *service_name);
+
+GList *service_adaptor_get_services_by_plugin_uri(service_adaptor_h service_adaptor,
+                                               const char *plugin_uri);
+
+service_adaptor_internal_error_code_e service_adaptor_bind_context(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service_src,
+                                               service_adaptor_service_context_h service_dst);
+
+service_adaptor_internal_error_code_e service_adaptor_bind_storage_context(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service_src,
+                                               service_adaptor_service_context_h service_dst);
+
+service_adaptor_internal_error_code_e service_adaptor_bind_push_context(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service_src,
+                                               service_adaptor_service_context_h service_dst);
+
+// Create / Destroy adaptors (Internal function)
+service_adaptor_h service_adaptor_create();
+void service_adaptor_destroy(service_adaptor_h service_adaptor);
+
+// Connects / Disconnects adaptors
+service_adaptor_internal_error_code_e service_adaptor_connect(service_adaptor_h service_adaptor,
+                                               service_adaptor_context_info_s *context_info,
+                                               const char *service_name,
+                                               const char *plugin_uri,
+                                               const char *user_password,
+                                               const char *app_secret,
+                                               bool auth_enable,
+                                               bool storage_enable,
+                                               bool contact_enable,
+                                               bool message_enable,
+                                               bool push_enable,
+                                               bool shop_enable,
+                                               char *ret_msg);
+
+service_adaptor_internal_error_code_e service_adaptor_disconnect(service_adaptor_h service_adaptor,
+                                               const char *service_name);
+
+service_adaptor_internal_error_code_e service_adaptor_auth_refresh(service_adaptor_h service_adaptor,
+                                               const char *service_name,
+                                               const char *plugin_uri);
+
+service_adaptor_internal_error_code_e service_adaptor_auth_refresh_with_service_context(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service_context,
+                                               const char *plugin_uri);
+
+int service_adaptor_is_service_binded(service_adaptor_h service_adaptor,
+                                               const char *service_package_id);
+
+#ifdef SERVICE_ADAPTOR_DEBUG_CONTEXT
+void debug_service_context(GList *service_list);
+#endif
+
+typedef enum
+{
+       SA_TIME_CHECK_FLAG_AUTH,
+       SA_TIME_CHECK_FLAG_STORAGE,
+       SA_TIME_CHECK_FLAG_CONTACT,
+       SA_TIME_CHECK_FLAG_MESSAGE,
+       SA_TIME_CHECK_FLAG_PUSH,
+       SA_TIME_CHECK_FLAG_SHOP,
+}sa_time_check_flag_e;
+
+void SERVICE_ADAPTOR_API_TIME_CHECK_START();
+void SERVICE_ADAPTOR_API_TIME_CHECK_PAUSE();
+
+void SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_START(sa_time_check_flag_e flag);
+void SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_PAUSE(sa_time_check_flag_e flag);
+
+void SERVICE_ADAPTOR_API_TIME_CHECK_TOTAL_REPORT(const char *service_name);
+
+#endif /* __SERVICE_ADAPTOR_TYPE_H__ */
diff --git a/inc/service-adaptor.h b/inc/service-adaptor.h
new file mode 100644 (file)
index 0000000..d302a10
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+* 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 __SERVICE_ADAPTOR_H__
+#define __SERVICE_ADAPTOR_H__
+
+#include <stdbool.h>
+#include <glib.h>
+
+typedef enum
+{
+        SERVICE_ADAPTOR_INTERNAL_ERROR_NONE                     =  0,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_LAUNCH                    = 1,    /**< 1 ~ 99: internal error*/
+       SERVICE_ADAPTOR_INTERNAL_ERROR_INIT                      = 2,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_DEINIT                    = 3,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_CREATE                    = 4,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_DESTROY                   = 5,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_START                     = 6,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_STOP                      = 7,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_CONNECT                   = 8,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_DISCONNECT                = 9,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_FOUND                 = 10,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_CORRUPTED                 = 11,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_UNSUPPORTED               = 12,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_HANDLE            = 13,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT          = 14,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT_TYPE     = 15,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED            = 16,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_ADAPTOR_INTERNAL          = 17,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_PLUGIN_INTERNAL           = 18,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_SERVER_INTERNAL           = 19,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS                      = 20,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_CALLBACK_TIME_OUT         = 21,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_INTERNAL_MAX              = 99,
+       SERVICE_ADAPTOR_INTERNAL_ERROR_NO_DATA,
+        SERVICE_ADAPTOR_INTERNAL_ERROR_MAX
+
+} service_adaptor_internal_error_code_e;
+
+typedef enum
+{
+       SERVICE_ADAPTOR_INTERNAL_RESULT_SUCCEEDED               = 0,
+       SERVICE_ADAPTOR_INTERNAL_RESULT_FAILED                  = -1,
+       SERVICE_ADAPTOR_INTERNAL_RESULT_CANCELED                = -2,
+       SERVICE_ADAPTOR_INTERNAL_RESULT_MIN,
+
+} service_adaptor_internal_result_e;
+
+typedef enum
+{
+       SERVICE_ADAPTOR_INTERNAL_SIGNAL_NONE                     = 0,    /**< specifies status as none*/
+       SERVICE_ADAPTOR_INTERNAL_SIGNAL_INITIALIZED              = 1,    /**< specifies status as none*/
+       SERVICE_ADAPTOR_INTERNAL_SIGNAL_NEW_PLUGIN               = 2,    /**< specifies status as none*/
+       SERVICE_ADAPTOR_INTERNAL_SIGNAL_ACTIVATE_PLUGIN          = 3,    /**< specifies status as none*/
+       SERVICE_ADAPTOR_INTERNAL_SIGNAL_SHUTDOWN                 = 4,    /**< specifies status as none*/
+       SERVICE_ADAPTOR_INTERNAL_SIGNAL_OTHER                    = 99,   /**< specifies status as none*/
+       SERVICE_ADAPTOR_INTERNAL_SIGNAL_UNKNOWN                  = 999,  /**< specifies status as none*/
+       SERVICE_ADAPTOR_INTERNAL_SIGNAL_MAX,
+
+} service_adaptor_internal_signal_code_e;
+
+typedef struct service_adaptor_internal_error_s
+{
+       long long int code;
+       char *msg;
+
+} service_adaptor_internal_error_t;
+typedef struct service_adaptor_internal_error_s *service_adaptor_internal_error_h;
+
+typedef struct service_adaptor_internal_plugin_s
+{
+       char *name;
+       bool login;
+} service_adaptor_internal_plugin_t;
+typedef struct service_adaptor_internal_plugin_s *service_adaptor_internal_plugin_h;
+
+typedef int(*service_daptor_internal_signal_cb)(service_adaptor_internal_signal_code_e signal, char *msg);
+
+#endif /* __SERVICE_ADAPTOR_H__ */
diff --git a/inc/util/client_checker.h b/inc/util/client_checker.h
new file mode 100644 (file)
index 0000000..61e9c44
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+* 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 __CLIENT_CHECKER_H__
+#define __CLIENT_CHECKER_H__
+
+int client_checker_init(void);
+
+void client_checker_deinit(void);
+
+int client_checker_add_client(const char *service_handle_name, const char *cookie);
+
+int client_checker_del_client(const char *service_handle_name);
+
+int client_checker_check_privilege(const char *service_handle_name, const char *privilege);
+
+/**
+* @brief Checks raw level Smack access rights for client using security-server
+* @since_tizen 2.4
+*
+* @param[in]   service_handle_name     The client's unique ID. It related with security cookie
+* @param[in]   object                  The smack label of target object
+* @param[in]   access_rights           The smack's rights string (e.g. "rwxat")
+* @retval      0                       Success, Smack condition is satisfied
+* @retval      others                  Failed, Client needs additional rule
+*/
+int client_checker_check_access_rights(const char *service_handle_name, const char *object, const char *access_rights);
+
+/**
+* @brief Checks Smack read permission for client using security-server
+* @since_tizen 2.4
+*
+* @param[in]   service_handle_name     The client's unique ID. It related with security cookie
+* @param[in]   path                    The file path that will be access
+* @retval      0                       Success, Smack condition is satisfied
+* @retval      others                  Failed, Client needs additional rule
+*/
+int client_checker_check_access_right_read(const char *service_handle_name, const char *path);
+
+/**
+* @brief Checks Smack write permission for client using security-server
+* @since_tizen 2.4
+*
+* @param[in]   service_handle_name     The client's unique ID. It related with security cookie
+* @param[in]   path                    The file path that will be access
+* @retval      0                       Success, Smack condition is satisfied
+* @retval      others                  Failed, Client needs additional rule
+*/
+int client_checker_check_access_right_write(const char *service_handle_name, const char *path);
+
+/**
+* @brief Checks Smack file create permission for client using security-server
+* @since_tizen 2.4
+*
+* @param[in]   service_handle_name     The client's unique ID. It related with security cookie
+* @param[in]   path                    The file path that will be access
+* @retval      0                       Success, Smack condition is satisfied
+* @retval      others                  Failed, Client needs additional rule
+*/
+int client_checker_check_access_right_create(const char *service_handle_name, const char *path);
+
+const char *clieht_checker_get_last_error(void);
+
+#endif /* __CLIENT_CHECKER_H__ */
diff --git a/inc/util/service_file_manager.h b/inc/util/service_file_manager.h
new file mode 100644 (file)
index 0000000..0de9788
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+* 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 __SERVICE_FILE_MANAGER_H__
+#define __SERVICE_FILE_MANAGER_H__
+
+typedef enum
+{
+       SERVICE_FILE_DIRECTORY_AUTH     = (0x01 << 0),
+       SERVICE_FILE_DIRECTORY_STORAGE  = (0x01 << 1),
+       SERVICE_FILE_DIRECTORY_CONTACT  = (0x01 << 2),
+       SERVICE_FILE_DIRECTORY_MESSAGE  = (0x01 << 3),
+       SERVICE_FILE_DIRECTORY_SHOP     = (0x01 << 4),
+       SERVICE_FILE_DIRECTORY_PUSH     = (0x01 << 5),
+
+       SERVICE_FILE_DIRECTORY_SERVICES = (0x01 << 10) & 0x01,
+       SERVICE_FILE_DIRECTORY_PLUGINS  = (0x01 << 10) & 0x02,
+} service_file_directory_e;
+
+typedef enum
+{
+       SERVICE_FILE_SECTION_GENERAL    = 1,
+       SERVICE_FILE_SECTION_PUSH       = 2,
+       SERVICE_FILE_SECTION_BUS        = 3,
+} service_file_section_e;
+
+typedef struct _service_file_s *service_file_h;
+
+int service_file_get_list(service_file_directory_e directory, char ***file_names, int *len);
+
+int service_file_load(service_file_directory_e directory, const char *file_name, service_file_h *service_file);
+
+int service_file_get_string(service_file_h service_file, service_file_section_e section, const char *key, char **value);
+
+int service_file_unload(service_file_h service_file);
+
+#endif /* __SERVICE_FILE_MANAGER_H__ */
diff --git a/org.tizen.serviceadaptor.client.service.in b/org.tizen.serviceadaptor.client.service.in
new file mode 100644 (file)
index 0000000..9965bfe
--- /dev/null
@@ -0,0 +1,6 @@
+[D-BUS Service]
+Name=org.tizen.serviceadaptor.client
+Exec=/bin/false
+SystemdService=@SVC_FILE_TGT@
+User=system
+Group=system
diff --git a/packaging/org.tizen.serviceadaptor.client.conf b/packaging/org.tizen.serviceadaptor.client.conf
new file mode 100644 (file)
index 0000000..d575a9d
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+    <policy user="system">
+        <allow own="org.tizen.serviceadaptor.client"/>
+    </policy>
+    <policy context="default">
+        <allow send_destination="org.tizen.serviceadaptor.client"/>
+    </policy>
+</busconfig>
diff --git a/packaging/service-adaptor.service b/packaging/service-adaptor.service
new file mode 100644 (file)
index 0000000..2370de3
--- /dev/null
@@ -0,0 +1,20 @@
+[Unit]
+Description=Service Adaptor daemon
+Requires=dbus.socket
+After=dlog_logger.service tizen-runtime.target
+ConditionDirectoryNotEmpty=|/opt/share/service-adaptor/.push
+ConditionDirectoryNotEmpty=|/opt/share/service-adaptor/.fingerprint
+
+[Service]
+Type=dbus
+BusName=org.tizen.serviceadaptor.client
+User=system
+Group=system
+SmackProcessLabel=service-adaptor
+ExecStart=/usr/bin/service-adaptor
+Restart=on-failure
+RestartSec=0
+KillMode=none
+
+[Install]
+WantedBy=multi-user.target
diff --git a/packaging/service-adaptor.spec b/packaging/service-adaptor.spec
new file mode 100644 (file)
index 0000000..507b01d
--- /dev/null
@@ -0,0 +1,103 @@
+Name:       service-adaptor
+Summary:    Service Adaptor
+Version:    1.0.1
+Release:    1
+Group:      Social & Content
+License:    Apache-2.0
+Source0:    %{name}-%{version}.tar.gz
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(gobject-2.0)
+BuildRequires:  pkgconfig(gio-2.0)
+BuildRequires:  pkgconfig(gthread-2.0)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(auth-adaptor)
+BuildRequires:  pkgconfig(push-adaptor)
+BuildRequires:  pkgconfig(contact-adaptor)
+BuildRequires:  pkgconfig(storage-adaptor)
+BuildRequires:  pkgconfig(message-adaptor)
+BuildRequires:  pkgconfig(shop-adaptor)
+BuildRequires:  pkgconfig(capi-base-common)
+BuildRequires:  pkgconfig(capi-appfw-application)
+BuildRequires:  pkgconfig(capi-appfw-app-manager)
+BuildRequires:  pkgconfig(capi-appfw-package-manager)
+BuildRequires:  pkgconfig(libsmack)
+BuildRequires:  pkgconfig(security-server)
+BuildRequires:  pkgconfig(bundle)
+BuildRequires:  capi-appfw-application-devel
+BuildRequires:  auth-adaptor-devel
+BuildRequires:  push-adaptor-devel
+BuildRequires:  storage-adaptor-devel
+BuildRequires:  contact-adaptor-devel
+BuildRequires: message-adaptor-devel
+BUildRequires: shop-adaptor-devel
+BuildRequires:  cmake
+
+BuildRequires:  pkgconfig(plugin-config)
+
+%define systemd_service_file_src       service-adaptor.service
+%if "%{?tizen_profile_name}" == "tv"
+%define systemd_service_file_tgt       service-adaptor.service
+%else
+%define systemd_service_file_tgt       service-adaptor.service
+%endif
+
+
+%description
+Service Adaptation
+
+%package -n service-adaptor-devel
+Summary:    Headers for service adaptor
+Group:      Development/Libraries
+Requires:   service-adaptor = %{version}-%{release}
+
+%description -n service-adaptor-devel
+This package contains the header and pc files.
+
+%prep
+%setup -q
+
+%build
+export PREFIX="/usr"
+export EXECUTABLE="service-adaptor"
+
+cmake . -DCMAKE_INSTALL_PREFIX="$PREFIX" -DVERSION=%{version} -DPACKAGE_NAME=%{name} -DEXECUTABLE_NAME="$EXECUTABLE" \
+       -DCMAKE_SVC_FILE_SRC=%{systemd_service_file_src} -DCMAKE_SVC_FILE_TGT=%{systemd_service_file_tgt}
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants
+ln -s %{_libdir}/systemd/system/%{systemd_service_file_tgt} %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/%{systemd_service_file_tgt}
+mkdir -p %{buildroot}/etc/dbus-1/system.d
+install -m 0644 packaging/org.tizen.serviceadaptor.client.conf %{buildroot}/etc/dbus-1/system.d/org.tizen.serviceadaptor.client.conf
+
+mkdir -p %{buildroot}/opt/share/service-adaptor
+mkdir -p %{buildroot}/opt/share/service-adaptor/services
+mkdir -p %{buildroot}/opt/share/service-adaptor/plugins
+mkdir -p %{buildroot}/opt/share/service-adaptor/auth
+mkdir -p %{buildroot}/opt/share/service-adaptor/.push
+mkdir -p %{buildroot}/opt/share/service-adaptor/.fingerprint
+
+%files
+%manifest service-adaptor.manifest
+%defattr(-,system,system,-)
+%{_bindir}/service-adaptor
+%attr(755,system,system) %{_bindir}/service-adaptor
+%attr(644,root,root) %{_libdir}/systemd/system/%{systemd_service_file_tgt}
+%attr(644,root,root) %{_libdir}/systemd/system/multi-user.target.wants/%{systemd_service_file_tgt}
+%attr(644,root,root) %{_datadir}/dbus-1/system-services/org.tizen.serviceadaptor.client.service
+%attr(644,root,root) /etc/dbus-1/system.d/org.tizen.serviceadaptor.client.conf
+
+%attr(755,root,root) /opt/share/service-adaptor
+%attr(755,root,root) /opt/share/service-adaptor/services
+%attr(770,system,app) /opt/share/service-adaptor/plugins
+%attr(770,system,app) /opt/share/service-adaptor/auth
+%attr(750,system,root) /opt/share/service-adaptor/.push
+%attr(770,system,app) /opt/share/service-adaptor/.fingerprint
+
+%files -n service-adaptor-devel
+%defattr(-,root,root,-)
+%{_includedir}/service-adaptor/*.h
+%{_libdir}/pkgconfig/service-adaptor.pc
diff --git a/service-adaptor.manifest.in b/service-adaptor.manifest.in
new file mode 100644 (file)
index 0000000..dc54d41
--- /dev/null
@@ -0,0 +1,58 @@
+<manifest>
+       <define>
+               <domain name="service-adaptor" />
+               <permit>
+                       <smack permit="system::use_internet" type="w" />
+                       <smack permit="crash-worker" type="rwxat"/>
+                       <smack permit="media-server" type="rwx"/>
+                       <smack permit="net-config" type="rwx"/>
+                       <smack permit="connman" type="rwx"/>
+
+                       <smack permit="push-service" type="rw"/>
+               </permit>
+               <request>
+                       <smack request="system::use_internet" type="rw"/>
+                       <smack request="system::media" type="rwxt"/>
+                       <smack request="device::app_logging" type="rwx"/>
+                       <smack request="device::sys_logging" type="rwx"/>
+                       <smack request="pkgmgr::db" type="rxw"/>
+                       <smack request="pkgmgr::info" type="rxw"/>
+                       <smack request="aul::launch" type="rxw"/>
+                       <smack request="aul::terminate" type="rxw"/>
+                       <smack request="xorg" type="rw"/>
+                       <smack request="media-server" type="rwxt"/>
+                       <smack request="tizen::vconf::setting::admin" type="rxw"/>
+                       <smack request="media-data::db" type="rxwl"/>
+                       <smack request="system::ext_storage" type="rxwat"/>
+                       <smack request="sys-assert::core" type="rwxat"/>
+                       <smack request="security-server::api-cookie-check" type="w"/>
+                       <smack request="privilege::tizen::packagemanager.info" type="rw"/>
+                       <smack request="connman" type="rwx"/>
+
+                       <smack request="unifiedstorage-fs" type="rwxt"/>
+
+                       <smack request="push-service" type="rw"/>
+                       <smack request="push-service::push" type="w"/>
+                       <smack request="contacts-agent::svc" type="rwxt"/>
+                       <smack request="contacts-service" type="rwxt"/>
+                       <smack request="contacts-service::svc" type="rwxt"/>
+                       <smack request="msg-service" type="rwxt"/>
+                       <smack request="system::homedir" type="x"/>
+               </request>
+       </define>
+       <assign>
+               <filesystem path="/usr/share/dbus-1/system-services/org.tizen.serviceadaptor.client.service" label="_"/>
+               <filesystem path="/usr/lib/systemd/system/@SVC_FILE_TGT@" label="_"/>
+               <filesystem path="/etc/dbus-1/system.d/org.tizen.serviceadaptor.client.conf" label="_"/>
+               <filesystem path="/opt/share/service-adaptor" label="_"/>
+               <filesystem path="/opt/share/service-adaptor/services" label="_"/>
+               <filesystem path="/opt/share/service-adaptor/auth" label="service-adaptor" type="transmutable"/>
+               <filesystem path="/opt/share/service-adaptor/plugins" label="service-adaptor" type="transmutable"/>
+               <filesystem path="/opt/share/service-adaptor/.push" label="service-adaptor" type="transmutable"/>
+               <filesystem path="/opt/share/service-adaptor/.fingerprint" label="*" type="transmutable"/>
+       </assign>
+       <request>
+               <domain name="service-adaptor" />
+       </request>
+</manifest>
+
diff --git a/service-adaptor.pc.in b/service-adaptor.pc.in
new file mode 100644 (file)
index 0000000..4c195e1
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=@PREFIX@
+libdir=@PREFIX@/lib
+includedir=@PREFIX@/include
+
+Name: @PACKAGE_NAME@
+Description: Service Adaptor
+
+Requires: glib-2.0 gobject-2.0 gio-2.0 gthread-2.0 auth-adaptor storage-adaptor
+Version: @VERSION@
+
+Libs: -L${libdir}
+Cflags: -I${includedir}/service-adaptor
diff --git a/src/dbus/dbus-auth-adaptor.c b/src/dbus/dbus-auth-adaptor.c
new file mode 100644 (file)
index 0000000..17f8ddc
--- /dev/null
@@ -0,0 +1,730 @@
+/*
+* 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 <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <unistd.h>
+
+#include "service-adaptor.h"
+#include "service-adaptor-auth.h"
+#include "service-adaptor-push.h"
+#include "service-adaptor-storage.h"
+#include "service-adaptor-message.h"
+#include "service-adaptor-type.h"
+#include "service-adaptor-log.h"
+#include "dbus-auth-adaptor.h"
+#include "dbus-server.h"
+#include "dbus-util.h"
+#include "util/client_checker.h"
+
+#include <bundle.h>
+
+#define AUTH_FLAG      (0x01 << 0)
+#define STORAGE_FLAG   (0x01 << 1)
+#define RET_MSG_LEN    2048
+#define __SAFE_STRDUP(x)       (x) ? strdup(x) : strdup("")
+#define __init_context_info_s(x)       do { \
+                                               (x).user_id = NULL; \
+                                               (x).app_id = NULL; \
+                                               (x).service_id = 0U; \
+                                               (x).imsi = NULL; \
+                                               (x).duid = NULL; \
+                                               (x).msisdn = NULL; \
+                                               (x).access_token = NULL; \
+                                               (x).refresh_token = NULL; \
+                                               (x).property = NULL; \
+                                       } while (0)
+
+#define _PLUGIN_PROPERTY_KEY_BASE      "http://tizen.org/service-adaptor/plugin/property/"
+
+void auth_adaptor_method_call(GDBusConnection *connection,
+                                               const gchar *sender,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *method_name,
+                                               GVariant *parameters,
+                                               GDBusMethodInvocation *invocation,
+                                               gpointer user_data)
+{
+FUNC_START();
+       service_adaptor_internal_error_code_e ret_code = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       char ret_msg[RET_MSG_LEN] = {0, };
+
+/************************************************************************
+ *
+ *                        private feature
+ */
+
+       if (0 == g_strcmp0(method_name, PRIVATE_DBUS_GET_AUTH_PLUGIN_LIST_METHOD)) {
+               service_adaptor_debug_func("Auth API : get_auth_plugin_list Called");
+               GList *plugin_list = NULL;
+               GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+               char *imsi = ipc_g_variant_dup_string(in_parameters);
+
+               GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE(private_plugin_list_type));
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               auth_adaptor_h adaptor = service_adaptor_get_auth_adaptor(service_adaptor);
+
+FUNC_STEP();
+               if (NULL == adaptor) {
+                       ret_code = SERVICE_ADAPTOR_INTERNAL_ERROR_INIT;
+                       snprintf(ret_msg, RET_MSG_LEN, "Not Initialized");
+
+                       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_plugin_list_type), builder, (uint64_t) ret_code, ret_msg);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       g_variant_builder_unref(builder);
+                       free(imsi);
+                       return;
+               }
+
+               service_adaptor_debug_func("get auth plugins");
+               plugin_list = auth_adaptor_get_plugins(adaptor);
+
+FUNC_STEP();
+               for (GList *list = g_list_first(plugin_list); list != NULL; list = g_list_next(list)) {
+                       auth_adaptor_plugin_h auth_plugin = (auth_adaptor_plugin_h) list->data;
+
+                       bool is_login = false;
+
+                       auth_adaptor_plugin_context_h auth_context =
+                                       auth_adaptor_create_plugin_context(auth_plugin, "", "", "", "", imsi, "is_auth_checker");
+
+FUNC_STEP();
+                       if (NULL == auth_context) {
+                               service_adaptor_error("Could not create auth plugin context");
+                               ret_code = SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_FOUND;
+                               snprintf(ret_msg, RET_MSG_LEN, "Could not create auth plugin context");
+                               continue;
+                       }
+
+                       int is_auth = -1;
+
+                       auth_adaptor_error_code_h error_code = NULL;
+                       service_adaptor_debug_func("call is_auth");
+                       ret_code = auth_adaptor_is_auth(auth_plugin, auth_context, NULL, &is_auth, &error_code, NULL);
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                               ret_code = SERVICE_ADAPTOR_INTERNAL_ERROR_CREATE;
+                               service_adaptor_error("Is_auth Function Internal error : %d", ret_code);
+
+                               if ((NULL != error_code) && (NULL != error_code->msg)) {
+                                       service_adaptor_error("[%lld] %s", error_code->code, error_code->msg);
+                               }
+                       }
+                       auth_adaptor_destroy_error_code(&error_code);
+                       auth_adaptor_destroy_plugin_context(auth_plugin, auth_context);
+                       auth_context = NULL;
+
+                       service_adaptor_debug_func("auth_plugins : is_auth(%d)", is_auth);
+                       if (1 == is_auth) {
+                               is_login = true;
+                       }
+
+/*                     int plugin_count = 1; */
+/*                     char *plugin_uri = NULL; */
+
+/*                     auth_adaptor_get_plugin_uri(auth_plugin, &plugin_uri); */
+
+                       service_adaptor_debug_func("wrapping auth_plugins");
+                       /*For product */
+
+                       g_variant_builder_open(builder, G_VARIANT_TYPE(private_service_adaptor_plugin_s_type));
+                       safe_g_variant_builder_add_string(builder, "CONTACT");
+                       g_variant_builder_add(builder, "b", is_login);
+                       g_variant_builder_close(builder);
+
+                       g_variant_builder_open(builder, G_VARIANT_TYPE(private_service_adaptor_plugin_s_type));
+                       safe_g_variant_builder_add_string(builder, "MESSAGE");
+                       g_variant_builder_add(builder, "b", is_login);
+                       g_variant_builder_close(builder);
+
+                       g_variant_builder_open(builder, G_VARIANT_TYPE(private_service_adaptor_plugin_s_type));
+                       safe_g_variant_builder_add_string(builder, "SHOP");
+                       g_variant_builder_add(builder, "b", is_login);
+                       g_variant_builder_close(builder);
+
+                       g_variant_builder_open(builder, G_VARIANT_TYPE(private_service_adaptor_plugin_s_type));
+                       safe_g_variant_builder_add_string(builder, "SPP");
+                       g_variant_builder_add(builder, "b", is_login);
+                       g_variant_builder_close(builder);
+
+                       g_variant_builder_open(builder, G_VARIANT_TYPE(private_service_adaptor_plugin_s_type));
+                       safe_g_variant_builder_add_string(builder, "ORS");
+                       g_variant_builder_add(builder, "b", is_login);
+                       g_variant_builder_close(builder);
+
+
+                       /*
+                       for (int i = 0; i < plugin_count; i++) {
+                               plugin->name = plugin_uri;
+
+                               g_variant_builder_open(builder, G_VARIANT_TYPE(private_service_adaptor_plugin_s_type));
+
+                               safe_g_variant_builder_add_string(builder, plugin->name);
+                               g_variant_builder_add(builder, "b", plugin->login);
+
+                               g_variant_builder_close(builder);
+                       }
+                       */
+
+                       ret_code = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+               }
+
+               if (NULL == plugin_list) {
+                       FUNC_STEP();
+                       ret_code = SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_FOUND;
+                       snprintf(ret_msg, RET_MSG_LEN, "No Plugin");
+               }
+
+               GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_plugin_list_type), builder, (uint64_t) ret_code, ret_msg);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               g_variant_builder_unref(builder);
+               free(imsi);
+               g_list_free(plugin_list);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_SET_AUTH_METHOD)) {
+               SERVICE_ADAPTOR_API_TIME_CHECK_START();
+               service_adaptor_debug_func("Auth API : set_auth Called");
+
+               GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+               GVariant *req_struct[private_service_adaptor_set_auth_s_type_length];
+
+               for (size_t j = 0; j < private_service_adaptor_set_auth_s_type_length; j++) {
+                       req_struct[j] = g_variant_get_child_value(in_parameters, j);
+               }
+
+               int idx = 0;
+               char *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+               char *imsi = ipc_g_variant_dup_string(req_struct[idx++]);
+               char *cluster_name = ipc_g_variant_dup_string(req_struct[idx++]);
+               char *app_id = g_variant_dup_string(req_struct[idx++], NULL);
+               char *app_secret = g_variant_dup_string(req_struct[idx++], NULL);
+               char *user_id = g_variant_dup_string(req_struct[idx++], NULL);
+               char *user_password = g_variant_dup_string(req_struct[idx++], NULL);
+               unsigned int service_id = g_variant_get_uint32(req_struct[idx++]);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+
+               service_adaptor_debug("Disconnects service [%s] if same context is already binded", service_name);
+               service_adaptor_disconnect(service_adaptor, service_name);
+
+               /* Private (Coreapps) specfic */
+               bool auth = true, storage = false, contact = false, message = false, push = false, shop = false;
+               if (NULL != cluster_name) {
+                       if (0 == strncmp(cluster_name, "CONTACT", strlen("CONTACT"))) {
+                               auth = true;
+                               contact = true;
+                               storage = true;
+                               push = true;
+                       }
+                       if (0 == strncmp(cluster_name, "MESSAGE", strlen("MESSAGE"))) {
+                               auth = true;
+                               message = true;
+                               storage = true;
+                               push = true;
+                       }
+                       if (0 == strncmp(cluster_name, "ORS", strlen("ORS"))) {
+                               auth = true;
+                               push = true;
+                       }
+                       if (0 == strncmp(cluster_name, "SHOP", strlen("SHOP"))) {
+                               auth = true;
+                               shop = true;
+                       }
+               }
+
+               service_adaptor_debug_func("[For CoreApps service] create SPP context");
+               char push_service_name[1024] = {0, };
+               snprintf(push_service_name, 1024, "preloaded_service/plugin='%s'&app_id='%s'",
+                               "com.samsung.coreapps", "82e51a05286942d1");
+
+               service_adaptor_service_context_h service_spp = NULL;
+               if (push) {
+                       service_spp = service_adaptor_get_service_context(service_adaptor, push_service_name);
+
+                       if (NULL == service_spp) {
+                               service_adaptor_debug("[For CoreApps service] Connect push service");
+                               /* default service (push: spp) */
+                               service_adaptor_context_info_s spp_context_info;
+                               __init_context_info_s(spp_context_info);
+
+                               spp_context_info.user_id = "";
+                               spp_context_info.app_id = "82e51a05286942d1";
+                               spp_context_info.imsi = imsi ? imsi : "";
+                               spp_context_info.service_id = service_id;
+
+                               ret_code = service_adaptor_connect(service_adaptor, &spp_context_info, push_service_name,
+                                               "com.samsung.coreapps", "", "",
+                                               false, false, false, false, true, false,
+                                               ret_msg);
+
+                               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                                       FUNC_STEP();
+                                       service_adaptor_warning("Cannot Connect %s Plugin", cluster_name);
+                               }
+                       } else {
+                               service_adaptor_debug_func("[For CoreApps service] get Lagecy SPP context (try reconnect)");
+                               ret_code = service_adaptor_reconnect_push_plugin(service_adaptor, service_spp);
+                               service_adaptor_debug_func("re-connect ret (%d)", ret_code);
+                       }
+               }
+
+               /* default service (core apps) */
+               service_adaptor_debug_func("[For CoreApps service] create CoreApps context");
+               service_adaptor_context_info_s orca_context_info;
+               __init_context_info_s(orca_context_info);
+
+               orca_context_info.app_id = app_id;
+               orca_context_info.user_id = user_id;
+               orca_context_info.imsi = imsi ? imsi : "";
+               orca_context_info.service_id = service_id;
+
+               ret_code = service_adaptor_connect(service_adaptor, &orca_context_info, service_name,
+                               "com.samsung.coreapps", user_password, app_secret,
+                               auth, storage, contact, message, false, shop,
+                               ret_msg);
+
+
+               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                       if (0 >= strlen(ret_msg)) {
+                               snprintf(ret_msg, RET_MSG_LEN, "Cannot Connect Plugin <Cluster : %s> (Please see plugin's Dlog)", cluster_name);
+                       }
+                       service_adaptor_error("set_auth failed : %d <service_name : %s>", (int)ret_code, service_name);
+               } else {
+                       service_adaptor_info("set_auth success <service_name : %s>", service_name);
+               }
+
+               service_spp = service_adaptor_get_service_context(service_adaptor, push_service_name);
+
+               service_adaptor_debug_func("[For CoreApps service] bind push context");
+               service_adaptor_service_context_h service_orca =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if ((NULL != service_spp) && (NULL != service_orca)) {
+                       FUNC_STEP();
+                       service_adaptor_bind_push_context(service_adaptor, service_spp, service_orca);
+               }
+
+               for (size_t j = 0; j < private_service_adaptor_set_auth_s_type_length; j++) {
+                       g_variant_unref(req_struct[j]);
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) ret_code, ret_msg));
+               SERVICE_ADAPTOR_API_TIME_CHECK_PAUSE();
+               SERVICE_ADAPTOR_API_TIME_CHECK_TOTAL_REPORT(service_name);
+
+               free(service_name);
+               free(imsi);
+               free(cluster_name);
+               free(app_id);
+               free(app_secret);
+               free(user_id);
+               free(user_password);
+       } else if (0 == g_strcmp0(method_name, DBUS_GET_AUTH_PLUGIN_LIST_METHOD)) {
+/*
+ *                       private feature
+ *
+ ***********************************************************************/
+
+/************************************************************************
+ *
+ *                        public feature
+ */
+               service_adaptor_debug("[START] Get Auth Plugin List");
+
+               GList *auth_plugin_list = NULL;
+               GList *storage_plugin_list = NULL;
+               GHashTable *plugin_list = g_hash_table_new_full(g_str_hash, g_str_equal, free, NULL);
+               service_adaptor_debug_func("hash table init (for sorting plugin list)");
+
+               GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE(plugin_list_type));
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               auth_adaptor_h auth_adaptor = service_adaptor_get_auth_adaptor(service_adaptor);
+               storage_adaptor_h storage_adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+
+               service_adaptor_debug_func("adaptors get. service_adaptor(%p) auth_adaptor(%p) storage_adaptor(%p)",
+                               service_adaptor, auth_adaptor, storage_adaptor);
+
+               if ((NULL == auth_adaptor) && (NULL == storage_adaptor)) {
+                       ret_code = SERVICE_ADAPTOR_INTERNAL_ERROR_INIT;
+                       snprintf(ret_msg, RET_MSG_LEN, "Not Initialized");
+                       service_adaptor_warning("Could not get adaptors");
+
+                       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(plugin_list_type), builder, (uint64_t) ret_code, ret_msg);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       g_variant_builder_unref(builder);
+                       return;
+               }
+
+               int installed_flag = 0;
+
+               auth_plugin_list = auth_adaptor_get_plugins(auth_adaptor);
+               for (GList *list = g_list_first(auth_plugin_list); list != NULL; list = g_list_next(list)) {
+                       auth_adaptor_plugin_h auth_plugin = (auth_adaptor_plugin_h) list->data;
+                       char *uri = NULL;
+                       auth_adaptor_get_plugin_uri(auth_plugin, &uri);
+                       service_adaptor_debug_func("auth plugin uri(%s)", uri);
+                       if (uri) {
+                               installed_flag = (int)g_hash_table_lookup(plugin_list, (gconstpointer)(uri));
+                               g_hash_table_insert(plugin_list, (void *)(uri), (void *)(installed_flag | AUTH_FLAG));
+                       } else {
+                               service_adaptor_error("Auth plugin URI is NULL");
+                       }
+               }
+
+               storage_plugin_list = storage_adaptor_get_plugins(storage_adaptor);
+               for (GList *list = g_list_first(storage_plugin_list); list != NULL; list = g_list_next(list)) {
+                       storage_adaptor_plugin_h storage_plugin = (storage_adaptor_plugin_h) list->data;
+                       char *uri = NULL;
+                       storage_adaptor_get_plugin_uri(storage_plugin, &uri);
+                       service_adaptor_debug_func("storage plugin uri(%s)", uri);
+                       if (uri) {
+                               installed_flag = (int)g_hash_table_lookup(plugin_list, (gconstpointer)(uri));
+                               g_hash_table_insert(plugin_list, (gpointer)(uri), (gpointer)(installed_flag | STORAGE_FLAG));
+                       } else {
+                               service_adaptor_error("Storage plugin URI is NULL");
+                       }
+               }
+
+               g_list_free(auth_plugin_list);
+               auth_plugin_list = NULL;
+               g_list_free(storage_plugin_list);
+               storage_plugin_list = NULL;
+
+               int plugin_uri_count = 0;
+               GHashTableIter iter;
+               gpointer key;
+               gpointer value;
+               g_hash_table_iter_init(&iter, plugin_list);
+               while (g_hash_table_iter_next(&iter, &key, &value)) {
+                       service_adaptor_debug_func("total plugin uri(%s) mask(%d)", (char *)key, (int)value);
+                       g_variant_builder_open(builder, G_VARIANT_TYPE(service_adaptor_plugin_s_type));
+
+                       safe_g_variant_builder_add_string(builder, (char *)key);
+                       g_variant_builder_add(builder, "i", (int)value);
+
+                       g_variant_builder_close(builder);
+                       plugin_uri_count++;
+               }
+
+               if (0 == plugin_uri_count) {
+                       service_adaptor_debug_func("total plugin count (0)");
+/*                     ret_code = SERVICE_ADAPTOR_INTERNAL_ERROR_NO_DATA; */
+/*                     strncpy(ret_msg, "No Plugin"); */
+               }
+
+               GVariant *response = g_variant_new(MAKE_RETURN_TYPE(plugin_list_type), builder, (uint64_t) ret_code, ret_msg);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               g_variant_builder_unref(builder);
+               service_adaptor_debug("[End] Get Auth Plugin List");
+       } else if (0 == g_strcmp0(method_name, DBUS_SET_AUTH_METHOD)) {
+               service_adaptor_debug("[START] Start Plugin");
+               GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+               GVariant *req_struct[service_adaptor_set_auth_s_type_length];
+
+               for (size_t j = 0; j < service_adaptor_set_auth_s_type_length; j++) {
+                       req_struct[j] = g_variant_get_child_value(in_parameters, j);
+               }
+
+               int idx = 0;
+
+               char security_cookie[21] = {0, };
+               gsize cookie_cnt = g_variant_n_children(req_struct[idx]);
+               service_adaptor_info("cookie count : %d", cookie_cnt);
+               /*service_adaptor_info("cookie : ");*/
+               for (int i = 0; i < cookie_cnt; i++) {
+                       g_variant_get_child(req_struct[idx], i, "(y)", &(security_cookie[i]));
+                       /*service_adaptor_debug_func("%c", security_cookie[i]);*/
+               }
+
+               idx++;
+
+               unsigned char *raw_data = NULL;
+               int raw_data_len = (int) g_variant_n_children(req_struct[idx]);
+               service_adaptor_info("raw data len : %d", raw_data_len);
+               raw_data = (unsigned char *) calloc(raw_data_len, sizeof(unsigned char));
+               bundle *plugin_property = NULL;
+               if (NULL != raw_data) {
+                       for (int i = 0; i < raw_data_len; i++) {
+                               g_variant_get_child(req_struct[idx], i, "(y)", &(raw_data[i]));
+                       }
+                       plugin_property = bundle_decode(raw_data, raw_data_len);
+               }
+               idx++;
+
+               char *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+               char *plugin_uri = ipc_g_variant_dup_string(req_struct[idx++]);
+               char *app_id = ipc_g_variant_dup_string(req_struct[idx++]);
+               char *app_secret = ipc_g_variant_dup_string(req_struct[idx++]);
+               char *user_id = ipc_g_variant_dup_string(req_struct[idx++]);
+               char *user_password = ipc_g_variant_dup_string(req_struct[idx++]);
+               int enable_mask = g_variant_get_int32(req_struct[idx++]);
+
+               service_adaptor_debug("security cookie : %s", security_cookie);
+               service_adaptor_debug("service name : %s", service_name);
+               service_adaptor_debug("plugin_uri : %s", plugin_uri);
+               service_adaptor_debug_func("app_id : %s", app_id);
+               service_adaptor_debug_func("app_secret : %s", app_secret);
+               service_adaptor_debug_func("user_id : %s", user_id);
+               service_adaptor_debug_func("user_password : %s", user_password);
+               service_adaptor_debug("enable mask : %d", enable_mask);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+
+               service_adaptor_service_context_h service =
+                       service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if ((NULL != service) && (NULL != service->service_name) &&
+                               (0 == strncmp(service->service_name, service_name ? service_name : "", strlen(service->service_name)))) {
+                       service_adaptor_debug("Disconnect context for same service_name (%s)", service_name);
+                       service_adaptor_disconnect(service_adaptor, service_name);
+                       service = NULL;
+               }
+
+               service_adaptor_context_info_s new_context_info;
+               __init_context_info_s(new_context_info);
+
+               new_context_info.app_id = app_id;
+               new_context_info.user_id = user_id;
+               new_context_info.property = plugin_property;
+
+               bool auth_enable = (enable_mask & AUTH_FLAG) ? true : false;
+               bool storage_enable = (enable_mask & STORAGE_FLAG) ? true : false;
+
+               ret_code = service_adaptor_connect(service_adaptor, &new_context_info, service_name,
+                               plugin_uri, user_password, app_secret, auth_enable, storage_enable, false, false, false, false, ret_msg);
+               service_adaptor_debug("Called service_adaptor_connect (ret : %d)", ret_code);
+
+               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                       snprintf(ret_msg, RET_MSG_LEN,  "Cannot Connect %s Plugin", plugin_uri);
+                       ret_code = SERVICE_ADAPTOR_INTERNAL_ERROR_CONNECT;
+               } else {
+                       service_adaptor_debug("Adds security cookie to client_checker (%d)",
+                                       client_checker_add_client(service_name, security_cookie));
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) ret_code, ret_msg));
+               service_adaptor_debug("[End] Start Plugin");
+
+               free(service_name);
+               free(plugin_uri);
+               free(app_id);
+               free(app_secret);
+               free(user_id);
+               free(user_password);
+               free(raw_data);
+
+               free(new_context_info.imsi);
+               free(new_context_info.duid);
+               free(new_context_info.msisdn);
+               free(new_context_info.access_token);
+               free(new_context_info.refresh_token);
+       } else if ((0 == g_strcmp0(method_name, DBUS_IS_AUTH_METHOD)) || (0 == g_strcmp0(method_name, DBUS_JOIN_METHOD))) {
+               service_adaptor_debug("[START] Is auth / join");
+               GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+               GVariant *req_struct[service_adaptor_is_auth_req_s_type_length];
+
+               for (size_t j = 0; j < service_adaptor_is_auth_req_s_type_length; j++) {
+                       req_struct[j] = g_variant_get_child_value(in_parameters, j);
+               }
+
+               int idx = 0;
+               char *plugin_uri = ipc_g_variant_dup_string(req_struct[idx++]);
+               char *user_id = NULL;
+               char *user_pw = NULL;
+               char *app_key = NULL;
+               char *app_secret = NULL;
+               char *imsi = NULL;
+               char *device_id = NULL;
+               char *service_name = "login_checker";
+
+               unsigned char *raw_data = NULL;
+               int raw_data_len = (int) g_variant_n_children(req_struct[idx]);
+               service_adaptor_info("raw data len : %d", raw_data_len);
+               raw_data = (unsigned char *) calloc(raw_data_len, sizeof(unsigned char));
+               if (NULL != raw_data) {
+                       for (int i = 0; i < raw_data_len; i++) {
+                               g_variant_get_child(req_struct[idx], i, "(y)", &(raw_data[i]));
+                       }
+                       bundle *bd = bundle_decode(raw_data, raw_data_len);
+                       if (bd) {
+                               char *str = NULL;
+                               if (!bundle_get_str(bd, _PLUGIN_PROPERTY_KEY_BASE"user_id", &str)) {
+                                       if (str) {
+                                               user_id = strdup(str);
+                                       }
+                               }
+                               str = NULL;
+                               if (!bundle_get_str(bd, _PLUGIN_PROPERTY_KEY_BASE"user_pw", &str)) {
+                                       if (str) {
+                                               user_pw = strdup(str);
+                                       }
+                               }
+                               str = NULL;
+                               if (!bundle_get_str(bd, _PLUGIN_PROPERTY_KEY_BASE"app_key", &str)) {
+                                       if (str) {
+                                               app_key = strdup(str);
+                                       }
+                               }
+                               str = NULL;
+                               if (!bundle_get_str(bd, _PLUGIN_PROPERTY_KEY_BASE"app_secret", &str)) {
+                                       if (str) {
+                                               app_secret = strdup(str);
+                                       }
+                               }
+                               str = NULL;
+                               if (!bundle_get_str(bd, _PLUGIN_PROPERTY_KEY_BASE"imsi", &str)) {
+                                       if (str) {
+                                               imsi = strdup(str);
+                                       }
+                               }
+                               str = NULL;
+                               if (!bundle_get_str(bd, _PLUGIN_PROPERTY_KEY_BASE"device_id", &str)) {
+                                       if (str) {
+                                               device_id = strdup(str);
+                                       }
+                               }
+                               str = NULL;
+                               bundle_free(bd);
+                               bd = NULL;
+                       }
+                       free(raw_data);
+               }
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               auth_adaptor_h auth_adaptor = service_adaptor_get_auth_adaptor(service_adaptor);
+               auth_adaptor_plugin_h auth_plugin = auth_adaptor_get_plugin_by_name(auth_adaptor, plugin_uri);
+               auth_adaptor_plugin_context_h auth_context =
+                               auth_adaptor_create_plugin_context(auth_plugin, user_id, user_pw, app_key, app_secret, imsi, service_name);
+
+               auth_adaptor_error_code_h error = NULL;
+               if (0 == g_strcmp0(method_name, DBUS_IS_AUTH_METHOD)) {
+                       int _is_auth = 0;
+                       service_adaptor_debug("try auth_adaptor_is_auth");
+                       ret_code = auth_adaptor_is_auth(auth_plugin, auth_context, NULL, &_is_auth, &error, NULL);
+                       if (ret_code) {
+                               if (error) {
+                                       ret_code = error->code;
+                                       snprintf(ret_msg, RET_MSG_LEN,  "%s", error->msg);
+                               } else {
+                                       snprintf(ret_msg, RET_MSG_LEN,  "No error detailed");
+                               }
+                       }
+                       GVariant *response = g_variant_new(MAKE_RETURN_TYPE("(b)"), (_is_auth ? true : false), (uint64_t)ret_code, ret_msg);
+                       g_dbus_method_invocation_return_value(invocation, response);
+               } else {
+                       service_adaptor_debug("try auth_adaptor_join");
+                       ret_code = auth_adaptor_join(auth_plugin, auth_context, device_id, NULL, &error, NULL);
+                       if (ret_code) {
+                               if (error) {
+                                       ret_code = error->code;
+                                       snprintf(ret_msg, RET_MSG_LEN,  "%s", error->msg);
+                               } else {
+                                       snprintf(ret_msg, RET_MSG_LEN,  "No error detailed");
+                               }
+                       }
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t)ret_code, ret_msg));
+               }
+               auth_adaptor_destroy_error_code(&error);
+               auth_adaptor_destroy_plugin_context(auth_plugin, auth_context);
+               auth_context = NULL;
+
+               free(plugin_uri);
+               free(user_id);
+               free(user_pw);
+               free(app_key);
+               free(app_secret);
+               free(imsi);
+               free(device_id);
+               service_adaptor_debug("[END] Is auth / join");
+       }
+/*
+ *                       public feature
+ *
+ ***********************************************************************/
+
+FUNC_END();
+}
+
+void auth_external_method_call(const char *service_name,
+                                               const char *api_uri,
+                                               const unsigned char *req_data,
+                                               int req_len,
+                                               unsigned char **res_data,
+                                               int *res_len,
+                                               int *ret_code,
+                                               char *ret_msg)
+{
+       service_adaptor_debug("<Start> Auth External request");
+       service_adaptor_h service_adaptor = service_adaptor_get_handle();
+       service_adaptor_service_context_h service =
+               service_adaptor_get_service_context(service_adaptor, service_name);
+
+       if (NULL == service) {
+               service_adaptor_info("Try API without context(%s)", service_name);
+               /*
+               *ret_code = AUTH_ADAPTOR_ERROR_NOT_FOUND;
+               snprintf(ret_msg, 2047, "Can not get service context");
+
+               return;
+               */
+       }
+
+       auth_adaptor_h adaptor = service_adaptor_get_auth_adaptor(service_adaptor);
+       auth_adaptor_plugin_h plugin = NULL;
+       auth_adaptor_plugin_context_h auth_context = NULL;
+
+       if (NULL != service) {
+               auth_context = service->auth_context;
+               if (NULL != auth_context) {
+                       plugin = auth_adaptor_get_plugin_by_name(adaptor, auth_context->plugin_uri);
+               } else {
+                       service_adaptor_error("Couldn't find context");
+               }
+       } else {
+               /* It will be removed on public API */
+               plugin = auth_adaptor_get_plugin_by_name(adaptor, "com.samsung.coreapps");
+       }
+
+       auth_adaptor_error_code_h error = NULL;
+       if (NULL != plugin) {
+               auth_error_code_t ret = AUTH_ADAPTOR_ERROR_NONE;
+               service_adaptor_debug_func("Call auth_adaptor_external_request");
+               ret = auth_adaptor_external_request(plugin, auth_context, api_uri,
+                               req_data, req_len, res_data, res_len, &error);
+               service_adaptor_debug_func("API ret (%d)", ret);
+       }
+
+       if (NULL != error) {
+               *ret_code = (int) error->code;
+               service_adaptor_debug_func("error_code (%lld)(%s)", error->code, error->msg);
+               if (NULL != error->msg) {
+                       snprintf(ret_msg, 2047, "%s", error->msg);
+               }
+               free(error->msg);
+               free(error);
+       } else {
+               *ret_code = 0;
+       }
+       service_adaptor_debug("<End> Auth External request");
+}
diff --git a/src/dbus/dbus-contact-adaptor.c b/src/dbus/dbus-contact-adaptor.c
new file mode 100644 (file)
index 0000000..32b70e4
--- /dev/null
@@ -0,0 +1,1714 @@
+/*
+* 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 <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <sys/time.h>
+
+#include "service-adaptor.h"
+#include "service-adaptor-contact.h"
+#include "service-adaptor-storage.h"
+#include "service-adaptor-type.h"
+#include "service-adaptor-log.h"
+#include "dbus-contact-adaptor.h"
+#include "dbus-server.h"
+#include "dbus-util.h"
+
+char *ipc_g_variant_dup_contact_string(GVariant *string)
+{
+        char *ret = g_variant_dup_string(string, NULL);
+       const int contact_protocol_padding_length = 1;
+        if (0 == strcmp(ret, "")) {
+                free(ret);
+                ret = NULL;
+        } else if (0 < strlen(ret)) {
+               char *dummy = ret;
+               ret = strdup((dummy + contact_protocol_padding_length));
+               free(dummy);
+       }
+
+        return ret;
+}
+
+
+static void __separate_path_to_dir_base(char *full_path,
+                                               char **dir_path,
+                                               char **base_path)
+{
+       if ((NULL == full_path) || (0 >= strlen(full_path))) {
+               *base_path = strdup("");
+               *dir_path = strdup("");
+               return;
+       }
+
+       char *base = strrchr(full_path, '/');
+       if (NULL == base) {
+               *base_path = strdup(full_path);
+               *dir_path = strdup("");
+       } else if (0 == strcmp(full_path, base)) {
+               *base_path = strdup(full_path);
+               *dir_path = strdup("");
+       } else {
+               *base_path = strdup(base + 1);
+               if ((base - full_path) > 1) {
+                       *dir_path = strndup(full_path, (base - full_path));
+               } else {
+                       *dir_path = strdup("");
+               }
+       }
+}
+
+void __destroy_req_images(contact_adaptor_contact_image_h *imgs, unsigned int imgs_len)
+{
+       if (NULL == imgs) {
+               return;
+       }
+
+       for (int i = 0; i < imgs_len; i++) {
+               if (NULL != imgs[i]) {
+                       free(imgs[i]->img);
+                       free(imgs[i]);
+               }
+       }
+       free(imgs);
+}
+
+void __get_contact_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               contact_adaptor_contact_req_h *contact_req)
+{
+FUNC_START();
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_contact_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_contact_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       *contact_req = (contact_adaptor_contact_req_h) calloc(1, sizeof(contact_adaptor_contact_req_t));
+       if (NULL != (*contact_req)) {
+               (*contact_req)->tt = g_variant_get_int64(req_struct[idx++]);
+
+               gsize list_count = g_variant_n_children(req_struct[idx]);
+
+FUNC_STEP();
+               (*contact_req)->cts = (contact_adaptor_contact_info_req_h *) calloc(list_count, sizeof(contact_adaptor_contact_info_req_h));
+
+               if (NULL != ((*contact_req)->cts)) {
+                       for (gsize i = 0; i < list_count; i++) {
+                               GVariant *req_info_struct[private_service_adaptor_contact_info_req_s_type_length];
+                               GVariant *req_info_entry_v = g_variant_get_child_value(req_struct[idx], i);
+
+                               contact_adaptor_contact_info_req_h contact_info_req
+                                               = (contact_adaptor_contact_info_req_h) calloc(1, sizeof(contact_adaptor_contact_info_req_t));
+
+                               if (NULL != contact_info_req) {
+                                       for (size_t j = 0; j < private_service_adaptor_contact_info_req_s_type_length; j++) {
+                                               req_info_struct[j] = g_variant_get_child_value(req_info_entry_v, j);
+                                       }
+
+                                       int idx2 = 0;
+                                       contact_info_req->tp = ipc_g_variant_dup_string(req_info_struct[idx2++]);
+                                       contact_info_req->id = ipc_g_variant_dup_string(req_info_struct[idx2++]);
+                                       contact_info_req->pn = ipc_g_variant_dup_string(req_info_struct[idx2++]);
+                                       contact_info_req->nm = ipc_g_variant_dup_contact_string(req_info_struct[idx2++]);
+                                       contact_info_req->cc = ipc_g_variant_dup_string(req_info_struct[idx2++]);
+
+                                       for (size_t j = 0; j < private_service_adaptor_contact_info_req_s_type_length; j++) {
+                                               g_variant_unref(req_info_struct[j]);
+                                       }
+                               }
+                               (*contact_req)->cts[i] = contact_info_req;
+                       }
+               }
+               idx++;
+
+FUNC_STEP();
+               (*contact_req)->cts_len = g_variant_get_uint32(req_struct[idx++]);
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_contact_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+FUNC_END();
+}
+
+GVariant *__create_contact_res_type(contact_adaptor_contact_res_h contact_res,
+                                               contact_adaptor_error_code_h error_code)
+{
+FUNC_START();
+       contact_adaptor_contact_res_t _contact_res;
+       _contact_res.tt = 0;
+       _contact_res.cts_len = 0;
+
+       if (NULL == contact_res) {
+               contact_res = &_contact_res;
+       }
+
+       GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE(private_contact_info_res_list_type));
+       GVariantBuilder *builder_in;
+FUNC_STEP();
+
+       for (gsize i = 0; i < contact_res->cts_len; i++) {
+               g_variant_builder_open(builder, G_VARIANT_TYPE(private_service_adaptor_contact_info_res_s_type));
+               safe_g_variant_builder_add_string(builder, contact_res->cts[i]->duid);
+               safe_g_variant_builder_add_string(builder, contact_res->cts[i]->id);
+               safe_g_variant_builder_add_string(builder, contact_res->cts[i]->msisdn);
+               safe_g_variant_builder_add_string(builder, contact_res->cts[i]->ty);
+               safe_g_variant_builder_add_string(builder, contact_res->cts[i]->cc);
+               safe_g_variant_builder_add_string(builder, contact_res->cts[i]->pn);
+               safe_g_variant_builder_add_string(builder, contact_res->cts[i]->nm);
+
+               /* evnt */
+FUNC_STEP();
+               builder_in = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
+
+               if (NULL != contact_res->cts[i]->evnt) {
+                       service_adaptor_debug("event_len  : %d", contact_res->cts[i]->evnt_len);
+                       for (gsize j = 0; j < contact_res->cts[i]->evnt_len; j++) {
+                               safe_g_variant_builder_add_array_string(builder_in, contact_res->cts[i]->evnt[j]);
+                       }
+               } else {
+                       service_adaptor_debug("(event == NULL) => event_len = 0");
+                       contact_res->cts[i]->evnt_len = 0U;
+               }
+
+               g_variant_builder_add(builder, "a(s)", builder_in);
+               g_variant_builder_unref(builder_in);
+
+               g_variant_builder_add(builder, "u", contact_res->cts[i]->evnt_len);
+
+               /* imgs */
+               builder_in = g_variant_builder_new(G_VARIANT_TYPE("a(is)"));
+               if (NULL != contact_res->cts[i]->imgs) {
+                       service_adaptor_debug("image_len  : %d", contact_res->cts[i]->imgs_len);
+                       for (gsize j = 0; j < contact_res->cts[i]->imgs_len; j++) {
+                               g_variant_builder_add(builder_in, "(is)", contact_res->cts[i]->imgs[j]->no, __safe_add_string(contact_res->cts[i]->imgs[j]->img));
+                       }
+               } else {
+                       service_adaptor_debug("(image == NULL) => image_len = 0");
+                       contact_res->cts[i]->imgs_len = 0U;
+               }
+               g_variant_builder_add(builder, "a(is)", builder_in);
+               g_variant_builder_unref(builder_in);
+
+               g_variant_builder_add(builder, "u", contact_res->cts[i]->imgs_len);
+
+               /* adrs */
+FUNC_STEP();
+               builder_in = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
+
+               if (NULL != contact_res->cts[i]->adrs) {
+                       service_adaptor_debug("adrs_len  : %d", contact_res->cts[i]->adrs_len);
+                       for (gsize j = 0; j < contact_res->cts[i]->adrs_len; j++) {
+                               safe_g_variant_builder_add_array_string(builder_in, contact_res->cts[i]->adrs[j]);
+                       }
+               } else {
+                       service_adaptor_debug("(adrs == NULL) => adrs_len = 0");
+                       contact_res->cts[i]->adrs_len = 0U;
+               }
+
+               g_variant_builder_add(builder, "a(s)", builder_in);
+               g_variant_builder_unref(builder_in);
+
+               g_variant_builder_add(builder, "u", contact_res->cts[i]->adrs_len);
+
+               /* mail */
+FUNC_STEP();
+               builder_in = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
+
+               if (NULL != contact_res->cts[i]->mail) {
+                       service_adaptor_debug("mail_len  : %d", contact_res->cts[i]->mail_len);
+                       for (gsize j = 0; j < contact_res->cts[i]->mail_len; j++) {
+                               safe_g_variant_builder_add_array_string(builder_in, contact_res->cts[i]->mail[j]);
+                       }
+               } else {
+                       service_adaptor_debug("(mail == NULL) => mail_len = 0");
+                       contact_res->cts[i]->mail_len = 0U;
+               }
+
+               g_variant_builder_add(builder, "a(s)", builder_in);
+               g_variant_builder_unref(builder_in);
+
+               g_variant_builder_add(builder, "u", contact_res->cts[i]->mail_len);
+               safe_g_variant_builder_add_string(builder, contact_res->cts[i]->org);
+               safe_g_variant_builder_add_string(builder, contact_res->cts[i]->prsc);
+               safe_g_variant_builder_add_string(builder, contact_res->cts[i]->status);
+               g_variant_builder_add(builder, "u", contact_res->cts[i]->sids);
+FUNC_STEP();
+               g_variant_builder_add(builder, "i", contact_res->cts[i]->type);
+               safe_g_variant_builder_add_string(builder, contact_res->cts[i]->url);
+
+               g_variant_builder_close(builder);
+       }
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_contact_res_s_type), (int64_t)contact_res->tt, builder, (uint32_t)contact_res->cts_len, (uint64_t)error_code->code, __safe_add_string(error_code->msg));
+
+       g_variant_builder_unref(builder);
+
+FUNC_END();
+       return response;
+}
+
+void __get_profile_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               contact_adaptor_profile_req_h *profile_req)
+{
+FUNC_START();
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_profile_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_profile_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+FUNC_STEP();
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       *profile_req = (contact_adaptor_profile_req_h) calloc(1, sizeof(contact_adaptor_profile_req_t));
+       if (NULL != (*profile_req)) {
+               (*profile_req)->cc = ipc_g_variant_dup_string(req_struct[idx++]);
+               (*profile_req)->pn = ipc_g_variant_dup_string(req_struct[idx++]);
+               (*profile_req)->nm = ipc_g_variant_dup_contact_string(req_struct[idx++]);
+
+               gsize evnt_count = g_variant_n_children(req_struct[idx]);
+
+               FUNC_STEP();
+               (*profile_req)->evnt = (char **) calloc(evnt_count, sizeof(char *));
+
+               if (NULL != ((*profile_req)->evnt)) {
+                       for (gsize i = 0; i < evnt_count; i++) {
+                               GVariant *evnt_info_struct;
+                               GVariant *evnt_info_entry_v = g_variant_get_child_value(req_struct[idx], i);
+                               evnt_info_struct = g_variant_get_child_value(evnt_info_entry_v, 0);
+
+                               (*profile_req)->evnt[i] = ipc_g_variant_dup_string(evnt_info_struct);
+
+                               g_variant_unref(evnt_info_struct);
+                       }
+               }
+               idx++;
+
+               (*profile_req)->evnt_len = g_variant_get_uint32(req_struct[idx++]);
+               (*profile_req)->img = ipc_g_variant_dup_string(req_struct[idx++]);
+
+               FUNC_STEP();
+               gsize adrs_count = g_variant_n_children(req_struct[idx]);
+
+               (*profile_req)->adrs = (char **) calloc(adrs_count, sizeof(char *));
+
+               if (NULL != ((*profile_req)->adrs)) {
+                       for (gsize i = 0; i < adrs_count; i++) {
+                               GVariant *adrs_info_struct;
+                               GVariant *adrs_info_entry_v = g_variant_get_child_value(req_struct[idx], i);
+                               adrs_info_struct = g_variant_get_child_value(adrs_info_entry_v, 0);
+
+                               (*profile_req)->adrs[i] = ipc_g_variant_dup_string(adrs_info_struct);
+
+                               g_variant_unref(adrs_info_struct);
+                       }
+               }
+               idx++;
+
+               FUNC_STEP();
+               (*profile_req)->adrs_len = g_variant_get_uint32(req_struct[idx++]);
+
+               gsize mail_count = g_variant_n_children(req_struct[idx]);
+
+               (*profile_req)->mail = (char **) calloc(mail_count, sizeof(char *));
+
+               if (NULL != ((*profile_req)->mail)) {
+                       for (gsize i = 0; i < mail_count; i++) {
+                               GVariant *mail_info_struct;
+                               GVariant *mail_info_entry_v = g_variant_get_child_value(req_struct[idx], i);
+                               mail_info_struct = g_variant_get_child_value(mail_info_entry_v, 0);
+
+                               (*profile_req)->mail[i] = ipc_g_variant_dup_string(mail_info_struct);
+
+                               g_variant_unref(mail_info_struct);
+                       }
+               }
+               idx++;
+
+               (*profile_req)->mail_len = g_variant_get_uint32(req_struct[idx++]);
+               (*profile_req)->org = ipc_g_variant_dup_string(req_struct[idx++]);
+               (*profile_req)->prsc = ipc_g_variant_dup_string(req_struct[idx++]);
+               (*profile_req)->status = ipc_g_variant_dup_string(req_struct[idx++]);
+       }
+       for (size_t j = 0; j < private_service_adaptor_profile_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+FUNC_END();
+}
+
+GVariant *__create_profile_res_type(contact_adaptor_profile_res_h profile_res,
+                                               contact_adaptor_error_code_h error_code)
+{
+FUNC_START();
+       contact_adaptor_profile_res_t _profile_res;
+       _profile_res.nm = "";
+       _profile_res.img = "";
+       _profile_res.prsc = "";
+
+       if (NULL == profile_res) {
+               profile_res = &_profile_res;
+       }
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_profile_res_s_type), __safe_add_string(profile_res->nm), __safe_add_string(profile_res->img), __safe_add_string(profile_res->prsc), __safe_add_string(profile_res->status), (uint64_t) error_code->code, __safe_add_string(error_code->msg));
+
+       /* free error and res */
+
+FUNC_END();
+       return response;
+}
+
+void __get_delete_me_req_type(GVariant *parameters,
+                                               char **service_name)
+{
+FUNC_START();
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_essential_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_essential_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+FUNC_STEP();
+
+       for (size_t j = 0; j < private_service_adaptor_essential_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+FUNC_END();
+}
+
+void __get_set_me_profile_type_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               int *type)
+{
+FUNC_START();
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_set_me_profile_type_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_set_me_profile_type_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *type = g_variant_get_int32(req_struct[idx++]);
+FUNC_STEP();
+
+       for (size_t j = 0; j < private_service_adaptor_set_me_profile_type_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+FUNC_END();
+}
+
+
+void __get_file_path_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               contact_adaptor_contact_image_h **req_imgs,
+                                               unsigned int *req_imgs_len,
+                                               contact_adaptor_contact_image_h **res_imgs,
+                                               unsigned int *res_imgs_len)
+{
+FUNC_START();
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_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++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+FUNC_STEP();
+
+       gsize list_count = g_variant_n_children(req_struct[idx]);
+
+       *req_imgs = (contact_adaptor_contact_image_h *) calloc(list_count, sizeof(contact_adaptor_contact_image_h));
+       *res_imgs = (contact_adaptor_contact_image_h *) calloc(list_count, sizeof(contact_adaptor_contact_image_h));
+       if ((NULL != (*req_imgs)) && (NULL != (*res_imgs))) {
+               for (gsize i = 0; i < list_count; i++) {
+                       (*req_imgs)[i] = (contact_adaptor_contact_image_h) calloc(1, sizeof(contact_adaptor_contact_image_t));
+                       (*res_imgs)[i] = NULL;
+                       if (NULL != (*req_imgs)[i]) {
+                               GVariant *path_info_struct;
+                               GVariant *path_info_entry_v = g_variant_get_child_value(req_struct[idx], i);
+                               path_info_struct = g_variant_get_child_value(path_info_entry_v, 0);
+                               (*req_imgs)[i]->req_type = g_variant_get_int32(path_info_struct);
+
+                               path_info_struct = g_variant_get_child_value(path_info_entry_v, 1);
+                               (*req_imgs)[i]->no = g_variant_get_int32(path_info_struct);
+
+                               path_info_struct = g_variant_get_child_value(path_info_entry_v, 2);
+                               (*req_imgs)[i]->img = ipc_g_variant_dup_string(path_info_struct);
+
+                               g_variant_unref(path_info_struct);
+                       }
+               }
+               idx++;
+               *req_imgs_len = g_variant_get_uint32(req_struct[idx++]);
+       } else {
+               free(*req_imgs);
+               free(*res_imgs);
+               *req_imgs = NULL;
+               *res_imgs = NULL;
+               *req_imgs_len = 0U;
+               *res_imgs_len = 0U;
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_contact_profile_image_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+FUNC_END();
+}
+
+GVariant *__create_file_path_res_type(contact_adaptor_contact_image_h *res_imgs,
+                                               unsigned int res_imgs_len,
+                                               contact_adaptor_error_code_h error_code)
+{
+FUNC_START();
+       if (NULL == res_imgs) {
+               res_imgs_len = 0;
+       }
+
+       GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(iis)"));
+
+       for (gsize j = 0; j < res_imgs_len; j++) {
+               if (NULL != res_imgs[j]) {
+                       g_variant_builder_add(builder, "(iis)", res_imgs[j]->req_type, res_imgs[j]->no, __safe_add_string(res_imgs[j]->img));
+               }
+       }
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_contact_profile_image_req_s_type), "", builder, (uint32_t)res_imgs_len, (uint64_t) error_code->code, __safe_add_string(error_code->msg));
+
+       g_variant_builder_unref(builder);
+
+FUNC_END();
+       return response;
+}
+
+void __get_privacy_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               contact_adaptor_privacy_req_h *privacy_req)
+{
+FUNC_START();
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_privacy_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_privacy_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       *privacy_req = (contact_adaptor_privacy_req_h) calloc(1, sizeof(contact_adaptor_privacy_req_t));
+       if (NULL != (*privacy_req)) {
+               (*privacy_req)->lvl = g_variant_get_uint32(req_struct[idx++]);
+
+               gsize list_count = g_variant_n_children(req_struct[idx]);
+
+               (*privacy_req)->cts = (contact_adaptor_privacy_info_req_h *) calloc(list_count, sizeof(contact_adaptor_privacy_info_req_h));
+
+               if (NULL != ((*privacy_req)->cts)) {
+                       for (gsize i = 0; i < list_count; i++) {
+                               FUNC_STEP();
+                               GVariant *req_info_struct[private_service_adaptor_privacy_info_req_s_type_length];
+                               GVariant *req_info_entry_v = g_variant_get_child_value(req_struct[idx], i);
+
+                               for (size_t j = 0; j < private_service_adaptor_privacy_info_req_s_type_length; j++) {
+                                       req_info_struct[j] = g_variant_get_child_value(req_info_entry_v, j);
+                               }
+
+                               int idx2 = 0;
+                               (*privacy_req)->cts[i] = (contact_adaptor_privacy_info_req_h) calloc(1, sizeof(contact_adaptor_privacy_info_req_t));
+                               if (NULL != ((*privacy_req)->cts[i])) {
+                                       (*privacy_req)->cts[i]->cc = ipc_g_variant_dup_string(req_info_struct[idx2++]);
+                                       (*privacy_req)->cts[i]->pn = ipc_g_variant_dup_string(req_info_struct[idx2++]);
+                               }
+
+                               for (size_t j = 0; j < private_service_adaptor_privacy_info_req_s_type_length; j++) {
+                                       g_variant_unref(req_info_struct[j]);
+                               }
+                       }
+               }
+               idx++;
+
+               (*privacy_req)->cts_len = g_variant_get_uint32(req_struct[idx++]);
+       }
+       for (size_t j = 0; j < private_service_adaptor_privacy_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+FUNC_END();
+}
+
+GVariant *__create_privacy_res_type(contact_adaptor_privacy_res_h privacy_res,
+                                               contact_adaptor_error_code_h error_code)
+{
+FUNC_START();
+       contact_adaptor_privacy_res_t _privacy_res;
+       _privacy_res.lvl = 0;
+       _privacy_res.prscon = 0;
+
+       if (NULL == privacy_res) {
+               privacy_res = &_privacy_res;
+       }
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_privacy_res_s_type), privacy_res->lvl, privacy_res->prscon, (uint64_t) error_code->code, __safe_add_string(error_code->msg));
+
+FUNC_END();
+       return response;
+}
+
+void __get_presence_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               contact_adaptor_presence_info_h *presence_req)
+{
+FUNC_START();
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_presence_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_presence_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       *presence_req = (contact_adaptor_presence_info_h) calloc(1, sizeof(contact_adaptor_presence_info_t));
+       if (NULL != (*presence_req)) {
+               (*presence_req)->prsc = ipc_g_variant_dup_string(req_struct[idx++]);
+               (*presence_req)->status = ipc_g_variant_dup_string(req_struct[idx++]);
+               (*presence_req)->prscon = g_variant_get_uint32(req_struct[idx++]);
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_presence_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+FUNC_END();
+}
+
+void contact_adaptor_method_call(GDBusConnection *connection,
+                                               const gchar *sender,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *method_name,
+                                               GVariant *parameters,
+                                               GDBusMethodInvocation *invocation,
+                                               gpointer user_data)
+{
+FUNC_START();
+       service_adaptor_internal_error_code_e ret_code = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+
+       if (0 == g_strcmp0(method_name, PRIVATE_DBUS_SET_NEW_CONTACT_LIST_METHOD)) {
+               char *service_name = NULL;
+               contact_adaptor_contact_req_h contact_req = NULL;
+               contact_adaptor_contact_res_h contact_res = NULL;
+               contact_adaptor_error_code_h error_code = NULL;
+               contact_adaptor_error_code_t _error;
+               _error.code = CONTACT_ADAPTOR_ERROR_NONE;
+               _error.msg = NULL;
+
+               __get_contact_req_type(parameters, &service_name, &contact_req);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       GVariant *response = __create_contact_res_type(contact_res, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       contact_adaptor_destroy_contact_req_s(contact_req);
+                       contact_adaptor_destroy_contact_res_s(contact_res);
+                       free(service_name);
+                       return;
+               }
+
+               contact_adaptor_h adaptor = service_adaptor_get_contact_adaptor(service_adaptor);
+               contact_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->contact_context) {
+                       plugin = contact_adaptor_get_plugin_by_name(adaptor, service->contact_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+FUNC_STEP();
+                       ret_code = contact_adaptor_new_contact_list(plugin, service->contact_context, contact_req, NULL, &contact_res, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->contact_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               contact_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = contact_adaptor_new_contact_list(plugin, service->contact_context, contact_req, NULL, &contact_res, &error_code, NULL);
+                       }
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                               service_adaptor_error("Can not run contact_adaptor_new_contact_list()");
+                       }
+               }
+FUNC_STEP();
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NONE;
+                       error_code->msg = strdup("");
+               }
+
+               GVariant *response = __create_contact_res_type(contact_res, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               contact_adaptor_destroy_contact_req_s(contact_req);
+               contact_adaptor_destroy_contact_res_s(contact_res);
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_SET_CONTACT_LIST_METHOD)) {
+               char *service_name = NULL;
+               contact_adaptor_contact_req_h contact_req = NULL;
+               contact_adaptor_contact_res_h contact_res = NULL;
+               contact_adaptor_error_code_h error_code = NULL;
+               contact_adaptor_error_code_t _error;
+               _error.code = CONTACT_ADAPTOR_ERROR_NONE;
+               _error.msg = NULL;
+
+               __get_contact_req_type(parameters, &service_name, &contact_req);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       GVariant *response = __create_contact_res_type(contact_res, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       contact_adaptor_destroy_contact_req_s(contact_req);
+                       contact_adaptor_destroy_contact_res_s(contact_res);
+                       free(service_name);
+                       return;
+               }
+
+               contact_adaptor_h adaptor = service_adaptor_get_contact_adaptor(service_adaptor);
+               contact_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->contact_context) {
+                       plugin = contact_adaptor_get_plugin_by_name(adaptor, service->contact_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+FUNC_STEP();
+                       ret_code = contact_adaptor_set_contact_list(plugin, service->contact_context, contact_req, NULL, &contact_res, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->contact_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               contact_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = contact_adaptor_set_contact_list(plugin, service->contact_context, contact_req, NULL, &contact_res, &error_code, NULL);
+                       }
+               }
+
+FUNC_STEP();
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NONE;
+                       error_code->msg = strdup("");
+               }
+
+               GVariant *response = __create_contact_res_type(contact_res, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               contact_adaptor_destroy_contact_req_s(contact_req);
+               contact_adaptor_destroy_contact_res_s(contact_res);
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_GET_CONTACT_LIST_METHOD)) {
+               GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+               GVariant *req_struct[private_service_adaptor_essential_s_type_length];
+
+               for (size_t j = 0; j < private_service_adaptor_essential_s_type_length; j++) {
+                       req_struct[j] = g_variant_get_child_value(in_parameters, j);
+               }
+
+               int idx = 0;
+               char *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+               for (size_t j = 0; j < private_service_adaptor_essential_s_type_length; j++) {
+                       g_variant_unref(req_struct[j]);
+               }
+
+               service_adaptor_debug("(%s)", service_name);
+
+               contact_adaptor_contact_res_h contact_res = NULL;
+               contact_adaptor_error_code_h error_code = NULL;
+               contact_adaptor_error_code_t _error;
+               _error.code = CONTACT_ADAPTOR_ERROR_NONE;
+               _error.msg = NULL;
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       GVariant *response = __create_contact_res_type(contact_res, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       contact_adaptor_destroy_contact_res_s(contact_res);
+                       free(service_name);
+                       return;
+               }
+
+               contact_adaptor_h adaptor = service_adaptor_get_contact_adaptor(service_adaptor);
+               contact_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->contact_context) {
+                       plugin = contact_adaptor_get_plugin_by_name(adaptor, service->contact_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+FUNC_STEP();
+                       ret_code = contact_adaptor_get_contact_infos_latest(plugin, service->contact_context, NULL, NULL, &contact_res, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->contact_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               contact_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = contact_adaptor_get_contact_infos_latest(plugin, service->contact_context, NULL, NULL, &contact_res, &error_code, NULL);
+                       }
+               }
+
+FUNC_STEP();
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NONE;
+                       error_code->msg = strdup("");
+               }
+
+               GVariant *response = __create_contact_res_type(contact_res, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               contact_adaptor_destroy_contact_res_s(contact_res);
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_GET_CONTACT_INFOS_POLLING_METHOD)) {
+               char *service_name = NULL;
+
+               contact_adaptor_contact_req_h contact_req = NULL;
+               contact_adaptor_contact_res_h contact_res = NULL;
+               contact_adaptor_error_code_h error_code = NULL;
+               contact_adaptor_error_code_t _error;
+               _error.code = CONTACT_ADAPTOR_ERROR_NONE;
+               _error.msg = NULL;
+
+               __get_contact_req_type(parameters, &service_name, &contact_req);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       GVariant *response = __create_contact_res_type(contact_res, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       contact_adaptor_destroy_contact_req_s(contact_req);
+                       contact_adaptor_destroy_contact_res_s(contact_res);
+                       free(service_name);
+                       return;
+               }
+
+               contact_adaptor_h adaptor = service_adaptor_get_contact_adaptor(service_adaptor);
+               contact_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->contact_context) {
+                       plugin = contact_adaptor_get_plugin_by_name(adaptor, service->contact_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+FUNC_STEP();
+                       ret_code = contact_adaptor_get_contact_infos_polling(plugin, service->contact_context, contact_req, NULL, &contact_res, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->contact_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               contact_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = contact_adaptor_get_contact_infos_polling(plugin, service->contact_context, contact_req, NULL, &contact_res, &error_code, NULL);
+                       }
+               }
+
+FUNC_STEP();
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NONE;
+                       error_code->msg = strdup("");
+               }
+
+               GVariant *response = __create_contact_res_type(contact_res, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               contact_adaptor_destroy_contact_req_s(contact_req);
+               contact_adaptor_destroy_contact_res_s(contact_res);
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_SET_ME_PROFILE_WITH_PUSH_METHOD)) {
+               char *service_name = NULL;
+               contact_adaptor_profile_req_h profile_req = NULL;
+               contact_adaptor_profile_res_h profile_res = NULL;
+               contact_adaptor_error_code_h error_code = NULL;
+               contact_adaptor_error_code_t _error;
+               _error.code = CONTACT_ADAPTOR_ERROR_NONE;
+               _error.msg = NULL;
+
+               __get_profile_req_type(parameters, &service_name, &profile_req);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       contact_adaptor_destroy_profile_req_s(profile_req);
+                       contact_adaptor_destroy_profile_res_s(profile_res);
+                       free(service_name);
+                       return;
+               }
+
+               contact_adaptor_h adaptor = service_adaptor_get_contact_adaptor(service_adaptor);
+               contact_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->contact_context) {
+                       plugin = contact_adaptor_get_plugin_by_name(adaptor, service->contact_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+FUNC_STEP();
+                       ret_code = contact_adaptor_set_me_profile_with_push(plugin, service->contact_context, profile_req, NULL, &profile_res, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->contact_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               contact_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = contact_adaptor_set_me_profile_with_push(plugin, service->contact_context, profile_req, NULL, &profile_res, &error_code, NULL);
+                       }
+               }
+
+FUNC_STEP();
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NONE;
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               service_adaptor_debug("(%s)", service_name);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               contact_adaptor_destroy_profile_req_s(profile_req);
+               contact_adaptor_destroy_profile_res_s(profile_res);
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_GET_PROFILE_METHOD)) {
+               char *service_name = NULL;
+               contact_adaptor_profile_req_h profile_req = NULL;
+               contact_adaptor_profile_res_h profile_res = NULL;
+               contact_adaptor_error_code_h error_code = NULL;
+               contact_adaptor_error_code_t _error;
+               _error.code = CONTACT_ADAPTOR_ERROR_NONE;
+               _error.msg = NULL;
+
+               __get_profile_req_type(parameters, &service_name, &profile_req);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       GVariant *response = __create_profile_res_type(profile_res, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       contact_adaptor_destroy_profile_req_s(profile_req);
+                       contact_adaptor_destroy_profile_res_s(profile_res);
+                       free(service_name);
+                       return;
+               }
+
+               contact_adaptor_h adaptor = service_adaptor_get_contact_adaptor(service_adaptor);
+               contact_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->contact_context) {
+                       plugin = contact_adaptor_get_plugin_by_name(adaptor, service->contact_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+FUNC_STEP();
+                       ret_code = contact_adaptor_get_profile(plugin, service->contact_context, profile_req, NULL, &profile_res, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->contact_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               contact_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = contact_adaptor_get_profile(plugin, service->contact_context, profile_req, NULL, &profile_res, &error_code, NULL);
+                       }
+               }
+
+FUNC_STEP();
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NONE;
+                       error_code->msg = strdup("");
+               }
+
+               GVariant *response = __create_profile_res_type(profile_res, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               contact_adaptor_destroy_profile_req_s(profile_req);
+               contact_adaptor_destroy_profile_res_s(profile_res);
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_SET_PROFILE_IMAGE_META_WITH_PUSH_METHOD)) {
+               char *service_name = NULL;
+               contact_adaptor_contact_image_h *req_imgs = NULL;
+               unsigned int req_imgs_len = 0;
+               contact_adaptor_contact_image_h *res_imgs = NULL;
+               unsigned int res_imgs_len = 0;
+
+               contact_adaptor_error_code_h contact_error_code = NULL;
+               storage_adaptor_error_code_h storage_error_code = NULL;
+
+               contact_adaptor_error_code_t _contact_error;
+               _contact_error.code = CONTACT_ADAPTOR_ERROR_NONE;
+               _contact_error.msg = NULL;
+
+               __get_file_path_req_type(parameters, &service_name, &req_imgs, &req_imgs_len, &res_imgs, &res_imgs_len);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       contact_error_code = &_contact_error;
+                       contact_error_code->code = CONTACT_ADAPTOR_ERROR_NOT_FOUND;
+                       contact_error_code->msg = "Can not get service context";
+
+                       GVariant *response = __create_file_path_res_type(res_imgs, res_imgs_len, contact_error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       __destroy_req_images(req_imgs, req_imgs_len);
+                       __destroy_req_images(res_imgs, res_imgs_len);
+                       free(service_name);
+                       return;
+               }
+
+               contact_adaptor_h contact_adaptor = service_adaptor_get_contact_adaptor(service_adaptor);
+               contact_adaptor_plugin_h contact_plugin = NULL;
+
+               if (NULL != service->contact_context) {
+                       contact_plugin = contact_adaptor_get_plugin_by_name(contact_adaptor, service->contact_context->plugin_uri);
+               }
+
+               storage_adaptor_h storage_adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h storage_plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       storage_plugin = storage_adaptor_get_plugin_by_name(storage_adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != contact_adaptor) && (NULL != contact_plugin) && (NULL != storage_adaptor)
+                               && (NULL != storage_plugin) && (NULL != req_imgs) && (0 < req_imgs_len)) {
+                       FUNC_STEP();
+                       for (int i = 0; i < req_imgs_len; i++) {
+                               if (CONTACT_ADAPTOR_REQUEST_SET != req_imgs[i]->req_type) {
+                                       service_adaptor_debug("Skip upload to %dth image (delete operation)", i);
+                                       continue;
+                               }
+                               char *parent_folder = NULL;
+                               char *full_path = req_imgs[i]->img;
+                               char *folder_path = NULL, *file_name = NULL;
+                               struct timeval tv;
+                               gettimeofday(&tv, NULL);
+
+                               __separate_path_to_dir_base(full_path, &folder_path, &file_name);
+                               parent_folder = g_strdup_printf("/contact%s/%ld%ld", folder_path, (long)tv.tv_sec, (long)tv.tv_usec);
+                               storage_adaptor_file_info_h file_info = NULL;
+                               service_adaptor_info("Contact upload path : prn(%s) file(%s)", parent_folder, file_name);
+
+                               storage_adaptor_destroy_error_code(&storage_error_code);
+                               ret_code = storage_adaptor_upload_file_sync(storage_plugin, service->storage_context,
+                                               parent_folder, file_name, req_imgs[i]->img, true, NULL, &file_info, &storage_error_code, NULL);
+
+                               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                                       service_adaptor_info("API returns auth-error. Try refresh auth");
+                                       service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                                       service_adaptor_debug("Empty error_code already issued (%lld: %s)", storage_error_code ? storage_error_code->code : 0ULL,
+                                                       storage_error_code ? storage_error_code->msg : NULL);
+                                       storage_adaptor_destroy_error_code(&storage_error_code);
+
+                                       service_adaptor_debug("Re-try API");
+                                       ret_code = storage_adaptor_upload_file_sync(storage_plugin, service->storage_context,
+                                                       parent_folder, file_name, req_imgs[i]->img, true, NULL, &file_info, &storage_error_code, NULL);
+                               }
+
+                               if ((NULL == storage_error_code) && (NULL != file_info) && (NULL != file_info->file_share_token)) {
+                                       FUNC_STEP();
+                                       GString* public_filepath = g_string_new("");
+                                       g_string_append_printf(public_filepath, "%s?auth_code=%s",
+                                                       file_info->file_share_token->public_token, file_info->file_share_token->auth_code);
+                                       free(req_imgs[i]->img);
+                                       req_imgs[i]->img = public_filepath->str;
+
+                                       storage_adaptor_destroy_file_info(&file_info);
+                                       service_adaptor_info("Shared image url (%s)", req_imgs[i]->img);
+                               } else {
+                                       if (NULL != storage_error_code) {
+                                               service_adaptor_error("Upload error occured <%lld / %s>", storage_error_code->code, storage_error_code->msg);
+                                       }
+                                       res_imgs[res_imgs_len++] = req_imgs[i];
+                                       req_imgs[i] = NULL;
+                               }
+                               storage_adaptor_destroy_file_info(&file_info);
+
+                               free(parent_folder);
+                               free(folder_path);
+                               free(file_name);
+                               FUNC_STEP();
+                       }
+
+                       contact_adaptor_contact_image_h *tmp_imgs = NULL;
+                       tmp_imgs = (contact_adaptor_contact_image_h *) calloc(req_imgs_len, sizeof(contact_adaptor_contact_image_h));
+                       unsigned int tmp_imgs_len = 0;
+
+                       if (NULL != tmp_imgs) {
+                               for (int al = 0; al < req_imgs_len; al++) {
+                                       if (NULL != req_imgs[al]) {
+                                               tmp_imgs[tmp_imgs_len++] = req_imgs[al];
+                                       }
+                               }
+
+                               service_adaptor_info("%u imgs is requested", req_imgs_len);
+                               service_adaptor_info("%u imgs is failed", res_imgs_len);
+                               service_adaptor_info("%u imgs is success", tmp_imgs_len);
+
+                               ret_code = contact_adaptor_set_me_profile_image_meta_with_push(contact_plugin,
+                                               service->contact_context, tmp_imgs, tmp_imgs_len, NULL, &contact_error_code, NULL);
+
+                               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                                       service_adaptor_info("API returns auth-error. Try refresh auth");
+                                       service_adaptor_auth_refresh(service_adaptor, service_name, service->contact_context->plugin_uri);
+
+                                       service_adaptor_debug("Empty error_code already issued (%lld: %s)", contact_error_code ? contact_error_code->code : 0ULL,
+                                                       contact_error_code ? contact_error_code->msg : NULL);
+                                       contact_adaptor_destroy_error_code(&contact_error_code);
+
+                                       service_adaptor_debug("Re-try API");
+                                       ret_code = contact_adaptor_set_me_profile_image_meta_with_push(contact_plugin,
+                                                       service->contact_context, tmp_imgs, tmp_imgs_len, NULL, &contact_error_code, NULL);
+                               }
+
+                       }
+                       free(tmp_imgs);
+               }
+
+               FUNC_STEP();
+               if (NULL != storage_error_code) {
+                       contact_adaptor_destroy_error_code(&contact_error_code);
+
+                       contact_error_code = &_contact_error;
+                       contact_error_code->code = storage_error_code->code;
+                       contact_error_code->msg = storage_error_code->msg;
+                       free(storage_error_code);
+               } else if (NULL == contact_error_code) {
+                       contact_error_code = &_contact_error;
+                       contact_error_code->code = CONTACT_ADAPTOR_ERROR_NONE;
+                       contact_error_code->msg = strdup("");
+               }
+
+               GVariant *response = __create_file_path_res_type(res_imgs, res_imgs_len, contact_error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (contact_error_code != &_contact_error) {
+                       free(contact_error_code->msg);
+                       free(contact_error_code);
+                       contact_error_code = NULL;
+               } else {
+                       free(_contact_error.msg);
+               }
+
+               __destroy_req_images(req_imgs, req_imgs_len);
+               __destroy_req_images(res_imgs, res_imgs_len);
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_DEL_ME_PROFILE_IMAGE_META_WITH_PUSH_METHOD)) {
+               char *service_name = NULL;
+               contact_adaptor_error_code_h error_code = NULL;
+               contact_adaptor_error_code_t _error;
+               _error.code = CONTACT_ADAPTOR_ERROR_NONE;
+               _error.msg = NULL;
+
+               __get_delete_me_req_type(parameters, &service_name);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       return;
+               }
+
+               contact_adaptor_h adaptor = service_adaptor_get_contact_adaptor(service_adaptor);
+               contact_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->contact_context) {
+                       plugin = contact_adaptor_get_plugin_by_name(adaptor, service->contact_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+FUNC_STEP();
+                       ret_code = contact_adaptor_delete_me_profile_image_meta_with_push(plugin, service->contact_context, NULL, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->contact_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               contact_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = contact_adaptor_delete_me_profile_image_meta_with_push(plugin, service->contact_context,  NULL, &error_code, NULL);
+                       }
+               }
+
+FUNC_STEP();
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NONE;
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_SET_ME_PROFILE_PRIVACY_METHOD)) {
+               char *service_name = NULL;
+               contact_adaptor_privacy_req_h privacy_req = NULL;
+               contact_adaptor_privacy_res_h privacy_res = NULL;
+               contact_adaptor_error_code_h error_code = NULL;
+               contact_adaptor_error_code_t _error;
+               _error.code = CONTACT_ADAPTOR_ERROR_NONE;
+               _error.msg = NULL;
+
+               __get_privacy_req_type(parameters, &service_name, &privacy_req);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       contact_adaptor_destroy_privacy_req_s(privacy_req);
+                       contact_adaptor_destroy_privacy_res_s(privacy_res);
+                       free(service_name);
+                       return;
+               }
+
+               contact_adaptor_h adaptor = service_adaptor_get_contact_adaptor(service_adaptor);
+               contact_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->contact_context) {
+                       plugin = contact_adaptor_get_plugin_by_name(adaptor, service->contact_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+FUNC_STEP();
+                       ret_code = contact_adaptor_set_me_profile_privacy(plugin, service->contact_context, privacy_req, NULL, &privacy_res, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->contact_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               contact_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = contact_adaptor_set_me_profile_privacy(plugin, service->contact_context, privacy_req, NULL, &privacy_res, &error_code, NULL);
+                       }
+               }
+
+FUNC_STEP();
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NONE;
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               contact_adaptor_destroy_privacy_req_s(privacy_req);
+               contact_adaptor_destroy_privacy_res_s(privacy_res);
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_GET_PROFILE_PRIVACY_METHOD)) {
+               GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+               GVariant *req_struct[private_service_adaptor_essential_s_type_length];
+
+               for (size_t j = 0; j < private_service_adaptor_essential_s_type_length; j++) {
+                       req_struct[j] = g_variant_get_child_value(in_parameters, j);
+               }
+
+               int idx = 0;
+               char *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+               for (size_t j = 0; j < private_service_adaptor_essential_s_type_length; j++) {
+                       g_variant_unref(req_struct[j]);
+               }
+
+               service_adaptor_debug("(%s)", service_name);
+
+               contact_adaptor_privacy_res_h privacy_res = NULL;
+               contact_adaptor_error_code_h error_code = NULL;
+               contact_adaptor_error_code_t _error;
+               _error.code = CONTACT_ADAPTOR_ERROR_NONE;
+               _error.msg = NULL;
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+FUNC_STEP();
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       GVariant *response = __create_privacy_res_type(privacy_res, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       contact_adaptor_destroy_privacy_res_s(privacy_res);
+                       free(service_name);
+                       return;
+               }
+
+               contact_adaptor_h adaptor = service_adaptor_get_contact_adaptor(service_adaptor);
+               contact_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->contact_context) {
+                       plugin = contact_adaptor_get_plugin_by_name(adaptor, service->contact_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+FUNC_STEP();
+                       ret_code = contact_adaptor_get_me_profile_privacy(plugin, service->contact_context, NULL, NULL, &privacy_res, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->contact_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               contact_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = contact_adaptor_get_me_profile_privacy(plugin, service->contact_context, NULL, NULL, &privacy_res, &error_code, NULL);
+                       }
+               }
+
+FUNC_STEP();
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NONE;
+                       error_code->msg = strdup("");
+               }
+
+               GVariant *response = __create_privacy_res_type(privacy_res, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               contact_adaptor_destroy_privacy_res_s(privacy_res);
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_SET_ME_PRESENCE_WITH_PUSH_METHOD)) {
+               char *service_name = NULL;
+               contact_adaptor_presence_info_h presence_req = NULL;
+
+               __get_presence_req_type(parameters, &service_name, &presence_req);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               contact_adaptor_presence_info_h presence_res = NULL;
+               contact_adaptor_error_code_h error_code = NULL;
+               contact_adaptor_error_code_t _error;
+               _error.code = CONTACT_ADAPTOR_ERROR_NONE;
+               _error.msg = NULL;
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+FUNC_STEP();
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       contact_adaptor_destroy_presence_info_s(presence_req);
+                       contact_adaptor_destroy_presence_info_s(presence_res);
+                       free(service_name);
+                       return;
+               }
+
+               contact_adaptor_h adaptor = service_adaptor_get_contact_adaptor(service_adaptor);
+               contact_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->contact_context) {
+                       plugin = contact_adaptor_get_plugin_by_name(adaptor, service->contact_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+FUNC_STEP();
+                       ret_code = contact_adaptor_set_me_presence_with_push(plugin, service->contact_context, presence_req, NULL, &presence_res, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->contact_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               contact_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = contact_adaptor_set_me_presence_with_push(plugin, service->contact_context, presence_req, NULL, &presence_res, &error_code, NULL);
+                       }
+               }
+
+
+FUNC_STEP();
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NONE;
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               contact_adaptor_destroy_presence_info_s(presence_req);
+               contact_adaptor_destroy_presence_info_s(presence_res);
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_SET_ME_PRESENCE_ON_OFF_WITH_PUSH_METHOD)) {
+               char *service_name = NULL;
+               contact_adaptor_presence_info_h presence_req = NULL;
+
+               __get_presence_req_type(parameters, &service_name, &presence_req);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               contact_adaptor_presence_info_h presence_res = NULL;
+               contact_adaptor_error_code_h error_code = NULL;
+               contact_adaptor_error_code_t _error;
+               _error.code = CONTACT_ADAPTOR_ERROR_NONE;
+               _error.msg = NULL;
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+FUNC_STEP();
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       contact_adaptor_destroy_presence_info_s(presence_req);
+                       contact_adaptor_destroy_presence_info_s(presence_res);
+                       free(service_name);
+                       return;
+               }
+
+               contact_adaptor_h adaptor = service_adaptor_get_contact_adaptor(service_adaptor);
+               contact_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->contact_context) {
+                       plugin = contact_adaptor_get_plugin_by_name(adaptor, service->contact_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+FUNC_STEP();
+                       ret_code = contact_adaptor_set_me_presence_on_off_with_push(plugin, service->contact_context, presence_req, NULL, &presence_res, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->contact_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               contact_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = contact_adaptor_set_me_presence_on_off_with_push(plugin, service->contact_context, presence_req, NULL, &presence_res, &error_code, NULL);
+                       }
+               }
+
+FUNC_STEP();
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NONE;
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               contact_adaptor_destroy_presence_info_s(presence_req);
+               contact_adaptor_destroy_presence_info_s(presence_res);
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_SET_ME_PROFILE_TYPE_METHOD)) {
+               char *service_name = NULL;
+               int type = -1;
+               contact_adaptor_error_code_h error_code = NULL;
+               contact_adaptor_error_code_t _error;
+               _error.code = CONTACT_ADAPTOR_ERROR_NONE;
+               _error.msg = NULL;
+
+               __get_set_me_profile_type_req_type(parameters, &service_name, &type);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_essential_s_type), "", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       return;
+               }
+
+               contact_adaptor_h adaptor = service_adaptor_get_contact_adaptor(service_adaptor);
+               contact_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->contact_context) {
+                       plugin = contact_adaptor_get_plugin_by_name(adaptor, service->contact_context->plugin_uri);
+               }
+
+               char *url = NULL;
+               if ((NULL != adaptor) && (NULL != plugin)) {
+FUNC_STEP();
+                       ret_code = contact_adaptor_set_me_profile_type(plugin, service->contact_context, type, NULL, &url, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->contact_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               contact_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = contact_adaptor_set_me_profile_type(plugin, service->contact_context, type, NULL, &url, &error_code, NULL);
+                       }
+               }
+
+FUNC_STEP();
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NONE;
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_essential_s_type),
+                               __safe_add_string(url), (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(url);
+               free(service_name);
+       }
+FUNC_END();
+}
diff --git a/src/dbus/dbus-ipc.c b/src/dbus/dbus-ipc.c
new file mode 100644 (file)
index 0000000..3b0e335
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+* 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 <glib.h>
+
+#include "service-adaptor-log.h"
+#include "dbus/dbus-ipc.h"
+#include "dbus/dbus-server.h"
+#include "dbus/dbus-server-type.h"
+
+/**
+ * D-Bus server thread.
+ */
+static GThread* dbusServerThread = NULL;
+
+/**
+ * D-Bus server thread main loop context.
+ */
+static GMainContext* dbusServerMainContext = NULL;
+
+/**
+ * D-Bus server thread main loop.
+ */
+static GMainLoop* dbusServerMainLoop = NULL;
+
+/**
+ * @brief D-Bus server thread function.
+ *
+ * D-Bus server thread function. It initialises structures and callbacks needed to export D-Bus interfaces.
+ * @param data Data passed to thread.
+ * @return Result data from thread (always NULL in this implementation).
+ */
+static gpointer dbus_server_thread_func(gpointer data)
+{
+       int ret = 0;
+
+       service_adaptor_debug("[Start] %s", __FUNCTION__);
+       dbusServerMainContext = g_main_context_new();
+       dbusServerMainLoop = g_main_loop_new(dbusServerMainContext, FALSE);
+       g_main_context_push_thread_default(dbusServerMainContext);
+
+       ret = dbus_server_init();
+
+       if (ret == 0) {
+               g_main_loop_run(dbusServerMainLoop);
+       }
+
+       dbus_server_deinit();
+
+       g_main_context_pop_thread_default(dbusServerMainContext);
+       g_main_loop_unref(dbusServerMainLoop);
+       dbusServerMainLoop = NULL;
+       g_main_context_unref(dbusServerMainContext);
+       dbusServerMainContext = NULL;
+
+       return NULL;
+}
+
+int dbus_ipc_server_layer_init()
+{
+       if (dbusServerThread != NULL) {
+               /* D-Bus server thread is already running */
+               return 1;
+       }
+       dbusServerThread = g_thread_new("D-Bus Server Thread", dbus_server_thread_func, NULL);
+
+       return 0;
+}
+
+void dbus_ipc_server_layer_deinit()
+{
+       if (dbusServerMainLoop != NULL) {
+               if (g_main_loop_is_running(dbusServerMainLoop)) {
+                       g_main_loop_quit(dbusServerMainLoop);
+               }
+       }
+       if (dbusServerThread != NULL) {
+               g_thread_join(dbusServerThread);
+               dbusServerThread = NULL;
+       }
+       if (dbusServerMainLoop != NULL) {
+               g_main_loop_unref(dbusServerMainLoop);
+               dbusServerMainLoop = NULL;
+       }
+       if (dbusServerMainContext != NULL) {
+               g_main_context_pop_thread_default(dbusServerMainContext);
+               g_main_context_unref(dbusServerMainContext);
+               dbusServerMainContext = NULL;
+       }
+}
+
+/* EOF */
diff --git a/src/dbus/dbus-message-adaptor.c b/src/dbus/dbus-message-adaptor.c
new file mode 100644 (file)
index 0000000..2ba270a
--- /dev/null
@@ -0,0 +1,2947 @@
+/*
+* 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 <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+#include "service-adaptor.h"
+#include "service-adaptor-message.h"
+#include "service-adaptor-type.h"
+#include "service-adaptor-log.h"
+#include "dbus-message-adaptor.h"
+#include "dbus-server.h"
+#include "dbus-server-type.h"
+#include "dbus-util.h"
+
+static char __MESSAGE_ADAPTOR_ERROR_NONE[] = "0";
+static char __MESSAGE_ADAPTOR_ERROR_NOT_FOUND[] = "10";
+static char __MESSAGE_ADAPTOR_ERROR_CONNECTION[] = "601";
+
+void __get_create_chatroom_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               int64_t *request_id,
+                                               int *chat_type,
+                                               int64_t **receivers,
+                                               unsigned int *receivers_len,
+                                               char **chatroom_title)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_create_chatroom_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_create_chatroom_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *request_id = g_variant_get_int64(req_struct[idx++]);
+       *chat_type = g_variant_get_int32(req_struct[idx++]);
+
+       gsize list_count = g_variant_n_children(req_struct[idx]);
+       *receivers = (int64_t *) calloc(list_count, sizeof(int64_t));
+
+       if (NULL != (*receivers)) {
+               for (gsize i = 0; i < list_count; i++) {
+                       GVariant *info_struct;
+                       GVariant *info_entry_v = g_variant_get_child_value(req_struct[idx], i);
+
+                       info_struct = g_variant_get_child_value(info_entry_v, 0);
+                       (*receivers)[i] = g_variant_get_int64(info_struct);
+               }
+               idx++;
+               *receivers_len = g_variant_get_uint32(req_struct[idx++]);
+       } else {
+               *receivers_len = 0U;
+               idx += 2;
+       }
+
+       *chatroom_title = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_create_chatroom_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_change_chatroom_meta_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               int64_t *request_id,
+                                               int64_t *chatroom_id,
+                                               char **chatroom_title,
+                                               int *default_message_ttl)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_change_chatroom_meta_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_change_chatroom_meta_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *request_id = g_variant_get_int64(req_struct[idx++]);
+       *chatroom_id = g_variant_get_int64(req_struct[idx++]);
+       *chatroom_title = ipc_g_variant_dup_string(req_struct[idx++]);
+       *default_message_ttl = g_variant_get_int32(req_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_change_chatroom_meta_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_chat_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               int64_t *request_id,
+                                               int64_t *chatroom_id,
+                                               message_adaptor_chat_msg_s ***chat_msgs,
+                                               unsigned int *chat_msgs_len)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_chat_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_chat_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *request_id = g_variant_get_int64(req_struct[idx++]);
+       *chatroom_id = g_variant_get_int64(req_struct[idx++]);
+
+       gsize list_count = g_variant_n_children(req_struct[idx]);
+       *chat_msgs = (message_adaptor_chat_msg_s **) calloc(list_count, sizeof(message_adaptor_chat_msg_s *));
+
+       if (NULL != (*chat_msgs)) {
+               for (gsize i = 0; i < list_count; i++) {
+                       GVariant *info_struct[private_service_adaptor_chat_msg_s_type_length];
+                       GVariant *info_entry_v = g_variant_get_child_value(req_struct[idx], i);
+
+                       for (size_t j = 0; j < private_service_adaptor_chat_msg_s_type_length; j++) {
+                               info_struct[j] = g_variant_get_child_value(info_entry_v, j);
+                       }
+
+                       int idx2 = 0;
+                       (*chat_msgs)[i] = (message_adaptor_chat_msg_s *) calloc(1, sizeof(message_adaptor_chat_msg_s));
+                       if (NULL != ((*chat_msgs)[i])) {
+                               (*chat_msgs)[i]->msg_id = g_variant_get_int64(info_struct[idx2++]);
+                               (*chat_msgs)[i]->msg_type = g_variant_get_int32(info_struct[idx2++]);
+                               (*chat_msgs)[i]->chatmsg = ipc_g_variant_dup_string(info_struct[idx2++]);
+                               (*chat_msgs)[i]->message_ttl = g_variant_get_int32(info_struct[idx2++]);
+                       }
+
+                       for (size_t j = 0; j < private_service_adaptor_chat_msg_s_type_length; j++) {
+                               g_variant_unref(info_struct[j]);
+                       }
+                       g_variant_unref(info_entry_v);
+               }
+               idx++;
+               *chat_msgs_len = g_variant_get_uint32(req_struct[idx++]);
+       } else {
+               *chat_msgs_len = 0U;
+               idx += 2;
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_chat_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_allow_chat_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               int64_t *request_id,
+                                               int64_t *chatroom_id,
+                                               bool *is_auto_allow,
+                                               int *max_count,
+                                               bool *need_delivery_acks,
+                                               unsigned long long *delivery_acks_timestamp,
+                                               bool *need_read_ack,
+                                               unsigned long long *last_read_ack_timestamp,
+                                               bool *need_ordered_chat_member_list)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_allow_chat_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_allow_chat_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *request_id = g_variant_get_int64(req_struct[idx++]);
+       *chatroom_id = g_variant_get_int64(req_struct[idx++]);
+       *is_auto_allow = g_variant_get_boolean(req_struct[idx++]);
+       *max_count = g_variant_get_int32(req_struct[idx++]);
+       *need_delivery_acks = g_variant_get_boolean(req_struct[idx++]);
+       *delivery_acks_timestamp = g_variant_get_uint64(req_struct[idx++]);
+       *need_read_ack = g_variant_get_boolean(req_struct[idx++]);
+       *last_read_ack_timestamp = g_variant_get_uint64(req_struct[idx++]);
+       *need_ordered_chat_member_list = g_variant_get_boolean(req_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_allow_chat_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_all_unread_message_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               int64_t *request_id,
+                                               int *max_count)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_all_unread_message_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_all_unread_message_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *request_id = g_variant_get_int64(req_struct[idx++]);
+       *max_count = g_variant_get_int32(req_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_all_unread_message_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_forward_online_message_res_type(GVariant *parameters,
+                                               char **service_name,
+                                               int64_t *request_id,
+                                               int64_t *chatroom_id,
+                                               bool *mark_as_read)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_forward_online_message_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_forward_online_message_res_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *request_id = g_variant_get_int64(req_struct[idx++]);
+       *chatroom_id = g_variant_get_int64(req_struct[idx++]);
+       *mark_as_read = g_variant_get_boolean(req_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_forward_online_message_res_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_forward_unread_message_res_type(GVariant *parameters,
+                                               char **service_name,
+                                               int64_t *request_id,
+                                               char **next_pagination_key,
+                                               int *max_count)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_forward_unread_message_res_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_forward_unread_message_res_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *request_id = g_variant_get_int64(req_struct[idx++]);
+       *next_pagination_key = ipc_g_variant_dup_string(req_struct[idx++]);
+       *max_count = g_variant_get_int32(req_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_forward_unread_message_res_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_read_message_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               int64_t *request_id,
+                                               int64_t *chatroom_id,
+                                               message_adaptor_inbox_message_s **inbox_msg)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_read_message_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_read_message_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *request_id = g_variant_get_int64(req_struct[idx++]);
+       *chatroom_id = g_variant_get_int64(req_struct[idx++]);
+
+       GVariant *req_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++) {
+               req_info_struct[j] = g_variant_get_child_value(req_struct[idx], j);
+       }
+
+       int idx2 = 0;
+       *inbox_msg = (message_adaptor_inbox_message_s *) calloc(1, sizeof(message_adaptor_inbox_message_s));
+       if (NULL != (*inbox_msg)) {
+               (*inbox_msg)->msgId = g_variant_get_int64(req_info_struct[idx2++]);
+               (*inbox_msg)->msgType = g_variant_get_int32(req_info_struct[idx2++]);
+               (*inbox_msg)->sender = g_variant_get_int64(req_info_struct[idx2++]);
+               (*inbox_msg)->receiver = g_variant_get_int64(req_info_struct[idx2++]);
+               (*inbox_msg)->sentTime = g_variant_get_int64(req_info_struct[idx2++]);
+               (*inbox_msg)->chatMsg = ipc_g_variant_dup_string(req_info_struct[idx2++]);
+               (*inbox_msg)->chatroomId = g_variant_get_int64(req_info_struct[idx2++]);
+               (*inbox_msg)->chatType = g_variant_get_int32(req_info_struct[idx2++]);
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_inbox_message_s_type_length; j++) {
+               g_variant_unref(req_info_struct[j]);
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_read_message_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_invite_chat_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               int64_t *request_id,
+                                               int64_t *chatroom_id,
+                                               int64_t **inviting_members,
+                                               unsigned int *inviting_members_len)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_invite_chat_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_invite_chat_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *request_id = g_variant_get_int64(req_struct[idx++]);
+       *chatroom_id = g_variant_get_int64(req_struct[idx++]);
+
+       gsize list_count = g_variant_n_children(req_struct[idx]);
+       *inviting_members = (int64_t *) calloc(list_count, sizeof(int64_t));
+
+       if (NULL != (*inviting_members)) {
+               for (gsize i = 0; i < list_count; i++) {
+                       GVariant *info_entry_v = g_variant_get_child_value(req_struct[idx], i);
+                       GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+                       (*inviting_members)[i] = g_variant_get_int64(info_struct);
+
+                       g_variant_unref(info_struct);
+                       g_variant_unref(info_entry_v);
+               }
+               idx++;
+
+               *inviting_members_len = g_variant_get_uint32(req_struct[idx++]);
+       } else {
+               *inviting_members_len = 0U;
+               idx += 2;
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_invite_chat_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_end_chat_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               int64_t *request_id,
+                                               message_adaptor_end_chat_s ***end_chats,
+                                               unsigned int *end_chats_len)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_end_chat_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_end_chat_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *request_id = g_variant_get_int64(req_struct[idx++]);
+
+       gsize list_count = g_variant_n_children(req_struct[idx]);
+       *end_chats = (message_adaptor_end_chat_s **) calloc(list_count, sizeof(message_adaptor_end_chat_s *));
+
+       if (NULL != (*end_chats)) {
+               for (gsize i = 0; i < list_count; i++) {
+                       GVariant *info_struct[private_service_adaptor_end_chat_s_type_length];
+                       GVariant *info_entry_v = g_variant_get_child_value(req_struct[idx], i);
+
+                       for (size_t j = 0; j < private_service_adaptor_end_chat_s_type_length; j++) {
+                               info_struct[j] = g_variant_get_child_value(info_entry_v, j);
+                       }
+
+                       int idx2 = 0;
+                       (*end_chats)[i] = (message_adaptor_end_chat_s *) calloc(1, sizeof(message_adaptor_end_chat_s));
+                       if (NULL != (*end_chats)[i]) {
+                               (*end_chats)[i]->chatroom_id = g_variant_get_int64(info_struct[idx2++]);
+                               (*end_chats)[i]->deny_invitation = g_variant_get_boolean(info_struct[idx2++]);
+                       }
+
+                       for (size_t j = 0; j < private_service_adaptor_end_chat_s_type_length; j++) {
+                               g_variant_unref(info_struct[j]);
+                       }
+                       g_variant_unref(info_entry_v);
+               }
+               idx++;
+
+               *end_chats_len = g_variant_get_uint32(req_struct[idx++]);
+       } else {
+               *end_chats_len = 0U;
+               idx += 2;
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_end_chat_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_unseal_message_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               int64_t *request_id,
+                                               int64_t *chatroom_id,
+                                               int64_t *sender_id,
+                                               int64_t *message_id,
+                                               char **message_detail)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_unseal_message_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_unseal_message_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *request_id = g_variant_get_int64(req_struct[idx++]);
+       *chatroom_id = g_variant_get_int64(req_struct[idx++]);
+       *sender_id = g_variant_get_int64(req_struct[idx++]);
+       *message_id = g_variant_get_int64(req_struct[idx++]);
+       *message_detail = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_unseal_message_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_save_call_log_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               int64_t *request_id,
+                                               int64_t *chatroom_id,
+                                               char **call_id,
+                                               char **call_log_type,
+                                               int64_t *call_sender_id,
+                                               int64_t *call_receiver_id,
+                                               int *conversaction_second)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_save_call_log_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_save_call_log_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *request_id = g_variant_get_int64(req_struct[idx++]);
+       *chatroom_id = g_variant_get_int64(req_struct[idx++]);
+       *call_id = ipc_g_variant_dup_string(req_struct[idx++]);
+       *call_log_type = ipc_g_variant_dup_string(req_struct[idx++]);
+       *call_sender_id = g_variant_get_int64(req_struct[idx++]);
+       *call_receiver_id = g_variant_get_int64(req_struct[idx++]);
+       *conversaction_second = g_variant_get_int32(req_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_save_call_log_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_current_time_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               int64_t *request_id)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_current_time_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_current_time_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *request_id = g_variant_get_int64(req_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_current_time_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_get_connection_policy_req_type(GVariant *parameters,
+                                               char **service_name)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_get_connection_policy_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_get_connection_policy_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_get_connection_policy_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_set_connection_policy_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               int *policy)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_set_connection_policy_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_set_connection_policy_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *policy = g_variant_get_int32(req_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_set_connection_policy_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+
+
+void __get_chat_id_list_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               message_adaptor_phone_number_s ***phone_number,
+                                               unsigned int *phone_number_len)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_chat_id_list_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_chat_id_list_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       gsize list_count = g_variant_n_children(req_struct[idx]);
+       *phone_number = (message_adaptor_phone_number_s **) calloc(list_count, sizeof(message_adaptor_phone_number_s *));
+
+       if (NULL != (*phone_number)) {
+               for (gsize i = 0; i < list_count; i++) {
+                       GVariant *info_struct[private_service_adaptor_phone_number_s_type_length];
+                       GVariant *info_entry_v = g_variant_get_child_value(req_struct[idx], i);
+
+                       for (size_t j = 0; j < private_service_adaptor_phone_number_s_type_length; j++) {
+                               info_struct[j] = g_variant_get_child_value(info_entry_v, j);
+                       }
+
+                       int idx2 = 0;
+                       (*phone_number)[i] = (message_adaptor_phone_number_s *) calloc(1, sizeof(message_adaptor_phone_number_s));
+                       if (NULL != (*phone_number)[i]) {
+                               (*phone_number)[i]->phonenumber = ipc_g_variant_dup_string(info_struct[idx2++]);
+                               (*phone_number)[i]->ccc = ipc_g_variant_dup_string(info_struct[idx2++]);
+                       }
+
+                       for (size_t j = 0; j < private_service_adaptor_phone_number_s_type_length; j++) {
+                               g_variant_unref(info_struct[j]);
+                       }
+               }
+               idx++;
+
+               *phone_number_len = g_variant_get_uint32(req_struct[idx++]);
+       } else {
+               *phone_number_len = 0U;
+               idx += 2;
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_chat_id_list_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_msisdn_list_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               int64_t **chat_ids,
+                                               unsigned int *chat_ids_len)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_msisdn_list_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_msisdn_list_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       gsize list_count = g_variant_n_children(req_struct[idx]);
+       *chat_ids = (int64_t *) calloc(list_count, sizeof(int64_t));
+
+       if (NULL != (*chat_ids)) {
+               for (gsize i = 0; i < list_count; i++) {
+                       GVariant *info_entry_v = g_variant_get_child_value(req_struct[idx], i);
+                       GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);;
+
+                       (*chat_ids)[i] = g_variant_get_int64(info_struct);
+
+                       g_variant_unref(info_struct);
+               }
+               idx++;
+
+               *chat_ids_len = g_variant_get_uint32(req_struct[idx++]);
+       } else {
+               *chat_ids_len = 0U;
+               idx += 2;
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_msisdn_list_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+GVariant *__create_chat_id_list_res_type(message_adaptor_chat_id_s **chat_ids,
+                                               unsigned int chat_ids_len,
+                                               message_adaptor_error_code_t *error_code)
+{
+       if (NULL == chat_ids) {
+               chat_ids_len = 0;
+       }
+
+       GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE(private_message_chat_id_list_type));
+
+       for (gsize i = 0; i < chat_ids_len; i++) {
+               g_variant_builder_open(builder, G_VARIANT_TYPE(private_service_adaptor_chat_id_s_type));
+               g_variant_builder_add(builder, "x", chat_ids[i]->chatid);
+               safe_g_variant_builder_add_string(builder, chat_ids[i]->msisdn);
+               g_variant_builder_close(builder);
+       }
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_chat_id_list_res_s_type),
+                       builder, chat_ids_len, (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg));
+
+       g_variant_builder_unref(builder);
+
+       return response;
+}
+
+void message_adaptor_method_call(GDBusConnection *connection,
+                                               const gchar *sender,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *method_name,
+                                               GVariant *parameters,
+                                               GDBusMethodInvocation *invocation,
+                                               gpointer user_data)
+{
+       service_adaptor_internal_error_code_e ret_code = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+
+       if (0 == g_strcmp0(method_name, PRIVATE_DBUS_REQUEST_CREATE_CHATROOM_METHOD)) {
+               char *service_name = NULL;
+               int64_t request_id = 0;
+               int chat_type = 0;
+               int64_t *receivers = NULL;
+               unsigned int receivers_len = 0;
+               char *chatroom_title = NULL;
+               message_adaptor_error_code_t *error_code = NULL;
+               message_adaptor_error_code_t _error;
+               _error.code = _error.msg = NULL;
+
+               __get_create_chatroom_req_type(parameters, &service_name, &request_id, &chat_type,
+                               &receivers, &receivers_len, &chatroom_title);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = __MESSAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       free(receivers);
+                       free(chatroom_title);
+                       return;
+               }
+
+               message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+               message_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->message_context) {
+                       plugin = message_adaptor_get_plugin_by_name(adaptor, service->message_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       if (MESSAGE_CONNECTION_POLICY_DISCONNECT == service->message_context->connection_policy) {
+                               service_adaptor_debug_func("Connection disconnected. Convert Auto connection");
+                               ret_code = service_adaptor_message_set_connection(plugin, service->message_context, MESSAGE_CONNECTION_POLICY_AUTO, &error_code);
+                               service_adaptor_debug("set_connection res (%d)", ret_code);
+                               if (NULL != error_code) {
+                                       service_adaptor_debug("rcode : %s, msg : %s", error_code->code, error_code->msg);
+                                       free(error_code->code);
+                                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_CONNECTION);
+                               } else if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                                       error_code = message_adaptor_create_error_code(__MESSAGE_ADAPTOR_ERROR_CONNECTION, "Server connect failed");
+                               }
+                       }
+                       if (NULL == error_code) {
+                               ret_code = message_adaptor_create_chatroom_request(plugin,
+                                               service->message_context, request_id, chat_type, &receivers, receivers_len, chatroom_title, &error_code, NULL);
+
+                               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                                       service_adaptor_info("API returns auth-error. Try refresh auth");
+                                       service_adaptor_auth_refresh(service_adaptor, service_name, service->message_context->plugin_uri);
+
+                                       service_adaptor_debug("Empty error_code already issued (%s: %s)", error_code ? error_code->code : NULL, error_code ? error_code->msg : NULL);
+                                       message_adaptor_destroy_error_code(&error_code);
+
+                                       service_adaptor_debug("Re-try API");
+                                       ret_code = message_adaptor_create_chatroom_request(plugin,
+                                                       service->message_context, request_id, chat_type, &receivers, receivers_len, chatroom_title, &error_code, NULL);
+                               }
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_NONE);
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       free(_error.code);
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(receivers);
+               free(chatroom_title);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_REQUEST_CHANGE_CHATROOM_META_METHOD)) {
+               char *service_name = NULL;
+               int64_t request_id = 0;
+               int64_t chatroom_id = 0;
+               char *chatroom_title = NULL;
+               int default_message_ttl = 0;
+
+               message_adaptor_error_code_t *error_code = NULL;
+               message_adaptor_error_code_t _error;
+               _error.code = _error.msg = NULL;
+
+               __get_change_chatroom_meta_req_type(parameters, &service_name, &request_id, &chatroom_id,
+                               &chatroom_title, &default_message_ttl);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = __MESSAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       free(chatroom_title);
+                       return;
+               }
+
+               message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+               message_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->message_context) {
+                       plugin = message_adaptor_get_plugin_by_name(adaptor, service->message_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       if (MESSAGE_CONNECTION_POLICY_DISCONNECT == service->message_context->connection_policy) {
+                               service_adaptor_debug_func("Connection disconnected. Convert Auto connection");
+                               ret_code = service_adaptor_message_set_connection(plugin, service->message_context, MESSAGE_CONNECTION_POLICY_AUTO, &error_code);
+                               service_adaptor_debug("set_connection res (%d)", ret_code);
+                               if (NULL != error_code) {
+                                       service_adaptor_debug("rcode : %s, msg : %s", error_code->code, error_code->msg);
+                                       free(error_code->code);
+                                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_CONNECTION);
+                               } else if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                                       error_code = message_adaptor_create_error_code(__MESSAGE_ADAPTOR_ERROR_CONNECTION, "Server connect failed");
+                               }
+                       }
+                       if (NULL == error_code) {
+                               ret_code = message_adaptor_change_chatroom_meta_request(plugin, service->message_context,
+                                               request_id, chatroom_id, chatroom_title, default_message_ttl, &error_code, NULL);
+
+                               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                                       service_adaptor_info("API returns auth-error. Try refresh auth");
+                                       service_adaptor_auth_refresh(service_adaptor, service_name, service->message_context->plugin_uri);
+
+                                       service_adaptor_debug("Empty error_code already issued (%s: %s)", error_code ? error_code->code : NULL, error_code ? error_code->msg : NULL);
+                                       message_adaptor_destroy_error_code(&error_code);
+
+                                       service_adaptor_debug("Re-try API");
+                                       ret_code = message_adaptor_change_chatroom_meta_request(plugin, service->message_context,
+                                                       request_id, chatroom_id, chatroom_title, default_message_ttl, &error_code, NULL);
+                               }
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_NONE);
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       free(_error.code);
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(chatroom_title);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_REQUEST_CHAT_METHOD)) {
+               char *service_name = NULL;
+               int64_t request_id = 0;
+               int64_t chatroom_id = 0;
+               message_adaptor_chat_msg_s **chat_msgs = NULL;
+               unsigned int chat_msgs_len = 0;
+               message_adaptor_error_code_t *error_code = NULL;
+               message_adaptor_error_code_t _error;
+               _error.code = _error.msg = NULL;
+
+               __get_chat_req_type(parameters, &service_name, &request_id, &chatroom_id, &chat_msgs, &chat_msgs_len);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = __MESSAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       if ((NULL != chat_msgs) && (0U < chat_msgs_len)) {
+                               for (int i = 0; i < chat_msgs_len; i++) {
+                                       if (NULL != chat_msgs[i]) {
+                                               free(chat_msgs[i]->chatmsg);
+                                               free(chat_msgs[i]);
+                                       }
+                               }
+                               free(chat_msgs);
+                       }
+                       return;
+               }
+
+               message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+               message_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->message_context) {
+                       plugin = message_adaptor_get_plugin_by_name(adaptor, service->message_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       if (MESSAGE_CONNECTION_POLICY_DISCONNECT == service->message_context->connection_policy) {
+                               service_adaptor_debug_func("Connection disconnected. Convert Auto connection");
+                               ret_code = service_adaptor_message_set_connection(plugin, service->message_context, MESSAGE_CONNECTION_POLICY_AUTO, &error_code);
+                               service_adaptor_debug("set_connection res (%d)", ret_code);
+                               if (NULL != error_code) {
+                                       service_adaptor_debug("rcode : %s, msg : %s", error_code->code, error_code->msg);
+                                       free(error_code->code);
+                                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_CONNECTION);
+                               } else if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                                       error_code = message_adaptor_create_error_code(__MESSAGE_ADAPTOR_ERROR_CONNECTION, "Server connect failed");
+                               }
+                       }
+                       if (NULL == error_code) {
+                               ret_code = message_adaptor_chat_request(plugin, service->message_context,
+                                               request_id, chatroom_id, chat_msgs, chat_msgs_len, &error_code, NULL);
+
+                               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                                       service_adaptor_info("API returns auth-error. Try refresh auth");
+                                       service_adaptor_auth_refresh(service_adaptor, service_name, service->message_context->plugin_uri);
+
+                                       service_adaptor_debug("Empty error_code already issued (%s: %s)", error_code ? error_code->code : NULL, error_code ? error_code->msg : NULL);
+                                       message_adaptor_destroy_error_code(&error_code);
+
+                                       service_adaptor_debug("Re-try API");
+                                       ret_code = message_adaptor_chat_request(plugin, service->message_context,
+                                                       request_id, chatroom_id, chat_msgs, chat_msgs_len, &error_code, NULL);
+                               }
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_NONE);
+                       error_code->msg = strdup("");
+               }
+
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       free(_error.code);
+                       free(_error.msg);
+               }
+
+               free(service_name);
+               if ((NULL != chat_msgs) && (0U < chat_msgs_len)) {
+                       for (int i = 0; i < chat_msgs_len; i++) {
+                               if (NULL != chat_msgs[i]) {
+                                       free(chat_msgs[i]->chatmsg);
+                                       free(chat_msgs[i]);
+                               }
+                       }
+                       free(chat_msgs);
+               }
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_REQUEST_ALLOW_CHAT_METHOD)) {
+               char *service_name = NULL;
+               int64_t request_id = 0;
+               int64_t chatroom_id = 0;
+               bool is_auto_allow = false;
+               int max_count = 0;
+               bool need_delivery_acks = false;
+               unsigned long long delivery_acks_timestamp = 0;
+               bool need_read_ack = false;
+               unsigned long long last_read_ack_timestamp = 0;
+               bool need_ordered_chat_member_list = false;
+               message_adaptor_error_code_t *error_code = NULL;
+               message_adaptor_error_code_t _error;
+               _error.code = _error.msg = NULL;
+
+               __get_allow_chat_req_type(parameters, &service_name, &request_id, &chatroom_id, &is_auto_allow, &max_count,
+                               &need_delivery_acks, &delivery_acks_timestamp,
+                               &need_read_ack, &last_read_ack_timestamp,
+                               &need_ordered_chat_member_list);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = __MESSAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       return;
+               }
+
+               message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+               message_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->message_context) {
+                       plugin = message_adaptor_get_plugin_by_name(adaptor, service->message_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       if (MESSAGE_CONNECTION_POLICY_DISCONNECT == service->message_context->connection_policy) {
+                               service_adaptor_debug_func("Connection disconnected. Convert Auto connection");
+                               ret_code = service_adaptor_message_set_connection(plugin, service->message_context, MESSAGE_CONNECTION_POLICY_AUTO, &error_code);
+                               service_adaptor_debug("set_connection res (%d)", ret_code);
+                               if (NULL != error_code) {
+                                       service_adaptor_debug("rcode : %s, msg : %s", error_code->code, error_code->msg);
+                                       free(error_code->code);
+                                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_CONNECTION);
+                               } else if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                                       error_code = message_adaptor_create_error_code(__MESSAGE_ADAPTOR_ERROR_CONNECTION, "Server connect failed");
+                               }
+                       }
+                       if (NULL == error_code) {
+                               ret_code = message_adaptor_allow_chat_request(plugin, service->message_context,
+                                               request_id, chatroom_id, is_auto_allow, max_count, need_delivery_acks, delivery_acks_timestamp,
+                                               need_read_ack, last_read_ack_timestamp, need_ordered_chat_member_list, &error_code, NULL);
+
+                               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                                       service_adaptor_info("API returns auth-error. Try refresh auth");
+                                       service_adaptor_auth_refresh(service_adaptor, service_name, service->message_context->plugin_uri);
+
+                                       service_adaptor_debug("Empty error_code already issued (%s: %s)", error_code ? error_code->code : NULL, error_code ? error_code->msg : NULL);
+                                       message_adaptor_destroy_error_code(&error_code);
+
+                                       service_adaptor_debug("Re-try API");
+                                       ret_code = message_adaptor_allow_chat_request(plugin, service->message_context,
+                                                       request_id, chatroom_id, is_auto_allow, max_count, need_delivery_acks, delivery_acks_timestamp,
+                                                       need_read_ack, last_read_ack_timestamp, need_ordered_chat_member_list, &error_code, NULL);
+                               }
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_NONE);
+                       error_code->msg = strdup("");
+               }
+
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       free(_error.code);
+                       free(_error.msg);
+               }
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_REQUEST_ALL_UNREAD_MESSAGE_METHOD)) {
+               char *service_name = NULL;
+               int64_t request_id = 0;
+               int max_count = 0;
+               message_adaptor_error_code_t *error_code = NULL;
+               message_adaptor_error_code_t _error;
+               _error.code = _error.msg = NULL;
+
+               __get_all_unread_message_req_type(parameters, &service_name, &request_id, &max_count);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = __MESSAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       return;
+               }
+
+               message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+               message_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->message_context) {
+                       plugin = message_adaptor_get_plugin_by_name(adaptor, service->message_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       if (MESSAGE_CONNECTION_POLICY_DISCONNECT == service->message_context->connection_policy) {
+                               service_adaptor_debug_func("Connection disconnected. Convert Auto connection");
+                               ret_code = service_adaptor_message_set_connection(plugin, service->message_context, MESSAGE_CONNECTION_POLICY_AUTO, &error_code);
+                               service_adaptor_debug("set_connection res (%d)", ret_code);
+                               if (NULL != error_code) {
+                                       service_adaptor_debug("rcode : %s, msg : %s", error_code->code, error_code->msg);
+                                       free(error_code->code);
+                                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_CONNECTION);
+                               } else if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                                       error_code = message_adaptor_create_error_code(__MESSAGE_ADAPTOR_ERROR_CONNECTION, "Server connect failed");
+                               }
+                       }
+                       if (NULL == error_code) {
+                               ret_code = message_adaptor_get_all_unread_message_request(plugin, service->message_context,
+                                               request_id, max_count, &error_code, NULL);
+
+                               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                                       service_adaptor_info("API returns auth-error. Try refresh auth");
+                                       service_adaptor_auth_refresh(service_adaptor, service_name, service->message_context->plugin_uri);
+
+                                       service_adaptor_debug("Empty error_code already issued (%s: %s)", error_code ? error_code->code : NULL, error_code ? error_code->msg : NULL);
+                                       message_adaptor_destroy_error_code(&error_code);
+
+                                       service_adaptor_debug("Re-try API");
+                                       ret_code = message_adaptor_get_all_unread_message_request(plugin, service->message_context,
+                                                       request_id, max_count, &error_code, NULL);
+                               }
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_NONE);
+                       error_code->msg = strdup("");
+               }
+
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       free(_error.code);
+                       free(_error.msg);
+               }
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_REPLY_FORWARD_ONLINE_MESSAGE_METHOD)) {
+               char *service_name = NULL;
+               int64_t request_id = 0;
+               int64_t chatroom_id = 0;
+               bool mark_as_read = false;
+               message_adaptor_error_code_t *error_code = NULL;
+               message_adaptor_error_code_t _error;
+               _error.code = _error.msg = NULL;
+
+               __get_forward_online_message_res_type(parameters, &service_name, &request_id, &chatroom_id, &mark_as_read);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = __MESSAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       return;
+               }
+
+               message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+               message_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->message_context) {
+                       plugin = message_adaptor_get_plugin_by_name(adaptor, service->message_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       if (MESSAGE_CONNECTION_POLICY_DISCONNECT == service->message_context->connection_policy) {
+                               service_adaptor_debug_func("Connection disconnected. Convert Auto connection");
+                               ret_code = service_adaptor_message_set_connection(plugin, service->message_context, MESSAGE_CONNECTION_POLICY_AUTO, &error_code);
+                               service_adaptor_debug("set_connection res (%d)", ret_code);
+                               if (NULL != error_code) {
+                                       service_adaptor_debug("rcode : %s, msg : %s", error_code->code, error_code->msg);
+                                       free(error_code->code);
+                                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_CONNECTION);
+                               } else if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                                       error_code = message_adaptor_create_error_code(__MESSAGE_ADAPTOR_ERROR_CONNECTION, "Server connect failed");
+                               }
+                       }
+                       if (NULL == error_code) {
+                               ret_code = message_adaptor_forward_online_message_reply(plugin, service->message_context,
+                                               request_id, chatroom_id, mark_as_read, &error_code, NULL);
+
+                               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                                       service_adaptor_info("API returns auth-error. Try refresh auth");
+                                       service_adaptor_auth_refresh(service_adaptor, service_name, service->message_context->plugin_uri);
+
+                                       service_adaptor_debug("Empty error_code already issued (%s: %s)", error_code ? error_code->code : NULL, error_code ? error_code->msg : NULL);
+                                       message_adaptor_destroy_error_code(&error_code);
+
+                                       service_adaptor_debug("Re-try API");
+                                       ret_code = message_adaptor_forward_online_message_reply(plugin, service->message_context,
+                                                       request_id, chatroom_id, mark_as_read, &error_code, NULL);
+                               }
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_NONE);
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       free(_error.code);
+                       free(_error.msg);
+               }
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_REPLY_FORWARD_UNREAD_MESSAGE_METHOD)) {
+               char *service_name = NULL;
+               int64_t request_id = 0;
+               char *next_pagination_key = NULL;
+               int max_count = 0;
+               message_adaptor_error_code_t *error_code = NULL;
+               message_adaptor_error_code_t _error;
+               _error.code = _error.msg = NULL;
+
+               __get_forward_unread_message_res_type(parameters, &service_name, &request_id, &next_pagination_key, &max_count);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = __MESSAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       free(next_pagination_key);
+                       return;
+               }
+
+               message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+               message_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->message_context) {
+                       plugin = message_adaptor_get_plugin_by_name(adaptor, service->message_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       if (MESSAGE_CONNECTION_POLICY_DISCONNECT == service->message_context->connection_policy) {
+                               service_adaptor_debug_func("Connection disconnected. Convert Auto connection");
+                               ret_code = service_adaptor_message_set_connection(plugin, service->message_context, MESSAGE_CONNECTION_POLICY_AUTO, &error_code);
+                               service_adaptor_debug("set_connection res (%d)", ret_code);
+                               if (NULL != error_code) {
+                                       service_adaptor_debug("rcode : %s, msg : %s", error_code->code, error_code->msg);
+                                       free(error_code->code);
+                                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_CONNECTION);
+                               } else if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                                       error_code = message_adaptor_create_error_code(__MESSAGE_ADAPTOR_ERROR_CONNECTION, "Server connect failed");
+                               }
+                       }
+                       if (NULL == error_code) {
+                               ret_code = message_adaptor_forward_unread_message_reply(plugin, service->message_context,
+                                               request_id, next_pagination_key, max_count, &error_code, NULL);
+
+                               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                                       service_adaptor_info("API returns auth-error. Try refresh auth");
+                                       service_adaptor_auth_refresh(service_adaptor, service_name, service->message_context->plugin_uri);
+
+                                       service_adaptor_debug("Empty error_code already issued (%s: %s)", error_code ? error_code->code : NULL, error_code ? error_code->msg : NULL);
+                                       message_adaptor_destroy_error_code(&error_code);
+
+                                       service_adaptor_debug("Re-try API");
+                                       ret_code = message_adaptor_forward_unread_message_reply(plugin, service->message_context,
+                                                       request_id, next_pagination_key, max_count, &error_code, NULL);
+                               }
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_NONE);
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       free(_error.code);
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(next_pagination_key);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_REQUEST_READ_MESSAGE_METHOD)) {
+               char *service_name = NULL;
+               int64_t request_id = 0;
+               int64_t chatroom_id = 0;
+               message_adaptor_inbox_message_s *inbox_msg = NULL;
+               message_adaptor_error_code_t *error_code = NULL;
+               message_adaptor_error_code_t _error;
+               _error.code = _error.msg = NULL;
+
+               __get_read_message_req_type(parameters, &service_name, &request_id, &chatroom_id, &inbox_msg);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = __MESSAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       if (NULL != inbox_msg) {
+                               free(inbox_msg->chatMsg);
+                               free(inbox_msg);
+                       }
+                       return;
+               }
+
+               message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+               message_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->message_context) {
+                       plugin = message_adaptor_get_plugin_by_name(adaptor, service->message_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       if (MESSAGE_CONNECTION_POLICY_DISCONNECT == service->message_context->connection_policy) {
+                               service_adaptor_debug_func("Connection disconnected. Convert Auto connection");
+                               ret_code = service_adaptor_message_set_connection(plugin, service->message_context, MESSAGE_CONNECTION_POLICY_AUTO, &error_code);
+                               service_adaptor_debug("set_connection res (%d)", ret_code);
+                               if (NULL != error_code) {
+                                       service_adaptor_debug("rcode : %s, msg : %s", error_code->code, error_code->msg);
+                                       free(error_code->code);
+                                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_CONNECTION);
+                               } else if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                                       error_code = message_adaptor_create_error_code(__MESSAGE_ADAPTOR_ERROR_CONNECTION, "Server connect failed");
+                               }
+                       }
+                       if (NULL == error_code) {
+                               ret_code = message_adaptor_read_message_request(plugin, service->message_context,
+                                               request_id, chatroom_id, inbox_msg, &error_code, NULL);
+
+                               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                                       service_adaptor_info("API returns auth-error. Try refresh auth");
+                                       service_adaptor_auth_refresh(service_adaptor, service_name, service->message_context->plugin_uri);
+
+                                       service_adaptor_debug("Empty error_code already issued (%s: %s)", error_code ? error_code->code : NULL, error_code ? error_code->msg : NULL);
+                                       message_adaptor_destroy_error_code(&error_code);
+
+                                       service_adaptor_debug("Re-try API");
+                                       ret_code = message_adaptor_read_message_request(plugin, service->message_context,
+                                                       request_id, chatroom_id, inbox_msg, &error_code, NULL);
+                               }
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_NONE);
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       free(_error.code);
+                       free(_error.msg);
+               }
+               free(service_name);
+               if (NULL != inbox_msg) {
+                       free(inbox_msg->chatMsg);
+                       free(inbox_msg);
+               }
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_REQUEST_INVITE_CHAT_METHOD)) {
+               char *service_name = NULL;
+               int64_t request_id = 0;
+               int64_t chatroom_id = 0;
+               int64_t *inviting_members = NULL;
+               unsigned int inviting_members_len = 0;
+               message_adaptor_error_code_t *error_code = NULL;
+               message_adaptor_error_code_t _error;
+               _error.code = _error.msg = NULL;
+
+               __get_invite_chat_req_type(parameters, &service_name, &request_id,
+                               &chatroom_id, &inviting_members, &inviting_members_len);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = __MESSAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       free(inviting_members);
+                       return;
+               }
+
+               message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+               message_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->message_context) {
+                       plugin = message_adaptor_get_plugin_by_name(adaptor, service->message_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       if (MESSAGE_CONNECTION_POLICY_DISCONNECT == service->message_context->connection_policy) {
+                               service_adaptor_debug_func("Connection disconnected. Convert Auto connection");
+                               ret_code = service_adaptor_message_set_connection(plugin, service->message_context, MESSAGE_CONNECTION_POLICY_AUTO, &error_code);
+                               service_adaptor_debug("set_connection res (%d)", ret_code);
+                               if (NULL != error_code) {
+                                       service_adaptor_debug("rcode : %s, msg : %s", error_code->code, error_code->msg);
+                                       free(error_code->code);
+                                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_CONNECTION);
+                               } else if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                                       error_code = message_adaptor_create_error_code(__MESSAGE_ADAPTOR_ERROR_CONNECTION, "Server connect failed");
+                               }
+                       }
+                       if (NULL == error_code) {
+                               ret_code = message_adaptor_invite_chat_request(plugin, service->message_context,
+                                               request_id, chatroom_id, inviting_members, inviting_members_len, &error_code, NULL);
+
+                               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                                       service_adaptor_info("API returns auth-error. Try refresh auth");
+                                       service_adaptor_auth_refresh(service_adaptor, service_name, service->message_context->plugin_uri);
+
+                                       service_adaptor_debug("Empty error_code already issued (%s: %s)", error_code ? error_code->code : NULL, error_code ? error_code->msg : NULL);
+                                       message_adaptor_destroy_error_code(&error_code);
+
+                                       service_adaptor_debug("Re-try API");
+                                       ret_code = message_adaptor_invite_chat_request(plugin, service->message_context,
+                                                       request_id, chatroom_id, inviting_members, inviting_members_len, &error_code, NULL);
+                               }
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_NONE);
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       free(_error.code);
+                       free(_error.msg);
+               }
+
+               free(service_name);
+               free(inviting_members);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_REQUEST_END_CHAT_METHOD)) {
+               char *service_name = NULL;
+               int64_t request_id = 0;
+               message_adaptor_end_chat_s **end_chats = NULL;
+               unsigned int end_chats_len = 0;
+               message_adaptor_error_code_t *error_code = NULL;
+               message_adaptor_error_code_t _error;
+               _error.code = _error.msg = NULL;
+
+               __get_end_chat_req_type(parameters, &service_name, &request_id, &end_chats, &end_chats_len);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = __MESSAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       if ((NULL != end_chats) && (0U < end_chats_len)) {
+                               for (int i = 0; i < end_chats_len; i++) {
+                                       free(end_chats[i]);
+                               }
+                               free(end_chats);
+                       }
+                       return;
+               }
+
+               message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+               message_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->message_context) {
+                       plugin = message_adaptor_get_plugin_by_name(adaptor, service->message_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       if (MESSAGE_CONNECTION_POLICY_DISCONNECT == service->message_context->connection_policy) {
+                               service_adaptor_debug_func("Connection disconnected. Convert Auto connection");
+                               ret_code = service_adaptor_message_set_connection(plugin, service->message_context, MESSAGE_CONNECTION_POLICY_AUTO, &error_code);
+                               service_adaptor_debug("set_connection res (%d)", ret_code);
+                               if (NULL != error_code) {
+                                       service_adaptor_debug("rcode : %s, msg : %s", error_code->code, error_code->msg);
+                                       free(error_code->code);
+                                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_CONNECTION);
+                               } else if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                                       error_code = message_adaptor_create_error_code(__MESSAGE_ADAPTOR_ERROR_CONNECTION, "Server connect failed");
+                               }
+                       }
+                       if (NULL == error_code) {
+                               ret_code = message_adaptor_end_chat_request(plugin, service->message_context,
+                                               request_id, end_chats, end_chats_len, &error_code, NULL);
+
+                               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                                       service_adaptor_info("API returns auth-error. Try refresh auth");
+                                       service_adaptor_auth_refresh(service_adaptor, service_name, service->message_context->plugin_uri);
+
+                                       service_adaptor_debug("Empty error_code already issued (%s: %s)", error_code ? error_code->code : NULL, error_code ? error_code->msg : NULL);
+                                       message_adaptor_destroy_error_code(&error_code);
+
+                                       service_adaptor_debug("Re-try API");
+                                       ret_code = message_adaptor_end_chat_request(plugin, service->message_context,
+                                                       request_id, end_chats, end_chats_len, &error_code, NULL);
+                               }
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_NONE);
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       free(_error.code);
+                       free(_error.msg);
+               }
+               free(service_name);
+               if ((NULL != end_chats) && (0U < end_chats_len)) {
+                       for (int i = 0; i < end_chats_len; i++) {
+                               free(end_chats[i]);
+                       }
+                       free(end_chats);
+               }
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_REQUEST_UNSEAL_MESSAGE_METHOD)) {
+               char *service_name = NULL;
+               int64_t request_id = 0;
+               int64_t chatroom_id = 0;
+               int64_t sender_id = 0;
+               int64_t message_id = 0;
+               char *message_detail = NULL;
+               message_adaptor_error_code_t *error_code = NULL;
+               message_adaptor_error_code_t _error;
+               _error.code = _error.msg = NULL;
+
+               __get_unseal_message_req_type(parameters, &service_name, &request_id, &chatroom_id, &sender_id, &message_id, &message_detail);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = __MESSAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       free(message_detail);
+                       return;
+               }
+
+               message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+               message_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->message_context) {
+                       plugin = message_adaptor_get_plugin_by_name(adaptor, service->message_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       if (MESSAGE_CONNECTION_POLICY_DISCONNECT == service->message_context->connection_policy) {
+                               service_adaptor_debug_func("Connection disconnected. Convert Auto connection");
+                               ret_code = service_adaptor_message_set_connection(plugin, service->message_context, MESSAGE_CONNECTION_POLICY_AUTO, &error_code);
+                               service_adaptor_debug("set_connection res (%d)", ret_code);
+                               if (NULL != error_code) {
+                                       service_adaptor_debug("rcode : %s, msg : %s", error_code->code, error_code->msg);
+                                       free(error_code->code);
+                                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_CONNECTION);
+                               } else if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                                       error_code = message_adaptor_create_error_code(__MESSAGE_ADAPTOR_ERROR_CONNECTION, "Server connect failed");
+                               }
+                       }
+                       if (NULL == error_code) {
+                               ret_code = message_adaptor_unseal_message_request(plugin, service->message_context,
+                                               request_id, chatroom_id, sender_id, message_id, message_detail, &error_code, NULL);
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_NONE);
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       free(_error.code);
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(message_detail);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_REQUEST_SAVE_CALL_LOG_METHOD)) {
+               char *service_name = NULL;
+               int64_t request_id = 0;
+               int64_t chatroom_id = 0;
+               char *call_id = NULL;
+               char *call_log_type = NULL;
+               int64_t call_sender_id = 0;
+               int64_t call_receiver_id = 0;
+               int conversaction_second = 0;
+               message_adaptor_error_code_t *error_code = NULL;
+               message_adaptor_error_code_t _error;
+               _error.code = _error.msg = NULL;
+
+               __get_save_call_log_req_type(parameters, &service_name, &request_id, &chatroom_id, &call_id, &call_log_type, &call_sender_id, &call_receiver_id, &conversaction_second);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = __MESSAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       free(call_id);
+                       free(call_log_type);
+                       return;
+               }
+
+               message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+               message_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->message_context) {
+                       plugin = message_adaptor_get_plugin_by_name(adaptor, service->message_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       if (MESSAGE_CONNECTION_POLICY_DISCONNECT == service->message_context->connection_policy) {
+                               service_adaptor_debug_func("Connection disconnected. Convert Auto connection");
+                               ret_code = service_adaptor_message_set_connection(plugin, service->message_context, MESSAGE_CONNECTION_POLICY_AUTO, &error_code);
+                               service_adaptor_debug("set_connection res (%d)", ret_code);
+                               if (NULL != error_code) {
+                                       service_adaptor_debug("rcode : %s, msg : %s", error_code->code, error_code->msg);
+                                       free(error_code->code);
+                                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_CONNECTION);
+                               } else if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                                       error_code = message_adaptor_create_error_code(__MESSAGE_ADAPTOR_ERROR_CONNECTION, "Server connect failed");
+                               }
+                       }
+                       if (NULL == error_code) {
+                               ret_code = message_adaptor_save_call_log_request(plugin, service->message_context, request_id, chatroom_id,
+                                               call_id, call_log_type, call_sender_id, call_receiver_id, conversaction_second, &error_code, NULL);
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_NONE);
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       free(_error.code);
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(call_id);
+               free(call_log_type);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_REQUEST_CURRENT_TIME_METHOD)) {
+               char *service_name = NULL;
+               int64_t request_id = 0;
+               message_adaptor_error_code_t *error_code = NULL;
+               message_adaptor_error_code_t _error;
+               _error.code = _error.msg = NULL;
+
+               __get_current_time_req_type(parameters, &service_name, &request_id);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = __MESSAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       return;
+               }
+
+               message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+               message_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->message_context) {
+                       plugin = message_adaptor_get_plugin_by_name(adaptor, service->message_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       if (MESSAGE_CONNECTION_POLICY_DISCONNECT == service->message_context->connection_policy) {
+                               service_adaptor_debug_func("Connection disconnected. Convert Auto connection");
+                               ret_code = service_adaptor_message_set_connection(plugin, service->message_context, MESSAGE_CONNECTION_POLICY_AUTO, &error_code);
+                               service_adaptor_debug("set_connection res (%d)", ret_code);
+                               if (NULL != error_code) {
+                                       service_adaptor_debug("rcode : %s, msg : %s", error_code->code, error_code->msg);
+                                       free(error_code->code);
+                                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_CONNECTION);
+                               } else if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                                       error_code = message_adaptor_create_error_code(__MESSAGE_ADAPTOR_ERROR_CONNECTION, "Server connect failed");
+                               }
+                       }
+                       if (NULL == error_code) {
+                               ret_code = message_adaptor_current_time_request(plugin, service->message_context,
+                                               request_id, &error_code, NULL);
+
+                               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                                       service_adaptor_info("API returns auth-error. Try refresh auth");
+                                       service_adaptor_auth_refresh(service_adaptor, service_name, service->message_context->plugin_uri);
+
+                                       service_adaptor_debug("Empty error_code already issued (%s: %s)", error_code ? error_code->code : NULL, error_code ? error_code->msg : NULL);
+                                       message_adaptor_destroy_error_code(&error_code);
+
+                                       service_adaptor_debug("Re-try API");
+                                       ret_code = message_adaptor_current_time_request(plugin, service->message_context,
+                                                       request_id, &error_code, NULL);
+                               }
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_NONE);
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       free(_error.code);
+                       free(_error.msg);
+               }
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_REQUEST_GET_CONNECTION_POLICY_METHOD)) {
+               char *service_name = NULL;
+               message_adaptor_error_code_t *error_code = NULL;
+               message_adaptor_error_code_t _error;
+               _error.code = _error.msg = NULL;
+
+               __get_get_connection_policy_req_type(parameters, &service_name);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if ((NULL == service) || (NULL == service->message_context)) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = __MESSAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_connection_policy_res_s_type),
+                                       (int32_t) MESSAGE_CONNECTION_POLICY_DISCONNECT, (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       return;
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_NONE);
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_connection_policy_res_s_type),
+                               (int32_t) service->message_context->connection_policy, (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       free(_error.code);
+                       free(_error.msg);
+               }
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_REQUEST_SET_CONNECTION_POLICY_METHOD)) {
+               char *service_name = NULL;
+               int policy = -1;
+               message_adaptor_error_code_t *error_code = NULL;
+               message_adaptor_error_code_t _error;
+               _error.code = _error.msg = NULL;
+
+               __get_set_connection_policy_req_type(parameters, &service_name, &policy);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if ((NULL == service) || (NULL == service->message_context)) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = __MESSAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_connection_policy_res_s_type),
+                                       (int32_t) MESSAGE_CONNECTION_POLICY_DISCONNECT, (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       return;
+               }
+
+               service_adaptor_debug("get message_adaptor");
+               message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+               message_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->message_context) {
+                       plugin = message_adaptor_get_plugin_by_name(adaptor, service->message_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       service_adaptor_debug("set message connection (%d)", policy);
+                       ret_code = service_adaptor_message_set_connection(plugin, service->message_context,
+                                       policy, &error_code);
+                       service_adaptor_debug("res (%d), policy (%d)", ret_code, policy);
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_NONE);
+                       error_code->msg = strdup("");
+               }
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_connection_policy_res_s_type),
+                               (int32_t) service->message_context->connection_policy, (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       free(_error.code);
+                       free(_error.msg);
+               }
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_GET_CHAT_ID_LIST_METHOD)) {
+               char *service_name = NULL;
+               message_adaptor_phone_number_s **phone_number = NULL;
+               unsigned int phone_number_len = 0;
+               message_adaptor_chat_id_s **chat_ids = NULL;
+               unsigned int chat_ids_len = 0;
+               void *user_data = NULL;
+               void *server_data = NULL;
+               message_adaptor_error_code_t *error_code = NULL;
+               message_adaptor_error_code_t _error;
+               _error.code = _error.msg = NULL;
+
+               __get_chat_id_list_req_type(parameters, &service_name, &phone_number, &phone_number_len);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = __MESSAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       GVariant *response = __create_chat_id_list_res_type(chat_ids, chat_ids_len, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       free(service_name);
+                       if ((NULL != phone_number) && (0U < phone_number_len)) {
+                               for (int pi = 0; pi < phone_number_len; pi++) {
+                                       if (NULL != phone_number[pi]) {
+                                               free(phone_number[pi]->phonenumber);
+                                               free(phone_number[pi]->ccc);
+                                               free(phone_number[pi]);
+                                       }
+                               }
+                               free(phone_number);
+                       }
+
+                       return;
+               }
+
+               message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+               message_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->message_context) {
+                       plugin = message_adaptor_get_plugin_by_name(adaptor, service->message_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       ret_code = message_adaptor_request_chat_id(plugin, service->message_context,
+                                       phone_number, phone_number_len, user_data,
+                                       &chat_ids, &chat_ids_len, &error_code, &server_data);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->message_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%s: %s)", error_code ? error_code->code : NULL, error_code ? error_code->msg : NULL);
+                               message_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = message_adaptor_request_chat_id(plugin, service->message_context,
+                                               phone_number, phone_number_len, user_data,
+                                               &chat_ids, &chat_ids_len, &error_code, &server_data);
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_NONE);
+                       error_code->msg = strdup("");
+               }
+
+               GVariant *response = __create_chat_id_list_res_type(chat_ids, chat_ids_len, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       free(_error.code);
+                       free(_error.msg);
+               }
+
+               free(service_name);
+               if ((NULL != phone_number) && (0U < phone_number_len)) {
+                       for (int pi = 0; pi < phone_number_len; pi++) {
+                               if (NULL != phone_number[pi]) {
+                                       free(phone_number[pi]->phonenumber);
+                                       free(phone_number[pi]->ccc);
+                                       free(phone_number[pi]);
+                               }
+                       }
+                       free(phone_number);
+               }
+               if ((NULL != chat_ids) && (0U < chat_ids_len)) {
+                       for (int ci = 0; ci < chat_ids_len; ci++) {
+                               if (NULL != chat_ids[ci]) {
+                                       free(chat_ids[ci]->msisdn);
+                                       free(chat_ids[ci]);
+                               }
+                       }
+                       free(chat_ids);
+               }
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_GET_MSISDN_LIST_METHOD)) {
+               char *service_name = NULL;
+               int64_t *chat_ids = NULL;
+               unsigned int chat_ids_len = 0;
+               message_adaptor_chat_id_s **msisdns = NULL;
+               unsigned int msisdns_len = 0;
+               void *user_data = NULL;
+               void *server_data = NULL;
+               message_adaptor_error_code_t *error_code = NULL;
+               message_adaptor_error_code_t _error;
+               _error.code = _error.msg = NULL;
+
+               __get_msisdn_list_req_type(parameters, &service_name, &chat_ids, &chat_ids_len);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = __MESSAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       free(chat_ids);
+                       return;
+               }
+
+               message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+               message_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->message_context) {
+                       plugin = message_adaptor_get_plugin_by_name(adaptor, service->message_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       ret_code = message_adaptor_request_msisdn(plugin, service->message_context,
+                                       chat_ids, chat_ids_len, user_data,
+                                       &msisdns, &msisdns_len, &error_code, &server_data);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->message_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%s: %s)", error_code ? error_code->code : NULL, error_code ? error_code->msg : NULL);
+                               message_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = message_adaptor_request_msisdn(plugin, service->message_context,
+                                               chat_ids, chat_ids_len, user_data,
+                                               &msisdns, &msisdns_len, &error_code, &server_data);
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = strdup(__MESSAGE_ADAPTOR_ERROR_NONE);
+                       error_code->msg = strdup("");
+               }
+
+               GVariant *response = __create_chat_id_list_res_type(msisdns, msisdns_len, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       free(_error.code);
+                       free(_error.msg);
+               }
+
+               free(service_name);
+               free(chat_ids);
+               if ((NULL != msisdns) && (0U < msisdns_len)) {
+                       for (int i = 0; i < msisdns_len; i++) {
+                               free(msisdns[i]->msisdn);
+                               free(msisdns[i]);
+                       }
+                       free(msisdns);
+               }
+       }
+}
+
+GVariant *__create_create_chatroom_res_type(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               int default_message_ttl,
+                                               message_adaptor_wrong_receiver_s *wrong_receiver,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       message_adaptor_wrong_receiver_s _wrong_receiver;
+       if (NULL == wrong_receiver) {
+               wrong_receiver = &_wrong_receiver;
+               wrong_receiver->invalid_receivers_len = 0;
+               wrong_receiver->interrupted_receivers_len = 0;
+               wrong_receiver->disabled_receivers_len = 0;
+               wrong_receiver->existing_chatmembers_len = 0;
+               wrong_receiver->did_violation_users_len = 0;
+               wrong_receiver->invitation_denieds_len = 0;
+       }
+
+       GVariantBuilder *builder_invalid = g_variant_builder_new(G_VARIANT_TYPE("a(x)"));
+
+       if (wrong_receiver->invalid_receivers) {
+               for (gsize j = 0; j < wrong_receiver->invalid_receivers_len; j++) {
+                       g_variant_builder_add(builder_invalid, "(x)", wrong_receiver->invalid_receivers[j]);
+               }
+       }
+
+       GVariantBuilder *builder_interrupted = g_variant_builder_new(G_VARIANT_TYPE("a(x)"));
+
+       if (wrong_receiver->interrupted_receivers) {
+               for (gsize j = 0; j < wrong_receiver->interrupted_receivers_len; j++) {
+                       g_variant_builder_add(builder_interrupted, "(x)", wrong_receiver->interrupted_receivers[j]);
+               }
+       }
+
+       GVariantBuilder *builder_disabled = g_variant_builder_new(G_VARIANT_TYPE("a(x)"));
+
+       if (wrong_receiver->disabled_receivers) {
+               for (gsize j = 0; j < wrong_receiver->disabled_receivers_len; j++) {
+                       g_variant_builder_add(builder_disabled, "(x)", wrong_receiver->disabled_receivers[j]);
+               }
+       }
+
+       GVariantBuilder *builder_existing = g_variant_builder_new(G_VARIANT_TYPE("a(x)"));
+
+       if (wrong_receiver->existing_chatmember) {
+               for (gsize j = 0; j < wrong_receiver->existing_chatmembers_len; j++) {
+                       g_variant_builder_add(builder_existing, "(x)", wrong_receiver->existing_chatmember[j]);
+               }
+       }
+
+       GVariantBuilder *builder_did_violation_users = g_variant_builder_new(G_VARIANT_TYPE(private_message_did_violation_users_list_type));
+
+       if (wrong_receiver->did_violation_users) {
+               for (gsize j = 0; j < wrong_receiver->did_violation_users_len; j++) {
+                       g_variant_builder_open(builder_did_violation_users, G_VARIANT_TYPE(private_service_adaptor_did_violation_users_s_type));
+                       g_variant_builder_add(builder_did_violation_users, "x", wrong_receiver->did_violation_users[j].usera);
+                       g_variant_builder_add(builder_did_violation_users, "x", wrong_receiver->did_violation_users[j].userb);
+                       g_variant_builder_close(builder_did_violation_users);
+               }
+       }
+
+       GVariantBuilder *builder_invitation = g_variant_builder_new(G_VARIANT_TYPE("a(x)"));
+
+       if (wrong_receiver->invitation_denieds) {
+               for (gsize j = 0; j < wrong_receiver->invitation_denieds_len; j++) {
+                       g_variant_builder_add(builder_invitation, "(x)", wrong_receiver->invitation_denieds[j]);
+               }
+       }
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_create_chatroom_res_s_type), request_id,
+                       chatroom_id, default_message_ttl, builder_invalid, wrong_receiver->invalid_receivers_len,
+                       builder_interrupted, wrong_receiver->interrupted_receivers_len,
+                       builder_disabled, wrong_receiver->disabled_receivers_len,
+                       builder_existing, wrong_receiver->existing_chatmembers_len,
+                       builder_did_violation_users, wrong_receiver->did_violation_users_len,
+                       builder_invitation, wrong_receiver->invitation_denieds_len,
+                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg));
+
+       g_variant_builder_unref(builder_invalid);
+       g_variant_builder_unref(builder_interrupted);
+       g_variant_builder_unref(builder_disabled);
+       g_variant_builder_unref(builder_existing);
+       g_variant_builder_unref(builder_did_violation_users);
+
+       return response;
+}
+
+GVariant *__create_change_chatroom_meta_res_type(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_change_chatroom_meta_res_s_type), request_id, chatroom_id, (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg));
+
+       return response;
+}
+
+GVariant *__create_chat_res_type(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               message_adaptor_processed_msg_s **processed_msgs,
+                                               unsigned int processed_msgs_len,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       if (NULL == processed_msgs) {
+               processed_msgs_len = 0;
+       }
+
+       GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE(private_message_processed_msg_list_type));
+
+       for (gsize i = 0; i < processed_msgs_len; i++) {
+               g_variant_builder_open(builder, G_VARIANT_TYPE(private_service_adaptor_processed_msg_s_type));
+               g_variant_builder_add(builder, "x", processed_msgs[i]->msg_id);
+               g_variant_builder_add(builder, "x", processed_msgs[i]->sent_time);
+               g_variant_builder_close(builder);
+       }
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_chat_res_s_type), request_id,
+                       chatroom_id, builder, processed_msgs_len,
+                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg));
+
+       g_variant_builder_unref(builder);
+
+       return response;
+}
+
+GVariant *__create_allow_chat_res_type(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               message_adaptor_delivery_ack_s **delivery_acks,
+                                               unsigned int delivery_acks_len,
+                                               int64_t last_delivery_ack_timestamp,
+                                               message_adaptor_read_ack_s **read_acks,
+                                               unsigned int read_acks_len,
+                                               int64_t last_read_ack_timestamp,
+                                               message_adaptor_ordered_chat_member_s **ordered_chat_members,
+                                               unsigned int ordered_chat_members_len,
+                                               const char *chatroom_title,
+                                               int default_message_ttl,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       if (NULL == delivery_acks) {
+               delivery_acks_len = 0;
+       }
+
+       if (NULL == read_acks) {
+               read_acks_len = 0;
+       }
+
+       if (NULL == ordered_chat_members) {
+               ordered_chat_members_len = 0;
+       }
+
+       GVariantBuilder *builder_delivery_ack = g_variant_builder_new(G_VARIANT_TYPE(private_message_delivery_ack_list_type));
+
+       for (gsize i = 0; i < delivery_acks_len; i++) {
+               g_variant_builder_open(builder_delivery_ack, G_VARIANT_TYPE(private_service_adaptor_delivery_ack_s_type));
+               g_variant_builder_add(builder_delivery_ack, "x", delivery_acks[i]->userId);
+               g_variant_builder_add(builder_delivery_ack, "x", delivery_acks[i]->msgId);
+               g_variant_builder_add(builder_delivery_ack, "t", delivery_acks[i]->timestamp);
+               g_variant_builder_close(builder_delivery_ack);
+       }
+
+       GVariantBuilder *builder_read_ack = g_variant_builder_new(G_VARIANT_TYPE(private_message_read_ack_list_type));
+
+       for (gsize i = 0; i < read_acks_len; i++) {
+               g_variant_builder_open(builder_read_ack, G_VARIANT_TYPE(private_service_adaptor_read_ack_s_type));
+               g_variant_builder_add(builder_read_ack, "x", read_acks[i]->userId);
+               g_variant_builder_add(builder_read_ack, "x", read_acks[i]->msgId);
+               g_variant_builder_add(builder_read_ack, "t", read_acks[i]->timestamp);
+               g_variant_builder_close(builder_read_ack);
+       }
+
+       GVariantBuilder *builder_ordered_chat_member = g_variant_builder_new(G_VARIANT_TYPE(private_message_ordered_chat_member_list_type));
+
+       for (gsize i = 0; i < ordered_chat_members_len; i++) {
+               g_variant_builder_open(builder_ordered_chat_member, G_VARIANT_TYPE(private_service_adaptor_ordered_chat_member_s_type));
+               g_variant_builder_add(builder_ordered_chat_member, "x", ordered_chat_members[i]->userId);
+               g_variant_builder_add(builder_ordered_chat_member, "b", ordered_chat_members[i]->available);
+               g_variant_builder_add(builder_ordered_chat_member, "s", ordered_chat_members[i]->name);
+               g_variant_builder_close(builder_ordered_chat_member);
+       }
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_allow_chat_res_s_type), request_id,
+                       chatroom_id, builder_delivery_ack, delivery_acks_len, last_delivery_ack_timestamp,
+                       builder_read_ack, read_acks_len, last_read_ack_timestamp,
+                       builder_ordered_chat_member, ordered_chat_members_len,
+                       __safe_add_string(chatroom_title), default_message_ttl,
+                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg));
+
+       g_variant_builder_unref(builder_delivery_ack);
+       g_variant_builder_unref(builder_read_ack);
+       g_variant_builder_unref(builder_ordered_chat_member);
+
+       return response;
+}
+
+GVariant *__create_all_unread_message_res_type(int64_t request_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_all_unread_message_res_s_type), request_id,
+                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg));
+
+       return response;
+}
+
+GVariant *__create_forward_online_message_req_type(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               int chat_type,
+                                               message_adaptor_inbox_message_s *inbox_msg,
+                                               bool skip_reply,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       service_adaptor_info("%s %s %d", __FUNCTION__, __FILE__, __LINE__);
+
+       message_adaptor_inbox_message_s _inbox_msg;
+       _inbox_msg.chatMsg = "";
+       if (NULL == inbox_msg) {
+               inbox_msg = &_inbox_msg;
+       }
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_forward_online_message_req_s_type), request_id,
+                       chatroom_id, chat_type, inbox_msg->msgId, inbox_msg->msgType, inbox_msg->sender,
+                       inbox_msg->receiver, inbox_msg->sentTime, __safe_add_string(inbox_msg->chatMsg),
+                       inbox_msg->chatroomId, inbox_msg->chatType, inbox_msg->message_ttl, skip_reply,
+                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg));
+
+       return response;
+}
+
+GVariant *__create_forward_unread_message_req_type(int64_t request_id,
+                                               message_adaptor_inbox_message_s **inbox_msgs,
+                                               unsigned int inbox_msgs_len,
+                                               char *next_pagination_key,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE(private_message_inbox_message_list_type));
+
+       for (gsize i = 0; i < inbox_msgs_len; i++) {
+               if (NULL == inbox_msgs[i]) {
+                       break;
+               }
+
+               g_variant_builder_open(builder, G_VARIANT_TYPE(private_service_adaptor_inbox_message_s_type));
+               g_variant_builder_add(builder, "x", inbox_msgs[i]->msgId);
+               g_variant_builder_add(builder, "i", inbox_msgs[i]->msgType);
+               g_variant_builder_add(builder, "x", inbox_msgs[i]->sender);
+               g_variant_builder_add(builder, "x", inbox_msgs[i]->receiver);
+               g_variant_builder_add(builder, "x", inbox_msgs[i]->sentTime);
+               safe_g_variant_builder_add_string(builder, inbox_msgs[i]->chatMsg);
+               g_variant_builder_add(builder, "x", inbox_msgs[i]->chatroomId);
+               g_variant_builder_add(builder, "i", inbox_msgs[i]->chatType);
+               g_variant_builder_add(builder, "i", inbox_msgs[i]->message_ttl);
+               g_variant_builder_close(builder);
+       }
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_forward_unread_message_req_s_type), request_id,
+                       builder, inbox_msgs_len, __safe_add_string(next_pagination_key),
+                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg));
+
+       g_variant_builder_unref(builder);
+
+       return response;
+}
+
+GVariant *__create_read_message_res_type(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_read_message_res_s_type), request_id, chatroom_id,
+                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg));
+
+       return response;
+}
+
+GVariant *__create_invite_chat_res_type(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               int64_t sent_time,
+                                               message_adaptor_wrong_receiver_s *wrong_receiver,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       message_adaptor_wrong_receiver_s _wrong_receiver;
+       if (NULL == wrong_receiver) {
+               wrong_receiver = &_wrong_receiver;
+               wrong_receiver->invalid_receivers_len = 0;
+               wrong_receiver->interrupted_receivers_len = 0;
+               wrong_receiver->disabled_receivers_len = 0;
+               wrong_receiver->existing_chatmembers_len = 0;
+               wrong_receiver->did_violation_users_len = 0;
+               wrong_receiver->invitation_denieds_len = 0;
+       }
+
+       GVariantBuilder *builder_invalid = g_variant_builder_new(G_VARIANT_TYPE("a(x)"));
+
+       if (wrong_receiver->invalid_receivers) {
+               for (gsize j = 0; j < wrong_receiver->invalid_receivers_len; j++) {
+                       g_variant_builder_add(builder_invalid, "(x)", wrong_receiver->invalid_receivers[j]);
+               }
+       }
+
+       GVariantBuilder *builder_interrupted = g_variant_builder_new(G_VARIANT_TYPE("a(x)"));
+
+       if (wrong_receiver->interrupted_receivers) {
+               for (gsize j = 0; j < wrong_receiver->interrupted_receivers_len; j++) {
+                       g_variant_builder_add(builder_interrupted, "(x)", wrong_receiver->interrupted_receivers[j]);
+               }
+       }
+
+       GVariantBuilder *builder_disabled = g_variant_builder_new(G_VARIANT_TYPE("a(x)"));
+
+       if (wrong_receiver->disabled_receivers) {
+               for (gsize j = 0; j < wrong_receiver->disabled_receivers_len; j++) {
+                       g_variant_builder_add(builder_disabled, "(x)", wrong_receiver->disabled_receivers[j]);
+               }
+       }
+
+       GVariantBuilder *builder_existing = g_variant_builder_new(G_VARIANT_TYPE("a(x)"));
+
+       if (wrong_receiver->existing_chatmember) {
+               for (gsize j = 0; j < wrong_receiver->existing_chatmembers_len; j++) {
+                       g_variant_builder_add(builder_existing, "(x)", wrong_receiver->existing_chatmember[j]);
+               }
+       }
+
+       GVariantBuilder *builder_did_violation_users = g_variant_builder_new(G_VARIANT_TYPE(private_message_did_violation_users_list_type));
+
+       if (wrong_receiver->did_violation_users) {
+               for (gsize j = 0; j < wrong_receiver->did_violation_users_len; j++) {
+                       g_variant_builder_open(builder_did_violation_users, G_VARIANT_TYPE(private_service_adaptor_did_violation_users_s_type));
+                       g_variant_builder_add(builder_did_violation_users, "x", wrong_receiver->did_violation_users[j].usera);
+                       g_variant_builder_add(builder_did_violation_users, "x", wrong_receiver->did_violation_users[j].userb);
+                       g_variant_builder_close(builder_did_violation_users);
+               }
+       }
+
+       GVariantBuilder *builder_invitation = g_variant_builder_new(G_VARIANT_TYPE("a(x)"));
+
+       if (wrong_receiver->invitation_denieds) {
+               for (gsize j = 0; j < wrong_receiver->invitation_denieds_len; j++) {
+                       g_variant_builder_add(builder_invitation, "(x)", wrong_receiver->invitation_denieds[j]);
+               }
+       }
+
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_invite_chat_res_s_type), request_id,
+                       chatroom_id, sent_time, builder_invalid, wrong_receiver->invalid_receivers_len,
+                       builder_interrupted, wrong_receiver->interrupted_receivers_len,
+                       builder_disabled, wrong_receiver->disabled_receivers_len,
+                       builder_existing, wrong_receiver->existing_chatmembers_len,
+                       builder_did_violation_users, wrong_receiver->did_violation_users_len,
+                       builder_invitation, wrong_receiver->invitation_denieds_len,
+                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg));
+
+       g_variant_builder_unref(builder_invalid);
+       g_variant_builder_unref(builder_interrupted);
+       g_variant_builder_unref(builder_disabled);
+       g_variant_builder_unref(builder_existing);
+       g_variant_builder_unref(builder_did_violation_users);
+
+       return response;
+}
+
+GVariant *__create_end_chat_res_type(int64_t request_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_end_chat_res_s_type), request_id,
+                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg));
+
+       return response;
+}
+
+GVariant *__create_unseal_message_res_type(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_unseal_message_res_s_type), request_id, chatroom_id, (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg));
+
+       return response;
+}
+
+GVariant *__create_save_call_log_res_type(int64_t request_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_save_call_log_res_s_type), request_id, (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg));
+
+       return response;
+}
+
+GVariant *__create_current_time_res_type(int64_t request_id,
+                                               int64_t current_time_millis,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_current_time_res_s_type), request_id, current_time_millis,
+                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg));
+
+       return response;
+}
+
+GVariant *__create_message_channel_disconnected_res_type(const char *service_name,
+                                               message_adaptor_error_code_t *error_code)
+{
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_channel_disconnected_res_s_type),
+                       __safe_add_string(service_name),
+                       (uint64_t) atoi(__safe_add_string(error_code->code)), __safe_add_string(error_code->msg));
+
+       return response;
+}
+
+service_adaptor_internal_error_code_e dbus_reply_create_chatroom_callback(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               int default_message_ttl,
+                                               message_adaptor_wrong_receiver_s *wrong_receiver,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+               GVariant *response = __create_create_chatroom_res_type(request_id, chatroom_id,
+                               default_message_ttl, wrong_receiver, error_code, server_data);
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_REPLY_CREATE_CHATROOM_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e dbus_reply_change_chatroom_meta_callback(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+               GVariant *response = __create_change_chatroom_meta_res_type(request_id, chatroom_id, error_code, server_data);
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_REPLY_CHANGE_CHATROOM_META_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e dbus_reply_chat_callback(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               message_adaptor_processed_msg_s **processed_msgs,
+                                               unsigned int processed_msgs_len,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+               GVariant *response = __create_chat_res_type(request_id, chatroom_id,
+                               processed_msgs, processed_msgs_len, error_code, server_data);
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_REPLY_CHAT_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e dbus_reply_allow_chat_callback(int64_t request_id,
+                                               long long int chatroom_id,
+                                               message_adaptor_delivery_ack_s **delivery_acks,
+                                               unsigned int delivery_acks_len,
+                                               unsigned long long last_delivery_acks_timestamp,
+                                               message_adaptor_read_ack_s **read_acks,
+                                               unsigned int read_acks_len,
+                                               unsigned long long last_read_acks_timestamp,
+                                               message_adaptor_ordered_chat_member_s **ordered_chat_members,
+                                               unsigned int ordered_chat_members_len,
+                                               const char *chatroom_title,
+                                               int default_message_ttl,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+               GVariant *response = __create_allow_chat_res_type(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, server_data);
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_REPLY_ALLOW_CHAT_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e dbus_reply_all_unread_message_callback(int64_t request_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+               GVariant *response = __create_all_unread_message_res_type(request_id, error_code, server_data);
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_REPLY_ALL_UNREAD_MESSAGE_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e dbus_request_forward_online_message_callback(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               int chat_type,
+                                               message_adaptor_inbox_message_s *inbox_msg,
+                                               bool skip_reply,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       service_adaptor_debug("%s Enter", __FUNCTION__);
+
+       if (NULL != dbus_connection) {
+               GVariant *response = __create_forward_online_message_req_type(request_id, chatroom_id,
+                               chat_type, inbox_msg, skip_reply, error_code, server_data);
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_REQUEST_FORWARD_ONLINE_MESSAGE_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       service_adaptor_debug("%s End", __FUNCTION__);
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e dbus_request_forward_unread_message_callback(int64_t request_id,
+                                               message_adaptor_inbox_message_s **inbox_msgs,
+                                               unsigned int inbox_msgs_len,
+                                               char *next_pagination_key,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+               GVariant *response = __create_forward_unread_message_req_type(request_id, inbox_msgs,
+                               inbox_msgs_len, next_pagination_key, error_code, server_data);
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_REQUEST_FORWARD_UNREAD_MESSAGE_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e dbus_reply_read_message_callback(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+               GVariant *response = __create_read_message_res_type(request_id, chatroom_id, error_code, server_data);
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_REPLY_READ_MESSAGE_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e dbus_reply_invite_chat_callback(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               int64_t sent_time,
+                                               message_adaptor_wrong_receiver_s *wrong_receiver,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+               GVariant *response = __create_invite_chat_res_type(request_id, chatroom_id,
+                               sent_time, wrong_receiver, error_code, server_data);
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_REPLY_INVITE_CHAT_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e dbus_reply_end_chat_callback(int64_t request_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+               GVariant *response = __create_end_chat_res_type(request_id, error_code, server_data);
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_REPLY_END_CHAT_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e dbus_reply_unseal_message_callback(int64_t request_id,
+                                               int64_t chatroom_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+               GVariant *response = __create_unseal_message_res_type(request_id, chatroom_id, error_code, server_data);
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_REPLY_UNSEAL_MESSAGE_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e dbus_reply_save_call_log_callback(int64_t request_id,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+               GVariant *response = __create_save_call_log_res_type(request_id, error_code, server_data);
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_REPLY_SAVE_CALL_LOG_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e dbus_reply_current_time_callback(int64_t request_id,
+                                               int64_t current_time_millis,
+                                               message_adaptor_error_code_t *error_code,
+                                               void *server_data)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+               GVariant *response = __create_current_time_res_type(request_id, current_time_millis, error_code, server_data);
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_REPLY_CURRENT_TIME_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e dbus_reply_message_channel_disconnected_callback(const char *service_name,
+                                               message_adaptor_error_code_t *error_code)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+               GVariant *response = __create_message_channel_disconnected_res_type(service_name, error_code);
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_REPLY_CHANNEL_DISCONNECTED_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
diff --git a/src/dbus/dbus-push-adaptor.c b/src/dbus/dbus-push-adaptor.c
new file mode 100644 (file)
index 0000000..e71c269
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+* 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 <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <unistd.h>
+
+#include "service-adaptor.h"
+#include "service-adaptor-push.h"
+#include "service-adaptor-type.h"
+#include "service-adaptor-log.h"
+#include "dbus-push-adaptor.h"
+#include "dbus-server.h"
+#include "dbus-util.h"
+#include "util/client_checker.h"
+
+#define AUTH_FLAG      (0x01 << 0)
+#define STORAGE_FLAG   (0x01 << 1)
+#define RET_MSG_LEN    2048
+#define __SAFE_STRDUP(x)       (x) ? strdup(x) : strdup("")
+
+void push_adaptor_method_call(GDBusConnection *connection,
+                                               const gchar *sender,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *method_name,
+                                               GVariant *parameters,
+                                               GDBusMethodInvocation *invocation,
+                                               gpointer user_data)
+{
+       service_adaptor_internal_error_code_e ret_code = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       /* char ret_msg[RET_MSG_LEN] = "";
+       memset(ret_msg, 0, RET_MSG_LEN); */
+
+/************************************************************************
+ *
+ *                        private feature
+ */
+       if (0 == g_strcmp0(method_name, PRIVATE_DBUS_PUSH_REGISTER_METHOD)) {
+               service_adaptor_debug("[START] Push register");
+               GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+               GVariant *req_struct[private_service_adaptor_push_register_req_s_type_length];
+
+               for (size_t j = 0; j < private_service_adaptor_push_register_req_s_type_length; j++) {
+                       req_struct[j] = g_variant_get_child_value(in_parameters, j);
+               }
+
+               int idx = 0;
+
+               char *service_file_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+               service_adaptor_debug("service_file : %s", service_file_name);
+
+               char *err = NULL;
+               ret_code = service_adaptor_push_register(service_file_name, &err);
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) ret_code, __safe_add_string(err)));
+
+               free(err);
+               free(service_file_name);
+               service_adaptor_debug("[End] Push register");
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_PUSH_DEREGISTER_METHOD)) {
+               service_adaptor_debug("[START] Push deregister");
+               GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+               GVariant *req_struct[private_service_adaptor_push_register_req_s_type_length];
+
+               for (size_t j = 0; j < private_service_adaptor_push_register_req_s_type_length; j++) {
+                       req_struct[j] = g_variant_get_child_value(in_parameters, j);
+               }
+
+               int idx = 0;
+
+               char *service_file_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+               service_adaptor_debug("service_file : %s", service_file_name);
+
+               char *err = NULL;
+               ret_code = service_adaptor_push_deregister(service_file_name, &err);
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) ret_code, __safe_add_string(err)));
+
+               free(err);
+               free(service_file_name);
+               service_adaptor_debug("[End] Push deregister");
+       }
+/*
+ *                       private feature
+ *
+ ***********************************************************************/
+}
+
+typedef struct __push_data_s {
+       long long int timestamp;
+       char *method;
+       char *data;
+       char *message;
+} _push_data_s;
+
+static void g_bus_async_ready_callback(GObject *source_object,
+                        GAsyncResult *res,
+                        gpointer user_data)
+{
+       service_adaptor_debug("[START] Push dbus proxy creation callback");
+       GDBusProxy *_proxy = (GDBusProxy *) source_object;
+       _push_data_s *push_data = (_push_data_s *) user_data;
+
+       GVariant *req = g_variant_new("(xss)", push_data->timestamp, push_data->data, push_data->message);
+
+       service_adaptor_info("Push dbus message send");
+       g_dbus_proxy_call(_proxy,
+                       push_data->method,
+                       req,
+                       (G_DBUS_CALL_FLAGS_NONE | G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED),
+                       -1,
+                       NULL,   /* GCancellable *cancellable */
+                       NULL,   /* GAsyncReadyCallback callback */
+                       NULL);  /* gpointer user_data */
+
+       free(push_data->data);
+       push_data->data = NULL;
+       free(push_data->message);
+       push_data->message = NULL;
+       free(push_data->method);
+       push_data->method = NULL;
+       free(push_data);
+       service_adaptor_debug("[End] Push dbus proxy creation callback");
+}
+
+void dbus_send_to_push_with_activation(int bus_type,
+                                               const char *bus_name,
+                                               const char *object_path,
+                                               const char *interface,
+                                               const char *method,
+                                               void **proxy,
+                                               long long int timestamp,
+                                               const char *data,
+                                               const char *message)
+{
+       service_adaptor_debug("[START] Push dbus activation message send");
+
+       _push_data_s *push_data = (_push_data_s *) calloc(1, sizeof(_push_data_s));
+       char *_data = strdup(data ? data : "");
+       char *_message = strdup(message ? message : "");
+       char *_method = strdup(method ? method : "");
+       if ((NULL == push_data) || (NULL == _data) || (NULL == _message)) {
+               free(push_data);
+               free(_data);
+               free(_message);
+               free(_method);
+               service_adaptor_error("Memory allocation failed");
+               return;
+       }
+       push_data->timestamp    = timestamp;
+       push_data->data         = _data;
+       push_data->message      = _message;
+       push_data->method       = _method;
+
+       service_adaptor_debug_func("[PARAM_DBG] bus_type  : %d", bus_type);
+       service_adaptor_debug_func("[PARAM_DBG] bus_name  : %s", bus_name);
+       service_adaptor_debug_func("[PARAM_DBG] obj_path  : %s", object_path);
+       service_adaptor_debug_func("[PARAM_DBG] interface : %s", interface);
+       service_adaptor_debug_func("[PARAM_DBG] method    : %s", method);
+       service_adaptor_debug_func("[PARAM_DBG] proxy     : %p", *proxy);
+       service_adaptor_debug_func("");
+       service_adaptor_debug_func("[PARAM_DBG] timestamp : %lld", timestamp);
+       service_adaptor_debug_func("[PARAM_DBG] data      : %s", data);
+       service_adaptor_debug_func("[PARAM_DBG] message   : %s", message);
+
+       service_adaptor_info("Try dbus proxy creation (Async)");
+       g_dbus_proxy_new_for_bus((GBusType) bus_type,
+                       G_DBUS_PROXY_FLAGS_NONE,
+                       NULL,
+                       bus_name,
+                       object_path,
+                       interface,
+                       NULL,
+                       g_bus_async_ready_callback,
+                       (void *) push_data);
+
+       service_adaptor_debug("[End] Push dbus activation message send");
+}
diff --git a/src/dbus/dbus-server.c b/src/dbus/dbus-server.c
new file mode 100644 (file)
index 0000000..e61f71f
--- /dev/null
@@ -0,0 +1,929 @@
+/*
+* 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 <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <errno.h>
+#include <stdint.h>
+
+#include "service-adaptor.h"
+#include "service-adaptor-type.h"
+#include "service-adaptor-log.h"
+#include "dbus-service-adaptor.h"
+#include "dbus-auth-adaptor.h"
+#include "dbus-contact-adaptor.h"
+#include "dbus-message-adaptor.h"
+#include "dbus-shop-adaptor.h"
+#include "dbus-storage-adaptor.h"
+#include "dbus-push-adaptor.h"
+#include "dbus-server.h"
+#include "dbus-server-type.h"
+#include "dbus-util.h"
+
+static GThreadPool *thread_pool = NULL;
+
+/**
+ * Compiled introspection data describing Service Adaptor D-Bus interface.
+ */
+static GDBusNodeInfo *introspection_data = NULL;
+
+/**
+ * Service Adaptor D-Bus server owner id.
+ */
+static guint owner_id = 0;
+
+/**
+ * DBus connection used by server.
+ */
+static GDBusConnection *dbus_connection = NULL;
+
+/**
+ * Introspection data describing vService Channel D-Bus interface.
+ */
+static const gchar introspection_xml[] =
+"<node>"
+"  <interface name='" SERVICE_ADAPTOR_INTERFACE "'>"
+/************************************************************************
+ *
+ *
+ *                          private feature
+ */
+"    <method name='" PRIVATE_DBUS_CONNECT_SERVICE_ADAPTOR_METHOD "'>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_EXTERNAL_REQ_METHOD "'>"
+"      <arg type='" private_service_adaptor_external_req_s_type "' name='ext_req' direction='in'/>"
+"      <arg type='" service_adaptor_raw_data_s_type "' name='ext_res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_GET_AUTH_PLUGIN_LIST_METHOD "'>"
+"      <arg type='s' name='imsi' direction='in'/>"
+"      <arg type='" private_plugin_list_type "' name='plugin_list' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_SET_AUTH_METHOD "'>"
+"      <arg type='" private_service_adaptor_set_auth_s_type "' name='set_auth' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_SET_NEW_CONTACT_LIST_METHOD "'>"
+"      <arg type='" private_service_adaptor_contact_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_contact_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_SET_CONTACT_LIST_METHOD "'>"
+"      <arg type='" private_service_adaptor_contact_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_contact_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_GET_CONTACT_LIST_METHOD "'>"
+"      <arg type='" private_service_adaptor_essential_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_contact_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_GET_CONTACT_INFOS_POLLING_METHOD "'>"
+"      <arg type='" private_service_adaptor_contact_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_contact_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_SET_ME_PROFILE_WITH_PUSH_METHOD "'>"
+"      <arg type='" private_service_adaptor_profile_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_GET_PROFILE_METHOD "'>"
+"      <arg type='" private_service_adaptor_profile_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_profile_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_SET_PROFILE_IMAGE_META_WITH_PUSH_METHOD "'>"
+"      <arg type='" private_service_adaptor_contact_profile_image_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_contact_profile_image_req_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_DEL_ME_PROFILE_IMAGE_META_WITH_PUSH_METHOD "'>"
+"      <arg type='" private_service_adaptor_essential_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_SET_ME_PROFILE_PRIVACY_METHOD "'>"
+"      <arg type='" private_service_adaptor_privacy_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_GET_PROFILE_PRIVACY_METHOD "'>"
+"      <arg type='" private_service_adaptor_essential_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_privacy_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_SET_ME_PRESENCE_WITH_PUSH_METHOD "'>"
+"      <arg type='" private_service_adaptor_presence_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_SET_ME_PROFILE_TYPE_METHOD "'>"
+"      <arg type='" private_service_adaptor_set_me_profile_type_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_essential_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_SET_ME_PRESENCE_ON_OFF_WITH_PUSH_METHOD "'>"
+"      <arg type='" private_service_adaptor_presence_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_REQUEST_CREATE_CHATROOM_METHOD "'>"
+"      <arg type='" private_service_adaptor_create_chatroom_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_REQUEST_CHANGE_CHATROOM_META_METHOD "'>"
+"      <arg type='" private_service_adaptor_change_chatroom_meta_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_REQUEST_CHAT_METHOD "'>"
+"      <arg type='" private_service_adaptor_chat_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_REQUEST_ALLOW_CHAT_METHOD "'>"
+"      <arg type='" private_service_adaptor_allow_chat_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_REQUEST_ALL_UNREAD_MESSAGE_METHOD "'>"
+"      <arg type='" private_service_adaptor_all_unread_message_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_REPLY_FORWARD_ONLINE_MESSAGE_METHOD "'>"
+"      <arg type='" private_service_adaptor_forward_online_message_res_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_REPLY_FORWARD_UNREAD_MESSAGE_METHOD "'>"
+"      <arg type='" private_service_adaptor_forward_unread_message_res_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_REQUEST_READ_MESSAGE_METHOD "'>"
+"      <arg type='" private_service_adaptor_read_message_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_REQUEST_INVITE_CHAT_METHOD "'>"
+"      <arg type='" private_service_adaptor_invite_chat_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_REQUEST_END_CHAT_METHOD "'>"
+"      <arg type='" private_service_adaptor_end_chat_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_REQUEST_UNSEAL_MESSAGE_METHOD "'>"
+"      <arg type='" private_service_adaptor_unseal_message_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_REQUEST_SAVE_CALL_LOG_METHOD "'>"
+"      <arg type='" private_service_adaptor_save_call_log_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_REQUEST_CURRENT_TIME_METHOD "'>"
+"      <arg type='" private_service_adaptor_current_time_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_REQUEST_GET_CONNECTION_POLICY_METHOD "'>"
+"      <arg type='" private_service_adaptor_get_connection_policy_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_connection_policy_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_REQUEST_SET_CONNECTION_POLICY_METHOD "'>"
+"      <arg type='" private_service_adaptor_set_connection_policy_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_connection_policy_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_GET_CHAT_ID_LIST_METHOD "'>"
+"      <arg type='" private_service_adaptor_chat_id_list_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_chat_id_list_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_GET_MSISDN_LIST_METHOD "'>"
+"      <arg type='" private_service_adaptor_msisdn_list_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_msisdn_list_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_GET_ITEM_LIST_METHOD "'>"
+"      <arg type='" private_service_adaptor_shop_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_shop_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_DOWNLOAD_ITEM_PACKAGE_METHOD "'>"
+"      <arg type='" private_service_adaptor_shop_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_shop_item_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_DOWNLOAD_STICKER_METHOD "'>"
+"      <arg type='" private_service_adaptor_shop_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_shop_item_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_GET_PANEL_URL_METHOD "'>"
+"      <arg type='" private_service_adaptor_shop_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_shop_item_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_DOWNLOAD_FILE_METHOD "'>"
+"      <arg type='" private_service_adaptor_file_transfer_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_DOWNLOAD_FILE_ASYNC_METHOD "'>"
+"      <arg type='" private_service_adaptor_file_transfer_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_file_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_UPLOAD_FILE_METHOD "'>"
+"      <arg type='" private_service_adaptor_file_transfer_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_UPLOAD_FILE_ASYNC_METHOD "'>"
+"      <arg type='" private_service_adaptor_file_transfer_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_file_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_DOWNLOAD_FILE_PUBLISH_METHOD "'>"
+"      <arg type='" private_service_adaptor_file_transfer_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_DOWNLOAD_FILE_PUBLISH_ASYNC_METHOD "'>"
+"      <arg type='" private_service_adaptor_file_transfer_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_file_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_UPLOAD_FILE_PUBLISH_METHOD "'>"
+"      <arg type='" private_service_adaptor_file_transfer_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_file_publish_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_UPLOAD_FILE_PUBLISH_ASYNC_METHOD "'>"
+"      <arg type='" private_service_adaptor_file_transfer_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_file_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_GET_FILE_STATUS_METHOD "'>"
+"      <arg type='" private_service_adaptor_file_status_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" private_service_adaptor_file_status_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_CANCEL_FILE_TRANSFER_METHOD "'>"
+"      <arg type='" private_service_adaptor_file_status_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_PAUSE_FILE_TRANSFER_METHOD "'>"
+"      <arg type='" private_service_adaptor_file_status_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_RESUME_FILE_TRANSFER_METHOD "'>"
+"      <arg type='" private_service_adaptor_file_status_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <signal name='" PRIVATE_DBUS_REPLY_CREATE_CHATROOM_SIGNAL "'>"
+"      <arg type='" private_service_adaptor_create_chatroom_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" PRIVATE_DBUS_REPLY_CHANGE_CHATROOM_META_SIGNAL "'>"
+"      <arg type='" private_service_adaptor_change_chatroom_meta_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" PRIVATE_DBUS_REPLY_CHAT_SIGNAL "'>"
+"      <arg type='" private_service_adaptor_chat_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" PRIVATE_DBUS_REPLY_ALLOW_CHAT_SIGNAL "'>"
+"      <arg type='" private_service_adaptor_allow_chat_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" PRIVATE_DBUS_REPLY_ALL_UNREAD_MESSAGE_SIGNAL "'>"
+"      <arg type='" private_service_adaptor_all_unread_message_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" PRIVATE_DBUS_REQUEST_FORWARD_ONLINE_MESSAGE_SIGNAL "'>"
+"      <arg type='" private_service_adaptor_forward_online_message_req_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" PRIVATE_DBUS_REQUEST_FORWARD_UNREAD_MESSAGE_SIGNAL "'>"
+"      <arg type='" private_service_adaptor_forward_unread_message_req_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" PRIVATE_DBUS_REPLY_READ_MESSAGE_SIGNAL "'>"
+"      <arg type='" private_service_adaptor_read_message_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" PRIVATE_DBUS_REPLY_INVITE_CHAT_SIGNAL "'>"
+"      <arg type='" private_service_adaptor_invite_chat_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" PRIVATE_DBUS_REPLY_END_CHAT_SIGNAL "'>"
+"      <arg type='" private_service_adaptor_end_chat_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" PRIVATE_DBUS_REPLY_UNSEAL_MESSAGE_SIGNAL "'>"
+"      <arg type='" private_service_adaptor_unseal_message_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" PRIVATE_DBUS_REPLY_SAVE_CALL_LOG_SIGNAL "'>"
+"      <arg type='" private_service_adaptor_save_call_log_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" PRIVATE_DBUS_REPLY_CURRENT_TIME_SIGNAL "'>"
+"      <arg type='" private_service_adaptor_current_time_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" PRIVATE_DBUS_REPLY_CHANNEL_DISCONNECTED_SIGNAL "'>"
+"      <arg type='" private_service_adaptor_channel_disconnected_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" PRIVATE_DBUS_STORAGE_FILE_PROGRESS_SIGNAL "'>"
+"      <arg type='" private_service_adaptor_file_progress_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" PRIVATE_DBUS_STORAGE_FILE_TRANSFER_COMPLETION_SIGNAL "'>"
+"      <arg type='" private_service_adaptor_file_transfer_completion_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" PRIVATE_DBUS_PUSH_DATA_SIGNAL "'>"
+"      <arg type='" private_service_adaptor_push_data_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <method name='" PRIVATE_DBUS_PUSH_REGISTER_METHOD "'>"
+"      <arg type='" private_service_adaptor_push_register_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" PRIVATE_DBUS_PUSH_DEREGISTER_METHOD "'>"
+"      <arg type='" private_service_adaptor_push_deregister_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <signal name='" PRIVATE_DBUS_SERVICE_ADAPTOR_SIGNAL "'>"
+"      <arg type='t' name='signal_code' direction='out'/>"
+"      <arg type='s' name='signal_msg' direction='out'/>"
+"    </signal>"
+/*
+ *                                private feature
+ *
+ *
+ ***********************************************************************/
+
+/************************************************************************
+ *
+ *
+ *                                public feature
+ */
+"    <method name='" DBUS_CONNECT_SERVICE_ADAPTOR_METHOD "'>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_GET_AUTH_PLUGIN_LIST_METHOD "'>"
+"      <arg type='s' name='temp' direction='in'/>"
+"      <arg type='" plugin_list_type "' name='plugin_list' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_IS_AUTH_METHOD "'>"
+"      <arg type='" service_adaptor_is_auth_req_s_type "' name='is_auth' direction='in'/>"
+"      <arg type='(b)' name='auth' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_JOIN_METHOD "'>"
+"      <arg type='" service_adaptor_join_req_s_type "' name='join' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_SET_AUTH_METHOD "'>"
+"      <arg type='" service_adaptor_set_auth_s_type "' name='set_auth' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_DOWNLOAD_FILE_METHOD "'>"
+"      <arg type='" service_adaptor_file_transfer_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_DOWNLOAD_THUMBNAIL_METHOD "'>"
+"      <arg type='" service_adaptor_download_thumbnail_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_UPLOAD_FILE_METHOD "'>"
+"      <arg type='" service_adaptor_file_transfer_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" service_adaptor_file_info_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_GET_ROOT_FOLDER_PATH_METHOD "'>"
+"      <arg type='" service_adaptor_get_root_folder_path_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" service_adaptor_get_root_folder_path_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_MAKE_DIRECTORY_METHOD "'>"
+"      <arg type='" service_adaptor_make_directory_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" service_adaptor_file_info_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_REMOVE_FILE_METHOD "'>"
+"      <arg type='" service_adaptor_remove_file_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_REMOVE_DIRECTORY_METHOD "'>"
+"      <arg type='" service_adaptor_remove_directory_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_MOVE_FILE_METHOD "'>"
+"      <arg type='" service_adaptor_move_file_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" service_adaptor_file_info_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_MOVE_DIRECTORY_METHOD "'>"
+"      <arg type='" service_adaptor_move_directory_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" service_adaptor_file_info_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_GET_FILE_LIST_METHOD "'>"
+"      <arg type='" service_adaptor_get_file_list_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" service_adaptor_get_file_list_res_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+
+"    <method name='" DBUS_OPEN_UPLOAD_FILE_METHOD "'>"
+"      <arg type='" service_adaptor_open_upload_file_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" service_adaptor_file_descriptor_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_OPEN_DOWNLOAD_FILE_METHOD "'>"
+"      <arg type='" service_adaptor_open_download_file_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" service_adaptor_file_descriptor_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_OPEN_DOWNLOAD_THUMBNAIL_METHOD "'>"
+"      <arg type='" service_adaptor_open_download_thumbnail_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" service_adaptor_file_descriptor_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_CLOSE_FILE_METHOD "'>"
+"      <arg type='" service_adaptor_close_file_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_START_UPLOAD_FILE_METHOD "'>"
+"      <arg type='" service_adaptor_start_upload_file_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_START_DOWNLOAD_FILE_METHOD "'>"
+"      <arg type='" service_adaptor_start_download_file_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_START_DOWNLOAD_THUMBNAIL_METHOD "'>"
+"      <arg type='" service_adaptor_start_download_thumbnail_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_CANCEL_UPLOAD_FILE_METHOD "'>"
+"      <arg type='" service_adaptor_cancel_file_task_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_CANCEL_DOWNLOAD_FILE_METHOD "'>"
+"      <arg type='" service_adaptor_cancel_file_task_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <method name='" DBUS_CANCEL_DOWNLOAD_THUMBNAIL_METHOD "'>"
+"      <arg type='" service_adaptor_cancel_file_task_req_s_type "' name='req' direction='in'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </method>"
+"    <signal name='" DBUS_STORAGE_FILE_PROGRESS_SIGNAL "'>"
+"      <arg type='" service_adaptor_file_progress_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" DBUS_STORAGE_FILE_TRANSFER_STATE_CHANGED_SIGNAL "'>"
+"      <arg type='" service_adaptor_file_transfer_state_changed_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" DBUS_PUSH_DATA_SIGNAL "'>"
+"      <arg type='" service_adaptor_push_data_s_type "' name='res' direction='out'/>"
+"      <arg type='t' name='error_code' direction='out'/>"
+"      <arg type='s' name='error_msg' direction='out'/>"
+"    </signal>"
+"    <signal name='" DBUS_SERVICE_ADAPTOR_SIGNAL "'>"
+"      <arg type='t' name='signal_code' direction='out'/>"
+"      <arg type='s' name='signal_msg' direction='out'/>"
+"    </signal>"
+
+/*
+ *                                public feature
+ *
+ *
+ ***********************************************************************/
+"  </interface>"
+"</node>";
+
+typedef struct _method_call_s {
+       GDBusConnection *connection;
+       gchar *sender;
+       gchar *object_path;
+       gchar *interface_name;
+       gchar *method_name;
+       GVariant *parameters;
+       GDBusMethodInvocation *invocation;
+       gpointer user_data;
+} method_call_s;
+
+GDBusConnection *dbus_get_connection()
+{
+       return dbus_connection;
+}
+
+static void method_call_async_func(gpointer data, gpointer user_data)
+{
+       method_call_s *handle = data;
+
+       service_adaptor_debug("Received %s() call", handle->method_name);
+
+       if (0 == strncmp(handle->method_name, DBUS_SERVICE_ADAPTOR, DBUS_NAME_LENGTH)) {
+               service_adaptor_method_call(handle->connection,
+                               handle->sender,
+                               handle->object_path,
+                               handle->interface_name,
+                               handle->method_name,
+                               handle->parameters,
+                               handle->invocation,
+                               handle->user_data);
+       } else if (0 == strncmp(handle->method_name, DBUS_AUTH_ADAPTOR, DBUS_NAME_LENGTH)) {
+               auth_adaptor_method_call(handle->connection,
+                               handle->sender,
+                               handle->object_path,
+                               handle->interface_name,
+                               handle->method_name,
+                               handle->parameters,
+                               handle->invocation,
+                               handle->user_data);
+       } else if (0 == strncmp(handle->method_name, DBUS_CONTACT_ADAPTOR, DBUS_NAME_LENGTH)) {
+               contact_adaptor_method_call(handle->connection,
+                               handle->sender,
+                               handle->object_path,
+                               handle->interface_name,
+                               handle->method_name,
+                               handle->parameters,
+                               handle->invocation,
+                               handle->user_data);
+       } else if (0 == strncmp(handle->method_name, DBUS_MESSAGE_ADAPTOR, DBUS_NAME_LENGTH)) {
+               message_adaptor_method_call(handle->connection,
+                               handle->sender,
+                               handle->object_path,
+                               handle->interface_name,
+                               handle->method_name,
+                               handle->parameters,
+                               handle->invocation,
+                               handle->user_data);
+       } else if (0 == strncmp(handle->method_name, DBUS_SHOP_ADAPTOR, DBUS_NAME_LENGTH)) {
+               shop_adaptor_method_call(handle->connection,
+                               handle->sender,
+                               handle->object_path,
+                               handle->interface_name,
+                               handle->method_name,
+                               handle->parameters,
+                               handle->invocation,
+                               handle->user_data);
+       } else if (0 == strncmp(handle->method_name, DBUS_STORAGE_ADAPTOR, DBUS_NAME_LENGTH)) {
+               storage_adaptor_method_call(handle->connection,
+                               handle->sender,
+                               handle->object_path,
+                               handle->interface_name,
+                               handle->method_name,
+                               handle->parameters,
+                               handle->invocation,
+                               handle->user_data);
+       } else if (0 == strncmp(handle->method_name, DBUS_PUSH_ADAPTOR, DBUS_NAME_LENGTH)) {
+               push_adaptor_method_call(handle->connection,
+                               handle->sender,
+                               handle->object_path,
+                               handle->interface_name,
+                               handle->method_name,
+                               handle->parameters,
+                               handle->invocation,
+                               handle->user_data);
+       }
+
+}
+
+/**
+ * @brief Service Adaptor D-Bus interface method call handler.
+ *
+ * Service Adaptor D-Bus interface method call handler. Called when client calls some function defined in
+ * Service Adaptor D-Bus interface.
+ * @param connection A GDBusConnection.
+ * @param sender The unique bus name of the remote caller.
+ * @param object_path The object path that the method was invoked on.
+ * @param interface_name The D-Bus interface name the method was invoked on.
+ * @param method_name The name of the method that was invoked.
+ * @param parameters A GVariant tuple with parameters.
+ * @param invocation A GDBusMethodInvocation object that can be used to return a value or error.
+ * @param user_data The user_data gpointer passed to g_dbus_connection_register_object().
+ */
+static void handle_method_call(GDBusConnection *connection,
+                                               const gchar *sender,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *method_name,
+                                               GVariant *parameters,
+                                               GDBusMethodInvocation *invocation,
+                                               gpointer user_data)
+{
+       method_call_s *handle = (method_call_s *) g_malloc0(sizeof(method_call_s));
+       if (NULL == handle) {
+               return;
+       }
+       handle->connection = connection;
+       handle->sender = (gchar *) sender;
+       handle->object_path = (gchar *) object_path;
+       handle->interface_name = (gchar *) interface_name;
+       handle->method_name = (gchar *) method_name;
+       handle->parameters = parameters;
+       handle->invocation = invocation;
+       handle->user_data = user_data;
+
+       g_thread_pool_push(thread_pool, (gpointer) handle, NULL);
+}
+
+/**
+ * @brief Service Adaptor D-Bus interface get property call handler.
+ *
+ * Service Adaptor D-Bus interface get property call handler.
+ * @param connection A GDBusConnection.
+ * @param sender The unique bus name of the remote caller.
+ * @param object_path The object path that the method was invoked on.
+ * @param interface_name The D-Bus interface name for the property.
+ * @param property_name The name of the property to get the value of.
+ * @param error Return location for error.
+ * @param user_data The user_data gpointer passed to g_dbus_connection_register_object().
+ * @return A GVariant with the value for property_name or NULL if error is set. If the returned GVariant
+ *         is floating, it is consumed - otherwise its reference count is decreased by one.
+ */
+static GVariant *handle_get_property(GDBusConnection *connection,
+                                               const gchar *sender,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *property_name,
+                                               GError **error,
+                                               gpointer user_data)
+{
+       GVariant *ret = NULL;
+
+       return ret;
+}
+
+/**
+ * @brief Service Adaptor D-Bus interface set property call handler.
+ *
+ * Service Adaptor D-Bus interface set property call handler.
+ * @param connection A GDBusConnection.
+ * @param sender The unique bus name of the remote caller.
+ * @param object_path The object path that the method was invoked on.
+ * @param interface_name The D-Bus interface name for the property.
+ * @param property_name The name of the property to get the value of.
+ * @param value The value to set the property to.
+ * @param error Return location for error.
+ * @param user_data     The user_data gpointer passed to g_dbus_connection_register_object().
+ * @return TRUE if the property was set to value, FALSE if error is set.
+ */
+static gboolean handle_set_property(GDBusConnection *connection,
+                                               const gchar *sender,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *property_name,
+                                               GVariant *value,
+                                               GError **error,
+                                               gpointer user_data)
+{
+       return *error == NULL;
+}
+
+/**
+ * D-Bus handlers vtable.
+ */
+static const GDBusInterfaceVTable interface_vtable = {
+       handle_method_call,
+       handle_get_property,
+       handle_set_property
+};
+
+/**
+ * @brief Callback function called when D-Bus bus name for vService Channel D-Bus server is acquired.
+ *
+ * Callback function called when D-Bus bus name for vService Channel D-Bus server is acquired.
+ * @param connection The GDBusConnection to a message bus.
+ * @param name The name that is requested to be owned.
+ * @param user_data User data passed to g_bus_own_name().
+ */
+static void on_bus_acquired(GDBusConnection *connection,
+                                               const gchar *name,
+                                               gpointer user_data)
+{
+       service_adaptor_debug("D-bus bus acquired");
+       guint registration_id;
+
+       registration_id = g_dbus_connection_register_object(connection,
+                       SERVICE_ADAPTOR_OBJECT_PATH,
+                       introspection_data->interfaces[0],
+                       &interface_vtable,
+                       NULL, /* user_data */
+                       NULL, /* user_data_free_func */
+                       NULL); /* GError** */
+       g_assert(registration_id > 0);
+}
+
+/**
+ * @brief Callback function called when D-Bus name for vService Channel D-Bus server is acquired.
+ *
+ * Callback function called when D-Bus name for vService Channel D-Bus server is acquired.
+ * @param connection The GDBusConnection on which to acquired the name.
+ * @param name The name being owned.
+ * @param user_data User data passed to g_bus_own_name() or g_bus_own_name_on_connection().
+ */
+static void on_name_acquired(GDBusConnection *connection,
+                                               const gchar *name,
+                                               gpointer user_data)
+{
+       service_adaptor_debug("D-bus bus name acquired");
+       dbus_connection = connection;
+       g_object_ref(dbus_connection);
+}
+
+/**
+ * @brief Callback function called when the vService Channel D-Bus name is lost or connection has been closed.
+ *
+ * Callback function called when the vService Channel D-Bus name is lost or connection has been closed.
+ * @param connection The GDBusConnection on which to acquire the name or NULL if the connection was disconnected.
+ * @param name The name being owned.
+ * @param user_data User data passed to g_bus_own_name() or g_bus_own_name_on_connection().
+ */
+static void on_name_lost(GDBusConnection *connection,
+                                               const gchar *name,
+                                               gpointer user_data)
+{
+       if (NULL != dbus_connection) {
+               g_object_unref(dbus_connection);
+               dbus_connection = NULL;
+       }
+
+       service_adaptor_warning("Unexpected D-bus bus name lost.");
+       service_adaptor_info("Service-adaptor Safe Shutdown");
+
+       exit(1);
+       /* Send SIGINT to main thread to stop File Manager process and cleanly close vService Channel */
+/*     kill(getpid(), SIGINT); */
+}
+
+int dbus_server_init()
+{
+       service_adaptor_debug("[Start] %s", __FUNCTION__);
+       if ((NULL != introspection_data) || (0 != owner_id)) {
+               /* Server is already running */
+               return -1;
+       }
+
+       service_adaptor_debug("[Step]");
+       introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
+       if (NULL == introspection_data) {
+               return -1;
+       }
+
+       service_adaptor_debug("[Step]");
+       thread_pool = g_thread_pool_new(method_call_async_func, NULL, -1, FALSE, NULL);
+
+       if (NULL == thread_pool) {
+               return -1;
+       }
+
+       service_adaptor_debug("[Step] thread pool (%p)", thread_pool);
+       owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
+                       SERVICE_ADAPTOR_BUS_NAME,
+                       G_BUS_NAME_OWNER_FLAGS_NONE,
+                       on_bus_acquired,
+                       on_name_acquired,
+                       on_name_lost,
+                       NULL,
+                       NULL);
+
+       service_adaptor_debug("[Step] owner_id %u", owner_id);
+       if (0 == owner_id) {
+               g_dbus_node_info_unref(introspection_data);
+               introspection_data = NULL;
+               return -1;
+       }
+
+       service_adaptor_debug("[End] %s", __FUNCTION__);
+       return 0;
+}
+
+void dbus_server_deinit()
+{
+       if (NULL != thread_pool) {
+               g_thread_pool_free(thread_pool, TRUE, TRUE);
+       }
+
+       if (0 != owner_id) {
+               g_bus_unown_name(owner_id);
+               owner_id = 0;
+       }
+
+       if (NULL != introspection_data) {
+               g_dbus_node_info_unref(introspection_data);
+               introspection_data = NULL;
+       }
+}
+/* EOF */
diff --git a/src/dbus/dbus-service-adaptor.c b/src/dbus/dbus-service-adaptor.c
new file mode 100644 (file)
index 0000000..6e14135
--- /dev/null
@@ -0,0 +1,238 @@
+/*
+* 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 <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "service-adaptor.h"
+#include "service-adaptor-type.h"
+#include "service-adaptor-log.h"
+#include "dbus-service-adaptor.h"
+#include "dbus-server.h"
+#include "dbus-server-type.h"
+#include "dbus-util.h"
+
+#include "dbus-auth-adaptor.h"
+#include "dbus-storage-adaptor.h"
+#include "dbus-contact-adaptor.h"
+#include "dbus-message-adaptor.h"
+#include "dbus-shop-adaptor.h"
+
+#define RET_MSG_LEN    2048
+
+void service_adaptor_method_call(GDBusConnection *connection,
+                                               const gchar *sender,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *method_name,
+                                               GVariant *parameters,
+                                               GDBusMethodInvocation *invocation,
+                                               gpointer user_data)
+{
+FUNC_START();
+       service_adaptor_internal_error_code_e ret_code = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       char ret_msg[RET_MSG_LEN] = {0,};
+
+       if ((0 == g_strcmp0(method_name, PRIVATE_DBUS_CONNECT_SERVICE_ADAPTOR_METHOD)) ||
+               (0 == g_strcmp0(method_name, DBUS_CONNECT_SERVICE_ADAPTOR_METHOD))) {
+#if !GLIB_CHECK_VERSION(2, 32, 0)
+               g_thread_init(NULL);
+#endif
+#if !GLIB_CHECK_VERSION(2, 35, 0)
+               g_type_init();
+#endif
+               int waiting_cnt = 10;
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+
+FUNC_STEP();
+               while ((NULL == service_adaptor) && (0 < waiting_cnt)) {
+                       service_adaptor = service_adaptor_get_handle();
+                       waiting_cnt--;
+                       service_adaptor_debug("Retry service_adaptor_get_handle()");
+                       sleep(1);
+               }
+
+FUNC_STEP();
+               if (NULL == service_adaptor) {
+                       service_adaptor_error("Cannot get handle of service adaptor");
+                       ret_code = SERVICE_ADAPTOR_INTERNAL_ERROR_INIT;
+                       strncpy(ret_msg, "Cannot get handle of service adaptor", (RET_MSG_LEN - 1));
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) ret_code, ret_msg));
+                       return;
+               }
+
+FUNC_STEP();
+               gint64 timeout = g_get_monotonic_time() + 10 * G_TIME_SPAN_SECOND;
+               g_mutex_lock(&service_adaptor->service_adaptor_mutex);
+
+FUNC_STEP();
+               while (!service_adaptor->started) {
+                       if (!g_cond_wait_until(&service_adaptor->service_adaptor_cond, &service_adaptor->service_adaptor_mutex, timeout)) {
+                               ret_code = SERVICE_ADAPTOR_INTERNAL_ERROR_INIT;
+                               strncpy(ret_msg, "Timeout", (RET_MSG_LEN - 1));
+                               service_adaptor_warning("Service adaptor Initalize timed out");
+
+                               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) ret_code, ret_msg));
+                               g_mutex_unlock(&service_adaptor->service_adaptor_mutex);
+
+                               return;
+                       }
+               }
+
+               g_mutex_unlock(&service_adaptor->service_adaptor_mutex);
+
+               service_adaptor_info("Client Connected Successful");
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) ret_code, ret_msg));
+FUNC_END();
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_EXTERNAL_REQ_METHOD)) {
+               service_adaptor_debug("[START] External request method");
+               GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+               GVariant *req_struct[private_service_adaptor_external_req_s_type_length];
+
+               for (size_t j = 0; j < private_service_adaptor_external_req_s_type_length; j++) {
+                       req_struct[j] = g_variant_get_child_value(in_parameters, j);
+               }
+               int idx = 0;
+               char *service_name      = ipc_g_variant_dup_string(req_struct[idx++]);
+               int service_flag        = g_variant_get_int32(req_struct[idx++]);
+               char *api_uri           = ipc_g_variant_dup_string(req_struct[idx++]);
+
+               service_adaptor_debug("service_name : %s / %d", service_name, service_flag);
+               service_adaptor_debug("api_uri : %s", api_uri);
+               int raw_data_len = g_variant_n_children(req_struct[idx]);
+               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(req_struct[idx], k, "(y)", &(raw_data[k]));
+                       }
+               }
+
+               for (size_t j = 0; j < private_service_adaptor_external_req_s_type_length; j++) {
+                       g_variant_unref(req_struct[j]);
+               }
+               service_adaptor_debug_func("req_data_len (%d)", raw_data_len);
+               service_adaptor_debug_func("req_data (%s)", raw_data);
+
+               int ret = 0;
+               unsigned char *res_data = NULL;
+               int res_data_len = 0;
+
+               /* Call API */
+               switch (service_flag) {
+               case SERVICE_ADAPTOR_PROTOCOL_SERVICE_TYPE_AUTH:
+                       service_adaptor_debug("Call auth_external_method_call");
+                       auth_external_method_call(service_name, api_uri, raw_data, raw_data_len,
+                                       &res_data, &res_data_len, &ret, ret_msg);
+                       break;
+               case SERVICE_ADAPTOR_PROTOCOL_SERVICE_TYPE_STORAGE:
+                       break;
+               case SERVICE_ADAPTOR_PROTOCOL_SERVICE_TYPE_CONTACT:
+                       break;
+               case SERVICE_ADAPTOR_PROTOCOL_SERVICE_TYPE_MESSAGE:
+                       break;
+               case SERVICE_ADAPTOR_PROTOCOL_SERVICE_TYPE_SHOP:
+                       break;
+               case SERVICE_ADAPTOR_PROTOCOL_SERVICE_TYPE_PUSH:
+                       break;
+               default:
+                       break;
+               }
+
+               service_adaptor_debug_func("res_data_len (%d)", res_data_len);
+               service_adaptor_debug_func("res_data (%s)", res_data);
+               GVariantBuilder *builder_raw = g_variant_builder_new(G_VARIANT_TYPE(service_adaptor_raw_data_s_type));
+               if (NULL != res_data) {
+                       for (int r = 0; r < res_data_len; r++) {
+                               g_variant_builder_add(builder_raw, "(y)", (guchar)res_data[r]);
+                       }
+               }
+
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new(MAKE_RETURN_TYPE(service_adaptor_raw_data_s_type), builder_raw, (uint64_t) ret, ret_msg));
+               g_variant_builder_unref(builder_raw);
+               service_adaptor_debug("[End] External request method");
+
+               free(service_name);
+               free(api_uri);
+               free(raw_data);
+               free(res_data);
+       }
+}
+
+service_adaptor_internal_error_code_e dbus_push_data_callback(uint32_t service_id,
+                                               push_adaptor_notification_data_h app_data,
+                                               service_adaptor_internal_error_h error_code,
+                                               void *server_data)
+{
+FUNC_START();
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+
+               GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_push_data_s_type), service_id, __safe_add_string(app_data->data), __safe_add_string(app_data->msg), app_data->time_stamp, (uint64_t) error_code->code, __safe_add_string(error_code->msg));
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_PUSH_DATA_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+FUNC_END();
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e dbus_service_adaptor_signal_callback(service_adaptor_internal_signal_code_e signal_code,
+                                               const char *signal_msg)
+{
+FUNC_START();
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+               GVariant *response = g_variant_new("(ts)", (uint64_t) signal_code, (signal_msg ? signal_msg : ""));
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_SERVICE_ADAPTOR_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+FUNC_END();
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
diff --git a/src/dbus/dbus-shop-adaptor.c b/src/dbus/dbus-shop-adaptor.c
new file mode 100644 (file)
index 0000000..1330455
--- /dev/null
@@ -0,0 +1,517 @@
+/*
+* 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 <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "service-adaptor.h"
+#include "service-adaptor-shop.h"
+#include "service-adaptor-type.h"
+#include "service-adaptor-log.h"
+#include "dbus-shop-adaptor.h"
+#include "dbus-server.h"
+#include "dbus-util.h"
+
+void __destroy_shop_info_s(shop_adaptor_shop_info_s *info)
+{
+       if (NULL == info) {
+               return;
+       }
+
+       free(info->lang_cd);
+       free(info->cntry_cd);
+}
+
+void __destroy_shop_item_s(shop_adaptor_shop_item_s *item)
+{
+       if (NULL == item) {
+               return;
+       }
+
+       free(item->sticker_ids);
+       free(item->title);
+       free(item->character);
+       free(item->download_url);
+       free(item->panel_url);
+       free(item->sticker_url);
+       free(item->character_code);
+}
+
+
+void __get_shop_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               shop_adaptor_shop_info_s *info)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_shop_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_shop_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       GVariant *req_info_struct[private_service_adaptor_shop_info_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_shop_info_s_type_length; j++) {
+               req_info_struct[j] = g_variant_get_child_value(req_struct[idx], j);
+       }
+
+       int idx2 = 0;
+       info->category_id = g_variant_get_int32(req_info_struct[idx2++]);
+       info->item_id = g_variant_get_int32(req_info_struct[idx2++]);
+       info->sticker_id = g_variant_get_int32(req_info_struct[idx2++]);
+       info->lang_cd = ipc_g_variant_dup_string(req_info_struct[idx2++]);
+       info->cntry_cd = ipc_g_variant_dup_string(req_info_struct[idx2++]);
+       info->rwidth = g_variant_get_int32(req_info_struct[idx2++]);
+       info->rheight = g_variant_get_int32(req_info_struct[idx2++]);
+       info->start_idx = g_variant_get_int32(req_info_struct[idx2++]);
+       info->count = g_variant_get_int32(req_info_struct[idx2++]);
+
+       for (size_t j = 0; j < private_service_adaptor_shop_info_s_type_length; j++) {
+               g_variant_unref(req_info_struct[j]);
+       }
+
+       for (size_t j = 0; j < private_service_adaptor_shop_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+GVariant *__create_shop_item_res_type(shop_adaptor_shop_item_s *item,
+                                               shop_adaptor_error_code_t *error_code)
+{
+       shop_adaptor_shop_item_s _item;
+       _item.sticker_ids_len = 0;
+       _item.item_id = 0;
+       _item.category_id = 0;
+       _item.title = "";
+       _item.character = "";
+       _item.version = 0;
+       _item.download_url = "";
+       _item.panel_url = "";
+       _item.sticker_url = "";
+       _item.file_size = 0;
+       _item.count = 0;
+       _item.character_code = "";
+       _item.startdate = 0;
+       _item.enddate = 0;
+       _item.expired_date = 0;
+       _item.valid_period = 0;
+
+       if (NULL == item) {
+               item = &_item;
+       }
+
+       GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(i)"));
+
+       for (gsize j = 0; j < item->sticker_ids_len; j++) {
+               g_variant_builder_add(builder, "(i)", item->sticker_ids[j]);
+       }
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_shop_item_s_type),
+                       item->item_id, item->category_id, builder, item->sticker_ids_len,
+                       __safe_add_string(item->title), __safe_add_string(item->character),
+                       item->version, __safe_add_string(item->download_url), __safe_add_string(item->panel_url),
+                       __safe_add_string(item->sticker_url), item->file_size, item->count,
+                       __safe_add_string(item->character_code), item->startdate, item->enddate,
+                       item->expired_date, item->valid_period,
+                       (uint64_t) error_code->code, __safe_add_string(error_code->msg));
+
+       g_variant_builder_unref(builder);
+
+       return response;
+}
+
+GVariant *__create_shop_item_list_res_type(shop_adaptor_shop_item_s **items,
+                                               unsigned int items_len,
+                                               shop_adaptor_error_code_t *error_code)
+{
+       if (NULL == items) {
+               items_len = 0;
+       }
+
+       GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE(private_shop_item_res_list_type));
+       GVariantBuilder *builder_in;
+
+       for (gsize i = 0; i < items_len; i++) {
+               g_variant_builder_open(builder, G_VARIANT_TYPE(private_service_adaptor_shop_item_s_type));
+               g_variant_builder_add(builder, "i", (int) items[i]->item_id);
+               g_variant_builder_add(builder, "i", items[i]->category_id);
+
+               /* sticker_ids */
+               builder_in = g_variant_builder_new(G_VARIANT_TYPE("a(i)"));
+
+               for (gsize j = 0; j < items[i]->sticker_ids_len; j++) {
+                       g_variant_builder_add(builder_in, "(i)", (int) items[i]->sticker_ids[j]);
+               }
+
+               g_variant_builder_add(builder, "a(i)", builder_in);
+               g_variant_builder_unref(builder_in);
+
+               g_variant_builder_add(builder, "u", items[i]->sticker_ids_len);
+               safe_g_variant_builder_add_string(builder, items[i]->title);
+               safe_g_variant_builder_add_string(builder, items[i]->character);
+               g_variant_builder_add(builder, "i", items[i]->version);
+               safe_g_variant_builder_add_string(builder, items[i]->download_url);
+               safe_g_variant_builder_add_string(builder, items[i]->panel_url);
+               safe_g_variant_builder_add_string(builder, items[i]->sticker_url);
+               g_variant_builder_add(builder, "i", (int) items[i]->file_size);
+               g_variant_builder_add(builder, "i", items[i]->count);
+               safe_g_variant_builder_add_string(builder, items[i]->character_code);
+               g_variant_builder_add(builder, "x", items[i]->startdate);
+               g_variant_builder_add(builder, "x", items[i]->enddate);
+               g_variant_builder_add(builder, "x", items[i]->expired_date);
+               g_variant_builder_add(builder, "x", items[i]->valid_period);
+               g_variant_builder_close(builder);
+       }
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_shop_res_s_type),
+                       builder, items_len, (uint64_t) error_code->code, __safe_add_string(error_code->msg));
+
+       g_variant_builder_unref(builder);
+
+       return response;
+}
+
+void shop_adaptor_method_call(GDBusConnection *connection,
+                                               const gchar *sender,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *method_name,
+                                               GVariant *parameters,
+                                               GDBusMethodInvocation *invocation,
+                                               gpointer user_data)
+{
+       service_adaptor_internal_error_code_e ret_code = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+
+       if (0 == g_strcmp0(method_name, PRIVATE_DBUS_GET_ITEM_LIST_METHOD)) {
+               char *service_name = NULL;
+               shop_adaptor_shop_info_s info;
+               shop_adaptor_shop_item_s **items = NULL;
+               unsigned int items_len = 0;
+               void *user_data = NULL;
+               void *server_data = NULL;
+               shop_adaptor_error_code_t *error_code = NULL;
+               shop_adaptor_error_code_t _error;
+               _error.code = SHOP_ADAPTOR_ERROR_NONE;
+               _error.msg = NULL;
+
+               __get_shop_req_type(parameters, &service_name, &info);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = SHOP_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       GVariant *response = __create_shop_item_list_res_type(items, items_len, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       free(service_name);
+                       __destroy_shop_info_s(&info);
+                       return;
+               }
+
+               shop_adaptor_h adaptor = service_adaptor_get_shop_adaptor(service_adaptor);
+               shop_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->shop_context) {
+                       plugin = shop_adaptor_get_plugin_by_name(adaptor, service->shop_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       ret_code = shop_adaptor_get_item_list_v1(plugin, service->shop_context,
+                                       &info, user_data, &items, &items_len, &error_code, &server_data);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->shop_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               shop_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = shop_adaptor_get_item_list_v1(plugin, service->shop_context,
+                                               &info, user_data, &items, &items_len, &error_code, &server_data);
+                       }
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                               service_adaptor_error("Can not run shop_adaptor_get_item_list_v1()");
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NONE;
+                       error_code->msg = strdup("");
+               }
+
+               GVariant *response = __create_shop_item_list_res_type(items, items_len, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               __destroy_shop_info_s(&info);
+               if ((NULL != items) && (0U < items_len)) {
+                       for (int i = 0; i < items_len; i++) {
+                               __destroy_shop_item_s(items[i]);
+                               free(items[i]);
+                       }
+                       free(items);
+               }
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_DOWNLOAD_ITEM_PACKAGE_METHOD)) {
+               char *service_name = NULL;
+               shop_adaptor_shop_info_s info;
+               shop_adaptor_shop_item_s *item = NULL;
+               shop_adaptor_error_code_t *error_code = NULL;
+               shop_adaptor_error_code_t _error;
+               _error.code = SHOP_ADAPTOR_ERROR_NONE;
+               _error.msg = NULL;
+
+               __get_shop_req_type(parameters, &service_name, &info);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = SHOP_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       GVariant *response = __create_shop_item_res_type(item, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       free(service_name);
+                       __destroy_shop_info_s(&info);
+                       return;
+               }
+
+               shop_adaptor_h adaptor = service_adaptor_get_shop_adaptor(service_adaptor);
+               shop_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->shop_context) {
+                       plugin = shop_adaptor_get_plugin_by_name(adaptor, service->shop_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       ret_code = shop_adaptor_download_item_package_v1(plugin, service->shop_context,
+                                       &info, NULL, &item, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->shop_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               shop_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = shop_adaptor_download_item_package_v1(plugin, service->shop_context,
+                                               &info, NULL, &item, &error_code, NULL);
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NONE;
+                       error_code->msg = strdup("");
+               }
+
+               GVariant *response = __create_shop_item_res_type(item, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               __destroy_shop_info_s(&info);
+               __destroy_shop_item_s(item);
+               free(item);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_DOWNLOAD_STICKER_METHOD)) {
+               char *service_name = NULL;
+               shop_adaptor_shop_info_s info;
+               shop_adaptor_shop_item_s *item = NULL;
+               shop_adaptor_error_code_t *error_code = NULL;
+               shop_adaptor_error_code_t _error;
+               _error.code = SHOP_ADAPTOR_ERROR_NONE;
+               _error.msg = NULL;
+
+               __get_shop_req_type(parameters, &service_name, &info);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = SHOP_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       GVariant *response = __create_shop_item_res_type(item, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       free(service_name);
+                       __destroy_shop_info_s(&info);
+                       return;
+               }
+
+               shop_adaptor_h adaptor = service_adaptor_get_shop_adaptor(service_adaptor);
+               shop_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->shop_context) {
+                       plugin = shop_adaptor_get_plugin_by_name(adaptor, service->shop_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       ret_code = shop_adaptor_download_sticker_v1(plugin, service->shop_context,
+                                       &info, NULL, &item, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->shop_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               shop_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = shop_adaptor_download_sticker_v1(plugin, service->shop_context,
+                                               &info, NULL, &item, &error_code, NULL);
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NONE;
+                       error_code->msg = strdup("");
+               }
+
+               GVariant *response = __create_shop_item_res_type(item, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               __destroy_shop_info_s(&info);
+               __destroy_shop_item_s(item);
+               free(item);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_GET_PANEL_URL_METHOD)) {
+               char *service_name = NULL;
+               shop_adaptor_shop_info_s info;
+               shop_adaptor_shop_item_s *item = NULL;
+               shop_adaptor_error_code_t *error_code = NULL;
+               shop_adaptor_error_code_t _error;
+               _error.code = SHOP_ADAPTOR_ERROR_NONE;
+               _error.msg = NULL;
+
+               __get_shop_req_type(parameters, &service_name, &info);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = SHOP_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = "Can not get service context";
+
+                       GVariant *response = __create_shop_item_res_type(item, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       free(service_name);
+                       __destroy_shop_info_s(&info);
+                       return;
+               }
+
+               shop_adaptor_h adaptor = service_adaptor_get_shop_adaptor(service_adaptor);
+               shop_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->shop_context) {
+                       plugin = shop_adaptor_get_plugin_by_name(adaptor, service->shop_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       ret_code = shop_adaptor_get_panel_url_v1(plugin, service->shop_context,
+                                       &info, NULL, &item, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->shop_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               shop_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = shop_adaptor_get_panel_url_v1(plugin, service->shop_context,
+                                               &info, NULL, &item, &error_code, NULL);
+                       }
+               }
+
+               if (NULL == error_code) {
+                       error_code = &_error;
+                       error_code->code = CONTACT_ADAPTOR_ERROR_NONE;
+                       error_code->msg = strdup("");
+               }
+
+               GVariant *response = __create_shop_item_res_type(item, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               __destroy_shop_info_s(&info);
+               __destroy_shop_item_s(item);
+               free(item);
+       }
+}
diff --git a/src/dbus/dbus-storage-adaptor.c b/src/dbus/dbus-storage-adaptor.c
new file mode 100644 (file)
index 0000000..682d705
--- /dev/null
@@ -0,0 +1,3395 @@
+/*
+* 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 <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <gio/gio.h>
+#include <libgen.h>
+
+#include "service-adaptor.h"
+#include "service-adaptor-storage.h"
+#include "service-adaptor-type.h"
+#include "service-adaptor-log.h"
+#include "dbus-storage-adaptor.h"
+#include "dbus-server.h"
+#include "dbus-server-type.h"
+#include "dbus-util.h"
+#include "util/client_checker.h"
+
+#define MEDIA_META_CLEAR(x) do {\
+               (x)->mime_type          = NULL;\
+               (x)->title              = NULL;\
+               (x)->album              = NULL;\
+               (x)->artist             = NULL;\
+               (x)->genere             = NULL;\
+               (x)->recorded_date      = NULL;\
+               (x)->width              = -1;\
+               (x)->height             = -1;\
+               (x)->duration           = -1;\
+               (x)->copyright          = NULL;\
+               (x)->track_num          = NULL;\
+               (x)->description        = NULL;\
+               (x)->composer           = NULL;\
+               (x)->year               = NULL;\
+               (x)->bitrate            = -1;\
+               (x)->samplerate         = -1;\
+               (x)->channel            = -1;\
+               (x)->extra_media_meta   = NULL; } while (0)
+
+#define CLOUD_META_CLEAR(x) do {\
+               (x)->service_name       = NULL;\
+               (x)->usage_byte         = 0ULL;\
+               (x)->quota_byte         = 0ULL;\
+               (x)->extra_cloud_meta   = NULL; } while (0)
+
+#define FILE_INFO_CLEAR(x) do {\
+                (x)->plugin_uri          = NULL;\
+                (x)->object_id           = NULL;\
+                (x)->storage_path        = NULL;\
+                (x)->file_size           = 0ULL;\
+\
+               (x)->revision            = -1;\
+               (x)->timestamp           = 0ULL;\
+               (x)->type                = NULL;\
+               (x)->deleted             = -1;\
+               (x)->expired_time        = 0ULL;\
+               (x)->download_count      = -0U;\
+               (x)->max_download_count  = -0U;\
+               (x)->file_info_index     = -1;\
+               (x)->tag                 = NULL;\
+               (x)->file_share_token    = NULL;\
+\
+               (x)->created_time        = 0ULL;\
+               (x)->modified_time       = 0ULL;\
+               (x)->file_info_index     = -1;\
+               (x)->content_type        = STORAGE_ADAPTOR_CONTENT_TYPE_DEFAULT;\
+               (x)->extra_file_info     = NULL;\
+\
+               (x)->media_meta          = NULL;\
+               (x)->cloud_meta          = NULL; } while (0)
+
+
+#define __check_error_code()   do { \
+               if (NULL == error_code) { \
+                       error_code = &_error; \
+                       if (ret_code) { \
+                               error_code->code = ret_code; \
+                               error_code->msg = strdup("[PLUGIN_ERROR] Unknown (Couldn't get detail message from plugin)"); \
+                       } else { \
+                               error_code->code = STORAGE_ADAPTOR_ERROR_NONE; \
+                               error_code->msg = strdup(""); \
+                       } \
+               } \
+       } while (0)
+
+void __get_file_transfer_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               char **server_path,
+                                               char **download_path)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[service_adaptor_file_transfer_req_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_file_transfer_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *server_path = ipc_g_variant_dup_string(req_struct[idx++]);
+       *download_path = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_file_transfer_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_download_thumbnail_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               char **server_path,
+                                               char **download_path,
+                                               int *thumbnail_size)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[service_adaptor_download_thumbnail_req_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_download_thumbnail_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *server_path = ipc_g_variant_dup_string(req_struct[idx++]);
+       *download_path = ipc_g_variant_dup_string(req_struct[idx++]);
+       *thumbnail_size = (int) g_variant_get_int32(req_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_download_thumbnail_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+/* private feature */
+GVariant *__private_create_file_transfer_res_type(int fd,
+                                               storage_adaptor_error_code_h error_code)
+{
+       storage_adaptor_error_code_t _error;
+       _error.msg = NULL;
+
+       if (NULL == error_code) {
+               error_code = &_error;
+               if (0 == fd) {
+                       error_code->code = STORAGE_PLUGIN_ERROR_FILE_OPEN_FAILED;
+                       error_code->msg = strdup("Open file failed");
+               } else {
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NONE;
+                       error_code->msg = strdup("");
+               }
+       }
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_file_s_type), fd,
+                       (uint64_t) error_code->code, __safe_add_string(error_code->msg));
+
+       free(_error.msg);
+
+       return response;
+}
+
+GVariant *__private_create_file_publish_transfer_res_type(storage_adaptor_file_info_h file_info,
+                                               storage_adaptor_error_code_h error_code)
+{
+       char publish_url[1024] = {0, };
+       storage_adaptor_error_code_t _error;
+       _error.msg = NULL;
+
+       if (NULL == error_code) {
+               error_code = &_error;
+               error_code->code = STORAGE_ADAPTOR_ERROR_NONE;
+               error_code->msg = strdup("");
+       }
+
+       if ((NULL == file_info) || (NULL == file_info->file_share_token)) {
+               snprintf(publish_url, 1024, "%s?auth_code=%s", "", "");
+               error_code->code = STORAGE_ADAPTOR_ERROR_SERVER_INTERNAL;
+               free(error_code->msg);
+               error_code->msg = strdup("Invalid Publish Token");
+       } else {
+               snprintf(publish_url, 1024, "%s?auth_code=%s", file_info->file_share_token->public_token,
+                               file_info->file_share_token->auth_code);
+       }
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_file_publish_s_type), publish_url,
+                       (uint64_t) error_code->code, __safe_add_string(error_code->msg));
+
+       free(_error.msg);
+
+       return response;
+}
+
+void __private_get_file_status_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               int *fd)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[private_service_adaptor_file_status_req_s_type_length];
+
+       for (size_t j = 0; j < private_service_adaptor_file_status_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *fd = g_variant_get_int32(req_struct[idx++]);
+
+       for (size_t j = 0; j < private_service_adaptor_file_status_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+GVariant *__private_create_file_status_res_type(int64_t progress_size,
+                                               int64_t total_size,
+                                               storage_adaptor_transfer_state_e state,
+                                               storage_adaptor_error_code_h error_code)
+{
+       storage_adaptor_error_code_t _error;
+       _error.msg = NULL;
+
+       if (NULL == error_code) {
+               error_code = &_error;
+               error_code->code = STORAGE_ADAPTOR_ERROR_NONE;
+               error_code->msg = strdup("");
+       }
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_file_status_res_s_type),
+                       total_size, progress_size, (uint64_t) state,
+                       (uint64_t) error_code->code, __safe_add_string(error_code->msg));
+
+       free(_error.msg);
+
+       return response;
+}
+
+/* public feature */
+void __get_get_root_folder_path_req_type(GVariant *parameters,
+                                               char **service_name)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[service_adaptor_get_root_folder_path_req_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_get_root_folder_path_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_get_root_folder_path_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_make_directory_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               char **folder_path)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[service_adaptor_make_directory_req_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_make_directory_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name   = ipc_g_variant_dup_string(req_struct[idx++]);
+       *folder_path    = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_make_directory_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_remove_file_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               char **file_path)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[service_adaptor_remove_file_req_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_remove_file_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *file_path = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_remove_file_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_remove_directory_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               char **folder_path)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[service_adaptor_remove_directory_req_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_remove_directory_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *folder_path = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_remove_directory_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_move_file_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               char **src_file_path,
+                                               char **des_file_path)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[service_adaptor_move_file_req_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_move_file_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *src_file_path = ipc_g_variant_dup_string(req_struct[idx++]);
+       *des_file_path = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_move_file_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_move_directory_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               char **src_folder_path,
+                                               char **des_folder_path)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[service_adaptor_move_directory_req_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_move_directory_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+       *src_folder_path = ipc_g_variant_dup_string(req_struct[idx++]);
+       *des_folder_path = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_move_directory_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_get_file_list_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               char **parent_path)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[service_adaptor_get_file_list_req_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_get_file_list_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name   = ipc_g_variant_dup_string(req_struct[idx++]);
+       *parent_path    = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_get_file_list_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_open_upload_file_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               char **local_path,
+                                               char **upload_path)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[service_adaptor_open_upload_file_req_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_open_upload_file_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name   = ipc_g_variant_dup_string(req_struct[idx++]);
+       *local_path     = ipc_g_variant_dup_string(req_struct[idx++]);
+       *upload_path    = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_open_upload_file_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_open_download_file_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               char **storage_path,
+                                               char **local_path)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[service_adaptor_open_download_file_req_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_open_download_file_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name   = ipc_g_variant_dup_string(req_struct[idx++]);
+       *storage_path   = ipc_g_variant_dup_string(req_struct[idx++]);
+       *local_path     = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_open_download_file_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_open_download_thumbnail_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               char **storage_path,
+                                               char **local_path,
+                                               int *thumbnail_size)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[service_adaptor_open_download_thumbnail_req_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_open_download_thumbnail_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name   = ipc_g_variant_dup_string(req_struct[idx++]);
+       *storage_path   = ipc_g_variant_dup_string(req_struct[idx++]);
+       *local_path     = ipc_g_variant_dup_string(req_struct[idx++]);
+       *thumbnail_size = g_variant_get_int32(req_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_open_download_thumbnail_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_close_file_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               long long int *file_uid)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[service_adaptor_close_file_req_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_close_file_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       do {
+               GVariant *fd_req_struct[service_adaptor_file_descriptor_s_type_length];
+               for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+                       fd_req_struct[k] = g_variant_get_child_value(req_struct[idx], k);
+               }
+               int fd_idx = 0;
+               *file_uid = (long long int) g_variant_get_int64(fd_req_struct[fd_idx++]);
+
+               for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+                       g_variant_unref(fd_req_struct[k]);
+               }
+               idx++;
+       } while (0);
+
+       for (size_t j = 0; j < service_adaptor_close_file_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_start_upload_file_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               long long int *file_uid,
+                                               char **storage_path,
+                                               bool *need_progress,
+                                               bool *need_state)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[service_adaptor_start_upload_file_req_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_start_upload_file_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       do {
+               GVariant *fd_req_struct[service_adaptor_file_descriptor_s_type_length];
+               for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+                       fd_req_struct[k] = g_variant_get_child_value(req_struct[idx], k);
+               }
+               int fd_idx = 0;
+               *file_uid = (long long int) g_variant_get_int64(fd_req_struct[fd_idx++]);
+
+               for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+                       g_variant_unref(fd_req_struct[k]);
+               }
+               idx++;
+       } while (0);
+       *storage_path = ipc_g_variant_dup_string(req_struct[idx++]);
+       *need_progress = g_variant_get_boolean(req_struct[idx++]);
+       *need_state = g_variant_get_boolean(req_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_start_upload_file_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+
+void __get_start_download_file_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               long long int *file_uid,
+                                               char **storage_path,
+                                               bool *need_progress,
+                                               bool *need_state)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[service_adaptor_start_download_file_req_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_start_download_file_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       do {
+               GVariant *fd_req_struct[service_adaptor_file_descriptor_s_type_length];
+               for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+                       fd_req_struct[k] = g_variant_get_child_value(req_struct[idx], k);
+               }
+               int fd_idx = 0;
+               *file_uid = (long long int) g_variant_get_int64(fd_req_struct[fd_idx++]);
+
+               for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+                       g_variant_unref(fd_req_struct[k]);
+               }
+               idx++;
+       } while (0);
+       *storage_path = ipc_g_variant_dup_string(req_struct[idx++]);
+       *need_progress = g_variant_get_boolean(req_struct[idx++]);
+       *need_state = g_variant_get_boolean(req_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_start_download_file_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+
+void __get_start_download_thumbnail_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               long long int *file_uid,
+                                               char **storage_path,
+                                               int *thumbnail_size,
+                                               bool *need_progress,
+                                               bool *need_state)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[service_adaptor_start_download_thumbnail_req_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_start_download_thumbnail_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       do {
+               GVariant *fd_req_struct[service_adaptor_file_descriptor_s_type_length];
+               for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+                       fd_req_struct[k] = g_variant_get_child_value(req_struct[idx], k);
+               }
+               int fd_idx = 0;
+               *file_uid = (long long int) g_variant_get_int64(fd_req_struct[fd_idx++]);
+
+               for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+                       g_variant_unref(fd_req_struct[k]);
+               }
+               idx++;
+       } while (0);
+       *storage_path = ipc_g_variant_dup_string(req_struct[idx++]);
+       *thumbnail_size = (int) g_variant_get_int32(req_struct[idx++]);
+       *need_progress = g_variant_get_boolean(req_struct[idx++]);
+       *need_state = g_variant_get_boolean(req_struct[idx++]);
+
+       for (size_t j = 0; j < service_adaptor_start_download_thumbnail_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+void __get_cancel_file_task_req_type(GVariant *parameters,
+                                               char **service_name,
+                                               long long int *file_uid)
+{
+       GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+       GVariant *req_struct[service_adaptor_cancel_file_task_req_s_type_length];
+
+       for (size_t j = 0; j < service_adaptor_cancel_file_task_req_s_type_length; j++) {
+               req_struct[j] = g_variant_get_child_value(in_parameters, j);
+       }
+
+       int idx = 0;
+       *service_name = ipc_g_variant_dup_string(req_struct[idx++]);
+
+       do {
+               GVariant *fd_req_struct[service_adaptor_file_descriptor_s_type_length];
+               for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+                       fd_req_struct[k] = g_variant_get_child_value(req_struct[idx], k);
+               }
+               int fd_idx = 0;
+               *file_uid = (long long int) g_variant_get_int64(fd_req_struct[fd_idx++]);
+
+               for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+                       g_variant_unref(fd_req_struct[k]);
+               }
+               idx++;
+       } while (0);
+
+       for (size_t j = 0; j < service_adaptor_cancel_file_task_req_s_type_length; j++) {
+               g_variant_unref(req_struct[j]);
+       }
+}
+
+GVariant *__create_file_descriptor_res_type(long long int file_uid,
+                                               storage_adaptor_error_code_h error_code)
+{
+       storage_adaptor_error_code_t _error;
+       _error.msg = NULL;
+
+       if (NULL == error_code) {
+               error_code = &_error;
+               error_code->code = STORAGE_ADAPTOR_ERROR_NONE;
+               error_code->msg = strdup("");
+       }
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(service_adaptor_file_descriptor_s_type),
+                       (int64_t) file_uid,
+                       (uint64_t) error_code->code, __safe_add_string(error_code->msg));
+
+       free(_error.msg);
+       return response;
+}
+
+
+
+GVariant *__create_get_root_folder_path_res_type(const char *root_folder_path,
+                                               storage_adaptor_error_code_h error_code)
+{
+       storage_adaptor_error_code_t _error;
+       _error.msg = NULL;
+
+       if (NULL == error_code) {
+               error_code = &_error;
+               error_code->code = STORAGE_ADAPTOR_ERROR_NONE;
+               error_code->msg = strdup("");
+       }
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(service_adaptor_get_root_folder_path_res_s_type),
+                       __safe_add_string(root_folder_path),
+                       (uint64_t) error_code->code, __safe_add_string(error_code->msg));
+
+       free(_error.msg);
+       return response;
+}
+
+GVariant *__create_file_info_res_type(storage_adaptor_file_info_h file_info,
+                                               storage_adaptor_error_code_h error_code)
+{
+       storage_adaptor_error_code_h _error_code = error_code;
+       storage_adaptor_error_code_t dummy_error_code;
+       dummy_error_code.code = 0LL;
+       dummy_error_code.msg = "";
+
+       if (NULL == _error_code) {
+               _error_code = &dummy_error_code;
+       }
+
+       storage_adaptor_file_info_h _file_info = file_info;
+       storage_adaptor_file_info_t dummy_file_info;
+       storage_adaptor_media_meta_s _media_meta;
+       storage_adaptor_cloud_meta_s _cloud_meta;
+
+       FILE_INFO_CLEAR(&dummy_file_info);
+       MEDIA_META_CLEAR(&_media_meta);
+       CLOUD_META_CLEAR(&_cloud_meta);
+
+       dummy_file_info.media_meta          = &_media_meta;
+       dummy_file_info.cloud_meta          = &_cloud_meta;
+
+       if (NULL == _file_info) {
+               _file_info = &dummy_file_info;
+       }
+
+       if (NULL == _file_info->media_meta) {
+               _file_info->media_meta = dummy_file_info.media_meta;
+       }
+
+       if (NULL == _file_info->cloud_meta) {
+               _file_info->cloud_meta = dummy_file_info.cloud_meta;
+       }
+
+       GVariant *return_val = NULL;
+       return_val = g_variant_new(MAKE_RETURN_TYPE(service_adaptor_file_info_s_type),
+                       /* file_info default */
+                       __safe_add_string(_file_info->plugin_uri),
+                       __safe_add_string(_file_info->object_id),
+                       __safe_add_string(_file_info->storage_path),
+                       (uint64_t) _file_info->file_size,
+                       (uint64_t) _file_info->created_time,
+                       (uint64_t) _file_info->modified_time,
+                       (int32_t) _file_info->file_info_index,
+                       (int32_t) _file_info->content_type,
+
+                       /* media_meta */
+                       __safe_add_string(_file_info->media_meta->mime_type),
+                       __safe_add_string(_file_info->media_meta->title),
+                       __safe_add_string(_file_info->media_meta->album),
+                       __safe_add_string(_file_info->media_meta->artist),
+                       __safe_add_string(_file_info->media_meta->genere),
+                       __safe_add_string(_file_info->media_meta->recorded_date),
+                       (int32_t) _file_info->media_meta->width,
+                       (int32_t) _file_info->media_meta->height,
+                       (int32_t) _file_info->media_meta->duration,
+                       __safe_add_string(_file_info->media_meta->copyright),
+                       __safe_add_string(_file_info->media_meta->track_num),
+                       __safe_add_string(_file_info->media_meta->description),
+                       __safe_add_string(_file_info->media_meta->composer),
+                       __safe_add_string(_file_info->media_meta->year),
+                       (int32_t) _file_info->media_meta->bitrate,
+                       (int32_t) _file_info->media_meta->samplerate,
+                       (int32_t) _file_info->media_meta->channel,
+                       __safe_add_string(_file_info->media_meta->extra_media_meta),
+
+                       /* cloud_meta */
+                       __safe_add_string(_file_info->cloud_meta->service_name),
+                       (uint64_t) _file_info->cloud_meta->usage_byte,
+                       (uint64_t) _file_info->cloud_meta->quota_byte,
+                       __safe_add_string(_file_info->cloud_meta->extra_cloud_meta),
+
+                       __safe_add_string(_file_info->extra_file_info),
+
+                       (uint64_t) _error_code->code, __safe_add_string(_error_code->msg));
+
+       return return_val;
+}
+
+GVariant *__create_get_file_list_res_type(storage_adaptor_file_info_h *file_info_list,
+                                               unsigned int file_info_len,
+                                               storage_adaptor_error_code_h error_code)
+{
+       storage_adaptor_error_code_t _error;
+       _error.msg = NULL;
+
+       if (NULL == error_code) {
+               error_code = &_error;
+               error_code->code = STORAGE_ADAPTOR_ERROR_NONE;
+               error_code->msg = strdup("");
+       }
+
+       if (NULL == file_info_list) {
+               file_info_len = 0;
+       }
+
+       GVariantBuilder *builder_file_info = g_variant_builder_new(G_VARIANT_TYPE(storage_file_info_list_type));
+
+       storage_adaptor_file_info_h _file_info = NULL;
+       storage_adaptor_file_info_h dummy_file_info = storage_adaptor_create_file_info();
+
+       for (gsize i = 0; i < file_info_len; i++) {
+               _file_info = file_info_list[i];
+               if (NULL == _file_info) {
+                       _file_info = dummy_file_info;
+               }
+
+               if (NULL == _file_info->media_meta) {
+                       _file_info->media_meta = dummy_file_info->media_meta;
+               }
+
+               if (NULL == _file_info->cloud_meta) {
+                       _file_info->cloud_meta = dummy_file_info->cloud_meta;
+               }
+
+               g_variant_builder_open(builder_file_info, G_VARIANT_TYPE(service_adaptor_file_info_s_type));
+
+               /* file_info default */
+               g_variant_builder_add(builder_file_info, "s", __safe_add_string(_file_info->plugin_uri));
+               g_variant_builder_add(builder_file_info, "s", __safe_add_string(_file_info->object_id));
+               g_variant_builder_add(builder_file_info, "s", __safe_add_string(_file_info->storage_path));
+               g_variant_builder_add(builder_file_info, "t", (uint64_t) _file_info->file_size);
+               g_variant_builder_add(builder_file_info, "t", (uint64_t) _file_info->created_time);
+               g_variant_builder_add(builder_file_info, "t", (uint64_t) _file_info->modified_time);
+               g_variant_builder_add(builder_file_info, "i", (int32_t) _file_info->file_info_index);
+               g_variant_builder_add(builder_file_info, "i", (int32_t) _file_info->content_type);
+
+               /* media_meta */
+
+               g_variant_builder_add_value(builder_file_info, g_variant_new(service_adaptor_content_meta_s_type,
+                               __safe_add_string(_file_info->media_meta->mime_type),
+                               __safe_add_string(_file_info->media_meta->title),
+                               __safe_add_string(_file_info->media_meta->album),
+                               __safe_add_string(_file_info->media_meta->artist),
+                               __safe_add_string(_file_info->media_meta->genere),
+                               __safe_add_string(_file_info->media_meta->recorded_date),
+                               (int32_t) _file_info->media_meta->width,
+                               (int32_t) _file_info->media_meta->height,
+                               (int32_t) _file_info->media_meta->duration,
+                               __safe_add_string(_file_info->media_meta->copyright),
+                               __safe_add_string(_file_info->media_meta->track_num),
+                               __safe_add_string(_file_info->media_meta->description),
+                               __safe_add_string(_file_info->media_meta->composer),
+                               __safe_add_string(_file_info->media_meta->year),
+                               (int32_t) _file_info->media_meta->bitrate,
+                               (int32_t) _file_info->media_meta->samplerate,
+                               (int32_t) _file_info->media_meta->channel,
+                               __safe_add_string(_file_info->media_meta->extra_media_meta)));
+
+               /* cloud_meta */
+               g_variant_builder_add_value(builder_file_info, g_variant_new(service_adaptor_cloud_meta_s_type,
+                               __safe_add_string(_file_info->cloud_meta->service_name),
+                               (uint64_t) _file_info->cloud_meta->usage_byte,
+                               (uint64_t) _file_info->cloud_meta->quota_byte));
+
+               g_variant_builder_add(builder_file_info, "s", __safe_add_string(_file_info->extra_file_info));
+
+               g_variant_builder_close(builder_file_info);
+       }
+       storage_adaptor_destroy_file_info(&dummy_file_info);
+
+       GVariant *response = g_variant_new(MAKE_RETURN_TYPE(service_adaptor_get_file_list_res_s_type),
+                       builder_file_info, (uint32_t)file_info_len,
+                       (uint64_t) error_code->code, __safe_add_string(error_code->msg));
+
+       free(_error.msg);
+       return response;
+}
+
+void __separate_path_to_dir_base(char *full_path,
+                                               char **dir_path,
+                                               char **base_path)
+{
+       if ((NULL == full_path) || (0 >= strlen(full_path))) {
+               *base_path = strdup("");
+               *dir_path = strdup("");
+               return;
+       }
+
+       char *base = strrchr(full_path, '/');
+       if (NULL == base) {
+               *base_path = strdup(full_path);
+               *dir_path = strdup("");
+       } else if (0 == strcmp(full_path, base)) {
+               *base_path = strdup(full_path);
+               *dir_path = strdup("");
+       } else {
+               *base_path = strdup(base + 1);
+               if ((base - full_path) > 1) {
+                       *dir_path = strndup(full_path, (base - full_path));
+               } else {
+                       *dir_path = strdup("");
+               }
+       }
+}
+
+void storage_adaptor_method_call(GDBusConnection *connection,
+                                               const gchar *sender,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *method_name,
+                                               GVariant *parameters,
+                                               GDBusMethodInvocation *invocation,
+                                               gpointer user_data)
+{
+       service_adaptor_internal_error_code_e ret_code = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+
+       service_adaptor_debug("Received %s() call", method_name);
+
+       /* private feature */
+       if (0 == g_strcmp0(method_name, PRIVATE_DBUS_DOWNLOAD_FILE_METHOD)) {
+               char *service_name = NULL;
+               char *server_path = NULL;
+               char *download_path = NULL;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_file_transfer_req_type(parameters, &service_name, &server_path, &download_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       error_code = &_error;
+
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       free(_error.msg);
+
+                       free(service_name);
+                       free(server_path);
+                       free(download_path);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       char *parent_folder = NULL;
+                       char *file_name = NULL;
+                       __separate_path_to_dir_base(server_path, &parent_folder, &file_name);
+
+                       ret_code = storage_adaptor_download_file_sync(plugin, service->storage_context,
+                                       parent_folder, file_name, download_path, NULL, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_download_file_sync(plugin, service->storage_context,
+                                               parent_folder, file_name, download_path, NULL, &error_code, NULL);
+                       }
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                               service_adaptor_error("Can not run storage_adaptor_download_file_sync()");
+                       }
+                       free(parent_folder);
+                       free(file_name);
+               }
+
+               __check_error_code();
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+
+               free(service_name);
+               free(server_path);
+               free(download_path);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_DOWNLOAD_FILE_ASYNC_METHOD)) {
+               char *service_name = NULL;
+               char *server_path = NULL;
+               char *download_path = NULL;
+               int fd = 0;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_file_transfer_req_type(parameters, &service_name, &server_path, &download_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       GVariant *response = __private_create_file_transfer_res_type(fd, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       free(_error.msg);
+                       free(service_name);
+                       free(server_path);
+                       free(download_path);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       char *parent_folder = NULL;
+                       char *file_name = NULL;
+                       __separate_path_to_dir_base(server_path, &parent_folder, &file_name);
+
+                       ret_code = storage_adaptor_download_file_async(plugin, service->storage_context,
+                                       parent_folder, file_name, download_path, NULL, (void *) &fd, &error_code);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_download_file_async(plugin, service->storage_context,
+                                               parent_folder, file_name, download_path, NULL, (void *) &fd, &error_code);
+                       }
+
+                       free(parent_folder);
+                       free(file_name);
+               }
+
+               __check_error_code();
+
+               GVariant *response = __private_create_file_transfer_res_type(fd, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(server_path);
+               free(download_path);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_UPLOAD_FILE_METHOD)) {
+               char *service_name = NULL;
+               char *upload_path = NULL;
+               char *server_path = NULL;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_file_transfer_req_type(parameters, &service_name, &upload_path, &server_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       free(_error.msg);
+                       free(service_name);
+                       free(server_path);
+                       free(upload_path);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       storage_adaptor_file_info_h file_info = NULL;
+                       char *parent_folder = NULL;
+                       char *file_name = NULL;
+                       __separate_path_to_dir_base(server_path, &parent_folder, &file_name);
+
+                       ret_code = storage_adaptor_upload_file_sync(plugin, service->storage_context,
+                                       parent_folder, file_name, upload_path, false, NULL, &file_info, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_upload_file_sync(plugin, service->storage_context,
+                                               parent_folder, file_name, upload_path, false, NULL, &file_info, &error_code, NULL);
+                       }
+                       free(parent_folder);
+                       free(file_name);
+               }
+
+               __check_error_code();
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(server_path);
+               free(upload_path);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_UPLOAD_FILE_ASYNC_METHOD)) {
+               char *service_name = NULL;
+               char *server_path = NULL;
+               char *upload_path = NULL;
+               int fd = 0;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_file_transfer_req_type(parameters, &service_name, &upload_path, &server_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       GVariant *response = __private_create_file_transfer_res_type(fd, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       free(_error.msg);
+                       free(service_name);
+                       free(server_path);
+                       free(upload_path);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       char *parent_folder = NULL;
+                       char *file_name = NULL;
+                       __separate_path_to_dir_base(server_path, &parent_folder, &file_name);
+
+                       ret_code = storage_adaptor_upload_file_async(plugin, service->storage_context,
+                                       parent_folder, file_name, upload_path, false, NULL, (void *) &fd, &error_code);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_upload_file_async(plugin, service->storage_context,
+                                               parent_folder, file_name, upload_path, false, NULL, (void *) &fd, &error_code);
+                       }
+                       free(parent_folder);
+                       free(file_name);
+               }
+
+               __check_error_code();
+
+               GVariant *response = __private_create_file_transfer_res_type(fd, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(server_path);
+               free(upload_path);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_DOWNLOAD_FILE_PUBLISH_METHOD)) {
+               char *service_name = NULL;
+               char *server_path = NULL;
+               char *download_path = NULL;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_file_transfer_req_type(parameters, &service_name, &server_path, &download_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       free(_error.msg);
+                       free(service_name);
+                       free(server_path);
+                       free(download_path);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       char public_token[1024] = {0,};
+                       char auth_code[1024] = {0,};
+
+                       sscanf(server_path, "%[^'?']?auth_code=%s", public_token, auth_code);
+                       ret_code = storage_adaptor_download_file_sync_by_public_token(plugin, service->storage_context,
+                                       public_token, auth_code, download_path, NULL, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_download_file_sync_by_public_token(plugin, service->storage_context,
+                                               public_token, auth_code, download_path, NULL, &error_code, NULL);
+                       }
+               }
+
+               __check_error_code();
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(server_path);
+               free(download_path);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_DOWNLOAD_FILE_PUBLISH_ASYNC_METHOD)) {
+               char *service_name = NULL;
+               char *server_path = NULL;
+               char *download_path = NULL;
+               int fd = 0;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_file_transfer_req_type(parameters, &service_name, &server_path, &download_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       GVariant *response = __private_create_file_transfer_res_type(fd, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       free(_error.msg);
+                       free(service_name);
+                       free(server_path);
+                       free(download_path);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       char public_token[1024] = {0,};
+                       char auth_code[1024] = {0,};
+
+                       sscanf(server_path, "%[^'?']?auth_code=%s", public_token, auth_code);
+
+                       ret_code = storage_adaptor_download_file_async_by_public_token(plugin, service->storage_context,
+                                       public_token, auth_code, download_path, NULL, (void *) &fd, &error_code);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_download_file_async_by_public_token(plugin, service->storage_context,
+                                               public_token, auth_code, download_path, NULL, (void *) &fd, &error_code);
+                       }
+               }
+
+               __check_error_code();
+
+               GVariant *response = __private_create_file_transfer_res_type(fd, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(server_path);
+               free(download_path);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_UPLOAD_FILE_PUBLISH_METHOD)) {
+               char *service_name = NULL;
+               char *upload_path = NULL;
+               char *server_path = NULL;
+               storage_adaptor_file_info_h file_info = NULL;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_file_transfer_req_type(parameters, &service_name, &upload_path, &server_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       GVariant *response = __private_create_file_publish_transfer_res_type(file_info, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       free(_error.msg);
+                       free(service_name);
+                       free(server_path);
+                       free(upload_path);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       char *parent_folder = NULL;
+                       char *file_name = NULL;
+                       __separate_path_to_dir_base(server_path, &parent_folder, &file_name);
+
+                       ret_code = storage_adaptor_upload_file_sync(plugin, service->storage_context,
+                                       parent_folder, file_name, upload_path, true, NULL, &file_info, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               storage_adaptor_destroy_file_info(&file_info);
+                               ret_code = storage_adaptor_upload_file_sync(plugin, service->storage_context,
+                                               parent_folder, file_name, upload_path, true, NULL, &file_info, &error_code, NULL);
+                       }
+                       free(parent_folder);
+                       free(file_name);
+               }
+
+               __check_error_code();
+
+               GVariant *response = __private_create_file_publish_transfer_res_type(file_info, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+               storage_adaptor_destroy_file_info(&file_info);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(server_path);
+               free(upload_path);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_UPLOAD_FILE_PUBLISH_ASYNC_METHOD)) {
+               char *service_name = NULL;
+               char *server_path = NULL;
+               char *upload_path = NULL;
+               int fd = 0;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_file_transfer_req_type(parameters, &service_name, &upload_path, &server_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       GVariant *response = __private_create_file_transfer_res_type(fd, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       free(_error.msg);
+                       free(service_name);
+                       free(server_path);
+                       free(upload_path);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       char *parent_folder = NULL;
+                       char *file_name = NULL;
+                       __separate_path_to_dir_base(server_path, &parent_folder, &file_name);
+
+                       ret_code = storage_adaptor_upload_file_async(plugin, service->storage_context,
+                                       parent_folder, file_name, upload_path, true, NULL, (void *) &fd, &error_code);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_upload_file_async(plugin, service->storage_context,
+                                               parent_folder, file_name, upload_path, true, NULL, (void *) &fd, &error_code);
+                       }
+                       free(parent_folder);
+                       free(file_name);
+               }
+
+               __check_error_code();
+
+               GVariant *response = __private_create_file_transfer_res_type(fd, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(server_path);
+               free(upload_path);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_GET_FILE_STATUS_METHOD)) {
+               char *service_name = NULL;
+               int fd = 0;
+               uint64_t progress_size = 0;
+               uint64_t total_size = 0;
+               storage_adaptor_transfer_state_e state = STORAGE_ADAPTOR_TRANSFER_STATUS_FINISHED;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __private_get_file_status_req_type(parameters, &service_name, &fd);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       GVariant *response = __private_create_file_status_res_type((int64_t) progress_size, (int64_t) total_size, state, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       free(_error.msg);
+                       free(service_name);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       ret_code = storage_adaptor_get_transfer_state(plugin, service->storage_context,
+                                       (void *) fd, NULL, &state, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_get_transfer_state(plugin, service->storage_context,
+                                               (void *) fd, NULL, &state, &error_code, NULL);
+                       }
+                       ret_code = storage_adaptor_get_transfer_progress(plugin, service->storage_context,
+                                       (void *) fd, NULL, &progress_size, &total_size, &error_code, NULL);
+               }
+
+               __check_error_code();
+
+               GVariant *response = __private_create_file_status_res_type((int64_t) progress_size, (int64_t) total_size, state, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_CANCEL_FILE_TRANSFER_METHOD)) {
+               char *service_name = NULL;
+               int fd = 0;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __private_get_file_status_req_type(parameters, &service_name, &fd);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       free(_error.msg);
+                       free(service_name);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       storage_adaptor_transfer_state_e state = STORAGE_ADAPTOR_TRANSFER_STATUS_CANCEL;
+
+                       ret_code = storage_adaptor_set_transfer_state(plugin, service->storage_context,
+                                       (void *) fd, state, NULL, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_set_transfer_state(plugin, service->storage_context,
+                                               (void *) fd, state, NULL, &error_code, NULL);
+                       }
+               }
+
+               __check_error_code();
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_PAUSE_FILE_TRANSFER_METHOD)) {
+               char *service_name = NULL;
+               int fd = 0;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __private_get_file_status_req_type(parameters, &service_name, &fd);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       free(_error.msg);
+                       free(service_name);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       storage_adaptor_transfer_state_e state = STORAGE_ADAPTOR_TRANSFER_STATUS_PAUSE;
+                       ret_code = storage_adaptor_set_transfer_state(plugin, service->storage_context,
+                                       (void *) fd, state, NULL, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_set_transfer_state(plugin, service->storage_context,
+                                               (void *) fd, state, NULL, &error_code, NULL);
+                       }
+               }
+
+               __check_error_code();
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, PRIVATE_DBUS_RESUME_FILE_TRANSFER_METHOD)) {
+               char *service_name = NULL;
+               int fd = 0;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __private_get_file_status_req_type(parameters, &service_name, &fd);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       free(_error.msg);
+                       free(service_name);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       storage_adaptor_transfer_state_e state = STORAGE_ADAPTOR_TRANSFER_STATUS_RESUME;
+                       ret_code = storage_adaptor_set_transfer_state(plugin, service->storage_context,
+                                       (void *) fd, state, NULL, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_set_transfer_state(plugin, service->storage_context,
+                                               (void *) fd, state, NULL, &error_code, NULL);
+                       }
+               }
+
+               __check_error_code();
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, DBUS_DOWNLOAD_FILE_METHOD)) { /* public feature */
+               char *service_name = NULL;
+               char *server_path = NULL;
+               char *download_path = NULL;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_file_transfer_req_type(parameters, &service_name, &server_path, &download_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       free(_error.msg);
+                       free(service_name);
+                       free(server_path);
+                       free(download_path);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       char *parent_folder = NULL;
+                       char *file_name = NULL;
+                       __separate_path_to_dir_base(server_path, &parent_folder, &file_name);
+
+                       ret_code = storage_adaptor_download_file_sync(plugin, service->storage_context,
+                                       parent_folder, file_name, download_path, NULL, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_download_file_sync(plugin, service->storage_context,
+                                               parent_folder, file_name, download_path, NULL, &error_code, NULL);
+                       }
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                               service_adaptor_error("Can not run storage_adaptor_download_file_sync()");
+                       }
+                       free(parent_folder);
+                       free(file_name);
+               }
+
+               __check_error_code();
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(server_path);
+               free(download_path);
+       } else if (0 == g_strcmp0(method_name, DBUS_DOWNLOAD_THUMBNAIL_METHOD)) {
+               char *service_name = NULL;
+               char *server_path = NULL;
+               char *download_path = NULL;
+               int thumbnail_size;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_download_thumbnail_req_type(parameters, &service_name, &server_path, &download_path, &thumbnail_size);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       free(_error.msg);
+                       free(service_name);
+                       free(server_path);
+                       free(download_path);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       char *parent_folder = NULL;
+                       char *file_name = NULL;
+                       __separate_path_to_dir_base(server_path, &parent_folder, &file_name);
+
+                       ret_code = storage_adaptor_download_thumbnail(plugin, service->storage_context,
+                                       parent_folder, file_name, download_path, thumbnail_size, NULL, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_download_thumbnail(plugin, service->storage_context,
+                                               parent_folder, file_name, download_path, thumbnail_size, NULL, &error_code, NULL);
+                       }
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret_code) {
+                               service_adaptor_error("Can not run storage_adaptor_download_thumbnail()");
+                       }
+                       free(parent_folder);
+                       free(file_name);
+               }
+
+               __check_error_code();
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(server_path);
+               free(download_path);
+       } else if (0 == g_strcmp0(method_name, DBUS_UPLOAD_FILE_METHOD)) {
+               char *service_name = NULL;
+               char *upload_path = NULL;
+               char *server_path = NULL;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+               storage_adaptor_file_info_h file_info = NULL;
+
+               __get_file_transfer_req_type(parameters, &service_name, &upload_path, &server_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       GVariant *res_v = __create_file_info_res_type(file_info, error_code);
+                       g_dbus_method_invocation_return_value(invocation, res_v);
+
+                       free(_error.msg);
+                       free(service_name);
+                       free(server_path);
+                       free(upload_path);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       char *parent_folder = NULL;
+                       char *file_name = NULL;
+                       __separate_path_to_dir_base(server_path, &parent_folder, &file_name);
+
+                       ret_code = storage_adaptor_upload_file_sync(plugin, service->storage_context,
+                                       parent_folder, file_name, upload_path, false, NULL, &file_info, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+                               storage_adaptor_destroy_file_info(&file_info);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_upload_file_sync(plugin, service->storage_context,
+                                               parent_folder, file_name, upload_path, false, NULL, &file_info, &error_code, NULL);
+                       }
+                       free(parent_folder);
+                       free(file_name);
+               }
+
+               __check_error_code();
+
+               GVariant *res_v = __create_file_info_res_type(file_info, error_code);
+               g_dbus_method_invocation_return_value(invocation, res_v);
+
+               storage_adaptor_destroy_file_info(&file_info);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(server_path);
+               free(upload_path);
+       } else if (0 == g_strcmp0(method_name, DBUS_GET_ROOT_FOLDER_PATH_METHOD)) {
+               char *service_name = NULL;
+               char *root_folder_path = NULL;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_get_root_folder_path_req_type(parameters, &service_name);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       GVariant *response = __create_get_root_folder_path_res_type(root_folder_path, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       free(_error.msg);
+                       free(service_name);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       ret_code = storage_adaptor_get_root_folder_path(plugin, service->storage_context,
+                                       NULL, &root_folder_path, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_get_root_folder_path(plugin, service->storage_context,
+                                               NULL, &root_folder_path, &error_code, NULL);
+                       }
+               }
+
+               __check_error_code();
+
+               GVariant *response = __create_get_root_folder_path_res_type(root_folder_path, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(root_folder_path);
+       } else if (0 == g_strcmp0(method_name, DBUS_MAKE_DIRECTORY_METHOD)) {
+               char *service_name = NULL;
+               char *folder_path = NULL;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+               storage_adaptor_file_info_h file_info = NULL;
+
+               __get_make_directory_req_type(parameters, &service_name, &folder_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       GVariant *res_v = __create_file_info_res_type(file_info, error_code);
+                       g_dbus_method_invocation_return_value(invocation, res_v);
+
+                       free(_error.msg);
+                       free(service_name);
+                       free(folder_path);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       char *folder_path_dir = NULL;
+                       char *folder_path_base = NULL;
+
+                       __separate_path_to_dir_base(folder_path, &folder_path_dir, &folder_path_base);
+
+                       ret_code = storage_adaptor_make_directory(plugin, service->storage_context,
+                                       folder_path_dir, folder_path_base, NULL, &file_info, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+                               storage_adaptor_destroy_file_info(&file_info);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_make_directory(plugin, service->storage_context,
+                                               folder_path_dir, folder_path_base, NULL, &file_info, &error_code, NULL);
+                       }
+                       free(folder_path_dir);
+                       free(folder_path_base);
+               }
+
+               __check_error_code();
+
+               GVariant *res_v = __create_file_info_res_type(file_info, error_code);
+               g_dbus_method_invocation_return_value(invocation, res_v);
+
+               storage_adaptor_destroy_file_info(&file_info);
+
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(folder_path);
+       } else if (0 == g_strcmp0(method_name, DBUS_REMOVE_FILE_METHOD)) {
+               char *service_name = NULL;
+               char *file_path = NULL;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+               storage_adaptor_file_info_h file_info = NULL;
+
+               __get_remove_file_req_type(parameters, &service_name, &file_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       free(_error.msg);
+                       free(service_name);
+                       free(file_path);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       char *file_path_dir = NULL;
+                       char *file_path_base = NULL;
+
+                       __separate_path_to_dir_base(file_path, &file_path_dir, &file_path_base);
+                       ret_code = storage_adaptor_delete_file(plugin, service->storage_context,
+                                       file_path_dir, file_path_base, NULL,
+                                       &file_info, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+                               storage_adaptor_destroy_file_info(&file_info);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_delete_file(plugin, service->storage_context,
+                                               file_path_dir, file_path_base, NULL,
+                                               &file_info, &error_code, NULL);
+                       }
+                       free(file_path_dir);
+                       free(file_path_base);
+               }
+
+               __check_error_code();
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(file_path);
+               storage_adaptor_destroy_file_info(&file_info);
+       } else if (0 == g_strcmp0(method_name, DBUS_REMOVE_DIRECTORY_METHOD)) {
+               char *service_name = NULL;
+               char *folder_path = NULL;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+               storage_adaptor_file_info_h file_info = NULL;
+
+               __get_remove_directory_req_type(parameters, &service_name, &folder_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                                       (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       free(_error.msg);
+                       free(service_name);
+                       free(folder_path);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       char *folder_path_dir = NULL;
+                       char *folder_path_base = NULL;
+
+                       __separate_path_to_dir_base(folder_path, &folder_path_dir, &folder_path_base);
+                       ret_code = storage_adaptor_remove_directory(plugin, service->storage_context,
+                                       folder_path_dir, folder_path_base, NULL,
+                                       &file_info, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+                               storage_adaptor_destroy_file_info(&file_info);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_remove_directory(plugin, service->storage_context,
+                                               folder_path_dir, folder_path_base, NULL,
+                                               &file_info, &error_code, NULL);
+                       }
+                       free(folder_path_dir);
+                       free(folder_path_base);
+               }
+
+               __check_error_code();
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)",
+                               (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(folder_path);
+
+               storage_adaptor_destroy_file_info(&file_info);
+       } else if (0 == g_strcmp0(method_name, DBUS_MOVE_FILE_METHOD)) {
+               char *service_name = NULL;
+               char *src_file_path = NULL;
+               char *dst_file_path = NULL;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+               storage_adaptor_file_info_h file_info = NULL;
+
+               __get_move_file_req_type(parameters, &service_name, &src_file_path, &dst_file_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       GVariant *res_v = __create_file_info_res_type(file_info, error_code);
+                       g_dbus_method_invocation_return_value(invocation, res_v);
+
+                       free(_error.msg);
+                       free(service_name);
+                       free(src_file_path);
+                       free(dst_file_path);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       char *src_file_path_dir = NULL;
+                       char *src_file_path_base = NULL;
+                       char *dst_file_path_dir = NULL;
+                       char *dst_file_path_base = NULL;
+
+                       __separate_path_to_dir_base(src_file_path, &src_file_path_dir, &src_file_path_base);
+                       __separate_path_to_dir_base(dst_file_path, &dst_file_path_dir, &dst_file_path_base);
+                       ret_code = storage_adaptor_move_file(plugin, service->storage_context,
+                                       src_file_path_dir, src_file_path_base,
+                                       dst_file_path_dir, dst_file_path_base, NULL,
+                                       &file_info, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+                               storage_adaptor_destroy_file_info(&file_info);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_move_file(plugin, service->storage_context,
+                                               src_file_path_dir, src_file_path_base,
+                                               dst_file_path_dir, dst_file_path_base, NULL,
+                                               &file_info, &error_code, NULL);
+                       }
+                       free(src_file_path_dir);
+                       free(src_file_path_base);
+                       free(dst_file_path_dir);
+                       free(dst_file_path_base);
+               }
+
+               __check_error_code();
+
+               GVariant *res_v = __create_file_info_res_type(file_info, error_code);
+               g_dbus_method_invocation_return_value(invocation, res_v);
+
+               storage_adaptor_destroy_file_info(&file_info);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(src_file_path);
+               free(dst_file_path);
+       } else if (0 == g_strcmp0(method_name, DBUS_MOVE_DIRECTORY_METHOD)) {
+               char *service_name = NULL;
+               char *src_folder_path = NULL;
+               char *dst_folder_path = NULL;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+               storage_adaptor_file_info_h file_info = NULL;
+
+               __get_move_directory_req_type(parameters, &service_name, &src_folder_path, &dst_folder_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       GVariant *res_v = __create_file_info_res_type(file_info, error_code);
+                       g_dbus_method_invocation_return_value(invocation, res_v);
+
+                       free(_error.msg);
+                       free(service_name);
+                       free(src_folder_path);
+                       free(dst_folder_path);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       char *src_folder_path_dir = NULL;
+                       char *src_folder_path_base = NULL;
+                       char *dst_folder_path_dir = NULL;
+                       char *dst_folder_path_base = NULL;
+
+                       __separate_path_to_dir_base(src_folder_path, &src_folder_path_dir, &src_folder_path_base);
+                       __separate_path_to_dir_base(dst_folder_path, &dst_folder_path_dir, &dst_folder_path_base);
+                       ret_code = storage_adaptor_move_directory(plugin, service->storage_context,
+                                       src_folder_path_dir, src_folder_path_base,
+                                       dst_folder_path_dir, dst_folder_path_base, NULL,
+                                       &file_info, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+                               storage_adaptor_destroy_file_info(&file_info);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_move_directory(plugin, service->storage_context,
+                                               src_folder_path_dir, src_folder_path_base,
+                                               dst_folder_path_dir, dst_folder_path_base, NULL,
+                                               &file_info, &error_code, NULL);
+                       }
+                       free(src_folder_path_dir);
+                       free(src_folder_path_base);
+                       free(dst_folder_path_dir);
+                       free(dst_folder_path_base);
+               }
+
+               __check_error_code();
+
+               GVariant *res_v = __create_file_info_res_type(file_info, error_code);
+               g_dbus_method_invocation_return_value(invocation, res_v);
+
+               storage_adaptor_destroy_file_info(&file_info);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(src_folder_path);
+               free(dst_folder_path);
+       } else if (0 == g_strcmp0(method_name, DBUS_GET_FILE_LIST_METHOD)) {
+               char *service_name = NULL;
+               char *parent_path = NULL;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+               storage_adaptor_file_info_h *file_info_list = NULL;
+               int file_info_list_len = 0;
+
+               __get_get_file_list_req_type(parameters, &service_name, &parent_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       GVariant *response = __create_get_file_list_res_type(file_info_list, (unsigned int)file_info_list_len, error_code);
+                       g_dbus_method_invocation_return_value(invocation, response);
+
+                       free(_error.msg);
+                       free(service_name);
+                       free(parent_path);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       char *parent_path_dir = NULL;
+                       char *parent_path_base = NULL;
+
+                       __separate_path_to_dir_base(parent_path, &parent_path_dir, &parent_path_base);
+                       ret_code = storage_adaptor_list(plugin, service->storage_context,
+                                       parent_path_dir, parent_path_base, NULL,
+                                       &file_info_list, &file_info_list_len, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+                               if ((0 < file_info_list_len) && (NULL != file_info_list)) {
+                                       int i;
+                                       for (i = 0; i < file_info_list_len; i++) {
+                                               storage_adaptor_destroy_file_info(&file_info_list[i]);
+                                       }
+                                       free(file_info_list);
+                                       file_info_list = NULL;
+                                       file_info_list_len = 0;
+                               }
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_list(plugin, service->storage_context,
+                                               parent_path_dir, parent_path_base, NULL,
+                                               &file_info_list, &file_info_list_len, &error_code, NULL);
+                       }
+                       free(parent_path_dir);
+                       free(parent_path_base);
+               }
+
+               __check_error_code();
+
+               GVariant *response = __create_get_file_list_res_type(file_info_list, (unsigned int)file_info_list_len, error_code);
+               g_dbus_method_invocation_return_value(invocation, response);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(parent_path);
+               if ((0 < file_info_list_len) && (NULL != file_info_list)) {
+                       int i;
+                       for (i = 0; i < file_info_list_len; i++) {
+                               storage_adaptor_destroy_file_info(&file_info_list[i]);
+                       }
+                       free(file_info_list);
+                       file_info_list = NULL;
+                       file_info_list_len = 0;
+               }
+       } else if (0 == g_strcmp0(method_name, DBUS_OPEN_UPLOAD_FILE_METHOD)) {
+               char *service_name = NULL;
+               char *local_path = NULL;
+               char *upload_path = NULL;
+               long long int file_uid = 0;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_open_upload_file_req_type(parameters, &service_name, &local_path, &upload_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       GVariant *res_v = __create_file_descriptor_res_type(file_uid, error_code);
+                       g_dbus_method_invocation_return_value(invocation, res_v);
+
+                       free(service_name);
+                       free(local_path);
+                       free(upload_path);
+
+                       free(_error.msg);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       /*ret_code = client_checker_check_access_right_read(service_name, local_path);
+                       service_adaptor_debug("Permission check : %d", ret_code);
+
+                       if (!ret_code) {*/
+                       ret_code = storage_adaptor_open_file(plugin, service->storage_context,
+                                       local_path, STORAGE_ADAPTOR_FILE_ACCESS_READ,
+                                       &file_uid, &error_code);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_open_file(plugin, service->storage_context,
+                                               local_path, STORAGE_ADAPTOR_FILE_ACCESS_READ,
+                                               &file_uid, &error_code);
+                       }
+/*                     } else {
+                               error_code = storage_adaptor_create_error_code(SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_COMMON_PERMISSION_DENIED,
+                                               clieht_checker_get_last_error());
+                       }*/
+               }
+
+               __check_error_code();
+
+               GVariant *res_v = __create_file_descriptor_res_type(file_uid, error_code);
+               g_dbus_method_invocation_return_value(invocation, res_v);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(local_path);
+               free(upload_path);
+       } else if (0 == g_strcmp0(method_name, DBUS_OPEN_DOWNLOAD_FILE_METHOD)) {
+               char *service_name = NULL;
+               char *storage_path = NULL;
+               char *local_path = NULL;
+               long long int file_uid = 0;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_open_download_file_req_type(parameters, &service_name, &storage_path, &local_path);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                       service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       GVariant *res_v = __create_file_descriptor_res_type(file_uid, error_code);
+                       g_dbus_method_invocation_return_value(invocation, res_v);
+
+                       free(service_name);
+                       free(storage_path);
+                       free(local_path);
+
+                       free(_error.msg);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       /*ret_code = client_checker_check_access_right_create(service_name, local_path);
+                       service_adaptor_debug("Permission check : %d", ret_code);
+
+                       if (!ret_code) {*/
+                       ret_code = storage_adaptor_open_file(plugin, service->storage_context,
+                                       local_path, STORAGE_ADAPTOR_FILE_ACCESS_WRITE,
+                                       &file_uid, &error_code);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_open_file(plugin, service->storage_context,
+                                               local_path, STORAGE_ADAPTOR_FILE_ACCESS_WRITE,
+                                               &file_uid, &error_code);
+                       }
+/*                     } else {
+                               error_code = storage_adaptor_create_error_code(SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_COMMON_PERMISSION_DENIED,
+                                               clieht_checker_get_last_error());
+                       }*/
+               }
+
+               __check_error_code();
+
+               GVariant *res_v = __create_file_descriptor_res_type(file_uid, error_code);
+               g_dbus_method_invocation_return_value(invocation, res_v);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(storage_path);
+               free(local_path);
+       } else if (0 == g_strcmp0(method_name, DBUS_OPEN_DOWNLOAD_THUMBNAIL_METHOD)) {
+               char *service_name = NULL;
+               char *storage_path = NULL;
+               char *local_path = NULL;
+               int thumbnail_size = 0;
+               long long int file_uid = 0;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_open_download_thumbnail_req_type(parameters, &service_name, &storage_path, &local_path, &thumbnail_size);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       GVariant *res_v = __create_file_descriptor_res_type(file_uid, error_code);
+                       g_dbus_method_invocation_return_value(invocation, res_v);
+
+                       free(service_name);
+                       free(storage_path);
+                       free(local_path);
+
+                       free(_error.msg);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       /*ret_code = client_checker_check_access_right_create(service_name, local_path);
+                       service_adaptor_debug("Permission check : %d", ret_code);
+
+                       if (!ret_code) {*/
+                       ret_code = storage_adaptor_open_file(plugin, service->storage_context,
+                                       local_path, STORAGE_ADAPTOR_FILE_ACCESS_WRITE,
+                                       &file_uid, &error_code);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_open_file(plugin, service->storage_context,
+                                               local_path, STORAGE_ADAPTOR_FILE_ACCESS_WRITE,
+                                               &file_uid, &error_code);
+                       }
+/*                     } else {
+                               error_code = storage_adaptor_create_error_code(SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_COMMON_PERMISSION_DENIED,
+                                               clieht_checker_get_last_error());
+                       }*/
+               }
+
+               __check_error_code();
+
+               GVariant *res_v = __create_file_descriptor_res_type(file_uid, error_code);
+               g_dbus_method_invocation_return_value(invocation, res_v);
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(storage_path);
+               free(local_path);
+       } else if (0 == g_strcmp0(method_name, DBUS_CLOSE_FILE_METHOD)) {
+               char *service_name = NULL;
+               long long int file_uid = 0;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_close_file_req_type(parameters, &service_name, &file_uid);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+
+                       free(_error.msg);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       ret_code = storage_adaptor_close_file(plugin, service->storage_context,
+                                       file_uid, &error_code);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_close_file(plugin, service->storage_context,
+                                               file_uid, &error_code);
+                       }
+               }
+
+               __check_error_code();
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+       } else if (0 == g_strcmp0(method_name, DBUS_START_UPLOAD_FILE_METHOD)) {
+               char *service_name = NULL;
+               long long int file_uid = 0;
+               char *storage_path = NULL;
+               bool need_progress = false;
+               bool need_state = false;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_start_upload_file_req_type(parameters, &service_name, &file_uid, &storage_path, &need_progress, &need_state);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       free(storage_path);
+
+                       free(_error.msg);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               char *storage_path_dir = NULL;
+               char *storage_path_base = NULL;
+               __separate_path_to_dir_base(storage_path, &storage_path_dir, &storage_path_base);
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       ret_code = storage_adaptor_start_upload_task(plugin, service->storage_context,
+                                       file_uid, storage_path_dir, storage_path_base, need_progress, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_start_upload_task(plugin, service->storage_context,
+                                               file_uid, storage_path_dir, storage_path_base, need_progress, &error_code, NULL);
+                       }
+               }
+               free(storage_path_dir);
+               free(storage_path_base);
+
+               __check_error_code();
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(storage_path);
+       } else if (0 == g_strcmp0(method_name, DBUS_START_DOWNLOAD_FILE_METHOD)) {
+               char *service_name = NULL;
+               long long int file_uid = 0;
+               char *storage_path = NULL;
+               bool need_progress = false;
+               bool need_state = false;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_start_download_file_req_type(parameters, &service_name, &file_uid, &storage_path, &need_progress, &need_state);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       free(storage_path);
+
+                       free(_error.msg);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               char *storage_path_dir = NULL;
+               char *storage_path_base = NULL;
+               __separate_path_to_dir_base(storage_path, &storage_path_dir, &storage_path_base);
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       ret_code = storage_adaptor_start_download_task(plugin, service->storage_context,
+                                       storage_path_dir, storage_path_base, file_uid, need_progress, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_start_download_task(plugin, service->storage_context,
+                                               storage_path_dir, storage_path_base, file_uid, need_progress, &error_code, NULL);
+                       }
+               }
+               free(storage_path_dir);
+               free(storage_path_base);
+
+               __check_error_code();
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(storage_path);
+       } else if (0 == g_strcmp0(method_name, DBUS_START_DOWNLOAD_THUMBNAIL_METHOD)) {
+               char *service_name = NULL;
+               long long int file_uid = 0;
+               char *storage_path = NULL;
+               int thumbnail_size = 0;
+               bool need_progress = false;
+               bool need_state = false;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_start_download_thumbnail_req_type(parameters, &service_name, &file_uid,
+                               &storage_path, &thumbnail_size, &need_progress, &need_state);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+                       free(storage_path);
+
+                       free(_error.msg);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               char *storage_path_dir = NULL;
+               char *storage_path_base = NULL;
+               __separate_path_to_dir_base(storage_path, &storage_path_dir, &storage_path_base);
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       ret_code = storage_adaptor_start_download_thumb_task(plugin, service->storage_context,
+                                       storage_path_dir, storage_path_base, file_uid, thumbnail_size, need_progress, &error_code, NULL);
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               ret_code = storage_adaptor_start_download_thumb_task(plugin, service->storage_context,
+                                               storage_path_dir, storage_path_base, file_uid, thumbnail_size, need_progress, &error_code, NULL);
+                       }
+               }
+               free(storage_path_dir);
+               free(storage_path_base);
+
+               __check_error_code();
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+               free(service_name);
+               free(storage_path);
+       } else if ((0 == g_strcmp0(method_name, DBUS_CANCEL_UPLOAD_FILE_METHOD))
+                       || (0 == g_strcmp0(method_name, DBUS_CANCEL_DOWNLOAD_FILE_METHOD))
+                       || (0 == g_strcmp0(method_name, DBUS_CANCEL_DOWNLOAD_THUMBNAIL_METHOD))) {
+               char *service_name = NULL;
+               long long int file_uid = 0;
+               storage_adaptor_error_code_h error_code = NULL;
+               storage_adaptor_error_code_t _error;
+               _error.msg = NULL;
+
+               __get_cancel_file_task_req_type(parameters, &service_name, &file_uid);
+
+               service_adaptor_debug("(%s)", service_name);
+
+               service_adaptor_h service_adaptor = service_adaptor_get_handle();
+               service_adaptor_service_context_h service =
+                               service_adaptor_get_service_context(service_adaptor, service_name);
+
+               if (NULL == service) {
+                       service_adaptor_error("Can not get service context: %s", service_name);
+                       error_code = &_error;
+                       error_code->code = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
+                       error_code->msg = strdup("Can not get service context");
+
+                       g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+                       free(service_name);
+
+                       free(_error.msg);
+                       return;
+               }
+
+               storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+               storage_adaptor_plugin_h plugin = NULL;
+
+               if (NULL != service->storage_context) {
+                       plugin = storage_adaptor_get_plugin_by_name(adaptor, service->storage_context->plugin_uri);
+               }
+
+               if ((NULL != adaptor) && (NULL != plugin)) {
+                       if (0 == g_strcmp0(method_name, DBUS_CANCEL_UPLOAD_FILE_METHOD)) {
+                               ret_code = storage_adaptor_cancel_upload_task(plugin, service->storage_context,
+                                               file_uid, &error_code);
+                       } else if (0 == g_strcmp0(method_name, DBUS_CANCEL_DOWNLOAD_FILE_METHOD)) {
+                               ret_code = storage_adaptor_cancel_download_task(plugin, service->storage_context,
+                                               file_uid, &error_code);
+                       } else {
+                               ret_code = storage_adaptor_cancel_download_thumb_task(plugin, service->storage_context,
+                                               file_uid, &error_code);
+                       }
+
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED == ret_code) {
+                               service_adaptor_info("API returns auth-error. Try refresh auth");
+                               service_adaptor_auth_refresh(service_adaptor, service_name, service->storage_context->plugin_uri);
+
+                               service_adaptor_debug("Empty error_code already issued (%lld: %s)", error_code ? error_code->code : 0ULL, error_code ? error_code->msg : NULL);
+                               storage_adaptor_destroy_error_code(&error_code);
+
+                               service_adaptor_debug("Re-try API");
+                               if (0 == g_strcmp0(method_name, DBUS_CANCEL_UPLOAD_FILE_METHOD)) {
+                                       ret_code = storage_adaptor_cancel_upload_task(plugin, service->storage_context,
+                                                       file_uid, &error_code);
+                               } else if (0 == g_strcmp0(method_name, DBUS_CANCEL_DOWNLOAD_FILE_METHOD)) {
+                                       ret_code = storage_adaptor_cancel_download_task(plugin, service->storage_context,
+                                                       file_uid, &error_code);
+                               } else {
+                                       ret_code = storage_adaptor_cancel_download_thumb_task(plugin, service->storage_context,
+                                                       file_uid, &error_code);
+                               }
+                       }
+               }
+
+               __check_error_code();
+
+               g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) error_code->code, __safe_add_string(error_code->msg)));
+
+               if (error_code != &_error) {
+                       free(error_code->msg);
+                       free(error_code);
+                       error_code = NULL;
+               } else {
+                       free(_error.msg);
+               }
+
+               free(service_name);
+       }
+
+}
+
+
+/* private feature */
+service_adaptor_internal_error_code_e private_dbus_storage_file_progress_callback(int32_t fd,
+                                               uint64_t progress_size,
+                                               uint64_t total_size,
+                                               storage_adaptor_error_code_h error_code,
+                                               void *server_data)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+               GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_file_progress_s_type),
+                               fd, progress_size, total_size, (uint64_t) error_code->code, __safe_add_string(error_code->msg));
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_STORAGE_FILE_PROGRESS_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e private_dbus_storage_file_transfer_completion_callback(int32_t fd,
+                                               char *publish_url,
+                                               storage_adaptor_error_code_h error_code,
+                                               void *server_data)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+               GVariant *response = g_variant_new(MAKE_RETURN_TYPE(private_service_adaptor_file_transfer_completion_s_type),
+                               fd, __safe_add_string(publish_url), (uint64_t) error_code->code, __safe_add_string(error_code->msg));
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               PRIVATE_DBUS_STORAGE_FILE_TRANSFER_COMPLETION_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+
+/* public feature */
+service_adaptor_internal_error_code_e dbus_storage_file_progress_callback(long long int file_uid,
+                                               unsigned long long progress_size,
+                                               unsigned long long total_size)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       if (NULL != dbus_connection) {
+               GVariant *response = g_variant_new("("service_adaptor_file_progress_s_type")",
+                               (int64_t) file_uid, (uint64_t) progress_size, (uint64_t) total_size);
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               DBUS_STORAGE_FILE_PROGRESS_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e dbus_storage_file_transfer_state_changed_callback(long long int file_uid,
+                                               storage_adaptor_transfer_state_e state,
+                                               storage_adaptor_error_code_h _error_code)
+{
+       GError* error = NULL;
+       GDBusConnection *dbus_connection = dbus_get_connection();
+
+       int _state = 0;
+
+       switch (state) {
+       case STORAGE_ADAPTOR_TRANSFER_STATE_IN_PROGRESS:
+               _state = SERVICE_ADAPTOR_FILE_TRANSFER_STATE_IN_PROGRESS;
+               break;
+       case STORAGE_ADAPTOR_TRANSFER_STATE_FINISHED:
+               _state = SERVICE_ADAPTOR_FILE_TRANSFER_STATE_COMPLETED;
+               break;
+       case STORAGE_ADAPTOR_TRANSFER_STATE_CANCELED:
+               _state = SERVICE_ADAPTOR_FILE_TRANSFER_STATE_CANCELED;
+               break;
+       case STORAGE_ADAPTOR_TRANSFER_STATE_FAILED:
+               _state = SERVICE_ADAPTOR_FILE_TRANSFER_STATE_FAILED;
+               break;
+       default:
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_UNSUPPORTED;
+       }
+
+       if (NULL != dbus_connection) {
+               GVariant *response = g_variant_new(MAKE_RETURN_TYPE(service_adaptor_file_transfer_state_changed_s_type),
+                               (int64_t) file_uid, (int32_t) _state, (uint64_t) _error_code->code, __safe_add_string(_error_code->msg));
+
+               g_dbus_connection_emit_signal(dbus_connection,
+                               NULL,
+                               SERVICE_ADAPTOR_OBJECT_PATH,
+                               SERVICE_ADAPTOR_INTERFACE,
+                               DBUS_STORAGE_FILE_TRANSFER_STATE_CHANGED_SIGNAL,
+                               response,
+                               &error);
+
+               if (NULL != error) {
+                       service_adaptor_debug("Unable to send msg: %s", error->message);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+               }
+       }
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
diff --git a/src/dbus/dbus-util.c b/src/dbus/dbus-util.c
new file mode 100644 (file)
index 0000000..91c9614
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+* 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 <string.h>
+#include <stdlib.h>
+#include <dbus-util.h>
+
+/**
+ * Free string memory
+ * @param data Data to be fried
+ */
+void free_string(gpointer data)
+{
+       g_free((gchar *) data);
+}
+
+/**
+ * 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;
+}
diff --git a/src/service-adaptor-auth.c b/src/service-adaptor-auth.c
new file mode 100644 (file)
index 0000000..2610fb5
--- /dev/null
@@ -0,0 +1,222 @@
+/*
+* 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 "service-adaptor.h"
+#include "service-adaptor-auth.h"
+#include "service-adaptor-type.h"
+#include "service-adaptor-log.h"
+#include "dbus-ipc.h"
+#include "dbus-server.h"
+#include "dbus-service-adaptor.h"
+#include "dbus-auth-adaptor.h"
+#include "auth-adaptor.h"
+
+#define AUTH_PLUGIN_PATH       "/usr/lib/auth-adaptor/plugins"
+#define MAX_RETRY              2
+
+auth_adaptor_h service_adaptor_get_auth_adaptor(service_adaptor_h service_adaptor)
+{
+       service_adaptor_debug("Get auth adaptor");
+
+       if ((void *) NULL == service_adaptor) {
+               service_adaptor_error("Invalid argument");
+               return NULL;
+       }
+
+       return service_adaptor->auth_handle;
+}
+
+auth_adaptor_plugin_context_h service_adaptor_get_auth_context(service_adaptor_h service_adaptor,
+                                               const char* imsi,
+                                               const char *app_id)
+{
+       service_adaptor_debug("Get auth context");
+
+       service_adaptor_warning("Could not get auth context with IMSI(%s) and AppID(%s)", imsi, app_id);
+
+       return NULL;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_connect_auth_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_context_info_s *context_info,
+                                               const char *service_name,
+                                               const char *plugin_uri,
+                                               const char *user_password,
+                                               const char *app_secret,
+                                               service_adaptor_service_context_h *service,
+                                               char *ret_msg)
+{
+       service_adaptor_info("Connect to auth plugin (%s)", service_name);
+
+       int ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+
+       if ((NULL == service_adaptor) || (NULL == context_info) || (NULL == plugin_uri) || (NULL == service)) {
+               service_adaptor_error("Invalid parameter");
+               snprintf(ret_msg, 2048, "auth plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       auth_adaptor_h adaptor = service_adaptor_get_auth_adaptor(service_adaptor);
+
+       if (NULL == adaptor) {
+               service_adaptor_error("Could not get auth adaptor");
+               snprintf(ret_msg, 2048, "auth plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       auth_adaptor_plugin_h plugin = auth_adaptor_get_plugin_by_name(adaptor, plugin_uri);
+
+       if (NULL == plugin) {
+               service_adaptor_error("Could not get auth plugin handle by plugin name (%s)", plugin_uri);
+               snprintf(ret_msg, 2048, "auth plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       auth_adaptor_plugin_context_h auth_context = auth_adaptor_create_plugin_context(plugin,
+                       context_info->user_id, user_password, context_info->app_id, app_secret,
+                       context_info->imsi, service_name);
+
+       if (NULL == auth_context) {
+               service_adaptor_error("Could not create auth plugin context (service = %s)(server = %s)", service_name, plugin_uri);
+               snprintf(ret_msg, 2048, "auth plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_CREATE;
+       }
+
+       int is_auth = 1;
+       /*int retry = 0;*/
+       auth_adaptor_error_code_h error_code = NULL;
+
+       /* 1) Login to auth plugin */
+       service_adaptor_debug("Try to login to auth plugin (%s)", context_info->app_id);
+
+       SERVICE_ADAPTOR_API_TIME_CHECK_PAUSE();
+       SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_START(SA_TIME_CHECK_FLAG_AUTH);
+       ret = auth_adaptor_login(plugin, auth_context, is_auth, (void *)context_info->property, &error_code, NULL);
+       SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_PAUSE(SA_TIME_CHECK_FLAG_AUTH);
+       SERVICE_ADAPTOR_API_TIME_CHECK_START();
+
+       service_adaptor_info("LOGIN: %d", ret);
+       if (AUTH_ADAPTOR_ERROR_NONE == ret) {
+               service_adaptor_debug_func("============= Login Successed ===============");
+               service_adaptor_debug_func("============= Auth context : %p ==========", auth_context);
+               if (NULL != auth_context) {
+                       service_adaptor_debug_secure("============= Access token : %s ==========", auth_context->access_token);
+                       service_adaptor_debug_secure("============= Unique id : %s ==========", auth_context->uid);
+               }
+       } else {
+               service_adaptor_debug_func("============= Login Failed ===============");
+               auth_adaptor_destroy_plugin_context(plugin, auth_context);
+               auth_context = NULL;
+               if (NULL != error_code) {
+                       ret = (int)error_code->code;
+                       if (NULL != error_code->msg) {
+                               service_adaptor_error("[%lld] %s", error_code->code, error_code->msg);
+                               snprintf(ret_msg, 2048, "auth plugin login failed [%lld][%s]", (long long int)error_code->code, error_code->msg);
+                       } else {
+                               service_adaptor_error("Unexpected error occurred (error code is empty)");
+                               snprintf(ret_msg, 2048, "auth plugin connect failed [%d]", (int)__LINE__);
+                       }
+                       auth_adaptor_destroy_error_code(&error_code);
+               } else {
+                       ret = SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_AUTH_NOT_AUTHORIZED;
+               }
+               return ret;
+       }
+       auth_adaptor_destroy_error_code(&error_code);
+
+       /* Get server info */
+       GHashTable *server_info = NULL;
+       ret = auth_adaptor_get_server_info(plugin, auth_context, NULL, &server_info, &error_code, NULL);
+       if (ret) {
+               service_adaptor_warning("Could not get server info from auth plugin: %d", ret);
+               if (NULL != error_code) {
+                       service_adaptor_warning("[%lld] %s", error_code->code, error_code->msg);
+               }
+               auth_adaptor_destroy_error_code(&error_code);
+       }
+
+       (*service)->context_info->duid = auth_adaptor_get_uid_dup(auth_context);
+       (*service)->context_info->msisdn = auth_adaptor_get_msisdn_dup(auth_context);
+       (*service)->context_info->access_token = auth_adaptor_get_access_token_dup(auth_context);
+
+       (*service)->auth_context = auth_context;
+       (*service)->connected |= 0x0000001;
+       (*service)->server_info = server_info;
+
+       service_adaptor_debug("Connected to auth plugin");
+
+       return ret;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_disconnect_auth_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service)
+{
+       service_adaptor_debug("Disconnect from auth plugin");
+
+       service_adaptor_debug("get auth adaptor");
+       auth_adaptor_h auth_adaptor = service_adaptor_get_auth_adaptor(service_adaptor);
+       if ((NULL != service->auth_context) && (NULL != auth_adaptor)) {
+               service_adaptor_debug("disconnects auth");
+               FUNC_STEP();
+               auth_adaptor_plugin_h auth_plugin = auth_adaptor_get_plugin_by_name(auth_adaptor, service->auth_context->plugin_uri);
+
+               if (NULL == auth_plugin) {
+                       service_adaptor_error("Cannot find plugin");
+               } else {
+                       service_adaptor_debug("dsetroys auth context");
+                       auth_adaptor_destroy_plugin_context(auth_plugin, service->auth_context);
+                       service->auth_context = NULL;
+               }
+       }
+
+       service_adaptor_debug("Disconnected from auth plugin");
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+auth_adaptor_h service_adaptor_create_auth()
+{
+       auth_adaptor_h auth_adaptor = auth_adaptor_create(AUTH_PLUGIN_PATH);
+
+       if ((void *) NULL == auth_adaptor) {
+               service_adaptor_error("Could not create auth adaptor");
+               return NULL;
+       }
+
+       service_adaptor_debug("Auth adaptor created");
+
+       return auth_adaptor;
+}
+
+auth_adaptor_listener_h service_adaptor_register_auth_listener(auth_adaptor_h auth_adaptor)
+{
+       if ((void *) NULL == auth_adaptor) {
+               service_adaptor_error("Could not create auth adaptor");
+               return NULL;
+       }
+
+       auth_adaptor_listener_h auth_listener =
+                       (auth_adaptor_listener_h) malloc(sizeof(auth_adaptor_listener_t));
+
+       if ((void *) NULL == auth_listener) {
+               service_adaptor_error("Could not create auth listener");
+               return NULL;
+       }
+
+       service_adaptor_debug("Auth adaptor listener created");
+
+       return auth_listener;
+}
diff --git a/src/service-adaptor-contact.c b/src/service-adaptor-contact.c
new file mode 100644 (file)
index 0000000..ea485f8
--- /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.
+*/
+
+#include "service-adaptor.h"
+#include "service-adaptor-auth.h"
+#include "service-adaptor-type.h"
+#include "service-adaptor-log.h"
+#include "dbus-ipc.h"
+#include "dbus-server.h"
+#include "dbus-service-adaptor.h"
+#include "dbus-contact-adaptor.h"
+#include "contact-adaptor.h"
+
+#define CONTACT_PLUGIN_PATH    "/usr/lib/contact-adaptor/plugins"
+
+contact_adaptor_h service_adaptor_get_contact_adaptor(service_adaptor_h service_adaptor)
+{
+       service_adaptor_debug("Get contact adaptor");
+
+       if ((void *) NULL == service_adaptor) {
+               service_adaptor_error("Invalid argument");
+               return NULL;
+       }
+
+       return service_adaptor->contact_handle;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_connect_contact_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service,
+                                               char *ret_msg)
+{
+       service_adaptor_debug("Connect to contact plugin");
+
+       if ((NULL == service_adaptor) || (NULL == service)) {
+               service_adaptor_error("Invalid parameter");
+               snprintf(ret_msg, 2048, "contact plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       contact_adaptor_h adaptor = service_adaptor_get_contact_adaptor(service_adaptor);
+       contact_adaptor_plugin_h plugin = contact_adaptor_get_plugin_by_name(adaptor, service->plugin_uri);
+
+       if (NULL == service->context_info) {
+               service_adaptor_error("Invalid service->context_info");
+               snprintf(ret_msg, 2048, "contact plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       } else if ((NULL == service->context_info->duid)
+                       || (NULL == service->context_info->access_token)) {
+               service_adaptor_error("Invalid duid or access_token");
+               service_adaptor_debug_secure("Invalid duid or access_token: %s, %s",
+                               service->context_info->duid, service->context_info->access_token);
+               snprintf(ret_msg, 2048, "contact plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       contact_adaptor_plugin_context_h contact_context = contact_adaptor_create_plugin_context(plugin,
+                       service->context_info->duid, service->context_info->access_token, service->service_name);
+
+       if (NULL == contact_context) {
+               service_adaptor_debug_func("Could not get contact plugin context: %s, %s",
+                               service->context_info->duid, service->context_info->access_token);
+               snprintf(ret_msg, 2048, "contact plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_CORRUPTED;
+       }
+
+       /* Set server info */
+       int ret = 0;
+       contact_adaptor_error_code_h error = NULL;
+       SERVICE_ADAPTOR_API_TIME_CHECK_PAUSE();
+       SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_START(SA_TIME_CHECK_FLAG_CONTACT);
+       ret = contact_adaptor_set_server_info(plugin, contact_context, service->server_info, NULL, &error, NULL);
+       SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_PAUSE(SA_TIME_CHECK_FLAG_CONTACT);
+       SERVICE_ADAPTOR_API_TIME_CHECK_START();
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_warning("Could not set contact plugin server information: %d", ret);
+               if (NULL != error) {
+                       service_adaptor_warning("[%lld] %s", error->code, error->msg);
+               }
+               contact_adaptor_destroy_error_code(&error);
+       }
+
+       service->contact_context = contact_context;
+       service->connected |= 0x0000010;
+
+       service_adaptor_debug("Connected to contact plugin");
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_disconnect_contact_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service)
+{
+       service_adaptor_debug("Disconnect from contact plugin");
+
+       service_adaptor_debug("get contact adaptor");
+       contact_adaptor_h contact_adaptor = service_adaptor_get_contact_adaptor(service_adaptor);
+       if ((NULL != service->contact_context) && (NULL != contact_adaptor)) {
+               service_adaptor_debug("disconnects contact");
+               FUNC_STEP();
+               contact_adaptor_plugin_h contact_plugin = contact_adaptor_get_plugin_by_name(contact_adaptor, service->contact_context->plugin_uri);
+
+               if (NULL == contact_plugin) {
+                       service_adaptor_error("Cannot find plugin");
+               } else {
+                       service_adaptor_debug("destroys contact context");
+                       contact_adaptor_destroy_plugin_context(contact_plugin, service->contact_context);
+                       service->contact_context = NULL;
+               }
+       }
+
+       service_adaptor_debug("Disconnected from contact plugin");
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+contact_adaptor_h service_adaptor_create_contact()
+{
+       contact_adaptor_h contact_adaptor = contact_adaptor_create(CONTACT_PLUGIN_PATH);
+
+       if (NULL == contact_adaptor) {
+               service_adaptor_error("Could not create contact adaptor");
+               return NULL;
+       }
+
+       service_adaptor_debug("Contact adaptor created");
+
+       return contact_adaptor;
+}
+
+contact_adaptor_listener_h service_adaptor_register_contact_listener(contact_adaptor_h contact_adaptor)
+{
+       if ((void *) NULL == contact_adaptor) {
+               service_adaptor_error("Could not create contact adaptor");
+               return NULL;
+       }
+
+       contact_adaptor_listener_h contact_listener =
+                       (contact_adaptor_listener_h) malloc(sizeof(contact_adaptor_listener_t));
+
+       return contact_listener;
+}
diff --git a/src/service-adaptor-message.c b/src/service-adaptor-message.c
new file mode 100644 (file)
index 0000000..1fb3ad2
--- /dev/null
@@ -0,0 +1,1053 @@
+/*
+* 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 <stdlib.h>
+#include <sys/time.h>
+
+#include "service-adaptor.h"
+#include "service-adaptor-message.h"
+#include "service-adaptor-type.h"
+#include "service-adaptor-log.h"
+#include "dbus-ipc.h"
+#include "dbus-server.h"
+#include "dbus-service-adaptor.h"
+#include "dbus-message-adaptor.h"
+#include "message-adaptor.h"
+
+#define MESSAGING_PLUGIN_PATH  "/usr/lib/message-adaptor/plugins"
+#define STR_MESSAGE_ADAPTOR_ERROR_CONNECTION   "601"
+
+/* if calling completion callback, it need to wait called message api in dbus-message-adaptor */
+
+
+void _get_service_name_by_message_context(message_adaptor_plugin_context_h context,
+                                               char **service_name)
+{
+       service_adaptor_debug("<Start> %s", __FUNCTION__);
+       service_adaptor_h service_adaptor = service_adaptor_get_handle();
+       GList *services = NULL;
+       services = service_adaptor_get_services_by_plugin_uri(service_adaptor, context->plugin_uri);
+
+       GList *iter = NULL;
+       service_adaptor_service_context_s *service_context = NULL;
+       service_adaptor_debug("Start services iter (%d)", g_list_length(services));
+       for (iter = g_list_first(services); iter; iter = g_list_next(iter)) {
+               if (NULL != iter->data) {
+                       service_context = (service_adaptor_service_context_s *)iter->data;
+                       if (service_context->message_context == context) {
+                               if (NULL == service_context->service_name) {
+                                       service_adaptor_error("Service name is NULL");
+                               } else {
+                                       *service_name = strdup(service_context->service_name);
+                                       service_adaptor_debug("Service name found (%s)", *service_name);
+                               }
+                               break;
+                       }
+               } else {
+                       service_adaptor_debug("iter data is NULL");
+               }
+       }
+       g_list_free(services);
+       service_adaptor_debug("<End> %s", __FUNCTION__);
+}
+
+/***********************************************************
+ * Free Message adaptor callback
+ **********************************************************/
+void service_adaptor_message_adaptor_client_echo_cb(message_adaptor_plugin_context_h context,
+                                               long long int request_id,
+                                               message_adaptor_error_code_t **error_code,
+                                               void *server_data)
+{
+       service_adaptor_info("[Message  client echo CB]");
+
+       message_adaptor_error_code_t *error = NULL;
+       service_adaptor_h service_adaptor = service_adaptor_get_handle();
+       message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+
+       if ((NULL == adaptor) || (NULL == context)) {
+               service_adaptor_error("[Message  client echo CB] Invalid Param");
+               return;
+       }
+
+       if (MESSAGE_CONNECTION_POLICY_CONNECT == context->connection_policy) {
+               message_adaptor_plugin_h plugin = message_adaptor_get_plugin_by_name(adaptor, context->plugin_uri);
+
+               if (NULL == plugin) {
+                       service_adaptor_warning("[Message  client echo CB] Could not find a plugin");
+                       return;
+               }
+
+               service_adaptor_info("Reply Server echo");
+               message_adaptor_client_echo_reply(plugin, context, request_id, &error, NULL);
+               message_adaptor_destroy_error_code(&error);
+       } else {
+               service_adaptor_info("Skip Server echo");
+       }
+
+       service_adaptor_info("%s End", __FUNCTION__);
+}
+
+void service_adaptor_message_adaptor_create_chatroom_reply_cb(message_adaptor_plugin_context_h context,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               int default_message_ttl,
+                                               message_adaptor_wrong_receiver_s *wrong_receiver,
+                                               message_adaptor_error_code_t **error_code,
+                                               void *server_data)
+{
+       service_adaptor_info("[Message  create chatroom reply CB]");
+
+       message_adaptor_error_code_t *err = error_code ? (*error_code) : NULL;
+       message_adaptor_error_code_t _error;
+       _error.code = "0";
+       _error.msg = NULL;
+
+       if (NULL == err) {
+               err = &_error;
+       }
+
+       service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       ret = dbus_reply_create_chatroom_callback(request_id, chatroom_id, default_message_ttl,
+                       wrong_receiver, err, server_data);
+
+       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+               service_adaptor_error("[Message  create chatroom reply DBus CB]");
+       }
+
+       service_adaptor_info("%s End", __FUNCTION__);
+}
+
+void service_adaptor_message_adaptor_change_chatroom_meta_reply_cb(message_adaptor_plugin_context_h context,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               message_adaptor_error_code_t **error_code,
+                                               void *server_data)
+{
+       service_adaptor_info("[Message change chatroom meta reply CB]");
+
+       message_adaptor_error_code_t *err = error_code ? (*error_code) : NULL;
+       message_adaptor_error_code_t _error;
+       _error.code = "0";
+       _error.msg = NULL;
+
+       if (NULL == err) {
+               err = &_error;
+       }
+
+       service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       ret = dbus_reply_change_chatroom_meta_callback(request_id, chatroom_id, err, server_data);
+
+       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+               service_adaptor_error("[Message change chatroom meta reply DBus CB]");
+       }
+
+       service_adaptor_info("%s End", __FUNCTION__);
+}
+
+
+void service_adaptor_message_adaptor_chat_reply_cb(message_adaptor_plugin_context_h context,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               message_adaptor_processed_msg_s **processed_msgs,
+                                               unsigned int processed_msgs_len,
+                                               message_adaptor_error_code_t **error_code,
+                                               void *server_data)
+{
+       service_adaptor_info("[Message chat reply CB]");
+
+       message_adaptor_error_code_t *err = error_code ? (*error_code) : NULL;
+       message_adaptor_error_code_t _error;
+       _error.code = "0";
+       _error.msg = NULL;
+
+       if (NULL == err) {
+               err = &_error;
+       }
+
+       service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       ret = dbus_reply_chat_callback(request_id, chatroom_id, processed_msgs, processed_msgs_len, err, server_data);
+
+       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+               service_adaptor_error("[Message chat reply DBus CB]");
+       }
+
+       service_adaptor_info("%s End", __FUNCTION__);
+}
+
+void service_adaptor_message_adaptor_allow_chat_reply_cb(message_adaptor_plugin_context_h context,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               message_adaptor_delivery_ack_s **delivery_acks,
+                                               unsigned int delivery_acks_len,
+                                               unsigned long long last_delivery_acks_timestamp,
+                                               message_adaptor_read_ack_s **read_acks,
+                                               unsigned int read_acks_len,
+                                               unsigned long long last_read_acks_timestamp,
+                                               message_adaptor_ordered_chat_member_s **ordered_chat_members,
+                                               unsigned int ordered_chat_members_len,
+                                               const char *chatroom_title,
+                                               int default_message_ttl,
+                                               message_adaptor_error_code_t **error_code,
+                                               void *server_data)
+{
+       service_adaptor_info("[Message allow chat reply CB]");
+
+       message_adaptor_error_code_t *err = error_code ? (*error_code) : NULL;
+       message_adaptor_error_code_t _error;
+       _error.code = "0";
+       _error.msg = NULL;
+
+       if (NULL == err) {
+               err = &_error;
+       }
+
+       service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       ret = dbus_reply_allow_chat_callback(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, err, server_data);
+
+       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+               service_adaptor_error("[Message allow chat reply DBus CB]");
+       }
+
+       service_adaptor_info("%s End", __FUNCTION__);
+}
+
+void service_adaptor_message_adaptor_get_all_unread_message_reply_cb(message_adaptor_plugin_context_h context,
+                                               long long int request_id,
+                                               message_adaptor_error_code_t **error_code,
+                                               void *server_data)
+{
+       service_adaptor_info("[Message  get all unread message reply CB]");
+
+       message_adaptor_error_code_t *err = error_code ? (*error_code) : NULL;
+       message_adaptor_error_code_t _error;
+       _error.code = "0";
+       _error.msg = NULL;
+
+       if (NULL == err) {
+               err = &_error;
+       }
+
+       service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       ret = dbus_reply_all_unread_message_callback(request_id, err, server_data);
+
+       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+               service_adaptor_error("[Message  get all unread message reply DBus CB]");
+       }
+
+       service_adaptor_info("%s End", __FUNCTION__);
+}
+
+void service_adaptor_message_adaptor_forward_online_message_request_cb(message_adaptor_plugin_context_h context,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               int chat_type,
+                                               message_adaptor_inbox_message_s *inbox_msg,
+                                               bool skip_reply,
+                                               message_adaptor_error_code_t **error_code,
+                                               void *server_data)
+{
+       service_adaptor_info("[Message  forward online message request CB]");
+
+       message_adaptor_error_code_t *err = error_code ? (*error_code) : NULL;
+       message_adaptor_error_code_t _error;
+       _error.code = "0";
+       _error.msg = NULL;
+
+       if (NULL == err) {
+               err = &_error;
+       }
+
+       service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       ret = dbus_request_forward_online_message_callback(request_id, chatroom_id, chat_type, inbox_msg, skip_reply, err, server_data);
+
+       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+               service_adaptor_error("[Message  forward online message DBus CB]");
+       }
+
+       service_adaptor_info("[End Message  forward online message request CB]");
+       service_adaptor_info("%s End", __FUNCTION__);
+}
+
+void service_adaptor_message_adaptor_forward_unread_message_request_cb(message_adaptor_plugin_context_h context,
+                                               long long int request_id,
+                                               message_adaptor_inbox_message_s ***inbox_msgs,
+                                               unsigned int inbox_msgs_len,
+                                               char **next_pagination_key,
+                                               message_adaptor_error_code_t **error_code,
+                                               void *server_data)
+{
+       service_adaptor_info("[Message  forward unread message request CB]");
+
+       message_adaptor_error_code_t *err = error_code ? (*error_code) : NULL;
+       message_adaptor_error_code_t _error;
+       _error.code = "0";
+       _error.msg = NULL;
+
+       if (NULL == err) {
+               err = &_error;
+       }
+
+       service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       ret = dbus_request_forward_unread_message_callback(request_id, *inbox_msgs, inbox_msgs_len, *next_pagination_key, err, server_data);
+
+       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+               service_adaptor_error("[Message  forward unread message request DBus CB]");
+       }
+
+       service_adaptor_info("%s End", __FUNCTION__);
+}
+
+void service_adaptor_message_adaptor_read_message_reply_cb(message_adaptor_plugin_context_h context,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               message_adaptor_error_code_t **error_code,
+                                               void *server_data)
+{
+       service_adaptor_info("[Message  read message reply CB]");
+
+       message_adaptor_error_code_t *err = error_code ? (*error_code) : NULL;
+       message_adaptor_error_code_t _error;
+       _error.code = "0";
+       _error.msg = NULL;
+
+       if (NULL == err) {
+               err = &_error;
+       }
+
+       service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       ret = dbus_reply_read_message_callback(request_id, chatroom_id, err, server_data);
+
+       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+               service_adaptor_error("[Message  read message reply DBus CB]");
+       }
+
+       service_adaptor_info("%s End", __FUNCTION__);
+}
+
+void service_adaptor_message_adaptor_invite_chat_reply_cb(message_adaptor_plugin_context_h context,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               long long int sent_time,
+                                               message_adaptor_wrong_receiver_s *wrong_receiver,
+                                               message_adaptor_error_code_t **error_code,
+                                               void *server_data)
+{
+       service_adaptor_info("[Message  invite chat reply CB]");
+
+       message_adaptor_error_code_t *err = error_code ? (*error_code) : NULL;
+       message_adaptor_error_code_t _error;
+       _error.code = "0";
+       _error.msg = NULL;
+
+       if (NULL == err) {
+               err = &_error;
+       }
+
+       service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       ret = dbus_reply_invite_chat_callback(request_id, chatroom_id, sent_time, wrong_receiver, err, server_data);
+
+       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+               service_adaptor_error("[Message  invite chat reply DBus CB]");
+       }
+
+       service_adaptor_info("%s End", __FUNCTION__);
+}
+
+void service_adaptor_message_adaptor_end_chat_reply_cb(message_adaptor_plugin_context_h context,
+                                               long long int request_id,
+                                               message_adaptor_error_code_t **error_code,
+                                               void *server_data)
+{
+       service_adaptor_info("[Message  end chat reply CB]");
+
+       message_adaptor_error_code_t *err = error_code ? (*error_code) : NULL;
+       message_adaptor_error_code_t _error;
+       _error.code = "0";
+       _error.msg = NULL;
+
+       if (NULL == err) {
+               err = &_error;
+       }
+
+       service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       ret = dbus_reply_end_chat_callback(request_id, err, server_data);
+
+       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+               service_adaptor_error("[Message  end chat reply DBus CB]");
+       }
+
+       service_adaptor_info("%s End", __FUNCTION__);
+}
+
+void service_adaptor_message_adaptor_unseal_message_reply_cb(message_adaptor_plugin_context_h context,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               message_adaptor_error_code_t **error_code,
+                                               void *server_data)
+{
+       service_adaptor_info("[Message  unseal message reply CB]");
+
+       message_adaptor_error_code_t *err = error_code ? (*error_code) : NULL;
+       message_adaptor_error_code_t _error;
+       _error.code = "0";
+       _error.msg = NULL;
+
+       if (NULL == err) {
+               err = &_error;
+       }
+
+       service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       ret = dbus_reply_unseal_message_callback(request_id, chatroom_id, err, server_data);
+
+       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+               service_adaptor_error("[Message  unseal message reply DBus CB]");
+       }
+
+       service_adaptor_info("%s End", __FUNCTION__);
+}
+
+
+void service_adaptor_message_adaptor_save_call_log_reply_cb(message_adaptor_plugin_context_h context,
+                                               long long int request_id,
+                                               message_adaptor_error_code_t **error_code,
+                                               void *server_data)
+{
+       service_adaptor_info("[Message  save call log reply CB]");
+
+       message_adaptor_error_code_t *err = error_code ? (*error_code) : NULL;
+       message_adaptor_error_code_t _error;
+       _error.code = "0";
+       _error.msg = NULL;
+
+       if (NULL == err) {
+               err = &_error;
+       }
+
+       service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       ret = dbus_reply_save_call_log_callback(request_id, err, server_data);
+
+       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+               service_adaptor_error("[Message  save call log reply DBus CB]");
+       }
+
+       service_adaptor_info("%s End", __FUNCTION__);
+}
+
+void service_adaptor_message_adaptor_current_time_reply_cb(message_adaptor_plugin_context_h context,
+                                               long long int request_id,
+                                               long long int current_time_millis,
+                                               message_adaptor_error_code_t **error_code,
+                                               void *server_data)
+{
+       service_adaptor_info("[Message  current time reply CB]");
+
+       message_adaptor_error_code_t *err = error_code ? (*error_code) : NULL;
+       message_adaptor_error_code_t _error;
+       _error.code = "0";
+       _error.msg = NULL;
+
+       if (NULL == err) {
+               err = &_error;
+       }
+
+       service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       ret = dbus_reply_current_time_callback(request_id, current_time_millis, err, server_data);
+
+       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+               service_adaptor_error("[Message  current time reply DBus CB]");
+       }
+
+       service_adaptor_info("%s End", __FUNCTION__);
+}
+
+void service_adaptor_message_adaptor_typing_updated_cb(message_adaptor_plugin_context_h context,
+                                               long long int request_id,
+                                               long long int chatroom_id,
+                                               long long int *sender,
+                                               char **state,
+                                               int *contentType,
+                                               int *refershTime,
+                                               message_adaptor_error_code_t **error_code,
+                                               void *server_data)
+{
+       service_adaptor_info("[Message typing updated reply CB]");
+       service_adaptor_info("%s End", __FUNCTION__);
+}
+
+void service_adaptor_message_adaptor_thread_completion_cb(message_adaptor_plugin_context_h context,
+                                               message_connection_state_t state,
+                                               message_adaptor_error_code_t **error_code,
+                                               void *server_data)
+{
+       service_adaptor_info("[Message  thread completion CB]");
+       service_adaptor_debug("connection state(%d)", state);
+
+       if (MESSAGE_CONNECTION_STATE_INTERRUPTED != state) {
+               service_adaptor_info("Message Connection Finished (without re-connect)");
+               return;
+       }
+
+       service_adaptor_h service_adaptor = service_adaptor_get_handle();
+       message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+
+       if ((NULL == adaptor) || (NULL == context)) {
+               service_adaptor_error("[Message  Thread Completion CB] Invalid Param");
+               return;
+       }
+
+       message_adaptor_plugin_h plugin = message_adaptor_get_plugin_by_name(adaptor, context->plugin_uri);
+
+       if (NULL == plugin) {
+               service_adaptor_error("[Message  Thread Completion CB] Could not find a plugin");
+               return;
+       }
+
+       int ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       message_adaptor_error_code_h error = NULL;
+
+       message_adaptor_error_code_t *err = error_code ? (*error_code) : NULL;
+       message_adaptor_error_code_t _error;
+       _error.code = "0";
+       _error.msg = NULL;
+
+       if (NULL == err) {
+               err = &_error;
+       }
+
+       /* Disconnect by user policy */
+       if (MESSAGE_CONNECTION_POLICY_CONNECT != context->connection_policy) {
+               service_adaptor_info("Disconnect By user policy (%d)", context->connection_policy);
+               context->connection_policy = MESSAGE_CONNECTION_POLICY_DISCONNECT;
+               message_adaptor_disconnect(plugin, context, &error);
+               char *service_name = NULL;
+               _get_service_name_by_message_context(context, &service_name);
+               dbus_reply_message_channel_disconnected_callback(service_name, err);
+               free(service_name);
+
+               if (NULL != error) {
+                       service_adaptor_debug("error code : code(%s) msg(%s)", error->code, error->msg);
+                       message_adaptor_destroy_error_code(&error);
+               }
+               return;
+       }
+
+       service_adaptor_debug("message connection create");
+       ret = service_adaptor_message_connection_create(plugin, context, &error);
+
+       if (NULL != error) {
+               service_adaptor_debug("error code : code(%s) msg(%s)", error->code, error->msg);
+               message_adaptor_destroy_error_code(&error);
+       }
+
+       switch (ret) {
+       case SERVICE_ADAPTOR_INTERNAL_ERROR_NONE:       /* success */
+               service_adaptor_debug("Message connection was resumed successfully");
+               break;
+       case SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT:   /* fail : Noti this information to Client */
+               service_adaptor_warning("msg_buffer was empty (can not get message plugin, context)");
+       case SERVICE_ADAPTOR_INTERNAL_ERROR_CONNECT:
+               service_adaptor_warning("msg_buffer was empty (can not get message plugin, context)");
+       default:
+               service_adaptor_debug("message connection disconnect");
+               context->connection_policy = MESSAGE_CONNECTION_POLICY_DISCONNECT;
+               int con_ret = message_adaptor_disconnect(plugin, context, &error);
+               if (con_ret) {
+                       service_adaptor_error("message connection disconnect failed");
+               } else {
+                       service_adaptor_error("message connection resumption stopped (disconnect res : %d)", con_ret);
+               }
+
+               service_adaptor_info("Set Connection policy, and call noti callback");
+               char *service_name = NULL;
+               _get_service_name_by_message_context(context, &service_name);
+               dbus_reply_message_channel_disconnected_callback(service_name, error ? error : &_error);
+               free(service_name);
+
+               if (NULL != error) {
+                       service_adaptor_debug("error code : code(%s) msg(%s)", error->code, error->msg);
+                       message_adaptor_destroy_error_code(&error);
+               }
+               break;
+       }
+
+       service_adaptor_info("%s End", __FUNCTION__);
+}
+
+service_adaptor_internal_error_code_e service_adaptor_message_connection_create(message_adaptor_plugin_h plugin,
+                                               message_adaptor_plugin_context_h message_context,
+                                               message_adaptor_error_code_t **error)
+{
+       if ((NULL == plugin) || (NULL == message_context)) {
+               service_adaptor_error("Invailid argument (plugin [%p], context [%p])", plugin, message_context);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       int try_count = 0;
+       int MAX_TRY_COUNT = 1;
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       service_adaptor_debug("Try 'message_adaptor_connect'");
+
+       do {
+               ret = SERVICE_ADAPTOR_ERROR_NONE;
+               ret = message_adaptor_connect(plugin, message_context, error);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+                       service_adaptor_warning("message adaptor connection failed(try count : %d)", ++try_count);
+                       if ((NULL != error) && (NULL != *error)) {
+                               service_adaptor_info("message connection fail error code [%s][%s]",
+                                               (*error)->code, (*error)->msg);
+                               message_adaptor_destroy_error_code(error);
+                       }
+
+                       if (MAX_TRY_COUNT <= try_count) {
+                               service_adaptor_error("message connection resumption stopped (last connect res : %d)", ret);
+                               return SERVICE_ADAPTOR_INTERNAL_ERROR_CONNECT;
+                       }
+               }
+       } while (SERVICE_ADAPTOR_ERROR_NONE != ret);
+
+       MAX_TRY_COUNT = 2;
+       try_count = 0;
+       message_adaptor_error_code_t *key_error_code = NULL;
+
+       service_adaptor_debug("Try 'message_adaptor_get_key'");
+
+       do {
+               ret = SERVICE_ADAPTOR_ERROR_NONE;
+               ret = message_adaptor_get_key(plugin, message_context,
+                               NULL, NULL, NULL, NULL, NULL, &key_error_code, NULL);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+                       service_adaptor_warning("Could not get encrypt key from server(try count : %d)", ++try_count);
+                       if (NULL != key_error_code) {
+                               service_adaptor_info("message get-key fail error code [%s][%s]",
+                                               key_error_code->code, key_error_code->msg);
+                               message_adaptor_destroy_error_code(&key_error_code);
+                       }
+
+                       if (MESSAGE_ADAPTOR_ERROR_NOT_AUTHORIZED == ret) {
+                               service_adaptor_info("Access token invalid. Try refresh auth");
+                               char *service_name = NULL;
+                               _get_service_name_by_message_context(message_context, &service_name);
+                               service_adaptor_debug("service name : %s", service_name);
+
+                               service_adaptor_auth_refresh(service_adaptor_get_handle(), service_name, message_context->plugin_uri);
+                               free(service_name);
+                       } else {
+                               ++try_count;
+                       }
+
+                       if (MAX_TRY_COUNT <= try_count) {
+                               service_adaptor_error("message connection resumption stopped (last get_key res : %d)", ret);
+                               return SERVICE_ADAPTOR_INTERNAL_ERROR_CONNECT;
+                       }
+               }
+       } while (SERVICE_ADAPTOR_ERROR_NONE != ret);
+
+       MAX_TRY_COUNT = 1;
+       try_count = 0;
+       struct timeval tv;
+       long long int req_id = 0;
+
+       service_adaptor_debug("Try 'message_adaptor_channel_auth_request'");
+
+       do {
+               gettimeofday(&tv, NULL);
+               req_id = (long long int)tv.tv_usec;
+
+               ret = SERVICE_ADAPTOR_ERROR_NONE;
+               int timeout_sec = 5;            /* TODO It will be changed to meaningful value */
+               int additional_timeout_sec = 2; /* TODO It will be changed to meaningful value */
+               ret = message_adaptor_channel_auth_request(plugin, message_context, req_id, timeout_sec, NULL, error, NULL);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+                       service_adaptor_warning("message adaptor channel-auth request failed(try count : %d)", ++try_count);
+                       if ((NULL != error) && (NULL != *error)) {
+                               service_adaptor_info("message channel-auth error code [%s][%s]",
+                                               (*error)->code, (*error)->msg);
+                               message_adaptor_destroy_error_code(error);
+                       }
+
+                       if (MAX_TRY_COUNT <= try_count) {
+                               service_adaptor_error("message connection resumption stopped (last channel_auth res : %d)", ret);
+                               return SERVICE_ADAPTOR_INTERNAL_ERROR_CONNECT;
+                       }
+                       if (MESSAGE_ADAPTOR_ERROR_TIME_OUT == ret) {
+                               timeout_sec += additional_timeout_sec;
+                               service_adaptor_info("Increase timeout seconds (total: %d sec)", timeout_sec);
+                       }
+               }
+       } while (SERVICE_ADAPTOR_ERROR_NONE != ret);
+
+       service_adaptor_debug("Message connection created successfully");
+
+       service_adaptor_info("%s End", __FUNCTION__);
+
+       return ret;
+}
+
+message_adaptor_h service_adaptor_get_message_adaptor(service_adaptor_h service_adaptor)
+{
+       service_adaptor_debug("Get message adaptor");
+
+       if ((void *) NULL == service_adaptor) {
+               service_adaptor_error("Invalid argument");
+               return NULL;
+       }
+
+       return service_adaptor->message_handle;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_connect_message_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service,
+                                               char *ret_msg)
+{
+       service_adaptor_debug("Connect to message plugin");
+
+       if ((NULL == service_adaptor) || (NULL == service)) {
+               service_adaptor_error("Invalid parameter");
+               snprintf(ret_msg, 2048, "message plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+       message_adaptor_plugin_h plugin = message_adaptor_get_plugin_by_name(adaptor, service->plugin_uri);
+
+       if ((NULL == service->context_info) || (NULL == service->context_info->duid)
+                       || (NULL == service->context_info->access_token)) {
+               if (NULL != service->context_info) {
+                       service_adaptor_error("Invalid duid or access_token");
+                       service_adaptor_debug_secure("Invalid duid or access_token: %s, %s",
+                                       service->context_info->duid, service->context_info->access_token);
+               } else {
+                       service_adaptor_error("Message context is NULL");
+               }
+               snprintf(ret_msg, 2048, "message plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       message_adaptor_plugin_context_h message_context = message_adaptor_create_plugin_context(plugin,
+                       service->plugin_uri, service->context_info->duid, service->context_info->access_token, service->context_info->app_id, service->context_info->service_id);
+       /* TODO It can be included in service_adaptor_service_context_t */
+
+       if (NULL == message_context) {
+               service_adaptor_debug_secure("Could not get message plugin context: %s, %s",
+                               service->context_info->duid, service->context_info->access_token);
+               snprintf(ret_msg, 2048, "message plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_CORRUPTED;
+       }
+
+       /* TODO It should remove this part. */
+       /* And then it can add conn info of message_context from conn info of same duid in message_adaptor_connect() */
+       int service_count = g_list_length(service_adaptor->service_list);
+
+       for (int i = 0; i < service_count; i++) {
+               service_adaptor_service_context_h svc = g_list_nth_data(service_adaptor->service_list, i);
+
+               if ((NULL != svc) && (NULL != svc->message_context) && (0 == strncmp(svc->context_info->duid, service->context_info->duid, strlen(service->context_info->duid)))) {
+                       message_connection_state_t state = MESSAGE_CONNECTION_STATE_INIT;
+                       message_adaptor_error_code_h msg_error = NULL;
+                       message_adaptor_get_connection_state(plugin, svc->message_context, &state, &msg_error);
+
+                       if (MESSAGE_CONNECTION_STATE_CONNECT == state) {
+                               service->message_context = svc->message_context;
+                               service->connected |= 0x0000100;
+                               message_adaptor_destroy_error_code(&msg_error);
+
+                               return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+                       }
+
+                       message_adaptor_destroy_error_code(&msg_error);
+               }
+       }
+
+       /* Set server info */
+       int ret = 0;
+       message_adaptor_error_code_h error = NULL;
+       ret = message_adaptor_set_server_info(plugin, message_context, service->server_info, NULL, &error, NULL);
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_warning("Could not set message plugin server information: %d", ret);
+               if (NULL != error) {
+                       service_adaptor_warning("[%s] %s", error->code, error->msg);
+               }
+               message_adaptor_destroy_error_code(&error);
+       }
+
+/*     ret = service_adaptor_message_connection_create(plugin, message_context, &error); */
+
+       SERVICE_ADAPTOR_API_TIME_CHECK_PAUSE();
+       SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_START(SA_TIME_CHECK_FLAG_MESSAGE);
+       ret = message_adaptor_connect(plugin, message_context, &error);
+       SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_PAUSE(SA_TIME_CHECK_FLAG_MESSAGE);
+       SERVICE_ADAPTOR_API_TIME_CHECK_START();
+
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_error("message adaptor connection failed");
+               message_context->connection_policy = MESSAGE_CONNECTION_POLICY_DISCONNECT;
+               service->message_context = message_context;
+               if (NULL != error) {
+                       snprintf(ret_msg, 2048, "message connect failed [%s][%s]", error->code, error->msg);
+                       if (0 == strncmp(STR_MESSAGE_ADAPTOR_ERROR_CONNECTION, error->code, strlen(STR_MESSAGE_ADAPTOR_ERROR_CONNECTION))) {
+                               ret = MESSAGE_PLUGIN_ERROR_NETWORK_DEVICE_OFFLINE;
+                       }
+               } else {
+                       snprintf(ret_msg, 2048, "message TCP connect failed []");
+               }
+               message_adaptor_destroy_error_code(&error);
+               return ret;
+       }
+
+       struct timeval tv;
+       long long int req_id = 0;
+       void *server_data = NULL;
+       message_adaptor_error_code_t *key_error_code = NULL;
+       message_adaptor_error_code_t *error_code = NULL;
+
+       SERVICE_ADAPTOR_API_TIME_CHECK_PAUSE();
+       SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_START(SA_TIME_CHECK_FLAG_MESSAGE);
+       ret = message_adaptor_get_key(plugin, message_context, NULL, NULL, NULL, NULL, NULL, &key_error_code, &server_data);
+       SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_PAUSE(SA_TIME_CHECK_FLAG_MESSAGE);
+       SERVICE_ADAPTOR_API_TIME_CHECK_START();
+
+       if (NULL != key_error_code) {
+               service_adaptor_error("Could not get encrypt key from server,%s %s", key_error_code->code, key_error_code->msg);
+
+/*             return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT; */
+       }
+
+       if (MESSAGE_ADAPTOR_ERROR_NOT_AUTHORIZED == ret) {
+               service_adaptor_info("Access token invalid. Try refresh auth");
+               message_adaptor_destroy_error_code(&key_error_code);
+
+               service->message_context = message_context;
+               SERVICE_ADAPTOR_API_TIME_CHECK_PAUSE();
+               SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_START(SA_TIME_CHECK_FLAG_AUTH);
+               service_adaptor_auth_refresh_with_service_context(service_adaptor_get_handle(), service, message_context->plugin_uri);
+               SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_PAUSE(SA_TIME_CHECK_FLAG_AUTH);
+               SERVICE_ADAPTOR_API_TIME_CHECK_START();
+               ret = message_adaptor_get_key(plugin, message_context, NULL, NULL, NULL, NULL, NULL, &key_error_code, &server_data);
+       }
+
+       if (NULL != key_error_code) {
+               service_adaptor_error("Could not get encrypt key from server,%s %s", key_error_code->code, key_error_code->msg);
+               snprintf(ret_msg, 2048, "message get-key failed [%s][%s]", key_error_code->code, key_error_code->msg);
+
+               if (0 == strncmp(STR_MESSAGE_ADAPTOR_ERROR_CONNECTION, key_error_code->code, strlen(STR_MESSAGE_ADAPTOR_ERROR_CONNECTION))) {
+                       ret = MESSAGE_PLUGIN_ERROR_NETWORK_DEVICE_OFFLINE;
+               }
+
+               message_adaptor_destroy_error_code(&key_error_code);
+               message_context->connection_policy = MESSAGE_CONNECTION_POLICY_DISCONNECT;
+               service->message_context = message_context;
+/*             service->message_context = NULL; */
+
+               return ret;
+       } else if (MESSAGE_ADAPTOR_ERROR_NONE != ret) {
+               snprintf(ret_msg, 2048, "message get-key failed [%s]", "No error message");
+               ret = MESSAGE_PLUGIN_ERROR_NETWORK_DEVICE_OFFLINE;
+
+               message_context->connection_policy = MESSAGE_CONNECTION_POLICY_DISCONNECT;
+               service->message_context = message_context;
+               return ret;
+       }
+
+       gettimeofday(&tv, NULL);
+       req_id = (long long int)tv.tv_usec;
+       int timeout_sec = 10;           /* TODO It will be changed to meaningful value */
+       SERVICE_ADAPTOR_API_TIME_CHECK_PAUSE();
+       SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_START(SA_TIME_CHECK_FLAG_MESSAGE);
+       ret = message_adaptor_channel_auth_request(plugin, message_context, req_id, timeout_sec, NULL, &error_code, NULL);
+       SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_PAUSE(SA_TIME_CHECK_FLAG_MESSAGE);
+       SERVICE_ADAPTOR_API_TIME_CHECK_START();
+
+       if (MESSAGE_ADAPTOR_ERROR_NONE == ret) {
+               message_context->connection_policy = MESSAGE_CONNECTION_POLICY_AUTO;
+               service->message_context = message_context;
+               service->connected |= 0x0000100;
+       } else {
+               message_context->connection_policy = MESSAGE_CONNECTION_POLICY_DISCONNECT;
+               service->message_context = message_context;
+/*             service->message_context = NULL; */
+               if (NULL != error_code) {
+                       service_adaptor_error("Channel create request error (%s): %s", error_code->code, error_code->msg);
+                       snprintf(ret_msg, 2048, "message channel-auth failed [%s][%s]", error_code->code, error_code->msg);
+
+                       if (0 == strncmp(STR_MESSAGE_ADAPTOR_ERROR_CONNECTION, error_code->code, strlen(STR_MESSAGE_ADAPTOR_ERROR_CONNECTION))) {
+                               ret = MESSAGE_PLUGIN_ERROR_NETWORK_DEVICE_OFFLINE;
+                       }
+
+                       message_adaptor_destroy_error_code(&error_code);
+               } else {
+                       snprintf(ret_msg, 2048, "message channel-auth failed [%s]", "No error message");
+                       ret = MESSAGE_PLUGIN_ERROR_NETWORK_DEVICE_OFFLINE;
+               }
+               return ret;
+       }
+
+       service_adaptor_debug("Connected to message plugin");
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_disconnect_message_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service)
+{
+       service_adaptor_debug("Disconnect from message plugin");
+
+       service_adaptor_debug("get message adaptor");
+       message_adaptor_h message_adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+       if ((NULL != service->message_context) && (NULL != message_adaptor)) {
+               service_adaptor_debug("disconnects message");
+               message_adaptor_error_code_h message_error = NULL;
+               message_adaptor_plugin_h message_plugin = message_adaptor_get_plugin_by_name(message_adaptor, service->message_context->plugin_uri);
+
+               if (NULL == message_plugin) {
+                       service_adaptor_error("Cannot find plugin");
+               } else {
+                       message_connection_state_t state = MESSAGE_CONNECTION_STATE_INIT;
+                       message_adaptor_get_connection_state(message_plugin, service->message_context, &state, &message_error);
+                       message_adaptor_destroy_error_code(&message_error);
+
+                       service_adaptor_debug_func("connection state (%d)", state);
+                       if ((MESSAGE_CONNECTION_STATE_CONNECT == state) ||
+                                       (MESSAGE_CONNECTION_STATE_INTERRUPTED == state)) {
+                               service_adaptor_debug_func("Call message_adaptor_disconnect");
+                               message_adaptor_disconnect(message_plugin, service->message_context, &message_error);
+                       }
+
+                       service_adaptor_debug("dsetroys message context");
+                       message_adaptor_destroy_plugin_context(message_plugin, service->message_context);
+                       service->message_context = NULL;
+
+                       if (NULL != message_error) {
+                               service_adaptor_debug("error code : code(%s) msg(%s)", message_error->code, message_error->msg);
+                               message_adaptor_destroy_error_code(&message_error);
+                       }
+               }
+       }
+
+       service_adaptor_debug("Disconnected from message plugin");
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+message_adaptor_h service_adaptor_create_message()
+{
+       message_adaptor_h message_adaptor = message_adaptor_create(MESSAGING_PLUGIN_PATH);
+
+       if (NULL == message_adaptor) {
+               service_adaptor_error("Could not create message adaptor");
+               return NULL;
+       }
+
+       service_adaptor_debug("Message adaptor created");
+
+       return message_adaptor;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_message_set_connection(message_adaptor_plugin_h plugin,
+                                               message_adaptor_plugin_context_h message_context,
+                                               message_connection_policy_e policy,
+                                               message_adaptor_error_code_t **error_code)
+{
+       service_adaptor_debug("<Start> %s", __FUNCTION__);
+       if ((NULL == plugin) || (NULL == message_context)) {
+               service_adaptor_error("Invailid argument (plugin [%p], context [%p])", plugin, message_context);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       message_adaptor_error_code_t *_error = NULL;
+
+       if (MESSAGE_CONNECTION_POLICY_DISCONNECT == policy) {
+               service_adaptor_info("Disconnect By user policy(%d)", policy);
+               message_context->connection_policy = MESSAGE_CONNECTION_POLICY_DISCONNECT;
+               message_adaptor_disconnect(plugin, message_context, &_error);
+       } else if ((MESSAGE_CONNECTION_POLICY_CONNECT == policy) || (MESSAGE_CONNECTION_POLICY_AUTO == policy)) {
+               service_adaptor_info("Connect By user policy(%d)", policy);
+               if (MESSAGE_CONNECTION_POLICY_DISCONNECT == message_context->connection_policy) {
+                       message_context->connection_policy = policy;
+                       service_adaptor_debug("Try new connection create");
+                       ret = service_adaptor_message_connection_create(plugin, message_context, &_error);
+                       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+                               service_adaptor_debug("New connection create failed, set disconnect");
+                               message_context->connection_policy = MESSAGE_CONNECTION_POLICY_DISCONNECT;
+                               message_adaptor_disconnect(plugin, message_context, &_error);
+                               message_adaptor_destroy_error_code(&_error);
+                               _error = message_adaptor_create_error_code("601", "Message Channel Connect failed");
+                               ret =  SERVICE_ADAPTOR_INTERNAL_ERROR_DISCONNECT;
+                       } else {
+                               message_context->connection_policy = policy;
+                       }
+               } else {
+                       message_context->connection_policy = policy;
+               }
+       }
+
+       if (error_code != NULL) {
+               *error_code = _error;
+       } else {
+               message_adaptor_destroy_error_code(&_error);
+       }
+
+       service_adaptor_debug("<End> %s", __FUNCTION__);
+
+       return ret;
+}
+
+message_adaptor_listener_h service_adaptor_register_message_listener(message_adaptor_h message_adaptor)
+{
+       if (NULL == message_adaptor) {
+               service_adaptor_error("Could not create message adaptor");
+               return NULL;
+       }
+
+       message_adaptor_listener_h message_listener =
+               (message_adaptor_listener_h) malloc(sizeof(message_adaptor_listener_t));
+
+       if ((void *) NULL == message_listener) {
+               service_adaptor_error("Could not create message listener");
+               return NULL;
+       }
+
+       message_listener->client_echo_cb = service_adaptor_message_adaptor_client_echo_cb;
+       message_listener->create_chatroom_reply_cb = service_adaptor_message_adaptor_create_chatroom_reply_cb;
+       message_listener->change_chatroom_meta_reply_cb = service_adaptor_message_adaptor_change_chatroom_meta_reply_cb;
+       message_listener->chat_reply_cb = service_adaptor_message_adaptor_chat_reply_cb;
+       message_listener->allow_chat_reply_cb = service_adaptor_message_adaptor_allow_chat_reply_cb;
+       message_listener->get_all_unread_message_reply_cb = service_adaptor_message_adaptor_get_all_unread_message_reply_cb;
+       message_listener->forward_online_message_request_cb = service_adaptor_message_adaptor_forward_online_message_request_cb;
+       message_listener->forward_unread_message_request_cb = service_adaptor_message_adaptor_forward_unread_message_request_cb;
+       message_listener->read_message_reply_cb = service_adaptor_message_adaptor_read_message_reply_cb;
+       message_listener->invite_chat_reply_cb = service_adaptor_message_adaptor_invite_chat_reply_cb;
+       message_listener->end_chat_reply_cb = service_adaptor_message_adaptor_end_chat_reply_cb;
+       message_listener->unseal_message_reply_cb = service_adaptor_message_adaptor_unseal_message_reply_cb;
+       message_listener->save_call_log_reply_cb = service_adaptor_message_adaptor_save_call_log_reply_cb;
+       message_listener->current_time_reply_cb = service_adaptor_message_adaptor_current_time_reply_cb;
+       message_listener->typing_updated_cb = service_adaptor_message_adaptor_typing_updated_cb;
+       message_listener->completion_cb = service_adaptor_message_adaptor_thread_completion_cb;
+
+       message_adaptor_register_listener(message_adaptor, message_listener);
+       service_adaptor_debug("Message adaptor listener created");
+
+       return message_listener;
+}
diff --git a/src/service-adaptor-plugin.c b/src/service-adaptor-plugin.c
new file mode 100644 (file)
index 0000000..5facd78
--- /dev/null
@@ -0,0 +1,285 @@
+/*
+* 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 <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <glib-object.h>
+#include <glib-unix.h>
+
+#include <app_info.h>
+#include <package_manager.h>
+#include <auth-adaptor.h>
+#include <storage-adaptor.h>
+
+#include "service-adaptor.h"
+#include "service-adaptor-plugin.h"
+#include "service-adaptor-auth.h"
+#include "service-adaptor-storage.h"
+#include "service-adaptor-type.h"
+#include "service-adaptor-log.h"
+
+void blank(char *s, ...) {}
+void _blank() {}
+
+#ifdef DEBUG_PLUGIN_OBSERVER_FLAG
+#define _service_adaptor_debug         service_adaptor_debug
+#define _service_adaptor_debug_func    service_adaptor_debug_func
+#define _service_adaptor_info          service_adaptor_info
+#define _FUNC_START                    FUNC_START
+#define _FUNC_END                      FUNC_END
+#else
+#define _service_adaptor_debug         blank
+#define _service_adaptor_debug_func    blank
+#define _service_adaptor_info          blank
+#define _FUNC_START                    _blank
+#define _FUNC_END                      _blank
+#endif
+
+static package_manager_h g_package_manager = NULL;
+
+struct package_checker_context_s {
+       char *package_id;
+       char *package_root;
+       char *auth_plugin_path;
+       char *storage_plugin_path;
+
+       bool version_defined;
+       bool auth_defined;
+       bool storage_defined;
+};
+
+bool __service_adaptor_app_meta_iterator_cb(const char *_key,
+                                               const char *value,
+                                               void *user_data)
+{
+       _FUNC_START();
+       char *key = strdup(_key);
+       struct package_checker_context_s *ctx = (struct package_checker_context_s *) user_data;
+       _service_adaptor_debug_func("app meta key(%s) value(%s)", key, value);
+       if (NULL != key) {
+               if (0 == strncmp(SERVICE_ADAPTOR_3RD_PARTY_METADATA_KEY_VERSION, key,
+                               strlen(SERVICE_ADAPTOR_3RD_PARTY_METADATA_KEY_VERSION))) {
+                       service_adaptor_info("Discovered 3rd party Plugin with Service adaptor");
+                       service_adaptor_info("Package id : %s", ctx->package_id);
+                       service_adaptor_info("Compatible Version : over %s", value);
+                       ctx->version_defined = true;
+               } else if (0 == strncmp(SERVICE_ADAPTOR_3RD_PARTY_METADATA_KEY_AUTH, key, strlen(SERVICE_ADAPTOR_3RD_PARTY_METADATA_KEY_AUTH))) {
+                       if (NULL != value) {
+                               /*free(ctx->auth_plugin_path); */
+                               ctx->auth_plugin_path = strdup(value);
+                               ctx->auth_defined = true;
+                       }
+                       _service_adaptor_debug_func("auth plugin path : %s", value);
+               } else if (0 == strncmp(SERVICE_ADAPTOR_3RD_PARTY_METADATA_KEY_STORAGE, key, strlen(SERVICE_ADAPTOR_3RD_PARTY_METADATA_KEY_STORAGE))) {
+                       if (NULL != value) {
+                               /*free(ctx->storage_plugin_path); */
+                               ctx->storage_plugin_path = strdup(value);
+                               ctx->storage_defined = true;
+                       }
+                       _service_adaptor_debug_func("storage plugin path : %s", value);
+               }
+       }
+       free(key);
+       _FUNC_END();
+       if ((ctx->version_defined) && (ctx->auth_defined) && (ctx->storage_defined)) {
+               _service_adaptor_debug("Stop iter (All fields are filled)");
+               return false;
+       }
+       return true;
+
+}
+
+bool __service_adaptor_app_info_iterator_cb(package_info_app_component_type_e comp_type,
+                                               const char *app_id,
+                                               void *user_data)
+{
+       _FUNC_START();
+       int ret = 0;
+
+       _service_adaptor_debug("package app_info callback : type(%d), app_id(%s)\n",
+                       comp_type, app_id);
+       app_info_h app_info;
+       ret = app_info_create(app_id, &app_info);
+       if (!ret) {
+               ret = app_info_foreach_metadata(app_info,
+                               __service_adaptor_app_meta_iterator_cb, user_data);
+               _service_adaptor_debug("app_meta foreach res : %d\n", ret);
+               app_info_destroy(app_info);
+       } else {
+               _service_adaptor_debug("app_info creation failed (%d)", ret);
+       }
+
+       _FUNC_END();
+       return true;
+}
+
+service_adaptor_internal_error_code_e
+_service_adaptor_check_package(service_adaptor_h service_adaptor,
+                                               const char *_package_id)
+{
+       _FUNC_START();
+       int ret;
+       package_info_h p_info;
+       ret = package_manager_get_package_info(_package_id, &p_info);
+       _service_adaptor_debug("package info get(%d)\n", ret);
+
+       if (ret == 0) {
+               char *path = NULL;
+               ret = package_info_get_root_path(p_info, &path);
+               _service_adaptor_debug("package root path(%d) : %s\n", ret, path);
+
+               /* Init context */
+               struct package_checker_context_s ctx;
+               ctx.package_id = strdup(_package_id);
+               ctx.package_root = path;
+               ctx.auth_plugin_path = NULL;
+               ctx.storage_plugin_path = NULL;
+
+               ctx.version_defined = false;
+               ctx.auth_defined = false;
+               ctx.storage_defined = false;
+
+               ret = package_info_foreach_app_from_package(p_info, PACKAGE_INFO_ALLAPP,
+                               __service_adaptor_app_info_iterator_cb, (void *)&ctx);
+               _service_adaptor_debug("package app foreach (%d)\n", ret);
+               ret = package_info_destroy(p_info);
+
+               if (ctx.version_defined) {
+                       _service_adaptor_debug("Version is defined");
+                       if ((ctx.auth_defined) && (NULL != ctx.auth_plugin_path)) {
+                               auth_adaptor_h auth_adaptor = service_adaptor_get_auth_adaptor(service_adaptor);
+                               ret = auth_adaptor_load_plugin_from_package(auth_adaptor, _package_id, ctx.auth_plugin_path);
+                               _service_adaptor_info("auth plugin load ret (%d)", ret);
+                       }
+
+                       if ((ctx.storage_defined) && (NULL != ctx.storage_plugin_path)) {
+                               storage_adaptor_h storage_adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+                               ret = storage_adaptor_load_plugin_from_package(storage_adaptor, _package_id, ctx.storage_plugin_path);
+                               _service_adaptor_info("storage plugin load ret (%d)", ret);
+                       }
+               }
+
+               free(ctx.auth_plugin_path);
+               free(ctx.storage_plugin_path);
+       }
+       _FUNC_END();
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+
+void service_adaptor_package_event_callback(const char *type,
+                                               const char *package_id,
+                                               package_manager_event_type_e event_type,
+                                               package_manager_event_state_e event_state,
+                                               int progress,
+                                               package_manager_error_e error,
+                                               void *user_data)
+{
+       _FUNC_START();
+       _service_adaptor_debug("package callback\n");
+
+       int ret = 0;
+       /* TODO add handling when the package is updated */
+       if ((PACKAGE_MANAGER_EVENT_TYPE_INSTALL == event_type) && (PACKAGE_MANAGER_EVENT_STATE_COMPLETED  == event_state)) {
+               _service_adaptor_debug("New package installed <package type(%s) / name(%s)>",
+                               type, package_id);
+               ret = _service_adaptor_check_package((service_adaptor_h)user_data, package_id);
+               _service_adaptor_debug("Package check ret (%d)", ret);
+       }
+       _FUNC_END();
+}
+
+service_adaptor_internal_error_code_e
+service_adaptor_set_package_installed_callback(service_adaptor_h _service_adaptor)
+{
+       _FUNC_START();
+       int ret = 0;
+       package_manager_h p_manager;
+       package_manager_create(&p_manager);
+
+       ret = package_manager_set_event_cb(p_manager,
+                       service_adaptor_package_event_callback, (void *)_service_adaptor);
+       _service_adaptor_debug("package manager set event (%d)\n", ret);
+       g_package_manager = p_manager;
+
+       _FUNC_END();
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e
+service_adaptor_unset_package_installed_callback(service_adaptor_h _service_adaptor)
+{
+       _FUNC_START();
+       package_manager_h p_manager = g_package_manager;
+       if (NULL != p_manager) {
+               package_manager_unset_event_cb(p_manager);
+               package_manager_destroy(p_manager);
+
+               g_package_manager = NULL;
+               _service_adaptor_debug("package manager unset event");
+       }
+
+       _FUNC_END();
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+
+bool _service_adaptor_package_iterator_cb(package_info_h package_info,
+                                               void *user_data)
+{
+       int ret = 0;
+       char *package = NULL;
+       ret = package_info_get_package(package_info, &package);
+       _service_adaptor_debug("package info get package(%d) : name(%s)", ret, package);
+       if ((0 == ret) && (NULL != package)) {
+               ret = _service_adaptor_check_package((service_adaptor_h)user_data, package);
+       }
+       free(package);
+       return true;
+}
+
+service_adaptor_internal_error_code_e
+service_adaptor_scan_all_packages(service_adaptor_h _service_adaptor)
+{
+       int ret = 0;
+       ret = package_manager_foreach_package_info(_service_adaptor_package_iterator_cb, (void *)_service_adaptor);
+       _service_adaptor_debug("Scan all packages ret(%d)", ret);
+       return 0;       /*TODO */
+}
+
+
+void *_scanner_runnable(void *data)
+{
+       int ret = package_manager_foreach_package_info(_service_adaptor_package_iterator_cb, data);
+       _service_adaptor_debug("Scan all packages ret(%d)", ret);
+
+       return NULL;
+}
+
+service_adaptor_internal_error_code_e
+service_adaptor_scan_all_packages_async(service_adaptor_h _service_adaptor)
+{
+       pthread_t runnable;
+       pthread_create(&runnable, NULL, _scanner_runnable, (void *)_service_adaptor);
+       return 0;       /*TODO */
+}
+
diff --git a/src/service-adaptor-push.c b/src/service-adaptor-push.c
new file mode 100644 (file)
index 0000000..28628de
--- /dev/null
@@ -0,0 +1,780 @@
+/*
+* 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 <stdlib.h>
+#include <stdio.h>
+
+#include "service-adaptor.h"
+#include "service-adaptor-push.h"
+#include "service-adaptor-message.h"
+#include "service-adaptor-type.h"
+#include "service-adaptor-log.h"
+#include "dbus-ipc.h"
+#include "dbus-server.h"
+#include "dbus-service-adaptor.h"
+#include "dbus-push-adaptor.h"
+#include "push-adaptor.h"
+#include "message-adaptor.h"
+#include "util/service_file_manager.h"
+
+#include <gio/gio.h>
+
+
+/*************************************************
+ *               Type definition
+ *************************************************/
+
+#define PUSH_PLUGIN_PATH       "/usr/lib/push-adaptor/plugins"
+#define SERVICE_ADAPTOR_SERVICE_FILE_PATH      "/opt/share/service-adaptor/services/"
+#define SERVICE_ADAPTOR_PUSH_ENABLED_PATH      "/opt/share/service-adaptor/.push/"
+
+#define PUSH_SERVICE_FILE_KEY_PLUGIN_URI       "PluginUri"
+#define PUSH_SERVICE_FILE_KEY_APP_ID           "AppId"
+#define PUSH_SERVICE_FILE_KEY_SESSION_INFO     "SessionInfo"
+#define PUSH_SERVICE_FILE_KEY_BUS_TYPE         "BusType"
+#define PUSH_SERVICE_FILE_KEY_BUS_NAME         "BusName"
+#define PUSH_SERVICE_FILE_KEY_OBJ_PATH         "ObjectPath"
+#define PUSH_SERVICE_FILE_KEY_INTERFACE                "Interface"
+#define PUSH_SERVICE_FILE_KEY_METHOD           "Method"
+#define PUSH_SERVICE_FILE_KEY_EXEC             "ExecPath"
+
+
+/*************************************************
+ *               Global valuable
+ *************************************************/
+
+static GList *g_push_activate_list = NULL;
+
+static GMutex g_push_activate_mutex;
+
+static GMutex g_push_reconnect_mutex;
+
+
+/*************************************************
+ *               Internal function prototype
+ *************************************************/
+
+static push_activate_h _create_push_handle_by_service_file(service_file_h file);
+
+static void _add_push_service_file(const char *service_file_name);
+
+static void _remove_push_service_file(const char *service_file_name);
+
+static void _load_all_push_service_file(void);
+
+static void _unload_all_push_service_file(void);
+
+static void push_data_dbus_activate_callback(const char *app_id, const char *session_info, long long int timestamp, const char *data, const char *message);
+
+
+/*************************************************
+ *               Public function prototype
+ *************************************************/
+
+service_adaptor_internal_error_code_e service_adaptor_ref_enabled_push_services(push_activate_h **services, int *services_len);
+
+
+/*************************************************
+ *               Internal function definition
+ *************************************************/
+
+static push_activate_h _create_push_handle_by_service_file(service_file_h file)
+{
+       service_adaptor_debug("<Start> %s", __FUNCTION__);
+       push_activate_h handle = (push_activate_h) calloc(1, sizeof(push_activate_t));
+
+       int ret = 0;
+       char *values[9] = {NULL, };
+       if (NULL != handle) {
+               ret += service_file_get_string(file, SERVICE_FILE_SECTION_PUSH, PUSH_SERVICE_FILE_KEY_PLUGIN_URI, &values[0]);
+               ret += service_file_get_string(file, SERVICE_FILE_SECTION_PUSH, PUSH_SERVICE_FILE_KEY_APP_ID, &values[1]);
+               ret += service_file_get_string(file, SERVICE_FILE_SECTION_PUSH, PUSH_SERVICE_FILE_KEY_SESSION_INFO, &values[2]);
+               ret += service_file_get_string(file, SERVICE_FILE_SECTION_BUS, PUSH_SERVICE_FILE_KEY_BUS_TYPE, &values[3]);
+               ret += service_file_get_string(file, SERVICE_FILE_SECTION_BUS, PUSH_SERVICE_FILE_KEY_BUS_NAME, &values[4]);
+               ret += service_file_get_string(file, SERVICE_FILE_SECTION_BUS, PUSH_SERVICE_FILE_KEY_OBJ_PATH, &values[5]);
+               ret += service_file_get_string(file, SERVICE_FILE_SECTION_BUS, PUSH_SERVICE_FILE_KEY_INTERFACE, &values[6]);
+               ret += service_file_get_string(file, SERVICE_FILE_SECTION_BUS, PUSH_SERVICE_FILE_KEY_METHOD, &values[7]);
+               ret += service_file_get_string(file, SERVICE_FILE_SECTION_GENERAL, PUSH_SERVICE_FILE_KEY_EXEC, &values[8]);
+       } else {
+               service_adaptor_error("Memory allocation failed");
+               return NULL;
+       }
+
+       GBusType bus_type = G_BUS_TYPE_NONE;
+       if (NULL != values[3]) {
+               if (0 == strcmp("session", values[3])) {
+                       bus_type = G_BUS_TYPE_SESSION;
+               } else if (0 == strcmp("system", values[3])) {
+                       bus_type = G_BUS_TYPE_SYSTEM;
+               } else {
+                       service_adaptor_debug("Invalid bus type");
+                       ret += -10;
+               }
+       }
+
+       if (ret) {
+               service_adaptor_debug("Failed config exist (%d)", ret);
+               for (int i = 0; i < 9; i++) {
+                       free(values[i]);
+               }
+               free(handle);
+               handle = NULL;
+       } else {
+               handle->plugin_uri = values[0];
+               handle->app_id = values[1];
+               handle->session_info = values[2];
+               handle->bus_type = (int) bus_type;
+               free(values[3]);
+               handle->bus_name = values[4];
+               handle->object_path = values[5];
+               handle->interface = values[6];
+               handle->method = values[7];
+               handle->proxy = NULL;
+               handle->exec = values[8];
+       }
+
+       service_adaptor_debug("<End> %s", __FUNCTION__);
+       return handle;
+}
+
+static void _load_all_push_service_file()
+{
+       service_adaptor_debug("<Start> %s", __FUNCTION__);
+       char **files = NULL;
+       int len = 0;
+
+       int ret = service_file_get_list(SERVICE_FILE_DIRECTORY_PUSH, &files, &len);
+       if (ret) {
+               service_adaptor_debug("service file load failed");
+               return;
+       }
+
+/*     if ((NULL == files) || (0 >= len)) {
+               service_adaptor_debug("There is no files");
+               return;
+       }*/
+
+       service_adaptor_debug_func("<<<<<[LOCK] push-activate mutex");
+       g_mutex_lock(&g_push_activate_mutex);
+       for (int i = 0; i < len; i++) {
+               service_file_h service_file = NULL;
+               ret = service_file_load(SERVICE_FILE_DIRECTORY_PUSH, files[i], &service_file);
+
+               if (0 == ret && NULL != service_file) {
+                       push_activate_h _data = NULL;
+                       _data = _create_push_handle_by_service_file(service_file);
+
+                       if (NULL != _data) {
+                               service_adaptor_debug("push service file load success");
+                               g_push_activate_list = g_list_append(g_push_activate_list, (void *)_data);
+                               _data->file_name = files[i];
+                       } else {
+                               service_adaptor_debug("Config data load failed");
+                               free(files[i]);
+                       }
+
+               } else {
+                       service_adaptor_debug("File load failed");
+                       free(files[i]);
+               }
+               ret = service_file_unload(service_file);
+       }
+       g_mutex_unlock(&g_push_activate_mutex);
+       service_adaptor_debug_func(">>>>>[UNLOCK] push-activate mutex");
+
+       free(files);
+       service_adaptor_debug("<End> %s", __FUNCTION__);
+}
+
+static void _unload_all_push_service_file(void)
+{
+       service_adaptor_debug("<Start> %s", __FUNCTION__);
+
+       service_adaptor_debug_func("<<<<<[LOCK] push-activate mutex");
+       g_mutex_lock(&g_push_activate_mutex);
+       int len = g_list_length(g_push_activate_list);
+
+       for (int i = 0; i < len; i++) {
+               push_activate_h handle = (push_activate_h) g_list_nth_data(g_push_activate_list, i);
+
+               free(handle->file_name);
+               free(handle->plugin_uri);
+               free(handle->app_id);
+               free(handle->session_info);
+               free(handle->bus_name);
+               free(handle->object_path);
+               free(handle->interface);
+               free(handle->method);
+               if (NULL != handle->proxy) {
+                       g_object_unref(((GDBusProxy *)(handle->proxy)));
+               }
+               free(handle->exec);
+               free(handle);
+       }
+
+       g_list_free(g_push_activate_list);
+       g_push_activate_list = NULL;
+       g_mutex_unlock(&g_push_activate_mutex);
+       service_adaptor_debug_func(">>>>>[UNLOCK] push-activate mutex");
+       service_adaptor_debug("<End> %s", __FUNCTION__);
+}
+
+static void _add_push_service_file(const char *service_file_name)
+{
+       service_adaptor_debug("<Start> %s", __FUNCTION__);
+
+       service_adaptor_debug_func("<<<<<[LOCK] push-activate mutex");
+       g_mutex_lock(&g_push_activate_mutex);
+
+       char *file_name = strdup(service_file_name);
+
+       if (NULL == file_name) {
+               service_adaptor_debug("Memory allocation failed");
+               return;
+       }
+
+       service_file_h service_file = NULL;
+       int ret = service_file_load(SERVICE_FILE_DIRECTORY_PUSH, file_name, &service_file);
+
+       if (0 == ret && NULL != service_file) {
+               push_activate_h _data = NULL;
+               _data = _create_push_handle_by_service_file(service_file);
+
+               if (NULL != _data) {
+                       service_adaptor_debug("push service file load success");
+                       g_push_activate_list = g_list_append(g_push_activate_list, (void *)_data);
+                       _data->file_name = file_name;
+               } else {
+                       service_adaptor_debug("Config data load failed");
+                       free(file_name);
+               }
+
+       } else {
+               service_adaptor_debug("File load failed");
+               free(file_name);
+       }
+
+       ret = service_file_unload(service_file);
+
+       g_mutex_unlock(&g_push_activate_mutex);
+       service_adaptor_debug_func(">>>>>[UNLOCK] push-activate mutex");
+       service_adaptor_debug("<End> %s", __FUNCTION__);
+}
+
+static void _remove_push_service_file(const char *service_file)
+{
+       service_adaptor_debug("<Start> %s", __FUNCTION__);
+
+       service_adaptor_debug_func("<<<<<[LOCK] push-activate mutex");
+       g_mutex_lock(&g_push_activate_mutex);
+
+       push_activate_h handle = NULL;
+
+       int len = g_list_length(g_push_activate_list);
+
+       for (int i = 0; i < len; i++) {
+               push_activate_h _data = (push_activate_h) g_list_nth_data(g_push_activate_list, i);
+               if (0 == strcmp(_data->file_name, service_file)) {
+                       handle = _data;
+                       break;
+               }
+       }
+
+       if (NULL != handle) {
+               g_push_activate_list = g_list_remove(g_push_activate_list, (void *) handle);
+
+               free(handle->file_name);
+               free(handle->plugin_uri);
+               free(handle->app_id);
+               free(handle->session_info);
+               free(handle->bus_name);
+               free(handle->object_path);
+               free(handle->interface);
+               free(handle->method);
+               if (NULL != handle->proxy) {
+                       g_object_unref(((GDBusProxy *)(handle->proxy)));
+               }
+               free(handle->exec);
+               free(handle);
+       }
+
+       g_mutex_unlock(&g_push_activate_mutex);
+       service_adaptor_debug_func(">>>>>[UNLOCK] push-activate mutex");
+
+       service_adaptor_debug("<End> %s", __FUNCTION__);
+}
+
+
+/***********************************************************
+ * Push adaptor callback
+ ***********************************************************/
+
+void service_adaptor_push_adaptor_on_notification_received(push_adaptor_notification_data_h notification,
+                                               void *user_data)
+{
+       service_adaptor_debug("Push adaptor notification callback");
+
+       if ((NULL == notification) || (NULL == notification->session_info)) {
+               service_adaptor_error("Could not get session info");
+               return;
+       }
+
+       service_adaptor_info("(%s) - Data: %s\n MSG: %s\n Time:%lld", notification->session_info, notification->data, notification->msg, notification->time_stamp);
+
+       uint32_t service_id = 0;
+
+       service_adaptor_h service_adaptor = service_adaptor_get_handle();
+       if (0 == strncmp(notification->session_info, "0", 1)) {
+               service_id = 0;
+       } else if (0 == strncmp(notification->session_info, "1", 1)) {
+               service_id = 1;
+
+               message_adaptor_h adaptor = service_adaptor_get_message_adaptor(service_adaptor);
+
+               if (NULL == adaptor) {
+                       service_adaptor_error("Invalid Param");
+                       return;
+               }
+
+               for (GList * list = g_list_first(service_adaptor->service_list); list != NULL; list = g_list_next(list)) {
+                       int ret = 0;
+                       char *decode_msg = NULL;
+                       message_adaptor_error_code_h error_code = NULL;
+
+                       service_adaptor_service_context_h service = (service_adaptor_service_context_h) list->data;
+                       if ((NULL == service) || (NULL == service->message_context)) {
+                               continue;
+                       }
+
+                       message_adaptor_plugin_h plugin = message_adaptor_get_plugin_by_name(adaptor, service->plugin_uri);
+
+                       if (NULL == plugin) {
+                               service_adaptor_error("Could not find a plugin");
+                               continue;
+                       }
+
+                       ret = message_adaptor_decode_push_message(plugin, service->message_context, notification->data, &decode_msg, &error_code);
+
+                       if (MESSAGE_ADAPTOR_ERROR_NONE == ret) {
+                               free(notification->data);
+                               notification->data = decode_msg;
+                               break;
+                       }
+
+                       if (NULL != error_code) {
+                               message_adaptor_destroy_error_code(&error_code);
+                       }
+               }
+
+       } else if (0 == strncmp(notification->session_info, "2", 1)) {
+               service_id = 2;
+       } else {
+               service_adaptor_error("Could not get session info");
+               return;
+       }
+
+       service_adaptor_internal_error_t error;
+       error.code = 0;
+       error.msg = strdup("");
+
+
+       dbus_push_data_callback(service_id, notification, &error, NULL);
+       free(error.msg);
+
+       push_data_dbus_activate_callback(notification->app_id, notification->session_info, notification->time_stamp, notification->data, notification->msg);
+}
+
+push_adaptor_h service_adaptor_get_push_adaptor(service_adaptor_h service_adaptor)
+{
+       service_adaptor_debug("Get push adaptor");
+
+       if ((void *) NULL == service_adaptor) {
+               service_adaptor_error("Invalid argument");
+               return NULL;
+       }
+
+       return service_adaptor->push_handle;
+}
+
+push_adaptor_plugin_context_h service_adaptor_get_push_context(service_adaptor_h service_adaptor,
+                                               const char *imsi,
+                                               const char *app_id)
+{
+       service_adaptor_debug("Get push context");
+
+       return NULL;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_connect_push_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service,
+                                               char *ret_msg)
+{
+       service_adaptor_debug("Connect to push plugin");
+
+       if ((NULL == service_adaptor) || (NULL == service)) {
+               service_adaptor_error("Invalid parameter");
+               snprintf(ret_msg, 2048, "push plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       push_adaptor_h adaptor = service_adaptor_get_push_adaptor(service_adaptor);
+       push_adaptor_plugin_h plugin = push_adaptor_get_plugin_by_name(adaptor, service->plugin_uri);
+
+       if (NULL == plugin) {
+               service_adaptor_warning("Invalid plugin");
+               snprintf(ret_msg, 2048, "push plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       } else if (NULL == service->context_info) {
+               service_adaptor_warning("Invalid service->context_info");
+               snprintf(ret_msg, 2048, "push plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       } else if (NULL == service->context_info->app_id) {
+               service_adaptor_warning("Invalid app_id");
+               snprintf(ret_msg, 2048, "push plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       push_adaptor_plugin_context_h push_context = push_adaptor_create_plugin_context(plugin,
+                       service->plugin_uri, service->context_info->app_id);
+
+       if (NULL == push_context) {
+               service_adaptor_error("Could not create plugin context: %s", service->service_name);
+               snprintf(ret_msg, 2048, "push plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_CREATE;
+       }
+/*
+       // Set server info
+       int ret = 0;
+       push_adaptor_error_code_h error = NULL;
+       ret = push_adaptor_set_server_info(plugin, push_context, service->server_info, NULL, &error, NULL);
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_warning("Could not set push plugin server information: %d", ret);
+               if (NULL != error) {
+                       service_adaptor_warning("[%lld] %s", error->code, error->msg);
+               }
+               push_adaptor_destroy_error_code(&error);
+       }
+*/
+       push_adaptor_error_code_h error = NULL;
+       SERVICE_ADAPTOR_API_TIME_CHECK_PAUSE();
+       SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_START(SA_TIME_CHECK_FLAG_PUSH);
+
+       service_adaptor_debug_func("<<<<<[LOCK] push-reconnect mutex");
+       g_mutex_lock(&g_push_reconnect_mutex);
+
+       push_adaptor_connect(plugin, push_context, &error);
+
+       g_mutex_unlock(&g_push_reconnect_mutex);
+       service_adaptor_debug_func(">>>>>[UNLOCK] push-reconnect mutex");
+
+       SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_PAUSE(SA_TIME_CHECK_FLAG_PUSH);
+       SERVICE_ADAPTOR_API_TIME_CHECK_START();
+
+       service->push_context = push_context;
+       service->connected |= 0x1000000;
+       push_adaptor_destroy_error_code(&error);
+       service_adaptor_debug("Connected to push plugin");
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_disconnect_push_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service)
+{
+       service_adaptor_debug("Disconnect from push plugin");
+
+       if (NULL != service) {
+               if (service->push_context) {
+                       service_adaptor_debug("Input NULL to push_context");
+                       service->push_context = NULL;
+               }
+       }
+
+       service_adaptor_debug("Disconnected from push plugin");
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_reconnect_push_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service)
+{
+       service_adaptor_info("Reconnect push plugin");
+
+       if ((NULL != service) && (NULL != service->push_context)) {
+               push_adaptor_h adaptor = service_adaptor_get_push_adaptor(service_adaptor);
+               push_adaptor_plugin_h plugin = push_adaptor_get_plugin_by_name(adaptor, service->plugin_uri);
+               if (NULL != plugin) {
+                       push_adaptor_error_code_h error = NULL;
+                       push_error_code_t push_ret;
+
+                       service_adaptor_debug_func("<<<<<[LOCK] push-reconnect mutex");
+                       g_mutex_lock(&g_push_reconnect_mutex);
+                       int connected = 0;
+                       push_ret = push_adaptor_is_connected(plugin, service->push_context, &connected);
+
+                       if (connected != PUSH_ADAPTOR_STATE_CONNECTED) {
+                               service_adaptor_debug("Disconnect push");
+
+                               push_ret = push_adaptor_disconnect(plugin, service->push_context, &error);
+                               service_adaptor_debug_func("Disconnect ret (%d)", push_ret);
+                               if (error) {
+                                       service_adaptor_error("error : %lld, %s", (long long int) error->code, error->msg);
+                                       push_adaptor_destroy_error_code(&error);
+                                       error = NULL;
+                               }
+
+                               service_adaptor_debug("Connect push");
+                               push_ret = push_adaptor_connect(plugin, service->push_context, &error);
+                               service_adaptor_debug_func("Connect ret (%d)", push_ret);
+                       } else {
+                               service_adaptor_debug("Keep legacy connection");
+                       }
+                       g_mutex_unlock(&g_push_reconnect_mutex);
+                       service_adaptor_debug_func(">>>>>[UNLOCK] push-reconnect mutex");
+
+                       if (error) {
+                               service_adaptor_error("error : %lld, %s", (long long int) error->code, error->msg);
+                               push_adaptor_destroy_error_code(&error);
+                               error = NULL;
+                       }
+                       if (PUSH_ADAPTOR_ERROR_NONE != push_ret) {
+                               return SERVICE_ADAPTOR_INTERNAL_ERROR_ADAPTOR_INTERNAL;
+                       }
+               } else {
+                       service_adaptor_warning("There is no push plugin (uri:%s)", service->plugin_uri);
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_ADAPTOR_INTERNAL;
+               }
+       } else {
+               service_adaptor_warning("There is no push context (%p)(%p)", service, (service ? service->push_context : NULL));
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_ADAPTOR_INTERNAL;
+       }
+
+       service_adaptor_info("Reconnected push plugin");
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+push_adaptor_h service_adaptor_create_push()
+{
+       push_adaptor_h push_adaptor = push_adaptor_create(PUSH_PLUGIN_PATH);
+
+       if ((void *) NULL == push_adaptor) {
+               service_adaptor_error("Could not create push adaptor");
+               return NULL;
+       }
+
+       service_adaptor_debug("Push adaptor created");
+
+       _load_all_push_service_file();
+
+       return push_adaptor;
+}
+
+void service_adaptor_destroy_push(push_adaptor_h push_handle)
+{
+       if ((void *) NULL == push_handle) {
+               service_adaptor_error("Could not create push adaptor");
+               return;
+       }
+
+       push_adaptor_destroy(push_handle);
+
+       service_adaptor_debug("Push adaptor destroied");
+
+       _unload_all_push_service_file();
+}
+
+
+push_adaptor_listener_h service_adaptor_register_push_listener(push_adaptor_h push_adaptor)
+{
+       if ((void *) NULL == push_adaptor) {
+               service_adaptor_error("Could not create push adaptor");
+               return NULL;
+       }
+
+       push_adaptor_listener_h push_listener =
+                       (push_adaptor_listener_h) malloc(sizeof(push_adaptor_listener_t));
+
+       if ((void *) NULL == push_listener) {
+               service_adaptor_error("Could not create push listener");
+               return NULL;
+       }
+
+       push_listener->_on_notification_received = service_adaptor_push_adaptor_on_notification_received;
+
+       push_adaptor_register_listener(push_adaptor, push_listener);
+       service_adaptor_debug("Push adaptor listener created");
+
+       return push_listener;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_push_register(const char *service_file, char **error_msg)
+{
+       service_adaptor_debug("<Start> %s", __FUNCTION__);
+       service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+
+       if (NULL == service_file) {
+               *error_msg = strdup("Invalid service file name");
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       char *src_path = g_strconcat(SERVICE_ADAPTOR_SERVICE_FILE_PATH, service_file, NULL);
+       char *dst_path = g_strconcat(SERVICE_ADAPTOR_PUSH_ENABLED_PATH, service_file, NULL);
+
+       if ((NULL == src_path) || (NULL == dst_path)) {
+               free(src_path);
+               free(dst_path);
+               *error_msg = strdup("Critical : Memory allocation failed");
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_ADAPTOR_INTERNAL;
+       }
+
+       int r = 0;
+       if ((r = access(src_path, O_RDONLY))) {
+               service_adaptor_error("File access failed (readonly)(%d): %s", r, service_file);
+               *error_msg = strdup("File access failed (readonly)");
+               ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_FOUND;
+       } else {
+               remove(dst_path);
+               _remove_push_service_file(service_file);
+               if ((r = symlink(src_path, dst_path))) {
+                       service_adaptor_error("push register failed(%d): %s", r, service_file);
+                       *error_msg = strdup("Push register failed (symlink fail)");
+                       ret = SERVICE_ADAPTOR_INTERNAL_ERROR_ADAPTOR_INTERNAL;
+               } else {
+                       _add_push_service_file(service_file);
+                       service_adaptor_info("push registered: %s", service_file);
+               }
+       }
+
+       free(src_path);
+       free(dst_path);
+
+       service_adaptor_debug("<End> %s", __FUNCTION__);
+       return ret;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_push_deregister(const char *service_file, char **error_msg)
+{
+       service_adaptor_debug("<Start> %s", __FUNCTION__);
+       service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+
+       if (NULL == service_file) {
+               *error_msg = strdup("Invalid service file name");
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       char *dst_path = g_strconcat(SERVICE_ADAPTOR_PUSH_ENABLED_PATH, service_file, NULL);
+
+       if (NULL == dst_path) {
+               free(dst_path);
+               *error_msg = strdup("Critical : Memory allocation failed");
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_ADAPTOR_INTERNAL;
+       }
+
+       remove(dst_path);
+       _remove_push_service_file(service_file);
+       service_adaptor_info("push deregistered: %s", service_file);
+
+       free(dst_path);
+
+       service_adaptor_debug("<End> %s", __FUNCTION__);
+       return ret;
+}
+
+static void push_data_dbus_activate_callback(const char *app_id,
+                                               const char *session_info,
+                                               long long int timestamp,
+                                               const char *push_data,
+                                               const char *message)
+{
+       service_adaptor_debug("<Start> %s", __FUNCTION__);
+       int len = g_list_length(g_push_activate_list);
+
+       push_activate_h data = NULL;
+
+       service_adaptor_debug("Registered push clitns (%d)", len);
+       for (int i = 0; i < len; i++) {
+               data = (push_activate_h) g_list_nth_data(g_push_activate_list, i);
+               if ((0 == strcmp(app_id, data->app_id)) &&
+                               (0 == strcmp(session_info, data->session_info))) {
+                       service_adaptor_debug("Catched push client (%s)(%s)", app_id, session_info);
+                       dbus_send_to_push_with_activation(data->bus_type, data->bus_name,
+                                       data->object_path, data->interface, data->method, &(data->proxy),
+                                       timestamp, push_data, message);
+               }
+       }
+       service_adaptor_debug("<End> %s", __FUNCTION__);
+}
+
+service_adaptor_internal_error_code_e service_adaptor_ref_enabled_push_services(push_activate_h **services, int *services_len)
+{
+       service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       if ((NULL == services) || (NULL == services_len)) {
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       service_adaptor_debug("<Start> %s", __FUNCTION__);
+       int len = g_list_length(g_push_activate_list);
+
+       push_activate_h data = NULL;
+       push_activate_h svc_data = NULL;
+       GList *svc = NULL;
+
+       service_adaptor_debug("Registered push clitns (%d)", len);
+       for (int i = 0; i < len; i++) {
+               data = (push_activate_h) g_list_nth_data(g_push_activate_list, i);
+
+               bool exist = false;
+               int jlen = g_list_length(svc);
+               for (int j = 0; j < jlen; j++) {
+                       svc_data = (push_activate_h) g_list_nth_data(svc, j);
+                       if ((0 == strcmp(data->plugin_uri, svc_data->plugin_uri)) &&
+                                       (0 == strcmp(data->app_id, svc_data->app_id))) {
+                               exist = true;
+                               break;
+                       }
+               }
+               if (false == exist) {
+                       svc = g_list_append(svc, (void *) data);
+                       service_adaptor_debug_func("Appended : plugin_uri(%s) app_id(%s)", data->plugin_uri, data->app_id);
+               }
+       }
+
+       int res_len = g_list_length(svc);
+       service_adaptor_debug("Enabled query res len(%d)", res_len);
+
+       push_activate_h *acts = NULL;
+       if (0 < res_len) {
+               acts = (push_activate_h *) calloc(res_len, sizeof(push_activate_h));
+               if (NULL != acts) {
+                       for (int k = 0; k < res_len; k++) {
+                               acts[k] = (push_activate_h) g_list_nth_data(svc, k);
+                       }
+               } else {
+                       service_adaptor_error("Memory allocation failed");
+                       ret = SERVICE_ADAPTOR_INTERNAL_ERROR_ADAPTOR_INTERNAL;
+               }
+       } else {
+               service_adaptor_debug("There is no enabled push service");
+               ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NO_DATA;
+       }
+       g_list_free(svc);
+
+       *services = acts;
+       *services_len = res_len;
+
+       service_adaptor_debug("<End> %s", __FUNCTION__);
+       return ret;
+}
diff --git a/src/service-adaptor-shop.c b/src/service-adaptor-shop.c
new file mode 100644 (file)
index 0000000..935df7b
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+* 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 "service-adaptor.h"
+#include "service-adaptor-shop.h"
+#include "service-adaptor-type.h"
+#include "service-adaptor-log.h"
+#include "dbus-ipc.h"
+#include "dbus-server.h"
+#include "dbus-service-adaptor.h"
+#include "dbus-shop-adaptor.h"
+#include "shop-adaptor.h"
+
+#define SHOP_PLUGIN_PATH       "/usr/lib/shop-adaptor/plugins"
+#define APP_TYPE               "FM"
+
+shop_adaptor_h service_adaptor_get_shop_adaptor(service_adaptor_h service_adaptor)
+{
+       service_adaptor_debug("Get shop adaptor");
+
+       if ((void *) NULL == service_adaptor) {
+               service_adaptor_error("Invalid argument");
+               return NULL;
+       }
+
+       return service_adaptor->shop_handle;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_connect_shop_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service,
+                                               char *ret_msg)
+{
+       service_adaptor_debug("Connect to shop plugin");
+
+       if ((NULL == service_adaptor) || (NULL == service)) {
+               service_adaptor_error("Invalid parameter");
+               snprintf(ret_msg, 2048, "shop plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       shop_adaptor_h adaptor = service_adaptor_get_shop_adaptor(service_adaptor);
+       shop_adaptor_plugin_h plugin = shop_adaptor_get_plugin_by_name(adaptor, service->plugin_uri);
+
+       if (NULL == service->context_info) {
+               service_adaptor_error("Invalid service->context_info");
+               snprintf(ret_msg, 2048, "shop plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       } else if ((NULL == service->context_info->duid)
+                       || (NULL == service->context_info->access_token)) {
+               service_adaptor_error("Invalid duid or access_token");
+               service_adaptor_debug_secure("Invalid duid or access_token: %s, %s",
+                               service->context_info->duid, service->context_info->access_token);
+               snprintf(ret_msg, 2048, "shop plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       shop_adaptor_plugin_context_h shop_context = shop_adaptor_create_plugin_context(
+                       plugin, service->plugin_uri, service->context_info->duid,
+                       service->context_info->access_token, service->context_info->app_id, APP_TYPE);
+
+       if (NULL == shop_context) {
+               service_adaptor_debug_func("Could not get shop plugin context");
+               service_adaptor_debug_secure("Could not get shop plugin context: %s, %s",
+                               service->context_info->duid, service->context_info->access_token);
+               snprintf(ret_msg, 2048, "shop plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_CORRUPTED;
+       }
+
+       /* Set server info */
+       int ret = 0;
+       shop_adaptor_error_code_h error = NULL;
+       SERVICE_ADAPTOR_API_TIME_CHECK_PAUSE();
+       SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_START(SA_TIME_CHECK_FLAG_SHOP);
+       ret = shop_adaptor_set_server_info(plugin, shop_context, service->server_info, &error);
+       SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_PAUSE(SA_TIME_CHECK_FLAG_SHOP);
+       SERVICE_ADAPTOR_API_TIME_CHECK_START();
+       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_warning("Could not set shop plugin server information: %d", ret);
+               if (NULL != error) {
+                       service_adaptor_warning("[%lld] %s", error->code, error->msg);
+               }
+               shop_adaptor_destroy_error_code(&error);
+       }
+
+       service->shop_context = shop_context;
+       service->connected |= 0x0001000;
+
+       service_adaptor_debug("Connected to shop plugin");
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_disconnect_shop_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service)
+{
+       service_adaptor_debug("Disconnect from shop plugin");
+
+       service_adaptor_debug("get shop adaptor");
+       shop_adaptor_h shop_adaptor = service_adaptor_get_shop_adaptor(service_adaptor);
+       if ((NULL != service->shop_context) && (NULL != shop_adaptor)) {
+               service_adaptor_debug("disconnects shop");
+               FUNC_STEP();
+               shop_adaptor_plugin_h shop_plugin = shop_adaptor_get_plugin_by_name(shop_adaptor, service->shop_context->plugin_uri);
+
+               if (NULL == shop_plugin) {
+                       service_adaptor_error("Cannot find plugin");
+               } else {
+                       service_adaptor_debug("dsetroys shop context");
+                       shop_adaptor_destroy_plugin_context(shop_plugin, service->shop_context);
+                       service->shop_context = NULL;
+               }
+       }
+
+       service_adaptor_debug("Disconnected from shop plugin");
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+shop_adaptor_h service_adaptor_create_shop()
+{
+       shop_adaptor_h shop_adaptor = shop_adaptor_create(SHOP_PLUGIN_PATH);
+
+       if (NULL == shop_adaptor) {
+               service_adaptor_error("Could not create shop adaptor");
+               return NULL;
+       }
+
+       service_adaptor_debug("Shop adaptor created");
+
+       return shop_adaptor;
+}
+
+shop_adaptor_listener_h service_adaptor_register_shop_listener(shop_adaptor_h shop_adaptor)
+{
+       if (NULL == shop_adaptor) {
+               service_adaptor_error("Could not create shop adaptor");
+               return NULL;
+       }
+
+       shop_adaptor_listener_h shop_listener =
+                       (shop_adaptor_listener_h) malloc(sizeof(shop_adaptor_listener_t));
+
+       return shop_listener;
+}
diff --git a/src/service-adaptor-storage.c b/src/service-adaptor-storage.c
new file mode 100644 (file)
index 0000000..5ae337f
--- /dev/null
@@ -0,0 +1,307 @@
+/*
+* 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 "service-adaptor.h"
+#include "service-adaptor-storage.h"
+#include "service-adaptor-type.h"
+#include "service-adaptor-log.h"
+#include "dbus-ipc.h"
+#include "dbus-server.h"
+#include "dbus-service-adaptor.h"
+#include "dbus-storage-adaptor.h"
+#include "storage-adaptor.h"
+
+#define STORAGE_PLUGIN_PATH    "/usr/lib/storage-adaptor/plugins"
+
+/***********************************************************
+ * Storage adaptor callback
+ ***********************************************************/
+/* private feature */
+void service_adaptor_storage_adaptor_download_file_async_cb(void *download_request_id,
+                                               char *download_file_local_path,
+                                               storage_adaptor_error_code_h error,
+                                               void *response)
+{
+       service_adaptor_debug("Storage adaptor download finished");
+       service_adaptor_info("Download path: %s", download_file_local_path);
+
+       storage_adaptor_error_code_t _error;
+       _error.code = 0LL;
+       _error.msg = NULL;
+
+       if (NULL == error) {
+               error = &_error;
+       }
+
+       if (0 >= (int32_t) download_request_id) {
+               service_adaptor_error("%s (%lld)", error->msg, error->code);
+               return;
+       }
+
+       private_dbus_storage_file_transfer_completion_callback((int32_t) download_request_id, NULL, error, NULL);
+}
+
+void service_adaptor_storage_adaptor_upload_file_async_cb(void *upload_request_id,
+                                               storage_adaptor_file_info_h file_info,
+                                               storage_adaptor_error_code_h error,
+                                               void *response)
+{
+       service_adaptor_debug("Storage adaptor upload finished");
+
+       if ((NULL != file_info) && (NULL != file_info->storage_path)) {
+               service_adaptor_info("Upload path: %s", file_info->storage_path);
+       }
+
+       storage_adaptor_error_code_t _error;
+       _error.code = 0LL;
+       _error.msg = NULL;
+
+       if (NULL == error) {
+               error = &_error;
+       }
+
+       if (0 >= (int32_t) upload_request_id) {
+               service_adaptor_error("%s (%lld)", error->msg, error->code);
+               return;
+       }
+
+       char *publish_url = NULL;
+       char publish_url_str[1000] = {0,};
+
+       if ((NULL != file_info) && (NULL != file_info->file_share_token)) {
+               snprintf(publish_url_str, 1000, "%s?auth_code=%s", file_info->file_share_token->public_token, file_info->file_share_token->auth_code);
+               publish_url = publish_url_str;
+       }
+
+       private_dbus_storage_file_transfer_completion_callback((int32_t) upload_request_id, publish_url, error, NULL);
+}
+
+void service_adaptor_storage_adaptor_file_transfer_progress_cb(void *transfer_request_id, unsigned long long progress_size, unsigned long long total_size, storage_adaptor_error_code_h error, void *response)
+{
+       service_adaptor_debug("Storage adaptor transfer progress");
+       service_adaptor_debug("\t===transfer id   : %d", (int)transfer_request_id);
+       service_adaptor_debug("\t===progress size : %llu", progress_size);
+       service_adaptor_debug("\t===total size    : %llu", total_size);
+
+       storage_adaptor_error_code_t _error;
+       _error.code = 0LL;
+       _error.msg = NULL;
+
+       if (NULL == error) {
+               error = &_error;
+       }
+
+       if (0 >= (int32_t) transfer_request_id) {
+               service_adaptor_error("%s (%lld)", error->msg, error->code);
+               return;
+       }
+
+       private_dbus_storage_file_progress_callback((int32_t) transfer_request_id, progress_size, total_size, error, NULL);
+}
+
+/* public feature */
+void service_adaptor_storage_adaptor_download_state_changed_cb(long long int file_uid,
+                                               storage_adaptor_transfer_state_e state,
+                                               storage_adaptor_error_code_h error,
+                                               void *user_data)
+{
+       service_adaptor_debug("Storage adaptor download finished");
+
+       storage_adaptor_error_code_t _error;
+       _error.code = 0LL;
+       _error.msg = NULL;
+
+       if (NULL == error) {
+               error = &_error;
+       }
+
+       dbus_storage_file_transfer_state_changed_callback(file_uid, state, error);
+}
+
+void service_adaptor_storage_adaptor_upload_state_changed_cb(long long int file_uid,
+                                               storage_adaptor_transfer_state_e state,
+                                               storage_adaptor_file_info_h file_info,
+                                               storage_adaptor_error_code_h error,
+                                               void *user_data)
+{
+       service_adaptor_debug("Storage adaptor upload finished");
+
+       storage_adaptor_error_code_t _error;
+       _error.code = 0LL;
+       _error.msg = NULL;
+
+       if (NULL == error) {
+               error = &_error;
+       }
+
+       dbus_storage_file_transfer_state_changed_callback(file_uid, state, error);
+}
+
+void service_adaptor_storage_adaptor_task_progress_cb(long long int file_uid,
+                                               unsigned long long progress_size,
+                                               unsigned long long total_size)
+{
+       service_adaptor_debug("Storage adaptor transfer progress");
+
+       service_adaptor_debug("\t===transfer id   : %lld", file_uid);
+       service_adaptor_debug("\t===progress size : %llu", progress_size);
+       service_adaptor_debug("\t===total size    : %llu", total_size);
+
+       dbus_storage_file_progress_callback(file_uid, progress_size, total_size);
+}
+
+storage_adaptor_h service_adaptor_get_storage_adaptor(service_adaptor_h service_adaptor)
+{
+       service_adaptor_debug("Get storage adaptor");
+
+       if ((void *) NULL == service_adaptor) {
+               service_adaptor_error("Invalid argument");
+               return NULL;
+       }
+
+       return service_adaptor->storage_handle;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_connect_storage_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service,
+                                               const char *app_secret,
+                                               char *ret_msg)
+{
+       service_adaptor_debug("Connect to storage plugin");
+
+       if ((NULL == service_adaptor) || (NULL == service)) {
+               service_adaptor_error("Invalid parameter");
+               snprintf(ret_msg, 2048, "storage plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       storage_adaptor_h adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+       storage_adaptor_plugin_h plugin = storage_adaptor_get_plugin_by_name(adaptor, service->plugin_uri);
+
+       if ((NULL == service->context_info) || (NULL == service->service_name)) {
+               service_adaptor_error("Invalid service_name or plugin_uri: %s, %s",
+                               service->service_name, service->plugin_uri);
+               snprintf(ret_msg, 2048, "storage plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       storage_adaptor_plugin_context_h storage_context = storage_adaptor_create_plugin_context(
+                       plugin, service->context_info->app_id, app_secret,
+                       service->context_info->access_token, service->context_info->user_id,
+                       service->context_info->duid, service->service_name);
+
+       if (NULL == storage_context) {
+               service_adaptor_debug_func("Could not get storage plugin context: %s", service->service_name);
+               snprintf(ret_msg, 2048, "storage plugin connect failed [%d]", (int)__LINE__);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_CORRUPTED;
+       }
+
+       /* Set server info */
+       int ret = 0;
+       storage_adaptor_error_code_h error = NULL;
+       SERVICE_ADAPTOR_API_TIME_CHECK_PAUSE();
+       SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_START(SA_TIME_CHECK_FLAG_STORAGE);
+       ret = storage_adaptor_set_server_info(plugin, storage_context, service->server_info, NULL, &error, NULL);
+       SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_PAUSE(SA_TIME_CHECK_FLAG_STORAGE);
+       SERVICE_ADAPTOR_API_TIME_CHECK_START();
+       if (STORAGE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_warning("Could not set storage plugin server information: %d", ret);
+               if (NULL != error) {
+                       service_adaptor_warning("[%lld] %s", error->code, error->msg);
+               }
+               storage_adaptor_destroy_error_code(&error);
+       }
+
+       service->storage_context = storage_context;
+       service->connected |= 0x0100000;
+
+       service_adaptor_debug("Connected to storage plugin");
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_disconnect_storage_plugin(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service)
+{
+       service_adaptor_debug("Disconnect from storage plugin");
+
+       service_adaptor_debug("get storage adaptor");
+       storage_adaptor_h storage_adaptor = service_adaptor_get_storage_adaptor(service_adaptor);
+       if ((NULL != service->storage_context) && (NULL != storage_adaptor)) {
+               service_adaptor_debug("disconnects storage");
+               FUNC_STEP();
+               storage_adaptor_plugin_h storage_plugin = storage_adaptor_get_plugin_by_name(storage_adaptor, service->storage_context->plugin_uri);
+
+               if (NULL == storage_plugin) {
+                       service_adaptor_error("Cannot find plugin");
+               } else {
+                       service_adaptor_debug("dsetroys storage context");
+                       storage_adaptor_destroy_plugin_context(storage_plugin, service->storage_context);
+                       service->storage_context = NULL;
+               }
+       }
+
+       service_adaptor_debug("Disconnected from storage plugin");
+
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+storage_adaptor_h service_adaptor_create_storage()
+{
+       storage_adaptor_h storage_adaptor = storage_adaptor_create(STORAGE_PLUGIN_PATH);
+
+       if (NULL == storage_adaptor) {
+               service_adaptor_error("Could not create storage adaptor");
+               return NULL;
+       }
+
+       service_adaptor_debug("Storage adaptor created");
+
+       return storage_adaptor;
+}
+
+storage_adaptor_listener_h service_adaptor_register_storage_listener(storage_adaptor_h storage_adaptor)
+{
+       if (NULL == storage_adaptor) {
+               service_adaptor_error("Could not create storage adaptor");
+               return NULL;
+       }
+
+       storage_adaptor_listener_h storage_listener =
+               (storage_adaptor_listener_h) malloc(sizeof(storage_adaptor_listener_t));
+
+       if ((void *) NULL == storage_listener) {
+               service_adaptor_error("Could not create storage listener");
+               return NULL;
+       }
+
+       /* private feature */
+       storage_listener->download_file_async_reply = service_adaptor_storage_adaptor_download_file_async_cb;
+       storage_listener->upload_file_async_reply   = service_adaptor_storage_adaptor_upload_file_async_cb;
+       storage_listener->file_transfer_progress_reply = service_adaptor_storage_adaptor_file_transfer_progress_cb;
+
+       /* public feature */
+       storage_listener->download_state_changed_reply = service_adaptor_storage_adaptor_download_state_changed_cb;
+       storage_listener->upload_state_changed_reply   = service_adaptor_storage_adaptor_upload_state_changed_cb;
+       storage_listener->task_progress_reply = service_adaptor_storage_adaptor_task_progress_cb;
+
+       storage_adaptor_register_listener(storage_adaptor, storage_listener);
+       service_adaptor_debug("Storage adaptor listener created");
+
+       return storage_listener;
+}
diff --git a/src/service-adaptor.c b/src/service-adaptor.c
new file mode 100644 (file)
index 0000000..9d980aa
--- /dev/null
@@ -0,0 +1,1414 @@
+/*
+* 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 <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <glib-object.h>
+#include <glib-unix.h>
+
+#include "service-adaptor.h"
+#include "service-adaptor-auth.h"
+#include "service-adaptor-contact.h"
+#include "service-adaptor-message.h"
+#include "service-adaptor-shop.h"
+#include "service-adaptor-storage.h"
+#include "service-adaptor-push.h"
+#include "service-adaptor-plugin.h"
+#include "service-adaptor-type.h"
+#include "service-adaptor-log.h"
+#include "dbus-ipc.h"
+#include "dbus-server.h"
+#include "dbus-service-adaptor.h"
+#include "util/client_checker.h"
+
+#include <bundle.h>
+
+service_adaptor_h g_service_adaptor = (void *) NULL;
+
+static char *safe_strdup(const char *str)
+{
+       if (NULL == str) {
+               return NULL;
+       } else {
+               return strdup(str);
+       }
+}
+
+static void safe_free(void **ptrptr)
+{
+       if (ptrptr != NULL && *ptrptr != NULL) {
+               free(*ptrptr);
+               *ptrptr = NULL;
+       }
+}
+
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+#define __init_context_info_s(x)        do { \
+                                                (x).user_id = NULL; \
+                                                (x).app_id = NULL; \
+                                                (x).service_id = 0U; \
+                                                (x).imsi = NULL; \
+                                                (x).duid = NULL; \
+                                                (x).msisdn = NULL; \
+                                                (x).access_token = NULL; \
+                                                (x).refresh_token = NULL; \
+                                                (x).property = NULL; \
+                                        } while (0)
+
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+service_adaptor_h service_adaptor_get_handle()
+{
+       service_adaptor_debug("Get adaptor handle");
+
+       return g_service_adaptor;
+}
+
+void debug_service_context(GList *service_list)
+{
+#ifdef SERVICE_ADAPTOR_DEBUG_CONTEXT
+       if (NULL == service_list) {
+               return;
+       }
+
+       int service_count = g_list_length(service_list);
+
+       for (int i = 0; i < service_count; i++) {
+               service_adaptor_service_context_h service = g_list_nth_data(service_list, i);
+
+               service_adaptor_debug_func("[CONTEXT_DEBUG]  ============ index %d =============", i);
+               if (service) {
+                       service_adaptor_debug_func("[CONTEXT_DEBUG] service_name(%s)", service->service_name);
+                       service_adaptor_debug_func("[CONTEXT_DEBUG] plugin_uri (%s)", service->plugin_uri);
+                       service_adaptor_debug_func("[CONTEXT_DEBUG] ctx [auth(%p) contact(%p) storage(%p) message(%p) push(%p) shop(%p)]",
+                                       service->auth_context, service->contact_context, service->storage_context,
+                                       service->message_context, service->push_context, service->shop_context);
+                       service_adaptor_debug_func("[CONTEXT_DEBUG] server_info (%p)", service->server_info);
+                       service_adaptor_debug_func("[CONTEXT_DEBUG] connected (%d)", (int)service->connected);
+                       service_adaptor_debug_func("[CONTEXT_DEBUG]==========================================");
+               }
+       }
+#endif
+}
+
+service_adaptor_service_context_h service_adaptor_get_service_context(service_adaptor_h service_adaptor,
+                                               const char *service_name)
+{
+FUNC_START();
+       service_adaptor_debug("Get service context");
+
+       if ((NULL == service_adaptor) || (NULL == service_name)) {
+               service_adaptor_error("Invalid argument");
+               return NULL;
+       }
+
+       int service_count = g_list_length(service_adaptor->service_list);
+       /* debug_service_context(service_adaptor->service_list); */
+
+       for (int i = 0; i < service_count; i++) {
+               service_adaptor_service_context_h service = g_list_nth_data(service_adaptor->service_list, i);
+
+               if ((NULL != service) && (0 == strncmp(service->service_name, service_name, strlen(service_name)))) {
+                       return service;
+               }
+       }
+
+       service_adaptor_warning("First time connected : service_name(%s)", service_name);
+
+FUNC_END();
+       return NULL;
+}
+
+GList *service_adaptor_get_services_by_plugin_uri(service_adaptor_h service_adaptor,
+                                               const char *plugin_uri)
+{
+FUNC_START();
+       service_adaptor_debug("Get service context");
+
+       if (NULL == service_adaptor) {
+               service_adaptor_error("Invalid argument");
+               return NULL;
+       }
+
+       GList *service_list = NULL;
+       int service_count = g_list_length(service_adaptor->service_list);
+       service_adaptor_debug("service count : %d", service_count);
+
+       for (int i = 0; i < service_count; i++) {
+               service_adaptor_service_context_h service = g_list_nth_data(service_adaptor->service_list, i);
+               if (NULL != service) {
+                       service_adaptor_debug("service name : %s", service->service_name);
+               }
+
+               if ((NULL != service) && (0 == strncmp(service->plugin_uri, plugin_uri, strlen(plugin_uri)))) {
+                       service_list = g_list_append(service_list, service);
+               }
+       }
+
+       if (NULL == service_list) {
+               service_adaptor_info("Could not get service context with plugin_uri(%s)", plugin_uri);
+       }
+
+FUNC_END();
+       return service_list;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_bind_storage_context(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service_src,
+                                               service_adaptor_service_context_h service_dst)
+{
+FUNC_START();
+       service_adaptor_debug("START");
+
+       if ((NULL == service_adaptor) || (NULL == service_src) || (NULL == service_dst)) {
+               service_adaptor_error("Invalid parameter");
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       storage_adaptor_plugin_h plugin = storage_adaptor_get_plugin_by_name(service_adaptor->storage_handle, service_dst->plugin_uri);
+       if (NULL != service_dst->storage_context) {
+               storage_adaptor_destroy_plugin_context(plugin, service_dst->storage_context);
+       }
+
+       service_dst->storage_context = service_src->storage_context;
+
+       service_adaptor_debug("END");
+
+FUNC_END();
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_bind_push_context(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service_src,
+                                               service_adaptor_service_context_h service_dst)
+{
+FUNC_START();
+       service_adaptor_debug("START");
+
+       if ((NULL == service_adaptor) || (NULL == service_src) || (NULL == service_dst)) {
+               service_adaptor_error("Invalid parameter");
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       /*push_adaptor_plugin_h plugin = push_adaptor_get_plugin_by_name(service_adaptor->push_handle, service_dst->plugin_uri);*/
+       if (NULL != service_dst->push_context) {
+               service_dst->push_context = NULL;
+       }
+
+       service_dst->push_context = service_src->push_context;
+
+       service_adaptor_debug("END");
+
+FUNC_END();
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_bind_context(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service_src,
+                                               service_adaptor_service_context_h service_dst)
+{
+FUNC_START();
+       service_adaptor_debug("START");
+
+       if ((NULL == service_adaptor) || (NULL == service_src) || (NULL == service_dst)) {
+               service_adaptor_error("Invalid parameter");
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       if (NULL == service_dst->auth_context) {
+               service_dst->auth_context = service_src->auth_context;
+       }
+
+       if (NULL == service_dst->contact_context) {
+               service_dst->contact_context = service_src->contact_context;
+       }
+
+       if (NULL == service_dst->message_context) {
+               service_dst->message_context = service_src->message_context;
+       }
+
+       if (NULL == service_dst->shop_context) {
+               service_dst->shop_context = service_src->shop_context;
+       }
+
+       if (NULL == service_dst->storage_context) {
+               service_dst->storage_context = service_src->storage_context;
+       }
+
+       if (NULL == service_dst->push_context) {
+               service_dst->push_context = service_src->push_context;
+       }
+
+       service_adaptor_debug("END");
+
+FUNC_END();
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+/**
+ * @brief Check service_context is binded
+ * @param[in] service_adaptor  specifies Service-adaptor handle
+ * @param[in] app_id           specifies app_id
+ * @param[in] service_id       specifies service_id
+ * @return count of context, otherwise a negative error value
+ **/
+int service_adaptor_is_service_binded(service_adaptor_h service_adaptor,
+                                               const char *service_package_id)
+{
+FUNC_START();
+       if ((NULL == service_adaptor) || (NULL == service_package_id)) {
+               return 0;
+       }
+
+       if ((NULL == service_adaptor->service_list) || (0 >= g_list_length(service_adaptor->service_list))) {
+               return 0;
+       }
+
+       GList *list = NULL;
+       char *temp_service_name;
+       for (list = g_list_first(service_adaptor->service_list); NULL != list; list = g_list_next(list)) {
+               if (NULL != list->data) {
+                       temp_service_name = ((service_adaptor_service_context_h) list->data)->service_name;
+                       if ((NULL != temp_service_name)) {
+                               if (0 == strcmp(temp_service_name, service_package_id)) {
+                                       return 1;
+                               }
+                       }
+               }
+       }
+FUNC_END();
+       return 0;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_connect(service_adaptor_h service_adaptor,
+                                               service_adaptor_context_info_s *context_info,
+                                               const char *service_name,
+                                               const char *plugin_uri,
+                                               const char *user_password,
+                                               const char *app_secret,
+                                               bool auth_enable,
+                                               bool storage_enable,
+                                               bool contact_enable,
+                                               bool message_enable,
+                                               bool push_enable,
+                                               bool shop_enable,
+                                               char *ret_msg)
+{
+FUNC_START();
+       service_adaptor_debug("Connect to adaptors: %s", plugin_uri);
+
+       if ((NULL == service_adaptor) || (NULL == context_info) || (NULL == service_name)
+                       || (NULL == plugin_uri)) {
+               service_adaptor_error("Invalid parameter");
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       service_adaptor_service_context_h service =
+                       service_adaptor_get_service_context(service_adaptor, service_name);
+
+       if (NULL != service) {
+               service_adaptor_info("Already connected to adaptors: %s", service_name);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       } else {
+               service_adaptor_debug("Create service_context_h");
+               service = (service_adaptor_service_context_h) calloc(1, sizeof(service_adaptor_service_context_s));
+               service_adaptor_context_info_s *_context_info =
+                       (service_adaptor_context_info_s *) calloc(1, sizeof(service_adaptor_context_info_s));
+
+               if ((NULL == service) || (NULL == _context_info)) {
+                       service_adaptor_error("Critical : Memory allocation failed");
+                       free(service);
+                       free(_context_info);
+                       snprintf(ret_msg, 2048, "Critical : There is no memory remained");
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_ADAPTOR_INTERNAL;
+               }
+
+               g_mutex_init(&service->service_context_mutex);
+               g_cond_init(&service->service_context_cond);
+
+               service->auth_context = NULL;
+               service->contact_context = NULL;
+               service->message_context = NULL;
+               service->shop_context = NULL;
+               service->push_context = NULL;
+               service->storage_context = NULL;
+
+               service->service_name = safe_strdup(service_name);
+               service->plugin_uri = safe_strdup(plugin_uri);
+
+               service->context_info = _context_info;
+
+               service->context_info->user_id = safe_strdup(context_info->user_id);
+               service->context_info->app_id = safe_strdup(context_info->app_id);
+               service->context_info->imsi = safe_strdup(context_info->imsi);
+               service->context_info->service_id = context_info->service_id;
+               service->context_info->property = context_info->property; /* Not dup */
+               context_info->property = NULL;
+
+               service->connected = 0x0000000;
+       }
+
+FUNC_STEP();
+       /* 1) Connect to AUTH PLUGIN */
+       int ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       int last_res = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+
+       if (auth_enable) {
+               FUNC_STEP();
+               ret += (last_res = service_adaptor_connect_auth_plugin(service_adaptor, service->context_info, service_name,
+                               plugin_uri, user_password, app_secret, &service, ret_msg));
+
+               if ((SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) || (NULL == service)) {
+                       service_adaptor_error("Could not connect to auth plugin: %d", ret);
+                       goto CONNECT_API_CHECK_RESULT;
+               }
+       }
+
+       /* 2) Connect to CONTACT PLUGIN */
+       if (contact_enable) {
+               FUNC_STEP();
+               ret += (last_res = service_adaptor_connect_contact_plugin(service_adaptor, service, ret_msg));
+
+               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+                       service_adaptor_warning("Could not connect to contact plugin: %d", ret);
+                       goto CONNECT_API_CHECK_RESULT;
+               }
+       }
+
+       /* 3) Connect to MESSAGE PLUGIN */
+       if (message_enable) {
+               FUNC_STEP();
+               ret += (last_res = service_adaptor_connect_message_plugin(service_adaptor, service, ret_msg));
+
+               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+                       service_adaptor_warning("Could not connect to message plugin: %d", ret);
+                       goto CONNECT_API_CHECK_RESULT;
+               }
+       }
+
+       /* 4) Connect to SHOP PLUGIN */
+       if (shop_enable) {
+               FUNC_STEP();
+               ret += (last_res = service_adaptor_connect_shop_plugin(service_adaptor, service, ret_msg));
+
+               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+                       service_adaptor_warning("Could not connect to shop plugin: %d", ret);
+                       goto CONNECT_API_CHECK_RESULT;
+               }
+       }
+
+       /* 5) Connect to STORAGE PLUGIN */
+       if (storage_enable) {
+               FUNC_STEP();
+               ret += (last_res = service_adaptor_connect_storage_plugin(service_adaptor, service, app_secret, ret_msg));
+
+               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+                       service_adaptor_warning("Could not connect to storage plugin: %d", ret);
+                       goto CONNECT_API_CHECK_RESULT;
+               }
+       }
+
+       /* 6) Connect to PUSH PLUGIN */
+       if (push_enable) {
+               FUNC_STEP();
+               ret += (last_res = service_adaptor_connect_push_plugin(service_adaptor, service, ret_msg));
+
+               if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+                       service_adaptor_warning("Could not connect to push plugin: %d", ret);
+                       goto CONNECT_API_CHECK_RESULT;
+               }
+       }
+
+CONNECT_API_CHECK_RESULT:
+       if (ret || (0 == service->connected)) {
+               service_adaptor_warning("Plugin Connect failed : ret(%d) connected(%d)", ret, service->connected);
+               service_adaptor_warning("<service_name : %s>", service_name);
+
+               g_mutex_clear(&service->service_context_mutex);
+               g_cond_clear(&service->service_context_cond);
+
+               free(service->context_info->user_id);
+               free(service->context_info->app_id);
+               free(service->context_info->imsi);
+
+               free(service->context_info);
+
+               free(service->service_name);
+               free(service->plugin_uri);
+
+               free(service);
+
+               return last_res;
+       }
+
+
+       service_adaptor->service_list = g_list_append(service_adaptor->service_list, service);
+
+       service_adaptor_debug_func("Connect success <service_name : %s>", service_name);
+       debug_service_context(service_adaptor->service_list);
+FUNC_END();
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_disconnect(service_adaptor_h service_adaptor,
+                                               const char *service_name)
+{
+FUNC_START();
+       service_adaptor_debug("Disconnects adaptor contexts");
+
+       service_adaptor_service_context_h service = NULL;
+       while (NULL != (service = service_adaptor_get_service_context(service_adaptor, service_name))) {
+
+               if (NULL == service) {
+                       service_adaptor_debug("service context already released");
+                       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+               }
+
+               service_adaptor_internal_error_code_e ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+               ret = service_adaptor_disconnect_message_plugin(service_adaptor, service);
+               service_adaptor_debug("Disconnected message (%d)", ret);
+
+               ret = service_adaptor_disconnect_contact_plugin(service_adaptor, service);
+               service_adaptor_debug("Disconnected contact (%d)", ret);
+
+               ret = service_adaptor_disconnect_shop_plugin(service_adaptor, service);
+               service_adaptor_debug("Disconnected shop (%d)", ret);
+
+               ret = service_adaptor_disconnect_storage_plugin(service_adaptor, service);
+               service_adaptor_debug("Disconnected storage (%d)", ret);
+
+               ret = service_adaptor_disconnect_push_plugin(service_adaptor, service);
+               service_adaptor_debug("Disconnected push (%d)", ret);
+
+               ret = service_adaptor_disconnect_auth_plugin(service_adaptor, service);
+               service_adaptor_debug("Disconnected auth (%d)", ret);
+
+               if ((NULL != service) && (NULL != service->server_info)) {
+                       g_hash_table_destroy(service->server_info);
+               }
+
+               service_adaptor_debug_func("Clears mutex & cond");
+               g_mutex_clear(&service->service_context_mutex);
+               g_cond_clear(&service->service_context_cond);
+
+               free(service->service_name);
+               free(service->plugin_uri);
+
+               service_adaptor_debug_func("Clears context info");
+               if (NULL != (service->context_info)) {
+                       free(service->context_info->user_id);
+                       free(service->context_info->app_id);
+                       free(service->context_info->imsi);
+                       free(service->context_info->duid);
+                       free(service->context_info->msisdn);
+                       free(service->context_info->access_token);
+                       free(service->context_info->refresh_token);
+                       if (service->context_info->property) {
+                               bundle_free((bundle *)(service->context_info->property));
+                       }
+               }
+               free(service->context_info);
+
+               service_adaptor_debug_func("Removes from service list");
+               service_adaptor->service_list = g_list_remove(service_adaptor->service_list, service);
+               free(service);
+               service = NULL;
+       }
+       service_adaptor_debug("Disconnected from adaptors");
+
+FUNC_END();
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+
+service_adaptor_internal_error_code_e service_adaptor_start(service_adaptor_h service_adaptor)
+{
+FUNC_START();
+       service_adaptor_debug("Service Adaptor: Start");
+
+       if (NULL == service_adaptor) {
+               service_adaptor_error("Invalid argument");
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       int ret = auth_adaptor_start(service_adaptor->auth_handle);
+
+       if (AUTH_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_error("Could not start auth adaptor");
+               service_adaptor_info("Auth-adaptor is mandatory");
+/*             return SERVICE_ADAPTOR_INTERNAL_ERROR_LAUNCH; */
+       }
+
+       service_adaptor_debug("Auth Adaptor: Started");
+
+       ret = contact_adaptor_start(service_adaptor->contact_handle);
+
+       if (CONTACT_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_warning("Could not start contact adaptor");
+/*             return SERVICE_ADAPTOR_INTERNAL_ERROR_LAUNCH; */
+       }
+
+       service_adaptor_debug("Contact Adaptor: Started");
+
+       ret = message_adaptor_start(service_adaptor->message_handle);
+
+       if (MESSAGE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_warning("Could not start message adaptor");
+/*             return SERVICE_ADAPTOR_INTERNAL_ERROR_LAUNCH; */
+       }
+
+       service_adaptor_debug("Message Adaptor: Started");
+
+       ret = shop_adaptor_start(service_adaptor->shop_handle);
+
+       if (SHOP_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_warning("Could not start shop adaptor");
+/*             return SERVICE_ADAPTOR_INTERNAL_ERROR_LAUNCH; */
+       }
+
+       service_adaptor_debug("Shop Adaptor: Started");
+
+       ret = storage_adaptor_start(service_adaptor->storage_handle);
+
+       if (STORAGE_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_warning("Could not start storage adaptor");
+/*             return SERVICE_ADAPTOR_INTERNAL_ERROR_LAUNCH; */
+       }
+
+       service_adaptor_debug("Storage Adaptor: Started");
+
+       ret = push_adaptor_start(service_adaptor->push_handle);
+
+       if (PUSH_ADAPTOR_ERROR_NONE != ret) {
+               service_adaptor_warning("Could not start push adaptor");
+/*             return SERVICE_ADAPTOR_INTERNAL_ERROR_LAUNCH; */
+       }
+
+       service_adaptor_debug("Push Adaptor: Started");
+/*
+       ret = service_adaptor_scan_all_packages_async(service_adaptor);
+       service_adaptor_debug("Scan all packages ret(%d)", ret);
+
+       ret = service_adaptor_set_package_installed_callback(service_adaptor);
+       service_adaptor_debug("Sets package installed callback ret(%d)", ret);
+*/
+       g_mutex_lock(&service_adaptor->service_adaptor_mutex);
+       service_adaptor->started = 1;
+       g_cond_signal(&service_adaptor->service_adaptor_cond);
+       g_mutex_unlock(&service_adaptor->service_adaptor_mutex);
+
+FUNC_END();
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+service_adaptor_internal_error_code_e service_adaptor_stop(service_adaptor_h service_adaptor)
+{
+FUNC_START();
+       service_adaptor_debug("Service Adaptor: Stop");
+
+       if (NULL == service_adaptor) {
+               service_adaptor_error("Invalid argument");
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_ARGUMENT;
+       }
+
+       if (0 <= service_adaptor->started) {
+               service_adaptor_error("Service Adaptor is not running");
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_START;
+       }
+
+FUNC_STEP();
+       int ret = auth_adaptor_stop(service_adaptor->auth_handle);
+       ret += contact_adaptor_stop(service_adaptor->contact_handle);
+       ret += message_adaptor_stop(service_adaptor->message_handle);
+       ret += shop_adaptor_stop(service_adaptor->shop_handle);
+       ret += storage_adaptor_stop(service_adaptor->storage_handle);
+       ret += push_adaptor_stop(service_adaptor->push_handle);
+
+       service_adaptor->started = 0;
+
+       if (0 != ret) {
+               service_adaptor_error("Error while stopping adaptors");
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_CORRUPTED;
+       }
+
+       service_adaptor_debug("Service Adaptor: Stopped");
+
+FUNC_END();
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+/**************************************************************************
+ * Create / Destroy Adaptors
+ **************************************************************************/
+service_adaptor_h service_adaptor_create()
+{
+FUNC_START();
+       service_adaptor_debug("Service Adaptor: Create");
+
+       /* create handle of adaptor */
+       auth_adaptor_h auth_handle = service_adaptor_create_auth();
+
+       if (NULL == auth_handle) {
+               service_adaptor_error("Could not create auth adaptor");
+               return NULL;
+       }
+
+       contact_adaptor_h contact_handle = service_adaptor_create_contact();
+
+       if (NULL == contact_handle) {
+               service_adaptor_error("Could not create contact adaptor");
+               auth_adaptor_destroy(auth_handle);
+               return NULL;
+       }
+
+       message_adaptor_h message_handle = service_adaptor_create_message();
+
+       if (NULL == message_handle) {
+               service_adaptor_error("Could not create message adaptor");
+               auth_adaptor_destroy(auth_handle);
+               contact_adaptor_destroy(contact_handle);
+               return NULL;
+       }
+
+       shop_adaptor_h shop_handle = service_adaptor_create_shop();
+
+       if (NULL == shop_handle) {
+               service_adaptor_error("Could not create shop adaptor");
+               auth_adaptor_destroy(auth_handle);
+               contact_adaptor_destroy(contact_handle);
+               message_adaptor_destroy(message_handle);
+               return NULL;
+       }
+
+       storage_adaptor_h storage_handle = service_adaptor_create_storage();
+
+       if (NULL == storage_handle) {
+               service_adaptor_error("Could not create storage adaptor");
+               auth_adaptor_destroy(auth_handle);
+               contact_adaptor_destroy(contact_handle);
+               message_adaptor_destroy(message_handle);
+               shop_adaptor_destroy(shop_handle);
+               return NULL;
+       }
+
+       push_adaptor_h push_handle = service_adaptor_create_push();
+
+       if (NULL == push_handle) {
+               service_adaptor_error("Could not create push adaptor");
+               auth_adaptor_destroy(auth_handle);
+               contact_adaptor_destroy(contact_handle);
+               message_adaptor_destroy(message_handle);
+               shop_adaptor_destroy(shop_handle);
+               storage_adaptor_destroy(storage_handle);
+               return NULL;
+       }
+
+       /* register listener of adaptor */
+       auth_adaptor_listener_h auth_listener = service_adaptor_register_auth_listener(auth_handle);
+
+       if (NULL == auth_listener) {
+               service_adaptor_error("Could not create auth listener");
+               auth_adaptor_destroy(auth_handle);
+               contact_adaptor_destroy(contact_handle);
+               message_adaptor_destroy(message_handle);
+               shop_adaptor_destroy(shop_handle);
+               storage_adaptor_destroy(storage_handle);
+               push_adaptor_destroy(push_handle);
+               return NULL;
+       }
+
+       contact_adaptor_listener_h contact_listener = service_adaptor_register_contact_listener(contact_handle);
+
+       if (NULL == contact_listener) {
+               service_adaptor_error("Could not create contact listener");
+               auth_adaptor_unregister_listener(auth_handle, auth_listener);
+
+               auth_adaptor_destroy(auth_handle);
+               contact_adaptor_destroy(contact_handle);
+               message_adaptor_destroy(message_handle);
+               shop_adaptor_destroy(shop_handle);
+               storage_adaptor_destroy(storage_handle);
+               push_adaptor_destroy(push_handle);
+               return NULL;
+       }
+
+       message_adaptor_listener_h message_listener = service_adaptor_register_message_listener(message_handle);
+
+       if (NULL == message_listener) {
+               service_adaptor_error("Could not create message listener");
+               auth_adaptor_unregister_listener(auth_handle, auth_listener);
+               contact_adaptor_unregister_listener(contact_handle, contact_listener);
+
+               auth_adaptor_destroy(auth_handle);
+               contact_adaptor_destroy(contact_handle);
+               message_adaptor_destroy(message_handle);
+               shop_adaptor_destroy(shop_handle);
+               storage_adaptor_destroy(storage_handle);
+               push_adaptor_destroy(push_handle);
+               return NULL;
+       }
+
+       shop_adaptor_listener_h shop_listener = service_adaptor_register_shop_listener(shop_handle);
+
+       if (NULL == shop_listener) {
+               service_adaptor_error("Could not create shop listener");
+               auth_adaptor_unregister_listener(auth_handle, auth_listener);
+               contact_adaptor_unregister_listener(contact_handle, contact_listener);
+               message_adaptor_unregister_listener(message_handle, message_listener);
+
+               auth_adaptor_destroy(auth_handle);
+               contact_adaptor_destroy(contact_handle);
+               message_adaptor_destroy(message_handle);
+               shop_adaptor_destroy(shop_handle);
+               storage_adaptor_destroy(storage_handle);
+               push_adaptor_destroy(push_handle);
+               return NULL;
+       }
+
+       storage_adaptor_listener_h storage_listener = service_adaptor_register_storage_listener(storage_handle);
+
+       if (NULL == storage_listener) {
+               service_adaptor_error("Could not create storage listener");
+               auth_adaptor_unregister_listener(auth_handle, auth_listener);
+               contact_adaptor_unregister_listener(contact_handle, contact_listener);
+               message_adaptor_unregister_listener(message_handle, message_listener);
+               shop_adaptor_unregister_listener(shop_handle, shop_listener);
+
+               auth_adaptor_destroy(auth_handle);
+               contact_adaptor_destroy(contact_handle);
+               message_adaptor_destroy(message_handle);
+               shop_adaptor_destroy(shop_handle);
+               storage_adaptor_destroy(storage_handle);
+               push_adaptor_destroy(push_handle);
+               return NULL;
+       }
+
+       push_adaptor_listener_h push_listener = service_adaptor_register_push_listener(push_handle);
+
+       if (NULL == push_listener) {
+               service_adaptor_error("Could not create push listener");
+               auth_adaptor_unregister_listener(auth_handle, auth_listener);
+               contact_adaptor_unregister_listener(contact_handle, contact_listener);
+               message_adaptor_unregister_listener(message_handle, message_listener);
+               shop_adaptor_unregister_listener(shop_handle, shop_listener);
+               storage_adaptor_unregister_listener(storage_handle, storage_listener);
+
+               auth_adaptor_destroy(auth_handle);
+               contact_adaptor_destroy(contact_handle);
+               message_adaptor_destroy(message_handle);
+               shop_adaptor_destroy(shop_handle);
+               storage_adaptor_destroy(storage_handle);
+               push_adaptor_destroy(push_handle);
+               return NULL;
+       }
+
+       /* create Service Adaptor */
+       service_adaptor_h service_adaptor = (service_adaptor_h) g_malloc0(sizeof(service_adaptor_s));
+
+       if (NULL == service_adaptor) {
+               service_adaptor_error("Could not create service adaptor");
+               auth_adaptor_unregister_listener(auth_handle, auth_listener);
+               contact_adaptor_unregister_listener(contact_handle, contact_listener);
+               message_adaptor_unregister_listener(message_handle, message_listener);
+               shop_adaptor_unregister_listener(shop_handle, shop_listener);
+               storage_adaptor_unregister_listener(storage_handle, storage_listener);
+               push_adaptor_unregister_listener(push_handle, push_listener);
+
+               auth_adaptor_destroy(auth_handle);
+               contact_adaptor_destroy(contact_handle);
+               message_adaptor_destroy(message_handle);
+               shop_adaptor_destroy(shop_handle);
+               storage_adaptor_destroy(storage_handle);
+               push_adaptor_destroy(push_handle);
+               return NULL;
+       }
+
+FUNC_STEP();
+       service_adaptor->auth_handle            = auth_handle;
+       service_adaptor->contact_handle         = contact_handle;
+       service_adaptor->message_handle         = message_handle;
+       service_adaptor->shop_handle            = shop_handle;
+       service_adaptor->storage_handle         = storage_handle;
+       service_adaptor->push_handle            = push_handle;
+
+       service_adaptor->auth_listener          = auth_listener;
+       service_adaptor->push_listener          = push_listener;
+       service_adaptor->shop_listener          = shop_listener;
+       service_adaptor->contact_listener       = contact_listener;
+       service_adaptor->storage_listener       = storage_listener;
+       service_adaptor->message_listener       = message_listener;
+
+       service_adaptor->service_list = NULL;
+       service_adaptor->started = 0;
+
+       g_mutex_init(&service_adaptor->service_adaptor_mutex);
+       g_cond_init(&service_adaptor->service_adaptor_cond);
+
+       service_adaptor_debug("Service Adaptor: Created");
+
+       service_adaptor_info("Init client checker (%d)", client_checker_init());
+
+FUNC_END();
+       return service_adaptor;
+}
+
+void service_adaptor_destroy(service_adaptor_h service_adaptor)
+{
+FUNC_START();
+       service_adaptor_debug("Service Adaptor: Destroy");
+       client_checker_deinit();
+       service_adaptor_info("Deinit client checker");
+
+       if ((void *) NULL == service_adaptor) {
+               service_adaptor_debug("Invalid argument");
+               return;
+       }
+
+       /* 1) deinit D-Bus */
+       dbus_ipc_server_layer_deinit();
+
+       service_adaptor_debug("Service adaptor destroyed: D-Bus");
+
+       /* 2) destroy service list */
+       if (NULL != service_adaptor->service_list) {
+               g_list_free(service_adaptor->service_list);
+               service_adaptor->service_list = NULL;
+       }
+
+       service_adaptor_debug("Service adaptor destroyed: service list");
+
+       /* 3) stop service adaptor */
+       if (0 < service_adaptor->started) {
+               service_adaptor_error("Service Adaptor is running. Force stopping before destroy");
+               service_adaptor_stop(service_adaptor);
+       }
+
+       service_adaptor_safe_free(service_adaptor);
+
+       service_adaptor_debug("Service Adaptor: Destroyed");
+FUNC_END();
+}
+
+void *servive_adaptor_preload_service_files(void *data)
+{
+FUNC_START();
+       service_adaptor_debug("5 sec sleep for load service files (TODO change)");
+       sleep(5);
+       service_adaptor_internal_error_code_e ret;
+       push_activate_h *services = NULL;
+       int svc_len = 0;
+       ret = service_adaptor_ref_enabled_push_services(&services, &svc_len);
+
+       service_adaptor_debug_func("### Preload service len : %d", svc_len);
+       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE == ret) {
+               for (int i = 0; i < svc_len; i++) {
+                       service_adaptor_context_info_s new_context_info;
+                       __init_context_info_s(new_context_info);
+                       new_context_info.app_id = services[i]->app_id;
+                       char service_name[1024] = {0, };
+                       snprintf(service_name, 1024, "preloaded_service/plugin='%s'&app_id='%s'",
+                                       services[i]->plugin_uri, services[i]->app_id);
+                       char ret_msg[2048] = {0, };
+                       ret = service_adaptor_connect(g_service_adaptor, &new_context_info, service_name,
+                                       services[i]->plugin_uri, "", "",
+                                       false, false, false, false, true, false, ret_msg);
+                       service_adaptor_debug_func("### Preload service : ret(%d) service_name(%s)", ret, service_name);
+               }
+               free(services);
+       }
+
+FUNC_END();
+       return NULL;
+}
+
+/**
+ * @brief init service adaptor
+ *
+ * @return     void.
+ */
+service_adaptor_internal_error_code_e service_adaptor_init()
+{
+FUNC_START();
+       service_adaptor_debug("Service Adaptor: Initialize");
+
+       int ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+
+       /* 1) create adaptor (memory allocation) */
+       service_adaptor_h service_adaptor = service_adaptor_create();
+
+       if (NULL == service_adaptor) {
+               service_adaptor_error("Could not create Service Adaptor");
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_CREATE;
+       }
+
+       service_adaptor_debug("Service Adaptor: created");
+
+       /* 2) start adaptor (plugin load, get IMIS list) */
+       ret = service_adaptor_start(service_adaptor);
+
+       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+               service_adaptor_error("Could not load Adaptors: %d", ret);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_START;
+       }
+
+       service_adaptor_debug("Service Adaptor: started");
+
+       /* 3) assign to global service adaptor handle */
+       g_service_adaptor = service_adaptor;
+
+       /* 4) init dbus */
+       ret = dbus_ipc_server_layer_init();
+
+       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+               service_adaptor_error("Could not init D-Bus IPC server: %d", ret);
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
+       }
+
+       service_adaptor_debug("Service Adaptor: init D-Bus");
+       service_adaptor_debug("Service Adaptor: Initialized (%d)", service_adaptor->started);
+
+       service_adaptor_debug("Service Adaptor: init preload service");
+       pthread_t job;
+       pthread_create(&job, NULL, servive_adaptor_preload_service_files, NULL);
+FUNC_END();
+       return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+}
+
+/**
+ * @brief deinit service adaptor
+ *
+ * @param[in]  service_adaptor         specifies handle of service adaptor
+ * @return     void.
+ */
+void service_adaptor_deinit(service_adaptor_h service_adaptor)
+{
+       service_adaptor_debug("Service Adaptor: Deinitialize");
+
+       if (NULL == service_adaptor) {
+               service_adaptor_error("Invalid argument");
+               return;
+       }
+       service_adaptor_destroy(service_adaptor);
+       service_adaptor_debug("Service Adaptor: Deinitialized");
+}
+
+/**
+ * @brief main signal function
+ *
+ * @param[in]  data            specifies user data passed by main function
+ * @return     void.
+ */
+static gint sigterm_callback(void *data)
+{
+       service_adaptor_info("Service Adaptor Shutdown");
+
+       g_main_loop_quit((GMainLoop *)data);
+
+       return FALSE;
+}
+
+/******************************************************************************
+  Public interface definition
+ *****************************************************************************/
+
+service_adaptor_internal_error_code_e service_adaptor_auth_refresh(service_adaptor_h service_adaptor,
+                                               const char *service_name,
+                                               const char *plugin_uri)
+{
+FUNC_START();
+       service_adaptor_debug("Auth refresh Start");
+
+       service_adaptor_service_context_h service_context =
+                       service_adaptor_get_service_context(service_adaptor, service_name);
+
+FUNC_END();
+       return service_adaptor_auth_refresh_with_service_context(service_adaptor, service_context, plugin_uri);
+}
+
+service_adaptor_internal_error_code_e service_adaptor_auth_refresh_with_service_context(service_adaptor_h service_adaptor,
+                                               service_adaptor_service_context_h service_context,
+                                               const char *plugin_uri)
+{
+FUNC_START();
+       service_adaptor_debug("Auth refresh with service context Start");
+
+       if (NULL == service_context) {
+               service_adaptor_warning("Parameter is NULL (service_adaptor_h service_adaptor)");
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_HANDLE;
+       }
+
+       if (NULL == service_context->auth_context) {
+               service_adaptor_warning("Parameter is NULL (service_context->auth_context)");
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_HANDLE;
+       }
+
+       int ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       char *old_access_token = NULL;
+       char *new_access_token = NULL;
+       char *new_uid = NULL;
+
+       service_adaptor_debug("Get contexts and plugins from service_adaptor_h");
+       if (NULL != service_context->context_info) {
+               old_access_token = service_context->context_info->access_token;
+       } else {
+               service_adaptor_warning("Element is NULL (service_context->context->info)");
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_INVALID_HANDLE;
+       }
+       auth_adaptor_plugin_h auth_plugin =
+                       auth_adaptor_get_plugin_by_name(service_adaptor->auth_handle, plugin_uri);
+       auth_adaptor_error_code_h       auth_error      = NULL;
+
+       int is_auth = -1;
+       service_adaptor_debug("Call is_auth");
+       ret = auth_adaptor_is_auth(auth_plugin, service_context->auth_context, NULL, &is_auth, &auth_error, NULL);
+
+       if (0 == is_auth) {
+               service_adaptor_error("Auth was withdrew (Can not use all service)");
+               /*TODO change context_info's auth flag */
+               return SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED;
+       }
+       auth_adaptor_destroy_error_code(&auth_error);
+
+       service_adaptor_debug("Call auth_adaptor_login");
+       ret = auth_adaptor_login(auth_plugin, service_context->auth_context, is_auth, NULL, &auth_error, NULL);
+
+       if ((NULL != old_access_token) && (AUTH_ADAPTOR_ERROR_NONE == ret)) {
+               if (NULL == service_context->auth_context->access_token) {
+                       service_adaptor_error("auth_plugin returns login success but auth_access token is empty");
+                       service_context->auth_context->access_token = strdup(old_access_token);
+                       ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NOT_AUTHORIZED;
+               } else {
+                       if (0 == strcmp(old_access_token, service_context->auth_context->access_token)) {
+                               service_adaptor_debug("Call auth_adaptor_login_refresh");
+                               ret = auth_adaptor_login_refresh(auth_plugin, service_context->auth_context, NULL, &auth_error, NULL);
+                       }
+
+                       if ((AUTH_ADAPTOR_ERROR_NONE == ret) &&
+                                       (NULL != service_context->auth_context->access_token) &&
+                                       (0 == strcmp(old_access_token, service_context->auth_context->access_token))) {
+                               service_adaptor_debug("Access token was not changed");
+                       } else if (AUTH_ADAPTOR_ERROR_NONE == ret) {
+                               service_adaptor_debug("Changing access token start");
+
+                               new_access_token = auth_adaptor_get_access_token_dup(service_context->auth_context);
+                               if (NULL != new_access_token) {
+                                       service_adaptor_debug_secure("New access token : %s", new_access_token);
+                                       free(service_context->context_info->access_token);
+                                       service_context->context_info->access_token = new_access_token;
+                                       service_adaptor_debug("service_context->context_info->access_token was changed");
+
+                                       ret = contact_adaptor_refresh_access_token(service_context->contact_context, new_access_token);
+                                       if (!ret) {
+                                               service_adaptor_debug("service_context->contact_context was changed");
+                                       }
+
+                                       ret = storage_adaptor_refresh_access_token(service_context->storage_context, new_access_token);
+                                       if (!ret) {
+                                               service_adaptor_debug("service_context->storage_context was changed");
+                                       }
+
+                                       ret = message_adaptor_refresh_access_token(service_context->message_context, new_access_token);
+                                       if (!ret) {
+                                               service_adaptor_debug("service_context->message_context was changed");
+                                       }
+
+                                       ret = shop_adaptor_refresh_access_token(service_context->shop_context, new_access_token);
+                                       if (!ret) {
+                                               service_adaptor_debug("service_context->shop_context was changed");
+                                       }
+                               }
+
+                               new_uid = auth_adaptor_get_uid_dup(service_context->auth_context);
+                               if (NULL != new_uid) {
+                                       service_adaptor_debug_secure("New unique id : %s", new_uid);
+                                       free(service_context->context_info->duid);
+                                       service_context->context_info->duid = new_uid;
+                                       service_adaptor_debug("service_context->context_info->uid was changed");
+
+                                       ret = contact_adaptor_refresh_uid(service_context->contact_context, new_uid);
+                                       if (!ret) {
+                                               service_adaptor_debug("service_context->contact_context was changed");
+                                       }
+
+                                       ret = storage_adaptor_refresh_uid(service_context->storage_context, new_uid);
+                                       if (!ret) {
+                                               service_adaptor_debug("service_context->storage_context was changed");
+                                       }
+
+                                       ret = message_adaptor_refresh_uid(service_context->message_context, new_uid);
+                                       if (!ret) {
+                                               service_adaptor_debug("service_context->message_context was changed");
+                                       }
+
+                                       ret = shop_adaptor_refresh_uid(service_context->shop_context, new_uid);
+                                       if (!ret) {
+                                               service_adaptor_debug("service_context->shop_context was changed");
+                                       }
+                               }
+                       } else {
+                               service_adaptor_error("Login refresh failed");
+                               if (NULL != auth_error) {
+                                       service_adaptor_error("Auth error code(%lld) message(%s)", auth_error->code, auth_error->msg);
+                               }
+                       }
+               }
+       } else {
+               service_adaptor_error("Login refresh failed");
+               if (NULL != auth_error) {
+                       service_adaptor_error("Auth error code(%lld) message(%s)", auth_error->code, auth_error->msg);
+               }
+       }
+
+       service_adaptor_debug("Auth refresh End");
+FUNC_END();
+       return ret;
+}
+
+
+/**
+ * @brief main function
+ *
+ * @param[in]  argc            specifies count of arguments
+ * @param[in]  argv            specifies value list of arguments
+ * @return     void.
+ */
+int main(int argc, char *argv[])
+{
+       int ret = SERVICE_ADAPTOR_INTERNAL_ERROR_NONE;
+       GMainLoop *loop;
+
+#if !GLIB_CHECK_VERSION(2, 32, 0)
+       g_thread_init(NULL);
+#endif
+#if !GLIB_CHECK_VERSION(2, 35, 0)
+       g_type_init();
+#endif
+
+       ret = service_adaptor_init();
+
+       if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+               service_adaptor_error("Service Adaptor initialize error: %d\n", ret);
+               return -1;
+       }
+
+       /* 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);
+
+       service_adaptor_h service_adaptor = service_adaptor_get_handle();
+       service_adaptor_deinit(service_adaptor);
+
+       return ret;
+}
+
+#ifdef SERVICE_ADAPTOR_DEBUG_TIME_CHECK
+
+#include <sys/time.h>
+/******************* for debug func *************/
+
+/* sa time */
+static __thread long start_time = 0;
+static __thread long now_time = 0;
+static __thread long delayed_time = 0;
+
+/* auth */
+static __thread long a_start_time = 0;
+static __thread long a_now_time = 0;
+static __thread long a_delayed_time = 0;
+
+/* storage */
+static __thread long s_start_time = 0;
+static __thread long s_now_time = 0;
+static __thread long s_delayed_time = 0;
+
+/* contact */
+static __thread long c_start_time = 0;
+static __thread long c_now_time = 0;
+static __thread long c_delayed_time = 0;
+
+/* message */
+static __thread long m_start_time = 0;
+static __thread long m_now_time = 0;
+static __thread long m_delayed_time = 0;
+
+/* push */
+static __thread long p_start_time = 0;
+static __thread long p_now_time = 0;
+static __thread long p_delayed_time = 0;
+
+/* shop */
+static __thread long h_start_time = 0;
+static __thread long h_now_time = 0;
+static __thread long h_delayed_time = 0;
+
+static __thread int a_count = 0;
+static __thread int s_count = 0;
+static __thread int c_count = 0;
+static __thread int m_count = 0;
+static __thread int p_count = 0;
+static __thread int h_count = 0;
+
+static __thread struct timeval tv;
+
+#endif
+void SERVICE_ADAPTOR_API_TIME_CHECK_START()
+{
+#ifdef SERVICE_ADAPTOR_DEBUG_TIME_CHECK
+       gettimeofday(&tv, NULL);
+       start_time = tv.tv_sec;
+#endif
+}
+void SERVICE_ADAPTOR_API_TIME_CHECK_PAUSE()
+{
+#ifdef SERVICE_ADAPTOR_DEBUG_TIME_CHECK
+       gettimeofday(&tv, NULL);
+       now_time = tv.tv_sec;
+
+       delayed_time += (now_time - start_time);
+#endif
+}
+
+void SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_START(sa_time_check_flag_e flag)
+{
+#ifdef SERVICE_ADAPTOR_DEBUG_TIME_CHECK
+       if (SA_TIME_CHECK_FLAG_AUTH == flag) {
+               gettimeofday(&tv, NULL);
+               a_start_time = tv.tv_sec;
+       }
+       if (SA_TIME_CHECK_FLAG_STORAGE == flag) {
+               gettimeofday(&tv, NULL);
+               s_start_time = tv.tv_sec;
+       }
+       if (SA_TIME_CHECK_FLAG_CONTACT == flag) {
+               gettimeofday(&tv, NULL);
+               c_start_time = tv.tv_sec;
+       }
+       if (SA_TIME_CHECK_FLAG_MESSAGE == flag) {
+               gettimeofday(&tv, NULL);
+               m_start_time = tv.tv_sec;
+       }
+       if (SA_TIME_CHECK_FLAG_PUSH == flag) {
+               gettimeofday(&tv, NULL);
+               p_start_time = tv.tv_sec;
+       }
+       if (SA_TIME_CHECK_FLAG_SHOP == flag) {
+               gettimeofday(&tv, NULL);
+               h_start_time = tv.tv_sec;
+       }
+#endif
+}
+void SERVICE_ADAPTOR_PLUGIN_API_TIME_CHECK_PAUSE(sa_time_check_flag_e flag)
+{
+#ifdef SERVICE_ADAPTOR_DEBUG_TIME_CHECK
+       if (SA_TIME_CHECK_FLAG_AUTH == flag) {
+               gettimeofday(&tv, NULL);
+               a_now_time = tv.tv_sec;
+
+               a_delayed_time += (a_now_time - a_start_time);
+               a_count++;
+       }
+       if (SA_TIME_CHECK_FLAG_STORAGE == flag) {
+               gettimeofday(&tv, NULL);
+               s_now_time = tv.tv_sec;
+
+               s_delayed_time += (s_now_time - s_start_time);
+               s_count++;
+       }
+       if (SA_TIME_CHECK_FLAG_CONTACT == flag) {
+               gettimeofday(&tv, NULL);
+               c_now_time = tv.tv_sec;
+
+               c_delayed_time += (c_now_time - c_start_time);
+               c_count++;
+       }
+       if (SA_TIME_CHECK_FLAG_MESSAGE == flag) {
+               gettimeofday(&tv, NULL);
+               m_now_time = tv.tv_sec;
+
+               m_delayed_time += (m_now_time - m_start_time);
+               m_count++;
+       }
+       if (SA_TIME_CHECK_FLAG_PUSH == flag) {
+               gettimeofday(&tv, NULL);
+               p_now_time = tv.tv_sec;
+
+               p_delayed_time += (p_now_time - p_start_time);
+               p_count++;
+       }
+       if (SA_TIME_CHECK_FLAG_SHOP == flag) {
+               gettimeofday(&tv, NULL);
+               h_now_time = tv.tv_sec;
+
+               h_delayed_time += (h_now_time - h_start_time);
+               h_count++;
+       }
+#endif
+}
+void SERVICE_ADAPTOR_API_TIME_CHECK_TOTAL_REPORT(const char *service_name)
+{
+#ifdef SERVICE_ADAPTOR_DEBUG_TIME_CHECK
+       service_adaptor_debug_func("[TIMECHECK]================================================");
+       service_adaptor_debug_func("[TIMECHECK]================================================");
+       service_adaptor_debug_func("[TIMECHECK]     Total set_auth time report (TID : %lld)", (long long int)syscall(__NR_gettid));
+       service_adaptor_debug_func("[TIMECHECK]     Service name : %s", service_name);
+       service_adaptor_debug_func("[TIMECHECK] Total delay time : %ld sec",
+                       (delayed_time + a_delayed_time + s_delayed_time + c_delayed_time + m_delayed_time + p_delayed_time + h_delayed_time));
+       service_adaptor_debug_func("[TIMECHECK] Adaptor : %ld sec", delayed_time);
+       service_adaptor_debug_func("[TIMECHECK] Auth plugin : %ld sec, called : %d", a_delayed_time, a_count);
+       service_adaptor_debug_func("[TIMECHECK] Storage plugin : %ld sec, called : %d", s_delayed_time, s_count);
+       service_adaptor_debug_func("[TIMECHECK] Contact plugin : %ld sec, called : %d", c_delayed_time, c_count);
+       service_adaptor_debug_func("[TIMECHECK] Message plugin : %ld sec, called : %d", m_delayed_time, m_count);
+       service_adaptor_debug_func("[TIMECHECK] Push plugin : %ld sec, called : %d", p_delayed_time, p_count);
+       service_adaptor_debug_func("[TIMECHECK] Shop plugin : %ld sec, called : %d", h_delayed_time, h_count);
+       service_adaptor_debug_func("[TIMECHECK]================================================");
+       service_adaptor_debug_func("[TIMECHECK]================================================");
+#endif
+}
+
diff --git a/src/util/client_checker.c b/src/util/client_checker.c
new file mode 100644 (file)
index 0000000..92a28fd
--- /dev/null
@@ -0,0 +1,455 @@
+/*
+* 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 <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <stdarg.h>
+
+#include <glib.h>
+#include <sys/smack.h>
+#include <security-server.h>
+
+#include "util/client_checker.h"
+#include "service-adaptor-log.h"
+
+/*************************************************
+ *               Type definition
+ *************************************************/
+
+#define CLIENT_TYPE_APP                1
+#define CLIENT_TYPE_ETC                0
+
+#define ERROR_MSG_MAX_LEN 200
+
+typedef struct _client_data_s {
+       int type;
+       int pid;
+       char *service_handle_name;
+       char cookie[21];
+} client_data_s;
+
+
+/*************************************************
+ *               Global valuable
+ *************************************************/
+
+static GHashTable *g_clients = NULL;
+
+static __thread char last_error_message[ERROR_MSG_MAX_LEN] = {0, };
+
+/*************************************************
+ *               Internal function prototype
+ *************************************************/
+
+static client_data_s *__client_data_create(void);
+
+static void __client_data_free(void *data);
+
+static client_data_s *__client_data_find(const char *_key);
+
+static int __get_dir_path(const char *path, char **dir_path);
+
+static void __set_last_error(const char *format, ...);
+
+
+/*************************************************
+ *               Public function prototype
+ *************************************************/
+
+int client_checker_init(void);
+
+void client_checker_deinit(void);
+
+int client_checker_add_client(const char *service_handle_name, const char *cookie);
+
+int client_checker_del_client(const char *service_handle_name);
+
+int client_checker_check_privilege(const char *service_handle_name, const char *privilege);
+
+int client_checker_check_access_rights(const char *service_handle_name, const char *object, const char *access_rights);
+
+int client_checker_check_access_right_read(const char *service_handle_name, const char *path);
+
+int client_checker_check_access_right_write(const char *service_handle_name, const char *path);
+
+int client_checker_check_access_right_create(const char *service_handle_name, const char *path);
+
+const char *clieht_checker_get_last_error(void);
+
+/*************************************************
+ *               Internal function definition
+ *************************************************/
+
+static client_data_s *__client_data_create(void)
+{
+       client_data_s *data = (client_data_s *) calloc(1, sizeof(client_data_s));
+       if (NULL != data) {
+               data->service_handle_name = NULL;
+               memset(data->cookie, 0, 21);
+       }
+       return data;
+}
+
+static void __client_data_free(void *data)
+{
+       if (NULL != data) {
+               free(((client_data_s *) data)->service_handle_name);
+               memset(((client_data_s *) data)->cookie, 0, 20);
+               free((client_data_s *) data);
+       }
+}
+
+static client_data_s *__client_data_find(const char *_key)
+{
+       client_data_s *data = (client_data_s *) g_hash_table_lookup(g_clients, _key);
+
+       service_adaptor_debug_func("+++ find data (%p)", data);
+       return data;
+}
+
+static int __get_dir_path(const char *path, char **dir_path)
+{
+        if ((NULL == path) || ('/' != path[0]) || (1 >= strlen(path))) {
+               /* path must be absolute path (starts with '/') */
+               __set_last_error("[Permission checker] Path must be absolute path (starts with '/')");
+                return -1;
+        }
+
+        char *full_path = strdup(path);
+        if (NULL == full_path) {
+               /* dup failed */
+               __set_last_error("[Permission checker] Internal error");
+                return -1;
+        } else if (full_path[strlen(full_path) - 1] == '/') {
+               /* if full_path is "/abc/d/" -> "abc/d" */
+                full_path[strlen(full_path) - 1] = '\0';
+        }
+
+        char *base = strrchr(full_path, '/');
+        if (base == full_path) {
+               /* if full_path is "/abc" */
+                *dir_path = strdup("/");
+        } else if (NULL != base) {
+               /* expected case */
+                *dir_path = strndup(full_path, (base - full_path));
+        } else {
+               __set_last_error("[Permission checker] Invalid path (Can not parse string)");
+                free(full_path);
+                return -1;
+        }
+        free(full_path);
+
+        return 0;
+}
+
+
+/*************************************************
+ *               Public function definition
+ *************************************************/
+
+int client_checker_init(void)
+{
+       g_clients = g_hash_table_new_full(g_str_hash, g_str_equal, free, __client_data_free);
+
+       if (NULL == g_clients) {
+               return -101;
+       }
+       return 0;
+}
+
+void client_checker_deinit(void)
+{
+       if (NULL != g_clients) {
+               g_hash_table_destroy(g_clients);
+               g_clients = NULL;
+       }
+}
+
+int client_checker_add_client(const char *service_handle_name, const char *cookie)
+{
+       if (NULL == g_clients) {
+               return -201;
+       }
+
+       if ((NULL == cookie) || ('\0' == cookie[0]) || (NULL == service_handle_name)) {
+               return -202;
+       }
+
+       client_data_s *data = __client_data_create();
+       if (NULL == data) {
+               return -203;
+       }
+
+       char *key = strdup(service_handle_name);
+       if (NULL == key) {
+               __client_data_free(data);
+               return -204;
+       }
+       strncpy(data->cookie, cookie, 20);
+
+       /* pid get */
+       int pid = security_server_get_cookie_pid(cookie);
+       service_adaptor_debug("pid : %d\n", pid);
+       data->pid = pid;
+
+       data->service_handle_name = strdup(service_handle_name);
+
+       g_hash_table_insert(g_clients, key, data);
+
+       return 0;
+}
+
+int client_checker_del_client(const char *service_handle_name)
+{
+       if (NULL == g_clients) {
+               return -301;
+       }
+
+       if (NULL == service_handle_name) {
+               return -302;
+       }
+
+       g_hash_table_remove(g_clients, service_handle_name);
+
+       return 0;
+}
+
+int client_checker_check_privilege(const char *service_handle_name, const char *privilege)
+{
+       if (NULL == g_clients) {
+               return -401;
+       }
+
+       if ((NULL == service_handle_name) || (NULL == privilege)) {
+               return -402;
+       }
+
+       client_data_s *data = __client_data_find(service_handle_name);
+       if (NULL == data) {
+               return -403;
+       }
+
+       int ret = security_server_check_privilege_by_cookie(data->cookie, privilege, "rw");
+
+       service_adaptor_debug_func("+++ [Service Adaptor Client privilege check]");
+       service_adaptor_debug_func("+++ handle name : %s", service_handle_name);
+       service_adaptor_debug_func("+++ pid : %d", data->pid);
+       service_adaptor_debug_func("+++ check privilege : %s", privilege);
+       service_adaptor_debug_func("+++ privilege check ret : %d", ret);
+
+       if (ret) {
+               fprintf(stderr, "[service-adaptor] User space smack denied : subject pid (%d), check privilege (%s)\n", data->pid, privilege);
+               service_adaptor_error("[service-adaptor] User space smack denied : subject pid (%d), check privilege (%s)\n", data->pid, privilege);
+               ret = -404;
+       } else {
+               service_adaptor_debug_func("===== privilege check passed =====");
+       }
+
+       return ret;
+}
+
+int client_checker_check_access_rights(const char *service_handle_name, const char *object, const char *access_rights)
+{
+       if (NULL == g_clients) {
+               return -501;
+       }
+
+       if ((NULL == service_handle_name) || (NULL == object) || (NULL == access_rights)) {
+               return -502;
+       }
+
+       client_data_s *data = __client_data_find(service_handle_name);
+       if (NULL == data) {
+               return -503;
+       }
+
+       int ret = security_server_check_privilege_by_cookie(data->cookie, object, access_rights);
+
+       service_adaptor_debug_func("+++ [Service Adaptor Client access right check]");
+       service_adaptor_debug_func("+++ handle name : %s", service_handle_name);
+       service_adaptor_debug_func("+++ pid : %d", data->pid);
+       service_adaptor_debug_func("+++ check object : %s, access_rights : %s", object, access_rights);
+       service_adaptor_debug_func("+++ privilege check ret : %d", ret);
+
+       if (ret) {
+               fprintf(stderr, "[service-adaptor] User space smack denied : subject pid (%d), check object (%s), access rights (%s)\n",
+                               data->pid, object, access_rights);
+               service_adaptor_error("[service-adaptor] User space smack denied : subject pid (%d), check object (%s), access rights (%s)\n",
+                               data->pid, object, access_rights);
+               ret = -504;
+       } else {
+               service_adaptor_debug_func("===== access rights check passed =====");
+       }
+
+       return ret;
+}
+
+int client_checker_check_access_right_read(const char *service_handle_name, const char *path)
+{
+       int ret;
+       char *target_label = NULL;
+       char *check_permission = NULL;
+       service_adaptor_debug("service_handle(%s), path(%s)", service_handle_name, path);
+       if (NULL == path) {
+               __set_last_error("[Permission checker] Invalid path");
+               return -601;
+       }
+
+       /* Gets dir path */
+       char *dir_path = NULL;
+       ret = __get_dir_path(path, &dir_path);
+       if (ret) {
+               service_adaptor_error("path error (%s)", path);
+               return -602;
+       }
+
+       /* Check to 'x' permission to dir_path */
+       check_permission = "x";
+       service_adaptor_info("[serice-adaptor] check dir execute permission : <path : %s> <right : %s>", dir_path, check_permission);
+       target_label = NULL;
+       ret = smack_getlabel(dir_path, &target_label, SMACK_LABEL_ACCESS);
+       if (ret || (NULL == target_label)) {
+               __set_last_error("[Permission checker] Security server internal (%d)", ret);
+               service_adaptor_error("file(%s) label get error (%d)", dir_path, ret);
+               free(dir_path);
+               free(target_label);
+               return -604;
+       }
+
+       service_adaptor_info("target path (%s) label(%s)", dir_path, target_label);
+       ret = client_checker_check_access_rights(service_handle_name, target_label, check_permission);
+
+       if (ret) {
+               __set_last_error("[Permission checker] Folder Access denied rights<%s> label<%s>", target_label, check_permission);
+               fprintf(stderr, "[service-adaptor] smack permission denied : path (%s), right (%s)\n",
+                               dir_path, check_permission);
+               service_adaptor_error("[service-adaptor] smack permission denied : path (%s), right (%s)\n",
+                               dir_path, check_permission);
+               free(dir_path);
+               free(target_label);
+               return -605;
+       } else {
+               service_adaptor_info("===== dir path check passed =====");
+       }
+       free(dir_path);
+
+       /* Check to 'r' permission to path */
+       check_permission = "r";
+        service_adaptor_info("[serice-adaptor] check path execute permission : <path : %s> <right : %s>", path, check_permission);
+       free(target_label);
+       target_label = NULL;
+       ret = smack_getlabel(path, &target_label, SMACK_LABEL_ACCESS);
+       if (ret || (NULL == target_label)) {
+               __set_last_error("[Permission checker] Security server internal (%d)", ret);
+               service_adaptor_error("file(%s) label get error (%d)", path, ret);
+               free(target_label);
+               return -606;
+       }
+
+       service_adaptor_info("target path (%s) label(%s)", path, target_label);
+       ret = client_checker_check_access_rights(service_handle_name, target_label, "r");
+
+       if (ret) {
+               __set_last_error("[Permission checker] Access denied rights<%s> label<%s>", target_label, check_permission);
+               fprintf(stderr, "[service-adaptor] smack permission denied : path (%s), right (%s)\n",
+                               path, check_permission);
+               service_adaptor_error("[service-adaptor] smack permission denied : path (%s), right (%s)\n",
+                               path, check_permission);
+               free(target_label);
+               return -607;
+       } else {
+               service_adaptor_info("===== path check passed =====");
+       }
+
+       free(target_label);
+       return ret;
+}
+
+int client_checker_check_access_right_write(const char *service_handle_name, const char *path)
+{
+       /* TODO */
+       return 0;
+}
+
+int client_checker_check_access_right_create(const char *service_handle_name, const char *path)
+{
+       int ret;
+       char *target_label = NULL;
+       char *check_permission = NULL;
+       service_adaptor_debug("service_handle(%s), path(%s)", service_handle_name, path);
+       if (NULL == path) {
+               return -801;
+       }
+
+       /* Gets dir path */
+       char *dir_path = NULL;
+       ret = __get_dir_path(path, &dir_path);
+       if (ret) {
+               service_adaptor_error("path error (%s)", path);
+               return -802;
+       }
+
+       /* Check to 'rwx' permission to dir_path */
+       check_permission = "rwx";
+       service_adaptor_info("[serice-adaptor] check dir execute permission : <path : %s> <right : %s>", dir_path, check_permission);
+       target_label = NULL;
+       ret = smack_getlabel(dir_path, &target_label, SMACK_LABEL_ACCESS);
+       if (ret || (NULL == target_label)) {
+               service_adaptor_error("file(%s) label get error (%d)", dir_path, ret);
+               free(dir_path);
+               free(target_label);
+               return -804;
+       }
+
+       service_adaptor_info("target path (%s) label(%s)", dir_path, target_label);
+       ret = client_checker_check_access_rights(service_handle_name, target_label, check_permission);
+
+       if (ret) {
+               fprintf(stderr, "[service-adaptor] smack permission denied : path (%s), right (%s)\n",
+                               dir_path, check_permission);
+               service_adaptor_error("[service-adaptor] smack permission denied : path (%s), right (%s)\n",
+                               dir_path, check_permission);
+               free(dir_path);
+               free(target_label);
+               return -805;
+       } else {
+               service_adaptor_info("===== dir path check passed =====");
+       }
+
+       free(target_label);
+       free(dir_path);
+
+       return ret;
+}
+
+
+static void __set_last_error(const char *format, ...)
+{
+       va_list args;
+       va_start(args, format);
+
+       vsnprintf(last_error_message, ERROR_MSG_MAX_LEN, format, args);
+
+       va_end(args);
+}
+
+const char *clieht_checker_get_last_error(void)
+{
+       return last_error_message;
+}
diff --git a/src/util/service_file_manager.c b/src/util/service_file_manager.c
new file mode 100644 (file)
index 0000000..28f8b80
--- /dev/null
@@ -0,0 +1,228 @@
+/*
+* 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 <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <glib.h>
+
+#include <pluginConfig.h>
+
+#include "util/service_file_manager.h"
+#include "service-adaptor-log.h"
+
+/*************************************************
+ *               Type definition
+ *************************************************/
+
+typedef struct _service_file_s {
+       ConfigHandle handle;
+} service_file_t;
+
+#define SERVICE_FILE_ROOT_PATH "/opt/share/service-adaptor/"
+#define SERVICE_FILE_SERVICES_PATH     SERVICE_FILE_ROOT_PATH "services/"
+#define SERVICE_FILE_AUTH_PATH         SERVICE_FILE_ROOT_PATH ".auth/"
+#define SERVICE_FILE_PUSH_PATH         SERVICE_FILE_ROOT_PATH ".push/"
+
+#define SERVICE_FILE_SECTION_STRING_GENERAL    "general"
+#define SERVICE_FILE_SECTION_STRING_BUS                "bus"
+#define SERVICE_FILE_SECTION_STRING_PUSH       "push"
+
+
+/*************************************************
+ *               Global valuable
+ *************************************************/
+
+
+/*************************************************
+ *               Internal function prototype
+ *************************************************/
+
+
+
+/*************************************************
+ *               Public function prototype
+ *************************************************/
+
+int service_file_get_list(service_file_directory_e directory, char ***file_names, int *len);
+
+int service_file_load(service_file_directory_e directory, const char *file_name, service_file_h *service_file);
+
+int service_file_get_string(service_file_h service_file, service_file_section_e section, const char *key, char **value);
+
+int service_file_unload(service_file_h service_file);
+
+
+/*************************************************
+ *               Internal function definition
+ *************************************************/
+
+
+/*************************************************
+ *               Public function definition
+ *************************************************/
+
+int service_file_get_list(service_file_directory_e directory, char ***file_names, int *files_len)
+{
+       service_adaptor_debug("<Start> %s", __FUNCTION__);
+       if ((NULL == file_names) || (NULL == files_len)) {
+               return -101;
+       }
+
+       if (SERVICE_FILE_DIRECTORY_PUSH != directory) {
+               service_adaptor_debug("Not supported yet");
+               return -102;
+       }
+
+       char *path = SERVICE_FILE_PUSH_PATH;
+
+       DIR *dirp = NULL;
+       struct dirent dent, *result = NULL;
+
+       dirp = opendir(path);
+       if (NULL == dirp) {
+               service_adaptor_error("dir open error");
+               return -103;
+       }
+
+       GList *_file_list = NULL;
+       while (0 == readdir_r(dirp, &dent, &result)) {
+               if (NULL == result) {
+                       break;
+               }
+               service_adaptor_debug_func("===== entry name [%s]", dent.d_name);
+               if ((0 == strcmp(".", dent.d_name)) || (0 == strcmp("..", dent.d_name))) {
+                       continue;
+               }
+               char *file = strdup(dent.d_name);
+               if (NULL != file) {
+                       _file_list = g_list_append(_file_list, (void *)file);
+               }
+       }
+
+       closedir(dirp);
+
+       int len = g_list_length(_file_list);
+       char **list = NULL;
+       if (0 < len) {
+               list = (char **) calloc(len, sizeof(char *));
+               if (NULL != list) {
+                       for (int i = 0; i < len; i++) {
+                               list[i] = (char *) g_list_nth_data(_file_list, i);
+                       }
+               } else {
+                       g_list_free_full(_file_list, free);
+                       return -104;
+               }
+       }
+
+       *file_names = list;
+       *files_len = len;
+       g_list_free(_file_list);
+
+       service_adaptor_debug("<End> %s", __FUNCTION__);
+       return 0;
+}
+
+int service_file_load(service_file_directory_e directory, const char *file_name, service_file_h *service_file)
+{
+       service_adaptor_debug("<Start> %s", __FUNCTION__);
+       if ((NULL == file_name) || (NULL == service_file)) {
+               return -201;
+       }
+
+       if (SERVICE_FILE_DIRECTORY_PUSH != directory) {
+               service_adaptor_debug("Not supported yet");
+               return -202;
+       }
+
+       service_adaptor_debug("Aollcates handle's memory");
+       char *path = g_strconcat(SERVICE_FILE_PUSH_PATH, file_name, NULL);
+       service_file_h _service = (service_file_h) calloc(1, sizeof(service_file_t));
+       ConfigHandle handle = plugin_config_create();
+
+       if ((NULL == path) || (NULL == _service) || (NULL == handle)) {
+               service_adaptor_error("Memory allocation failed");
+               g_free(path);
+               free(_service);
+               plugin_config_delete(handle);
+               return -203;
+       }
+
+       plugin_config_load(handle, path, CCT_INI);
+
+       _service->handle = handle;
+       *service_file = _service;
+
+       g_free(path);
+
+       service_adaptor_debug("<End> %s", __FUNCTION__);
+       return 0;
+}
+
+int service_file_get_string(service_file_h service_file, service_file_section_e section, const char *key, char **value)
+{
+       service_adaptor_debug("<Start> %s", __FUNCTION__);
+       if ((NULL == service_file) || (NULL == key) || (NULL == value)) {
+               return -301;
+       }
+
+       char section_name[10] = {0, };
+       switch (section) {
+       case SERVICE_FILE_SECTION_GENERAL:
+               snprintf(section_name, 10, "%s", SERVICE_FILE_SECTION_STRING_GENERAL);
+               break;
+       case SERVICE_FILE_SECTION_PUSH:
+               snprintf(section_name, 10, "%s", SERVICE_FILE_SECTION_STRING_PUSH);
+               break;
+       case SERVICE_FILE_SECTION_BUS:
+               snprintf(section_name, 10, "%s", SERVICE_FILE_SECTION_STRING_BUS);
+               break;
+       default:
+               service_adaptor_debug("Invalid section (%d)", section);
+               return -302;
+       }
+
+       char *data = (char *) plugin_config_get_string(service_file->handle, section_name, key);
+       service_adaptor_debug_func("Config result : section(%s) key(%s) value(%s)",
+                       section_name, key, data);
+       char *_data = NULL;
+       if ((NULL == data) || (NULL == (_data = strdup(data)))) {
+               return -303;
+       }
+       *value = _data;
+
+       service_adaptor_debug("<End> %s", __FUNCTION__);
+       return 0;
+}
+
+int service_file_unload(service_file_h service_file)
+{
+       service_adaptor_debug("<Start> %s", __FUNCTION__);
+       if (NULL == service_file) {
+               return -401;
+       }
+
+       plugin_config_delete(service_file->handle);
+       free(service_file);
+
+       service_adaptor_debug("<End> %s", __FUNCTION__);
+       return 0;
+}
+
+