--- /dev/null
+*.swp
+*~
+tags
+cscope.out
+.gitignore
+
SET(CMAKE_BUILD_TYPE "Debug")
ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
-MESSAGE("")
-MESSAGE(">>> current directory: ${CMAKE_CURRENT_SOURCE_DIR}")
-MESSAGE(">>> Build type: ${CMAKE_BUILD_TYPE}")
+SET(PROVIDER_PATH "${LIB_INSTALL_DIR}/service-provider")
+ADD_DEFINITIONS("-DSERVICE_PROVIDER_INSTALL_PATH=\"${PROVIDER_PATH}\"")
##########################################################
# Define Adaptor
##########################################################
# Define Adaptor API
##########################################################
-#ADD_SUBDIRECTORY(api)
+ADD_SUBDIRECTORY(api)
##########################################################
# Define Adaptor Manager & Execute File
##########################################################
-#ADD_SUBDIRECTORY(server)
+ADD_SUBDIRECTORY(server)
##########################################################
# Define Test App
MESSAGE(">>> Build type: ${CMAKE_BUILD_TYPE}")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VISIBILITY} -fvisibility=hidden")
+#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VISIBILITY} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--gc-sections")
ADD_DEFINITIONS("-DSERVICE_ADAPTOR_DEBUGGING")
ADD_DEFINITIONS("-D_SERVICE_ADAPTOR_IPC_SERVER")
+ADD_DEFINITIONS("-DDEBUG_ADAPTOR_PARAMS")
+
##########################################################
# Define auth adaptor lib
##########################################################
SET(AUTH-LIB "auth-adaptor")
SET(AUTH-SRCS
- ./auth-adaptor/auth-adaptor.c
+ ${CMAKE_SOURCE_DIR}/adaptor/auth-adaptor/auth-adaptor.c
)
INCLUDE_DIRECTORIES(
- ${CMAKE_SOURCE_DIR}/adaptor/auth-adaptor/
${CMAKE_SOURCE_DIR}/common/plugin_config
+ ${CMAKE_SOURCE_DIR}/adaptor/auth-adaptor/
)
INCLUDE(FindPkgConfig)
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
ADD_LIBRARY(${AUTH-LIB} SHARED ${AUTH-SRCS})
-TARGET_LINK_LIBRARIES(${AUTH-LIB} ${auth_pkgs_LDFLAGS} plugin-config)
+TARGET_LINK_LIBRARIES(${AUTH-LIB} ${auth_pkgs_LDFLAGS} plugin-config auth-adaptor)
SET_TARGET_PROPERTIES(${AUTH-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET_TARGET_PROPERTIES(${AUTH-LIB} PROPERTIES VERSION ${VERSION})
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/adaptor/auth-adaptor/auth-adaptor.h DESTINATION /usr/include/)
+#INSTALL(FILES ${CMAKE_SOURCE_DIR}/adaptor/auth-adaptor/auth-adaptor.h DESTINATION /usr/include/)
INSTALL(TARGETS ${AUTH-LIB} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+SET(AUTH-ADAPTOR-HEADERS
+ ${CMAKE_SOURCE_DIR}/adaptor/auth-adaptor/auth-adaptor.h
+)
+INSTALL(FILES ${AUTH-ADAPTOR-HEADERS} DESTINATION include/service-provider)
+
##########################################################
# Define contact adaptor lib
##########################################################
SET(CONTACT-LIB "contact-adaptor")
SET(CONTACT-SRCS
- ./contact-adaptor/contact-adaptor.c
+ ${CMAKE_SOURCE_DIR}/adaptor/contact-adaptor/contact-adaptor.c
)
INCLUDE_DIRECTORIES(
SET_TARGET_PROPERTIES(${CONTACT-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET_TARGET_PROPERTIES(${CONTACT-LIB} PROPERTIES VERSION ${VERSION})
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/adaptor/contact-adaptor/contact-adaptor.h DESTINATION /usr/include/)
+#INSTALL(FILES ${CMAKE_SOURCE_DIR}/adaptor/contact-adaptor/contact-adaptor.h DESTINATION /usr/include/)
INSTALL(TARGETS ${CONTACT-LIB} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+SET(CONTACT-ADAPTOR-HEADERS
+ ${CMAKE_SOURCE_DIR}/adaptor/contact-adaptor/contact-adaptor.h
+)
+INSTALL(FILES ${CONTACT-ADAPTOR-HEADERS} DESTINATION include/service-provider)
##########################################################
# Define storage adaptor lib
SET(STORAGE-LIB "storage-adaptor")
SET(STORAGE-SRCS
- ./storage-adaptor/storage-adaptor.c
+ ${CMAKE_SOURCE_DIR}/adaptor/storage-adaptor/storage-adaptor.c
)
INCLUDE_DIRECTORIES(
- ${CMAKE_SOURCE_DIR}/adaptor/storage-adaptor
${CMAKE_SOURCE_DIR}/common/plugin_config
+ ${CMAKE_SOURCE_DIR}/adaptor/storage-adaptor
)
INCLUDE(FindPkgConfig)
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
ADD_LIBRARY(${STORAGE-LIB} SHARED ${STORAGE-SRCS})
-TARGET_LINK_LIBRARIES(${STORAGE-LIB} ${storage_pkgs_LDFLAGS} plugin-config)
+TARGET_LINK_LIBRARIES(${STORAGE-LIB} ${storage_pkgs_LDFLAGS} storage-adaptor plugin-config)
SET_TARGET_PROPERTIES(${STORAGE-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET_TARGET_PROPERTIES(${STORAGE-LIB} PROPERTIES VERSION ${VERSION})
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/adaptor/storage-adaptor/storage-adaptor.h DESTINATION /usr/include/)
+#INSTALL(FILES ${CMAKE_SOURCE_DIR}/adaptor/storage-adaptor/storage-adaptor.h DESTINATION /usr/include/)
INSTALL(TARGETS ${STORAGE-LIB} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+SET(STORAGE-ADAPTOR-HEADERS
+ ${CMAKE_SOURCE_DIR}/adaptor/storage-adaptor/storage-adaptor.h
+)
+INSTALL(FILES ${STORAGE-ADAPTOR-HEADERS} DESTINATION include/service-provider)
+
##########################################################
# Define message adaptor lib
##########################################################
SET(MESSAGE-LIB "message-adaptor")
SET(MESSAGE-SRCS
- ./message-adaptor/message-adaptor.c
+ ${CMAKE_SOURCE_DIR}/adaptor/message-adaptor/message-adaptor.c
)
INCLUDE_DIRECTORIES(
SET_TARGET_PROPERTIES(${MESSAGE-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET_TARGET_PROPERTIES(${MESSAGE-LIB} PROPERTIES VERSION ${VERSION})
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/adaptor/message-adaptor/message-adaptor.h DESTINATION /usr/include/)
+#INSTALL(FILES ${CMAKE_SOURCE_DIR}/adaptor/message-adaptor/message-adaptor.h DESTINATION /usr/include/)
INSTALL(TARGETS ${MESSAGE-LIB} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+SET(MESSAGE-ADAPTOR-HEADERS
+ ${CMAKE_SOURCE_DIR}/adaptor/message-adaptor/message-adaptor.h
+)
+INSTALL(FILES ${MESSAGE-ADAPTOR-HEADERS} DESTINATION include/service-provider)
+
##########################################################
# Define push adaptor lib
##########################################################
SET(PUSH-LIB "push-adaptor")
SET(PUSH-SRCS
- ./push-adaptor/push-adaptor.c
+ ${CMAKE_SOURCE_DIR}/adaptor/push-adaptor/push-adaptor.c
)
INCLUDE_DIRECTORIES(
SET_TARGET_PROPERTIES(${PUSH-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET_TARGET_PROPERTIES(${PUSH-LIB} PROPERTIES VERSION ${VERSION})
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/adaptor/push-adaptor/push-adaptor.h DESTINATION /usr/include/)
+#INSTALL(FILES ${CMAKE_SOURCE_DIR}/adaptor/push-adaptor/push-adaptor.h DESTINATION /usr/include/)
INSTALL(TARGETS ${PUSH-LIB} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+SET(PUSH-ADAPTOR-HEADERS
+ ${CMAKE_SOURCE_DIR}/adaptor/push-adaptor/push-adaptor.h
+)
+INSTALL(FILES ${PUSH-ADAPTOR-HEADERS} DESTINATION include/service-provider)
+
##########################################################
# Define shop adaptor lib
##########################################################
SET(SHOP-LIB "shop-adaptor")
SET(SHOP-SRCS
- ./shop-adaptor/shop-adaptor.c
+ ${CMAKE_SOURCE_DIR}/adaptor/shop-adaptor/shop-adaptor.c
)
INCLUDE_DIRECTORIES(
SET_TARGET_PROPERTIES(${SHOP-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET_TARGET_PROPERTIES(${SHOP-LIB} PROPERTIES VERSION ${VERSION})
-INSTALL(FILES ${CMAKE_SOURCE_DIR}/adaptor/shop-adaptor/shop-adaptor.h DESTINATION /usr/include/)
+#INSTALL(FILES ${CMAKE_SOURCE_DIR}/adaptor/shop-adaptor/shop-adaptor.h DESTINATION /usr/include/)
INSTALL(TARGETS ${SHOP-LIB} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+
+SET(SHOP-ADAPTOR-HEADERS
+ ${CMAKE_SOURCE_DIR}/adaptor/shop-adaptor/shop-adaptor.h
+)
+INSTALL(FILES ${SHOP-ADAPTOR-HEADERS} DESTINATION include/service-provider)
/**
* Loads plugin from selected path
*/
+EXPORT_API
int storage_adaptor_load_plugin(storage_adaptor_h,
const char *plugin_path);
// For 3rd party plugin packages
+EXPORT_API
int storage_adaptor_load_plugin_from_package(storage_adaptor_h adaptor,
const char *package_id,
const char *plugin_path);
/**
* Unloads selected plugin
*/
+EXPORT_API
int storage_adaptor_unload_plugin(storage_adaptor_h,
storage_adaptor_plugin_h);
/**
* Gets plugin name
*/
+EXPORT_API
void storage_adaptor_get_plugin_uri(storage_adaptor_plugin_h plugin,
char **plugin_uri);
MESSAGE(">>> Build type: ${CMAKE_BUILD_TYPE}")
SET(VISIBILITY "-DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\"")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VISIBILITY} -fvisibility=hidden")
+#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VISIBILITY} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--gc-sections")
ADD_DEFINITIONS("-DSERVICE_ADAPTOR_DEBUGGING")
ADD_DEFINITIONS("-D_SERVICE_ADAPTOR_IPC_CLIENT")
+#ADD_DEFINITIONS("-D__DEBUG_GLIB_ERROR")
+
+
##########################################################
# Define Service Adaptor CLIENT
##########################################################
SET(ADAPTOR-CLIENT-LIB "service-adaptor-client")
-SET(ADAPTOR-CLIENT-SRCS
- ${CMAKE_SOURCE_DIR}/api/client/sal_service_adaptor.c
-# ${CMAKE_SOURCE_DIR}/api/client/sal_service_task.c
-# ${CMAKE_SOURCE_DIR}/api/client/sal_service_auth.c
-# ${CMAKE_SOURCE_DIR}/api/client/sal_service_storage.c
+FILE(GLOB ADAPTOR-CLIENT-SRCS
+ ${CMAKE_SOURCE_DIR}/api/client/src/*.c
+ ${CMAKE_SOURCE_DIR}/api/client/src/dbus/*.c
+ ${CMAKE_SOURCE_DIR}/api/client/src/util/*.c
)
INCLUDE_DIRECTORIES(
+ ${CMAKE_SOURCE_DIR}/server/inc
+ ${CMAKE_SOURCE_DIR}/server/inc/dbus
+
${CMAKE_SOURCE_DIR}/include
- ${CMAKE_SOURCE_DIR}/api/client
- ${CMAKE_SOURCE_DIR}/common/base
- ${CMAKE_SOURCE_DIR}/common/ipc-client
-# ${CMAKE_SOURCE_DIR}/adaptor/auth-adaptor
-# ${CMAKE_SOURCE_DIR}/adaptor/contact-adaptor
-# ${CMAKE_SOURCE_DIR}/adaptor/storage-adaptor
+ ${CMAKE_SOURCE_DIR}/api/client/include
+ ${CMAKE_SOURCE_DIR}/api/client/include/private
+ ${CMAKE_SOURCE_DIR}/api/client/include/dbus
+ ${CMAKE_SOURCE_DIR}/api/client/include/util
)
INCLUDE(FindPkgConfig)
ADD_LIBRARY(${ADAPTOR-CLIENT-LIB} SHARED ${ADAPTOR-CLIENT-SRCS})
-TARGET_LINK_LIBRARIES(${ADAPTOR-CLIENT-LIB} ${adaptor_client_pkgs_LDFLAGS} sal-common-base sal-common-client)
+TARGET_LINK_LIBRARIES(${ADAPTOR-CLIENT-LIB} ${adaptor_client_pkgs_LDFLAGS})
SET_TARGET_PROPERTIES(${ADAPTOR-CLIENT-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET_TARGET_PROPERTIES(${ADAPTOR-CLIENT-LIB} PROPERTIES VERSION ${VERSION})
SET(SAL-ADAPTOR-CLIENT-HEADERS
${CMAKE_SOURCE_DIR}/include/service_adaptor_client.h
${CMAKE_SOURCE_DIR}/include/service_adaptor_client_plugin.h
-# ${CMAKE_SOURCE_DIR}/include/service_adaptor_client_storage.h
- ${CMAKE_SOURCE_DIR}/include/service_adaptor_type.h
-# ${CMAKE_SOURCE_DIR}/include/service_adaptor_errors.h
-# ${CMAKE_SOURCE_DIR}/include/service_adaptor_internal.h
-# ${CMAKE_SOURCE_DIR}/client/sal_service_adaptor.h
-# ${CMAKE_SOURCE_DIR}/client/sal_service_task.h
-# ${CMAKE_SOURCE_DIR}/client/sal_service_auth.h
-# ${CMAKE_SOURCE_DIR}/client/sal_service_storage.h
-# ${CMAKE_SOURCE_DIR}/common/base/sal_ipc.h
-# ${CMAKE_SOURCE_DIR}/common/ipc-client/sal_ipc_client.h
-# ${CMAKE_SOURCE_DIR}/common/ipc-client/sal_ipc_client_core.h
-# ${CMAKE_SOURCE_DIR}/common/ipc-client/sal_ipc_client_auth.h
-# ${CMAKE_SOURCE_DIR}/common/ipc-client/sal_ipc_client_storage.h
+ ${CMAKE_SOURCE_DIR}/include/service_adaptor_client_storage.h
+
+ ${CMAKE_SOURCE_DIR}/api/client/include/service_adaptor_client_private.h
+ ${CMAKE_SOURCE_DIR}/api/client/include/service_adaptor_client_storage_internal.h
+ ${CMAKE_SOURCE_DIR}/api/client/include/service_adaptor_client_type.h
+
+ ${CMAKE_SOURCE_DIR}/api/client/include/private/service-adaptor-client.h
+ ${CMAKE_SOURCE_DIR}/api/client/include/private/service-adaptor-client-auth.h
+ ${CMAKE_SOURCE_DIR}/api/client/include/private/service-adaptor-client-contact.h
+ ${CMAKE_SOURCE_DIR}/api/client/include/private/service-adaptor-client-message.h
+ ${CMAKE_SOURCE_DIR}/api/client/include/private/service-adaptor-client-push.h
+ ${CMAKE_SOURCE_DIR}/api/client/include/private/service-adaptor-client-shop.h
+ ${CMAKE_SOURCE_DIR}/api/client/include/private/service-adaptor-client-storage.h
)
INSTALL(FILES ${SAL-ADAPTOR-CLIENT-HEADERS} DESTINATION include/service-adaptor)
-##########################################################
-# Define Service Provider CLIENT
-##########################################################
-
-SET(PLUGIN-CLIENT-LIB "service-provider")
-SET(PLUGIN-CLIENT-SRCS
- ${CMAKE_SOURCE_DIR}/api/provider/sal_provider_service.c
- ${CMAKE_SOURCE_DIR}/api/provider/sal_provider_base.c
- ${CMAKE_SOURCE_DIR}/api/provider/sal_provider_storage.c
-)
-
-INCLUDE_DIRECTORIES(
- ${CMAKE_SOURCE_DIR}/include
- ${CMAKE_SOURCE_DIR}/api/provider
- ${CMAKE_SOURCE_DIR}/common/base
- ${CMAKE_SOURCE_DIR}/common/ipc-provider
-)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(plugin_client_pkgs REQUIRED dlog glib-2.0 capi-appfw-application capi-appfw-service-application)
-
-FOREACH(flag ${plugin_client_pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -std=gnu99")
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
-
-ADD_LIBRARY(${PLUGIN-CLIENT-LIB} SHARED ${PLUGIN-CLIENT-SRCS})
-
-TARGET_LINK_LIBRARIES(${PLUGIN-CLIENT-LIB} ${plugin_client_pkgs_LDFLAGS})
-SET_TARGET_PROPERTIES(${PLUGIN-CLIENT-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
-SET_TARGET_PROPERTIES(${PLUGIN-CLIENT-LIB} PROPERTIES VERSION ${VERSION})
-
-INSTALL(TARGETS ${PLUGIN-CLIENT-LIB} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
-
-SET(SAL-PLUGIN-CLIENT-HEADERS
- ${CMAKE_SOURCE_DIR}/include/service_provider.h
- ${CMAKE_SOURCE_DIR}/include/service_provider_types.h
- ${CMAKE_SOURCE_DIR}/include/storage_provider.h
-)
-
-INSTALL(FILES ${SAL-PLUGIN-CLIENT-HEADERS} DESTINATION include/service-provider)
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: dbus-client.h
+ * Desc: D-Bbus IPC client APIs
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ * @file dbus-client.h
+ * @brief Defines interface of D-Bus IPC
+ * @version 0.1
+ */
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_private.h"
+
+#define __safe_add_string(x) (x==NULL)?"":x
+
+#define SECURITY_SERVER_COOKIE_BUFFER_SIZE 21
+
+/*==================================================================================================
+ FUNCTION PROTOTYPES
+==================================================================================================*/
+
+GDBusProxy *_dbus_get_sac_interface_proxy();
+
+/**
+ * @brief Service Adaptor D-Bus client initialization.
+ */
+int _dbus_client_service_adaptor_init();
+
+/**
+ * @brief Service Adaptor D-Bus client deinitialization.
+ */
+void _dbus_client_service_adaptor_deinit();
+
+
+/**
+ * @brief Adds string into variant builder
+ */
+void __safe_g_variant_builder_add_string(GVariantBuilder *builder,
+ const char *data);
+
+/**
+ * @brief Adds string into array variant builder
+ */
+void __safe_g_variant_builder_add_array_string(GVariantBuilder *builder,
+ const char *data);
+
+/**
+ * @brief Returns NULL point if string is ""
+ */
+char *ipc_g_variant_dup_string(GVariant *string);
+
+/**
+ * @brief
+ * @param[out]
+ * @param[out]
+ * @return
+ * @pre This function requires opened DBus connection by service-adaptor-client.c
+ */
+int _dbus_connect_service_adaptor(service_adaptor_error_s *error);
+
+int _dbus_disconnect_service_adaptor(service_adaptor_error_s *error);
+
+int _dbus_get_plugin_list(plugin_entry_t ***plugin_list, unsigned int *plugins_len, service_adaptor_error_s *error);
+
+int _dbus_is_login_required(service_plugin_h plugin, bool *required, service_adaptor_error_s *error);
+
+int _dbus_request_login(service_plugin_h plugin, void *callback, void *user_data, service_adaptor_error_s *error);
+
+int _dbus_start_service(service_plugin_h plugin, int service_flag, const char *security_cookie, service_adaptor_error_s *error);
+
+int _dbus_external_request(const char *service_name,
+ int service_flag,
+ const char *api_uri,
+ unsigned char *input_str,
+ int input_len,
+ unsigned char **output_str,
+ int *output_len,
+ service_adaptor_error_s *error);
+
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: dbus-client-auth.h
+ * Desc: D-Bbus IPC client APIs for auth
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ * @file dbus-client-auth.h
+ * @brief Defines interface of D-Bus IPC
+ * @version 0.1
+ */
+
+#ifndef __DBUS_CLIENT_AUTH_H__
+#define __DBUS_CLIENT_AUTH_H__
+
+#include <glib.h>
+#include "service_adaptor_client_type.h"
+#include "private/service-adaptor-client-auth.h"
+
+/**
+ * @brief
+ * @param[out]
+ * @param[out]
+ * @return
+ * @pre This function requires opened DBus connection by service-adaptor-client-auth.c
+ */
+int _dbus_get_auth_plugin_list(GList **plugin_list,
+ const char *imsi,
+ service_adaptor_error_s *error);
+
+int _dbus_set_auth(const char *service_name,
+ const char *imsi,
+ const char *name,
+ const char *app_id,
+ const char *app_secret,
+ unsigned int service_id,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+#endif /* __DBUS_CLIENT_AUTH_H__ */
+
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: dbus-client-contact.h
+ * Desc: D-Bbus IPC client APIs for contact
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ * @file dbus-client-contact.h
+ * @brief Defines interface of D-Bus IPC
+ * @version 0.1
+ */
+
+#ifndef __DBUS_CLIENT_CONTACT_H__
+#define __DBUS_CLIENT_CONTACT_H__
+
+#include <glib.h>
+#include "service_adaptor_client_type.h"
+#include "private/service-adaptor-client-contact.h"
+
+#define CONTACT_PROFILE_IMAGE_PATH_LEN 2048
+
+typedef struct _service_adaptor_profile_image_s
+{
+ service_adaptor_contact_request_type_e type;
+ int index;
+ char path[CONTACT_PROFILE_IMAGE_PATH_LEN];
+} service_adaptor_profile_image_s;
+
+
+/**
+ * @brief
+ * @param[out]
+ * @param[out]
+ * @return
+ * @pre This function requires opened DBus connection by service-adaptor-client-contact.c
+ */
+int _dbus_set_new_contact_list(const char *service_name,
+ service_adaptor_contact_req_s *contact_req,
+ void *user_data,
+ service_adaptor_contact_res_s **contact_res,
+ void **server_data,
+ service_adaptor_error_s *error);
+
+int _dbus_set_contact_list(const char *service_name,
+ service_adaptor_contact_req_s *contact_req,
+ void *user_data,
+ service_adaptor_contact_res_s **contact_res,
+ void **server_data,
+ service_adaptor_error_s *error);
+
+int _dbus_get_contact_list(const char *service_name,
+ service_adaptor_contact_res_s **contact_res,
+ void **server_data,
+ service_adaptor_error_s *error);
+
+int _dbus_get_contact_infos_polling(const char *service_name,
+ service_adaptor_contact_req_s *contact_req,
+ void *user_data,
+ service_adaptor_contact_res_s **contact_res,
+ void **server_data,
+ service_adaptor_error_s *error);
+
+int _dbus_set_me_profile_with_push(const char *service_name,
+ service_adaptor_profile_req_s *profile_req,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_get_profile(const char *service_name,
+ service_adaptor_profile_req_s *profile_req,
+ void *user_data,
+ service_adaptor_profile_res_s **profile_res,
+ void **server_data,
+ service_adaptor_error_s *error);
+
+int _dbus_set_profile_image_meta_with_push(const char *service_name,
+ service_adaptor_profile_image_h *images,
+ unsigned int images_len,
+ void *user_data,
+ service_adaptor_profile_image_h **failed_images,
+ unsigned int *failed_images_len,
+ void **server_data,
+ service_adaptor_error_s *error);
+
+int _dbus_delete_me_profile_image_meta_with_push(const char *service_name,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_set_me_profile_privacy(const char *service_name,
+ service_adaptor_privacy_req_s *privacy_req,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_get_me_profile_privacy(const char *service_name,
+ service_adaptor_privacy_res_s **privacy_res,
+ void **server_data,
+ service_adaptor_error_s *error);
+
+int _dbus_set_me_presence_with_push(const char *service_name,
+ service_adaptor_presence_req_s *presence_req,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_set_me_presence_on_off_with_push(const char *service_name,
+ service_adaptor_presence_req_s *presence_req,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_set_me_profile_type(const char *service_name,
+ int type,
+ char **url,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+#endif /* __DBUS_CLIENT_CONTACT_H__ */
+
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: dbus-client-layer.h
+ * Desc: D-Bbus IPC client
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ * @file dbus-client-layer.h
+ * @brief Defines interface of D-Bus IPC
+ * @version 0.1
+ */
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_LAYER_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_LAYER_H__
+
+/*==================================================================================================
+ FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+ * @brief Initialize D-Bus IPC client layer.
+ *
+ * Initialize D-Bus IPC client layer. Must be called once at startup before any call to Service Adaptor
+ * client API is made.
+ * @return 0 on success, -1 on error.
+ */
+int _dbus_client_layer_init();
+
+/**
+ * @brief Deinitialize D-Bus IPC client layer.
+ *
+ * Deinitialize D-Bus IPC client layer. Should be run once at shutdown.
+ */
+void _dbus_client_layer_deinit();
+
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_LAYER_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: dbus-client-message.h
+ * Desc: D-Bbus IPC client APIs for message
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ * @file dbus-client-message.h
+ * @brief Defines interface of D-Bus IPC
+ * @version 0.1
+ */
+
+#ifndef __DBUS_CLIENT_MESSAGE_H__
+#define __DBUS_CLIENT_MESSAGE_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+#include "service_adaptor_client_type.h"
+#include "private/service-adaptor-client-message.h"
+
+void on_message_signal(GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data);
+
+/**
+ * @brief
+ * @param[out]
+ * @param[out]
+ * @return
+ * @pre This function requires opened DBus connection by service-adaptor-client-messaging.c
+ */
+int _dbus_request_create_chatroom(const char *service_name,
+ long long int request_id,
+ int chat_type,
+ long long int *receivers,
+ unsigned int receivers_len,
+ const char *chatroom_title,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_request_change_chatroom_meta(const char *service_name,
+ long long int request_id,
+ long long int chatroom_id,
+ const char *chatroom_title,
+ int default_message_ttl,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_request_chat(const char *service_name,
+ long long int request_id,
+ long long int chatroom_id,
+ service_adaptor_chat_msg_s **chat_msgs,
+ unsigned int chat_msgs_len,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_request_allow_chat(const char *service_name,
+ long long int request_id,
+ long long int chatroom_id,
+ bool is_auto_allow,
+ int max_count,
+ bool need_delivery_ack,
+ unsigned long long last_delivery_ack_timestamp,
+ bool need_read_ack,
+ unsigned long long last_read_ack_timestamp,
+ bool need_ordered_chat_member_list,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_request_all_unread_message(const char *service_name,
+ long long int request_id,
+ int max_count,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_reply_forward_online_message(const char *service_name,
+ long long int request_id,
+ long long int chatroom_id,
+ bool mark_as_read,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_reply_forward_unread_message(const char *service_name,
+ long long int request_id,
+ const char *next_pagination_key,
+ int max_count,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_request_read_message(const char *service_name,
+ long long int request_id,
+ long long int chatroom_id,
+ service_adaptor_inbox_message_s *inbox_msg,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_request_invite_chat(const char *service_name,
+ long long int request_id,
+ long long int chatroom_id,
+ long long int *inviting_members,
+ unsigned int inviting_members_len,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_request_end_chat(const char *service_name,
+ long long int request_id,
+ service_adaptor_end_chat_s **end_chats,
+ unsigned int end_chats_len,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_request_unseal_message(const char *service_name,
+ long long int request_id,
+ long long int chatroom_id,
+ long long int sender_id,
+ long long int message_id,
+ const char *message_detail,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_request_save_call_log(const char *service_name,
+ long long int request_id,
+ long long int chatroom_id,
+ const char *call_id,
+ const char *call_log_type,
+ long long int call_sender_id,
+ long long int call_receiver_id,
+ int conversaction_second,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_request_current_time(const char *service_name,
+ long long int request_id,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_request_get_connection_policy(const char *service_name,
+ service_adaptor_connection_policy_e *policy,
+ service_adaptor_error_s *error);
+
+int _dbus_request_set_connection_policy(const char *service_name,
+ service_adaptor_connection_policy_e *policy,
+ service_adaptor_error_s *error);
+
+int _dbus_get_chat_id_list(const char *service_name,
+ service_adaptor_phone_number_s **phone_numbers,
+ unsigned int phone_numbers_len,
+ void *user_data,
+ service_adaptor_chat_id_s ***chat_ids,
+ unsigned int *chat_ids_len,
+ void **server_data,
+ service_adaptor_error_s *error);
+
+int _dbus_get_msisdn_list(const char *service_name,
+ long long int *chat_ids,
+ unsigned int chat_ids_len,
+ void *user_data,
+ service_adaptor_chat_id_s ***msisdns,
+ unsigned int *msisdns_len,
+ void **server_data,
+ service_adaptor_error_s *error);
+
+#endif /* __DBUS_CLIENT_MESSAGE_H__ */
+
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: dbus-client-push.h
+ * Desc: D-Bbus IPC client APIs for auth
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ * @file dbus-client-push.h
+ * @brief Defines interface of D-Bus IPC
+ * @version 0.1
+ */
+
+#ifndef __DBUS_CLIENT_PUSH_H__
+#define __DBUS_CLIENT_PUSH_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+#include "service_adaptor_client_type.h"
+#include "private/service-adaptor-client-push.h"
+
+void on_push_signal(GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data);
+
+/**
+ * @brief
+ * @param[out]
+ * @param[out]
+ * @return
+ * @pre This function requires opened DBus connection by service-adaptor-client-push.c
+ */
+
+int _dbus_push_register(const char *file_name,
+ service_adaptor_error_s *error);
+
+int _dbus_push_deregister(const char *file_name,
+ service_adaptor_error_s *error);
+#endif /* __DBUS_CLIENT_PUSH_H__ */
+
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: dbus-client-shop.h
+ * Desc: D-Bbus IPC client APIs for shop
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ * @file dbus-client-shop.h
+ * @brief Defines interface of D-Bus IPC
+ * @version 0.1
+ */
+
+#ifndef __DBUS_CLIENT_SHOP_H__
+#define __DBUS_CLIENT_SHOP_H__
+
+#include <glib.h>
+#include "service_adaptor_client_type.h"
+#include "private/service-adaptor-client-shop.h"
+
+/**
+ * @brief
+ * @param[out]
+ * @param[out]
+ * @return
+ * @pre This function requires opened DBus connection by service-adaptor-client-shop.c
+ */
+int _dbus_get_item_list(const char *service_name,
+ service_adaptor_shop_info_s *info,
+ void *user_data,
+ service_adaptor_shop_item_s ***items,
+ unsigned int *items_len,
+ void **server_data,
+ service_adaptor_error_s *error);
+
+int _dbus_download_item_package(const char *service_name,
+ service_adaptor_shop_info_s *info,
+ void *user_data,
+ service_adaptor_shop_item_s **item,
+ void **server_data,
+ service_adaptor_error_s *error);
+
+int _dbus_download_sticker(const char *service_name,
+ service_adaptor_shop_info_s *info,
+ void *user_data,
+ service_adaptor_shop_item_s **item,
+ void **server_data,
+ service_adaptor_error_s *error);
+
+int _dbus_get_panel_url(const char *service_name,
+ service_adaptor_shop_info_s *info,
+ void *user_data,
+ service_adaptor_shop_item_s **item,
+ void **server_data,
+ service_adaptor_error_s *error);
+
+#endif /* __DBUS_CLIENT_SHOP_H__ */
+
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: dbus-client-storage.h
+ * Desc: D-Bbus IPC client APIs for storage
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ * @file dbus-client-storage.h
+ * @brief Defines interface of D-Bus IPC
+ * @version 0.1
+ */
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_STORAGE_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_STORAGE_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_storage.h"
+#include "service_adaptor_client_storage_internal.h"
+
+//////////////////////// private feature
+#include "private/service-adaptor-client-storage.h"
+//////////////////////// private feature
+
+void on_storage_signal(GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data);
+
+/**
+ * @brief
+ * @param[out]
+ * @param[out]
+ * @return
+ * @pre This function requires opened DBus connection by service-adaptor-client-storage.c
+ */
+int _dbus_download_file(const char *service_name,
+ const char *server_path,
+ const char *download_path,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_download_thumbnail(const char *service_name,
+ const char *server_path,
+ const char *download_path,
+ int thumbnail_size,
+ service_adaptor_error_s *error);
+
+int _dbus_download_file_async(const char *service_name,
+ const char *server_path,
+ const char *download_path,
+ service_storage_file_h *file_handle,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_upload_file(const char *service_name,
+ const char *upload_path,
+ const char *server_path,
+ service_storage_file_h *file_info,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_upload_file_async(const char *service_name,
+ const char *upload_path,
+ const char *server_path,
+ service_storage_file_h *file_handle,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_get_root_folder_path(const char *service_name,
+ char **root_folder_path,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_make_directory(const char *service_name,
+ const char *folder_path,
+ service_storage_file_h *file_info,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_remove_file(const char *service_name,
+ const char *file_path,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_remove_directory(const char *service_name,
+ const char *folder_path,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_move_file(const char *service_name,
+ const char *src_file_path,
+ const char *dst_file_path,
+ service_storage_file_h *file_info,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_move_directory(const char *service_name,
+ const char *src_folder_path,
+ const char *dst_folder_path,
+ service_storage_file_h *file_info,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_get_file_list(const char *service_name,
+ const char *parent_path,
+ service_storage_file_h **file_info_list,
+ unsigned int *file_info_list_len,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_open_upload_file(const char *_service_name,
+ const char *_file_path,
+ const char *_upload_path,
+ long long int *_task_id,
+ service_adaptor_error_s *error);
+
+int _dbus_open_download_file(const char *_service_name,
+ const char *_storage_path,
+ const char *_download_path,
+ long long int *_task_id,
+ service_adaptor_error_s *error);
+
+int _dbus_open_download_thumbnail(const char *_service_name,
+ const char *_storage_path,
+ const char *_download_path,
+ int _thumbnail_size,
+ long long int *_task_id,
+ service_adaptor_error_s *error);
+
+int _dbus_close_file_task(const char *_service_name,
+ long long int _task_id,
+ service_adaptor_error_s *error);
+
+int _dbus_start_upload_file(const char *_service_name,
+ long long int _task_id,
+ const char *_storage_path,
+ bool _need_progress,
+ bool _need_state,
+ service_adaptor_error_s *error);
+
+int _dbus_start_download_file(const char *_service_name,
+ long long int _task_id,
+ const char *_storage_path,
+ bool _need_progress,
+ bool _need_state,
+ service_adaptor_error_s *error);
+
+int _dbus_start_download_thumbnail(const char *_service_name,
+ long long int _task_id,
+ const char *_storage_path,
+ int thumbnail_size,
+ bool _need_progress,
+ bool _need_state,
+ service_adaptor_error_s *error);
+
+int _dbus_cancel_upload_file(const char *_service_name,
+ long long int _task_id,
+ service_adaptor_error_s *error);
+
+int _dbus_cancel_download_file(const char *_service_name,
+ long long int _task_id,
+ service_adaptor_error_s *error);
+
+int _dbus_cancel_download_thumbnail(const char *_service_name,
+ long long int _task_id,
+ service_adaptor_error_s *error);
+
+
+
+
+///////////////////// private feature
+
+
+int _private_dbus_download_file_async(const char *service_name,
+ const char *server_path,
+ const char *download_path,
+ service_adaptor_file_h *file_handle,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _private_dbus_upload_file_async(const char *service_name,
+ const char *upload_path,
+ const char *server_path,
+ service_adaptor_file_h *file_handle,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+
+
+int _dbus_download_file_publish(const char *service_name,
+ const char *server_path,
+ const char *download_path,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_download_file_publish_async(const char *service_name,
+ const char *server_path,
+ const char *download_path,
+ service_adaptor_file_h *file_handle,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_upload_file_publish(const char *service_name,
+ const char *upload_path,
+ const char *server_path,
+ char **publish_url,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_upload_file_publish_async(const char *service_name,
+ const char *upload_path,
+ const char *server_path,
+ service_adaptor_file_h *file_handle,
+ void *user_data,
+ service_adaptor_error_s *error);
+
+int _dbus_get_file_status(const char *service_name,
+ service_adaptor_file_h file_handle,
+ service_adaptor_file_status_s **status,
+ void **server_data,
+ service_adaptor_error_s *error);
+
+int _dbus_cancel_file_transfer(const char *service_name,
+ service_adaptor_file_h file_handle,
+ void **server_data,
+ service_adaptor_error_s *error);
+
+int _dbus_pause_file_transfer(const char *service_name,
+ service_adaptor_file_h file_handle,
+ void **server_data,
+ service_adaptor_error_s *error);
+
+int _dbus_resume_file_transfer(const char *service_name,
+ service_adaptor_file_h file_handle,
+ void **server_data,
+ service_adaptor_error_s *error);
+
+
+
+///////////////////// private feature
+
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_DBUS_CLIENT_STORAGE_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: service-adaptor-client-auth.h
+ * Desc: Service Adaptor APIs
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ * @file service-adaptor-client-auth.h
+ * @brief Defines interface of Service Adaptor's Auth
+ * @version 0.1
+ */
+
+#ifndef __PRIVATE_SERVICE_ADAPTOR_CLIENT_AUTH_H__
+#define __PRIVATE_SERVICE_ADAPTOR_CLIENT_AUTH_H__
+
+#include "service-adaptor-client.h"
+#include "service_adaptor_client_type.h"
+
+/*==================================================================================================
+ FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+* @brief Gets Auth Plugin List
+*
+* @param[in] handle the handle which is returned in service_adaptor_connect
+* @param[out] plugins list of auth plugins including plugin name and available
+* @param[out] plugins_len length of plugins
+* @param[out] error_code specifies error code
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_auth_plugin(service_adaptor_h handle,
+ service_adaptor_plugin_h **plugins,
+ unsigned int *plugins_len,
+ service_adaptor_error_s **error_code);
+
+/**
+* @brief Sets Plugin
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] plugin_handle The handle which is returned in service_adaptor_get_auth_plugin
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_auth_plugin(service_adaptor_h handle,
+ service_adaptor_plugin_h plugin_handle);
+
+/**
+* @brief Requests Channel Auth
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] service_name specifies service name like "com.serviceadaptor.message"
+* @param[in] app_id specifies app id
+* @param[in] app_secret specifies app secret
+* @param[in] service_id specifies service id (0: contact, 1: free message)
+* @param[in] imsi specifies imsi
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED Need authorization
+* @retval #SERVICE_ADAPTOR_ERROR_NETWORK Failed by network
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_adaptor_set_auth(service_adaptor_h handle,
+ const char *service_name,
+ const char *app_id,
+ const char *app_secret,
+ unsigned int service_id,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+#endif /* __PRIVATE_SERVICE_ADAPTOR_CLIENT_AUTH_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+/******************************************************************************
+ * File: service-adaptor-client-contact.h
+ * Desc: Service Adaptor APIs
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ * @file service-adaptor-client-contact.h
+ * @brief Defines interface of Service Adaptor's Contact
+ * @version 0.1
+ */
+
+#ifndef __SERVICE_ADAPTOR_CLIENT_CONTACT_H__
+#define __SERVICE_ADAPTOR_CLIENT_CONTACT_H__
+
+#include "service-adaptor-client.h"
+#include "service_adaptor_client_type.h"
+#include "service-adaptor-client-storage.h"
+
+typedef struct _service_adaptor_profile_image_s *service_adaptor_profile_image_h;
+
+/**
+* @brief Describes contact infromation for request
+*/
+typedef struct _service_adaptor_contact_info_req_s
+{
+ char *tp; /**< specifies status as none*/
+ char *id; /**< specifies status as none*/
+ char *pn; /**< specifies status as none*/
+ char *nm; /**< specifies status as none*/
+ char *cc; /**< specifies status as none*/
+} service_adaptor_contact_info_req_s;
+
+/**
+* @brief Describes request infromation about contact
+*/
+typedef struct _service_adaptor_contact_req_s
+{
+ long long int tt; /**< specifies status as none*/
+ service_adaptor_contact_info_req_s **cts; /**< specifies status as none*/
+ unsigned int cts_len; /**< specifies status as none*/
+} service_adaptor_contact_req_s;
+
+/**
+* @brief Describes contact infromation for response
+*/
+typedef struct _service_adaptor_contact_info_res_s
+{
+ char *duid; /**< specifies status as none*/
+ char *id; /**< specifies status as none*/
+ char *msisdn; /**< specifies status as none*/
+ char *ty; /**< specifies status as none*/
+ char *cc; /**< specifies status as none*/
+ char *pn; /**< specifies status as none*/
+ char *nm; /**< specifies status as none*/
+ char **evnt; /**< specifies status as none*/
+ unsigned int evnt_len; /**< specifies status as none*/
+// char *img; /**< specifies status as none*/
+ service_adaptor_profile_image_h *images;
+ unsigned int images_len;
+ char **adrs; /**< specifies status as none*/
+ unsigned int adrs_len; /**< specifies status as none*/
+ char **mail; /**< specifies status as none*/
+ unsigned int mail_len; /**< specifies status as none*/
+ char *org; /**< specifies status as none*/
+ char *prsc; /**< specifies status as none*/
+ char *status; /**< specifies status as none*/
+ unsigned int sids; /**< specifies status as none*/
+ int profile_type;
+ char *profile_url;
+} service_adaptor_contact_info_res_s;
+
+/**
+* @brief Describes response infromation about contact
+*/
+typedef struct _service_adaptor_contact_res_s
+{
+ long long int tt; /**< specifies status as none*/
+ service_adaptor_contact_info_res_s **cts; /**< specifies status as none*/
+ unsigned int cts_len; /**< specifies status as none*/
+} service_adaptor_contact_res_s;
+
+/**
+* @brief Describes request infromation about profile
+*/
+typedef struct _service_adaptor_profile_req_s
+{
+ char *cc; /**< specifies status as none*/
+ char *pn; /**< specifies status as none*/
+ char *nm; /**< specifies status as none*/
+ char **evnt; /**< specifies status as none*/
+ unsigned int evnt_len; /**< specifies status as none*/
+ char *img; /**< specifies status as none*/
+ char **adrs; /**< specifies status as none*/
+ unsigned int adrs_len; /**< specifies status as none*/
+ char **mail; /**< specifies status as none*/
+ unsigned int mail_len; /**< specifies status as none*/
+ char *org; /**< specifies status as none*/
+ char *prsc; /**< specifies status as none*/
+ char *status; /**< status message*/
+} service_adaptor_profile_req_s;
+
+/**
+* @brief Describes response infromation about profile
+*/
+typedef struct _service_adaptor_profile_res_s
+{
+ char *nm; /**< specifies status as none*/
+ char *img; /**< specifies status as none*/
+ char *prsc; /**< specifies status as none*/
+ char *status; /**< specifies status as none*/
+} service_adaptor_profile_res_s;
+
+/**
+* @brief Describes privacy infromation for request
+*/
+typedef struct _service_adaptor_privacy_info_req_s
+{
+ char *cc; /**< specifies status as none*/
+ char *pn; /**< specifies status as none*/
+} service_adaptor_privacy_info_req_s;
+
+/**
+* @brief Describes request infromation about privacy
+*/
+typedef struct _service_adaptor_privacy_req_s
+{
+ unsigned int lvl; /**< specifies status as none*/
+ service_adaptor_privacy_info_req_s **cts; /**< specifies status as none*/
+ unsigned int cts_len; /**< specifies status as none*/
+} service_adaptor_privacy_req_s;
+
+/**
+* @brief Describes response infromation about privacy
+*/
+typedef struct _service_adaptor_privacy_res_s
+{
+ unsigned int lvl; /**< specifies status as none*/
+ unsigned int prscon; /**< specifies status as none*/
+} service_adaptor_privacy_res_s;
+
+/**
+* @brief Describes presence infromation for request
+*/
+typedef struct _service_adaptor_presence_req_s
+{
+ char *prsc; /**< specifies status as none*/
+ char *status; /**< specifies status as none*/
+ unsigned int prscon; /**< specifies status as none*/
+} service_adaptor_presence_req_s;
+
+/*==================================================================================================
+ FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+* @brief Resets contact information in Contact Server and
+* uploads native contact information of device to the server
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] contact_req request information about contact
+* @param[in] user_data specifies user_data (json) passed in API
+* @param[out] contact_res response information about contact
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_new_contact_list(service_adaptor_h handle,
+ service_adaptor_contact_req_s *contact_req,
+ void *user_data,
+ service_adaptor_contact_res_s **contact_res,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+
+/**
+* @brief Synchronizes native contact information of device with Contact Server
+* according to [type] field of each contact
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] contact_req request information about contact
+* @param[in] user_data specifies user_data (json) passed in API
+* @param[out] contact_res response information about contact
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_contact_list(service_adaptor_h handle,
+ service_adaptor_contact_req_s *contact_req,
+ void *user_data,
+ service_adaptor_contact_res_s **contact_res,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+
+/**
+* @brief Gets profile and service registration information of each contact
+* (only contacts agreed to share with me are returned)
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[out] contact_res response information about contact
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_contact_infos_latest(service_adaptor_h handle,
+ service_adaptor_contact_res_s **contact_res,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+
+/**
+* @brief Gets profiles and service registration information of contacts
+* that have been updated since last update
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] contact_req request information about contact
+* @param[in] user_data specifies user_data (json) passed in API
+* @param[out] contact_res response information about contact
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_contact_infos_polling(service_adaptor_h handle,
+ service_adaptor_contact_req_s *contact_req,
+ void *user_data,
+ service_adaptor_contact_res_s **contact_res,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+
+/**
+* @brief Sets or updates device’s profile to server
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] profile_req request information about profile
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_me_profile_with_push(service_adaptor_h handle,
+ service_adaptor_profile_req_s *profile_req,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Gets the profile information of a contact which is correspondent with
+* country code (optional) and phone number (mandatory)
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] profile_req request information about profile
+* @param[in] user_data specifies user_data (json) passed in API
+* @param[out] profile_res response information about profile
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_profile(service_adaptor_h handle,
+ service_adaptor_profile_req_s *profile_req,
+ void *user_data,
+ service_adaptor_profile_res_s **profile_res,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+
+/**
+* @brief Uploads profile image meta to File Server and sets my profile image to Profile Server
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] file_paths file information for request
+* @param[in] user_data specifies user_data (json) passed in API
+* @param[out] server_paths file information for response
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_profile_image_meta_with_push(service_adaptor_h handle,
+ service_adaptor_profile_image_h *images,
+ unsigned int images_len,
+ void *user_data,
+ service_adaptor_profile_image_h **failed_images,
+ unsigned int *failed_images_len,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+
+/**
+* @brief Deletes profile image meta from Profile Server
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] server_paths file information responsed by xxx_set_profile_image_meta_with_push()
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_delete_me_profile_image_meta_with_push(service_adaptor_h handle,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Sets the level of privacy, the scope of people to be opened
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] privacy_req request information about privacy
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_me_profile_privacy(service_adaptor_h handle,
+ service_adaptor_privacy_req_s *privacy_req,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Gets my profile’s privacy level
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[out] privacy_res response information about privacy
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_me_profile_privacy(service_adaptor_h handle,
+ service_adaptor_privacy_res_s **privacy_res,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+
+/**
+* @brief Sets my presence information to Presence Server
+*
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] presence_req request information about presence
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_me_presence_with_push(service_adaptor_h handle,
+ service_adaptor_presence_req_s *presence_req,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Sets my presence ON/OFF information to Presence Server
+*
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] presence_req request information about presence
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_me_presence_on_off_with_push(service_adaptor_h handle,
+ service_adaptor_presence_req_s *presence_req,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Sets my profile type to Presence Server
+*
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] profile_type the profile types, this value is following a server spec
+* @param[out] profile_url the profile web url, this value is optional output value
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+* @remarks @a profile_url must be released using free()
+*/
+int service_adaptor_set_me_profile_type(service_adaptor_h handle,
+ int profile_type,
+ char **profile_url,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+typedef enum
+{
+ SERVICE_ADAPTOR_CONTACT_SET = 1,
+ SERVICE_ADAPTOR_CONTACT_DELETE = 2,
+} service_adaptor_contact_request_type_e;
+
+int service_adaptor_profile_image_create (service_adaptor_profile_image_h *image);
+
+int service_adaptor_profile_image_set_element (service_adaptor_profile_image_h image,
+ service_adaptor_contact_request_type_e req_type,
+ int index,
+ const char *path);
+
+int service_adaptor_profile_image_get_index (service_adaptor_profile_image_h image, int *index);
+
+int service_adaptor_profile_image_get_url (service_adaptor_profile_image_h image, char **url);
+
+int service_adaptor_profile_image_get_req_type (service_adaptor_profile_image_h image, int *req_type);
+
+void service_adaptor_profile_image_destroy (service_adaptor_profile_image_h image);
+
+
+
+#endif /* __SERVICE_ADAPTOR_CLIENT_CONTACT_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: service-adaptor-client-message.h
+ * Desc: Service Adaptor APIs
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ * @file service-adaptor-client-message.h
+ * @brief Defines interface of Service Adaptor's Messaging
+ * @version 0.1
+ */
+
+#ifndef __SERVICE_ADAPTOR_CLIENT_MESSAGE_H__
+#define __SERVICE_ADAPTOR_CLIENT_MESSAGE_H__
+
+#include <stdbool.h>
+#include "service-adaptor-client.h"
+#include "service_adaptor_client_type.h"
+
+typedef enum _service_adaptor_connection_policy_e
+{
+ SERVICE_ADAPTOR_CONNECTION_POLICY_AUTO = 0,
+ SERVICE_ADAPTOR_CONNECTION_POLICY_CONNECT = 1,
+ SERVICE_ADAPTOR_CONNECTION_POLICY_DISCONNECT = 2,
+} service_adaptor_connection_policy_e;
+/**
+* @brief Describes infromation about violation users of wrong receivers
+*/
+typedef struct _service_adaptor_did_violation_users_s
+{
+ long long int usera;
+ long long int userb;
+} service_adaptor_did_violation_users_s;
+
+/**
+* @brief Describes infromation about wrong receivers
+*/
+typedef struct _service_adaptor_wrong_receiver_s
+{
+ long long int *invalid_receivers; /**< specifies status as none*/
+ unsigned int invalid_receivers_len; /**< specifies status as none*/
+ long long int *interrupted_receivers; /**< specifies status as none*/
+ unsigned int interrupted_receivers_len; /**< specifies status as none*/
+ long long int *disabled_receivers; /**< specifies status as none*/
+ unsigned int disabled_receivers_len; /**< specifies status as none*/
+ long long int *existing_chatmembers; /**< specifies status as none*/
+ unsigned int existing_chatmembers_len; /**< specifies status as none*/
+ service_adaptor_did_violation_users_s **did_violation_users; /**< specifies status as none*/
+ unsigned int did_violation_users_len; /**< specifies status as none*/
+ long long int *invitation_denieds;
+ unsigned int invitation_denieds_len;
+
+} service_adaptor_wrong_receiver_s;
+
+/**
+* @brief Describes infromation about chat message
+*/
+typedef struct _service_adaptor_chat_msg_s
+{
+ long long int msg_id; /**< specifies status as none*/
+ int msg_type; /**< specifies status as none*/
+ char *chatmsg; /**< specifies status as none*/
+ int message_ttl; /**< specifies status as none*/
+} service_adaptor_chat_msg_s;
+
+/**
+* @brief Describes infromation about processed message
+*/
+typedef struct _service_adaptor_processed_msg_s
+{
+ long long int msg_id; /**< specifies status as none*/
+ long long int sent_time; /**< specifies status as none*/
+} service_adaptor_processed_msg_s;
+
+/**
+* @brief Describes infromation about delivery ack
+*/
+typedef struct _service_adaptor_delivery_ack_s
+{
+ long long int user_id;
+ long long int msg_id;
+ long long int timestamp;
+} service_adaptor_delivery_ack_s;
+
+/**
+* @brief Describes infromation about read_ack
+*/
+typedef struct _service_adaptor_read_ack_s
+{
+ long long int user_id; /**< specifies status as none*/
+ long long int msg_id; /**< specifies status as none*/
+ long long int timestamp; /**< specifies status as none*/
+} service_adaptor_read_ack_s;
+
+/**
+* @brief Describes infromation about ordered chat member
+*/
+typedef struct _service_adaptor_ordered_chat_member_s
+{
+ long long int user_id; /**< specifies status as none*/
+ bool available; /**< specifies status as none*/
+ char *name; /**< specifies status as none*/
+} service_adaptor_ordered_chat_member_s;
+
+/**
+* @brief Describes infromation about inbox message
+*/
+typedef struct _service_adaptor_inbox_message_s
+{
+ long long int msg_id; /**< specifies status as none*/
+ int msg_type; /**< specifies status as none*/
+ long long int sender; /**< specifies status as none*/
+ long long int receiver; /**< specifies status as none*/
+ long long int sent_time; /**< specifies status as none*/
+ char *chat_msg; /**< specifies status as none*/
+ long long int chatroom_id; /**< specifies status as none*/
+ int chat_type; /**< specifies status as none*/
+ int message_ttl; /**< specifies status as none*/
+} service_adaptor_inbox_message_s;
+
+/**
+* @brief Describes infromation about end chat
+*/
+typedef struct _service_adaptor_end_chat_s
+{
+ long long int chatroom_id; /**< specifies status as none*/
+ bool deny_invitation;
+} service_adaptor_end_chat_s;
+
+/**
+* @brief Describes infromation about phone number
+*/
+typedef struct _service_adaptor_phone_number_s
+{
+ char *phonenumber; /**< specifies status as none*/
+ char *ccc; /**< specifies status as none*/
+} service_adaptor_phone_number_s;
+
+/**
+* @brief Describes infromation about chat id
+*/
+typedef struct _service_adaptor_chat_id_s
+{
+ long long int chatid; /**< specifies status as none*/
+ char *msisdn; /**< specifies status as none*/
+} service_adaptor_chat_id_s;
+
+#ifdef NOT_IN_USE
+
+/**
+* @brief Callback for service_adaptor_request_channel_auth API
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] request_id specifies request id
+* @param[in] error_code specifies error code
+* @param[in] server_data specifies server_data passed in API
+* @return void
+* @pre service_adaptor_request_channel_auth will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_channel_auth_cb)(service_adaptor_h handle,
+ long long int request_id,
+ service_adaptor_error_s *error_code,
+ void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_client_echo API
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] request_id specifies request id
+* @param[in] error_code specifies error code
+* @param[in] server_data specifies server_data passed in API
+* @return void
+* @pre service_adaptor_request_client_echo will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_client_echo_cb)(service_adaptor_h handle,
+ long long int request_id,
+ service_adaptor_error_s *error_code,
+ void *server_data);
+
+#endif /* NOT_IN_USE */
+
+typedef void (*service_adaptor_reply_channel_disconnected_cb)(service_adaptor_h handle,
+ service_adaptor_error_s *error_code,
+ void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_create_chatroom API
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] request_id specifies request id
+* @param[in] chatroom_id specifies created chatroom Id
+* @param[in] wrong_receiver specifies invalid_receivers and disabled_receivers
+* @param[in] error_code specifies error code
+* @param[in] server_data specifies server_data passed in API
+* @return void
+* @pre service_adaptor_request_create_chatroom will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_create_chatroom_cb)(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ int default_message_ttl,
+ service_adaptor_wrong_receiver_s *wrong_receiver,
+ service_adaptor_error_s *error_code,
+ void *server_data);
+
+typedef void (*service_adaptor_reply_change_chatroom_meta_cb)(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ service_adaptor_error_s *error_code,
+ void *server_data);
+
+
+/**
+* @brief Callback for service_adaptor_request_chat API
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] request_id specifies request id
+* @param[in] chatroom_id specifies created chatroom Id
+* @param[in] processed_msgs specifies processed messages
+* @param[in] processed_msgs_len specifies length of processed_msgs
+* @param[in] error_code specifies error code
+* @param[in] server_data specifies server_data passed in API
+* @return void
+* @pre service_adaptor_request_chat will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_chat_cb)(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ service_adaptor_processed_msg_s **processed_msgs,
+ unsigned int processed_msgs_len,
+ service_adaptor_error_s *error_code,
+ void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_allow_chat API
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] request_id specifies request id
+* @param[in] chatroom_id specifies created chatroom Id
+* @param[in] read_acks specifies read_acks
+* @param[in] read_acks_len specifies length of read_acks
+* @param[in] ordered_chat_members specifies ordered chat members
+* @param[in] ordered_chat_members_len specifies length of ordered_chat_members
+* @param[in] error_code specifies error code
+* @param[in] server_data specifies server_data passed in API
+* @return void
+* @pre service_adaptor_request_allow_chat will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_allow_chat_cb)(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ service_adaptor_delivery_ack_s **delivery_acks,
+ unsigned int delivery_acks_len,
+ unsigned long long last_delivery_ack_timestamp,
+ service_adaptor_read_ack_s **read_acks,
+ unsigned int read_acks_len,
+ unsigned long long last_read_ack_timestamp,
+ service_adaptor_ordered_chat_member_s **ordered_chat_members,
+ unsigned int ordered_chat_members_len,
+ const char *chatroom_title,
+ int default_message_ttl,
+ service_adaptor_error_s *error_code,
+ void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_all_unread_message API
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] request_id specifies request id
+* @param[in] error_code specifies error code
+* @param[in] server_data specifies server_data passed in API
+* @return void
+* @pre service_adaptor_request_all_unread_message will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_all_unread_message_cb)(service_adaptor_h handle,
+ long long int request_id,
+ service_adaptor_error_s *error_code,
+ void *server_data);
+
+/**
+* @brief Callback for service_adaptor_register_forward_online_message_listener API
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] request_id specifies request id
+* @param[in] chatroom_id specifies created chatroom Id
+* @param[in] chat_type specifies type of chat
+* @param[in] inbox_msg specifies inbox message
+* @param[in] error_code specifies error code
+* @param[in] server_data specifies server_data passed in API
+* @return void
+* @pre service_adaptor_register_forward_online_message_listener will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_request_forward_online_message_cb)(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ int chat_type,
+ service_adaptor_inbox_message_s *inbox_msg,
+ bool skip_reply,
+ service_adaptor_error_s *error_code,
+ void *server_data);
+
+/**
+* @brief Callback for service_adaptor_register_forward_online_message_listener API
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] request_id specifies request id
+* @param[in] inbox_msgs specifies inbox message
+* @param[in] inbox_msgs_len specifies length of inbox message
+* @param[in] next_pagination_key specifies pagination function's next page value
+* @param[in] error_code specifies error code
+* @param[in] server_data specifies server_data passed in API
+* @return void
+* @pre service_adaptor_register_forward_online_message_listener will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_request_forward_unread_message_cb)(service_adaptor_h handle,
+ long long int request_id,
+ service_adaptor_inbox_message_s **inbox_msgs,
+ unsigned int inbox_msgs_len,
+ const char *next_pagination_key,
+ service_adaptor_error_s *error_code,
+ void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_read_message API
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] request_id specifies request id
+* @param[in] chatroom_id specifies created chatroom Id
+* @param[in] error_code specifies error code
+* @param[in] server_data specifies server_data passed in API
+* @return void
+* @pre service_adaptor_request_read_message will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_read_message_cb)(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ service_adaptor_error_s *error_code,
+ void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_invite_chat API
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] request_id specifies request id
+* @param[in] chatroom_id specifies created chatroom Id
+* @param[in] sent_time specifies "InviteRequest" time received from server
+* @param[in] wrong_receiver specifies invalid_receivers and disabled_receivers
+* @param[in] error_code specifies error code
+* @param[in] server_data specifies server_data passed in API
+* @return void
+* @pre service_adaptor_request_invite_chat will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_invite_chat_cb)(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ long long int sent_time,
+ service_adaptor_wrong_receiver_s *wrong_receiver,
+ service_adaptor_error_s *error_code,
+ void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_end_chat API
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] request_id specifies request id
+* @param[in] error_code specifies error code
+* @param[in] server_data specifies server_data passed in API
+* @return void
+* @pre service_adaptor_request_end_chat will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_end_chat_cb)(service_adaptor_h handle,
+ long long int request_id,
+ service_adaptor_error_s *error_code,
+ void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_unseal_message API
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] request_id specifies request id
+* @param[in] chatroom_id specifies chatroom id
+* @param[in] error_code specifies error code
+* @param[in] server_data specifies server_data passed in API
+* @return void
+* @pre service_adaptor_request_unseal_message will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_unseal_message_cb)(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ service_adaptor_error_s *error_code,
+ void *server_data);
+
+
+/**
+* @brief Callback for service_adaptor_request_save_call_log API
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] request_id specifies request id
+* @param[in] error_code specifies error code
+* @param[in] server_data specifies server_data passed in API
+* @return void
+* @pre service_adaptor_request_save_call_log will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_save_call_log_cb)(service_adaptor_h handle,
+ long long int request_id,
+ service_adaptor_error_s *error_code,
+ void *server_data);
+
+/**
+* @brief Callback for service_adaptor_request_current_time API
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] request_id specifies request id
+* @param[in] current_time_millis specifies current time (ms)
+* @param[in] error_code specifies error code
+* @param[in] server_data specifies server_data passed in API
+* @return void
+* @pre service_adaptor_request_current_time will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_reply_current_time_cb)(service_adaptor_h handle,
+ long long int request_id,
+ long long int current_time_millis,
+ service_adaptor_error_s *error_code,
+ void *server_data);
+
+/*==================================================================================================
+ FUNCTION PROTOTYPES
+==================================================================================================*/
+
+#ifdef NOT_IN_USE
+/**
+* @brief Requests Channel Auth
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] request_id specifies packet Id
+* @param[in] uid specifies DUID
+* @param[in] duid specifies DUID
+* @param[in] appid specifies appid
+* @param[in] access_token specifies access token
+* @param[in] callback the callback function to invoke
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_channel_auth(service_adaptor_h handle,
+ long long int request_id,
+ long long int uid,
+ long long int duid,
+ const char *appid,
+ const char *access_token,
+ service_adaptor_reply_channel_auth_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Requests Client Echo
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] request_id specifies packet Id
+* @param[in] callback the callback function to invoke
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_client_echo(service_adaptor_h handle,
+ long long int request_id,
+ service_adaptor_reply_client_echo_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+#endif /* NOT_IN_USE */
+
+/**
+* @brief Requests Creating Chatroom
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] request_id specifies packet Id
+* @param[in] chat_type specifies type of chat (Single: 0, Group: 1)
+* @param[in] receivers specifies receivers
+* @param[in] receivers_len specifies length of receivers
+* @param[in] callback the callback function to invoke
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_create_chatroom(service_adaptor_h handle,
+ long long int request_id,
+ int chat_type,
+ long long int *receivers,
+ unsigned int receivers_len,
+ const char *chatroom_title,
+ service_adaptor_reply_create_chatroom_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+int service_adaptor_request_change_chatroom_meta(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ const char *chatroom_title,
+ int default_message_ttl,
+ service_adaptor_reply_change_chatroom_meta_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Requests Chat
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] request_id specifies packet Id
+* @param[in] chatroom_id specifies created chatroom Id
+* @param[in] chat_msgs specifies information of chat message
+* @param[in] chat_msgs_len specifies length of chat_msgs
+* @param[in] callback the callback function to invoke
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_chat(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ service_adaptor_chat_msg_s **chat_msgs,
+ unsigned int chat_msgs_len,
+ service_adaptor_reply_chat_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Allows Chat
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] request_id specifies packet Id
+* @param[in] chatroom_id specifies created chatroom Id
+* @param[in] max_count specifies the number of message
+* @param[in] need_delivery_ack specifies requesting delivery ask's data
+* @param[in] last_delivery_ack_timestamp specifies last delivery ask's timestamp
+* @param[in] need_read_ack specifies requesting read_ack's data
+* @param[in] last_read_ack_timestamp specifies last read_ack's timestamp
+* @param[in] need_ordered_chat_member_list specifies requesting ordered member list
+* @param[in] callback the callback function to invoke
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_allow_chat(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ bool is_auto_allow,
+ int max_count,
+ bool need_delivery_ack,
+ unsigned long long last_delivery_ack_timestamp,
+ bool need_read_ack,
+ unsigned long long last_read_ack_timestamp,
+ bool need_ordered_chat_member_list,
+ service_adaptor_reply_allow_chat_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Requests All Unread Message
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] request_id specifies packet Id
+* @param[in] max_count specifies the number of message
+* @param[in] callback the callback function to invoke
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_all_unread_message(service_adaptor_h handle,
+ long long int request_id,
+ int max_count,
+ service_adaptor_reply_all_unread_message_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+
+int service_adaptor_register_channel_disconnected_listener(service_adaptor_h handle,
+ service_adaptor_reply_channel_disconnected_cb callback,
+ void *user_data);
+
+int service_adaptor_unregister_channel_disconnected_listener(service_adaptor_h handle,
+ void *user_data);
+
+
+/**
+* @brief Registers Forward Online Message Listener
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] callback the callback function to invoke
+* @param[in] user_data specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_register_forward_online_message_listener(service_adaptor_h handle,
+ service_adaptor_request_forward_online_message_cb callback,
+ void *user_data);
+
+/**
+* @brief Unregisters Forward Online Message Listener
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] user_data specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_unregister_forward_online_message_listener(service_adaptor_h handle,
+ void *user_data);
+
+/**
+* @brief Requests Forward Online Message
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] request_id specifies packet Id
+* @param[in] chatroom_id specifies created chatroom Id
+* @param[in] mark_as_read specifies mark as read
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_reply_forward_online_message(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ bool mark_as_read,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Registers Forward Unread Message Listener
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] callback the callback function to invoke
+* @param[in] user_data specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_register_forward_unread_message_listener(service_adaptor_h handle,
+ service_adaptor_request_forward_unread_message_cb callback,
+ void *user_data);
+
+/**
+* @brief Unregisters Forward Unread Message Listener
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] user_data specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_unregister_forward_unread_message_listener(service_adaptor_h handle,
+ void *user_data);
+
+/**
+* @brief Requests Forward Unread Message
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] request_id specifies packet Id
+* @param[in] next_pagination_key specifies pagination function's next page value
+* @param[in] max_count specifies the number of message
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_reply_forward_unread_message(service_adaptor_h handle,
+ long long int request_id,
+ const char *next_pagination_key,
+ int max_count,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Requests Read Message
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] request_id specifies packet Id
+* @param[in] chatroom_id specifies created chatroom Id
+* @param[in] inbox_msg specifies inbox message
+* @param[in] callback the callback function to invoke
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_read_message(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ service_adaptor_inbox_message_s *inbox_msg,
+ service_adaptor_reply_read_message_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Requests Invite Chat
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] request_id specifies packet Id
+* @param[in] chatroom_id specifies created chatroom Id
+* @param[in] inviting_members specifies invited user id
+* @param[in] inviting_members_len specifies length of invited user id
+* @param[in] callback the callback function to invoke
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_invite_chat(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ long long int *inviting_members,
+ unsigned int inviting_members_len,
+ service_adaptor_reply_invite_chat_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Requests End Chat
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] request_id specifies packet Id
+* @param[in] end_chats specifies list of created chatroom id
+* @param[in] end_chats_len specifies length of end_chats
+* @param[in] callback the callback function to invoke
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_end_chat(service_adaptor_h handle,
+ long long int request_id,
+ service_adaptor_end_chat_s **end_chats,
+ unsigned int end_chats_len,
+ service_adaptor_reply_end_chat_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Requests Unseal Message
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] request_id specifies packet Id
+* @param[in] chatroom_id specifies chatroom Id
+* @param[in] sender_id specifies message sender Id for 'Unseal Message'
+* @param[in] message_id specifies message Id for 'Unseal Message'
+* @param[in] callback the callback function to invoke
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_unseal_message(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ long long int sender_id,
+ long long int message_id,
+ const char *message_detail,
+ service_adaptor_reply_unseal_message_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Requests Save Call Log
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] request_id specifies packet Id
+* @param[in] chatroom_id specifies chatroom Id
+* @param[in] call_id specifies unique call Id
+* @param[in] call_log_type specifies call log type string
+* @param[in] call_sender_id specifies caller's unique Id
+* @param[in] call_receiver_id specifies callee's unique Id
+* @param[in] conversaction_second specifies calling time
+* @param[in] callback the callback function to invoke
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_save_call_log(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ const char *call_id,
+ const char *call_log_type,
+ long long int call_sender_id,
+ long long int call_receiver_id,
+ int conversaction_second,
+ service_adaptor_reply_save_call_log_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Requests Current Time
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] request_id specifies packet Id
+* @param[in] callback the callback function to invoke
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_request_current_time(service_adaptor_h handle,
+ long long int request_id,
+ service_adaptor_reply_current_time_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+
+int service_adaptor_request_get_connection_policy(service_adaptor_h handle,
+ service_adaptor_connection_policy_e *policy,
+ service_adaptor_error_s **error_code);
+
+int service_adaptor_request_set_connection_policy(service_adaptor_h handle,
+ service_adaptor_connection_policy_e *policy,
+ service_adaptor_error_s **error_code);
+/**
+* @brief Requests chat id based on phone number
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] phone_numbers list of phone number
+* @param[in] phone_numbers_len length of phone_numbers
+* @param[in] user_data specifies user_data (json) passed in API
+* @param[out] chat_ids list of chat id
+* @param[out] chat_ids_len length of chat_ids
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_chat_id_list(service_adaptor_h handle,
+ service_adaptor_phone_number_s **phone_numbers,
+ unsigned int phone_numbers_len,
+ void *user_data,
+ service_adaptor_chat_id_s ***chat_ids,
+ unsigned int *chat_ids_len,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+
+/**
+* @brief Requests MSISDN based on User ID
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] chat_ids list of chat id
+* @param[in] chat_ids_len length of chat_ids
+* @param[in] user_data specifies user_data (json) passed in API
+* @param[out] msisdns list of msisdn
+* @param[out] msisdns_len length of msisdns
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_msisdn_list(service_adaptor_h handle,
+ long long int *chat_ids,
+ unsigned int chat_ids_len,
+ void *user_data,
+ service_adaptor_chat_id_s ***msisdns,
+ unsigned int *msisdns_len,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+
+#endif /* __SERVICE_ADAPTOR_CLIENT_MESSAGE_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: service-adaptor-client-push.h
+ * Desc: Service Adaptor APIs
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ * @file service-adaptor-client-push.h
+ * @brief Defines interface of Service Adaptor's Push
+ * @version 0.1
+ */
+
+#ifndef __SERVICE_ADAPTOR_CLIENT_PUSH_H__
+#define __SERVICE_ADAPTOR_CLIENT_PUSH_H__
+
+#include "service-adaptor-client.h"
+#include "service_adaptor_client_type.h"
+
+/**
+* @brief Describes push information
+*/
+typedef struct _service_adaptor_push_notification_s
+{
+ char *data; /**< specifies status as none*/
+ char *message; /**< specifies status as none*/
+ long long int time; /**< specifies status as none*/
+} service_adaptor_push_notification_s;
+
+/**
+* @brief Callback for service_adaptor_connect_push_service API
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] noti_info specifies push_notification information
+* @param[in] error_code specifies error code
+* @param[in] user_data specifies user_data passed in service_adaptor_connect_push_service API
+* @return void
+* @pre service_adaptor_connect_push_service will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_push_notification_cb)(service_adaptor_h handle,
+ service_adaptor_push_notification_s *noti_info,
+ service_adaptor_error_s *error_code,
+ void *user_data);
+
+/*==================================================================================================
+ FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+* @brief Registers a callback function to receive push notification from push service
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] callback the callback function to invoke
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_connect_push_service(service_adaptor_h handle,
+ service_adaptor_push_notification_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Deregisters the callback function that had been registered to push service
+*
+* @param[in] handle specifies Service Adaptor handle
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_disconnect_push_service(service_adaptor_h handle);
+
+
+int service_adaptor_register_push_service(service_adaptor_h handle,
+ const char *service_file_name);
+
+int service_adaptor_deregister_push_service(service_adaptor_h handle,
+ const char *service_file_name);
+
+#endif /* __SERVICE_ADAPTOR_CLIENT_PUSH_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: service-adaptor-client-shop.h
+ * Desc: Service Adaptor APIs
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ * @file service-adaptor-client-shop.h
+ * @brief Defines interface of Service Adaptor's Shop
+ * @version 0.1
+ */
+
+#ifndef __SERVICE_ADAPTOR_CLIENT_SHOP_H__
+#define __SERVICE_ADAPTOR_CLIENT_SHOP_H__
+
+#include "service-adaptor-client.h"
+#include "service_adaptor_client_type.h"
+
+/**
+* @brief Describes infromation about shop
+*/
+typedef struct _service_adaptor_shop_info_s
+{
+ int category_id; /**< specifies category id of item*/
+ long item_id; /**< specifies item id*/
+ long sticker_id; /**< specifies sticker id*/
+ char *lang_cd; /**< specifies display language type*/
+ char *cntry_cd; /**< specifies country code*/
+ int rwidth; /**< specifies device resolution width*/
+ int rheight; /**< specifies device resolution height*/
+ int start_idx; /**< default value : 0*/
+ int count; /**< default value : 5*/
+} service_adaptor_shop_info_s;
+
+/**
+* @brief Describes infromation about item
+*/
+typedef struct _service_adaptor_shop_item_s
+{
+ long item_id; /**< specifies category id of item*/
+ int category_id; /**< specifies category id of item*/
+ long *sticker_ids; /**< specifies category id of item*/
+ unsigned int sticker_ids_len; /**< specifies category id of item*/
+ char *title; /**< specifies category id of item*/
+ char *character; /**< specifies category id of item*/
+ int version; /**< specifies category id of item*/
+ char *download_url; /**< specifies category id of item*/
+ char *panel_url; /**< specifies category id of item*/
+ char *sticker_url; /**< specifies category id of item*/
+ long file_size; /**< specifies category id of item*/
+ int count; /**< specifies category id of item*/
+ char *character_code; /**< specifies category id of item*/
+ long long int startdate; /**< specifies category id of item*/
+ long long int enddate; /**< specifies category id of item*/
+ long long int expired_date; /**< specifies category id of item*/
+ long long int valid_period; /**< specifies category id of item*/
+} service_adaptor_shop_item_s;
+
+/*==================================================================================================
+ FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+* @brief Requests List of Item
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] info specifies shop information
+* @param[in] user_data specifies user_data (json) passed in API
+* @param[in] items specifies list of items
+* @param[in] items_len specifies length of items
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_item_list(service_adaptor_h handle,
+ service_adaptor_shop_info_s *info,
+ void *user_data,
+ service_adaptor_shop_item_s ***items,
+ unsigned int *items_len,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+
+/**
+* @brief Requests Item Information for Download
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] info specifies shop information
+* @param[in] user_data specifies user_data (json) passed in API
+* @param[in] item specifies item
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_download_item_package(service_adaptor_h handle,
+ service_adaptor_shop_info_s *info,
+ void *user_data,
+ service_adaptor_shop_item_s **item,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+
+/**
+* @brief Requests Download of Item
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] info specifies shop information
+* @param[in] user_data specifies user_data (json) passed in API
+* @param[in] item specifies item
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_download_sticker(service_adaptor_h handle,
+ service_adaptor_shop_info_s *info,
+ void *user_data,
+ service_adaptor_shop_item_s **item,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+
+/**
+* @brief Requests Item Panel URL
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] info specifies shop information
+* @param[in] user_data specifies user_data (json) passed in API
+* @param[in] item specifies item
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_get_panel_url(service_adaptor_h handle,
+ service_adaptor_shop_info_s *info,
+ void *user_data,
+ service_adaptor_shop_item_s **item,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+
+#endif /* __SERVICE_ADAPTOR_CLIENT_SHOP_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: service-adaptor-client-storage.h
+ * Desc: Service Adaptor APIs
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ * @file service-adaptor-client-storage.h
+ * @brief Defines interface of Service Adaptor's Storage
+ * @version 0.1
+ */
+
+#ifndef __PRIVATE_SERVICE_ADAPTOR_CLIENT_STORAGE_H__
+#define __PRIVATE_SERVICE_ADAPTOR_CLIENT_STORAGE_H__
+
+#include "service-adaptor-client.h"
+
+typedef enum _service_adaptor_file_status_code_e
+{
+ SERVICE_ADAPTOR_TRANSFER_STATUS_PROGRESS = 1,
+ SERVICE_ADAPTOR_TRANSFER_STATUS_RESUME = 1,
+ SERVICE_ADAPTOR_TRANSFER_STATUS_PAUSE = 2,
+ SERVICE_ADAPTOR_TRANSFER_STATUS_CANCEL = 3, // canceled by request
+ SERVICE_ADAPTOR_TRANSFER_STATUS_STOPPED = 4, // canceled by system
+ SERVICE_ADAPTOR_TRANSFER_STATUS_FINISHED = 5
+} service_adaptor_file_status_code_e;
+
+typedef enum _service_adaptor_thumbnail_size_e
+{
+ SERVICE_ADAPTOR_THUMBNAIL_XSMALL = 96,
+ SERVICE_ADAPTOR_THUMBNAIL_SMALL = 200,
+ SERVICE_ADAPTOR_THUMBNAIL_MEDIUM = 500,
+ SERVICE_ADAPTOR_THUMBNAIL_LARGE = 760
+} service_adaptor_thumbnail_size_e;
+
+/**
+* @brief Describes file description about download and upload
+*/
+typedef struct _service_adaptor_file_s
+{
+ int file_description; /**< specifies status as none*/
+} service_adaptor_file_s;
+
+/**
+* @brief Describes file infromation about download and upload
+*/
+typedef struct _service_adaptor_file_path_s
+{
+ char **file_paths; /**< specifies status as none*/
+ unsigned int file_paths_len; /**< specifies status as none*/
+} service_adaptor_file_path_s;
+
+/**
+* @brief Describes file status about transfer
+*/
+typedef struct _service_adaptor_file_status_s
+{
+ long long int total_size; /**< specifies status as none*/
+ long long int transferred_size; /**< specifies status as none*/
+ service_adaptor_file_status_code_e status; /**< specifies status as none*/
+} service_adaptor_file_status_s;
+
+/**
+* @brief The handle for File Description
+*/
+typedef service_adaptor_file_s *service_adaptor_file_h;
+
+/**
+* @brief Callback for file upload and download API
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] file_handle specifies file description
+* @param[in] transferred_size specifies transferred size
+* @param[in] total_size specifies total size
+* @param[in] error_code specifies error code
+* @param[in] user_data specifies user_data passed in API
+* @return void
+* @pre service_adaptor_request_channel_auth will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_file_progress_cb)(service_adaptor_h handle,
+ service_adaptor_file_h file_handle,
+ unsigned long long transferred_size,
+ unsigned long long total_size,
+ service_adaptor_error_s *error_code,
+ void *user_data);
+
+/**
+* @brief Callback for file transfer completion
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] file_handle specifies file description
+* @param[in] publish_url specifies publish url for another user
+* @param[in] error_code specifies error code
+* @param[in] user_data specifies user_data passed in API
+* @return void
+* @pre service_adaptor_request_channel_auth will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_file_transfer_completion_cb)(service_adaptor_h handle,
+ service_adaptor_file_h file_handle,
+ char *publish_url,
+ service_adaptor_error_s *error_code,
+ void *user_data);
+
+/*==================================================================================================
+ FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+* @brief Registers File Progress Listener
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] callback the callback function to invoke
+* @param[in] user_data specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_register_file_progress_listener(service_adaptor_h handle,
+ service_adaptor_file_progress_cb callback,
+ void *user_data);
+
+/**
+* @brief Unregisters File Progress Listener
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] user_data specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_unregister_file_progress_listener(service_adaptor_h handle,
+ void *user_data);
+
+/**
+* @brief Registers File Transfer Completion Listener
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] callback the callback function to invoke
+* @param[in] user_data specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_register_file_transfer_completion_listener(service_adaptor_h handle,
+ service_adaptor_file_transfer_completion_cb callback,
+ void *user_data);
+
+/**
+* @brief Unregisters File Transfer Completion Listener
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] user_data specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_unregister_file_transfer_completion_listener(service_adaptor_h handle,
+ void *user_data);
+
+/**
+* @brief Downloads a server file and writes it to local file
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] server_path specifies server url of file to download
+* @param[in] download_path specifies local path where we expect downloaded file to be written
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_download_file(service_adaptor_h handle,
+ const char *server_path,
+ const char *download_path,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Downloads a server file and writes it to local file (Async)
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] server_path specifies server url of file to download
+* @param[in] download_path specifies local path where we expect downloaded file to be written
+* @param[out] file_handle specifies file description
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_download_file_async(service_adaptor_h handle,
+ const char *server_path,
+ const char *download_path,
+ service_adaptor_file_h *file_handle,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Uploads a local file to server path
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] upload_path specifies local path for upload
+* @param[in] server_path specifies server url of file to download
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_upload_file(service_adaptor_h handle,
+ const char *upload_path,
+ const char *server_path,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Uploads a local file to server path (Async)
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] upload_path specifies local path for upload
+* @param[in] server_path specifies server url of file to download
+* @param[out] file_handle specifies file description
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_upload_file_async(service_adaptor_h handle,
+ const char *upload_path,
+ const char *server_path,
+ service_adaptor_file_h *file_handle,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Downloads a server file and writes it to local file
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] publish_url specifies publish url of file to download
+* @param[in] download_path specifies local path where we expect downloaded file to be written
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_download_file_publish(service_adaptor_h handle,
+ const char *publish_url,
+ const char *download_path,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Downloads a server file and writes it to local file (Async)
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] publish_url specifies publish url of file to download
+* @param[in] download_path specifies local path where we expect downloaded file to be written
+* @param[out] file_handle specifies file description
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_download_file_publish_async(service_adaptor_h handle,
+ const char *publish_url,
+ const char *download_path,
+ service_adaptor_file_h *file_handle,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Uploads a local file to server path
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] upload_path specifies local path for upload
+* @param[in] server_path specifies server url of file to download
+* @param[out] publish_url specifies publish url
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_upload_file_publish(service_adaptor_h handle,
+ const char *upload_path,
+ const char *server_path,
+ char **publish_url,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Uploads a local file to server path (Async)
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] upload_path specifies local path for upload
+* @param[in] server_path specifies server url of file to download
+* @param[out] file_handle specifies file description
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_upload_file_publish_async(service_adaptor_h handle,
+ const char *upload_path,
+ const char *server_path,
+ service_adaptor_file_h *file_handle,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Downloads a thumbnail file and writes it to local file
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] publish_url specifies publish url of file to download
+* @param[in] download_path specifies local path where we expect downloaded file to be written
+* @param[in] size specifies size of thumbnail
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_download_thumbnail_publish(service_adaptor_h handle,
+ const char *publish_url,
+ const char *download_path,
+ service_adaptor_thumbnail_size_e size,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+
+/**
+* @brief Requests File Status
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] file_handle specifies file description
+* @param[out] status specifies status of file transfer
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) received from Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_get_file_status(service_adaptor_h handle,
+ service_adaptor_file_h file_handle,
+ service_adaptor_file_status_s **status,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+
+/**
+* @brief Cancels File Transfer
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] file_handle specifies file description
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) received from Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_cancel_file_transfer(service_adaptor_h handle,
+ service_adaptor_file_h file_handle,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+
+/**
+* @brief Pause File Transfer
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] file_handle specifies file description
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) received from Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_pause_file_transfer(service_adaptor_h handle,
+ service_adaptor_file_h file_handle,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+
+/**
+* @brief Resume File Transfer
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] file_handle specifies file description
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) received from Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in service_adaptor_result_e - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+service_adaptor_result_e service_adaptor_resume_file_transfer(service_adaptor_h handle,
+ service_adaptor_file_h file_handle,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+
+#endif /* __PRIVATE_SERVICE_ADAPTOR_CLIENT_STORAGE_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: service-adaptor-client.h
+ * Desc: Service Adaptor APIs
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ * @file service-adaptor-client.h
+ * @brief Defines interface of Service Adaptor
+ * @version 0.1
+ */
+
+#ifndef __PRIVATE_SERVICE_ADAPTOR_CLIENT_H__
+#define __PRIVATE_SERVICE_ADAPTOR_CLIENT_H__
+
+#include <stdbool.h>
+#include <service_adaptor_client.h>
+#include "service_adaptor_client_type.h"
+
+/**
+ * @brief Enumerations of result code for Service Adaptor
+ */
+typedef enum _service_adaptor_result_e
+{
+ SERVICE_ADAPTOR_RESULT_SUCCEEDED = SERVICE_ADAPTOR_ERROR_NONE, /**< specifies status as none*/
+ SERVICE_ADAPTOR_RESULT_FAILED = -1, /**< specifies status as none*/
+ SERVICE_ADAPTOR_RESULT_CANCELED = -2 /**< specifies status as none*/
+} __service_adaptor_result_e; /*TODO deplicate*/
+
+typedef int service_adaptor_result_e; /* For version compatibility */
+
+/**
+ * @brief Enumerations of error code for Service Adaptor
+ */
+typedef enum _private_service_adaptor_error_e
+{
+ SERVICE_ADAPTOR_ERROR_LAUNCH = 1, /**< 1 ~ 99: internal error*/
+ SERVICE_ADAPTOR_ERROR_INIT = 2,
+ SERVICE_ADAPTOR_ERROR_DEINIT = 3,
+ SERVICE_ADAPTOR_ERROR_CREATE = 4,
+ SERVICE_ADAPTOR_ERROR_DESTROY = 5,
+ SERVICE_ADAPTOR_ERROR_START = 6,
+ SERVICE_ADAPTOR_ERROR_STOP = 7,
+ SERVICE_ADAPTOR_ERROR_CONNECT = 8,
+ SERVICE_ADAPTOR_ERROR_DISCONNECT = 9,
+ SERVICE_ADAPTOR_ERROR_NOT_FOUND = 10,
+ SERVICE_ADAPTOR_ERROR_CORRUPTED = 11,
+ SERVICE_ADAPTOR_ERROR_UNSUPPORTED = 12,
+ SERVICE_ADAPTOR_ERROR_INVALID_HANDLE = 13,
+ SERVICE_ADAPTOR_ERROR_INVALID_ARGUMENT = 14,
+ SERVICE_ADAPTOR_ERROR_INVALID_ARGUMENT_TYPE = 15,
+ SERVICE_ADAPTOR_ERROR_ADAPTOR_INTERNAL = 17,
+ SERVICE_ADAPTOR_ERROR_PLUGIN_INTERNAL = 18,
+ SERVICE_ADAPTOR_ERROR_SERVER_INTERNAL = 19,
+ SERVICE_ADAPTOR_ERROR_DBUS = 20,
+ SERVICE_ADAPTOR_ERROR_CALLBACK_TIME_OUT = 21,
+ SERVICE_ADAPTOR_ERROR_INTERNAL_MAX = 99,
+
+ SERVICE_ADAPTOR_ERROR_NETWORK = TIZEN_ERROR_SERVICE_ADAPTOR | 0xf1,
+} private_service_adaptor_error_e;
+
+/**
+ * @brief Type of service in plugin (ext internal)
+ */
+typedef enum
+{
+ SERVICE_PLUGIN_SERVICE_CONTACT = (0x01 << 2), /**< Contact service type flag */
+ SERVICE_PLUGIN_SERVICE_MESSAGE = (0x01 << 3), /**< Message service type flag */
+ SERVICE_PLUGIN_SERVICE_SHOP = (0x01 << 4), /**< Shop service type flag */
+ SERVICE_PLUGIN_SERVICE_PUSH = (0x01 << 5), /**< Push service type flag */
+} internal_service_plugin_service_type_e;
+
+/**
+* @brief Describes infromation about plugin
+*/
+typedef struct _service_adaptor_plugin_s
+{
+ char *name; /**< specifies status as none*/
+ bool login; /**< specifies status as none*/
+} service_adaptor_plugin_s;
+
+/**
+* @brief The handle for Service Adaptor error
+*/
+typedef service_adaptor_plugin_s *service_adaptor_plugin_h;
+
+/**
+* @brief Callback for service_adaptor_connect API
+*
+* @param[in] signal specifies signal code
+* @param[in] msg specifies signal message
+* @return void.
+* @pre service_adaptor_connect() will invoke this callback.
+* @see
+*/
+typedef void(* service_adaptor_signal_cb)(service_adaptor_h handle,
+ service_adaptor_signal_code_e signal,
+ char *msg);
+
+/**
+* @brief Callback for getting async external operation result
+*
+* @param[in] result Result code for async operation (see #service_adaptor_error_e)
+* @param[in] out_params Created bundle, if the special API returns optional values, get result from this bundle (reference to plugin's SPEC)
+* @param[in] user_data Passed data from request function
+* @remarks You can get the error detail from #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() API. Error codes and messages are described in Service Plugin.
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_NO_DATA There is no data
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see #service_adaptor_error_e
+* @see service_adaptor_external_request_async()
+* @see service_adaptor_get_last_result()
+* @see service_adaptor_get_last_error_message()
+* @return void
+* @pre #service_adaptor_external_request_async() will invoke this callback.
+*/
+typedef void (*service_adaptor_external_response_cb)(int result,
+ bundle *out_params,
+ void *user_data);
+
+/*==================================================================================================
+ FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+* @brief Connects Service Adaptor
+*
+* @param[out] handle specifies Service Adaptor handle
+* @param[in] callback the callback function to invoke
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_connect(service_adaptor_h *handle,
+ service_adaptor_signal_cb callback);
+
+/**
+* @brief Disconnects Service Adaptor
+*
+* @param[in] handle the handle which is returned in service_adaptor_connect
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_disconnect(service_adaptor_h handle);
+
+/**
+* @brief Sets IMSI
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] imsi specifies Mobile station identification number
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_set_imsi(service_adaptor_h handle,
+ const char *imsi);
+
+int service_adaptor_set_plugin(service_adaptor_h handle,
+ const char *plugin_uri);
+
+/**
+* @brief Free the list of auth plugin
+*
+* @param[in] plugins specifies the list of auth plugin
+* @param[in] plugins_len specifies length of auth plugins
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_RESULT_SUCCEEDED if Successful
+*/
+int service_adaptor_free_plugins(service_adaptor_plugin_h *plugins,
+ unsigned int plugins_len);
+
+/**
+* @brief Requests external API to plugin directly (Sync)
+* @since_tizen 2.4
+* @param[in] handle The handle of service-adaptor
+* @param[in] service_flag The special API direction to specific plugin (refer to #service_plugin_service_type_e)
+* @param[in] api_uri The special API signature that is described plugin's SPEC
+* @param[in] in_params Created bundle, if the special API needs optional parameter, insert to bundle (refer to plugin's SPEC)
+* @param[in] out_params Created bundle, if the special API returns optional values, get result from this bundle (refer to plugin's SPEC)
+* @remarks @a in_params must be created using bundle_create()
+* @remarks @a out_params must be released memory using bundle_free()
+* @remarks You can get the error detail from #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() API. Error codes and messages are described in Service Plugin.
+* @see service_adaptor_get_last_result()
+* @see service_adaptor_get_last_error_message() (refer to #service_plugin_service_type_e)
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_adaptor_external_request(service_adaptor_h handle,
+ int service_flag,
+ const char *api_uri,
+ bundle *in_params,
+ bundle **out_params);
+
+/**
+* @brief Requests external API to plugin directly (Async)
+* @since_tizen 2.4
+* @param[in] handle The handle of service-adaptor
+* @param[in] service_flag The special API direction to specific plugin
+* @param[in] api_uri The special API signature that is descrypted plugin's SPEC
+* @param[in] in_params Created bundle, if the special API needs optional parameter, insert to bundle (reference to plugin's SPEC)
+* @param[in] callback The callback for getting result this operation
+* @param[in] user_data The user data to be passed to the callback function
+* @remarks You can get the error detail from #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() API. Error codes and messages are described in Service Plugin.
+* @see service_adaptor_get_last_result()
+* @see service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @post #service_adaptor_external_response_cb() will be invoked
+*/
+int service_adaptor_external_request_async(service_adaptor_h handle,
+ int service_flag,
+ const char *api_uri,
+ bundle *in_params,
+ service_adaptor_external_response_cb callback,
+ void *user_data);
+
+#endif /* __PRIVATE_SERVICE_ADAPTOR_CLIENT_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_LOG_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_LOG_H__
+
+/**
+ * HOW TO USE IT:
+ * First you need to set platform logging on the device:
+ *
+ * # dlogctrl set platformlog 1
+ *
+ * After reboot you are able to see logs from this application, when you launch dlogutil with a proper filter e.g.:
+ *
+ * # dlogutil SERVICE_ADAPTOR:D
+ *
+ * You may use different logging levels as: D (debug), I (info), W (warning), E (error) or F (fatal).
+ * Higher level messages are included by default e.g. dlogutil CLOUDBOX:W prints warnings but also errors and fatal messages.
+ */
+
+#include <unistd.h>
+#include <linux/unistd.h>
+
+/* These defines must be located before #include <dlog.h> */
+#define TIZEN_ENGINEER_MODE
+// TODO: Investigate why this macro is defined somewhere else
+#ifndef TIZEN_DEBUG_ENABLE
+#define TIZEN_DEBUG_ENABLE
+#endif
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+/* Literal to filter logs from dlogutil */
+#define LOG_TAG "SERVICE_ADAPTOR_CLIENT"
+
+#include <dlog.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+ /**
+ * Colors of font
+ */
+#define FONT_COLOR_RESET "\033[0m"
+#define FONT_COLOR_BLACK "\033[30m" /* Black */
+#define FONT_COLOR_RED "\033[31m" /* Red */
+#define FONT_COLOR_GREEN "\033[32m" /* Green */
+#define FONT_COLOR_YELLOW "\033[33m" /* Yellow */
+#define FONT_COLOR_BLUE "\033[34m" /* Blue */
+#define FONT_COLOR_PURPLE "\033[35m" /* Purple */
+#define FONT_COLOR_CYAN "\033[36m" /* Cyan */
+#define FONT_COLOR_WHITE "\033[37m" /* White */
+#define FONT_COLOR_BOLDBLACK "\033[1m\033[30m" /* Bold Black */
+#define FONT_COLOR_BOLDRED "\033[1m\033[31m" /* Bold Red */
+#define FONT_COLOR_BOLDGREEN "\033[1m\033[32m" /* Bold Green */
+#define FONT_COLOR_BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */
+#define FONT_COLOR_BOLDBLUE "\033[1m\033[34m" /* Bold Blue */
+#define FONT_COLOR_BOLDPURPLE "\033[1m\033[35m" /* Bold Purple */
+#define FONT_COLOR_BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */
+#define FONT_COLOR_BOLDWHITE "\033[1m\033[37m" /* Bold White */
+
+/**
+ * Gets thread ID
+ */
+#define sac_gettid() ((int)syscall(__NR_gettid))
+
+/**
+ * @brief Macro for returning value if expression is satisfied
+ * @param[in] expr Expression to be checked
+ * @param[out] val Value to be returned when expression is true
+ */
+#define sac_retv_if(expr, val) do { \
+ if(expr) { \
+ LOGE(FONT_COLOR_PURPLE"[%d]"FONT_COLOR_RESET, sac_gettid()); \
+ return (val); \
+ } \
+ } while (0)
+
+/**
+ * @brief Prints debug messages
+ * @param[in] fmt Format of data to be displayed
+ * @param[in] args Arguments to be displayed
+ */
+#define sac_debug(fmt, arg...) do { \
+ LOGD(FONT_COLOR_GREEN"[%d]"fmt""FONT_COLOR_RESET, sac_gettid(), ##arg); \
+ } while (0)
+
+/**
+ * @brief Prints info messages
+ * @param[in] fmt Format of data to be displayed
+ * @param[in] args Arguments to be displayed
+ */
+#define sac_info(fmt, arg...) do { \
+ LOGI(FONT_COLOR_BLUE"[%d]"fmt""FONT_COLOR_RESET, sac_gettid() ,##arg); \
+ } while (0)
+
+/**
+ * @brief Prints warning messages
+ * @param[in] fmt Format of data to be displayed
+ * @param[in] args Arguments to be displayed
+ */
+#define sac_warning(fmt, arg...) do { \
+ LOGW(FONT_COLOR_YELLOW"[%d]"fmt""FONT_COLOR_RESET,sac_gettid(), ##arg); \
+ } while (0)
+
+/**
+ * @brief Prints error messages
+ * @param[in] fmt Format of data to be displayed
+ * @param[in] args Arguments to be displayed
+ */
+#define sac_error(fmt, arg...) do { \
+ LOGE(FONT_COLOR_RED"[%d]"fmt""FONT_COLOR_RESET,sac_gettid(), ##arg); \
+ } while (0)
+
+/**
+ * @brief Prints fatal messages
+ * @param[in] fmt Format of data to be displayed
+ * @param[in] args Arguments to be displayed
+ */
+#define sac_fatal(fmt, arg...) do { \
+ LOGF(FONT_COLOR_BOLDRED"[%d]"fmt""FONT_COLOR_RESET,sac_gettid(), ##arg); \
+ } while (0)
+
+/**
+ * @brief Prints debug message on entry to particular function
+ * @param[in] fmt Format of data to be displayed
+ * @param[in] args Arguments to be displayed
+ */
+#define sac_debug_func(fmt, arg...) do { \
+ LOGD(FONT_COLOR_CYAN"[%d]"fmt""FONT_COLOR_RESET, sac_gettid(), ##arg); \
+ } while (0)
+
+#define sac_api_start() do { \
+ sac_info("API start <%s>", __FUNCTION__); \
+ } while (0)
+
+#define sac_api_start_msg(req_id) do { \
+ sac_info("API start <%s> : req_is(%lld)", __FUNCTION__, (long long int)req_id); \
+ } while (0)
+
+#define sac_api_end(ret) do { \
+ sac_info("API end <%s> : %d", __FUNCTION__, (int)ret); \
+ } while (0)
+
+#define FUNC_START() do{sac_debug_func(FONT_COLOR_BOLDBLACK">>>>>>>> Start\n%s"FONT_COLOR_RESET, __FUNCTION__);}while(0)
+#define FUNC_STEP() do{sac_debug_func(FONT_COLOR_BOLDBLACK"====== Step\n%s"FONT_COLOR_RESET, __FUNCTION__);}while(0)
+#define FUNC_STOP() do{sac_debug_func(FONT_COLOR_BOLDBLACK"<<==<<== Stop\n%s"FONT_COLOR_RESET, __FUNCTION__);}while(0)
+#define FUNC_END() do{sac_debug_func(FONT_COLOR_BOLDBLACK"<<<<<<<< End\n%s"FONT_COLOR_RESET, __FUNCTION__);}while(0)
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_LOG_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: service_adaptor_client_storage_private.h
+ * Desc: Service Adaptor APIs
+ * Created on: Feb, 2015
+ * Auth: Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_PRIVATE_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_PRIVATE_H__
+
+#if defined _WIN32 || defined __CYGWIN__
+ #define DLL_IMPORT __declspec(dllimport)
+ #define DLL_EXPORT __declspec(dllexport)
+ #define DLL_LOCAL
+#else
+ #if __GNUC__ >= 4
+ #define DLL_IMPORT __attribute__ ((visibility ("default")))
+ #define DLL_EXPORT __attribute__ ((visibility ("default")))
+ #define DLL_LOCAL __attribute__ ((visibility ("hidden")))
+ #else
+ #define DLL_IMPORT
+ #define DLL_EXPORT
+ #define DLL_LOCAL
+ #endif
+#endif
+
+#ifdef SERVICE_ADAPTOR_CLIENT_DLL
+ #ifdef SERVICE_ADAPTOR_CLIENT_DLL_EXPORTS
+ #define SERVICE_ADAPTOR_CLIENT_PUBLIC_API DLL_EXPORT
+ #else
+ #define SERVICE_ADAPTOR_CLIENT_PUBLIC_API DLL_IMPORT
+ #endif
+ #define SERVICE_ADAPTOR_CLIENT_LOCAL_API DLL_LOCAL
+#else
+ #define SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+ #define SERVICE_ADAPTOR_CLIENT_LOCAL_API
+#endif
+
+#include "service_adaptor_client.h"
+#include "service_adaptor_client_type.h"
+#include "private/service-adaptor-client.h"
+#include <glib.h>
+
+/**
+* @brief Describes infromation about Service Adaptor
+*/
+struct _service_adaptor_s
+{
+ void *on_signal;
+
+// struct _service_plugin_s **plugins; //TODO
+// int plugin_count; // TODO
+
+/////////////////////// private feature
+ char *service_name; /**< specifies status as none*/
+ char *user_id; /**< specifies status as none*/
+ char *app_id; /**< specifies status as none*/
+ unsigned int service_id;
+ char *imsi; /**< specifies status as none*/
+ GMutex set_auth_mutex;
+
+ service_adaptor_plugin_s *plugin; /**< specifies status as none*/
+/////////////////////// private feature
+};
+
+typedef struct _plugin_entry_s
+{
+ char *plugin_uri;
+ int installed_mask;
+}plugin_entry_t;
+
+typedef enum _client_app_type_e
+{
+ CLIENT_APP_TYPE_APPLICATION = 1,
+ CLIENT_APP_TYPE_ETC = 0,
+}client_app_type_e;
+
+struct _service_plugin_s
+{
+ struct _service_adaptor_s *adaptor;
+
+ char *service_handle_name;
+ void *optional_property;
+ char *plugin_uri;
+ int enabled_mask;
+ client_app_type_e app_type;
+};
+
+
+
+
+
+/**
+* @brief Callback for getting login result
+* @since_tizen 2.4
+*
+* @param[in] result Result code for login request (see #service_adaptor_error_e)
+* @param[in] user_data Passed data from request function
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_NETWORK_UNREACHABLE Failed by network issue
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see #service_adaptor_error_e
+* @see service_plugin_request_login()
+* @pre #service_plugin_request_login() will invoke this callback.
+*/
+typedef void (*service_plugin_login_cb)(int result,
+ void *user_data);
+
+
+
+/**
+* @brief Set callback for changing state of Service Adaptor
+* @since_tizen 2.4
+*
+* @param[in] service_adaptor The handle of Service Adaptor
+* @param[in] callback The callback function to receive message from service adaptor daemon
+* @param[in] user_data Passed data to callback
+* @remarks @a service_adaptor must be released memory using service_adaptor_destroy() when you finish using service adaptor
+* @see service_adaptor_destroy()
+* @see service_adaptor_signal_cb()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_HANDLE Invalid handle
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre @a service_adaptor must be issued by service_adaptor_create()
+*/
+int service_adaptor_set_state_changed_cb(service_adaptor_h service_adaptor,
+ service_adaptor_signal_cb callback,
+ void *user_data);
+
+/**
+* @brief Set callback for changing state of Service Adaptor
+* @since_tizen 2.4
+*
+* @param[in] service_adaptor The handle of Service Adaptor
+* @remarks @a service_adaptor must be released memory using service_adaptor_destroy() when you finish using service adaptor
+* @see service_adaptor_destroy()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_HANDLE Invalid handle
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre @a service_adaptor must be issued by service_adaptor_create()
+*/
+int service_adaptor_unset_state_changed_cb(service_adaptor_h service_adaptor);
+
+/**
+* @brief Gets whether a plugin is logined or not logined
+* @details 'Login' includes both authentication(sign-in by user) and authorization (allowed by user) <br>
+* If plugin does not need authentication or authorization, service_plugin_is_login_required() API's result is true on anytime.
+* @since_tizen 2.4
+*
+* @param[in] plugin The handle for use Plugin APIs
+* @param[out] required true on login required, otherwise false
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+*/
+int service_plugin_is_login_required(service_plugin_h plugin,
+ bool *required);
+
+/**
+* @brief Requests login to plugin
+* @details 'Login' includes both authentication(sign-in by user) and authorization (allowed by user) <br>
+* If the plugin does not logined by user, you must request login using this API.<br>
+* You can check whether logined or not using service_plugin_is_login_required().<br>
+* If not logined, you will be failed #service_plugin_start().<br>
+* Of caurse, if plugin does not need authentication or authorization, service_plugin_is_login_required() API's result is true on anytime.
+* @since_tizen 2.4
+*
+* @param[in] plugin The handle for use Plugin APIs
+* @param[in] callback The callback for getting result this operation
+* @param[in] user_data The user data to be passed to the callback function
+* @see service_plugin_start()
+* @see service_plugin_login_cb()
+* @see service_adaptor_get_last_result()
+* @see service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @post #service_plugin_login_cb() will be invoked
+*/
+int service_plugin_request_login(service_plugin_h plugin,
+ service_plugin_login_cb callback,
+ void *user_data);
+
+/**
+* @brief The type for Service Adaptor
+*/
+typedef struct _service_adaptor_s service_adaptor_s;
+
+typedef struct _service_plugin_s service_plugin_s;
+
+void _service_adaptor_set_last_result (int code, const char *message);
+
+#define service_adaptor_set_last_result(code, msg) do { \
+ sac_error("Error occured (%d)(%s)", (int)(code), (msg)); \
+ _service_adaptor_set_last_result((code), (msg)); \
+ } while (0)
+
+#endif /*__TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_PRIVATE_H__*/
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: service_adaptor_client_storage_private.h
+ * Desc: Service Adaptor APIs
+ * Created on: Feb, 2015
+ * Auth: Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+/**
+ * @file service_adaptor_client_storage_internal.h
+ * @brief Defines interface of Service Adaptor's Storage
+ * @version 0.1
+ */
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_STORAGE_INTERNAL_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_STORAGE_INTERNAL_H__
+
+#include "service_adaptor_client.h"
+#include "service_adaptor_client_storage.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Storage adaptor content type
+ */
+typedef enum _service_storage_file_content_type_e
+{
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_DEFAULT = -1, // initalize value
+
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_IMGAE = 160,
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_VIDEO = 161,
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_SOUND = 162,
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_MUSIC = 163,
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_OTHER = 164,
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_DOCUMENT = 165,
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_THUMBNAIL = 166,
+
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_CHUNK_MASK = 320,
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_IMGAE_CHUNK = 480,
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_VIDEO_CHUNK = 481,
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_SOUND_CHUNK = 482,
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_MUSIC_CHUNK = 483,
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_OTHER_CHUNK = 484,
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_DOCUMENT_CHUNK = 485,
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_THUMBNAIL_CHUNK = 486,
+
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_FOLDER = 1024,
+ SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_METADATA = 2048,
+} service_storage_content_type_e;
+
+typedef struct _service_storage_media_meta_s
+{
+ char *mime_type;
+ char *title;
+ char *album;
+ char *artist;
+ char *genere;
+ char *recorded_date;
+ int width;
+ int height;
+ int duration;
+ char *copyright;
+ char *track_num;
+ char *description;
+ char *composer;
+ char *year;
+ int bitrate;
+ int samplerate;
+ int channel;
+ char *extra_media_meta;
+} service_storage_media_meta_s;
+
+typedef struct _service_storage_cloud_meta_s
+{
+ char *service_name;
+ unsigned long long usage_byte;
+ unsigned long long quota_byte;
+ char *extra_cloud_meta;
+} service_storage_cloud_meta_s;
+
+/**
+* @brief Describes file information description
+*/
+struct _service_storage_file_s
+{
+ char *plugin_name; /**< specifies plugin name generated file_info */
+ char *object_id; /**< specifies file object id be used in storage */
+ char *storage_path; /**< specifies file path in storage */
+ unsigned long long file_size; /**< specifies file size (recomend byte)*/
+ unsigned long long created_time; /**< specifies timestamp */
+ unsigned long long modified_time; /**< specifies timestamp */
+ int file_info_index; /**< specifies file info index (wide use; e.g : chunk upload, multi download)*/
+ service_storage_content_type_e content_type; /**< specifies file content type (reference service_adaptor_file_content_type_e) */
+
+ service_storage_media_meta_s *media_meta;
+ service_storage_cloud_meta_s *cloud_meta;
+ char *extra_file_info; /**< specifies content name in metadata */
+};
+
+
+typedef struct _service_storage_file_s service_storage_file_s;
+
+/**
+* @brief The handle for File Description
+*/
+typedef struct _service_storage_file_s *service_storage_file_h;
+
+
+
+/**
+* @brief Callback for file upload and download API
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] file_handle specifies file description
+* @param[in] transferred_size specifies transferred size
+* @param[in] total_size specifies total size
+* @param[in] error_code specifies error code
+* @param[in] user_data specifies user_data passed in API
+* @return void
+* @pre service_adaptor_request_channel_auth will invoke this callback.
+* @see
+*/
+/*
+typedef void(* service_adaptor_file_progress_cb)(service_adaptor_h handle,
+ service_adaptor_file_h file_handle,
+ unsigned long long transferred_size,
+ unsigned long long total_size,
+ service_adaptor_error_s *error_code,
+ void *user_data);
+*/
+/**
+* @brief Callback for file transfer completion
+*
+* @param[in] handle specifies Service Adaptor handle. use this handle to get internal data
+* @param[in] file_handle specifies file description
+* @param[in] publish_url specifies publish url for another user
+* @param[in] error_code specifies error code
+* @param[in] user_data specifies user_data passed in API
+* @return void
+* @pre service_adaptor_request_channel_auth will invoke this callback.
+* @see
+*/
+/*
+typedef void(* service_adaptor_file_transfer_completion_cb)(service_adaptor_h handle,
+ service_adaptor_file_h file_handle,
+ char *publish_url,
+ service_adaptor_error_s *error_code,
+ void *user_data);
+
+*/
+
+/**
+* @brief Create memory for service_storage_file_h
+* @since_tizen 2.4
+*
+* @param[in] void
+* @return service_storage_file_h
+* @retval Allocated and filled default value file_info's pointer
+*/
+service_storage_file_h service_storage_create_file_info(void);
+
+/**
+* @brief Release memory for service_storage_file_h
+* @since_tizen 2.4
+*
+* @param[in] file_info specifies Service Adaptor file information handle
+* @return service_storage_file_h
+* @retval released file_info's pointer
+*/
+int service_storage_unref_file_info(service_storage_file_h *file_info);
+
+
+
+/**
+* @brief Registers File Progress Listener
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] callback the callback function to invoke
+* @param[in] user_data specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_adaptor_register_file_progress_listener(service_adaptor_h handle,
+ service_adaptor_file_progress_cb callback,
+ void *user_data);
+*/
+/**
+* @brief Unregisters File Progress Listener
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] user_data specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_adaptor_unregister_file_progress_listener(service_adaptor_h handle,
+ void *user_data);
+*/
+/**
+* @brief Registers File Transfer Completion Listener
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] callback the callback function to invoke
+* @param[in] user_data specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_adaptor_register_file_transfer_completion_listener(service_adaptor_h handle,
+ service_adaptor_file_transfer_completion_cb callback,
+ void *user_data);
+*/
+/**
+* @brief Unregisters File Transfer Completion Listener
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] user_data specifies user_data passed in API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_adaptor_unregister_file_transfer_completion_listener(service_adaptor_h handle,
+ void *user_data);
+
+*/
+/**
+* @brief Downloads a server file and writes it to local file (Async)
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] server_path specifies server url of file to download
+* @param[in] download_path specifies local path where we expect downloaded file to be written
+* @param[out] file_handle specifies file description
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_download_file_async(service_adaptor_h handle,
+ const char *storage_path,
+ const char *local_path,
+ service_adaptor_file_h *file_handle,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+*/
+
+
+/**
+* @brief Uploads a local file to server path (Async)
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] upload_path specifies local path for upload
+* @param[in] server_path specifies server url of file to download
+* @param[out] file_handle specifies file description
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_upload_file_async(service_adaptor_h handle,
+ const char *local_path,
+ const char *storage_path,
+ service_adaptor_file_h *file_handle,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+*/
+
+
+
+/**
+* @brief Downloads a server file and writes it to local file
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] publish_url specifies publish url of file to download
+* @param[in] download_path specifies local path where we expect downloaded file to be written
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_download_file_publish(service_adaptor_h handle,
+ const char *publish_url,
+ const char *local_path,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+*/
+/**
+* @brief Downloads a server file and writes it to local file (Async)
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] publish_url specifies publish url of file to download
+* @param[in] download_path specifies local path where we expect downloaded file to be written
+* @param[out] file_handle specifies file description
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_download_file_publish_async(service_adaptor_h handle,
+ const char *publish_url,
+ const char *local_path,
+ service_adaptor_file_h *file_handle,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+*/
+/**
+* @brief Uploads a local file to server path
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] upload_path specifies local path for upload
+* @param[in] server_path specifies server url of file to download
+* @param[out] publish_url specifies publish url
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+
+/*
+int service_storage_upload_file_publish(service_adaptor_h handle,
+ const char *local_path,
+ const char *storage_path,
+ char **publish_url,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+*/
+/**
+* @brief Uploads a local file to server path (Async)
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] upload_path specifies local path for upload
+* @param[in] server_path specifies server url of file to download
+* @param[out] file_handle specifies file description
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_upload_file_publish_async(service_adaptor_h handle,
+ const char *local_path,
+ const char *storage_path,
+ service_adaptor_file_h *file_handle,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+*/
+/**
+* @brief Downloads a thumbnail file and writes it to local file
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] publish_url specifies publish url of file to download
+* @param[in] download_path specifies local path where we expect downloaded file to be written
+* @param[in] size specifies size of thumbnail
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_download_thumbnail_publish(service_adaptor_h handle,
+ const char *publish_url,
+ const char *local_path,
+ storage_adaptor_thumbnail_size_e size,
+ service_adaptor_error_s **error_code,
+ void *user_data);
+*/
+/**
+* @brief Requests File Status
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] file_handle specifies file description
+* @param[out] status specifies status of file transfer
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) received from Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_get_file_status(service_adaptor_h handle,
+ service_adaptor_file_h file_handle,
+ service_adaptor_file_status_s **status,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+*/
+
+/**
+* @brief Cancels File Transfer
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] file_handle specifies file description
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) received from Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_cancel_file_transfer(service_adaptor_h handle,
+ service_adaptor_file_h file_handle,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+*/
+/**
+* @brief Pause File Transfer
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] file_handle specifies file description
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) received from Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_pause_file_transfer(service_adaptor_h handle,
+ service_adaptor_file_h file_handle,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+*/
+/**
+* @brief Resume File Transfer
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] file_handle specifies file description
+* @param[out] error_code specifies error code
+* @param[out] server_data specifies server_data (json) received from Server API
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+/*
+int service_storage_resume_file_transfer(service_adaptor_h handle,
+ service_adaptor_file_h file_handle,
+ service_adaptor_error_s **error_code,
+ void **server_data);
+*/
+
+
+
+
+/**
+* @brief Downloads a server file and writes it to local file
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] server_path specifies server url of file to download
+* @param[in] download_path specifies local path where we expect downloaded file to be written
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see service_adaptor_error_s
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+
+int service_storage_download_file(service_plugin_h handle,
+ const char *storage_path,
+ const char *local_path);
+
+/**
+* @brief Requests download thumbnail from storage (internal)
+* @since_tizen 2.4
+*
+* @param[in] plugin The handle for use Plugin APIs
+* @param[in] storage_path The source file path in storage (Physical path)
+* @param[in] download_path The download path in local (Logical path)
+* @param[in] thumbnail_size The size <b>level</b> of thumbnail, the level is defined service plugin SPEC
+* @remarks If @a thumbnail_size is <b>0</b>, gets default size thumbnail, the default size must be defined plugin SPEC
+* @remarks If @a thumbnail_size is <b>-1</b>, gets minimum size thumbnail be supported plugin
+* @remarks If @a thumbnail_size is <b>-2</b>, gets maximum size thumbnail be supported plugin
+* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @remarks Reference details for <b>"Logical path"</b> and <b>"Physical path"</b> at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page
+* @see service_plugin_start()
+* @see service_adaptor_get_last_result()
+* @see service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no thumbnail data
+* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre API prerequires #service_plugin_start()
+*/
+int service_storage_download_thumbnail(service_plugin_h handle,
+ const char *storage_path,
+ const char *local_path,
+ int thumbnail_size);
+
+/**
+* @brief Uploads a local file to server path
+* @since_tizen 2.4
+* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
+* @see service_storage_file_h
+* @see service_storage_unref_file_info
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] upload_path specifies local path for upload
+* @param[in] server_path specifies server url of file to download
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see service_adaptor_error_s
+* @remarks 'file_info' is needed memory free using 'service_storage_unref_file_info()'
+* @see service_storage_unref_file_info()
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+int service_storage_upload_file(service_plugin_h handle,
+ const char *local_path,
+ const char *storage_path,
+ service_storage_file_h *file_info);
+/**
+* @brief Get root diretory path
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[out] dir_path specifies be mounted path
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see service_adaptor_error_s
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+int service_storage_get_root_directory(service_plugin_h handle,
+ char **dir_path);
+
+/**
+* @brief Make directory in storage
+* @since_tizen 2.4
+* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
+* @see service_storage_file_h
+* @see service_storage_unref_file_info
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] dir_path specifies directory path will be made
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see service_adaptor_error_s
+* @remarks 'file_info' is needed memory free using 'service_storage_unref_file_info()'
+* @see service_storage_unref_file_info()
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+int service_storage_make_directory(service_plugin_h handle,
+ const char *dir_path,
+ service_storage_file_h *file_info);
+
+/**
+* @brief Remove file in storage
+* @since_tizen 2.4
+* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
+* @see service_storage_file_h
+* @see service_storage_unref_file_info
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] file_path specifies file path will be removed
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see service_adaptor_error_s
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+int service_storage_remove_file(service_plugin_h handle,
+ const char *file_path);
+
+/**
+* @brief Remove directory in storage
+* @since_tizen 2.4
+* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
+* @see service_storage_file_h
+* @see service_storage_unref_file_info
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] file_path specifies directory path will be removed
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see service_adaptor_error_s
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+int service_storage_remove_directory(service_plugin_h handle,
+ const char *dir_path);
+
+/**
+* @brief Move file in storage
+* @since_tizen 2.4
+* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
+* @see service_storage_file_h
+* @see service_storage_unref_file_info
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] src_file_path specifies source file path will move
+* @param[in] dst_file_path specifies destination file path will be moved
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see service_adaptor_error_s
+* @remarks 'file_info' is needed memory free using 'service_storage_unref_file_info()'
+* @see service_storage_unref_file_info()
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+int service_storage_move_file(service_plugin_h handle,
+ const char *src_file_path,
+ const char *dst_file_path,
+ service_storage_file_h *file_info);
+
+/**
+* @brief Move directory in storage
+* @since_tizen 2.4
+* @remarks 'file_info' need memory release using 'service_storage_unref_file_info'
+* @see service_storage_file_h
+* @see service_storage_unref_file_info
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] src_file_path specifies source directory path will move
+* @param[in] dst_file_path specifies destination directory path will be moved
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see service_adaptor_error_s
+* @remarks 'file_info' is needed memory free using 'service_storage_unref_file_info()'
+* @see service_storage_unref_file_info()
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+int service_storage_move_directory(service_plugin_h handle,
+ const char *src_dir_path,
+ const char *dst_dir_path,
+ service_storage_file_h *file_info);
+
+/**
+* @brief Get directory entries in storage
+* @since_tizen 2.4
+*
+* @param[in] handle specifies Service Adaptor handle
+* @param[in] dir_path specifies parent directory path
+* @param[out] file_info_list specifies file_info entries in 'dir_path'
+* @param[out] file_info_list_len specifies file_info entries count
+* @param[out] error_code specifies error code
+* @param[in] user_data specifies user_data (json) passed in Server API
+* @remarks 'error_code' and 'error_code->msg'(Caution to NULL dereference) is need memory free using 'free()'
+* @see service_adaptor_error_s
+* @remarks 'file_info_list[<index>]' is needed memory free using 'service_storage_unref_file_info()'
+* @see service_storage_unref_file_info()
+* @remarks 'file_info_list' is needed memory free using 'free()' after free for each element
+* @see free()
+* @return 0 on success, otherwise a negative error value
+* @retval error code defined in int - SERVICE_ADAPTOR_ERROR_NONE if Successful
+*/
+int service_storage_get_directory_entries(service_plugin_h handle,
+ const char *dir_path,
+ service_storage_file_h **file_info_list,
+ unsigned int *file_info_list_len);
+
+
+/**
+* @brief Gets result after finishing storage task
+* @since_tizen 2.4
+*
+* @param[in] task The handle of storage task
+* @param[out] result The result information
+* @remarks This function must be called after complete to specfic task
+* @remarks When the <b>upload task</b> was finished, @a result is filled to #service_storage_file_h
+* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @see service_storage_start_task()
+* @see service_adaptor_get_last_result()
+* @see service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED Permission denied
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre API prerequires #service_plugin_start()
+*/
+int service_storage_get_task_result(service_storage_task_h task,
+ void **result);
+
+#ifdef __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /*__TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_STORAGE_INTERNAL_H__*/
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_TYPE_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_TYPE_H__
+
+#include <stdint.h>
+#include "service_adaptor_client.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define TASK_MESSAGE_FORWARD_ONLINE_MESSAGE -100
+#define TASK_MESSAGE_FORWARD_UNREAD_MESSAGE -101
+#define TASK_MESSAGE_CHANNEL_DISCONNECTED_MESSAGE -102
+
+///////////////// private feature
+#define PRIVATE_SIGNAL_FILE_PROGRESS_ID 11000
+#define PRIVATE_SIGNAL_FILE_TRANSFER_COMPLETION_ID 11001
+///////////////// private feature
+
+#define SIGNAL_STORAGE_FILE_PROGRESS_ID 1000
+#define SIGNAL_STORAGE_FILE_STATE_CHANGED_ID 1001
+#define SIGNAL_SERVICE_ADAPTOR 9000
+
+//////////////////////////////////////////////////////////////////////////////////
+///// Signal Task area
+//////////////////////
+
+typedef struct _service_storage_task_s
+{
+ char *service_handle_name;
+ long long int task_id; // file_uid (matched fd)
+ void *param1;
+ void *param2;
+ void *param3;
+
+ int operation; // 1: upload, 2: download, 3:thumbnail (TEMP)
+ int state;
+ service_storage_task_state_cb state_callback;
+ void *state_user_data;
+ service_storage_task_progress_cb progress_callback;
+ void *progress_user_data;
+}service_storage_task_t;
+
+/**
+* @brief Describes infromation about task
+*/
+typedef struct _service_adaptor_task_s
+{
+ int64_t id; /**< specifies status as none*/
+ uint32_t callback; /**< specifies status as none*/
+ void *handle; /**< specifies status as none*/
+ void *user_data;
+} service_adaptor_task_s;
+
+/**
+* @brief Describes infromation about Service Adaptor's error
+* @remarks 'msg' is need free()
+*/
+typedef struct _service_adaptor_error_s
+{
+ long long int code; /**< specifies status as none*/
+ char *msg; /**< specifies status as none*/
+} service_adaptor_error_s;
+
+#define __SAFE_STRDUP(x) (x) ? strdup((x)) : NULL
+#define __SAFE_FREE(x) do { free(x); (x) = NULL; } while (0)
+#define _assign_error_code(src, tgt) do { \
+ sac_error("Error occured a : (%lld) (%s)", (long long int)((src)->code), (src)->msg); \
+ __assign_error_code((src), (tgt)); \
+ } while (0)
+
+#define _set_error_code(tgt, code, msg) do { \
+ sac_error("Error occured b : (%d) (%s)", (int)(code), (msg)); \
+ __set_error_code((tgt), (code), (msg)); \
+ } while (0)
+
+
+/**
+* @brief The handle for Task
+*/
+typedef service_adaptor_task_s *service_adaptor_task_h;
+
+int _queue_add_task(int64_t id,
+ uint32_t callback,
+ void *handle,
+ void *user_data);
+
+int _queue_del_task(service_adaptor_task_h task);
+
+service_adaptor_task_h _queue_get_task(int64_t id);
+
+void _queue_clear_task(void);
+
+int _signal_queue_add_task(int64_t id,
+ uint32_t callback,
+ void *handle,
+ void *user_data);
+
+service_adaptor_task_h _signal_queue_get_task(int64_t id);
+
+int _signal_queue_del_task(service_adaptor_task_h task);
+
+void _signal_queue_clear_task(void);
+
+int service_adaptor_check_handle_validate(service_adaptor_h handle);
+
+
+/**
+ * @brief Enumerations of signal code for Service Adaptor
+ */
+typedef enum _service_adaptor_signal_code_e
+{
+ SERVICE_ADAPTOR_SIGNAL_INITIALIZED = 1, /* Service adaptor finished initalization */
+ SERVICE_ADAPTOR_SIGNAL_NEW_PLUGIN = 2, /* New Plugins loaded in a running time */
+ SERVICE_ADAPTOR_SIGNAL_ACTIVATE_PLUGIN = 3, /* Some Plugins be activated by policy or user atholization or etc */
+ SERVICE_ADAPTOR_SIGNAL_SHUTDOWN = 4, /* Service adaptor was shutdowned by unsuspected issue */
+} service_adaptor_signal_code_e;
+
+//////////////////////
+///// Signal Task area
+//////////////////////////////////////////////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////////////////////////////////
+///// Storage Task area
+//////////////////////
+
+
+//////////////////////
+///// Storage Task area
+//////////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifdef __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_TYPE_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_UTIL_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_UTIL_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include "service_adaptor_client_type.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char *_safe_strdup(const char *str);
+
+void __set_error_code(service_adaptor_error_s **error_code, int code, const char *msg);
+
+void __assign_error_code(service_adaptor_error_s *source_error, service_adaptor_error_s **target_error);
+
+int _get_result_code(long long int error_code);
+
+void _create_raw_data_from_plugin_property(void *property, GVariantBuilder **builder);
+
+static const int dbus_default_timeout_msec = 5000;
+
+#define sac_safe_add_string(str) ((str) ? (str) : "")
+
+#define ipc_check_proxy(proxy) do { \
+ if (NULL == (proxy)) { \
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE; \
+ error->msg = strdup("D-Bus interface proxy has NOT been initialized"); \
+ return SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE; \
+ } \
+ } while (0)
+
+int _ipc_get_simple_result(GVariant *call_result, GError *g_error, service_adaptor_error_s *error);
+
+#define _ipc_get_complex_result(expected_type, __DO_WORK) do { \
+ if (NULL == call_result) { \
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE; \
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE; \
+\
+ if (NULL != g_error) { \
+ sac_error("G_IO_ERROR DEBUG (%d)", (int)(g_error->code)); \
+ if (g_error->code == G_IO_ERROR_TIMED_OUT) { \
+ ret = SERVICE_ADAPTOR_ERROR_TIMED_OUT; \
+ } \
+ error->msg = __SAFE_STRDUP(g_error->message); \
+ g_error_free(g_error); \
+ } \
+ } else { \
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE((expected_type)))) { \
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE; \
+ error->msg = strdup("D-Bus return type error"); \
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE; \
+ } else { \
+ GVariant *call_result_struct[3]; \
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0); \
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1); \
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2); \
+\
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]); \
+\
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) { \
+ error->code = remote_call_result; \
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]); \
+ ret = _get_result_code(remote_call_result); \
+ } else { \
+ __DO_WORK \
+ } \
+\
+ g_variant_unref(call_result_struct[0]); \
+ g_variant_unref(call_result_struct[1]); \
+ g_variant_unref(call_result_struct[2]); \
+ } \
+\
+ g_variant_unref(call_result); \
+ } \
+} while (0)
+
+#define sac_check_param_null(val, val_name) {\
+ if (NULL == (val)) {\
+ sac_error ("\"%s\" is NULL, return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER(%d)", \
+ (const char *)val_name, (int)SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);\
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;\
+ }\
+}
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_UTIL_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: dbus-client.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include <dbus-server.h>
+
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "service_adaptor_client_private.h"
+#include "dbus_client.h"
+#include "dbus_client_storage.h"
+#include "dbus_client_message.h"
+#include "dbus_client_push.h"
+
+#include "private/service-adaptor-client.h"
+#include "util/service_adaptor_client_util.h"
+
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/**
+ * Service Adaptor D-Bus client thread data
+ */
+typedef struct {
+ GMutex connection_mutex; /* Mutex used to protect connection status data */
+ GCond connection_cond; /* Conditional variable used to signal that connection was established */
+ int connection_cond_signaled; /* Additional variable used to signal that connection was established */
+} dbus_service_adaptor_client_thread_data_s;
+
+/**
+ * D-Bus client thread.
+ */
+static GThread *dbusClientThread = NULL;
+
+/**
+ * D-Bus client thread main loop context.
+ */
+static GMainContext *dbusClientMainContext = NULL;
+
+/**
+ * D-Bus client thread main loop.
+ */
+static GMainLoop *dbusClientMainLoop = NULL;
+
+/**
+ * Service Adaptor D-Bus bus watcher id.
+ */
+static guint watcher_id = 0;
+
+/**
+ * D-Bus connection to vService Channel
+ */
+static GDBusConnection *connection = NULL;
+
+/**
+ * D-Bus proxy to Service Adaptor Client interface
+ */
+static GDBusProxy *sac_interface_proxy = NULL;
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+struct _internal_service_signal_data_s {
+ uint64_t code;
+ char *msg;
+ service_adaptor_task_h task;
+};
+
+static void *_on_dbus_disappeared_cb(void *data);
+
+/**
+ * @brief D-Bus client thread function.
+ *
+ * D-Bus client thread function. It initialises all client D-Bus interfaces.
+ * @param data Data passed to thread.
+ * @return Result data from thread (always NULL in this implementation).
+ */
+static gpointer __dbus_service_adaptor_client_thread(gpointer data);
+
+/**
+ * @brief Initialises Service Adaptor D-Bus client internal structures.
+ *
+ * Initialises Service Adaptor D-Bus client internal structures.
+ * @param thread_data Pointer to thread data used to signal that connection was successfully established.
+ * @return 0 on success, error code when some structures could not be initialised.
+ */
+static int __dbus_connection_init(dbus_service_adaptor_client_thread_data_s *thread_data);
+
+/**
+ * @brief Deinitialises Service Adaptor D-Bus client internal structures.
+ *
+ * Deinitialises Service Adaptor D-Bus client internal structures.
+ */
+static void __dbus_connection_deinit();
+
+/**
+ * @brief Service Adaptor availability callback function.
+ *
+ * Service Adaptor availability callback function. Called when Service Adaptor appears at D-Bus bus.
+ * @param connection D-Bus connection.
+ * @param name The name being watched.
+ * @param name_owner Unique name of the owner of the name being watched.
+ * @param user_data User data passed to g_bus_watch_name().
+ */
+static void on_name_appeared(GDBusConnection *connection,
+ const gchar *name,
+ const gchar *name_owner,
+ gpointer user_data);
+
+/**
+ * @brief Service Adaptor availability callback function.
+ *
+ * Service Adaptor availability callback function. Called when Service Adaptor disappears from D-Bus bus.
+ * @param connection D-Bus connection.
+ * @param name he name being watched.
+ * @param user_data User data passed to g_bus_watch_name().
+ */
+static void on_name_vanished(GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data);
+
+/**
+ * @brief Service Adaptor signals handler.
+ *
+ * Service Adaptor signals handler. It is called when Service Adaptor sends signal over D-Bus.
+ * @param proxy D-Bus proxy object.
+ * @param sender_name The unique bus name of the remote caller.
+ * @param signal_name Signal name.
+ * @param parameters Signal parameters.
+ * @param user_data The user_data gpointer.
+ */
+static void on_signal(GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data);
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+static gpointer __dbus_service_adaptor_client_thread(gpointer data)
+{
+ FUNC_START();
+ int ret = 0;
+
+ dbusClientMainContext = g_main_context_new();
+ dbusClientMainLoop = g_main_loop_new(dbusClientMainContext, FALSE);
+ g_main_context_push_thread_default(dbusClientMainContext);
+
+ ret = __dbus_connection_init(data);
+
+ if (0 == ret) {
+ g_main_loop_run(dbusClientMainLoop);
+ __dbus_connection_deinit();
+ } else {
+ /* Already released dbus setting (=__dbus_connection_deinit()) */
+ }
+
+ g_main_context_pop_thread_default(dbusClientMainContext);
+ g_main_loop_unref(dbusClientMainLoop);
+ dbusClientMainLoop = NULL;
+ g_main_context_unref(dbusClientMainContext);
+ dbusClientMainContext = NULL;
+
+ FUNC_END();
+ return data;
+}
+
+static int __dbus_connection_init(dbus_service_adaptor_client_thread_data_s *thread_data)
+{
+ FUNC_START();
+ GError *error = NULL;
+
+ if ((NULL != connection) || (sac_interface_proxy)) {
+ FUNC_STOP();
+ return -1;
+ }
+
+ connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+
+ if (NULL == connection) {
+ g_error_free(error);
+
+ FUNC_STOP();
+ return -1;
+ } else {
+ sac_interface_proxy = g_dbus_proxy_new_sync(connection,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ SERVICE_ADAPTOR_BUS_NAME,
+ SERVICE_ADAPTOR_OBJECT_PATH,
+ SERVICE_ADAPTOR_INTERFACE,
+ NULL,
+ &error);
+
+ if (NULL == sac_interface_proxy) {
+ g_error_free(error);
+
+ g_object_unref(connection);
+ connection = NULL;
+
+ FUNC_STOP();
+ return -1;
+ }
+ }
+
+ watcher_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
+ SERVICE_ADAPTOR_BUS_NAME,
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ on_name_appeared,
+ on_name_vanished,
+ thread_data,
+ NULL);
+
+ if (0 == watcher_id) {
+ g_object_unref(sac_interface_proxy);
+ sac_interface_proxy = NULL;
+
+ g_object_unref(connection);
+ connection = NULL;
+
+ FUNC_STOP();
+ return -1;
+ }
+
+ int res = g_signal_connect(sac_interface_proxy,
+ "g-signal",
+ G_CALLBACK(on_signal),
+ NULL);
+
+ if (0 == res) {
+ g_object_unref(sac_interface_proxy);
+ sac_interface_proxy = NULL;
+
+ g_object_unref(connection);
+ connection = NULL;
+
+ g_bus_unwatch_name(watcher_id);
+ watcher_id = 0;
+
+ FUNC_STOP();
+ return -1;
+ }
+
+ FUNC_END();
+ return 0;
+}
+
+static void __dbus_connection_deinit()
+{
+ FUNC_START();
+ if (NULL != sac_interface_proxy) {
+ g_object_unref(sac_interface_proxy);
+ sac_interface_proxy = NULL;
+ }
+
+ if (NULL != connection) {
+ g_object_unref(connection);
+ connection = NULL;
+ }
+
+ if (0 != watcher_id) {
+ g_bus_unwatch_name(watcher_id);
+ watcher_id = 0;
+ }
+}
+
+static void on_name_appeared(GDBusConnection *connection,
+ const gchar *name,
+ const gchar *name_owner,
+ gpointer user_data)
+{
+ FUNC_START();
+ dbus_service_adaptor_client_thread_data_s *thread_data = (dbus_service_adaptor_client_thread_data_s *)user_data;
+
+ if (NULL != thread_data) {
+ g_mutex_lock(&thread_data->connection_mutex);
+ thread_data->connection_cond_signaled = 1;
+ g_cond_signal(&thread_data->connection_cond);
+ g_mutex_unlock(&thread_data->connection_mutex);
+ }
+ FUNC_END();
+}
+
+static void on_name_vanished(GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ FUNC_START();
+ dbus_service_adaptor_client_thread_data_s *thread_data = (dbus_service_adaptor_client_thread_data_s *)user_data;
+
+ if ((NULL != thread_data) && (thread_data->connection_cond_signaled)) { /* appeared -> vanished */
+ if (0 != watcher_id) {
+ g_bus_unwatch_name(watcher_id);
+ watcher_id = 0;
+ }
+ pthread_t th;
+ pthread_create(&th, NULL, _on_dbus_disappeared_cb, NULL);
+ }
+ FUNC_END();
+}
+
+static void _service_signal_emitter(void *data)
+{
+ FUNC_START();
+ struct _internal_service_signal_data_s *signal_context =
+ (struct _internal_service_signal_data_s *) data;
+
+ service_adaptor_signal_cb callback = (service_adaptor_signal_cb) signal_context->task->callback;
+
+ if (NULL != callback) {
+ callback(signal_context->task->handle, (service_adaptor_signal_code_e) signal_context->code, signal_context->msg);/*, signal_context->task->user_data); */
+ }
+
+ g_free(signal_context->msg);
+ g_free(signal_context);
+ signal_context = NULL;
+
+ g_thread_unref(g_thread_self());
+ FUNC_END();
+}
+
+static void on_service_signal(GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ FUNC_START();
+
+ if (0 == g_strcmp0(signal_name, DBUS_SERVICE_ADAPTOR_SIGNAL)) {
+ service_adaptor_task_h task = _signal_queue_get_task(SIGNAL_SERVICE_ADAPTOR);
+
+ if (NULL == task) {
+ FUNC_STOP();
+ return;
+ }
+
+ struct _internal_service_signal_data_s *signal_context =
+ (struct _internal_service_signal_data_s *)g_malloc0(sizeof(struct _internal_service_signal_data_s));
+
+ if (NULL == signal_context) {
+ FUNC_STOP();
+ return;
+ } else {
+ signal_context->msg = NULL;
+ signal_context->task = NULL;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 0);
+ call_result[1] = g_variant_get_child_value(parameters, 1);
+
+ signal_context->code = g_variant_get_uint64(call_result[0]);
+ signal_context->msg = ipc_g_variant_dup_string(call_result[1]);
+ signal_context->task = task;
+
+
+ GError *worker_error = NULL;
+ g_thread_try_new("service-adaptor-client-signal-emitter", (GThreadFunc) _service_signal_emitter,
+ (void *) signal_context, &worker_error);
+
+ g_clear_error(&worker_error);
+ worker_error = NULL;
+ }
+
+ FUNC_END();
+}
+
+static void on_signal(GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ if (0 == strncmp(signal_name, DBUS_SERVICE_ADAPTOR, DBUS_NAME_LENGTH)) {
+ on_service_signal(proxy,
+ sender_name,
+ signal_name,
+ parameters,
+ user_data);
+ } else if (0 == strncmp(signal_name, DBUS_MESSAGE_ADAPTOR, DBUS_NAME_LENGTH)) {
+ on_message_signal(proxy,
+ sender_name,
+ signal_name,
+ parameters,
+ user_data);
+ } else if (0 == strncmp(signal_name, DBUS_STORAGE_ADAPTOR, DBUS_NAME_LENGTH)) {
+ on_storage_signal(proxy,
+ sender_name,
+ signal_name,
+ parameters,
+ user_data);
+ } else if (0 == strncmp(signal_name, DBUS_PUSH_ADAPTOR, DBUS_NAME_LENGTH)) {
+ on_push_signal(proxy,
+ sender_name,
+ signal_name,
+ parameters,
+ user_data);
+ }
+
+}
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+GDBusProxy *_dbus_get_sac_interface_proxy()
+{
+ return sac_interface_proxy;
+}
+
+/** @brie
+ * @return int
+ * @remarks :
+ */
+int _dbus_client_service_adaptor_init()
+{
+ FUNC_START();
+#if !GLIB_CHECK_VERSION(2, 32, 0)
+ g_thread_init(NULL);
+#endif
+#if !GLIB_CHECK_VERSION(2, 35, 0)
+ g_type_init();
+#endif
+
+ if (NULL != dbusClientThread) {
+ /* D-Bus client thread is already running */
+ FUNC_STOP();
+ return -1;
+ }
+
+ dbus_service_adaptor_client_thread_data_s *thread_data =
+ (dbus_service_adaptor_client_thread_data_s *) calloc(1, sizeof(dbus_service_adaptor_client_thread_data_s));
+
+ if (NULL == thread_data) {
+ FUNC_STOP();
+ return -1;
+ }
+
+ g_mutex_init(&thread_data->connection_mutex);
+ g_cond_init(&thread_data->connection_cond);
+ thread_data->connection_cond_signaled = 0;
+
+ dbusClientThread = g_thread_new("Service Adaptor D-Bus Client Thread", __dbus_service_adaptor_client_thread, thread_data);
+
+ gint64 timeout = g_get_monotonic_time() + 15 * G_TIME_SPAN_SECOND;
+ g_mutex_lock(&thread_data->connection_mutex);
+ while (!thread_data->connection_cond_signaled) {
+ if (!g_cond_wait_until(&thread_data->connection_cond, &thread_data->connection_mutex, timeout)) {
+ /* timeout */
+ g_mutex_unlock(&thread_data->connection_mutex);
+
+ FUNC_STOP();
+ return -1;
+ }
+ }
+ g_mutex_unlock(&thread_data->connection_mutex);
+
+ FUNC_END();
+ return 0;
+}
+
+/** @brief
+ * @return void
+ * @remarks :
+ */
+void _dbus_client_service_adaptor_deinit()
+{
+ FUNC_START();
+ if (NULL != dbusClientMainLoop) {
+ if (g_main_loop_is_running(dbusClientMainLoop)) {
+ g_main_loop_quit(dbusClientMainLoop);
+ }
+ }
+
+ if (NULL != dbusClientThread) {
+ gpointer data = g_thread_join(dbusClientThread);
+ if (NULL != data) { /* thread passed data must be free here */
+ free(data);
+ }
+ dbusClientThread = NULL;
+ }
+
+ if (NULL != dbusClientMainLoop) {
+ g_main_loop_unref(dbusClientMainLoop);
+ dbusClientMainLoop = NULL;
+ }
+
+ if (NULL != dbusClientMainContext) {
+ g_main_context_pop_thread_default(dbusClientMainContext);
+ g_main_context_unref(dbusClientMainContext);
+ dbusClientMainContext = NULL;
+ }
+
+ _queue_clear_task();
+ _signal_queue_clear_task();
+ FUNC_END();
+}
+
+/**
+ * Adds string into variant builder
+ * @param builder Builder
+ * @param data String to be added
+ */
+void __safe_g_variant_builder_add_string(GVariantBuilder *builder,
+ const char *data)
+{
+ if (NULL == data) {
+ g_variant_builder_add(builder, "s", "");
+ } else {
+ g_variant_builder_add(builder, "s", data);
+ }
+}
+
+void __safe_g_variant_builder_add_array_string(GVariantBuilder *builder,
+ const char *data)
+{
+ if (NULL == data) {
+ g_variant_builder_add(builder, "(s)", "");
+ } else {
+ g_variant_builder_add(builder, "(s)", data);
+ }
+}
+
+char *ipc_g_variant_dup_string(GVariant *string)
+{
+ char *ret = g_variant_dup_string(string, NULL);
+
+ if (0 == strcmp(ret, "")) {
+ free(ret);
+ ret = NULL;
+ }
+
+ return ret;
+}
+
+/** @brief
+ * @return service_adaptor_error_s
+ * @remarks :
+ */
+int _dbus_connect_service_adaptor(service_adaptor_error_s *error)
+{
+ FUNC_START();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ char executable_path[1000] = {0, };
+ int executable_path_len = 0;
+ executable_path_len = readlink("/proc/self/exe", executable_path, 1000);
+
+ if (executable_path_len <= 0)
+ snprintf(executable_path, strlen("notfound") + 1, "%s", "notfound");
+
+ char *client_info = g_strdup_printf("%s %d", executable_path, (int)getpid());
+
+ sac_info("[DM] client info <%s>", client_info);
+ GVariant *req = g_variant_new("("service_adaptor_essential_s_type")", client_info);
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_CONNECT_SERVICE_ADAPTOR_METHOD,
+ req,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[2];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+ ret = SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED;
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ }
+ g_variant_unref(call_result);
+ }
+
+/* g_variant_unref(req);*/
+ free(client_info);
+
+ FUNC_END();
+ return ret;
+}
+
+int _dbus_disconnect_service_adaptor(service_adaptor_error_s *error)
+{
+ FUNC_START();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ char executable_path[1000] = {0, };
+ int executable_path_len = 0;
+ executable_path_len = readlink("/proc/self/exe", executable_path, 1000);
+
+ if (executable_path_len <= 0)
+ snprintf(executable_path, strlen("notfound") + 1, "%s", "notfound");
+
+ char *client_info = g_strdup_printf("%s %d", executable_path, (int)getpid());
+
+ sac_info("[DM] client info <%s>", client_info);
+ GVariant *req = g_variant_new("("service_adaptor_essential_s_type")", client_info);
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_DISCONNECT_SERVICE_ADAPTOR_METHOD,
+ req,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[2];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+ ret = SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED;
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+/* g_variant_unref(req);*/
+ free(client_info);
+
+ FUNC_END();
+ return ret;
+}
+
+int _dbus_get_plugin_list(plugin_entry_t ***plugin_list,
+ unsigned int *plugins_len,
+ service_adaptor_error_s *error)
+{
+ FUNC_START();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_GET_AUTH_PLUGIN_LIST_METHOD,
+ g_variant_new("(s)",
+ "temp_todo_remove"), /*TODO */
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(plugin_list_type)))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED;
+ } else {
+ gsize list_count = g_variant_n_children(call_result_struct[0]);
+
+ *plugins_len = (unsigned int) (list_count);
+ plugin_entry_t **plugins = NULL;
+ plugins = (plugin_entry_t **) calloc((*plugins_len), sizeof(plugin_entry_t *));
+
+ if (NULL != plugins) {
+ for (gsize i = 0; i < list_count; i++) {
+ GVariant *plugin_info_struct[service_adaptor_plugin_s_type_length];
+ GVariant *plugin_info_entry_v = g_variant_get_child_value(call_result_struct[0], i);
+
+ for (size_t j = 0; j < service_adaptor_plugin_s_type_length; j++) {
+ plugin_info_struct[j] = g_variant_get_child_value(plugin_info_entry_v, j);
+ }
+
+ plugins[i] = (plugin_entry_t *) calloc(1, sizeof(plugin_entry_t));
+
+ int idx = 0;
+ plugins[i]->plugin_uri = ipc_g_variant_dup_string(plugin_info_struct[idx++]);
+ plugins[i]->installed_mask = g_variant_get_int32(plugin_info_struct[idx++]);
+
+ for (size_t j = 0; j < service_adaptor_plugin_s_type_length; j++) {
+ g_variant_unref(plugin_info_struct[j]);
+ }
+ }
+ *plugin_list = plugins;
+ } else {
+ *plugins_len = (unsigned int) 0;
+ ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ FUNC_END();
+ return ret;
+}
+
+int _dbus_is_login_required(service_plugin_h plugin,
+ bool *required,
+ service_adaptor_error_s *error)
+{
+ FUNC_START();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariantBuilder *builder_in = NULL;
+ _create_raw_data_from_plugin_property((void *)(plugin->optional_property), &builder_in);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_IS_AUTH_METHOD,
+ g_variant_new("(" service_adaptor_is_auth_req_s_type ")",
+ plugin->plugin_uri,
+ builder_in),
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ bool is_auth = false;
+
+ _ipc_get_complex_result(MAKE_RETURN_TYPE("(b)"),
+
+ GVariant *res_info_struct = g_variant_get_child_value(call_result_struct[0], 0);
+ is_auth = g_variant_get_boolean(res_info_struct);
+ g_variant_unref(res_info_struct);
+ );
+
+ *required = !is_auth;
+
+ return ret;
+}
+
+struct __login_request_context
+{
+ void *callback;
+ void *user_data;
+};
+
+static void __dbus_login_result_callback (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+
+ service_adaptor_error_s error = {0LL, NULL};
+ GError *g_error = NULL;
+
+ GVariant *result_obj = g_dbus_proxy_call_finish(_dbus_get_sac_interface_proxy(), res, &g_error);
+ int result = _ipc_get_simple_result(result_obj, g_error, &error);
+ if (SERVICE_ADAPTOR_ERROR_NONE != result) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ }
+
+ struct __login_request_context *context = (struct __login_request_context *)user_data;
+ service_plugin_login_cb callback = (service_plugin_login_cb)(context->callback);
+
+ callback(result, context->user_data);
+
+ free(context);
+ if (g_error) {
+ g_error_free(g_error);
+ }
+}
+
+int _dbus_request_login(service_plugin_h plugin,
+ void *callback,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ FUNC_START();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ struct __login_request_context *context = (struct __login_request_context *)calloc(1, sizeof(struct __login_request_context));
+ if (NULL == context) {
+ error->code = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ error->msg = strdup("Memory allocation failed");
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+ context->callback = callback;
+ context->user_data = user_data;
+
+ GVariantBuilder *builder_in = NULL;
+ _create_raw_data_from_plugin_property((void *)(plugin->optional_property), &builder_in);
+
+ g_dbus_proxy_call(sac_interface_proxy,
+ DBUS_JOIN_METHOD,
+ g_variant_new("(" service_adaptor_join_req_s_type ")",
+ plugin->plugin_uri,
+ builder_in),
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ __dbus_login_result_callback,
+ (void *)context);
+
+ return ret;
+}
+
+int _dbus_start_service(service_plugin_h plugin,
+ int service_flag,
+ const char *security_cookie,
+ service_adaptor_error_s *error)
+{
+ FUNC_START();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ char *app_id = NULL;
+ char *app_secret = NULL;
+ char *user_id = NULL;
+ char *user_password = "";
+
+ if (NULL != plugin->optional_property) {
+ app_id = (char *) g_hash_table_lookup((GHashTable *)plugin->optional_property, (gconstpointer) SERVICE_PLUGIN_PROPERTY_APP_KEY);
+ app_secret = (char *) g_hash_table_lookup((GHashTable *)plugin->optional_property, (gconstpointer) SERVICE_PLUGIN_PROPERTY_APP_SECRET);
+ user_id = (char *) g_hash_table_lookup((GHashTable *)plugin->optional_property, (gconstpointer) SERVICE_PLUGIN_PROPERTY_USER_ID);
+ }
+
+ GVariantBuilder *builder_in = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+ for (int k = 0; k < (SECURITY_SERVER_COOKIE_BUFFER_SIZE - 1); k++) {
+ g_variant_builder_add(builder_in, "(y)", (guchar)security_cookie[k]);
+ }
+
+ GVariantBuilder *builder_property = NULL;
+ _create_raw_data_from_plugin_property((void *)(plugin->optional_property), &builder_property);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_SET_AUTH_METHOD,
+ g_variant_new("(" service_adaptor_set_auth_s_type ")",
+ builder_in,
+ builder_property,
+ plugin->service_handle_name,
+ plugin->plugin_uri,
+ app_id ? app_id : "",
+ app_secret ? app_secret : "",
+ user_id ? user_id : "",
+ user_password,
+ service_flag),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &g_error);
+
+ g_variant_builder_unref(builder_in);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[2];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_external_request(const char *service_name,
+ int service_flag,
+ const char *api_uri,
+ unsigned char *input_str,
+ int input_len,
+ unsigned char **output_str,
+ int *output_len,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariantBuilder *builder_in = g_variant_builder_new(G_VARIANT_TYPE(service_adaptor_raw_data_s_type));
+ for (int k = 0; k < input_len; k++) {
+ g_variant_builder_add(builder_in, "(y)", (guchar)input_str[k]);
+ }
+
+ sac_debug_func("input_str_len(%d)", input_len);
+ /* sac_debug_func("input_str(%s)", input_str); */
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_EXTERNAL_REQ_METHOD,
+ g_variant_new("(" private_service_adaptor_external_req_s_type ")",
+ service_name,
+ (int32_t) service_flag,
+ api_uri,
+ builder_in),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &g_error);
+
+ g_variant_builder_unref(builder_in);
+
+ sac_debug("%s API sent", PRIVATE_DBUS_EXTERNAL_REQ_METHOD);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(service_adaptor_raw_data_s_type)))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ FUNC_STEP();
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED;
+ } else {
+
+ int raw_data_len = g_variant_n_children(call_result_struct[0]);
+ unsigned char *raw_data = (unsigned char *) calloc((raw_data_len + 1), sizeof(unsigned char));
+
+ if (NULL != raw_data) {
+ for (int k = 0; k < raw_data_len; k++) {
+ g_variant_get_child(call_result_struct[0], k, "(y)", &(raw_data[k]));
+ }
+ *output_str = raw_data;
+ *output_len = raw_data_len;
+ }
+ sac_debug_func("output_str_len(%d)", raw_data_len);
+ /* sac_debug_func("output_str(%s)", raw_data); */
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+static void *_on_dbus_disappeared_cb(void *data)
+{
+ FUNC_START();
+ __dbus_connection_deinit();
+ service_adaptor_task_h task = _signal_queue_get_task(SIGNAL_SERVICE_ADAPTOR);
+
+ if (NULL == task) {
+ FUNC_STOP();
+ return NULL;
+ }
+
+ struct _internal_service_signal_data_s *signal_context =
+ (struct _internal_service_signal_data_s *)g_malloc0(sizeof(struct _internal_service_signal_data_s));
+
+ if (NULL == signal_context) {
+ FUNC_STOP();
+ return NULL;
+ } else {
+ signal_context->msg = NULL;
+ signal_context->task = NULL;
+ }
+
+ signal_context->code = (int64_t) SERVICE_ADAPTOR_SIGNAL_SHUTDOWN;
+ signal_context->msg = strdup("Service-adaptor DBus interface was vanished");
+ signal_context->task = task;
+
+ GError *worker_error = NULL;
+ g_thread_try_new("service-adaptor-client-signal-emitter", (GThreadFunc) _service_signal_emitter,
+ (void *) signal_context, &worker_error);
+
+ g_clear_error(&worker_error);
+ worker_error = NULL;
+
+ FUNC_END();
+ return NULL;
+}
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: dbus-client-auth.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include <dbus-server.h>
+
+#include "dbus_client.h"
+#include "dbus_client_auth.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "private/service-adaptor-client-auth.h"
+
+#include "util/service_adaptor_client_util.h"
+
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+/** @brief
+ * @return service_adaptor_error_s
+ * @remarks :
+ */
+int _dbus_get_auth_plugin_list(GList **plugin_list,
+ const char *imsi,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_GET_AUTH_PLUGIN_LIST_METHOD,
+ g_variant_new("(s)",
+ imsi),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_plugin_list_type)))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED;
+ } else {
+ gsize list_count = g_variant_n_children(call_result_struct[0]);
+
+ for (gsize i = 0; i < list_count; i++) {
+ GVariant *plugin_info_struct[private_service_adaptor_plugin_s_type_length];
+ GVariant *plugin_info_entry_v = g_variant_get_child_value(call_result_struct[0], i);
+ service_adaptor_plugin_s *info = (service_adaptor_plugin_s *) g_malloc0(sizeof(service_adaptor_plugin_s));
+
+ for (size_t j = 0; j < private_service_adaptor_plugin_s_type_length; j++) {
+ plugin_info_struct[j] = g_variant_get_child_value(plugin_info_entry_v, j);
+ }
+
+ int idx = 0;
+ info->name = ipc_g_variant_dup_string(plugin_info_struct[idx++]);
+ info->login = g_variant_get_boolean(plugin_info_struct[idx++]);
+
+ for (size_t j = 0; j < private_service_adaptor_plugin_s_type_length; j++) {
+ g_variant_unref(plugin_info_struct[j]);
+ }
+
+ *plugin_list = g_list_append(*plugin_list, info);
+ }
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+/** @brief
+ * @return service_adaptor_error_s
+ * @remarks :
+ */
+int _dbus_set_auth(const char *service_name,
+ const char *imsi,
+ const char *plugin_name,
+ const char *app_id,
+ const char *app_secret,
+ unsigned int service_id,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_SET_AUTH_METHOD,
+ g_variant_new("(" private_service_adaptor_set_auth_s_type ")",
+ service_name, imsi, plugin_name, app_id, app_secret, "", "", service_id),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ sac_error("G_IO_ERROR DEBUG (%d)", (int)(g_error->code));
+ if (g_error->code == G_IO_ERROR_TIMED_OUT) {
+ error->code = SERVICE_ADAPTOR_ERROR_NETWORK;
+ ret = SERVICE_ADAPTOR_ERROR_NETWORK;
+ }
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[2];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+ ret = _get_result_code(remote_call_result);
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: dbus-client-contact.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include <dbus-server.h>
+
+#include "dbus_client.h"
+#include "dbus_client_contact.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "private/service-adaptor-client-contact.h"
+
+#include "util/service_adaptor_client_util.h"
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+static void __safe_g_variant_builder_add_contact_string(GVariantBuilder *builder,
+ const char *data)
+{
+ if (NULL == data) {
+ g_variant_builder_add(builder, "s", "");
+ } else {
+ char *_data = g_strconcat(" ", data, NULL);
+ g_variant_builder_add(builder, "s", _data);
+ free(_data);
+ }
+}
+
+static char *__safe_dup_contact_string(char *data)
+{
+ char *str = __safe_add_string(data);
+ char *ret = NULL;
+ if (0 < strlen(str)) {
+ ret = g_strconcat(" ", str, NULL);
+ } else {
+ ret = strdup(str);
+ }
+
+ return ret;
+}
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+GVariant *__create_contact_req_type(const char *service_name,
+ service_adaptor_contact_req_s *contact_req,
+ void *user_data)
+{
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE(private_contact_info_req_list_type));
+
+ for (int i = 0; i < contact_req->cts_len; i++) {
+ g_variant_builder_open(builder, G_VARIANT_TYPE(private_service_adaptor_contact_info_req_s_type));
+ __safe_g_variant_builder_add_string(builder, contact_req->cts[i]->tp);
+ __safe_g_variant_builder_add_string(builder, contact_req->cts[i]->id);
+ __safe_g_variant_builder_add_string(builder, contact_req->cts[i]->pn);
+ __safe_g_variant_builder_add_contact_string(builder, contact_req->cts[i]->nm);
+ __safe_g_variant_builder_add_string(builder, contact_req->cts[i]->cc);
+ g_variant_builder_close(builder);
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_contact_req_s_type ")", __safe_add_string(service_name), contact_req->tt, builder, contact_req->cts_len);
+
+ g_variant_builder_unref(builder);
+
+ return request;
+}
+
+void __get_contact_res_type(GVariant *call_result_struct,
+ service_adaptor_contact_res_s **contact_res,
+ void **server_data)
+{
+ GVariant *res_info_struct[private_service_adaptor_contact_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_contact_res_s_type_length; j++) {
+ res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+ }
+
+ int idx = 0;
+ *contact_res = (service_adaptor_contact_res_s *) calloc(1, sizeof(service_adaptor_contact_res_s));
+
+ if (NULL != (*contact_res)) {
+ (*contact_res)->tt = g_variant_get_int64(res_info_struct[idx++]);
+ sac_info("tt : %lld", (*contact_res)->tt);
+
+ /* cts list */
+ gsize cts_count = g_variant_n_children(res_info_struct[idx]);
+ sac_info("cts count : %d", (int)cts_count);
+
+ if (0 == cts_count) {
+ (*contact_res)->cts_len = 0;
+ sac_info("cts len : %u", (*contact_res)->cts_len);
+
+ for (size_t j = 0; j < private_service_adaptor_contact_res_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+ return;
+ }
+
+ (*contact_res)->cts = (service_adaptor_contact_info_res_s **) calloc(cts_count, sizeof(service_adaptor_contact_info_res_s*));
+
+ if (NULL == ((*contact_res)->cts)) {
+ sac_error("Critical : Memory allocation failed");
+ (*contact_res)->cts_len = 0;
+
+ for (size_t j = 0; j < private_service_adaptor_contact_res_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+ return;
+ }
+ for (gsize i = 0; i < cts_count; i++) {
+ GVariant *cts_info_struct[private_service_adaptor_contact_info_res_s_type_length];
+ GVariant *cts_info_entry_v = g_variant_get_child_value(res_info_struct[idx], i);
+
+ (*contact_res)->cts[i] = (service_adaptor_contact_info_res_s *) calloc(1, sizeof(service_adaptor_contact_info_res_s));
+
+ if (NULL != ((*contact_res)->cts[i])) {
+ for (size_t j = 0; j < private_service_adaptor_contact_info_res_s_type_length; j++) {
+ cts_info_struct[j] = g_variant_get_child_value(cts_info_entry_v, j);
+ }
+
+ int idx2 = 0;
+ (*contact_res)->cts[i]->duid = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+ (*contact_res)->cts[i]->id = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+ (*contact_res)->cts[i]->msisdn = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+ (*contact_res)->cts[i]->ty = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+ (*contact_res)->cts[i]->cc = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+ (*contact_res)->cts[i]->pn = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+ (*contact_res)->cts[i]->nm = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+
+ /* evnt list */
+ gsize evnt_count = g_variant_n_children(cts_info_struct[idx2]);
+ (*contact_res)->cts[i]->evnt = (char **) calloc(evnt_count, sizeof(char *));
+
+ if (NULL != ((*contact_res)->cts[i]->evnt)) {
+ for (gsize k = 0; k < evnt_count; k++) {
+ GVariant *evnt_info_struct;
+ GVariant *evnt_info_entry_v = g_variant_get_child_value(cts_info_struct[idx2], k);
+ evnt_info_struct = g_variant_get_child_value(evnt_info_entry_v, 0);
+
+ (*contact_res)->cts[i]->evnt[k] = ipc_g_variant_dup_string(evnt_info_struct);
+
+ g_variant_unref(evnt_info_struct);
+ }
+ }
+ idx2++;
+ /* evnt list */
+
+ (*contact_res)->cts[i]->evnt_len = g_variant_get_uint32(cts_info_struct[idx2++]);
+
+ /* image list */
+ gsize img_count = g_variant_n_children(cts_info_struct[idx2]);
+ sac_info("img_count : %d", (int)img_count);
+ (*contact_res)->cts[i]->images = (service_adaptor_profile_image_h *) calloc(img_count, sizeof(service_adaptor_profile_image_h));
+
+ if (NULL != ((*contact_res)->cts[i]->images)) {
+ for (gsize k = 0; k < img_count; k++) {
+ (*contact_res)->cts[i]->images[k] = (service_adaptor_profile_image_h) calloc(1, sizeof(struct _service_adaptor_profile_image_s));
+ if (NULL != (*contact_res)->cts[i]->images[k]) {
+ GVariant *img_info_struct[2];
+ GVariant *img_info_entry_v = g_variant_get_child_value(cts_info_struct[idx2], k);
+ img_info_struct[0] = g_variant_get_child_value(img_info_entry_v, 0);
+
+ img_info_struct[1] = g_variant_get_child_value(img_info_entry_v, 1);
+
+ (*contact_res)->cts[i]->images[k]->index = g_variant_get_int32(img_info_struct[0]);
+ sac_info("Test (image index : %d)", (*contact_res)->cts[i]->images[k]->index);
+ char *path = ipc_g_variant_dup_string(img_info_struct[1]);
+ sac_info("Test (path : %s)", path);
+
+ if (NULL != path) {
+ strncpy((*contact_res)->cts[i]->images[k]->path, path, (CONTACT_PROFILE_IMAGE_PATH_LEN - 1));
+ }
+
+ g_variant_unref(img_info_struct[0]);
+ g_variant_unref(img_info_struct[1]);
+ }
+ }
+ }
+ idx2++;
+ /* image list */
+
+ (*contact_res)->cts[i]->images_len = g_variant_get_uint32(cts_info_struct[idx2++]);
+
+
+ /*(*contact_res)->cts[i]->img = ipc_g_variant_dup_string(cts_info_struct[idx2++]);*/
+
+ /* adrs list */
+ gsize adrs_count = g_variant_n_children(cts_info_struct[idx2]);
+ (*contact_res)->cts[i]->adrs = (char **) calloc(adrs_count, sizeof(char *));
+
+ if (NULL != ((*contact_res)->cts[i]->adrs)) {
+ for (gsize k = 0; k < adrs_count; k++) {
+ GVariant *adrs_info_struct;
+ GVariant *adrs_info_entry_v = g_variant_get_child_value(cts_info_struct[idx2], k);
+ adrs_info_struct = g_variant_get_child_value(adrs_info_entry_v, 0);
+
+ (*contact_res)->cts[i]->adrs[k] = ipc_g_variant_dup_string(adrs_info_struct);
+
+ g_variant_unref(adrs_info_struct);
+ }
+ }
+ idx2++;
+ /* adrs list */
+
+ (*contact_res)->cts[i]->adrs_len = g_variant_get_uint32(cts_info_struct[idx2++]);
+
+ /* mail list */
+ gsize mail_count = g_variant_n_children(cts_info_struct[idx2]);
+ (*contact_res)->cts[i]->mail = (char **) calloc(mail_count, sizeof(char *));
+
+ if (NULL != ((*contact_res)->cts[i]->mail)) {
+ for (gsize k = 0; k < mail_count; k++) {
+ GVariant *mail_info_struct;
+ GVariant *mail_info_entry_v = g_variant_get_child_value(cts_info_struct[idx2], k);
+ mail_info_struct = g_variant_get_child_value(mail_info_entry_v, 0);
+
+ (*contact_res)->cts[i]->mail[k] = ipc_g_variant_dup_string(mail_info_struct);
+
+ g_variant_unref(mail_info_struct);
+ }
+ }
+ idx2++;
+ /* mail list */
+
+ (*contact_res)->cts[i]->mail_len = g_variant_get_uint32(cts_info_struct[idx2++]);
+ (*contact_res)->cts[i]->org = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+ (*contact_res)->cts[i]->prsc = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+ (*contact_res)->cts[i]->status = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+ (*contact_res)->cts[i]->sids = g_variant_get_uint32(cts_info_struct[idx2++]);
+ (*contact_res)->cts[i]->profile_type = g_variant_get_int32(cts_info_struct[idx2++]);
+ (*contact_res)->cts[i]->profile_url = ipc_g_variant_dup_string(cts_info_struct[idx2++]);
+
+ for (size_t j = 0; j < private_service_adaptor_contact_info_res_s_type_length; j++) {
+ g_variant_unref(cts_info_struct[j]);
+ }
+ }
+ }
+ idx++;
+ /* cts list */
+
+ (*contact_res)->cts_len = g_variant_get_uint32(res_info_struct[idx++]);
+ }
+
+ for (size_t j = 0; j < private_service_adaptor_contact_res_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+}
+
+GVariant *__create_profile_req_type(const char *service_name,
+ service_adaptor_profile_req_s *profile_req,
+ void *user_data)
+{
+ GVariantBuilder *evnt_builder = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
+
+ for (gsize j = 0; j < profile_req->evnt_len; j++) {
+ __safe_g_variant_builder_add_array_string(evnt_builder, profile_req->evnt[j]);
+ }
+
+ GVariantBuilder *adrs_builder = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
+
+ for (gsize j = 0; j < profile_req->adrs_len; j++) {
+ __safe_g_variant_builder_add_array_string(adrs_builder, profile_req->adrs[j]);
+ }
+
+ GVariantBuilder *mail_builder = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
+
+ for (gsize j = 0; j < profile_req->mail_len; j++) {
+ __safe_g_variant_builder_add_array_string(mail_builder, profile_req->mail[j]);
+ }
+
+ char *converted_nm = __safe_dup_contact_string(profile_req->nm);
+ GVariant *request = g_variant_new("(" private_service_adaptor_profile_req_s_type ")", __safe_add_string(service_name),
+ __safe_add_string(profile_req->cc), __safe_add_string(profile_req->pn), converted_nm,
+ evnt_builder, profile_req->evnt_len,
+ __safe_add_string(profile_req->img),
+ adrs_builder, profile_req->adrs_len, mail_builder, profile_req->mail_len,
+ __safe_add_string(profile_req->org), __safe_add_string(profile_req->prsc), __safe_add_string(profile_req->status));
+ free(converted_nm);
+
+ g_variant_builder_unref(evnt_builder);
+ g_variant_builder_unref(adrs_builder);
+ g_variant_builder_unref(mail_builder);
+
+ return request;
+}
+
+void __get_profile_res_type(GVariant *call_result_struct,
+ service_adaptor_profile_res_s **profile_res,
+ void **server_data)
+{
+ GVariant *res_info_struct[private_service_adaptor_profile_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_profile_res_s_type_length; j++) {
+ res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+ }
+
+ int idx = 0;
+ *profile_res = (service_adaptor_profile_res_s *) calloc(1, sizeof(service_adaptor_profile_res_s));
+ if (NULL != *profile_res) {
+ (*profile_res)->nm = ipc_g_variant_dup_string(res_info_struct[idx++]);
+ (*profile_res)->img = ipc_g_variant_dup_string(res_info_struct[idx++]);
+ (*profile_res)->prsc = ipc_g_variant_dup_string(res_info_struct[idx++]);
+ (*profile_res)->status = ipc_g_variant_dup_string(res_info_struct[idx++]);
+ }
+
+ for (size_t j = 0; j < private_service_adaptor_profile_res_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+}
+
+GVariant *__create_del_me_profile_req_type(const char *service_name,
+ void *user_data)
+{
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_essential_s_type ")", __safe_add_string(service_name));
+
+
+ return request;
+}
+
+
+GVariant *__create_file_path_req_type(const char *service_name,
+ service_adaptor_profile_image_h *images,
+ unsigned int images_len,
+ void *user_data)
+{
+
+
+ if (NULL == images) {
+ images_len = 0;
+ }
+
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(iis)"));
+
+ for (int j = 0; j < images_len; j++) {
+ sac_debug_func("[DBG] Set me profile image meta Params %dth [DBG]", j);
+ sac_debug_func("type (%d) index (%d) path (%s)", images[j]->type, images[j]->index, images[j]->path);
+ g_variant_builder_add(builder, "(iis)", (int32_t)(images[j]->type), (int32_t)images[j]->index, __safe_add_string(images[j]->path));
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_contact_profile_image_req_s_type ")", __safe_add_string(service_name), builder, images_len);
+
+ g_variant_builder_unref(builder);
+
+ return request;
+}
+
+void __get_failed_image_meta_res_type(GVariant *call_result_struct,
+ service_adaptor_profile_image_h **images,
+ unsigned int *images_len)
+{
+ GVariant *res_info_struct[private_service_adaptor_contact_profile_image_req_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_contact_profile_image_req_s_type_length; j++) {
+ res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+ }
+ int idx = 0;
+ idx++; /* skip first value */
+ gsize list_count = g_variant_n_children(res_info_struct[idx]);
+
+ if (0 < list_count) {
+ *images = (service_adaptor_profile_image_h *) calloc(list_count, sizeof(service_adaptor_profile_image_h));
+ if (NULL == (*images)) {
+ sac_error("Critical : Memory allocation failed!!");
+ } else {
+ for (int i = 0; i < list_count; i++) {
+ (*images)[i] = (service_adaptor_profile_image_h)calloc(1, sizeof(struct _service_adaptor_profile_image_s));
+ if (NULL == ((*images)[i])) {
+ sac_error("Critical : Memory allocation failed!!");
+ } else {
+ GVariant *path_info_struct[3] = {NULL, };
+ GVariant *path_info_entry_v = g_variant_get_child_value(res_info_struct[idx], i);
+ path_info_struct[0] = g_variant_get_child_value(path_info_entry_v, 0);
+ path_info_struct[1] = g_variant_get_child_value(path_info_entry_v, 1);
+ path_info_struct[2] = g_variant_get_child_value(path_info_entry_v, 2);
+
+ ((*images)[i])->type = g_variant_get_int32(path_info_struct[0]);
+ ((*images)[i])->index = g_variant_get_int32(path_info_struct[1]);
+ char *path = ipc_g_variant_dup_string(path_info_struct[2]);;
+ snprintf(((*images)[i])->path, 2048, "%s", (path ? path : ""));
+ free(path);
+
+ g_variant_unref(path_info_struct[0]);
+ g_variant_unref(path_info_struct[1]);
+ g_variant_unref(path_info_struct[2]);
+ }
+ }
+ }
+ }
+ idx++;
+
+ *images_len = g_variant_get_uint32(res_info_struct[idx++]);
+
+ for (size_t j = 0; j < private_service_adaptor_contact_profile_image_req_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+}
+
+GVariant *__create_privacy_req_type(const char *service_name,
+ service_adaptor_privacy_req_s *privacy_req,
+ void *user_data)
+{
+ GVariantBuilder *cts_builder = g_variant_builder_new(G_VARIANT_TYPE("a(ss)"));
+
+ for (gsize j = 0; j < privacy_req->cts_len; j++) {
+ g_variant_builder_open(cts_builder, G_VARIANT_TYPE("(ss)"));
+ __safe_g_variant_builder_add_string(cts_builder, privacy_req->cts[j]->cc);
+ __safe_g_variant_builder_add_string(cts_builder, privacy_req->cts[j]->pn);
+ g_variant_builder_close(cts_builder);
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_privacy_req_s_type ")", __safe_add_string(service_name), privacy_req->lvl, cts_builder, privacy_req->cts_len);
+
+ g_variant_builder_unref(cts_builder);
+
+ return request;
+}
+
+void __get_privacy_res_type(GVariant *call_result_struct,
+ service_adaptor_privacy_res_s **privacy_res,
+ void **server_data)
+{
+ GVariant *res_info_struct[private_service_adaptor_privacy_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_privacy_res_s_type_length; j++) {
+ res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+ }
+
+ int idx = 0;
+ *privacy_res = (service_adaptor_privacy_res_s *) calloc(1, sizeof(service_adaptor_privacy_res_s));
+ if (NULL != *privacy_res) {
+ (*privacy_res)->lvl = g_variant_get_uint32(res_info_struct[idx++]);
+ (*privacy_res)->prscon = g_variant_get_uint32(res_info_struct[idx++]);
+ }
+
+ for (size_t j = 0; j < private_service_adaptor_privacy_res_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+}
+
+void __get_profile_type_res_type(GVariant *call_result_struct,
+ char **url)
+{
+ GVariant *res_info_struct = NULL;
+
+ res_info_struct = g_variant_get_child_value(call_result_struct, 0);
+
+ *url = ipc_g_variant_dup_string(res_info_struct);
+
+ g_variant_unref(res_info_struct);
+}
+
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+/** @brief
+ * @return service_adaptor_error_s
+ * @remarks :
+ */
+int _dbus_set_new_contact_list(const char *service_name,
+ service_adaptor_contact_req_s *contact_req,
+ void *user_data,
+ service_adaptor_contact_res_s **contact_res,
+ void **server_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = __create_contact_req_type(service_name, contact_req, user_data);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_SET_NEW_CONTACT_LIST_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_contact_res_s_type)))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = _get_result_code(remote_call_result);
+ } else {
+ if (NULL != contact_res) {
+ __get_contact_res_type(call_result_struct[0], contact_res, server_data);
+ }
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_set_contact_list(const char *service_name,
+ service_adaptor_contact_req_s *contact_req,
+ void *user_data,
+ service_adaptor_contact_res_s **contact_res,
+ void **server_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = __create_contact_req_type(service_name, contact_req, user_data);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_SET_CONTACT_LIST_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_contact_res_s_type)))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = _get_result_code(remote_call_result);
+ } else {
+ if (NULL != contact_res) {
+ __get_contact_res_type(call_result_struct[0], contact_res, server_data);
+ }
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_get_contact_list(const char *service_name,
+ service_adaptor_contact_res_s **contact_res,
+ void **server_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_essential_s_type ")", __safe_add_string(service_name));
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_GET_CONTACT_LIST_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_contact_res_s_type)))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = _get_result_code(remote_call_result);
+ } else {
+ if (NULL != contact_res) {
+ __get_contact_res_type(call_result_struct[0], contact_res, server_data);
+ }
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_get_contact_infos_polling(const char *service_name,
+ service_adaptor_contact_req_s *contact_req,
+ void *user_data,
+ service_adaptor_contact_res_s **contact_res,
+ void **server_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = __create_contact_req_type(service_name, contact_req, user_data);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_GET_CONTACT_INFOS_POLLING_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_contact_res_s_type)))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = _get_result_code(remote_call_result);
+ } else {
+ if (NULL != contact_res) {
+ __get_contact_res_type(call_result_struct[0], contact_res, server_data);
+ }
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_set_me_profile_with_push(const char *service_name,
+ service_adaptor_profile_req_s *profile_req,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = __create_profile_req_type(service_name, profile_req, user_data);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_SET_ME_PROFILE_WITH_PUSH_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[2];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+ ret = _get_result_code(remote_call_result);
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_get_profile(const char *service_name,
+ service_adaptor_profile_req_s *profile_req,
+ void *user_data,
+ service_adaptor_profile_res_s **profile_res,
+ void **server_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = __create_profile_req_type(service_name, profile_req, user_data);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_GET_PROFILE_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_profile_res_s_type)))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = _get_result_code(remote_call_result);
+ } else {
+ if (NULL != profile_res) {
+ __get_profile_res_type(call_result_struct[0], profile_res, server_data);
+ }
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_set_profile_image_meta_with_push(const char *service_name,
+ service_adaptor_profile_image_h *images,
+ unsigned int images_len,
+ void *user_data,
+ service_adaptor_profile_image_h **failed_images,
+ unsigned int *failed_images_len,
+ void **server_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = __create_file_path_req_type(service_name, images, images_len, user_data);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_SET_PROFILE_IMAGE_META_WITH_PUSH_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_contact_profile_image_req_s_type)))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = _get_result_code(remote_call_result);
+ if ((NULL != failed_images) && (NULL != failed_images_len)) {
+ __get_failed_image_meta_res_type(call_result_struct[0], failed_images, failed_images_len);
+ }
+ } else {
+ /* __get_failed_image_meta_res_type(call_result_struct[0], failed_images, failed_images_len); */
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_delete_me_profile_image_meta_with_push(const char *service_name,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = __create_del_me_profile_req_type(service_name, user_data);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_DEL_ME_PROFILE_IMAGE_META_WITH_PUSH_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[2];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+ ret = _get_result_code(remote_call_result);
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_set_me_profile_privacy(const char *service_name,
+ service_adaptor_privacy_req_s *privacy_req,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = __create_privacy_req_type(service_name, privacy_req, user_data);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_SET_ME_PROFILE_PRIVACY_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[2];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+ ret = _get_result_code(remote_call_result);
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_get_me_profile_privacy(const char *service_name,
+ service_adaptor_privacy_res_s **privacy_res,
+ void **server_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_essential_s_type ")", __safe_add_string(service_name));
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_GET_PROFILE_PRIVACY_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_privacy_res_s_type)))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = _get_result_code(remote_call_result);
+ } else {
+ if (NULL != privacy_res) {
+ __get_privacy_res_type(call_result_struct[0], privacy_res, server_data);
+ }
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_set_me_presence_with_push(const char *service_name,
+ service_adaptor_presence_req_s *presence_req,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_presence_req_s_type ")",
+ __safe_add_string(service_name), __safe_add_string(presence_req->prsc),
+ __safe_add_string(presence_req->status), presence_req->prscon);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_SET_ME_PRESENCE_WITH_PUSH_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[2];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+ ret = _get_result_code(remote_call_result);
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_set_me_presence_on_off_with_push(const char *service_name,
+ service_adaptor_presence_req_s *presence_req,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_presence_req_s_type ")", __safe_add_string(service_name), __safe_add_string(presence_req->prsc), __safe_add_string(presence_req->status), presence_req->prscon);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_SET_ME_PRESENCE_ON_OFF_WITH_PUSH_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[2];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+ ret = _get_result_code(remote_call_result);
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+
+int _dbus_set_me_profile_type(const char *service_name,
+ int type,
+ char **url,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_set_me_profile_type_req_s_type ")", __safe_add_string(service_name), type);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_SET_ME_PROFILE_TYPE_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_essential_s_type)))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = _get_result_code(remote_call_result);
+ } else {
+ __get_profile_type_res_type(call_result_struct[0], url);
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: dbus_client_layer.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include "dbus_client_layer.h"
+#include "dbus_client.h"
+
+int _dbus_client_layer_init()
+{
+ int ret = _dbus_client_service_adaptor_init();
+
+ if (0 != ret) {
+ _dbus_client_service_adaptor_deinit();
+ return ret;
+ }
+
+ return 0;
+}
+
+void _dbus_client_layer_deinit()
+{
+ _dbus_client_service_adaptor_deinit();
+}
+
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: dbus-client-message.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include <dbus-server.h>
+
+#include "dbus_client.h"
+#include "dbus_client_message.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "private/service-adaptor-client-message.h"
+
+#include "util/service_adaptor_client_util.h"
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+#define __FREE_ERROR_CODE(err) do { if (err) free(err->msg); free(err); (err) = NULL; } while (0)
+
+#define __FREE_POINTER_ARRAY(__arr, __len) do { \
+ if ((NULL != (__arr)) && (0 < (__len))) { \
+ for (int __idx = 0; __idx < (__len); __idx++) { \
+ __SAFE_FREE(__arr[__idx]); \
+ } \
+ __SAFE_FREE((__arr)); \
+ } } while (0)
+
+#define __ipc_get_simple_error_code() do { \
+ GVariant *call_result_struct[2]; \
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0); \
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1); \
+\
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]); \
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) { \
+ error->code = remote_call_result; \
+ error->msg = ipc_g_variant_dup_string(call_result_struct[1]); \
+ ret = _get_result_code(remote_call_result); \
+ } \
+ g_variant_unref(call_result_struct[0]); \
+ g_variant_unref(call_result_struct[1]); \
+ } while (0)
+
+void __free_wrong_receiver_s(service_adaptor_wrong_receiver_s *wrong_receiver)
+{
+ __SAFE_FREE(wrong_receiver->invalid_receivers);
+ __SAFE_FREE(wrong_receiver->interrupted_receivers);
+ __SAFE_FREE(wrong_receiver->disabled_receivers);
+ __SAFE_FREE(wrong_receiver->existing_chatmembers);
+ __FREE_POINTER_ARRAY(wrong_receiver->did_violation_users, wrong_receiver->did_violation_users_len);
+ __SAFE_FREE(wrong_receiver->invitation_denieds);
+}
+
+void __free_ordered_chat_member_s_list(service_adaptor_ordered_chat_member_s **ordered_chat_members, unsigned int ordered_chat_members_len)
+{
+ if ((NULL != ordered_chat_members) && (0 < ordered_chat_members_len)) {
+ for (int i = 0; i < ordered_chat_members_len; i++) {
+ if (NULL != ordered_chat_members[i]) {
+ __SAFE_FREE(ordered_chat_members[i]->name);
+ __SAFE_FREE(ordered_chat_members[i]);
+ }
+ }
+ }
+}
+void __free_inbox_message_s_list(service_adaptor_inbox_message_s **inbox_messages, unsigned int inbox_messages_len)
+{
+ if ((NULL != inbox_messages) && (0 < inbox_messages_len)) {
+ for (int i = 0; i < inbox_messages_len; i++) {
+ if (NULL != inbox_messages[i]) {
+ __SAFE_FREE(inbox_messages[i]->chat_msg);
+ __SAFE_FREE(inbox_messages[i]);
+ }
+ }
+ }
+}
+void __get_create_chatroom_res_type(GVariant *parameters,
+ int64_t *request_id,
+ int64_t *chatroom_id,
+ int *default_message_ttl,
+ service_adaptor_wrong_receiver_s *wrong_receiver)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[private_service_adaptor_create_chatroom_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_create_chatroom_res_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ *request_id = g_variant_get_int64(res_struct[idx++]);
+ *chatroom_id = g_variant_get_int64(res_struct[idx++]);
+ *default_message_ttl = g_variant_get_int32(res_struct[idx++]);
+
+ GVariant *res_info_struct[private_service_adaptor_wrong_receiver_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_wrong_receiver_s_type_length; j++) {
+ res_info_struct[j] = g_variant_get_child_value(res_struct[idx], j);
+ }
+
+ int idx2 = 0;
+
+ gsize invalid_count = g_variant_n_children(res_info_struct[idx2]);
+ wrong_receiver->invalid_receivers = (int64_t *) calloc(invalid_count, sizeof(int64_t));
+
+ if (NULL != wrong_receiver->invalid_receivers) {
+ for (gsize i = 0; i < invalid_count; i++) {
+ GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+ GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+ wrong_receiver->invalid_receivers[i] = g_variant_get_int64(info_struct);
+
+ g_variant_unref(info_struct);
+ }
+ idx2++;
+ wrong_receiver->invalid_receivers_len = g_variant_get_uint32(res_info_struct[idx2++]);
+ } else {
+ wrong_receiver->invalid_receivers_len = 0U;
+ idx2++;
+ idx2++;
+ }
+
+ gsize interrupted_count = g_variant_n_children(res_info_struct[idx2]);
+ wrong_receiver->interrupted_receivers = (int64_t *) calloc(interrupted_count, sizeof(int64_t));
+
+ if (NULL != wrong_receiver->interrupted_receivers) {
+ for (gsize i = 0; i < interrupted_count; i++) {
+ GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+ GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+ wrong_receiver->interrupted_receivers[i] = g_variant_get_int64(info_struct);
+
+ g_variant_unref(info_struct);
+ }
+ idx2++;
+ wrong_receiver->interrupted_receivers_len = g_variant_get_uint32(res_info_struct[idx2++]);
+ } else {
+ wrong_receiver->interrupted_receivers_len = 0U;
+ idx2++;
+ idx2++;
+ }
+
+ gsize disabled_count = g_variant_n_children(res_info_struct[idx2]);
+ wrong_receiver->disabled_receivers = (int64_t *) calloc(disabled_count, sizeof(int64_t));
+
+ if (NULL != wrong_receiver->disabled_receivers) {
+ for (gsize i = 0; i < disabled_count; i++) {
+ GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+ GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+ wrong_receiver->disabled_receivers[i] = g_variant_get_int64(info_struct);
+
+ g_variant_unref(info_struct);
+ }
+ idx2++;
+ wrong_receiver->disabled_receivers_len = g_variant_get_uint32(res_info_struct[idx2++]);
+ } else {
+ wrong_receiver->disabled_receivers_len = 0U;
+ idx2++;
+ idx2++;
+ }
+
+ gsize existing_count = g_variant_n_children(res_info_struct[idx2]);
+ wrong_receiver->existing_chatmembers = (int64_t *) calloc(existing_count, sizeof(int64_t));
+
+ if (NULL != wrong_receiver->existing_chatmembers) {
+ for (gsize i = 0; i < existing_count; i++) {
+ GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+ GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+ wrong_receiver->existing_chatmembers[i] = g_variant_get_int64(info_struct);
+
+ g_variant_unref(info_struct);
+ }
+ idx2++;
+ wrong_receiver->existing_chatmembers_len = g_variant_get_uint32(res_info_struct[idx2++]);
+ } else {
+ wrong_receiver->existing_chatmembers_len = 0U;
+ idx2++;
+ idx2++;
+ }
+
+ gsize did_violation_users_count = g_variant_n_children(res_info_struct[idx2]);
+ wrong_receiver->did_violation_users = (service_adaptor_did_violation_users_s **) calloc(did_violation_users_count, sizeof(service_adaptor_did_violation_users_s *));
+
+ if (NULL != wrong_receiver->did_violation_users) {
+ for (gsize i = 0; i < did_violation_users_count; i++) {
+ GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+ GVariant *info_struct[private_service_adaptor_did_violation_users_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_did_violation_users_s_type_length; j++) {
+ info_struct[j] = g_variant_get_child_value(info_entry_v, j);
+ }
+
+ int idx3 = 0;
+ wrong_receiver->did_violation_users[i] = (service_adaptor_did_violation_users_s *) calloc(1, sizeof(service_adaptor_did_violation_users_s));
+ if (NULL != wrong_receiver->did_violation_users[i]) {
+ wrong_receiver->did_violation_users[i]->usera = g_variant_get_int64(info_struct[idx3++]);
+ wrong_receiver->did_violation_users[i]->userb = g_variant_get_int64(info_struct[idx3++]);
+ }
+
+ for (size_t j = 0; j < private_service_adaptor_did_violation_users_s_type_length; j++) {
+ g_variant_unref(info_struct[j]);
+ }
+ }
+ idx2++;
+ wrong_receiver->did_violation_users_len = g_variant_get_uint32(res_info_struct[idx2++]);
+ } else {
+ wrong_receiver->did_violation_users_len = 0U;
+ idx2++;
+ idx2++;
+ }
+
+ gsize denieds_count = g_variant_n_children(res_info_struct[idx2]);
+ wrong_receiver->invitation_denieds = (int64_t *) calloc(denieds_count, sizeof(int64_t));
+
+ if (NULL != wrong_receiver->invitation_denieds) {
+ for (gsize i = 0; i < denieds_count; i++) {
+ GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+ GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+ wrong_receiver->invitation_denieds[i] = g_variant_get_int64(info_struct);
+
+ g_variant_unref(info_struct);
+ }
+ idx2++;
+ wrong_receiver->invitation_denieds_len = g_variant_get_uint32(res_info_struct[idx2++]);
+ } else {
+ wrong_receiver->invitation_denieds_len = 0U;
+ idx2++;
+ idx2++;
+ }
+
+ for (size_t j = 0; j < private_service_adaptor_wrong_receiver_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+
+ for (size_t j = 0; j < private_service_adaptor_create_chatroom_res_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+
+void __get_change_chatroom_meta_res_type(GVariant *parameters,
+ int64_t *request_id,
+ int64_t *chatroom_id)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[private_service_adaptor_change_chatroom_meta_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_change_chatroom_meta_res_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ *request_id = g_variant_get_int64(res_struct[idx++]);
+ *chatroom_id = g_variant_get_int64(res_struct[idx++]);
+
+ for (size_t j = 0; j < private_service_adaptor_change_chatroom_meta_res_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+
+void __get_chat_res_type(GVariant *parameters,
+ int64_t *request_id,
+ int64_t *chatroom_id,
+ service_adaptor_processed_msg_s ***processed_msgs,
+ unsigned int *processed_msgs_len)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[private_service_adaptor_chat_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_chat_res_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ *request_id = g_variant_get_int64(res_struct[idx++]);
+ *chatroom_id = g_variant_get_int64(res_struct[idx++]);
+
+ gsize list_count = g_variant_n_children(res_struct[idx]);
+
+ *processed_msgs = (service_adaptor_processed_msg_s **) calloc(list_count, sizeof(service_adaptor_processed_msg_s *));
+
+ if (NULL != *processed_msgs) {
+ for (gsize i = 0; i < list_count; i++) {
+ GVariant *info_struct[private_service_adaptor_processed_msg_s_type_length];
+ GVariant *info_entry_v = g_variant_get_child_value(res_struct[idx], i);
+
+ (*processed_msgs)[i] = (service_adaptor_processed_msg_s *) calloc(1, sizeof(service_adaptor_processed_msg_s));
+
+ if (NULL != (*processed_msgs)[i]) {
+ for (size_t j = 0; j < private_service_adaptor_processed_msg_s_type_length; j++) {
+ info_struct[j] = g_variant_get_child_value(info_entry_v, j);
+ }
+
+ int idx2 = 0;
+ (*processed_msgs)[i]->msg_id = g_variant_get_int64(info_struct[idx2++]);
+ (*processed_msgs)[i]->sent_time = g_variant_get_int64(info_struct[idx2++]);
+
+ for (size_t j = 0; j < private_service_adaptor_processed_msg_s_type_length; j++) {
+ g_variant_unref(info_struct[j]);
+ }
+ }
+ }
+ idx++;
+ *processed_msgs_len = g_variant_get_uint32(res_struct[idx++]);
+ } else {
+ *processed_msgs_len = 0U;
+ idx++;
+ idx++;
+ }
+
+ for (size_t j = 0; j < private_service_adaptor_chat_res_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+
+void __get_allow_chat_res_type(GVariant *parameters,
+ int64_t *request_id,
+ int64_t *chatroom_id,
+ service_adaptor_delivery_ack_s ***delivery_acks,
+ unsigned int *delivery_acks_len,
+ unsigned long long *last_delivery_acks_timestamp,
+ service_adaptor_read_ack_s ***read_acks,
+ unsigned int *read_acks_len,
+ unsigned long long *last_read_acks_timestamp,
+ service_adaptor_ordered_chat_member_s ***ordered_chat_members,
+ unsigned int *ordered_chat_members_len,
+ char **chatroom_title,
+ int *default_message_ttl)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[private_service_adaptor_allow_chat_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_allow_chat_res_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ *request_id = g_variant_get_int64(res_struct[idx++]);
+ *chatroom_id = g_variant_get_int64(res_struct[idx++]);
+
+ gsize delivery_acks_count = g_variant_n_children(res_struct[idx]);
+ *delivery_acks = (service_adaptor_delivery_ack_s **) calloc(delivery_acks_count, sizeof(service_adaptor_delivery_ack_s *));
+
+ if (NULL != *delivery_acks) {
+ for (gsize i = 0; i < delivery_acks_count; i++) {
+ GVariant *info_struct[private_service_adaptor_delivery_ack_s_type_length];
+ GVariant *info_entry_v = g_variant_get_child_value(res_struct[idx], i);
+
+ (*delivery_acks)[i] = (service_adaptor_delivery_ack_s *) calloc(1, sizeof(service_adaptor_delivery_ack_s));
+
+ if (NULL == (*delivery_acks)[i]) {
+ continue;
+ }
+
+ for (size_t j = 0; j < private_service_adaptor_delivery_ack_s_type_length; j++) {
+ info_struct[j] = g_variant_get_child_value(info_entry_v, j);
+ }
+
+ int idx2 = 0;
+ (*delivery_acks)[i]->user_id = g_variant_get_int64(info_struct[idx2++]);
+ (*delivery_acks)[i]->msg_id = g_variant_get_int64(info_struct[idx2++]);
+ (*delivery_acks)[i]->timestamp = g_variant_get_uint64(info_struct[idx2++]);
+
+ for (size_t j = 0; j < private_service_adaptor_delivery_ack_s_type_length; j++) {
+ g_variant_unref(info_struct[j]);
+ }
+ }
+ idx++;
+
+ *delivery_acks_len = g_variant_get_uint32(res_struct[idx++]);
+ } else {
+ *delivery_acks_len = 0U;
+ idx++;
+ idx++;
+ }
+ *last_delivery_acks_timestamp = g_variant_get_uint64(res_struct[idx++]);
+
+ gsize read_acks_count = g_variant_n_children(res_struct[idx]);
+ *read_acks = (service_adaptor_read_ack_s **) calloc(read_acks_count, sizeof(service_adaptor_read_ack_s *));
+
+ if (NULL != *read_acks) {
+ for (gsize i = 0; i < read_acks_count; i++) {
+ GVariant *info_struct[private_service_adaptor_read_ack_s_type_length];
+ GVariant *info_entry_v = g_variant_get_child_value(res_struct[idx], i);
+
+ (*read_acks)[i] = (service_adaptor_read_ack_s *) calloc(1, sizeof(service_adaptor_read_ack_s));
+ if (NULL == (*read_acks)[i]) {
+ continue;
+ }
+
+ for (size_t j = 0; j < private_service_adaptor_read_ack_s_type_length; j++) {
+ info_struct[j] = g_variant_get_child_value(info_entry_v, j);
+ }
+
+ int idx2 = 0;
+ (*read_acks)[i]->user_id = g_variant_get_int64(info_struct[idx2++]);
+ (*read_acks)[i]->msg_id = g_variant_get_int64(info_struct[idx2++]);
+ (*read_acks)[i]->timestamp = g_variant_get_uint64(info_struct[idx2++]);
+
+ for (size_t j = 0; j < private_service_adaptor_read_ack_s_type_length; j++) {
+ g_variant_unref(info_struct[j]);
+ }
+ }
+ idx++;
+
+ *read_acks_len = g_variant_get_uint32(res_struct[idx++]);
+ } else {
+ *read_acks_len = 0U;
+ }
+ *last_read_acks_timestamp = g_variant_get_uint64(res_struct[idx++]);
+
+ gsize ordered_chat_member_count = g_variant_n_children(res_struct[idx]);
+ *ordered_chat_members = (service_adaptor_ordered_chat_member_s **) calloc(ordered_chat_member_count, sizeof(service_adaptor_ordered_chat_member_s *));
+
+ if (NULL != *ordered_chat_members) {
+ for (gsize i = 0; i < ordered_chat_member_count; i++) {
+ GVariant *info_struct[private_service_adaptor_ordered_chat_member_s_type_length];
+ GVariant *info_entry_v = g_variant_get_child_value(res_struct[idx], i);
+
+ (*ordered_chat_members)[i] = (service_adaptor_ordered_chat_member_s *) calloc(1, sizeof(service_adaptor_ordered_chat_member_s));
+
+ if (NULL != (*ordered_chat_members)[i]) {
+ for (size_t j = 0; j < private_service_adaptor_ordered_chat_member_s_type_length; j++) {
+ info_struct[j] = g_variant_get_child_value(info_entry_v, j);
+ }
+
+ int idx2 = 0;
+ (*ordered_chat_members)[i]->user_id = g_variant_get_int64(info_struct[idx2++]);
+ (*ordered_chat_members)[i]->available = g_variant_get_boolean(info_struct[idx2++]);
+ (*ordered_chat_members)[i]->name = ipc_g_variant_dup_string(info_struct[idx2++]);
+
+ for (size_t j = 0; j < private_service_adaptor_ordered_chat_member_s_type_length; j++) {
+ g_variant_unref(info_struct[j]);
+ }
+ }
+ }
+ idx++;
+ *ordered_chat_members_len = g_variant_get_uint32(res_struct[idx++]);
+ } else {
+ *ordered_chat_members_len = 0U;
+ idx++;
+ idx++;
+ }
+ *chatroom_title = ipc_g_variant_dup_string(res_struct[idx++]);
+ *default_message_ttl = g_variant_get_int32(res_struct[idx++]);
+
+ for (size_t j = 0; j < private_service_adaptor_allow_chat_res_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+
+void __get_all_unread_message_res_type(GVariant *parameters,
+ int64_t *request_id)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[private_service_adaptor_all_unread_message_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_all_unread_message_res_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ *request_id = g_variant_get_int64(res_struct[idx++]);
+
+ for (size_t j = 0; j < private_service_adaptor_all_unread_message_res_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+void __get_channel_disconnected_res_type(GVariant *parameters,
+ char **service_name)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[private_service_adaptor_channel_disconnected_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_channel_disconnected_res_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ *service_name = ipc_g_variant_dup_string(res_struct[idx++]);
+
+ for (size_t j = 0; j < private_service_adaptor_channel_disconnected_res_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+
+
+void __get_forward_online_message_req_type(GVariant *parameters,
+ int64_t *request_id,
+ int64_t *chatroom_id,
+ int *chat_type,
+ service_adaptor_inbox_message_s *inbox_msg,
+ bool *skip_reply)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[private_service_adaptor_forward_online_message_req_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_forward_online_message_req_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ *request_id = g_variant_get_int64(res_struct[idx++]);
+ *chatroom_id = g_variant_get_int64(res_struct[idx++]);
+ *chat_type = g_variant_get_int32(res_struct[idx++]);
+
+ GVariant *res_info_struct[private_service_adaptor_inbox_message_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_inbox_message_s_type_length; j++) {
+ res_info_struct[j] = g_variant_get_child_value(res_struct[idx], j);
+ }
+
+ int idx2 = 0;
+
+ inbox_msg->msg_id = g_variant_get_int64(res_info_struct[idx2++]);
+ inbox_msg->msg_type = g_variant_get_int32(res_info_struct[idx2++]);
+ inbox_msg->sender = g_variant_get_int64(res_info_struct[idx2++]);
+ inbox_msg->receiver = g_variant_get_int64(res_info_struct[idx2++]);
+ inbox_msg->sent_time = g_variant_get_int64(res_info_struct[idx2++]);
+ inbox_msg->chat_msg = ipc_g_variant_dup_string(res_info_struct[idx2++]);
+ inbox_msg->chatroom_id = g_variant_get_int64(res_info_struct[idx2++]);
+ inbox_msg->chat_type = g_variant_get_int32(res_info_struct[idx2++]);
+ inbox_msg->message_ttl = g_variant_get_int32(res_info_struct[idx2++]);
+
+ for (size_t j = 0; j < private_service_adaptor_inbox_message_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+ idx++;
+
+ *skip_reply = g_variant_get_boolean(res_struct[idx++]);
+
+ for (size_t j = 0; j < private_service_adaptor_forward_online_message_req_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+
+void __get_forward_unread_message_req_type(GVariant *parameters,
+ int64_t *request_id,
+ service_adaptor_inbox_message_s ***inbox_msgs,
+ unsigned int *inbox_msgs_len,
+ char **next_pagination_key)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[private_service_adaptor_forward_unread_message_req_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_forward_unread_message_req_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ *request_id = g_variant_get_int64(res_struct[idx++]);
+
+ gsize list_count = g_variant_n_children(res_struct[idx]);
+
+ *inbox_msgs = (service_adaptor_inbox_message_s **) calloc(list_count, sizeof(service_adaptor_inbox_message_s *));
+
+ if (NULL != *inbox_msgs) {
+ for (gsize i = 0; i < list_count; i++) {
+ GVariant *info_struct[private_service_adaptor_inbox_message_s_type_length];
+ GVariant *info_entry_v = g_variant_get_child_value(res_struct[idx], i);
+
+ (*inbox_msgs)[i] = (service_adaptor_inbox_message_s *) calloc(1, sizeof(service_adaptor_inbox_message_s));
+
+ if (NULL != (*inbox_msgs)[i]) {
+ for (size_t j = 0; j < private_service_adaptor_inbox_message_s_type_length; j++) {
+ info_struct[j] = g_variant_get_child_value(info_entry_v, j);
+ }
+
+ int idx2 = 0;
+ (*inbox_msgs)[i]->msg_id = g_variant_get_int64(info_struct[idx2++]);
+ (*inbox_msgs)[i]->msg_type = g_variant_get_int32(info_struct[idx2++]);
+ (*inbox_msgs)[i]->sender = g_variant_get_int64(info_struct[idx2++]);
+ (*inbox_msgs)[i]->receiver = g_variant_get_int64(info_struct[idx2++]);
+ (*inbox_msgs)[i]->sent_time = g_variant_get_int64(info_struct[idx2++]);
+ (*inbox_msgs)[i]->chat_msg = ipc_g_variant_dup_string(info_struct[idx2++]);
+ (*inbox_msgs)[i]->chatroom_id = g_variant_get_int64(info_struct[idx2++]);
+ (*inbox_msgs)[i]->chat_type = g_variant_get_int32(info_struct[idx2++]);
+ (*inbox_msgs)[i]->message_ttl = g_variant_get_int32(info_struct[idx2++]);
+
+ for (size_t j = 0; j < private_service_adaptor_inbox_message_s_type_length; j++) {
+ g_variant_unref(info_struct[j]);
+ }
+ }
+ }
+ idx++;
+ *inbox_msgs_len = g_variant_get_uint32(res_struct[idx++]);
+ } else {
+ *inbox_msgs_len = 0U;
+ idx++;
+ idx++;
+ }
+ *next_pagination_key = ipc_g_variant_dup_string(res_struct[idx++]);
+
+ for (size_t j = 0; j < private_service_adaptor_forward_unread_message_req_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+
+void __get_read_message_res_type(GVariant *parameters,
+ int64_t *request_id,
+ int64_t *chatroom_id)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[private_service_adaptor_read_message_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_read_message_res_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ *request_id = g_variant_get_int64(res_struct[idx++]);
+ *chatroom_id = g_variant_get_int64(res_struct[idx++]);
+
+ for (size_t j = 0; j < private_service_adaptor_read_message_res_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+
+void __get_invite_chat_res_type(GVariant *parameters,
+ int64_t *request_id,
+ int64_t *chatroom_id,
+ int64_t *sent_time,
+ service_adaptor_wrong_receiver_s *wrong_receiver)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[private_service_adaptor_invite_chat_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_invite_chat_res_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ *request_id = g_variant_get_int64(res_struct[idx++]);
+ *chatroom_id = g_variant_get_int64(res_struct[idx++]);
+ *sent_time = g_variant_get_int64(res_struct[idx++]);
+
+ GVariant *res_info_struct[private_service_adaptor_wrong_receiver_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_wrong_receiver_s_type_length; j++) {
+ res_info_struct[j] = g_variant_get_child_value(res_struct[idx], j);
+ }
+
+ int idx2 = 0;
+
+ gsize invalid_count = g_variant_n_children(res_info_struct[idx2]);
+ wrong_receiver->invalid_receivers = (int64_t *) calloc(invalid_count, sizeof(int64_t));
+
+ if (NULL != wrong_receiver->invalid_receivers) {
+ for (gsize i = 0; i < invalid_count; i++) {
+ GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+ GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+ wrong_receiver->invalid_receivers[i] = g_variant_get_int64(info_struct);
+
+ g_variant_unref(info_struct);
+ }
+ idx2++;
+ wrong_receiver->invalid_receivers_len = g_variant_get_uint32(res_info_struct[idx2++]);
+ } else {
+ wrong_receiver->invalid_receivers_len = 0U;
+ idx2++;
+ idx2++;
+ }
+
+ gsize interrupted_count = g_variant_n_children(res_info_struct[idx2]);
+ wrong_receiver->interrupted_receivers = (int64_t *) calloc(interrupted_count, sizeof(int64_t));
+
+ if (NULL != wrong_receiver->interrupted_receivers) {
+ for (gsize i = 0; i < interrupted_count; i++) {
+ GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+ GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+ wrong_receiver->interrupted_receivers[i] = g_variant_get_int64(info_struct);
+
+ g_variant_unref(info_struct);
+ }
+ idx2++;
+ wrong_receiver->interrupted_receivers_len = g_variant_get_uint32(res_info_struct[idx2++]);
+ } else {
+ wrong_receiver->interrupted_receivers_len = 0U;
+ idx2++;
+ idx2++;
+ }
+
+ gsize disabled_count = g_variant_n_children(res_info_struct[idx2]);
+ wrong_receiver->disabled_receivers = (int64_t *) calloc(disabled_count, sizeof(int64_t));
+
+ if (NULL != wrong_receiver->disabled_receivers) {
+ for (gsize i = 0; i < disabled_count; i++) {
+ GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+ GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+ wrong_receiver->disabled_receivers[i] = g_variant_get_int64(info_struct);
+
+ g_variant_unref(info_struct);
+ }
+ idx2++;
+ wrong_receiver->disabled_receivers_len = g_variant_get_uint32(res_info_struct[idx2++]);
+ } else {
+ wrong_receiver->disabled_receivers_len = 0U;
+ idx2++;
+ idx2++;
+ }
+
+ gsize existing_count = g_variant_n_children(res_info_struct[idx2]);
+ wrong_receiver->existing_chatmembers = (int64_t *) calloc(existing_count, sizeof(int64_t));
+
+ if (NULL != wrong_receiver->existing_chatmembers) {
+ for (gsize i = 0; i < existing_count; i++) {
+ GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+ GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+ wrong_receiver->existing_chatmembers[i] = g_variant_get_int64(info_struct);
+
+ g_variant_unref(info_struct);
+ }
+ idx2++;
+ wrong_receiver->existing_chatmembers_len = g_variant_get_uint32(res_info_struct[idx2++]);
+ } else {
+ wrong_receiver->existing_chatmembers_len = 0U;
+ idx2++;
+ idx2++;
+ }
+
+ gsize did_violation_count = g_variant_n_children(res_info_struct[idx2]);
+ wrong_receiver->did_violation_users = (service_adaptor_did_violation_users_s **) calloc(did_violation_count, sizeof(service_adaptor_did_violation_users_s *));
+
+ if (NULL != wrong_receiver->did_violation_users) {
+ for (gsize i = 0; i < did_violation_count; i++) {
+ GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+ GVariant *info_struct[private_service_adaptor_did_violation_users_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_did_violation_users_s_type_length; j++) {
+ info_struct[j] = g_variant_get_child_value(info_entry_v, j);
+ }
+
+ int idx3 = 0;
+
+ wrong_receiver->did_violation_users[i] = (service_adaptor_did_violation_users_s *) calloc(1, sizeof(service_adaptor_did_violation_users_s));
+ if (NULL != wrong_receiver->did_violation_users[i]) {
+ wrong_receiver->did_violation_users[i]->usera = g_variant_get_int64(info_struct[idx3++]);
+ wrong_receiver->did_violation_users[i]->userb = g_variant_get_int64(info_struct[idx3++]);
+ }
+
+ for (size_t j = 0; j < private_service_adaptor_did_violation_users_s_type_length; j++) {
+ g_variant_unref(info_struct[j]);
+ }
+ }
+ idx2++;
+ wrong_receiver->did_violation_users_len = g_variant_get_uint32(res_info_struct[idx2++]);
+ } else {
+ wrong_receiver->did_violation_users_len = 0U;
+ idx2++;
+ idx2++;
+ }
+
+ gsize denieds_count = g_variant_n_children(res_info_struct[idx2]);
+ wrong_receiver->invitation_denieds = (int64_t *) calloc(denieds_count, sizeof(int64_t));
+
+ if (NULL != wrong_receiver->invitation_denieds) {
+ for (gsize i = 0; i < denieds_count; i++) {
+ GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx2], i);
+ GVariant *info_struct = g_variant_get_child_value(info_entry_v, 0);
+
+ wrong_receiver->invitation_denieds[i] = g_variant_get_int64(info_struct);
+
+ g_variant_unref(info_struct);
+ }
+ idx2++;
+ wrong_receiver->invitation_denieds_len = g_variant_get_uint32(res_info_struct[idx2++]);
+ } else {
+ wrong_receiver->invitation_denieds_len = 0U;
+ idx2++;
+ idx2++;
+ }
+
+
+ for (size_t j = 0; j < private_service_adaptor_wrong_receiver_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+
+ for (size_t j = 0; j < private_service_adaptor_invite_chat_res_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+
+void __get_end_chat_res_type(GVariant *parameters,
+ int64_t *request_id)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[private_service_adaptor_end_chat_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_end_chat_res_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ *request_id = g_variant_get_int64(res_struct[idx++]);
+
+ for (size_t j = 0; j < private_service_adaptor_end_chat_res_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+
+void __get_unseal_message_res_type(GVariant *parameters,
+ int64_t *request_id,
+ int64_t *chatroom_id)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[private_service_adaptor_unseal_message_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_unseal_message_res_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ *request_id = g_variant_get_int64(res_struct[idx++]);
+ *chatroom_id = g_variant_get_int64(res_struct[idx++]);
+
+ for (size_t j = 0; j < private_service_adaptor_unseal_message_res_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+void __get_save_call_log_res_type(GVariant *parameters,
+ int64_t *request_id)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[private_service_adaptor_save_call_log_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_save_call_log_res_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ *request_id = g_variant_get_int64(res_struct[idx++]);
+
+ for (size_t j = 0; j < private_service_adaptor_save_call_log_res_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+
+void __get_current_time_res_type(GVariant *parameters,
+ int64_t *request_id,
+ int64_t *current_time_millis)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[private_service_adaptor_current_time_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_current_time_res_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ *request_id = g_variant_get_int64(res_struct[idx++]);
+ *current_time_millis = g_variant_get_int64(res_struct[idx++]);
+
+ for (size_t j = 0; j < private_service_adaptor_current_time_res_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+
+void __get_chat_id_list_res_type(GVariant *call_result_struct,
+ service_adaptor_chat_id_s ***chat_ids,
+ unsigned int *chat_ids_len,
+ void **server_data)
+{
+ GVariant *res_info_struct[private_service_adaptor_chat_id_list_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_chat_id_list_res_s_type_length; j++) {
+ res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+ }
+
+ int idx = 0;
+ gsize list_count = g_variant_n_children(res_info_struct[idx]);
+
+ *chat_ids = (service_adaptor_chat_id_s **) calloc(list_count, sizeof(service_adaptor_chat_id_s *));
+
+ if (NULL != *chat_ids) {
+ for (gsize i = 0; i < list_count; i++) {
+ GVariant *list_info_struct[private_service_adaptor_chat_id_s_type_length];
+ GVariant *list_info_entry_v = g_variant_get_child_value(res_info_struct[idx], i);
+ (*chat_ids)[i] = (service_adaptor_chat_id_s *) calloc(1, sizeof(service_adaptor_chat_id_s));
+
+ if (NULL != (*chat_ids)[i]) {
+ for (size_t j = 0; j < private_service_adaptor_chat_id_s_type_length; j++) {
+ list_info_struct[j] = g_variant_get_child_value(list_info_entry_v, j);
+ }
+
+ int idx2 = 0;
+ (*chat_ids)[i]->chatid = g_variant_get_int64(list_info_struct[idx2++]);
+ (*chat_ids)[i]->msisdn = ipc_g_variant_dup_string(list_info_struct[idx2++]);
+
+ for (size_t j = 0; j < private_service_adaptor_chat_id_s_type_length; j++) {
+ g_variant_unref(list_info_struct[j]);
+ }
+ }
+ }
+ idx++;
+ *chat_ids_len = g_variant_get_uint32(res_info_struct[idx++]);
+ } else {
+ *chat_ids_len = 0U;
+ idx++;
+ idx++;
+ }
+
+ for (size_t j = 0; j < private_service_adaptor_chat_id_list_res_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+}
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+void on_message_signal(GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_CREATE_CHATROOM_SIGNAL)) {
+ int64_t request_id = 0;
+ int64_t chatroom_id = 0;
+ int default_message_ttl = 0;
+ service_adaptor_wrong_receiver_s wrong_receiver;
+ service_adaptor_error_s *error_code = NULL;
+
+ __get_create_chatroom_res_type(parameters, &request_id, &chatroom_id, &default_message_ttl, &wrong_receiver);
+
+ service_adaptor_task_h task = _queue_get_task(request_id);
+
+ if (NULL == task) {
+ __free_wrong_receiver_s(&wrong_receiver);
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+ if (NULL != error_code) {
+ error_code->code = remote_call_result;
+ error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+ }
+ }
+
+ service_adaptor_reply_create_chatroom_cb callback = (service_adaptor_reply_create_chatroom_cb) task->callback;
+
+ if (NULL != callback) {
+ callback(task->handle, request_id, chatroom_id, default_message_ttl, &wrong_receiver, error_code, task->user_data);
+ }
+
+ _queue_del_task(task);
+ __free_wrong_receiver_s(&wrong_receiver);
+ __FREE_ERROR_CODE(error_code);
+ } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_CHANGE_CHATROOM_META_SIGNAL)) {
+ int64_t request_id = 0;
+ int64_t chatroom_id = 0;
+ service_adaptor_error_s *error_code = NULL;
+
+ __get_change_chatroom_meta_res_type(parameters, &request_id, &chatroom_id);
+
+ service_adaptor_task_h task = _queue_get_task(request_id);
+
+ if (NULL == task) {
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+ if (NULL != error_code) {
+ error_code->code = remote_call_result;
+ error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+ }
+ }
+
+ service_adaptor_reply_change_chatroom_meta_cb callback = (service_adaptor_reply_change_chatroom_meta_cb) task->callback;
+
+ if (NULL != callback) {
+ callback(task->handle, request_id, chatroom_id, error_code, task->user_data);
+ }
+ __FREE_ERROR_CODE(error_code);
+
+ _queue_del_task(task);
+ } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_CHAT_SIGNAL)) {
+ int64_t request_id = 0;
+ int64_t chatroom_id = 0;
+ service_adaptor_processed_msg_s **processed_msgs = NULL;
+ unsigned int processed_msgs_len = 0;
+ service_adaptor_error_s *error_code = NULL;
+
+ __get_chat_res_type(parameters, &request_id, &chatroom_id, &processed_msgs, &processed_msgs_len);
+
+ service_adaptor_task_h task = _queue_get_task(request_id);
+
+ if (NULL == task) {
+ __FREE_POINTER_ARRAY(processed_msgs, processed_msgs_len);
+ __SAFE_FREE(processed_msgs);
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+ if (NULL != error_code) {
+ error_code->code = remote_call_result;
+ error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+ }
+ }
+
+ service_adaptor_reply_chat_cb callback = (service_adaptor_reply_chat_cb) task->callback;
+
+ if (NULL != callback) {
+ callback(task->handle, request_id, chatroom_id, processed_msgs, processed_msgs_len, error_code, task->user_data);
+ }
+ __FREE_POINTER_ARRAY(processed_msgs, processed_msgs_len);
+ __SAFE_FREE(processed_msgs);
+ __FREE_ERROR_CODE(error_code);
+
+ _queue_del_task(task);
+ } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_ALLOW_CHAT_SIGNAL)) {
+ int64_t request_id = 0;
+ int64_t chatroom_id = 0;
+ service_adaptor_delivery_ack_s **delivery_acks = NULL;
+ unsigned int delivery_acks_len = 0;
+ unsigned long long last_delivery_acks_timestamp = 0;
+ service_adaptor_read_ack_s **read_acks = NULL;
+ unsigned int read_acks_len = 0;
+ unsigned long long last_read_acks_timestamp = 0;
+ service_adaptor_ordered_chat_member_s **ordered_chat_members = NULL;
+ unsigned int ordered_chat_members_len = 0;
+ char *chatroom_title = NULL;
+ int default_message_ttl = 0;
+ service_adaptor_error_s *error_code = NULL;
+
+
+ __get_allow_chat_res_type(parameters, &request_id, &chatroom_id,
+ &delivery_acks, &delivery_acks_len, &last_delivery_acks_timestamp,
+ &read_acks, &read_acks_len, &last_read_acks_timestamp,
+ &ordered_chat_members, &ordered_chat_members_len,
+ &chatroom_title, &default_message_ttl);
+
+ service_adaptor_task_h task = _queue_get_task(request_id);
+
+ if (NULL == task) {
+ __FREE_POINTER_ARRAY(delivery_acks, delivery_acks_len);
+ __SAFE_FREE(delivery_acks);
+ __FREE_POINTER_ARRAY(read_acks, read_acks_len);
+ __SAFE_FREE(read_acks);
+ __free_ordered_chat_member_s_list(ordered_chat_members, ordered_chat_members_len);
+ __SAFE_FREE(ordered_chat_members);
+ __SAFE_FREE(chatroom_title);
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+ if (NULL != error_code) {
+ error_code->code = remote_call_result;
+ error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+ }
+ }
+
+ service_adaptor_reply_allow_chat_cb callback = (service_adaptor_reply_allow_chat_cb) task->callback;
+ if (NULL != callback) {
+ callback(task->handle, request_id, chatroom_id,
+ delivery_acks, delivery_acks_len, last_delivery_acks_timestamp,
+ read_acks, read_acks_len, last_read_acks_timestamp,
+ ordered_chat_members, ordered_chat_members_len,
+ chatroom_title, default_message_ttl, error_code, task->user_data);
+ }
+ __FREE_POINTER_ARRAY(delivery_acks, delivery_acks_len);
+ __SAFE_FREE(delivery_acks);
+ __FREE_POINTER_ARRAY(read_acks, read_acks_len);
+ __SAFE_FREE(read_acks);
+ __free_ordered_chat_member_s_list(ordered_chat_members, ordered_chat_members_len);
+ __SAFE_FREE(ordered_chat_members);
+ __SAFE_FREE(chatroom_title);
+ __FREE_ERROR_CODE(error_code);
+
+ _queue_del_task(task);
+ } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_ALL_UNREAD_MESSAGE_SIGNAL)) {
+ int64_t request_id = 0;
+ service_adaptor_error_s *error_code = NULL;
+
+ __get_all_unread_message_res_type(parameters, &request_id);
+
+ service_adaptor_task_h task = _queue_get_task(request_id);
+
+ if (NULL == task) {
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+ if (NULL != error_code) {
+ error_code->code = remote_call_result;
+ error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+ }
+ }
+
+ service_adaptor_reply_all_unread_message_cb callback = (service_adaptor_reply_all_unread_message_cb) task->callback;
+
+ if (NULL != callback) {
+ callback(task->handle, request_id, error_code, task->user_data);
+ }
+ __FREE_ERROR_CODE(error_code);
+
+ _queue_del_task(task);
+ } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REQUEST_FORWARD_ONLINE_MESSAGE_SIGNAL)) {
+ int64_t request_id = 0;
+ int64_t chatroom_id = 0;
+ int chat_type = 0;
+ service_adaptor_inbox_message_s inbox_msg;
+ bool skip_reply = false;
+ service_adaptor_error_s *error_code = NULL;
+
+ __get_forward_online_message_req_type(parameters, &request_id, &chatroom_id, &chat_type, &inbox_msg, &skip_reply);
+
+ service_adaptor_task_h task = _queue_get_task(-100);
+
+ if (NULL == task) {
+ __SAFE_FREE(inbox_msg.chat_msg);
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+ if (NULL != error_code) {
+ error_code->code = remote_call_result;
+ error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+ }
+ }
+
+ service_adaptor_request_forward_online_message_cb callback = (service_adaptor_request_forward_online_message_cb) task->callback;
+
+ if (NULL != callback) {
+ callback(task->handle, request_id, chatroom_id, chat_type, &inbox_msg, skip_reply, error_code, task->user_data);
+ }
+ __SAFE_FREE(inbox_msg.chat_msg);
+ __FREE_ERROR_CODE(error_code);
+ } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REQUEST_FORWARD_UNREAD_MESSAGE_SIGNAL)) {
+ int64_t request_id = 0;
+ service_adaptor_inbox_message_s **inbox_msgs = NULL;
+ uint32_t inbox_msgs_len = 0;
+ char *next_pagination_key = NULL;
+ service_adaptor_error_s *error_code = NULL;
+
+ __get_forward_unread_message_req_type(parameters, &request_id, &inbox_msgs, &inbox_msgs_len, &next_pagination_key);
+
+ service_adaptor_task_h task = _queue_get_task(-101);
+
+ if (NULL == task) {
+ __SAFE_FREE(next_pagination_key);
+ __free_inbox_message_s_list(inbox_msgs, inbox_msgs_len);
+ __SAFE_FREE(inbox_msgs);
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+ if (NULL != error_code) {
+ error_code->code = remote_call_result;
+ error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+ }
+ }
+
+ service_adaptor_request_forward_unread_message_cb callback = (service_adaptor_request_forward_unread_message_cb) task->callback;
+
+ if (NULL != callback) {
+ callback(task->handle, request_id, inbox_msgs, inbox_msgs_len, next_pagination_key, error_code, task->user_data);
+ }
+ __SAFE_FREE(next_pagination_key);
+ __free_inbox_message_s_list(inbox_msgs, inbox_msgs_len);
+ __SAFE_FREE(inbox_msgs);
+ __FREE_ERROR_CODE(error_code);
+ } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_CHANNEL_DISCONNECTED_SIGNAL)) {
+ char *service_name = NULL;
+ service_adaptor_error_s *error_code = NULL;
+
+ __get_channel_disconnected_res_type(parameters, &service_name);
+
+ service_adaptor_task_h task = _queue_get_task(-102);
+
+ if (NULL == task) {
+ __SAFE_FREE(service_name);
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+ if (NULL != error_code) {
+ error_code->code = remote_call_result;
+ error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+ }
+ }
+
+ service_adaptor_reply_channel_disconnected_cb callback = (service_adaptor_reply_channel_disconnected_cb) task->callback;
+
+ if ((NULL != callback) && (NULL != task->handle) && (NULL != ((service_adaptor_h)task->handle)->service_name) && (NULL != service_name)
+ && (0 == strncmp(((service_adaptor_h)task->handle)->service_name, service_name, strlen(((service_adaptor_h)task->handle)->service_name)))) {
+ callback(task->handle, error_code, task->user_data);
+ }
+ __SAFE_FREE(service_name);
+ __FREE_ERROR_CODE(error_code);
+ } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_READ_MESSAGE_SIGNAL)) {
+ int64_t request_id = 0;
+ int64_t chatroom_id = 0;
+ service_adaptor_error_s *error_code = NULL;
+
+ __get_read_message_res_type(parameters, &request_id, &chatroom_id);
+
+ service_adaptor_task_h task = _queue_get_task(request_id);
+
+ if (NULL == task) {
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+ if (NULL != error_code) {
+ error_code->code = remote_call_result;
+ error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+ }
+ }
+
+ service_adaptor_reply_read_message_cb callback = (service_adaptor_reply_read_message_cb) task->callback;
+ if (NULL != callback) {
+ callback(task->handle, request_id, chatroom_id, error_code, task->user_data);
+ }
+ __FREE_ERROR_CODE(error_code);
+
+ _queue_del_task(task);
+ } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_INVITE_CHAT_SIGNAL)) {
+ int64_t request_id = 0;
+ int64_t chatroom_id = 0;
+ int64_t sent_time = 0;
+ service_adaptor_wrong_receiver_s wrong_receiver;
+ service_adaptor_error_s *error_code = NULL;
+
+ __get_invite_chat_res_type(parameters, &request_id, &chatroom_id, &sent_time, &wrong_receiver);
+
+ service_adaptor_task_h task = _queue_get_task(request_id);
+
+ if (NULL == task) {
+ __free_wrong_receiver_s(&wrong_receiver);
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+ if (NULL != error_code) {
+ error_code->code = remote_call_result;
+ error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+ }
+ }
+
+ service_adaptor_reply_invite_chat_cb callback = (service_adaptor_reply_invite_chat_cb) task->callback;
+ if (NULL != callback) {
+ callback(task->handle, request_id, chatroom_id, sent_time, &wrong_receiver, error_code, task->user_data);
+ }
+
+ __free_wrong_receiver_s(&wrong_receiver);
+ __FREE_ERROR_CODE(error_code);
+ _queue_del_task(task);
+ } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_END_CHAT_SIGNAL)) {
+ int64_t request_id = 0;
+ service_adaptor_error_s *error_code = NULL;
+
+ __get_end_chat_res_type(parameters, &request_id);
+
+ service_adaptor_task_h task = _queue_get_task(request_id);
+
+ if (NULL == task) {
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+ if (NULL != error_code) {
+ error_code->code = remote_call_result;
+ error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+ }
+ }
+
+ service_adaptor_reply_end_chat_cb callback = (service_adaptor_reply_end_chat_cb) task->callback;
+ if (NULL != callback) {
+ callback(task->handle, request_id, error_code, task->user_data);
+ }
+ __FREE_ERROR_CODE(error_code);
+
+ _queue_del_task(task);
+ } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_UNSEAL_MESSAGE_SIGNAL)) {
+ int64_t request_id = 0;
+ int64_t chatroom_id = 0;
+ service_adaptor_error_s *error_code = NULL;
+
+ __get_unseal_message_res_type(parameters, &request_id, &chatroom_id);
+
+ service_adaptor_task_h task = _queue_get_task(request_id);
+
+ if (NULL == task) {
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+ if (NULL != error_code) {
+ error_code->code = remote_call_result;
+ error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+ }
+ }
+
+ service_adaptor_reply_unseal_message_cb callback = (service_adaptor_reply_unseal_message_cb) task->callback;
+ if (NULL != callback) {
+ callback(task->handle, request_id, chatroom_id, error_code, task->user_data);
+ }
+ __FREE_ERROR_CODE(error_code);
+
+ _queue_del_task(task);
+ } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_SAVE_CALL_LOG_SIGNAL)) {
+ int64_t request_id = 0;
+ service_adaptor_error_s *error_code = NULL;
+
+ __get_save_call_log_res_type(parameters, &request_id);
+
+ service_adaptor_task_h task = _queue_get_task(request_id);
+
+ if (NULL == task) {
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+ if (NULL != error_code) {
+ error_code->code = remote_call_result;
+ error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+ }
+ }
+
+ service_adaptor_reply_save_call_log_cb callback = (service_adaptor_reply_save_call_log_cb) task->callback;
+ if (NULL != callback) {
+ callback(task->handle, request_id, error_code, task->user_data);
+ }
+ __FREE_ERROR_CODE(error_code);
+
+ _queue_del_task(task);
+ } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_REPLY_CURRENT_TIME_SIGNAL)) {
+ int64_t request_id = 0;
+ int64_t current_time_millis = 0;
+ service_adaptor_error_s *error_code = NULL;
+
+ __get_current_time_res_type(parameters, &request_id, ¤t_time_millis);
+
+ service_adaptor_task_h task = _queue_get_task(request_id);
+
+ if (NULL == task) {
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+ if (NULL != error_code) {
+ error_code->code = remote_call_result;
+ error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+ }
+ }
+
+ service_adaptor_reply_current_time_cb callback = (service_adaptor_reply_current_time_cb) task->callback;
+ if (NULL != callback) {
+ callback(task->handle, request_id, current_time_millis, error_code, task->user_data);
+ }
+ __FREE_ERROR_CODE(error_code);
+
+ _queue_del_task(task);
+ }
+}
+
+/** @brief
+ * @return service_adaptor_error_s
+ * @remarks :
+ */
+int _dbus_request_create_chatroom(const char *service_name,
+ long long int request_id,
+ int chat_type,
+ long long int *receivers,
+ unsigned int receivers_len,
+ const char *chatroom_title,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == receivers) || (1 > receivers_len)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(x)"));
+
+ for (int i = 0; i < receivers_len; i++) {
+ g_variant_builder_add(builder, "(x)", receivers[i]);
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_create_chatroom_req_s_type ")", __safe_add_string(service_name),
+ request_id, chat_type, builder, receivers_len, __safe_add_string(chatroom_title));
+
+ g_variant_builder_unref(builder);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_REQUEST_CREATE_CHATROOM_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ } else {
+ __ipc_get_simple_error_code();
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+/** @brief
+ * @return service_adaptor_error_s
+ * @remarks :
+ */
+int _dbus_request_change_chatroom_meta(const char *service_name,
+ long long int request_id,
+ long long int chatroom_id,
+ const char *chatroom_title,
+ int default_message_ttl,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ ipc_check_proxy(sac_interface_proxy);
+
+ if (NULL == service_name) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_change_chatroom_meta_req_s_type ")", __safe_add_string(service_name),
+ request_id, chatroom_id, __safe_add_string(chatroom_title), default_message_ttl);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_REQUEST_CHANGE_CHATROOM_META_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ } else {
+ __ipc_get_simple_error_code();
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+
+int _dbus_request_chat(const char *service_name,
+ long long int request_id,
+ long long int chatroom_id,
+ service_adaptor_chat_msg_s **chat_msgs,
+ unsigned int chat_msgs_len,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (chat_msgs == NULL) || (1 > chat_msgs_len)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a" private_service_adaptor_chat_msg_s_type));
+
+ for (int i = 0; i < chat_msgs_len; i++) {
+ g_variant_builder_open(builder, G_VARIANT_TYPE(private_service_adaptor_chat_msg_s_type));
+ g_variant_builder_add(builder, "x", chat_msgs[i]->msg_id);
+ g_variant_builder_add(builder, "i", chat_msgs[i]->msg_type);
+ __safe_g_variant_builder_add_string(builder, chat_msgs[i]->chatmsg);
+ g_variant_builder_add(builder, "i", chat_msgs[i]->message_ttl);
+ g_variant_builder_close(builder);
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_chat_req_s_type ")", __safe_add_string(service_name), request_id, chatroom_id, builder, chat_msgs_len);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_REQUEST_CHAT_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ } else {
+ __ipc_get_simple_error_code();
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_request_allow_chat(const char *service_name,
+ long long int request_id,
+ long long int chatroom_id,
+ bool is_auto_allow,
+ int max_count,
+ bool need_delivery_ack,
+ unsigned long long last_delivery_ack_timestamp,
+ bool need_read_ack,
+ unsigned long long last_read_ack_timestamp,
+ bool need_ordered_chat_member_list,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_allow_chat_req_s_type ")",
+ __safe_add_string(service_name), request_id, chatroom_id, is_auto_allow, max_count,
+ need_delivery_ack, last_delivery_ack_timestamp,
+ need_read_ack, last_read_ack_timestamp, need_ordered_chat_member_list);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_REQUEST_ALLOW_CHAT_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ } else {
+ __ipc_get_simple_error_code();
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_request_all_unread_message(const char *service_name,
+ long long int request_id,
+ int max_count,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_all_unread_message_req_s_type ")", __safe_add_string(service_name), request_id, max_count);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_REQUEST_ALL_UNREAD_MESSAGE_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ } else {
+ __ipc_get_simple_error_code();
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_reply_forward_online_message(const char *service_name,
+ long long int request_id,
+ long long int chatroom_id,
+ bool mark_as_read,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_forward_online_message_res_s_type ")", __safe_add_string(service_name), request_id, chatroom_id, mark_as_read);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_REPLY_FORWARD_ONLINE_MESSAGE_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ } else {
+ __ipc_get_simple_error_code();
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_reply_forward_unread_message(const char *service_name,
+ long long int request_id,
+ const char *next_pagination_key,
+ int max_count,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_forward_unread_message_res_s_type ")", __safe_add_string(service_name), request_id, __safe_add_string(next_pagination_key), max_count);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_REPLY_FORWARD_UNREAD_MESSAGE_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ } else {
+ __ipc_get_simple_error_code();
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_request_read_message(const char *service_name,
+ long long int request_id,
+ long long int chatroom_id,
+ service_adaptor_inbox_message_s *inbox_msg,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == inbox_msg)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_read_message_req_s_type ")", __safe_add_string(service_name), request_id, chatroom_id, inbox_msg->msg_id, inbox_msg->msg_type, inbox_msg->sender, inbox_msg->receiver, inbox_msg->sent_time, __safe_add_string(inbox_msg->chat_msg), inbox_msg->chatroom_id, inbox_msg->chat_type, inbox_msg->message_ttl);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_REQUEST_READ_MESSAGE_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ } else {
+ __ipc_get_simple_error_code();
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_request_invite_chat(const char *service_name,
+ long long int request_id,
+ long long int chatroom_id,
+ long long int *inviting_members,
+ unsigned int inviting_members_len,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == inviting_members) || (1 > inviting_members_len)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(x)"));
+
+ for (int i = 0; i < inviting_members_len; i++) {
+ g_variant_builder_add(builder, "(x)", inviting_members[i]);
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_invite_chat_req_s_type ")", __safe_add_string(service_name), request_id, chatroom_id, builder, inviting_members_len);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_REQUEST_INVITE_CHAT_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ } else {
+ __ipc_get_simple_error_code();
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_request_end_chat(const char *service_name,
+ long long int request_id,
+ service_adaptor_end_chat_s **end_chats,
+ unsigned int end_chats_len,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == end_chats) || (1 > end_chats_len)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a" private_service_adaptor_end_chat_s_type));
+
+ for (int i = 0; i < end_chats_len; i++) {
+ g_variant_builder_add(builder, private_service_adaptor_end_chat_s_type, end_chats[i]->chatroom_id, end_chats[i]->deny_invitation);
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_end_chat_req_s_type ")", __safe_add_string(service_name), request_id, builder, end_chats_len);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_REQUEST_END_CHAT_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ } else {
+ __ipc_get_simple_error_code();
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+
+int _dbus_request_unseal_message(const char *service_name,
+ long long int request_id,
+ long long int chatroom_id,
+ long long int sender_id,
+ long long int message_id,
+ const char *message_detail,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_unseal_message_req_s_type ")", __safe_add_string(service_name),
+ request_id, chatroom_id, sender_id, message_id, __safe_add_string(message_detail));
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_REQUEST_UNSEAL_MESSAGE_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ } else {
+ __ipc_get_simple_error_code();
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+
+int _dbus_request_save_call_log(const char *service_name,
+ long long int request_id,
+ long long int chatroom_id,
+ const char *call_id,
+ const char *call_log_type,
+ long long int call_sender_id,
+ long long int call_receiver_id,
+ int conversaction_second,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_save_call_log_req_s_type ")", __safe_add_string(service_name),
+ request_id, chatroom_id, call_id, call_log_type, call_sender_id, call_receiver_id, conversaction_second);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_REQUEST_SAVE_CALL_LOG_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ } else {
+ __ipc_get_simple_error_code();
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_request_current_time(const char *service_name,
+ long long int request_id,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_current_time_req_s_type ")", __safe_add_string(service_name), request_id);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_REQUEST_CURRENT_TIME_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ } else {
+ __ipc_get_simple_error_code();
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_request_get_connection_policy(const char *service_name,
+ service_adaptor_connection_policy_e *policy,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_get_connection_policy_req_s_type ")", __safe_add_string(service_name));
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_REQUEST_GET_CONNECTION_POLICY_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result,
+ G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_connection_policy_res_s_type)))) {
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ GVariant *gv_policy = g_variant_get_child_value(call_result_struct[0], 0);
+ *policy = (int) g_variant_get_int32(gv_policy);
+ g_variant_unref(gv_policy);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = _get_result_code(remote_call_result);
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_request_set_connection_policy(const char *service_name,
+ service_adaptor_connection_policy_e *policy,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_set_connection_policy_req_s_type ")", __safe_add_string(service_name), (int32_t)*policy);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_REQUEST_SET_CONNECTION_POLICY_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result,
+ G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_connection_policy_res_s_type)))) {
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ GVariant *gv_policy = g_variant_get_child_value(call_result_struct[0], 0);
+ *policy = (int) g_variant_get_int32(gv_policy);
+ g_variant_unref(gv_policy);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = _get_result_code(remote_call_result);
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_get_chat_id_list(const char *service_name,
+ service_adaptor_phone_number_s **phone_numbers,
+ unsigned int phone_numbers_len,
+ void *user_data,
+ service_adaptor_chat_id_s ***chat_ids,
+ unsigned int *chat_ids_len,
+ void **server_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == phone_numbers) || (1 > phone_numbers_len)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a" private_service_adaptor_phone_number_s_type));
+
+ for (int i = 0; i < phone_numbers_len; i++) {
+ g_variant_builder_open(builder, G_VARIANT_TYPE(private_service_adaptor_phone_number_s_type));
+ __safe_g_variant_builder_add_string(builder, phone_numbers[i]->phonenumber);
+ __safe_g_variant_builder_add_string(builder, phone_numbers[i]->ccc);
+ g_variant_builder_close(builder);
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_chat_id_list_req_s_type ")", __safe_add_string(service_name), builder, phone_numbers_len);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_GET_CHAT_ID_LIST_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_chat_id_list_res_s_type)))) {
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = _get_result_code(remote_call_result);
+ } else {
+ if ((NULL != chat_ids) && (NULL != chat_ids_len)) {
+ __get_chat_id_list_res_type(call_result_struct[0], chat_ids, chat_ids_len, server_data);
+ }
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_get_msisdn_list(const char *service_name,
+ long long int *chat_ids,
+ unsigned int chat_ids_len,
+ void *user_data,
+ service_adaptor_chat_id_s ***msisdns,
+ unsigned int *msisdns_len,
+ void **server_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == chat_ids) || (1 > chat_ids_len)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(x)"));
+
+ for (int i = 0; i < chat_ids_len; i++) {
+ g_variant_builder_add(builder, "(x)", chat_ids[i]);
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_msisdn_list_req_s_type ")", __safe_add_string(service_name), builder, chat_ids_len);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_GET_MSISDN_LIST_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_chat_id_list_res_s_type)))) {
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = _get_result_code(remote_call_result);
+ } else {
+ if ((NULL != msisdns) && (NULL != msisdns_len)) {
+ __get_chat_id_list_res_type(call_result_struct[0], msisdns, msisdns_len, server_data);
+ }
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: dbus-client-push.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include <dbus-server.h>
+
+#include "dbus_client.h"
+#include "dbus_client_push.h"
+#include "service_adaptor_client_type.h"
+#include "private/service-adaptor-client-push.h"
+#include "service_adaptor_client_log.h"
+
+#include "util/service_adaptor_client_util.h"
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+#define __SAFE_FREE(x) do { free(x); (x) = NULL; } while (0)
+
+void __get_push_data_type(GVariant *parameters,
+ uint32_t *service_id,
+ service_adaptor_push_notification_s *noti_info)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[private_service_adaptor_push_data_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_push_data_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ *service_id = g_variant_get_uint32(res_struct[idx++]);
+ noti_info->data = ipc_g_variant_dup_string(res_struct[idx++]);
+ noti_info->message = ipc_g_variant_dup_string(res_struct[idx++]);
+ noti_info->time = g_variant_get_int64(res_struct[idx++]);
+
+ for (size_t j = 0; j < private_service_adaptor_push_data_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+void on_push_signal(GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_PUSH_DATA_SIGNAL)) {
+ uint32_t service_id = 0;
+ service_adaptor_push_notification_s noti_info;
+ service_adaptor_error_s *error_code = NULL;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+ __get_push_data_type(parameters, &service_id, ¬i_info);
+
+ service_adaptor_task_h task = _signal_queue_get_task(service_id);
+
+ sac_debug("==on_push_signal== task(%p) service_id(%u)", task, service_id);
+
+ if (NULL == task) {
+ __SAFE_FREE(noti_info.data);
+ __SAFE_FREE(noti_info.message);
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error_code = &error;
+
+ if (NULL != error_code) {
+ error_code->code = remote_call_result;
+ error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+ }
+ }
+
+ sac_debug("push data : %s", noti_info.data);
+ sac_debug("push message : %s", noti_info.message);
+ sac_debug("push time : %lld", noti_info.time);
+
+ service_adaptor_push_notification_cb callback = (service_adaptor_push_notification_cb) task->callback;
+
+ if (NULL != callback) {
+ callback(task->handle, ¬i_info, error_code, task->user_data);
+ }
+ __SAFE_FREE(noti_info.data);
+ __SAFE_FREE(noti_info.message);
+ __SAFE_FREE(error.msg);
+ }
+}
+
+static int __dbus_push_simple_operation(const char *file_name,
+ service_adaptor_error_s *error,
+ const char *method_name)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_push_register_req_s_type ")", file_name);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ method_name,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[2];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+ ret = SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED;
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_push_register(const char *file_name,
+ service_adaptor_error_s *error)
+{
+ return __dbus_push_simple_operation(file_name, error, PRIVATE_DBUS_PUSH_REGISTER_METHOD);
+}
+
+int _dbus_push_deregister(const char *file_name,
+ service_adaptor_error_s *error)
+{
+ return __dbus_push_simple_operation(file_name, error, PRIVATE_DBUS_PUSH_DEREGISTER_METHOD);
+}
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: dbus-client-shop.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include <dbus-server.h>
+
+#include "dbus_client.h"
+#include "dbus_client_shop.h"
+#include "service_adaptor_client_type.h"
+#include "private/service-adaptor-client-shop.h"
+
+#include "util/service_adaptor_client_util.h"
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+void __get_item_list_res_type(GVariant *call_result_struct,
+ service_adaptor_shop_item_s ***items,
+ unsigned int *items_len,
+ void **server_data)
+{
+ GVariant *res_info_struct[private_service_adaptor_shop_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_shop_res_s_type_length; j++) {
+ res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+ }
+
+ int idx = 0;
+ gsize item_count = g_variant_n_children(res_info_struct[idx]);
+
+ *items = (service_adaptor_shop_item_s **) g_malloc0(sizeof(service_adaptor_shop_item_s *) * item_count);
+
+ for (gsize i = 0; i < item_count; i++) {
+ GVariant *item_info_struct[private_service_adaptor_shop_item_s_type_length];
+ GVariant *item_info_entry_v = g_variant_get_child_value(res_info_struct[idx], i);
+ (*items)[i] = (service_adaptor_shop_item_s *) g_malloc0(sizeof(service_adaptor_shop_item_s));
+
+ for (size_t j = 0; j < private_service_adaptor_shop_item_s_type_length; j++) {
+ item_info_struct[j] = g_variant_get_child_value(item_info_entry_v, j);
+ }
+
+ int idx2 = 0;
+ (*items)[i]->item_id = g_variant_get_int32(item_info_struct[idx2++]);
+ (*items)[i]->category_id = g_variant_get_int32(item_info_struct[idx2++]);
+
+ gsize ids_count = g_variant_n_children(item_info_struct[idx2]);
+ (*items)[i]->sticker_ids = (long *) g_malloc0(sizeof(long) * ids_count);
+
+ for (gsize k = 0; k < ids_count; k++) {
+ GVariant *ids_info_entry_v = g_variant_get_child_value(item_info_struct[idx2], k);
+ GVariant *ids_info_struct = g_variant_get_child_value(ids_info_entry_v, 0);;
+
+ (*items)[i]->sticker_ids[k] = g_variant_get_int32(ids_info_struct);
+
+ g_variant_unref(ids_info_struct);
+ }
+ idx2++;
+
+ (*items)[i]->sticker_ids_len = g_variant_get_uint32(item_info_struct[idx2++]);
+ (*items)[i]->title = ipc_g_variant_dup_string(item_info_struct[idx2++]);
+ (*items)[i]->character = ipc_g_variant_dup_string(item_info_struct[idx2++]);
+ (*items)[i]->version = g_variant_get_int32(item_info_struct[idx2++]);
+ (*items)[i]->download_url = ipc_g_variant_dup_string(item_info_struct[idx2++]);
+ (*items)[i]->panel_url = ipc_g_variant_dup_string(item_info_struct[idx2++]);
+ (*items)[i]->sticker_url = ipc_g_variant_dup_string(item_info_struct[idx2++]);
+ (*items)[i]->file_size = g_variant_get_int32(item_info_struct[idx2++]);
+ (*items)[i]->count = g_variant_get_int32(item_info_struct[idx2++]);
+ (*items)[i]->character_code = ipc_g_variant_dup_string(item_info_struct[idx2++]);
+ (*items)[i]->startdate = (long long int) g_variant_get_int64(item_info_struct[idx2++]);
+ (*items)[i]->enddate = (long long int) g_variant_get_int64(item_info_struct[idx2++]);
+ (*items)[i]->expired_date = (long long int) g_variant_get_int64(item_info_struct[idx2++]);
+ (*items)[i]->valid_period = (long long int) g_variant_get_int64(item_info_struct[idx2++]);
+
+ for (size_t j = 0; j < private_service_adaptor_shop_item_s_type_length; j++) {
+ g_variant_unref(item_info_struct[j]);
+ }
+ }
+ idx++;
+
+ *items_len = g_variant_get_uint32(res_info_struct[idx++]);
+
+ for (size_t j = 0; j < private_service_adaptor_shop_res_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+}
+
+GVariant *__create_shop_req_type(const char *service_name,
+ service_adaptor_shop_info_s *info,
+ void *user_data)
+{
+ GVariant *request = g_variant_new("(" private_service_adaptor_shop_req_s_type ")", __safe_add_string(service_name), info->category_id, info->item_id, info->sticker_id, __safe_add_string(info->lang_cd), __safe_add_string(info->cntry_cd), info->rwidth, info->rheight, info->start_idx, info->count);
+
+ return request;
+}
+
+void __get_shop_res_type(GVariant *call_result_struct,
+ service_adaptor_shop_item_s **item,
+ void **server_data)
+{
+ GVariant *res_info_struct[private_service_adaptor_shop_item_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_shop_item_s_type_length; j++) {
+ res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+ }
+
+ int idx = 0;
+ *item = (service_adaptor_shop_item_s *) calloc(1, sizeof(service_adaptor_shop_item_s));
+ if (NULL != *item) {
+ (*item)->item_id = g_variant_get_int32(res_info_struct[idx++]);
+ (*item)->category_id = g_variant_get_int32(res_info_struct[idx++]);
+
+ gsize ids_count = g_variant_n_children(res_info_struct[idx]);
+ (*item)->sticker_ids = (long *) calloc(ids_count, sizeof(long));
+
+ if (NULL != (*item)->sticker_ids) {
+ for (gsize i = 0; i < ids_count; i++) {
+ GVariant *ids_info_entry_v = g_variant_get_child_value(res_info_struct[idx], i);
+ GVariant *ids_info_struct = g_variant_get_child_value(ids_info_entry_v, 0);;
+
+ (*item)->sticker_ids[i] = g_variant_get_int32(ids_info_struct);
+
+ g_variant_unref(ids_info_struct);
+ }
+ idx++;
+ (*item)->sticker_ids_len = g_variant_get_uint32(res_info_struct[idx++]);
+ } else {
+ (*item)->sticker_ids_len = 0U;
+ idx++;
+ idx++;
+ }
+ (*item)->title = ipc_g_variant_dup_string(res_info_struct[idx++]);
+ (*item)->character = ipc_g_variant_dup_string(res_info_struct[idx++]);
+ (*item)->version = g_variant_get_int32(res_info_struct[idx++]);
+ (*item)->download_url = ipc_g_variant_dup_string(res_info_struct[idx++]);
+ (*item)->panel_url = ipc_g_variant_dup_string(res_info_struct[idx++]);
+ (*item)->sticker_url = ipc_g_variant_dup_string(res_info_struct[idx++]);
+ (*item)->file_size = g_variant_get_int32(res_info_struct[idx++]);
+ (*item)->count = g_variant_get_int32(res_info_struct[idx++]);
+ (*item)->character_code = ipc_g_variant_dup_string(res_info_struct[idx++]);
+ (*item)->startdate = g_variant_get_int64(res_info_struct[idx++]);
+ (*item)->enddate = g_variant_get_int64(res_info_struct[idx++]);
+ (*item)->expired_date = g_variant_get_int64(res_info_struct[idx++]);
+ (*item)->valid_period = g_variant_get_int64(res_info_struct[idx++]);
+ }
+
+ for (size_t j = 0; j < private_service_adaptor_shop_item_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+}
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+/** @brief
+ * @return service_adaptor_error_s
+ * @remarks :
+ */
+int _dbus_get_item_list(const char *service_name,
+ service_adaptor_shop_info_s *info,
+ void *user_data,
+ service_adaptor_shop_item_s ***items,
+ unsigned int *items_len,
+ void **server_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = __create_shop_req_type(service_name, info, user_data);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_GET_ITEM_LIST_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_shop_res_s_type)))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = _get_result_code(remote_call_result);
+ } else {
+ if ((NULL != items) && (NULL != items_len)) {
+ __get_item_list_res_type(call_result_struct[0], items, items_len, server_data);
+ }
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_download_item_package(const char *service_name,
+ service_adaptor_shop_info_s *info,
+ void *user_data,
+ service_adaptor_shop_item_s **item,
+ void **server_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = __create_shop_req_type(service_name, info, user_data);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_DOWNLOAD_ITEM_PACKAGE_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_shop_item_s_type)))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = _get_result_code(remote_call_result);
+ } else {
+ if (NULL != item) {
+ __get_shop_res_type(call_result_struct[0], item, server_data);
+ }
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_download_sticker(const char *service_name,
+ service_adaptor_shop_info_s *info,
+ void *user_data,
+ service_adaptor_shop_item_s **item,
+ void **server_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = __create_shop_req_type(service_name, info, user_data);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_DOWNLOAD_STICKER_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_shop_item_s_type)))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = _get_result_code(remote_call_result);
+ } else {
+ if (NULL != item) {
+ __get_shop_res_type(call_result_struct[0], item, server_data);
+ }
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+int _dbus_get_panel_url(const char *service_name,
+ service_adaptor_shop_info_s *info,
+ void *user_data,
+ service_adaptor_shop_item_s **item,
+ void **server_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = __create_shop_req_type(service_name, info, user_data);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_GET_PANEL_URL_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+
+ if (NULL != g_error) {
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE(MAKE_RETURN_TYPE(private_service_adaptor_shop_item_s_type)))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[3];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+ call_result_struct[2] = g_variant_get_child_value(call_result, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[1]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[2]);
+ ret = _get_result_code(remote_call_result);
+ } else {
+ if (NULL != item) {
+ __get_shop_res_type(call_result_struct[0], item, server_data);
+ }
+ }
+
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ g_variant_unref(call_result_struct[2]);
+ }
+
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: dbus-client-storage.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include <dbus-server.h>
+
+#include "dbus_client.h"
+#include "dbus_client_storage.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "service_adaptor_client_storage.h"
+#include "service_adaptor_client_storage_internal.h"
+
+#include "private/service-adaptor-client.h"
+#include "private/service-adaptor-client-storage.h"
+
+#include "util/service_adaptor_client_util.h"
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+/******************************************************************************
+ private feature
+******************************************************************************/
+
+void __private_get_file_progress_type(GVariant *parameters,
+ service_adaptor_file_h *file_handle,
+ uint64_t *progress_size,
+ uint64_t *total_size)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[private_service_adaptor_file_progress_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_file_progress_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ *file_handle = (service_adaptor_file_h) calloc(1, sizeof(service_adaptor_file_s));
+ if (NULL != *file_handle) {
+ (*file_handle)->file_description = g_variant_get_int32(res_struct[idx]);
+ }
+ idx++;
+ *progress_size = g_variant_get_uint64(res_struct[idx++]);
+ *total_size = g_variant_get_uint64(res_struct[idx++]);
+
+ for (size_t j = 0; j < private_service_adaptor_file_progress_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+
+void __private_get_file_transfer_completion_type(GVariant *parameters,
+ service_adaptor_file_h *file_handle,
+ char **publish_url)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[private_service_adaptor_file_transfer_completion_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_file_transfer_completion_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ *file_handle = (service_adaptor_file_h) calloc(1, sizeof(service_adaptor_file_s));
+ if (NULL != *file_handle) {
+ (*file_handle)->file_description = g_variant_get_int32(res_struct[idx]);
+ }
+ idx++;
+ *publish_url = ipc_g_variant_dup_string(res_struct[idx++]);
+
+ for (size_t j = 0; j < private_service_adaptor_file_transfer_completion_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+
+void __private_get_file_status_res_type(GVariant *call_result_struct,
+ service_adaptor_file_status_s **status,
+ void **server_data)
+{
+ GVariant *res_info_struct[private_service_adaptor_file_status_res_s_type_length];
+
+ for (size_t j = 0; j < private_service_adaptor_file_status_res_s_type_length; j++) {
+ res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+ }
+
+ int idx = 0;
+ *status = (service_adaptor_file_status_s *) calloc(1, sizeof(service_adaptor_file_status_s));
+ if (NULL != *status) {
+ (*status)->total_size = g_variant_get_int64(res_info_struct[idx++]);
+ (*status)->transferred_size = g_variant_get_int64(res_info_struct[idx++]);
+ (*status)->status = g_variant_get_int64(res_info_struct[idx++]);
+ }
+
+ for (size_t j = 0; j < private_service_adaptor_file_status_res_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+}
+
+void __private_get_file_handle_res_type(GVariant *call_result,
+ service_adaptor_file_h *file_handle,
+ service_adaptor_error_s *error,
+ int *ret)
+{
+ if (NULL != file_handle) {
+ if (((*file_handle) = (service_adaptor_file_h) calloc(1, sizeof(struct _service_adaptor_file_s)))) {
+ GVariant *fd = g_variant_get_child_value(call_result, 0);
+ (*file_handle)->file_description = g_variant_get_int32(fd);
+ } else {
+ *ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ error->code = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ error->msg = strdup("Critical : Memory allocation failed");
+ }
+ }
+}
+
+/******************************************************************************
+ private feature
+******************************************************************************/
+
+void __get_file_progress_type(GVariant *parameters,
+ long long int *_file_uid,
+ unsigned long long *_progress_size,
+ unsigned long long *_total_size)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[service_adaptor_file_progress_s_type_length];
+
+ for (size_t j = 0; j < service_adaptor_file_progress_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ do {
+ GVariant *fd_res_struct[service_adaptor_file_descriptor_s_type_length];
+ for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+ fd_res_struct[k] = g_variant_get_child_value(res_struct[idx], k);
+ }
+ int fd_idx = 0;
+ *_file_uid = (long long int) g_variant_get_int64(fd_res_struct[fd_idx++]);
+
+ for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+ g_variant_unref(fd_res_struct[k]);
+ }
+ idx++;
+ } while (0);
+
+ *_progress_size = (unsigned long long) g_variant_get_uint64(res_struct[idx++]);
+ *_total_size = (unsigned long long) g_variant_get_uint64(res_struct[idx++]);
+
+ for (size_t j = 0; j < service_adaptor_file_progress_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+
+void __get_file_transfer_state_changed_type(GVariant *parameters,
+ long long int *_file_uid,
+ int *_state)
+{
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ GVariant *res_struct[service_adaptor_file_transfer_state_changed_s_type_length];
+
+ for (size_t j = 0; j < service_adaptor_file_transfer_state_changed_s_type_length; j++) {
+ res_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ do {
+ GVariant *fd_res_struct[service_adaptor_file_descriptor_s_type_length];
+ for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+ fd_res_struct[k] = g_variant_get_child_value(res_struct[idx], k);
+ }
+ int fd_idx = 0;
+ *_file_uid = (long long int) g_variant_get_int64(fd_res_struct[fd_idx++]);
+
+ for (size_t k = 0; k < service_adaptor_file_descriptor_s_type_length; k++) {
+ g_variant_unref(fd_res_struct[k]);
+ }
+ idx++;
+ } while (0);
+
+ *_state = (int) g_variant_get_int32(res_struct[idx++]);
+
+ for (size_t j = 0; j < service_adaptor_file_transfer_state_changed_s_type_length; j++) {
+ g_variant_unref(res_struct[j]);
+ }
+}
+
+void __get_file_info_s_type(GVariant *call_result_struct,
+ service_storage_file_h *file_info)
+{
+ service_storage_file_h _file_info = NULL;
+ GVariant *res_info_struct[service_adaptor_file_info_s_type_length];
+
+ for (size_t j = 0; j < service_adaptor_file_info_s_type_length; j++) {
+ res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+ }
+
+ int idx1 = 0, idx2 = 0, idx3 = 0;
+ _file_info = service_storage_create_file_info();
+ if (NULL == _file_info) {
+ *file_info = NULL;
+
+ for (size_t j = 0; j < service_adaptor_file_info_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+ return;
+ }
+
+ _file_info->plugin_name = ipc_g_variant_dup_string(res_info_struct[idx1++]);
+ _file_info->object_id = ipc_g_variant_dup_string(res_info_struct[idx1++]);
+ _file_info->storage_path = ipc_g_variant_dup_string(res_info_struct[idx1++]);
+ _file_info->file_size = g_variant_get_uint64(res_info_struct[idx1++]);
+ _file_info->created_time = g_variant_get_uint64(res_info_struct[idx1++]);
+ _file_info->modified_time = g_variant_get_uint64(res_info_struct[idx1++]);
+ _file_info->file_info_index = g_variant_get_int32(res_info_struct[idx1++]);
+ _file_info->content_type = g_variant_get_int32(res_info_struct[idx1++]);
+
+ GVariant *media_meta_info[service_adaptor_content_meta_s_type_length];
+ do { /* get media_meta */
+ for (size_t k = 0; k < service_adaptor_content_meta_s_type_length; k++) {
+ media_meta_info[k] = g_variant_get_child_value(res_info_struct[idx1], k);
+ }
+
+ _file_info->media_meta->mime_type = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+ _file_info->media_meta->title = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+ _file_info->media_meta->album = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+ _file_info->media_meta->artist = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+ _file_info->media_meta->genere = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+ _file_info->media_meta->recorded_date = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+ _file_info->media_meta->width = g_variant_get_int32(media_meta_info[idx2++]);
+ _file_info->media_meta->height = g_variant_get_int32(media_meta_info[idx2++]);
+ _file_info->media_meta->duration = g_variant_get_int32(media_meta_info[idx2++]);
+ _file_info->media_meta->copyright = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+ _file_info->media_meta->track_num = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+ _file_info->media_meta->description = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+ _file_info->media_meta->composer = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+ _file_info->media_meta->year = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+ _file_info->media_meta->bitrate = g_variant_get_int32(media_meta_info[idx2++]);
+ _file_info->media_meta->samplerate = g_variant_get_int32(media_meta_info[idx2++]);
+ _file_info->media_meta->channel = g_variant_get_int32(media_meta_info[idx2++]);
+ _file_info->media_meta->extra_media_meta = ipc_g_variant_dup_string(media_meta_info[idx2++]);
+
+ for (size_t k = 0; k < service_adaptor_content_meta_s_type_length; k++) {
+ g_variant_unref(media_meta_info[k]);
+ }
+ } while (0);
+ idx1++;
+
+ GVariant *cloud_meta_info[service_adaptor_cloud_meta_s_type_length];
+ do { /* get cloud_meta */
+ for (size_t l = 0; l < service_adaptor_cloud_meta_s_type_length; l++) {
+ cloud_meta_info[l] = g_variant_get_child_value(res_info_struct[idx1], l);
+ }
+
+ _file_info->cloud_meta->service_name = ipc_g_variant_dup_string(cloud_meta_info[idx3++]);
+ _file_info->cloud_meta->usage_byte = g_variant_get_uint64(cloud_meta_info[idx3++]);
+ _file_info->cloud_meta->quota_byte = g_variant_get_uint64(cloud_meta_info[idx3++]);
+ _file_info->cloud_meta->extra_cloud_meta = ipc_g_variant_dup_string(cloud_meta_info[idx3++]);
+
+ for (size_t l = 0; l < service_adaptor_cloud_meta_s_type_length; l++) {
+ g_variant_unref(cloud_meta_info[l]);
+ }
+ } while (0);
+ idx1++;
+
+
+ _file_info->extra_file_info = ipc_g_variant_dup_string(res_info_struct[idx1++]);
+
+ for (size_t j = 0; j < service_adaptor_file_info_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+
+ *file_info = _file_info;
+}
+
+
+void __get_get_root_folder_path_res_type(GVariant *call_result_struct,
+ char **root_folder_path)
+{
+ GVariant *res_info_struct[service_adaptor_get_root_folder_path_res_s_type_length];
+
+ for (size_t j = 0; j < service_adaptor_get_root_folder_path_res_s_type_length; j++) {
+ res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+ }
+
+ int idx = 0;
+ *root_folder_path = ipc_g_variant_dup_string(res_info_struct[idx++]);
+
+ for (size_t j = 0; j < service_adaptor_get_root_folder_path_res_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+}
+
+void __get_get_file_list_res_type(GVariant *in_parameters,
+ service_storage_file_h **file_info_list,
+ unsigned int *file_info_list_len)
+{
+ GVariant *res_info_struct[service_adaptor_get_file_list_res_s_type_length];
+
+ for (size_t j = 0; j < service_adaptor_get_file_list_res_s_type_length; j++) {
+ res_info_struct[j] = g_variant_get_child_value(in_parameters, j);
+ }
+
+ int idx = 0;
+ gsize list_count = g_variant_n_children(res_info_struct[idx]);
+ *file_info_list = (service_storage_file_s **) calloc(list_count, sizeof(service_storage_file_s *));
+
+ if (NULL != *file_info_list) {
+ for (gsize i = 0; i < list_count; i++) {
+ GVariant *info_entry_v = g_variant_get_child_value(res_info_struct[idx], i);
+
+ __get_file_info_s_type(info_entry_v, &((*file_info_list)[i]));
+
+ g_variant_unref(info_entry_v);
+ }
+ idx++;
+ *file_info_list_len = g_variant_get_uint32(res_info_struct[idx++]);
+ } else {
+ *file_info_list_len = 0U;
+ }
+
+ for (size_t j = 0; j < service_adaptor_get_file_list_res_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+}
+
+void __get_file_descriptor_s_type(GVariant *call_result_struct,
+ long long int *_file_uid)
+{
+ GVariant *res_info_struct[service_adaptor_file_descriptor_s_type_length];
+
+ for (size_t j = 0; j < service_adaptor_file_descriptor_s_type_length; j++) {
+ res_info_struct[j] = g_variant_get_child_value(call_result_struct, j);
+ }
+
+ int idx = 0;
+ *_file_uid = (long long int) g_variant_get_int64(res_info_struct[idx++]);
+
+ for (size_t j = 0; j < service_adaptor_file_descriptor_s_type_length; j++) {
+ g_variant_unref(res_info_struct[j]);
+ }
+}
+
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+void on_storage_signal(GDBusProxy *proxy,
+ gchar *sender_name,
+ gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ if (0 == g_strcmp0(signal_name, DBUS_STORAGE_FILE_PROGRESS_SIGNAL)) {
+ long long int file_uid = 0;
+ unsigned long long progress_size = 0;
+ unsigned long long total_size = 0;
+
+ __get_file_progress_type(parameters, &file_uid, &progress_size, &total_size);
+
+ service_adaptor_task_h task = _queue_get_task(file_uid);
+
+ if (NULL == task) {
+ sac_warning("Callback task get failed");
+ return;
+ } else if (NULL == task->handle) {
+ sac_warning("Callback task->handle get failed");
+ return;
+ } else {
+ service_storage_task_h storage_task = (service_storage_task_h) task->handle;
+
+ if (NULL != storage_task->progress_callback) {
+ sac_debug("Call progress callback[%lld] (%llu/%llu byte)", file_uid, progress_size, total_size);
+ storage_task->progress_callback(progress_size, total_size, storage_task->progress_user_data);
+ }
+ }
+ } else if (0 == g_strcmp0(signal_name, DBUS_STORAGE_FILE_TRANSFER_STATE_CHANGED_SIGNAL)) {
+ long long int file_uid = 0;
+ int state = 0;
+
+ __get_file_transfer_state_changed_type(parameters, &file_uid, &state);
+
+ /* Convert to sac enum from sa enum */
+ service_storage_task_state_e _state;
+ switch (state) {
+ case SERVICE_ADAPTOR_FILE_TRANSFER_STATE_IN_PROGRESS:
+ _state = SERVICE_STORAGE_TASK_IN_PROGRESS;
+ break;
+ case SERVICE_ADAPTOR_FILE_TRANSFER_STATE_COMPLETED:
+ _state = SERVICE_STORAGE_TASK_COMPLETED;
+ break;
+ case SERVICE_ADAPTOR_FILE_TRANSFER_STATE_CANCELED:
+ _state = SERVICE_STORAGE_TASK_CANCELED;
+ break;
+ case SERVICE_ADAPTOR_FILE_TRANSFER_STATE_FAILED:
+ _state = SERVICE_STORAGE_TASK_FAILED;
+ break;
+ default:
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+ char *remote_call_message = ipc_g_variant_dup_string(call_result[1]);
+
+ service_adaptor_set_last_result((int) remote_call_result, remote_call_message);
+ free(remote_call_message);
+
+ service_adaptor_task_h task = _queue_get_task(file_uid);
+
+ if (NULL == task) {
+ sac_warning("Callback task get failed");
+ return;
+ } else if (NULL == task->handle) {
+ sac_warning("Callback task->handle get failed");
+ return;
+ } else {
+ service_storage_task_h storage_task = (service_storage_task_h) task->handle;
+
+ if (NULL != storage_task->state_callback) {
+ sac_debug("Call state callback[%lld] (%d state)", file_uid, _state);
+ storage_task->state_callback(_state, storage_task->state_user_data);
+ }
+ }
+ } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_STORAGE_FILE_PROGRESS_SIGNAL)) {
+/******************************************************************************
+ private feature
+******************************************************************************/
+ service_adaptor_file_h file_handle = NULL;
+ uint64_t progress_size = 0;
+ uint64_t total_size = 0;
+ service_adaptor_error_s *error_code = NULL;
+
+ __private_get_file_progress_type(parameters, &file_handle, &progress_size, &total_size);
+
+ service_adaptor_task_h task = _signal_queue_get_task(PRIVATE_SIGNAL_FILE_PROGRESS_ID);
+
+ if (NULL == task) {
+ free(file_handle);
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+ if (NULL != error_code) {
+ error_code->code = remote_call_result;
+ error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+ }
+ }
+
+ service_adaptor_file_progress_cb callback = (service_adaptor_file_progress_cb) task->callback;
+
+ if (NULL != callback) {
+ callback(task->handle, file_handle, progress_size, total_size, error_code, task->user_data);
+ }
+ if (NULL != error_code) {
+ free(error_code->msg);
+ free(error_code);
+ }
+ free(file_handle);
+ } else if (0 == g_strcmp0(signal_name, PRIVATE_DBUS_STORAGE_FILE_TRANSFER_COMPLETION_SIGNAL)) {
+ service_adaptor_file_h file_handle = NULL;
+ char *publish_url = NULL;
+ service_adaptor_error_s *error_code = NULL;
+
+ __private_get_file_transfer_completion_type(parameters, &file_handle, &publish_url);
+
+ service_adaptor_task_h task = _signal_queue_get_task(PRIVATE_SIGNAL_FILE_TRANSFER_COMPLETION_ID);
+
+ if (NULL == task) {
+ free(file_handle);
+ return;
+ }
+
+ GVariant *call_result[2];
+ call_result[0] = g_variant_get_child_value(parameters, 1);
+ call_result[1] = g_variant_get_child_value(parameters, 2);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result[0]);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error_code = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+
+ if (NULL != error_code) {
+ error_code->code = remote_call_result;
+ error_code->msg = ipc_g_variant_dup_string(call_result[1]);
+ }
+ }
+
+ service_adaptor_file_transfer_completion_cb callback = (service_adaptor_file_transfer_completion_cb) task->callback;
+
+ if (NULL != callback) {
+ callback(task->handle, file_handle, publish_url, error_code, task->user_data);
+ }
+ if (NULL != error_code) {
+ free(error_code->msg);
+ free(error_code);
+ }
+ free(file_handle);
+ }
+
+/******************************************************************************
+ private feature
+******************************************************************************/
+
+
+}
+
+/** @brief
+ * @return service_adaptor_error_s
+ * @remarks :
+ */
+int _dbus_download_file(const char *service_name,
+ const char *server_path,
+ const char *download_path,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == server_path) || (NULL == download_path)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), server_path, download_path);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_DOWNLOAD_FILE_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ ret = _ipc_get_simple_result(call_result, g_error, error);
+
+ return ret;
+}
+
+/** @brief
+ * @return service_adaptor_error_s
+ * @remarks :
+ */
+int _dbus_download_thumbnail(const char *service_name,
+ const char *server_path,
+ const char *download_path,
+ int thumbnail_size,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("(" service_adaptor_download_thumbnail_req_s_type ")", service_name, server_path, download_path, (int32_t)thumbnail_size);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_DOWNLOAD_THUMBNAIL_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ ret = _ipc_get_simple_result(call_result, g_error, error);
+
+ return ret;
+}
+
+int _dbus_upload_file(const char *service_name,
+ const char *upload_path,
+ const char *server_path,
+ service_storage_file_h *file_info,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+ service_storage_file_h _file_info = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == upload_path) || (NULL == server_path)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), upload_path, server_path);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_UPLOAD_FILE_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_info_s_type),
+ __get_file_info_s_type(call_result_struct[0], &_file_info);
+ *file_info = _file_info;
+ );
+
+ return ret;
+}
+
+int _dbus_get_root_folder_path(const char *service_name,
+ char **root_folder_path,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == root_folder_path)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" service_adaptor_get_root_folder_path_req_s_type ")", __safe_add_string(service_name));
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_GET_ROOT_FOLDER_PATH_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_get_root_folder_path_res_s_type),
+ __get_get_root_folder_path_res_type(call_result_struct[0], root_folder_path);
+ );
+
+ return ret;
+}
+
+
+int _dbus_make_directory(const char *service_name,
+ const char *folder_path,
+ service_storage_file_h *file_info,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+ service_storage_file_h _file_info = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == folder_path)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" service_adaptor_make_directory_req_s_type ")", service_name, folder_path);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_MAKE_DIRECTORY_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_info_s_type),
+ __get_file_info_s_type(call_result_struct[0], &_file_info);
+ *file_info = _file_info;
+ );
+
+ return ret;
+
+}
+
+int _dbus_remove_file(const char *service_name,
+ const char *file_path,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("(" service_adaptor_remove_file_req_s_type ")", service_name, file_path);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_REMOVE_FILE_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ ret = _ipc_get_simple_result(call_result, g_error, error);
+
+ return ret;
+
+
+}
+
+int _dbus_remove_directory(const char *service_name,
+ const char *folder_path,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("(" service_adaptor_remove_directory_req_s_type ")", service_name, folder_path);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_REMOVE_DIRECTORY_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ ret = _ipc_get_simple_result(call_result, g_error, error);
+
+ return ret;
+
+
+}
+
+int _dbus_move_file(const char *service_name,
+ const char *src_file_path,
+ const char *dst_file_path,
+ service_storage_file_h *file_info,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+ service_storage_file_h _file_info = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("(" service_adaptor_move_file_req_s_type ")",
+ service_name, src_file_path, dst_file_path);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_MOVE_FILE_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_info_s_type),
+ __get_file_info_s_type(call_result_struct[0], &_file_info);
+ *file_info = _file_info;
+ );
+
+ return ret;
+
+
+}
+
+int _dbus_move_directory(const char *service_name,
+ const char *src_folder_path,
+ const char *dst_folder_path,
+ service_storage_file_h *file_info,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+ service_storage_file_h _file_info = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("(" service_adaptor_move_directory_req_s_type ")", __safe_add_string(service_name), __safe_add_string(src_folder_path), __safe_add_string(dst_folder_path));
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_MOVE_DIRECTORY_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_info_s_type),
+ __get_file_info_s_type(call_result_struct[0], &_file_info);
+ *file_info = _file_info;
+ );
+
+ return ret;
+}
+
+int _dbus_get_file_list(const char *service_name,
+ const char *parent_path,
+ service_storage_file_h **file_info_list,
+ unsigned int *file_info_list_len,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("(" service_adaptor_get_file_list_req_s_type ")", service_name, parent_path);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_GET_FILE_LIST_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_get_file_list_res_s_type),
+ __get_get_file_list_res_type(call_result_struct[0], file_info_list, file_info_list_len);
+ );
+
+ return ret;
+}
+
+int _dbus_open_upload_file(const char *_service_name,
+ const char *_file_path,
+ const char *_upload_path,
+ long long int *_task_id,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("(" service_adaptor_open_upload_file_req_s_type ")", _service_name, _file_path, _upload_path);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_OPEN_UPLOAD_FILE_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_descriptor_s_type),
+ long long int file_uid = 0;
+ __get_file_descriptor_s_type(call_result_struct[0], &file_uid);
+ *_task_id = file_uid;
+ );
+
+ return ret;
+}
+
+int _dbus_open_download_file(const char *_service_name,
+ const char *_storage_path,
+ const char *_download_path,
+ long long int *_task_id,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("(" service_adaptor_open_download_file_req_s_type ")", _service_name, _storage_path, _download_path);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_OPEN_DOWNLOAD_FILE_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_descriptor_s_type),
+ long long int file_uid = 0;
+ __get_file_descriptor_s_type(call_result_struct[0], &file_uid);
+ *_task_id = file_uid;
+ );
+
+ return ret;
+}
+
+int _dbus_open_download_thumbnail(const char *_service_name,
+ const char *_storage_path,
+ const char *_download_path,
+ int _thumbnail_size,
+ long long int *_task_id,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("(" service_adaptor_open_download_thumbnail_req_s_type ")", _service_name, _storage_path, _download_path, _thumbnail_size);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_OPEN_DOWNLOAD_THUMBNAIL_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(service_adaptor_file_descriptor_s_type),
+ long long int file_uid = 0;
+ __get_file_descriptor_s_type(call_result_struct[0], &file_uid);
+ *_task_id = file_uid;
+ );
+
+ return ret;
+}
+
+int __dbus_send_simple_fd_for_task(GVariant *request,
+ const char *_method_name,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ _method_name,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ ret = _ipc_get_simple_result(call_result, g_error, error);
+
+ return ret;
+}
+
+
+int _dbus_close_file_task(const char *_service_name,
+ long long int _task_id,
+ service_adaptor_error_s *error)
+{
+ GVariant *request = g_variant_new("("service_adaptor_close_file_req_s_type")", _service_name, (int64_t)_task_id);
+
+ return __dbus_send_simple_fd_for_task(request, DBUS_CLOSE_FILE_METHOD, error);
+}
+
+int _dbus_cancel_upload_file(const char *_service_name,
+ long long int _task_id,
+ service_adaptor_error_s *error)
+{
+ GVariant *request = g_variant_new("("service_adaptor_cancel_file_task_req_s_type")", _service_name, (int64_t)_task_id);
+
+ return __dbus_send_simple_fd_for_task(request, DBUS_CANCEL_UPLOAD_FILE_METHOD, error);
+}
+
+int _dbus_cancel_download_file(const char *_service_name,
+ long long int _task_id,
+ service_adaptor_error_s *error)
+{
+ GVariant *request = g_variant_new("("service_adaptor_cancel_file_task_req_s_type")", _service_name, (int64_t)_task_id);
+
+ return __dbus_send_simple_fd_for_task(request, DBUS_CANCEL_DOWNLOAD_FILE_METHOD, error);
+}
+
+int _dbus_cancel_download_thumbnail(const char *_service_name,
+ long long int _task_id,
+ service_adaptor_error_s *error)
+{
+ GVariant *request = g_variant_new("("service_adaptor_cancel_file_task_req_s_type")", _service_name, (int64_t)_task_id);
+
+ return __dbus_send_simple_fd_for_task(request, DBUS_CANCEL_DOWNLOAD_THUMBNAIL_METHOD, error);
+}
+
+
+
+
+
+int _dbus_start_upload_file(const char *_service_name,
+ long long int _task_id,
+ const char *_storage_path,
+ bool _need_progress,
+ bool _need_state,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("("service_adaptor_start_upload_file_req_s_type")", _service_name, (int64_t)_task_id, _storage_path, _need_progress, _need_state);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_START_UPLOAD_FILE_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ ret = _ipc_get_simple_result(call_result, g_error, error);
+
+ return ret;
+}
+
+
+int _dbus_start_download_file(const char *_service_name,
+ long long int _task_id,
+ const char *_storage_path,
+ bool _need_progress,
+ bool _need_state,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("("service_adaptor_start_download_file_req_s_type")", _service_name, (int64_t)_task_id, _storage_path, _need_progress, _need_state);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_START_DOWNLOAD_FILE_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ ret = _ipc_get_simple_result(call_result, g_error, error);
+
+ return ret;
+}
+
+
+int _dbus_start_download_thumbnail(const char *_service_name,
+ long long int _task_id,
+ const char *_storage_path,
+ int _thumbnail_size,
+ bool _need_progress,
+ bool _need_state,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ GVariant *request = g_variant_new("("service_adaptor_start_download_thumbnail_req_s_type")", _service_name, (int64_t)_task_id, _storage_path, (int32_t)_thumbnail_size, _need_progress, _need_state);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ DBUS_START_DOWNLOAD_THUMBNAIL_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ ret = _ipc_get_simple_result(call_result, g_error, error);
+
+ return ret;
+}
+
+
+/******************************************************************************
+ private feature
+******************************************************************************/
+
+
+int _private_dbus_upload_file_async(const char *service_name,
+ const char *upload_path,
+ const char *server_path,
+ service_adaptor_file_h *file_handle,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == upload_path) || (NULL == server_path)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), upload_path, server_path);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_UPLOAD_FILE_ASYNC_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_s_type),
+ __private_get_file_handle_res_type(call_result_struct[0], file_handle, error, &ret);
+ );
+
+ return ret;
+}
+
+
+
+int _private_dbus_download_file_async(const char *service_name,
+ const char *server_path,
+ const char *download_path,
+ service_adaptor_file_h *file_handle,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == server_path) || (NULL == download_path)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), server_path, download_path);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_DOWNLOAD_FILE_ASYNC_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_s_type),
+ __private_get_file_handle_res_type(call_result_struct[0], file_handle, error, &ret);
+ );
+
+ return ret;
+}
+
+
+
+
+/** @brief
+ * @return service_adaptor_error_s
+ * @remarks :
+ */
+int _dbus_download_file_publish(const char *service_name,
+ const char *server_path,
+ const char *download_path,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == server_path) || (NULL == download_path)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), server_path, download_path);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_DOWNLOAD_FILE_PUBLISH_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ ret = _ipc_get_simple_result(call_result, g_error, error);
+
+ return ret;
+}
+
+int _dbus_download_file_publish_async(const char *service_name,
+ const char *server_path,
+ const char *download_path,
+ service_adaptor_file_h *file_handle,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == server_path) || (NULL == download_path)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), server_path, download_path);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_DOWNLOAD_FILE_PUBLISH_ASYNC_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_s_type),
+ __private_get_file_handle_res_type(call_result_struct[0], file_handle, error, &ret);
+ );
+
+ return ret;
+}
+
+int _dbus_upload_file_publish(const char *service_name,
+ const char *upload_path,
+ const char *server_path,
+ char **publish_url,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == upload_path) || (NULL == server_path)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), upload_path, server_path);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_UPLOAD_FILE_PUBLISH_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_publish_s_type),
+ if (NULL != publish_url) {
+ GVariant *url = g_variant_get_child_value(call_result_struct[0], 0);
+ *publish_url = ipc_g_variant_dup_string(url);
+ }
+ );
+
+ return ret;
+}
+
+int _dbus_upload_file_publish_async(const char *service_name,
+ const char *upload_path,
+ const char *server_path,
+ service_adaptor_file_h *file_handle,
+ void *user_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == upload_path) || (NULL == server_path)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_file_transfer_req_s_type ")", __safe_add_string(service_name), upload_path, server_path);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_UPLOAD_FILE_PUBLISH_ASYNC_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_s_type),
+ __private_get_file_handle_res_type(call_result_struct[0], file_handle, error, &ret);
+ );
+
+ return ret;
+}
+
+int _dbus_get_file_status(const char *service_name,
+ service_adaptor_file_h file_handle,
+ service_adaptor_file_status_s **status,
+ void **server_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == file_handle)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_file_status_req_s_type ")", __safe_add_string(service_name), file_handle->file_description);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_GET_FILE_STATUS_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ _ipc_get_complex_result(MAKE_RETURN_TYPE(private_service_adaptor_file_status_res_s_type),
+ if (NULL != status) {
+ __private_get_file_status_res_type(call_result_struct[0], status, server_data);
+ }
+ );
+
+ return ret;
+}
+
+int _dbus_cancel_file_transfer(const char *service_name,
+ service_adaptor_file_h file_handle,
+ void **server_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == file_handle)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_file_status_req_s_type ")", __safe_add_string(service_name), file_handle->file_description);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_CANCEL_FILE_TRANSFER_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ ret = _ipc_get_simple_result(call_result, g_error, error);
+
+ return ret;
+}
+
+int _dbus_pause_file_transfer(const char *service_name,
+ service_adaptor_file_h file_handle,
+ void **server_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == file_handle)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_file_status_req_s_type ")", __safe_add_string(service_name), file_handle->file_description);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_PAUSE_FILE_TRANSFER_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ ret = _ipc_get_simple_result(call_result, g_error, error);
+
+ return ret;
+}
+
+int _dbus_resume_file_transfer(const char *service_name,
+ service_adaptor_file_h file_handle,
+ void **server_data,
+ service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ GError *g_error = NULL;
+ GVariant *call_result = NULL;
+
+ GDBusProxy *sac_interface_proxy = _dbus_get_sac_interface_proxy();
+
+ ipc_check_proxy(sac_interface_proxy);
+
+ if ((NULL == service_name) || (NULL == file_handle)) {
+ error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error->msg = strdup("Invalid Param");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ GVariant *request = g_variant_new("(" private_service_adaptor_file_status_req_s_type ")", __safe_add_string(service_name), file_handle->file_description);
+
+ call_result = g_dbus_proxy_call_sync(sac_interface_proxy,
+ PRIVATE_DBUS_RESUME_FILE_TRANSFER_METHOD,
+ request,
+ G_DBUS_CALL_FLAGS_NONE,
+ G_MAXINT,
+ NULL,
+ &g_error);
+
+ ret = _ipc_get_simple_result(call_result, g_error, error);
+
+ return ret;
+}
+
+
+/******************************************************************************
+ private feature
+******************************************************************************/
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <fcntl.h>
+
+#include <glib.h>
+#include <tizen.h>
+/*#include <security-server.h>*/
+/* #include <app.h> */
+#include <app_common.h>
+/* #include <app_manager.h> */
+
+#include <dbus-server.h>
+
+#include "service_adaptor_client.h"
+#include "service_adaptor_client_plugin.h"
+#include "service_adaptor_client_private.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "dbus_client.h"
+#include "dbus_client_layer.h"
+
+#include "util/service_adaptor_client_util.h"
+/************************* private feature */
+#include "private/service-adaptor-client.h"
+/************************* private feature */
+
+#define ERROR_MSG_MAX_LEN 2048
+
+static __thread int last_error_code = 0;
+static __thread char last_error_message[ERROR_MSG_MAX_LEN] = "";
+
+/**
+ * Work Queue about async functions
+ */
+GList *g_service_adaptor_task_queue = NULL;
+GList *g_service_adaptor_signal_queue = NULL;
+
+/**
+ * Connection counter. It is needed to allow multiple connections from single process.
+ */
+static int connections_counter = 0;
+
+static GMutex connections_counter_mutex;
+
+static service_adaptor_h g_service_adaptor = NULL;
+
+#ifdef __DEBUG_GLIB_ERROR
+static void __glog_handler_cb(const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *message,
+ gpointer user_data)
+{
+ sac_error("============================================================");
+ sac_error("============================================================");
+ sac_error("================== Critical GLib Error =====================");
+ sac_error("============================================================");
+ sac_error("============================================================");
+ sac_error("=== Log Domain : %s", log_domain);
+ sac_error("=== Level : %d", (int)log_level);
+ sac_error("=== Message : %s", message);
+ sac_error("============================================================");
+ sac_error("============================================================");
+}
+
+static void glog_handler_init()
+{
+ sac_info("glib log handler init : %d",
+ (int)g_log_set_handler("GLib", G_LOG_LEVEL_CRITICAL, __glog_handler_cb, NULL));
+}
+#endif
+
+/** @brief Adds Task in Queue
+ * @return int
+ * @remarks :
+ */
+int _queue_add_task(int64_t _id,
+ uint32_t _callback,
+ void *_handle,
+ void *user_data)
+{
+ FUNC_START();
+
+ service_adaptor_task_h task = (service_adaptor_task_h) g_malloc0(sizeof(service_adaptor_task_s));
+
+ if (NULL == task) {
+ FUNC_STOP();
+ return -1;
+ }
+
+ task->id = _id;
+ task->callback = _callback;
+ task->handle = _handle;
+ task->user_data = user_data;
+
+ g_service_adaptor_task_queue = g_list_append(g_service_adaptor_task_queue, task);
+
+ FUNC_END();
+ return 0;
+}
+
+/** @brief Adds Task in Queue
+ * @return int
+ * @remarks :
+ */
+int _queue_del_task(service_adaptor_task_h _task)
+{
+ FUNC_START();
+ service_adaptor_task_h target = NULL;
+
+ for (GList *list = g_list_first(g_service_adaptor_task_queue); list != NULL; list = g_list_next(list)) {
+ service_adaptor_task_h data = (service_adaptor_task_h) list->data;
+
+ if ((NULL != data) && (_task == data)) {
+ target = data;
+ break;
+ }
+ }
+
+ if (NULL != target) {
+ g_service_adaptor_task_queue = g_list_remove(g_service_adaptor_task_queue, target);
+ g_free(target);
+ target = NULL;
+ }
+
+ FUNC_END();
+ return 0;
+}
+
+/** @brief Adds Task in Queue
+ * @return service_adaptor_task_h
+ * @remarks :
+ */
+service_adaptor_task_h _queue_get_task(int64_t id)
+{
+ FUNC_START();
+ service_adaptor_task_h target = NULL;
+
+ for (GList *list = g_list_first(g_service_adaptor_task_queue); list != NULL; list = g_list_next(list)) {
+ service_adaptor_task_h data = (service_adaptor_task_h) list->data;
+
+ if ((NULL != data) && (id == data->id)) {
+ target = data;
+ break;
+ }
+ }
+
+ FUNC_END();
+ return target;
+}
+
+/** @brief Clears Task in Queue
+ * @return void
+ * @remarks :
+ */
+void _queue_clear_task()
+{
+ FUNC_START();
+ if (NULL != g_service_adaptor_task_queue) {
+ g_list_free(g_service_adaptor_task_queue);
+ }
+ g_service_adaptor_task_queue = NULL;
+}
+
+/** @brief Adds Task in Queue
+ * @return int
+ * @remarks :
+ */
+int _signal_queue_add_task(int64_t _id,
+ uint32_t _callback,
+ void *_handle,
+ void *user_data)
+{
+ FUNC_START();
+
+ service_adaptor_task_h task = (service_adaptor_task_h) g_malloc0(sizeof(service_adaptor_task_s));
+
+ if (NULL == task) {
+ FUNC_STOP();
+ return -1;
+ }
+
+ task->id = _id;
+ task->callback = _callback;
+ task->handle = _handle;
+ task->user_data = user_data;
+
+ g_service_adaptor_signal_queue = g_list_append(g_service_adaptor_signal_queue, task);
+
+ FUNC_END();
+ return 0;
+}
+
+/** @brief Adds Task in Queue
+ * @return service_adaptor_task_h
+ * @remarks :
+ */
+service_adaptor_task_h _signal_queue_get_task(int64_t _id)
+{
+ FUNC_START();
+ service_adaptor_task_h target = NULL;
+
+ for (GList *list = g_list_first(g_service_adaptor_signal_queue); list != NULL; list = g_list_next(list)) {
+ service_adaptor_task_h data = (service_adaptor_task_h) list->data;
+
+ if ((NULL != data) && (_id == data->id)) {
+ target = data;
+ break;
+ }
+ }
+
+ FUNC_END();
+ return target;
+}
+
+/** @brief Adds Task in Queue
+ * @return int
+ * @remarks :
+ */
+int _signal_queue_del_task(service_adaptor_task_h _task)
+{
+ FUNC_START();
+ service_adaptor_task_h target = NULL;
+
+ for (GList *list = g_list_first(g_service_adaptor_signal_queue); list != NULL; list = g_list_next(list)) {
+ service_adaptor_task_h data = (service_adaptor_task_h) list->data;
+
+ if ((NULL != data) && (_task == data)) {
+ target = data;
+ break;
+ }
+ }
+
+ if (NULL != target) {
+ g_service_adaptor_signal_queue = g_list_remove(g_service_adaptor_signal_queue, target);
+ g_free(target);
+ target = NULL;
+ }
+
+ FUNC_END();
+ return 0;
+}
+
+/** @brief Adds Task in Queue
+ * @return int
+ * @remarks :
+ */
+int _signal_queue_del_task_by_id(int id)
+{
+ FUNC_START();
+ service_adaptor_task_h target = NULL;
+
+ int i, len = g_list_length(g_service_adaptor_signal_queue);
+ for (i = 0; i < len; i++) {
+ for (GList *list = g_list_first(g_service_adaptor_signal_queue); list != NULL; list = g_list_next(list)) {
+ service_adaptor_task_h data = (service_adaptor_task_h) list->data;
+
+ if ((NULL != data) && (id == data->id)) {
+ target = data;
+ break;
+ }
+ }
+
+ if (NULL != target) {
+ g_service_adaptor_signal_queue = g_list_remove(g_service_adaptor_signal_queue, target);
+ g_free(target);
+ }
+ }
+
+ FUNC_END();
+ return 0;
+}
+
+/** @brief Clears Task in Queue
+ * @return void
+ * @remarks :
+ */
+void _signal_queue_clear_task()
+{
+ FUNC_START();
+ if (NULL != g_service_adaptor_signal_queue) {
+ g_list_free(g_service_adaptor_signal_queue);
+ }
+ g_service_adaptor_signal_queue = NULL;
+ FUNC_END();
+}
+
+int service_adaptor_check_handle_validate(service_adaptor_h handle)
+{
+ if ((NULL == handle) || (NULL == g_service_adaptor)) {
+ sac_error("The handle is invalid <user(%p) adaptor(%p)>", handle, g_service_adaptor);
+ return -1;
+ } else if (handle != g_service_adaptor) {
+ sac_error("The handle is invalid <user(%p) adaptor(%p)>", handle, g_service_adaptor);
+ return -2;
+ } else {
+ return 0;
+ }
+}
+
+void _service_adaptor_set_last_result(int code, const char *message)
+{
+ FUNC_START();
+ last_error_code = code;
+
+ memset(last_error_message, 0x00, ERROR_MSG_MAX_LEN);
+
+ if (NULL != message) {
+ strncpy(last_error_message, message, ERROR_MSG_MAX_LEN-1);
+ }
+ FUNC_END();
+}
+
+int service_adaptor_get_last_result(int *err)
+{
+ FUNC_START();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if (NULL == err) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+ *err = last_error_code;
+
+ FUNC_END();
+ return ret;
+}
+
+int service_adaptor_get_last_error_message(char **message)
+{
+ FUNC_START();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if (NULL == message) {
+ ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ } else if (0 >= strlen(last_error_message)) {
+ ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
+ } else {
+ *message = strdup(last_error_message);
+ ret = SERVICE_ADAPTOR_ERROR_NONE;
+ }
+
+ FUNC_END();
+ return ret;
+}
+
+/** @brief Connects Service Adaptor
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_create(service_adaptor_h *handle)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_h service = NULL;
+
+#ifdef __DEBUG_GLIB_ERROR
+ glog_handler_init();
+#endif
+
+ g_mutex_lock(&connections_counter_mutex);
+
+ if (NULL == handle) {
+ g_mutex_unlock(&connections_counter_mutex);
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (0 < connections_counter) {
+ g_mutex_unlock(&connections_counter_mutex);
+
+ return SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED;
+ }
+
+ service = (service_adaptor_h) calloc(1, sizeof(service_adaptor_s));
+
+ if (NULL == service) {
+ service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_UNKNOWN, "Memory allocation failed");
+ g_mutex_unlock(&connections_counter_mutex);
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+/*
+ int trd = 0;
+ char fingerprint[50] = {0, };
+ snprintf(fingerprint, 50, "%s/%d", SERVICE_ADAPTOR_START_KEY_PATH, getpid());
+ sac_debug("Trigger open : %s", fingerprint);
+ trd = open(fingerprint, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
+ if (0 > trd) {
+ sac_error("Trigger open failed (%d)", trd);
+ free(service);
+ g_mutex_unlock(&connections_counter_mutex);
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+*/
+ int dbus_ret = _dbus_client_layer_init();
+
+ if (0 == dbus_ret) {
+ connections_counter = connections_counter + 1;
+ }
+
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ ret = _dbus_connect_service_adaptor(&error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(service);
+/*
+ close(trd);
+ remove(fingerprint);
+*/
+ g_mutex_unlock(&connections_counter_mutex);
+ free(error.msg);
+ return ret;
+ }
+
+ service->on_signal = NULL;
+
+/* service->plugins = NULL; */
+/* service->plugin_count = 0; */
+
+ *handle = service;
+ g_service_adaptor = service;
+/*
+ close(trd);
+ remove(fingerprint);
+*/
+ g_mutex_unlock(&connections_counter_mutex);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Disconnects Service Adaptor
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_destroy(service_adaptor_h handle)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if (NULL == handle) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ g_mutex_lock(&connections_counter_mutex);
+
+ if (0 >= connections_counter) {
+ connections_counter = 0;
+ g_service_adaptor = NULL;
+ g_mutex_unlock(&connections_counter_mutex);
+
+ ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ return ret;
+ }
+
+ if (NULL != handle) {
+ free(handle);
+ handle = NULL;
+ }
+
+ connections_counter = connections_counter - 1;
+
+ if (0 == connections_counter) {
+ _dbus_client_layer_deinit();
+ }
+
+ g_service_adaptor = NULL;
+ g_mutex_unlock(&connections_counter_mutex);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Connects Service Adaptor
+ * @return int
+ * @remarks :
+ */
+int service_adaptor_set_state_changed_cb(service_adaptor_h handle,
+ service_adaptor_signal_cb callback,
+ void *user_data)
+{
+ FUNC_START();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if (NULL == handle) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->on_signal = callback;
+ _signal_queue_add_task(SIGNAL_SERVICE_ADAPTOR, (uint32_t) callback, handle, user_data);
+
+ FUNC_END();
+ return ret;
+}
+
+int service_adaptor_unset_state_changed_cb(service_adaptor_h handle)
+{
+ FUNC_START();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if (NULL == handle) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ handle->on_signal = NULL;
+
+ FUNC_END();
+ return ret;
+}
+
+
+int service_adaptor_foreach_plugin(service_adaptor_h handle,
+ service_adaptor_plugin_cb callback,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ if (NULL == handle) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+ if (NULL == callback) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ plugin_entry_t **plugin_uris = NULL;
+ unsigned int plugins_len = 0;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+ ret = _dbus_get_plugin_list(&plugin_uris, &plugins_len, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ } else if ((NULL != plugin_uris) && (0 < plugins_len)) {
+ int i;
+ bool is_continue = true;
+ for (i = 0; i < plugins_len; i++) {
+ if (is_continue) {
+ is_continue = callback(plugin_uris[i]->plugin_uri, plugin_uris[i]->installed_mask, user_data);
+ }
+ free(plugin_uris[i]->plugin_uri);
+ free(plugin_uris[i]);
+ }
+ } else {
+ ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
+ }
+ free(plugin_uris);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_adaptor_create_plugin(service_adaptor_h handle,
+ const char *plugin_uri,
+ service_plugin_h *plugin)
+{
+ sac_info("API Called <%s>", __FUNCTION__);
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ if ((NULL == handle) || (NULL == plugin) || (NULL == plugin_uri)) {
+ ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ } else {
+ service_plugin_h _plugin = (service_plugin_h) calloc(1, sizeof(service_plugin_s));
+ char *_plugin_uri = strdup(plugin_uri);
+ if ((NULL != _plugin) && (NULL != _plugin_uri)) {
+ _plugin->adaptor = handle;
+ _plugin->service_handle_name = NULL;
+ _plugin->optional_property = (void *)g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
+
+ _plugin->plugin_uri = _plugin_uri;
+ _plugin->enabled_mask = 0;
+
+ *plugin = _plugin;
+ } else {
+ free(_plugin);
+ free(_plugin_uri);
+ sac_error("Critical : Memory allocation failed.");
+ ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_plugin_destroy(service_plugin_h plugin)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ if (NULL == plugin) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ } else {
+ plugin->adaptor = NULL;
+ if (NULL != plugin->optional_property) {
+ g_hash_table_destroy((GHashTable *)(plugin->optional_property));
+ plugin->optional_property = NULL;
+ }
+ free(plugin->service_handle_name);
+ free(plugin->plugin_uri);
+ free(plugin);
+ }
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_plugin_add_property(service_plugin_h handle,
+ const char *key,
+ const char *value)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ if ((NULL == handle) || (NULL == handle->optional_property)) {
+ ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ } else if ((NULL == key) || (0 >= strlen(key))) {
+ ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ } else if ((NULL == value) || (0 >= strlen(value))) {
+ ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ } else {
+ g_hash_table_insert((GHashTable *)(handle->optional_property), strdup(key), strdup(value));
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_plugin_remove_property(service_plugin_h handle,
+ const char *key)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ if ((NULL == handle) || (NULL == handle->optional_property)) {
+ ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ } else if ((NULL == key) || (0 >= strlen(key))) {
+ ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ } else {
+ g_hash_table_remove((GHashTable *)(handle->optional_property), key);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_plugin_get_property(service_plugin_h handle,
+ const char *key,
+ char **value)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ if (NULL == handle) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if ((NULL == key) || (0 >= strlen(key)) || (NULL == value)) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ void *property = (void *)g_hash_table_lookup((GHashTable *)(handle->optional_property), (gconstpointer *)key);
+ if (NULL == property) {
+ ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
+ } else {
+ *value = strdup((char *) property);
+ }
+/*
+ GHashTableIter iter;
+ gpointer iter_key;
+ gpointer iter_value;
+ g_hash_table_iter_init(&iter, (GHashTable *)(handle->optional_property));
+ while (g_hash_table_iter_next(&iter, &iter_key, &iter_value)) {
+ if (NULL != iter_key) {
+ if (0 == strcmp((char *)iter_key, key)) {
+ ret = SERVICE_ADAPTOR_ERROR_NONE;
+ *value = strdup((char *)iter_value);
+ break;
+ }
+ }
+ }
+*/
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_plugin_start(service_plugin_h handle,
+ int service_flag)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ int app_ret = 0;
+ char *service_handle_name = NULL;
+ char security_cookie[SECURITY_SERVER_COOKIE_BUFFER_SIZE] = {0, };
+
+ char *tizen_app_id = NULL;
+ char *type = NULL;
+
+ if (NULL == handle) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ app_ret = app_get_id(&tizen_app_id);
+
+ if (app_ret || (NULL == tizen_app_id)) {
+ char executable_path[1000];
+ int executable_path_len = 0;
+ executable_path_len = readlink("/proc/self/exe", executable_path, 1000);
+ tizen_app_id = strndup(executable_path, executable_path_len);
+ type = strdup("etc");
+ handle->app_type = CLIENT_APP_TYPE_ETC;
+ } else {
+ type = strdup("app");
+ handle->app_type = CLIENT_APP_TYPE_APPLICATION;
+ }
+
+ if (NULL == tizen_app_id) {
+ free(type);
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+
+ service_handle_name = g_strconcat(tizen_app_id, "?type=", type, "&plugin=", handle->plugin_uri, NULL);
+
+ free(tizen_app_id);
+ free(type);
+
+ if (NULL == service_handle_name) {
+ sac_error("handle name get failed");
+ service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_UNKNOWN, "handle name get failed");
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+
+ /* TODO replace to real cookie */
+ snprintf(security_cookie, SECURITY_SERVER_COOKIE_BUFFER_SIZE, "%020d", (int)getpid());
+/*
+ int sec_ret = security_server_request_cookie(security_cookie, SECURITY_SERVER_COOKIE_BUFFER_SIZE);
+ sac_debug_func("security_cookie : %s (%d)", security_cookie, sec_ret);
+
+ if (('\0' == security_cookie[0]) || sec_ret) {
+ sac_error("cookie get failed");
+ service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_UNKNOWN, "security cookie get failed");
+ free(service_handle_name);
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+*/
+
+ handle->service_handle_name = service_handle_name;
+ sac_info("handle name :%s", handle->service_handle_name);
+ sac_info("uri :%s mask : %d", handle->plugin_uri, handle->enabled_mask);
+
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ ret = _dbus_start_service(handle, service_flag, security_cookie, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_plugin_stop(service_plugin_h handle)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ if (NULL == handle) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+
+int service_plugin_is_login_required(service_plugin_h plugin,
+ bool *required)
+{
+ sac_api_start();
+ sac_check_param_null(plugin, "plugin");
+ sac_check_param_null(required, "required");
+
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error = {0ULL, NULL};
+ bool _required = false;
+
+ ret = _dbus_is_login_required(plugin, &_required, &error);
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_plugin_request_login(service_plugin_h plugin,
+ service_plugin_login_cb callback,
+ void *user_data)
+{
+ sac_api_start();
+ sac_check_param_null(plugin, "plugin");
+ sac_check_param_null(callback, "callback");
+
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error = {0ULL, NULL};
+
+ ret = _dbus_request_login(plugin, (void *)callback, user_data, &error);
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/************************* private feature */
+
+/** @brief Connects Service Adaptor
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_connect(service_adaptor_h *handle,
+ service_adaptor_signal_cb callback)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_h service = NULL;
+
+#ifdef __DEBUG_GLIB_ERROR
+ glog_handler_init();
+#endif
+
+ g_mutex_lock(&connections_counter_mutex);
+
+ if (NULL == handle) {
+ g_mutex_unlock(&connections_counter_mutex);
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (0 < connections_counter) {
+ sac_error("Handle already connected");
+ g_mutex_unlock(&connections_counter_mutex);
+
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+
+ service = (service_adaptor_h) calloc(1, sizeof(service_adaptor_s));
+
+ if (NULL == service) {
+ service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_UNKNOWN, "Memory allocation failed");
+ g_mutex_unlock(&connections_counter_mutex);
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+/*
+ int trd = 0;
+ char fingerprint[50] = {0, };
+ snprintf(fingerprint, 50, "%s/%d", SERVICE_ADAPTOR_START_KEY_PATH, getpid());
+ sac_debug("Trigger open : %s", fingerprint);
+ trd = open(fingerprint, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
+ if (0 > trd) {
+ sac_error("Trigger open failed (%d)", trd);
+ free(service);
+ g_mutex_unlock(&connections_counter_mutex);
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+*/
+ int dbus_ret = _dbus_client_layer_init();
+
+ if (0 == dbus_ret) {
+ sac_info("Proxy creation success");
+ }
+
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ ret = _dbus_connect_service_adaptor(&error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(service);
+/*
+ close(trd);
+ remove(fingerprint);
+*/
+ g_mutex_unlock(&connections_counter_mutex);
+ free(error.msg);
+ return ret;
+ }
+
+ service->service_name = NULL;
+ service->user_id = NULL;
+ service->app_id = NULL;
+ service->service_id = 0;
+ service->imsi = NULL;
+ service->on_signal = callback;
+ service->plugin = NULL;
+ g_mutex_init(&service->set_auth_mutex);
+
+ *handle = service;
+ g_service_adaptor = service;
+ sac_info("Connects success handle (%p) instance (%p)", handle, service);
+ connections_counter = connections_counter + 1;
+
+ _signal_queue_add_task(SIGNAL_SERVICE_ADAPTOR, (uint32_t) callback, *handle, NULL);
+/*
+ close(trd);
+ remove(fingerprint);
+*/
+ g_mutex_unlock(&connections_counter_mutex);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Disconnects Service Adaptor
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_disconnect(service_adaptor_h handle)
+{
+ sac_api_start();
+ if (NULL == handle) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ g_mutex_lock(&connections_counter_mutex);
+
+ if (0 >= connections_counter) {
+ connections_counter = 0;
+ g_service_adaptor = NULL;
+ g_mutex_unlock(&connections_counter_mutex);
+
+ ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ return ret;
+ }
+
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ ret = _dbus_disconnect_service_adaptor(&error);
+ if (ret) {
+ sac_error("disconnect error : %s", error.msg);
+ free(error.msg);
+ error.msg = NULL;
+ }
+
+ if (NULL != handle) {
+ __SAFE_FREE(handle->service_name);
+ __SAFE_FREE(handle->user_id);
+
+ __SAFE_FREE(handle->app_id);
+ __SAFE_FREE(handle->imsi);
+
+ if (NULL != handle->plugin) {
+ __SAFE_FREE(handle->plugin->name);
+ }
+
+ __SAFE_FREE(handle->plugin);
+ handle->on_signal = NULL;
+ __SAFE_FREE(handle);
+ }
+
+ connections_counter = connections_counter - 1;
+
+ if (0 == connections_counter) {
+ _dbus_client_layer_deinit();
+ }
+
+ g_service_adaptor = NULL;
+ g_mutex_unlock(&connections_counter_mutex);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Sets IMSI
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_imsi(service_adaptor_h handle,
+ const char *imsi)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if ((NULL == handle) || (NULL == imsi)) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL != handle->imsi) {
+ free(handle->imsi);
+ handle->imsi = NULL;
+ }
+
+ handle->imsi = _safe_strdup(imsi);
+ if (NULL == handle->imsi) {
+ ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_adaptor_set_plugin(service_adaptor_h handle,
+ const char *plugin_uri)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if ((NULL == handle) || (NULL == plugin_uri)) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ service_adaptor_plugin_h plugin = NULL;
+ plugin = (service_adaptor_plugin_h) calloc(1, sizeof(service_adaptor_plugin_s));
+ char *_plugin_uri = strdup(plugin_uri);
+ if ((NULL == plugin) || (NULL == _plugin_uri)){
+ free(plugin);
+ free(_plugin_uri);
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+
+ plugin->name = _plugin_uri;
+ plugin->login = true;
+
+ handle->plugin = plugin;
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Free plugins
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_free_plugins(service_adaptor_plugin_h * plugins,
+ unsigned int plugins_len)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ if ((NULL == plugins) || (0U == plugins_len)) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ for (int i = 0; i < plugins_len; i++) {
+ if (NULL == plugins[i]) {
+ continue;
+ }
+
+ free(plugins[i]->name);
+ free(plugins[i]);
+ }
+
+ free(plugins);
+ plugins = NULL;
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_adaptor_external_request(service_adaptor_h handle,
+ int service_flag,
+ const char *api_uri,
+ bundle *in_params,
+ bundle **out_params)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (0 == service_flag) || (NULL == api_uri) || (NULL == in_params) || (NULL == out_params)) {
+ service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER,
+ "Invalid Argument : Not null params");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (service_adaptor_check_handle_validate(handle)) {
+ service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle (Not connected handle)");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+/*
+ if (NULL == handle->service_name) {
+ service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid State");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+*/
+
+ unsigned char *input_str = NULL;
+ unsigned char *output_str = NULL;
+ int input_len = 0;
+ int output_len = 0;
+
+ ret = bundle_encode(in_params, &input_str, &input_len);
+
+ ret = _dbus_external_request(sac_safe_add_string(handle->service_name), service_flag, api_uri, input_str, input_len, &output_str, &output_len, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ } else {
+ *out_params = bundle_decode(output_str, output_len);
+ if (NULL == *out_params) {
+ ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_adaptor_external_request_async(service_adaptor_h handle,
+ int service_flag,
+ const char *api_uri,
+ bundle *in_params,
+ service_adaptor_external_response_cb callback,
+ void *user_data)
+{
+ service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED, "Not supported yet (TBD)");
+ return SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED;
+}
+/************************* private feature */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: service-adaptor-client-auth.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "private/service-adaptor-client-auth.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "dbus_client.h"
+#include "dbus_client_auth.h"
+
+#include "util/service_adaptor_client_util.h"
+/** @brief Gets Auth Plugin List
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_auth_plugin(service_adaptor_h handle,
+ service_adaptor_plugin_h **plugins,
+ unsigned int *plugins_len,
+ service_adaptor_error_s **error_code)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+ GList *plugin_list = NULL;
+ int len = 0;
+
+ if ((NULL == handle) || (NULL == plugins) || (0 == plugins_len)) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _dbus_get_auth_plugin_list(&plugin_list, handle->imsi ? handle->imsi : "", &error);
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ int size = g_list_length(plugin_list);
+ service_adaptor_plugin_h *plugins_array = (service_adaptor_plugin_h *) calloc(size, sizeof(service_adaptor_plugin_h));
+
+ if (NULL == plugins_array) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_UNKNOWN, "Memory allocation failed");
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+
+ for (GList *list = g_list_first(plugin_list); list != NULL; list = g_list_next(list)) {
+ service_adaptor_plugin_h plugin = (service_adaptor_plugin_h) list->data;
+
+ if (NULL == plugin) {
+ continue;
+ }
+
+ plugins_array[len] = (service_adaptor_plugin_h) calloc(1, sizeof(service_adaptor_plugin_s));
+ if (NULL != plugins_array[len]) {
+ plugins_array[len]->name = _safe_strdup(plugin->name);
+ plugins_array[len]->login = plugin->login;
+ }
+ len++;
+ }
+
+ *plugins = plugins_array;
+ *plugins_len = size;
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Logins Auth Plugin using appId and appSecret
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_auth_plugin(service_adaptor_h handle,
+ service_adaptor_plugin_h plugin_handle)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_plugin_h plugin = NULL;
+
+ if ((NULL == handle) || (NULL == plugin_handle) || (NULL == plugin_handle->name)) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ plugin = (service_adaptor_plugin_h) calloc(1, sizeof(service_adaptor_plugin_s));
+
+ if (NULL == plugin) {
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+
+ plugin->name = _safe_strdup(plugin_handle->name);
+ plugin->login = plugin_handle->login;
+
+ handle->plugin = plugin;
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Renuests Channel Auth
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_auth(service_adaptor_h handle,
+ const char *service_name,
+ const char *app_id,
+ const char *app_secret,
+ unsigned int service_id,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->imsi) || (NULL == handle->plugin) || (NULL == handle->plugin->name) || (NULL == service_name) || (NULL == app_id) || (NULL == app_secret)) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL != handle->service_name) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Duplicated handle usage (Destroy and create new handle)");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ char *_service_name = strdup(service_name);
+ char *_app_id = strdup(app_id);
+ if ((NULL == _service_name) || (NULL == _app_id)) {
+ free(_service_name);
+ free(_app_id);
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_UNKNOWN, "Memory allocation failed");
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+
+ sac_debug("set_auth mutex lock");
+ g_mutex_lock(&handle->set_auth_mutex);
+ ret = _dbus_set_auth(service_name, handle->imsi, handle->plugin->name, app_id, app_secret, service_id, user_data, &error);
+ g_mutex_unlock(&handle->set_auth_mutex);
+ sac_debug("set_auth mutex unlock");
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ sac_info("set_auth API failed: %d (%s)", ret, _service_name);
+ free(_service_name);
+ free(_app_id);
+ _assign_error_code(&error, error_code);
+ } else {
+ sac_info("set_auth API success (%s)", _service_name);
+ handle->service_name = _service_name;
+ handle->app_id = _app_id;
+ handle->service_id = service_id;
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: service-adaptor-client-contact.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "private/service-adaptor-client-contact.h"
+#include "dbus_client.h"
+#include "dbus_client_contact.h"
+
+#include "util/service_adaptor_client_util.h"
+/** @brief Resets contact information in Contact Server and
+ * uploads native contact information of device to the server
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_new_contact_list(service_adaptor_h handle,
+ service_adaptor_contact_req_s *contact_req,
+ void *user_data,
+ service_adaptor_contact_res_s **contact_res,
+ service_adaptor_error_s **error_code,
+ void **server_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == contact_req)) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_name) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_set_new_contact_list(handle->service_name, contact_req, user_data, contact_res, server_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Synchronizes native contact information of device with Contact Server
+ * according to [type] field of each contact
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_contact_list(service_adaptor_h handle,
+ service_adaptor_contact_req_s *contact_req,
+ void *user_data,
+ service_adaptor_contact_res_s **contact_res,
+ service_adaptor_error_s **error_code,
+ void **server_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == contact_req)) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_name) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_set_contact_list(handle->service_name, contact_req, user_data, contact_res, server_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Gets profile and service registration information of each contact
+ * (only contacts agreed to share with me are returned)
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_contact_infos_latest(service_adaptor_h handle,
+ service_adaptor_contact_res_s **contact_res,
+ service_adaptor_error_s **error_code,
+ void **server_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == contact_res)) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_name) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_get_contact_list(handle->service_name, contact_res, server_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Gets profiles and service registration information of contacts
+ * that have been updated since last update
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_contact_infos_polling(service_adaptor_h handle,
+ service_adaptor_contact_req_s *contact_req,
+ void *user_data,
+ service_adaptor_contact_res_s **contact_res,
+ service_adaptor_error_s **error_code,
+ void **server_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == contact_req)) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_name) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_get_contact_infos_polling(handle->service_name, contact_req, user_data, contact_res, server_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Sets or updates device’s profile to server
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_me_profile_with_push(service_adaptor_h handle,
+ service_adaptor_profile_req_s *profile_req,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == profile_req)) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_name) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_set_me_profile_with_push(handle->service_name, profile_req, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Gets the profile information of a contact which is correspondent with
+ * country code (optional) and phone number (mandatory)
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_profile(service_adaptor_h handle,
+ service_adaptor_profile_req_s *profile_req,
+ void *user_data,
+ service_adaptor_profile_res_s **profile_res,
+ service_adaptor_error_s **error_code,
+ void **server_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == profile_req) || (NULL == profile_res)) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_name) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_get_profile(handle->service_name, profile_req, user_data,
+ profile_res, server_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Uploads profile image meta to File Server and sets my profile image to Profile Server
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_profile_image_meta_with_push(service_adaptor_h handle,
+ service_adaptor_profile_image_h *images,
+ unsigned int images_len,
+ void *user_data,
+ service_adaptor_profile_image_h **failed_images,
+ unsigned int *failed_images_len,
+ service_adaptor_error_s **error_code,
+ void **server_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == images)) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_name) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_set_profile_image_meta_with_push(handle->service_name,
+ images, images_len, user_data, failed_images, failed_images_len, server_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Deletes profile image meta from Profile Server
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_delete_me_profile_image_meta_with_push(service_adaptor_h handle,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin)) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_name) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_delete_me_profile_image_meta_with_push(handle->service_name, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Sets the level of privacy, the scope of people to be opened
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_me_profile_privacy(service_adaptor_h handle,
+ service_adaptor_privacy_req_s *privacy_req,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == privacy_req)) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_name) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_set_me_profile_privacy(handle->service_name, privacy_req, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Gets my profile’s privacy level
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_me_profile_privacy(service_adaptor_h handle,
+ service_adaptor_privacy_res_s **privacy_res,
+ service_adaptor_error_s **error_code,
+ void **server_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == privacy_res)) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_name) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_get_me_profile_privacy(handle->service_name, privacy_res, server_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Sets my presence information to Presence Server
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_me_presence_with_push(service_adaptor_h handle,
+ service_adaptor_presence_req_s *presence_req,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == presence_req)) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_name) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_set_me_presence_with_push(handle->service_name, presence_req, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Sets my presence ON/OFF information to Presence Server
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_set_me_presence_on_off_with_push(service_adaptor_h handle,
+ service_adaptor_presence_req_s *presence_req,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == presence_req)) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_name) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_set_me_presence_on_off_with_push(handle->service_name,
+ presence_req, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_adaptor_set_me_profile_type(service_adaptor_h handle,
+ int profile_type,
+ char **profile_url,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == profile_url)) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_name) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_set_me_profile_type(handle->service_name,
+ profile_type, profile_url, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+
+
+int service_adaptor_profile_image_create(service_adaptor_profile_image_h *image)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ if (NULL == image) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ *image = (service_adaptor_profile_image_h)calloc(1, sizeof(struct _service_adaptor_profile_image_s));
+
+ if (NULL == *image) {
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+
+ memset((*image)->path, 0, 2048);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_adaptor_profile_image_set_element(service_adaptor_profile_image_h image,
+ service_adaptor_contact_request_type_e req_type,
+ int index,
+ const char *path)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ if ((NULL == image) || (NULL == path)) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ image->type = req_type;
+ image->index = index;
+ strncpy(image->path, path, (CONTACT_PROFILE_IMAGE_PATH_LEN - 1));
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_adaptor_profile_image_get_index(service_adaptor_profile_image_h image, int *index)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ if ((NULL == image) || (NULL == index)) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ *index = image->index;
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_adaptor_profile_image_get_url(service_adaptor_profile_image_h image, char **url)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ if ((NULL == image) || (NULL == url)) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if ('\0' == image->path[0]) {
+ *url = NULL;
+ ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
+ } else {
+ *url = strdup(image->path);
+ if (*url == NULL) {
+ ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_adaptor_profile_image_get_req_type(service_adaptor_profile_image_h image, int *req_type)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ if ((NULL == image) || (NULL == req_type)) {
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ *req_type = image->type;
+
+ sac_api_end(ret);
+ return ret;
+}
+
+void service_adaptor_profile_image_destroy(service_adaptor_profile_image_h image)
+{
+ free(image);
+}
+
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: service-adaptor-client-messaging.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "private/service-adaptor-client-message.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "dbus_client.h"
+#include "dbus_client_message.h"
+
+#include "util/service_adaptor_client_util.h"
+/** @brief Requests Creating Chatroom
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_create_chatroom(service_adaptor_h handle,
+ long long int request_id,
+ int chat_type,
+ long long int *receivers,
+ unsigned int receivers_len,
+ const char *chatroom_title,
+ service_adaptor_reply_create_chatroom_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start_msg(request_id);
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (0 > chat_type) || (1 < chat_type) ||
+ (NULL == chatroom_title) || (NULL == receivers) || (1 > receivers_len)) {
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ _error->msg = strdup("Invalid Argument");
+ }
+ *error_code = _error;
+ }
+
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+ error.code = SERVICE_ADAPTOR_ERROR_NONE;
+ error.msg = NULL;
+ ret = _dbus_request_create_chatroom(handle->service_name, request_id, chat_type, receivers, receivers_len, chatroom_title, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != error_code)) {
+ _error->code = error.code;
+ _error->msg = error.msg;
+ *error_code = _error;
+ } else {
+ free(_error);
+ free(error.msg);
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests Changing Chatroom metadata
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_change_chatroom_meta(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ const char *chatroom_title,
+ int default_message_ttl,
+ service_adaptor_reply_change_chatroom_meta_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+
+{
+ sac_api_start_msg(request_id);
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin)) {
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ _error->msg = strdup("Invalid Argument");
+ }
+ *error_code = _error;
+ }
+
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+ error.code = SERVICE_ADAPTOR_ERROR_NONE;
+ error.msg = NULL;
+ ret = _dbus_request_change_chatroom_meta(handle->service_name, request_id, chatroom_id, chatroom_title, default_message_ttl, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != error_code)) {
+ _error->code = error.code;
+ _error->msg = error.msg;
+ *error_code = _error;
+ } else {
+ free(_error);
+ free(error.msg);
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+
+/** @brief Requests Chat
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_chat(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ service_adaptor_chat_msg_s **chat_msgs,
+ unsigned int chat_msgs_len,
+ service_adaptor_reply_chat_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start_msg(request_id);
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == chat_msgs) || (1 > chat_msgs_len)) {
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ _error->msg = strdup("Invalid Argument");
+ }
+ *error_code = _error;
+ }
+
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+ error.code = SERVICE_ADAPTOR_ERROR_NONE;
+ error.msg = NULL;
+ ret = _dbus_request_chat(handle->service_name, request_id, chatroom_id, chat_msgs, chat_msgs_len, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != error_code)) {
+ _error->code = error.code;
+ _error->msg = error.msg;
+ *error_code = _error;
+ } else {
+ free(_error);
+ free(error.msg);
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests Allow Chat
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_allow_chat(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ bool is_auto_allow,
+ int max_count,
+ bool need_delivery_ack,
+ unsigned long long last_delivery_ack_timestamp,
+ bool need_read_ack,
+ unsigned long long last_read_ack_timestamp,
+ bool need_ordered_chat_member_list,
+ service_adaptor_reply_allow_chat_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start_msg(request_id);
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin)) {
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ _error->msg = strdup("Invalid Argument");
+ }
+ *error_code = _error;
+ }
+
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+ error.code = SERVICE_ADAPTOR_ERROR_NONE;
+ error.msg = NULL;
+ ret = _dbus_request_allow_chat(handle->service_name, request_id, chatroom_id, is_auto_allow, max_count,
+ need_delivery_ack, last_delivery_ack_timestamp, need_read_ack, last_read_ack_timestamp,
+ need_ordered_chat_member_list, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != error_code)) {
+ _error->code = error.code;
+ _error->msg = error.msg;
+ *error_code = _error;
+ } else {
+ free(_error);
+ free(error.msg);
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests All Unread Message
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_all_unread_message(service_adaptor_h handle,
+ long long int request_id,
+ int max_count,
+ service_adaptor_reply_all_unread_message_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start_msg(request_id);
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin)) {
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ _error->msg = strdup("Invalid Argument");
+ }
+ *error_code = _error;
+ }
+
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+ error.code = SERVICE_ADAPTOR_ERROR_NONE;
+ error.msg = NULL;
+ ret = _dbus_request_all_unread_message(handle->service_name, request_id, max_count, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != error_code)) {
+ _error->code = error.code;
+ _error->msg = error.msg;
+ *error_code = _error;
+ } else {
+ free(_error);
+ free(error.msg);
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Registers Forward Online Message Listener
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_register_channel_disconnected_listener(service_adaptor_h handle,
+ service_adaptor_reply_channel_disconnected_cb callback,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ _queue_add_task(TASK_MESSAGE_CHANNEL_DISCONNECTED_MESSAGE, (uint32_t) callback, handle, user_data);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Unregisters Forward Online Message Listener
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_unregister_channel_disconnected_listener(service_adaptor_h handle,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ service_adaptor_task_h task = _queue_get_task(TASK_MESSAGE_CHANNEL_DISCONNECTED_MESSAGE);
+
+ if (NULL == task) {
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+
+ _queue_del_task(task);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+
+
+/** @brief Registers Forward Online Message Listener
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_register_forward_online_message_listener(service_adaptor_h handle,
+ service_adaptor_request_forward_online_message_cb callback,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ _queue_add_task(TASK_MESSAGE_FORWARD_ONLINE_MESSAGE, (uint32_t) callback, handle, user_data);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Unregisters Forward Online Message Listener
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_unregister_forward_online_message_listener(service_adaptor_h handle,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ service_adaptor_task_h task = _queue_get_task(TASK_MESSAGE_FORWARD_ONLINE_MESSAGE);
+
+ if (NULL == task) {
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+
+ _queue_del_task(task);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests Forward Online Message
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_reply_forward_online_message(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ bool mark_as_read,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start_msg(request_id);
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin)) {
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ _error->msg = strdup("Invalid Argument");
+ }
+ *error_code = _error;
+ }
+
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ error.code = SERVICE_ADAPTOR_ERROR_NONE;
+ error.msg = NULL;
+ ret = _dbus_reply_forward_online_message(handle->service_name, request_id, chatroom_id, mark_as_read, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != error_code)) {
+ _error->code = error.code;
+ _error->msg = error.msg;
+ *error_code = _error;
+ } else {
+ free(_error);
+ free(error.msg);
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Registers Forward Unread Message Listener
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_register_forward_unread_message_listener(service_adaptor_h handle,
+ service_adaptor_request_forward_unread_message_cb callback,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ _queue_add_task(TASK_MESSAGE_FORWARD_UNREAD_MESSAGE, (uint32_t) callback, handle, user_data);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Unregisters Forward Unread Message Listener
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_unregister_forward_unread_message_listener(service_adaptor_h handle,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ service_adaptor_task_h task = _queue_get_task(TASK_MESSAGE_FORWARD_UNREAD_MESSAGE);
+
+ if (NULL == task) {
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+
+ _queue_del_task(task);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests Forward Unread Message
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_reply_forward_unread_message(service_adaptor_h handle,
+ long long int request_id,
+ const char *next_pagination_key,
+ int max_count,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start_msg(request_id);
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin)) {
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ _error->msg = strdup("Invalid Argument");
+ }
+ *error_code = _error;
+ }
+
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ error.code = SERVICE_ADAPTOR_ERROR_NONE;
+ error.msg = NULL;
+ ret = _dbus_reply_forward_unread_message(handle->service_name, request_id, next_pagination_key, max_count, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != error_code)) {
+ _error->code = error.code;
+ _error->msg = error.msg;
+ *error_code = _error;
+ } else {
+ free(_error);
+ free(error.msg);
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests Read Message
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_read_message(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ service_adaptor_inbox_message_s *inbox_msg,
+ service_adaptor_reply_read_message_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start_msg(request_id);
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == inbox_msg)) {
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ _error->msg = strdup("Invalid Argument");
+ }
+ *error_code = _error;
+ }
+
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ error.code = SERVICE_ADAPTOR_ERROR_NONE;
+ error.msg = NULL;
+ ret = _dbus_request_read_message(handle->service_name, request_id, chatroom_id, inbox_msg, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != error_code)) {
+ _error->code = error.code;
+ _error->msg = error.msg;
+ *error_code = _error;
+ } else {
+ free(_error);
+ free(error.msg);
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests Invite Chat
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_invite_chat(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ long long int *inviting_members,
+ unsigned int inviting_members_len,
+ service_adaptor_reply_invite_chat_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start_msg(request_id);
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == inviting_members) || (1 > inviting_members_len)) {
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ _error->msg = strdup("Invalid Argument");
+ }
+ *error_code = _error;
+ }
+
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+ error.code = SERVICE_ADAPTOR_ERROR_NONE;
+ error.msg = NULL;
+ ret = _dbus_request_invite_chat(handle->service_name, request_id, chatroom_id, inviting_members, inviting_members_len, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != error_code)) {
+ _error->code = error.code;
+ _error->msg = error.msg;
+ *error_code = _error;
+ } else {
+ free(_error);
+ free(error.msg);
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests End Chat
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_end_chat(service_adaptor_h handle,
+ long long int request_id,
+ service_adaptor_end_chat_s **end_chats,
+ unsigned int end_chats_len,
+ service_adaptor_reply_end_chat_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start_msg(request_id);
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == end_chats) || (1 > end_chats_len)) {
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ _error->msg = strdup("Invalid Argument");
+ }
+ *error_code = _error;
+ }
+
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+ error.code = SERVICE_ADAPTOR_ERROR_NONE;
+ error.msg = NULL;
+ ret = _dbus_request_end_chat(handle->service_name, request_id, end_chats, end_chats_len, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != error_code)) {
+ _error->code = error.code;
+ _error->msg = error.msg;
+ *error_code = _error;
+ } else {
+ free(_error);
+ free(error.msg);
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests Unseal Message
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_unseal_message(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ long long int sender_id,
+ long long int message_id,
+ const char *message_detail,
+ service_adaptor_reply_unseal_message_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start_msg(request_id);
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == message_detail)) {
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ _error->msg = strdup("Invalid Argument");
+ }
+ *error_code = _error;
+ }
+
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+ error.code = SERVICE_ADAPTOR_ERROR_NONE;
+ error.msg = NULL;
+ ret = _dbus_request_unseal_message(handle->service_name, request_id, chatroom_id,
+ sender_id, message_id, message_detail, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != error_code)) {
+ _error->code = error.code;
+ _error->msg = error.msg;
+ *error_code = _error;
+ } else {
+ free(_error);
+ free(error.msg);
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests Save Call Log
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_save_call_log(service_adaptor_h handle,
+ long long int request_id,
+ long long int chatroom_id,
+ const char *call_id,
+ const char *call_log_type,
+ long long int call_sender_id,
+ long long int call_receiver_id,
+ int conversaction_second,
+ service_adaptor_reply_save_call_log_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start_msg(request_id);
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin)) {
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ _error->msg = strdup("Invalid Argument");
+ }
+ *error_code = _error;
+ }
+
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+ error.code = SERVICE_ADAPTOR_ERROR_NONE;
+ error.msg = NULL;
+ ret = _dbus_request_save_call_log(handle->service_name, request_id, chatroom_id,
+ call_id, call_log_type, call_sender_id, call_receiver_id,
+ conversaction_second, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != error_code)) {
+ _error->code = error.code;
+ _error->msg = error.msg;
+ *error_code = _error;
+ } else {
+ free(_error);
+ free(error.msg);
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests Current Time
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_current_time(service_adaptor_h handle,
+ long long int request_id,
+ service_adaptor_reply_current_time_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start_msg(request_id);
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin)) {
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ _error->msg = strdup("Invalid Argument");
+ }
+ *error_code = _error;
+ }
+
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ _queue_add_task(request_id, (uint32_t) callback, handle, user_data);
+
+ error.code = SERVICE_ADAPTOR_ERROR_NONE;
+ error.msg = NULL;
+ ret = _dbus_request_current_time(handle->service_name, request_id, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != error_code)) {
+ _error->code = error.code;
+ _error->msg = error.msg;
+ *error_code = _error;
+ } else {
+ free(_error);
+ free(error.msg);
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_get_connection_policy(service_adaptor_h handle,
+ service_adaptor_connection_policy_e *policy,
+ service_adaptor_error_s **error_code)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == policy)) {
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ _error->msg = strdup("Invalid Argument");
+ }
+ *error_code = _error;
+ }
+
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ error.code = SERVICE_ADAPTOR_ERROR_NONE;
+ error.msg = NULL;
+ ret = _dbus_request_get_connection_policy(handle->service_name, policy, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != error_code)) {
+ _error->code = error.code;
+ _error->msg = error.msg;
+ *error_code = _error;
+ } else {
+ free(_error);
+ free(error.msg);
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_request_set_connection_policy(service_adaptor_h handle,
+ service_adaptor_connection_policy_e *policy,
+ service_adaptor_error_s **error_code)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == policy)) {
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ _error->msg = strdup("Invalid Argument");
+ }
+ *error_code = _error;
+ }
+
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ error.code = SERVICE_ADAPTOR_ERROR_NONE;
+ error.msg = NULL;
+ ret = _dbus_request_set_connection_policy(handle->service_name, policy, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != error_code)) {
+ _error->code = error.code;
+ _error->msg = error.msg;
+ *error_code = _error;
+ } else {
+ free(_error);
+ free(error.msg);
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+
+
+/** @brief Requests chat id based on phone number
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_chat_id_list(service_adaptor_h handle,
+ service_adaptor_phone_number_s **phone_numbers,
+ unsigned int phone_numbers_len,
+ void *user_data,
+ service_adaptor_chat_id_s ***chat_ids,
+ unsigned int *chat_ids_len,
+ service_adaptor_error_s **error_code,
+ void **server_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == phone_numbers) || (1 > phone_numbers_len) || (NULL == chat_ids) || (NULL == chat_ids_len)) {
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ _error->msg = strdup("Invalid Argument");
+ }
+ *error_code = _error;
+ }
+
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (service_adaptor_check_handle_validate(handle)) {
+ service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle (Please success set_auth first)");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ error.code = SERVICE_ADAPTOR_ERROR_NONE;
+ error.msg = NULL;
+ ret = _dbus_get_chat_id_list(handle->service_name, phone_numbers, phone_numbers_len, user_data, chat_ids, chat_ids_len, server_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != error_code)) {
+ _error->code = error.code;
+ _error->msg = error.msg;
+ *error_code = _error;
+ } else {
+ free(_error);
+ free(error.msg);
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests MSISDN based on User ID
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_msisdn_list(service_adaptor_h handle,
+ long long int *chat_ids,
+ unsigned int chat_ids_len,
+ void *user_data,
+ service_adaptor_chat_id_s ***msisdns,
+ unsigned int *msisdns_len,
+ service_adaptor_error_s **error_code,
+ void **server_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == chat_ids) || (1 > chat_ids_len) || (NULL == msisdns) || (msisdns_len == NULL)) {
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ _error->msg = strdup("Invalid Argument");
+ }
+ *error_code = _error;
+ }
+
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ error.code = SERVICE_ADAPTOR_ERROR_NONE;
+ error.msg = NULL;
+ ret = _dbus_get_msisdn_list(handle->service_name, chat_ids, chat_ids_len, user_data, msisdns, msisdns_len, server_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != error_code)) {
+ _error->code = error.code;
+ _error->msg = error.msg;
+ *error_code = _error;
+ } else {
+ free(_error);
+ free(error.msg);
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: service-adaptor-client-push.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <glib.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "private/service-adaptor-client-push.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_private.h"
+#include "service_adaptor_client_log.h"
+#include "dbus/dbus_client_push.h"
+
+#include "util/service_adaptor_client_util.h"
+/** @brief Registers a callback function to receive push notification from push service
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_connect_push_service(service_adaptor_h handle,
+ service_adaptor_push_notification_cb callback,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if ((NULL == handle) || (NULL == callback)) {
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Parameter");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ sac_debug("Connect push service : service_id(%d)", handle->service_id);
+
+ _signal_queue_add_task(handle->service_id, (uint32_t) callback, handle, user_data);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Deregisters the callback function that had been registered to push service
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_disconnect_push_service(service_adaptor_h handle)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if (NULL == handle) {
+ service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invlid parameters");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ service_adaptor_task_h task = _signal_queue_get_task(handle->service_id);
+
+ if (NULL == task) {
+ return SERVICE_ADAPTOR_ERROR_NONE;
+ }
+
+ sac_debug("Disconnect push service : service_id(%d)", handle->service_id);
+
+ _signal_queue_del_task(task);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_register_push_service(service_adaptor_h handle,
+ const char *service_file_name)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == service_file_name)) {
+ service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invlid parameters");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _dbus_push_register(service_file_name, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ sac_error("Error occured (%lld)(%s)", error.code, error.msg);
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_deregister_push_service(service_adaptor_h handle,
+ const char *service_file_name)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == service_file_name)) {
+ service_adaptor_set_last_result(SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invlid parameters");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _dbus_push_deregister(service_file_name, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ sac_error("Error occured (%lld)(%s)", error.code, error.msg);
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: service-adaptor-client-shop.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "private/service-adaptor-client-shop.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "dbus_client.h"
+#include "dbus_client_shop.h"
+
+#include "util/service_adaptor_client_util.h"
+/** @brief Requests List of Item
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_item_list(service_adaptor_h handle,
+ service_adaptor_shop_info_s *info,
+ void *user_data,
+ service_adaptor_shop_item_s ***items,
+ unsigned int *items_len,
+ service_adaptor_error_s **error_code,
+ void **server_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == info) || (NULL == items)) {
+ sac_error("Invalid Parameter");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Parameter");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_name) {
+ sac_error("The service_name is NULL");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_get_item_list(handle->service_name, info, user_data, items, items_len, server_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests Item Information for Download
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_download_item_package(service_adaptor_h handle,
+ service_adaptor_shop_info_s *info,
+ void *user_data,
+ service_adaptor_shop_item_s **item,
+ service_adaptor_error_s **error_code,
+ void **server_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == info) || (NULL == item)) {
+ sac_error("Invalid Parameter");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Parameter");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_name) {
+ sac_error("The service_name is NULL");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_download_item_package(handle->service_name, info, user_data, item, server_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests Download of Item
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_download_sticker(service_adaptor_h handle,
+ service_adaptor_shop_info_s *info,
+ void *user_data,
+ service_adaptor_shop_item_s **item,
+ service_adaptor_error_s **error_code,
+ void **server_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == info) || (NULL == item)) {
+ sac_error("Invalid Parameter");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Parameter");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_name) {
+ sac_error("The service_name is NULL");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_download_sticker(handle->service_name, info, user_data, item, server_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests Item Panel URL
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_panel_url(service_adaptor_h handle,
+ service_adaptor_shop_info_s *info,
+ void *user_data,
+ service_adaptor_shop_item_s **item,
+ service_adaptor_error_s **error_code,
+ void **server_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == info) || (NULL == item)) {
+ sac_error("Invalid Parameter");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Parameter");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_name) {
+ sac_error("The service_name is NULL");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_STATE, "Invalid handle state");
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_get_panel_url(handle->service_name, info, user_data, item, server_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: service-adaptor-client-storage.c
+ * Desc:
+ * Created on: Oct, 2014
+ * Auth: Yongjin Kim <youth.kim@samsung.com>
+ *
+ *****************************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+
+#include "service_adaptor_client_private.h"
+#include "service_adaptor_client_type.h"
+#include "service_adaptor_client_log.h"
+#include "service_adaptor_client_storage.h"
+#include "service_adaptor_client_storage_internal.h"
+#include "dbus_client.h"
+#include "dbus_client_storage.h"
+
+#include "util/service_adaptor_client_util.h"
+
+/****************** private feature */
+#include "private/service-adaptor-client-storage.h"
+/****************** private feature */
+
+#define SAFE_STRDUP(src) (src) ? strdup(src) : NULL
+
+#define ASYNC_OPERATION_UPLOAD_FILE 1
+#define ASYNC_OPERATION_DOWNLOAD_FILE 2
+#define ASYNC_OPERATION_DOWNLOAD_THUMBNAIL 3
+
+#define TIZEN_PRIVILEGE_NAME_INTERNET "http://tizen.org/privilege/internet"
+
+struct _service_storage_file_list_s {
+ service_storage_file_h *list;
+ int length;
+};
+
+/**
+* @brief Release memory for service_storage_file_h
+*
+* @param[in] void
+* @return service_storage_file_h
+* @retval Allocated and filled default value file_info's pointer
+*/
+service_storage_file_h service_storage_create_file_info(void)
+{
+ FUNC_START();
+ service_storage_file_h _file_info = NULL;
+ _file_info = (service_storage_file_h) calloc(1, sizeof(struct _service_storage_file_s));
+
+ service_storage_media_meta_s *_media_meta = NULL;
+ _media_meta = (service_storage_media_meta_s *) calloc(1, sizeof(service_storage_media_meta_s));
+
+ service_storage_cloud_meta_s *_cloud_meta = NULL;
+ _cloud_meta = (service_storage_cloud_meta_s *) calloc(1, sizeof(service_storage_cloud_meta_s));
+
+ if ((NULL == _file_info) || (NULL == _media_meta) || (NULL == _cloud_meta)) {
+ free(_file_info);
+ free(_media_meta);
+ free(_cloud_meta);
+
+ FUNC_STOP();
+ return NULL;
+ }
+
+ _media_meta->mime_type = NULL;
+ _media_meta->title = NULL;
+ _media_meta->album = NULL;
+ _media_meta->artist = NULL;
+ _media_meta->genere = NULL;
+ _media_meta->recorded_date = NULL;
+ _media_meta->width = -1;
+ _media_meta->height = -1;
+ _media_meta->duration = -1;
+ _media_meta->copyright = NULL;
+ _media_meta->track_num = NULL;
+ _media_meta->description = NULL;
+ _media_meta->composer = NULL;
+ _media_meta->year = NULL;
+ _media_meta->bitrate = -1;
+ _media_meta->samplerate = -1;
+ _media_meta->channel = -1;
+ _media_meta->extra_media_meta = NULL;
+
+ _cloud_meta->service_name = NULL;
+ _cloud_meta->usage_byte = 0ULL;
+ _cloud_meta->quota_byte = 0ULL;
+ _cloud_meta->extra_cloud_meta = NULL;
+
+ _file_info->plugin_name = NULL;
+ _file_info->object_id = NULL;
+ _file_info->storage_path = NULL;
+ _file_info->file_size = 0ULL;
+ _file_info->created_time = 0ULL;
+ _file_info->modified_time = 0ULL;
+ _file_info->file_info_index = -1;
+ _file_info->content_type = SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_DEFAULT;
+ _file_info->media_meta = _media_meta;
+ _file_info->cloud_meta = _cloud_meta;
+ _file_info->extra_file_info = NULL;
+
+ FUNC_END();
+ return _file_info;
+}
+
+/**
+* @brief Release memory for service_storage_file_h
+*
+* @param[in] file_info specifies Service Adaptor file information handle
+* @return service_storage_file_h
+* @retval released file_info's pointer
+*/
+int service_storage_unref_file_info(service_storage_file_h *file_info)
+{
+ FUNC_START();
+ if (NULL == file_info) {
+ FUNC_STOP();
+ return 1;
+ }
+
+ if (NULL == *file_info) {
+ FUNC_STOP();
+ return 0;
+ }
+ service_storage_file_h _file_info = *file_info;
+
+ free(_file_info->plugin_name);
+ free(_file_info->object_id);
+ free(_file_info->storage_path);
+ free(_file_info->extra_file_info);
+
+ service_storage_media_meta_s *_media_meta = _file_info->media_meta;
+
+ if (NULL != _media_meta) {
+ free(_media_meta->mime_type);
+ free(_media_meta->title);
+ free(_media_meta->album);
+ free(_media_meta->artist);
+ free(_media_meta->genere);
+ free(_media_meta->recorded_date);
+ free(_media_meta->copyright);
+ free(_media_meta->track_num);
+ free(_media_meta->description);
+ free(_media_meta->composer);
+ free(_media_meta->year);
+ free(_media_meta->extra_media_meta);
+ }
+
+ service_storage_cloud_meta_s *_cloud_meta = _file_info->cloud_meta;
+
+ if (NULL != _cloud_meta) {
+ free(_cloud_meta->service_name);
+ free(_cloud_meta->extra_cloud_meta);
+ }
+
+ free((*file_info)->media_meta);
+ free((*file_info)->cloud_meta);
+ free(*file_info);
+ *file_info = NULL;
+
+ FUNC_END();
+ return 0;
+}
+
+
+/** @brief Uploads a server file and writes it to local file
+ * @return int
+ * @remarks :
+ */
+int service_storage_upload_file(service_plugin_h handle,
+ const char *upload_path,
+ const char *server_path,
+ service_storage_file_h *file_info)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == upload_path) || (NULL == server_path)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_handle_name) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_upload_file(handle->service_handle_name, upload_path, server_path, file_info, NULL, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests
+ * @return int
+ * @remarks :
+ */
+int service_storage_get_root_directory(service_plugin_h handle,
+ char **root_folder_path)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if (NULL == handle) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_handle_name) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_get_root_folder_path(handle->service_handle_name, root_folder_path, NULL, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests
+ * @return int
+ * @remarks :
+ */
+int service_storage_make_directory(service_plugin_h handle,
+ const char *folder_path,
+ service_storage_file_h *file_info)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if (NULL == handle) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_handle_name) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_make_directory(handle->service_handle_name, folder_path, file_info, NULL, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+
+/** @brief Requests
+ * @return int
+ * @remarks :
+ */
+int service_storage_remove_file(service_plugin_h handle,
+ const char *file_path)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == file_path)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_handle_name) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_remove_file(handle->service_handle_name, file_path, NULL, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+
+/** @brief Requests
+ * @return int
+ * @remarks :
+ */
+int service_storage_remove_directory(service_plugin_h handle,
+ const char *folder_path)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == folder_path)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_handle_name) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_remove_directory(handle->service_handle_name, folder_path, NULL, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+
+/** @brief Requests
+ * @return int
+ * @remarks :
+ */
+int service_storage_move_file(service_plugin_h handle,
+ const char *src_file_path,
+ const char *dst_file_path,
+ service_storage_file_h *file_info)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == src_file_path) || (NULL == dst_file_path)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_handle_name) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_move_file(handle->service_handle_name, src_file_path, dst_file_path, file_info, NULL, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+
+/** @brief Requests
+ * @return int
+ * @remarks :
+ */
+int service_storage_move_directory(service_plugin_h handle,
+ const char *src_folder_path,
+ const char *dst_folder_path,
+ service_storage_file_h *file_info)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == src_folder_path) || (NULL == dst_folder_path) || (NULL == file_info)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_handle_name) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_move_directory(handle->service_handle_name, src_folder_path, dst_folder_path, file_info, NULL, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/** @brief Requests
+ * @return int
+ * @remarks :
+ */
+int service_storage_get_directory_entries(service_plugin_h handle,
+ const char *parent_path,
+ service_storage_file_h **file_info_list,
+ unsigned int *file_info_list_len)
+
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == parent_path) || (NULL == file_info_list) || (NULL == file_info_list_len)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_handle_name) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_get_file_list(handle->service_handle_name, parent_path, file_info_list, file_info_list_len, NULL, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_storage_download_file(service_plugin_h handle,
+ const char *cloud_path,
+ const char *download_path)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == cloud_path) || (NULL == download_path)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_handle_name) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_download_file(handle->service_handle_name, cloud_path, download_path, NULL, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_storage_download_thumbnail(service_plugin_h handle,
+ const char *storage_path,
+ const char *local_path,
+ int thumbnail_size)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == storage_path) || (NULL == local_path)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == handle->service_handle_name) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+
+ ret = _dbus_download_thumbnail(handle->service_handle_name, storage_path, local_path, thumbnail_size, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+/******* Async implementation */
+
+int service_storage_create_upload_task(service_plugin_h plugin,
+ const char *file_path,
+ const char *upload_path,
+ service_storage_task_h *task)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == plugin) || (NULL == file_path) || (NULL == upload_path) || (NULL == task)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == plugin->service_handle_name) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+/*
+ if (CLIENT_APP_TYPE_APPLICATION == plugin->app_type) {
+ int privilege_ret = 0;
+ privilege_ret = privilege_checker_check_privilege(TIZEN_PRIVILEGE_NAME_INTERNET);
+ if (PRIVILEGE_CHECKER_ERR_NONE != privilege_ret) {
+ sac_error("Privilege check error (ret : %d)", privilege_ret);
+ return SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED;
+ }
+ }
+*/
+
+ service_storage_task_h _task = (service_storage_task_h) calloc(1, sizeof(service_storage_task_t));
+ if (NULL == _task) {
+ ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ service_adaptor_set_last_result(ret, "Memory allocation failed");
+ return ret;
+ }
+
+ long long int task_id = 0;
+ ret = _dbus_open_upload_file(plugin->service_handle_name, file_path, upload_path, &task_id, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ free(_task);
+ } else {
+ _task->service_handle_name = strdup(plugin->service_handle_name);
+ _task->task_id = task_id;
+ _task->operation = ASYNC_OPERATION_UPLOAD_FILE;
+ _task->state_callback = NULL;
+ _task->state_user_data = NULL;
+ _task->progress_callback = NULL;
+ _task->progress_user_data = NULL;
+
+ _task->param1 = (void *)strdup(file_path);
+ _task->param2 = (void *)strdup(upload_path);
+ _task->param3 = NULL;
+
+ *task = _task;
+
+ service_adaptor_task_h callback_task = NULL;
+ while ((callback_task = _queue_get_task((int64_t)_task->task_id))) {
+ _queue_del_task(callback_task);
+ callback_task = NULL;
+ }
+ _queue_add_task((int64_t)_task->task_id,
+ (uint32_t) NULL, (void *) _task, NULL);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+
+int service_storage_create_download_task(service_plugin_h plugin,
+ const char *storage_path,
+ const char *download_path,
+ service_storage_task_h *task)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == plugin) || (NULL == storage_path) || (NULL == download_path) || (NULL == task)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == plugin->service_handle_name) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+/*
+ if (CLIENT_APP_TYPE_APPLICATION == plugin->app_type) {
+ int privilege_ret = 0;
+ privilege_ret = privilege_checker_check_privilege(TIZEN_PRIVILEGE_NAME_INTERNET);
+ if (PRIVILEGE_CHECKER_ERR_NONE != privilege_ret) {
+ sac_error("Privilege check error (ret : %d)", privilege_ret);
+ return SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED;
+ }
+ }
+*/
+ service_storage_task_h _task = (service_storage_task_h) calloc(1, sizeof(service_storage_task_t));
+ if (NULL == _task) {
+ ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ service_adaptor_set_last_result(ret, "Memory allocation failed");
+ return ret;
+ }
+
+ long long int task_id = 0;
+ ret = _dbus_open_download_file(plugin->service_handle_name, storage_path, download_path, &task_id, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ free(_task);
+ } else {
+ _task->service_handle_name = strdup(plugin->service_handle_name);
+ _task->task_id = task_id;
+ _task->operation = ASYNC_OPERATION_DOWNLOAD_FILE;
+ _task->state_callback = NULL;
+ _task->state_user_data = NULL;
+ _task->progress_callback = NULL;
+ _task->progress_user_data = NULL;
+
+ _task->param1 = (void *)strdup(storage_path);
+ _task->param2 = (void *)strdup(download_path);
+ _task->param3 = NULL;
+
+ *task = _task;
+
+ service_adaptor_task_h callback_task = NULL;
+ while ((callback_task = _queue_get_task((int64_t)_task->task_id))) {
+ _queue_del_task(callback_task);
+ callback_task = NULL;
+ }
+ _queue_add_task((int64_t)_task->task_id,
+ (uint32_t) NULL, (void *) _task, NULL);
+ }
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_storage_create_download_thumbnail_task(service_plugin_h plugin,
+ const char *storage_path,
+ const char *download_path,
+ int thumbnail_size,
+ service_storage_task_h *task)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == plugin) || (NULL == storage_path) || (NULL == download_path) || (NULL == task)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == plugin->service_handle_name) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+/*
+ if (CLIENT_APP_TYPE_APPLICATION == plugin->app_type) {
+ int privilege_ret = 0;
+ privilege_ret = privilege_checker_check_privilege(TIZEN_PRIVILEGE_NAME_INTERNET);
+ if (PRIVILEGE_CHECKER_ERR_NONE != privilege_ret) {
+ sac_error("Privilege check error (ret : %d)", privilege_ret);
+ return SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED;
+ }
+ }
+*/
+ service_storage_task_h _task = (service_storage_task_h) calloc(1, sizeof(service_storage_task_t));
+ int *t_size = (int *)calloc(1, sizeof(int));
+ if ((NULL == _task) || (NULL == t_size)) {
+ ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ service_adaptor_set_last_result(ret, "Memory allocation failed");
+ free(_task);
+ free(t_size);
+ return ret;
+ }
+
+ long long int task_id = 0;
+ ret = _dbus_open_download_thumbnail(plugin->service_handle_name, storage_path, download_path, thumbnail_size, &task_id, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ free(_task);
+ free(t_size);
+ } else {
+ _task->service_handle_name = strdup(plugin->service_handle_name);
+ _task->task_id = task_id;
+ _task->operation = ASYNC_OPERATION_DOWNLOAD_THUMBNAIL;
+ _task->state_callback = NULL;
+ _task->state_user_data = NULL;
+ _task->progress_callback = NULL;
+ _task->progress_user_data = NULL;
+
+ _task->param1 = (void *)strdup(storage_path);
+ _task->param2 = (void *)strdup(download_path);
+ *t_size = thumbnail_size;
+ _task->param3 = (void *)t_size;
+
+ *task = _task;
+
+ service_adaptor_task_h callback_task = NULL;
+ while ((callback_task = _queue_get_task((int64_t)_task->task_id))) {
+ _queue_del_task(callback_task);
+ callback_task = NULL;
+ }
+ _queue_add_task((int64_t)_task->task_id,
+ (uint32_t) NULL, (void *) _task, NULL);
+
+ }
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_storage_destroy_task(service_storage_task_h task)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if (NULL == task) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _dbus_close_file_task(task->service_handle_name, task->task_id, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ service_adaptor_task_h callback_task = NULL;
+ while ((callback_task = _queue_get_task((int64_t)task->task_id))) {
+ _queue_del_task(callback_task);
+ callback_task = NULL;
+ }
+
+ free(task->service_handle_name);
+ free(task->param1);
+ free(task->param2);
+ free(task->param3);
+ free(task);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_storage_start_task(service_storage_task_h task)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if (NULL == task) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ switch (task->operation) {
+ case ASYNC_OPERATION_UPLOAD_FILE:
+ sac_info("Start upload async task");
+ ret = _dbus_start_upload_file(task->service_handle_name,
+ task->task_id, (char *)task->param2,
+ task->progress_callback ? true : false, task->state_callback ? true : false, &error);
+ break;
+ case ASYNC_OPERATION_DOWNLOAD_FILE:
+ sac_info("Start download async task");
+ ret = _dbus_start_download_file(task->service_handle_name,
+ task->task_id, (char *)task->param1,
+ task->progress_callback ? true : false, task->state_callback ? true : false, &error);
+ break;
+
+ case ASYNC_OPERATION_DOWNLOAD_THUMBNAIL:
+ sac_info("Start download thumbnail async task");
+ ret = _dbus_start_download_thumbnail(task->service_handle_name,
+ task->task_id, (char *)task->param1, *((int *)task->param3),
+ task->progress_callback ? true : false, task->state_callback ? true : false, &error);
+ break;
+
+ default:
+ sac_info("Invalid async task");
+ ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error.code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error.msg = strdup("Invalid async task operation");
+ break;
+ }
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_storage_cancel_task(service_storage_task_h task)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if (NULL == task) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ switch (task->operation) {
+ case ASYNC_OPERATION_UPLOAD_FILE:
+ sac_info("Start upload async task");
+ ret = _dbus_cancel_upload_file(task->service_handle_name,
+ task->task_id, &error);
+ break;
+ case ASYNC_OPERATION_DOWNLOAD_FILE:
+ sac_info("Start download async task");
+ ret = _dbus_cancel_download_file(task->service_handle_name,
+ task->task_id, &error);
+ break;
+
+ case ASYNC_OPERATION_DOWNLOAD_THUMBNAIL:
+ sac_info("Start download thumbnail async task");
+ ret = _dbus_cancel_download_thumbnail(task->service_handle_name,
+ task->task_id, &error);
+ break;
+
+ default:
+ sac_info("Invalid async task");
+ ret = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error.code = SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ error.msg = strdup("Invalid async task operation");
+ break;
+ }
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ sac_api_end(ret);
+ return ret;
+
+}
+
+int service_storage_set_task_progress_cb(service_storage_task_h task,
+ service_storage_task_progress_cb callback,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if ((NULL == task) || (NULL == callback)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ task->progress_callback = callback;
+ task->progress_user_data = user_data;
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_storage_unset_task_progress_cb(service_storage_task_h task)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if (NULL == task) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ task->progress_callback = NULL;
+ task->progress_user_data = NULL;
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_storage_set_task_state_changed_cb(service_storage_task_h task,
+ service_storage_task_state_cb callback,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if ((NULL == task) || (NULL == callback)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ task->state_callback = callback;
+ task->state_user_data = user_data;
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_storage_unset_task_state_changed_cb(service_storage_task_h task)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if (NULL == task) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ task->state_callback = NULL;
+ task->state_user_data = NULL;
+
+ sac_api_end(ret);
+ return ret;
+}
+
+struct __async_wrapper_context {
+ service_plugin_h plugin;
+ char *path;
+ void *callback;
+ void *user_data;
+};
+
+void *_get_file_list_runnable(void *_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ struct __async_wrapper_context *_params = (struct __async_wrapper_context *)_data;
+
+ service_storage_file_list_h file_list = NULL;
+
+ service_adaptor_error_s error;
+ error.msg = NULL;
+ service_storage_file_h *files = NULL;
+ unsigned int files_len = 0;
+
+ ret = _dbus_get_file_list(_params->plugin->service_handle_name, _params->path, &files, &files_len, NULL, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ if ((NULL != files) && (0 < files_len)) {
+ int i;
+ for (i = 0; i < files_len; i++) {
+ service_storage_unref_file_info(&files[i]);
+ }
+ free(files);
+ files = NULL;
+ }
+ } else {
+ if (0 < files_len) {
+ file_list = (service_storage_file_list_h) calloc(1, sizeof(struct _service_storage_file_list_s));
+ if (NULL == file_list) {
+ sac_error("Critical : Memory allocation failed");
+ ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ } else {
+ file_list->list = files;
+ file_list->length = (int) files_len;
+ }
+ } else {
+ ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
+ }
+ }
+
+ ((service_storage_file_list_cb)_params->callback)(ret, file_list, _params->user_data);
+
+ int i;
+ for (i = 0; i < files_len; i++) {
+ service_storage_unref_file_info(&files[i]);
+ }
+ free(files);
+ free(file_list);
+
+ free(_params->path);
+ free(_params);
+
+ sac_api_end(ret);
+ return NULL;
+}
+
+int service_storage_get_file_list(service_plugin_h plugin,
+ const char *dir_path,
+ service_storage_file_list_cb callback,
+ void *user_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if ((NULL == plugin) || (NULL == callback) || (NULL == dir_path)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == plugin->service_handle_name) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+/*
+ if (CLIENT_APP_TYPE_APPLICATION == plugin->app_type) {
+ int privilege_ret = 0;
+ privilege_ret = privilege_checker_check_privilege(TIZEN_PRIVILEGE_NAME_INTERNET);
+ if (PRIVILEGE_CHECKER_ERR_NONE != privilege_ret) {
+ sac_error("Privilege check error (ret : %d)", privilege_ret);
+ return SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED;
+ }
+ }
+*/
+ struct __async_wrapper_context *params = NULL;
+ params = (struct __async_wrapper_context *) calloc(1, sizeof(struct __async_wrapper_context));
+
+ if (NULL == params) {
+ sac_warning("Memory allocation failed");
+ ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ } else {
+ params->plugin = plugin;
+ params->path = strdup(dir_path);
+ params->callback = (void *)callback;
+ params->user_data = user_data;
+
+ int thread_ret = 0;
+ pthread_t get_list_thread;
+ thread_ret = pthread_create(&get_list_thread, NULL, _get_file_list_runnable, (void *)params);
+
+ if (thread_ret) {
+ sac_warning("Thread create failed");
+ ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ free(params->path);
+ free(params);
+ }
+ }
+
+ return ret;
+}
+
+int service_storage_file_list_clone(service_storage_file_list_h src_list,
+ service_storage_file_list_h *dst_list)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if ((NULL == src_list) || (NULL == dst_list)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ service_storage_file_list_h _list = NULL;
+ _list = (service_storage_file_list_h) calloc(1, sizeof(struct _service_storage_file_list_s));
+ if (NULL == _list) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+ _list->length = src_list->length;
+ _list->list = (service_storage_file_h *) calloc(_list->length, sizeof(struct _service_storage_file_s *));
+ if (NULL == _list->list) {
+ free(_list);
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+
+ int i = 0;
+ for (i = 0; i < _list->length; i++) {
+ service_storage_file_h file = NULL;
+ service_storage_file_clone(src_list->list[i], &file);
+ _list->list[i] = file;
+ }
+
+ *dst_list = _list;
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_storage_file_list_destroy(service_storage_file_list_h list)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if (NULL == list) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ int i;
+ for (i = 0; i < list->length; i++) {
+ service_storage_file_destroy(list->list[i]);
+ }
+ free(list);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_storage_file_clone(service_storage_file_h src_file,
+ service_storage_file_h *dst_file)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if ((NULL == src_file) || (NULL == dst_file)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ service_storage_file_h src = src_file;
+ service_storage_file_h new_file = service_storage_create_file_info();
+
+ if (NULL == new_file) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+
+ if (NULL != src->media_meta) {
+ new_file->media_meta->mime_type =
+ SAFE_STRDUP(src->media_meta->mime_type);
+ new_file->media_meta->title =
+ SAFE_STRDUP(src->media_meta->title);
+ new_file->media_meta->album =
+ SAFE_STRDUP(src->media_meta->album);
+ new_file->media_meta->artist =
+ SAFE_STRDUP(src->media_meta->artist);
+ new_file->media_meta->genere =
+ SAFE_STRDUP(src->media_meta->genere);
+ new_file->media_meta->recorded_date =
+ SAFE_STRDUP(src->media_meta->recorded_date);
+ new_file->media_meta->width =
+ src->media_meta->width;
+ new_file->media_meta->height =
+ src->media_meta->height;
+ new_file->media_meta->duration =
+ src->media_meta->duration;
+ new_file->media_meta->copyright =
+ SAFE_STRDUP(src->media_meta->copyright);
+ new_file->media_meta->track_num =
+ SAFE_STRDUP(src->media_meta->track_num);
+ new_file->media_meta->description =
+ SAFE_STRDUP(src->media_meta->description);
+ new_file->media_meta->composer =
+ SAFE_STRDUP(src->media_meta->composer);
+ new_file->media_meta->year =
+ SAFE_STRDUP(src->media_meta->year);
+ new_file->media_meta->bitrate =
+ src->media_meta->bitrate;
+ new_file->media_meta->samplerate =
+ src->media_meta->samplerate;
+ new_file->media_meta->channel =
+ src->media_meta->channel;
+ new_file->media_meta->extra_media_meta =
+ SAFE_STRDUP(src->media_meta->extra_media_meta);
+ }
+
+ if (NULL != src->cloud_meta) {
+ new_file->cloud_meta->service_name =
+ SAFE_STRDUP(src->cloud_meta->service_name);
+ new_file->cloud_meta->usage_byte =
+ src->cloud_meta->usage_byte;
+ new_file->cloud_meta->quota_byte =
+ src->cloud_meta->quota_byte;
+ new_file->cloud_meta->extra_cloud_meta =
+ SAFE_STRDUP(src->cloud_meta->extra_cloud_meta);
+ }
+
+ new_file->plugin_name =
+ SAFE_STRDUP(src->plugin_name);
+ new_file->object_id =
+ SAFE_STRDUP(src->object_id);
+ new_file->storage_path =
+ SAFE_STRDUP(src->storage_path);
+ new_file->file_size =
+ src->file_size;
+ new_file->created_time =
+ src->created_time;
+ new_file->modified_time =
+ src->modified_time;
+ new_file->file_info_index =
+ src->file_info_index;
+ new_file->content_type =
+ src->content_type;
+ new_file->extra_file_info =
+ SAFE_STRDUP(src->extra_file_info);
+
+ *dst_file = new_file;
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_storage_file_destroy(service_storage_file_h file)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if (NULL == file) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+ service_storage_file_h file_info = file;
+ service_storage_unref_file_info(&file_info);
+
+ return ret;
+}
+
+int service_storage_file_list_get_length(service_storage_file_list_h list,
+ int *length)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if ((NULL == list) || (NULL == length)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ *length = list->length;
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_storage_file_list_foreach_file(service_storage_file_list_h list,
+ service_storage_file_cb callback,
+ void *user_data)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if ((NULL == list) || (NULL == callback)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (0 > list->length) {
+ ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
+ } else {
+ int i;
+ bool is_continue = true;
+ for (i = 0; i < list->length; i++) {
+ if (is_continue) {
+ is_continue = callback(list->list[i], user_data);
+ }
+ }
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_storage_file_get_logical_path(service_storage_file_h file,
+ char **path)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if ((NULL == file) || (NULL == path)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ *path = SAFE_STRDUP(file->storage_path);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_storage_file_get_physical_path(service_storage_file_h file,
+ char **path)
+{
+
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if ((NULL == file) || (NULL == path)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ *path = SAFE_STRDUP(file->object_id);
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_storage_file_is_dir(service_storage_file_h file,
+ bool *is_dir)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if ((NULL == file) || (NULL == is_dir)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (SERVICE_ADAPTOR_STORAGE_CONTENT_TYPE_FOLDER == file->content_type) {
+ *is_dir = true;
+ } else {
+ *is_dir = false;
+ }
+
+ sac_api_end(ret);
+ return ret;
+}
+
+int service_storage_file_get_size(service_storage_file_h file,
+ unsigned long long *size)
+{
+ sac_api_start();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if ((NULL == file) || (NULL == size)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ *size = file->file_size;
+
+ sac_api_end(ret);
+ return ret;
+}
+
+void *_remove_runnable(void *_data)
+{
+ FUNC_START();
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ struct __async_wrapper_context *_params = (struct __async_wrapper_context *)_data;
+
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ ret = _dbus_remove_file(_params->plugin->service_handle_name, _params->path, NULL, &error);
+
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+ service_adaptor_set_last_result(error.code, error.msg);
+ free(error.msg);
+ }
+
+ ((service_storage_result_cb)_params->callback)(ret, _params->user_data);
+
+ free(_params->path);
+ free(_params);
+
+ FUNC_END();
+ return NULL;
+}
+
+
+
+int service_storage_remove(service_plugin_h plugin,
+ const char *remove_path,
+ service_storage_result_cb callback,
+ void *user_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if ((NULL == plugin) || (NULL == callback) || (NULL == remove_path)) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ if (NULL == plugin->service_handle_name) {
+ FUNC_STOP();
+ return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+ }
+/*
+ if (CLIENT_APP_TYPE_APPLICATION == plugin->app_type) {
+ int privilege_ret = 0;
+ privilege_ret = privilege_checker_check_privilege(TIZEN_PRIVILEGE_NAME_INTERNET);
+ if (PRIVILEGE_CHECKER_ERR_NONE != privilege_ret) {
+ sac_error("Privilege check error (ret : %d)", privilege_ret);
+ return SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED;
+ }
+ }
+*/
+ struct __async_wrapper_context *params = NULL;
+ params = (struct __async_wrapper_context *) calloc(1, sizeof(struct __async_wrapper_context));
+
+ if (NULL == params) {
+ sac_warning("Memory allocation failed");
+ ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ } else {
+ params->plugin = plugin;
+ params->path = strdup(remove_path);
+ params->callback = (void *)callback;
+ params->user_data = user_data;
+
+ int thread_ret = 0;
+ pthread_t remove_thread;
+ thread_ret = pthread_create(&remove_thread, NULL, _remove_runnable, (void *)params);
+
+ if (thread_ret) {
+ sac_warning("Thread create failed");
+ ret = SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ free(params->path);
+ free(params);
+ }
+ }
+
+ return ret;
+
+}
+
+
+
+
+/******************************** private feature */
+
+
+/** @brief Registers File Progress Listener
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_register_file_progress_listener(service_adaptor_h handle,
+ service_adaptor_file_progress_cb callback,
+ void *user_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ _signal_queue_add_task(PRIVATE_SIGNAL_FILE_PROGRESS_ID, (uint32_t) callback, handle, user_data);
+
+ return ret;
+}
+
+/** @brief Unregisters File Progress Listener
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_unregister_file_progress_listener(service_adaptor_h handle,
+ void *user_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ service_adaptor_task_h task = _signal_queue_get_task(PRIVATE_SIGNAL_FILE_PROGRESS_ID);
+
+ if (NULL == task) {
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+
+ _signal_queue_del_task(task);
+
+ return ret;
+}
+
+/** @brief Registers File Transfer Completion Listener
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_register_file_transfer_completion_listener(service_adaptor_h handle,
+ service_adaptor_file_transfer_completion_cb callback,
+ void *user_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ _signal_queue_add_task(PRIVATE_SIGNAL_FILE_TRANSFER_COMPLETION_ID, (uint32_t) callback, handle, user_data);
+
+ return ret;
+}
+
+/** @brief Unregisters Forward Online Message Listener
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_unregister_file_transfer_completion_listener(service_adaptor_h handle,
+ void *user_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ service_adaptor_task_h task = _signal_queue_get_task(PRIVATE_SIGNAL_FILE_TRANSFER_COMPLETION_ID);
+
+ if (NULL == task) {
+ return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+ }
+
+ _signal_queue_del_task(task);
+
+ return ret;
+}
+
+/** @brief Downloads a server file and writes it to local file
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_download_file(service_adaptor_h handle,
+ const char *server_path,
+ const char *download_path,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == server_path) || (NULL == download_path)) {
+ sac_error("Invalid Parameter");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _dbus_download_file(handle->service_name, server_path, download_path, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ return ret;
+}
+
+/** @brief Downloads a server file and writes it to local file (Async)
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_download_file_async(service_adaptor_h handle,
+ const char *server_path,
+ const char *download_path,
+ service_adaptor_file_h *file_handle,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == server_path) || (NULL == download_path)) {
+ sac_error("Invalid Parameter");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _private_dbus_download_file_async(handle->service_name, server_path, download_path, file_handle, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ return ret;
+}
+
+/** @brief Uploads a server file and writes it to local file
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_upload_file(service_adaptor_h handle,
+ const char *upload_path,
+ const char *server_path,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == upload_path) || (NULL == server_path)) {
+ sac_error("Invalid Parameter");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ service_storage_file_h file = NULL;
+ ret = _dbus_upload_file(handle->service_name, upload_path, server_path, &file, user_data, &error);
+ service_storage_unref_file_info(&file);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ return ret;
+}
+
+/** @brief Uploads a server file and writes it to local file (Async)
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_upload_file_async(service_adaptor_h handle,
+ const char *upload_path,
+ const char *server_path,
+ service_adaptor_file_h *file_handle,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == upload_path) || (NULL == server_path)) {
+ sac_error("Invalid Parameter");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _private_dbus_upload_file_async(handle->service_name, upload_path, server_path, file_handle, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ return ret;
+}
+
+/** @brief Downloads a server file and writes it to local file
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_download_file_publish(service_adaptor_h handle,
+ const char *publish_url,
+ const char *download_path,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == publish_url) || (NULL == download_path)) {
+ sac_error("Invalid Parameter");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _dbus_download_file_publish(handle->service_name, publish_url, download_path, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ return ret;
+}
+
+/** @brief Downloads a server file and writes it to local file (Async)
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_download_file_publish_async(service_adaptor_h handle,
+ const char *publish_url,
+ const char *download_path,
+ service_adaptor_file_h *file_handle,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == publish_url) || (NULL == download_path)) {
+ sac_error("Invalid Parameter");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _dbus_download_file_publish_async(handle->service_name, publish_url, download_path, file_handle, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ return ret;
+}
+
+/** @brief Uploads a server file and writes it to local file
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_upload_file_publish(service_adaptor_h handle,
+ const char *upload_path,
+ const char *server_path,
+ char **publish_url,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == upload_path) || (NULL == server_path) || (NULL == publish_url)) {
+ sac_error("Invalid Parameter");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _dbus_upload_file_publish(handle->service_name, upload_path, server_path, publish_url, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ return ret;
+}
+
+/** @brief Uploads a server file and writes it to local file (Async)
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_upload_file_publish_async(service_adaptor_h handle,
+ const char *upload_path,
+ const char *server_path,
+ service_adaptor_file_h *file_handle,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == upload_path) || (NULL == server_path)) {
+ sac_error("Invalid Parameter");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _dbus_upload_file_publish_async(handle->service_name, upload_path, server_path, file_handle, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ return ret;
+}
+
+/** @brief Downloads a thumbnail file and writes it to local file
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_download_thumbnail_publish(service_adaptor_h handle,
+ const char *publish_url,
+ const char *download_path,
+ service_adaptor_thumbnail_size_e size,
+ service_adaptor_error_s **error_code,
+ void *user_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+ char thumbnail_url[2048] = {0,};
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == publish_url) || (NULL == download_path)) {
+ sac_error("Invalid Parameter");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ char public_token[1024], auth_code[1024];
+ sscanf(publish_url, "%[^'?']?auth_code=%s", public_token, auth_code);
+ snprintf(thumbnail_url, 2048, "%s_%d?auth_code=%s", public_token, size, auth_code);
+
+ ret = _dbus_download_file_publish(handle->service_name, thumbnail_url, download_path, user_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ return ret;
+}
+
+/** @brief Requests File Status
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_get_file_status(service_adaptor_h handle,
+ service_adaptor_file_h file_handle,
+ service_adaptor_file_status_s **status,
+ service_adaptor_error_s **error_code,
+ void **server_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == file_handle) || (NULL == status)) {
+ sac_error("Invalid Parameter");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _dbus_get_file_status(handle->service_name, file_handle, status, server_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ return ret;
+}
+
+/** @brief Cancels File Transfer
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_cancel_file_transfer(service_adaptor_h handle,
+ service_adaptor_file_h file_handle,
+ service_adaptor_error_s **error_code,
+ void **server_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == file_handle)) {
+ sac_error("Invalid Parameter");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _dbus_cancel_file_transfer(handle->service_name, file_handle, server_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ return ret;
+}
+
+/** @brief Pause File Transfer
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_pause_file_transfer(service_adaptor_h handle,
+ service_adaptor_file_h file_handle,
+ service_adaptor_error_s **error_code,
+ void **server_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == file_handle)) {
+ sac_error("Invalid Parameter");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _dbus_pause_file_transfer(handle->service_name, file_handle, server_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ return ret;
+}
+
+/** @brief Resume File Transfer
+ * @return int
+ * @remarks :
+ */
+SERVICE_ADAPTOR_CLIENT_PUBLIC_API
+int service_adaptor_resume_file_transfer(service_adaptor_h handle,
+ service_adaptor_file_h file_handle,
+ service_adaptor_error_s **error_code,
+ void **server_data)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ service_adaptor_error_s error;
+ error.msg = NULL;
+
+ if ((NULL == handle) || (NULL == handle->plugin) || (NULL == file_handle)) {
+ sac_error("Invalid Parameter");
+ _set_error_code(error_code, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER, "Invalid Argument");
+ return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _dbus_resume_file_transfer(handle->service_name, file_handle, server_data, &error);
+
+ if (ret != SERVICE_ADAPTOR_ERROR_NONE) {
+ _assign_error_code(&error, error_code);
+ }
+
+ return ret;
+}
+
+/******************************** private feature */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <glib-object.h>
+
+#include <dbus-server.h>
+
+#include "service_adaptor_client_log.h"
+#include "dbus_client.h"
+#include "util/service_adaptor_client_util.h"
+
+#include <bundle.h>
+
+/** @brief NULL-pointer safe string duplication function
+ * This function will not crash if source string pointer is NULL. It is user's
+ * responsibility to free the result pointer.
+ * @param str pointer to string which should be duplicated
+ * @return pointer to the duplicated string
+ * @remarks :
+ */
+char *_safe_strdup(const char *str)
+{
+ if (NULL == str) {
+ return NULL;
+ } else {
+ return strdup(str);
+ }
+}
+
+void __set_error_code(service_adaptor_error_s **error_code, int code, const char *msg)
+{
+ if (NULL != error_code) {
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if (NULL != _error) {
+ _error->code = code;
+ _error->msg = strdup(msg);
+ }
+ *error_code = _error;
+ }
+}
+
+void __assign_error_code(service_adaptor_error_s *source_error, service_adaptor_error_s **target_error)
+{
+ service_adaptor_error_s *_error = (service_adaptor_error_s *) calloc(1, sizeof(service_adaptor_error_s));
+ if ((NULL != _error) && (NULL != target_error)) {
+ _error->code = source_error->code;
+ _error->msg = source_error->msg;
+ *target_error = _error;
+ } else {
+ free(_error);
+ free(source_error->msg);
+ }
+}
+
+int _get_result_code(long long int error_code)
+{
+ switch (error_code) {
+ case SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_NONE:
+ return SERVICE_ADAPTOR_ERROR_NONE;
+ case SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_COMMON_NO_DATA:
+ sac_error("SERVICE_ADAPTOR_ERROR_NO_DATA");
+ return SERVICE_ADAPTOR_ERROR_NO_DATA;
+ case SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_COMMON_TIMED_OUT:
+ sac_error("SERVICE_ADAPTOR_ERROR_TIMED_OUT");
+ return SERVICE_ADAPTOR_ERROR_TIMED_OUT;
+ case SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_COMMON_NOT_SUPPORTED:
+ sac_error("SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED");
+ return SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED;
+ case SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_COMMON_PERMISSION_DENIED:
+ sac_error("SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED");
+ return SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED;
+
+ case SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_AUTH_NOT_AUTHORIZED:
+ sac_error("SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED");
+ return SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED;
+
+ case SERVICE_ADAPTOR_PROTOCOL_RETURN_CODE_MESSAGE_NETWORK:
+ sac_error("SERVICE_ADAPTOR_ERROR_NETWORK");
+ return SERVICE_ADAPTOR_ERROR_NETWORK;
+
+ default:
+ sac_error("SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED");
+ return SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED;
+ }
+}
+
+
+int _ipc_get_simple_result(GVariant *call_result, GError *g_error, service_adaptor_error_s *error)
+{
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+ if (NULL == call_result) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ if (NULL != g_error) {
+ sac_error("G_IO_ERROR DEBUG (%d)", (int)(g_error->code));
+ if (g_error->code == G_IO_ERROR_TIMED_OUT) {
+ ret = SERVICE_ADAPTOR_ERROR_TIMED_OUT;
+ }
+ error->msg = __SAFE_STRDUP(g_error->message);
+ g_error_free(g_error);
+ }
+ } else {
+ if (FALSE == g_variant_is_of_type(call_result, G_VARIANT_TYPE("(ts)"))) {
+ error->code = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ error->msg = strdup("D-Bus return type error");
+ ret = SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+ } else {
+ GVariant *call_result_struct[2];
+ call_result_struct[0] = g_variant_get_child_value(call_result, 0);
+ call_result_struct[1] = g_variant_get_child_value(call_result, 1);
+
+ uint64_t remote_call_result = g_variant_get_uint64(call_result_struct[0]);
+ if (SERVICE_ADAPTOR_ERROR_NONE != remote_call_result) {
+ error->code = remote_call_result;
+ error->msg = ipc_g_variant_dup_string(call_result_struct[1]);
+ ret = _get_result_code(remote_call_result);
+ }
+ g_variant_unref(call_result_struct[0]);
+ g_variant_unref(call_result_struct[1]);
+ }
+ g_variant_unref(call_result);
+ }
+
+ return ret;
+}
+
+static void __g_hash_iterator(gpointer key, gpointer value, gpointer user_data)
+{
+ if (key && value && user_data) {
+ bundle_add_str((bundle *)user_data, (const char *)key, (const char *)value);
+ }
+}
+
+void _create_raw_data_from_plugin_property(void *property, GVariantBuilder **builder)
+{
+ if ((NULL == property) || (NULL == builder)) {
+ return;
+ }
+
+ *builder = g_variant_builder_new(G_VARIANT_TYPE(service_adaptor_raw_data_s_type));
+
+ bundle *bd = bundle_create();
+
+ if (NULL != bd) {
+ g_hash_table_foreach((GHashTable *)property, __g_hash_iterator, (gpointer)bd);
+ unsigned char *input_str = NULL;
+ int input_len = 0;
+
+ int ret = bundle_encode(bd, &input_str, &input_len);
+ if (!ret && input_str && input_len) {
+ for (int k = 0; k < input_len; k++) {
+ g_variant_builder_add((*builder), "(y)", (guchar)input_str[k]);
+ }
+ }
+
+ sac_debug_func("input_str_len(%d)", input_len);
+ free(input_str);
+ input_str = NULL;
+ bundle_free(bd);
+ bd = NULL;
+ }
+}
+
MESSAGE(">>> current directory: ${CMAKE_CURRENT_SOURCE_DIR}")
MESSAGE(">>> Build type: ${CMAKE_BUILD_TYPE}")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VISIBILITY} -fvisibility=hidden")
+#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VISIBILITY} -fvisibility=hidden")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--gc-sections")
ADD_DEFINITIONS("-DSERVICE_ADAPTOR_DEBUGGING")
SET(PLUGIN-CONFIG-LIB "plugin-config")
SET(PLUGIN-CONFIG-SRCS
${CMAKE_SOURCE_DIR}/common/plugin_config/plugin_message.c
+ ${CMAKE_SOURCE_DIR}/common/plugin_config/pluginConfig.c
+ ${CMAKE_SOURCE_DIR}/common/plugin_config/trimming.c
)
INCLUDE_DIRECTORIES(
INSTALL(TARGETS ${PLUGIN-CONFIG-LIB} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+SET(PLUGIN-CONFIG-HEADERS
+ ${CMAKE_SOURCE_DIR}/common/plugin_config/pluginConfig.h
+ ${CMAKE_SOURCE_DIR}/common/plugin_config/pluginConfigTypes.h
+ ${CMAKE_SOURCE_DIR}/common/plugin_config/plugin_message.h
+)
+INSTALL(FILES ${PLUGIN-CONFIG-HEADERS} DESTINATION include)
+
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/**
+ * @file pluginConfig.c
+ * @author Dawid Kozinski (d.kozinski@samsung.com)
+ *
+ * @brief Plugin configuration parser done in C99.
+ */
+
+/* threads */
+#include <glib.h>
+#include "pluginConfig.h"
+
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <float.h>
+
+#include "pluginConfigLog.h"
+
+#define UNUSED(x) (void)(x)
+
+/*********************************************************************************
+ * C99 implementation
+ ******************************************************************************/
+/*bool a = true; */
+
+/******************************************************************************
+ *
+ * Implicit Declarations of trimming functions
+ * this only describes and assumes allocated elsewhere (trimming.c)
+ *
+ ******************************************************************************/
+/**
+* @brief trim from start, i.e. left side
+* Trimming leading whitespace from string
+*
+* @param s ...
+* @return :char*
+**/
+extern char *plugin_internal_ltrim(char *s);
+
+/**
+* @brief trim from end, i.e. right side
+* Trimming trailing whitespace from string
+*
+* @param s ...
+* @return :char*
+**/
+extern char *plugin_internal_rtrim(char *s);
+
+/**
+* @brief trim from both ends
+* Trimming leading and trailing whitespace from string
+* @param s ...
+* @return :string&
+**/
+extern char *plugin_internal_trim(char *s);
+
+/******************************************************************************
+ * Typedefs
+ ******************************************************************************/
+
+/******************************************************************************
+ * [unique name][cloud_adaptor_handle*]
+ ******************************************************************************/
+/**
+* @typedef plugin_internal_MapStrStr
+* Section data
+* |---------------------------|-----------------------------------------------|
+* | KEY : char* | VALUE : char* |
+* |---------------------------|-----------------------------------------------|
+* | KEY1 | VAL1 |
+* |---------------------------|-----------------------------------------------|
+* | KEY2 | VAL2 |
+* |---------------------------|-----------------------------------------------|
+* | KEY3 | VAL3 |
+* |---------------------------|-----------------------------------------------|
+*/
+typedef GHashTable plugin_internal_MapStrStr;
+
+/**
+* @typedef plugin_internal_MapStrSection
+* Sections
+* |---------------------------|-----------------------------------------------|
+* | SECTION NAME : char* | SECTION PTR : MapStrStr * |
+* |---------------------------|-----------------------------------------------|
+* | SN1 | SP1 |
+* |---------------------------|-----------------------------------------------|
+* | SN2 | SP2 |
+* |---------------------------|-----------------------------------------------|
+* | SN3 | SP3 |
+* |---------------------------|-----------------------------------------------|
+*/
+typedef GHashTable plugin_internal_MapStrSection;
+
+/**
+* @typedef plugin_internal_ListSection
+* Sections
+* |------------------------------------------|
+* | SECTION PTR : MapStrStr * |
+* |------------------------------------------|
+* | SP1 |
+* |------------------------------------------|
+* | SP2 |
+* |------------------------------------------|
+* | SN3 |
+* |------------------------------------------|
+*/
+typedef GList plugin_internal_ListSection;
+
+/******************************************************************************
+ * ConfigParserState struct
+ ******************************************************************************/
+typedef struct plugin_internal_ConfigParserState {
+ char *current_section_name;
+ plugin_internal_MapStrStr *current_section;
+} ConfigParserState;
+
+/******************************************************************************
+ * ConfigData class
+ ******************************************************************************/
+typedef struct plugin_internal_ConfigData {
+ GMutex *data_mutex;
+
+ /**
+ * @brief Filepath to the read configuration file.
+ **/
+ char *filepath;
+
+ /**
+ * @brief Describes layout of the data in the file.
+ **/
+ PluginConfigType type;
+
+ /**
+ * @brief Variable that stores the all sections of configuration,
+ * meant to be accessed through the field 'configuration'.
+ **/
+ plugin_internal_ListSection *sections;
+
+ /**
+ * @brief Variable that stores the whole configuration.
+ **/
+ plugin_internal_MapStrSection *configuration;
+} plugin_internal_ConfigData;
+
+/******************************************************************************
+ * Declarations (methods of ConfigData class)
+ ******************************************************************************/
+
+/******************************************************************************
+ * Calbacks
+ ******************************************************************************/
+
+/**
+ * @brief Function which is called when a data element of configuration map
+ * being a member of plugin_internal_ConfigData struct
+ * (@see plugin_internal_ConfigData) is destroyed.
+ * @see plugin_internal_MapStrSection
+ *
+ * @param data pointer to the user data
+ * @return void
+ **/
+static
+void plugin_internal_ConfigData_cbMapStrSectionFreeData(gpointer data);
+
+/**
+ * @brief Function passed to g_hash_table_foreach().
+ * Function is called for each key/value pair.
+ *
+ * @param key a key
+ * @param value the value corresponding to the key
+ * @param user_data user data passed to g_hash_table_foreach()
+ * @return void
+ **/
+static
+void plugin_internal_ConfigData_cbMapStrSectionEntryCopy(gpointer key,
+ gpointer value,
+ gpointer user_data);
+
+/**
+ * @brief Function passed to g_hash_table_foreach().
+ * Function is called for each key/value pair.
+ *
+ * @param key a key
+ * @param value the value corresponding to the key
+ * @param user_data user data passed to g_hash_table_foreach()
+ * @return void
+ **/
+static
+void plugin_internal_ConfigData_cbMapStrSectionCopy(gpointer key,
+ gpointer value,
+ gpointer user_data);
+/**
+ * @brief Function passed to g_list_foreach().
+ * The function called for each element's data.
+ *
+ * @param data the element's data.
+ * @param user_data user data passed to g_list_foreach() or g_slist_foreach().
+ * @return gpointer
+ **/
+static
+gpointer plugin_internal_ConfigData_cbListSectionCopy(gconstpointer data,
+ gpointer user_data);
+
+/**
+ * @brief The function to be called to free each element's data.
+ * The function which is called when a data element is destroyed.
+ * It is passed the pointer to the data element and should free any memory and
+ * resources allocated for it.
+ *
+ * @param data the data element.
+ * @return void
+ **/
+static
+void plugin_internal_ConfigData_cbDestroySectionsList(gpointer data);
+
+/******************************************************************************
+ * Constructing object
+ ******************************************************************************/
+/**
+ * @brief Contruct object of type plugin_internal_ConfigData
+ * @return plugin_internal_ConfigData*
+ **/
+/*plugin_internal_ConfigData *plugin_internal_ConfigData_new(); */
+
+/**
+* @brief Contruct object of type plugin_internal_ConfigData and loads
+* configuration from the specified file.
+*
+* @param filepath a path to the configuration file
+* @param type expected type of configuration file, this value
+* determines how the file is parsed
+**/
+static
+plugin_internal_ConfigData *
+plugin_internal_ConfigData_new(const char *filepath, PluginConfigType type);
+
+/**
+* @brief Copy constructor.
+*
+* @param source ...
+**/
+#if 0
+static
+plugin_internal_ConfigData *
+plugin_internal_ConfigData_copy(const plugin_internal_ConfigData *source);
+#endif
+
+/******************************************************************************
+ * Destroying obect
+ ******************************************************************************/
+/**
+* @brief Removes configuration from memory, rendering this configuration invalid.
+*
+* @return void
+**/
+static
+void plugin_internal_ConfigData_clear(plugin_internal_ConfigData *self);
+
+/**
+* @brief Destructor.
+*
+**/
+static
+void plugin_internal_ConfigData_delete(plugin_internal_ConfigData *self);
+
+/******************************************************************************
+ * private methods
+ ******************************************************************************/
+
+/**
+ * @brief parse line of INI file
+ *
+ * @param self pointer to object of type plugin_internal_ConfigData
+ * @param state ...
+ * @param line pointer to the string containing line of file
+ * @return void
+ **/
+static
+void plugin_internal_ConfigData_parseLineIni(plugin_internal_ConfigData *self,
+ ConfigParserState *state,
+ const char *line);
+
+/* TODO Provide implementation */
+/**
+ * @todo Provide implementation
+ *
+ * @brief parse line of GIT config file
+ *
+ * @param self pointer to object of type plugin_internal_ConfigData
+ * @param state ...
+ * @param line pointer to the string containing line of file
+ * @return void
+ **/
+static
+void plugin_internal_ConfigData_parseLineGit(plugin_internal_ConfigData *self,
+ ConfigParserState *state,
+ const char *line);
+
+/* TODO Provide implementation */
+/**
+ * @todo Provide implementation
+ *
+ * @brief parse line of CSV config file
+ *
+ * @param self pointer to object of type plugin_internal_ConfigData
+ * @param state ...
+ * @param line pointer to the string containing line of file
+ * @param separator ...
+ * @return void
+ **/
+static
+void plugin_internal_ConfigData_parseLineCsv(plugin_internal_ConfigData *self,
+ ConfigParserState *state,
+ const char *line,
+ char separator);
+
+/* Public */
+/**
+ * @brief ...
+ *
+ * @param self pointer to object of type plugin_internal_ConfigData
+ * @param section ...
+ * @return int
+ **/
+static
+bool
+plugin_internal_ConfigData_hasSection(const plugin_internal_ConfigData *self,
+ const char *section);
+
+/**
+* @brief This method assumes that the given section exists. Use hasSection()
+* first, or use hasSectionAndKey() instead.
+*
+* @param self pointer to object of type plugin_internal_ConfigData
+* @param section name of the configuration section
+* @param key name of the key within that section
+* @return int 1 if such key exists
+**/
+static
+bool
+plugin_internal_ConfigData_hasKey(const plugin_internal_ConfigData *self,
+ const char *section,
+ const char *key);
+
+/**
+ * @brief ...
+ *
+ * @param self pointer to object of type plugin_internal_ConfigData
+ * @param section ...
+ * @param key ...
+ * @return int
+ **/
+static
+bool
+plugin_internal_ConfigData_hasSectionAndKey(const plugin_internal_ConfigData *self,
+ const char *section,
+ const char *key);
+
+/**
+ * @brief ...
+ *
+ * @param self pointer to object of type plugin_internal_ConfigData
+ * @return const char*
+ **/
+static
+const char *
+plugin_internal_ConfigData_getFilepath(const plugin_internal_ConfigData *self);
+
+/**
+ * @brief ...
+ *
+ * @param self pointer to object of type plugin_internal_ConfigData
+ * @return PluginConfigType
+ **/
+static
+PluginConfigType
+plugin_internal_ConfigData_getType(const plugin_internal_ConfigData *self);
+
+/**
+ * @brief ...
+ *
+ * @param self pointer to object of type plugin_internal_ConfigData
+ * @param section_name ...
+ * @param section_key ...
+ * @return const char*
+ **/
+static
+const char *
+plugin_internal_ConfigData_getEntry(const plugin_internal_ConfigData *self,
+ const char *section_name,
+ const char *section_key);
+
+/******************************************************************************
+ * Definitions (methods of ConfigData class)
+ ******************************************************************************/
+
+/******************************************************************************/
+static
+void plugin_internal_ConfigData_cbMapStrSectionFreeData(gpointer data)
+{
+ /* TODO Is it enough ? */
+ /* free(data); */
+ /* data = NULL; */
+}
+
+#if 0
+/******************************************************************************/
+plugin_internal_ConfigData *plugin_internal_ConfigData_new()
+{
+ plugin_internal_ConfigData *self;
+ self = (plugin_internal_ConfigData *)calloc(1, sizeof(plugin_internal_ConfigData));
+
+ GMutex *data_mutex = (GMutex *)calloc(1, sizeof(GMutex));
+ g_mutex_init(data_mutex);
+
+ self->data_mutex = data_mutex;
+ self->filepath = NULL;
+ self->type = CCT_INI;
+ self->sections = NULL;
+ self->configuration = NULL;
+
+ self->configuration = g_hash_table_new_full(g_str_hash, /* Hash function */
+ g_str_equal, /* Comparator */
+ plugin_internal_ConfigData_cbMapStrSectionFreeData, /* Key destructor */
+ plugin_internal_ConfigData_cbMapStrSectionFreeData); /* Val destructor */
+
+ return self;
+}
+#endif
+
+/******************************************************************************/
+static
+plugin_internal_ConfigData *
+plugin_internal_ConfigData_new(const char *filepath, PluginConfigType type)
+{
+ startfunc;
+
+ if (NULL == filepath) {
+ return NULL;
+ }
+
+ if (CCT_INVALID == type) {
+ return NULL;
+ }
+
+ plugin_internal_ConfigData *self;
+ self = (plugin_internal_ConfigData *)calloc(1, sizeof(plugin_internal_ConfigData));
+
+ if (NULL == self) {
+ return NULL;
+ }
+
+ GMutex *data_mutex = (GMutex *)calloc(1, sizeof(GMutex));
+ if (NULL == data_mutex) {
+ free(self);
+ return NULL;
+ }
+
+ g_mutex_init(data_mutex);
+
+ self->data_mutex = data_mutex;
+ self->filepath = strdup(filepath);
+ self->type = CCT_INI;
+ self->sections = NULL; /* sections.reserve(128); */
+ self->configuration = NULL;
+
+ self->configuration =
+ g_hash_table_new_full(g_str_hash, /* Hash function */
+ g_str_equal, /* Comparator */
+ plugin_internal_ConfigData_cbMapStrSectionFreeData, /* Key destructor */
+ plugin_internal_ConfigData_cbMapStrSectionFreeData);/* Val destructor */
+
+ FILE *fp;
+ char *line;
+ size_t len = 0;
+ ssize_t read;
+
+ fp = fopen(filepath, "r");
+
+ if (NULL == fp) {
+ /* exit(EXIT_FAILURE); */
+ if (self) {
+ if (self->data_mutex) {
+ g_mutex_clear(self->data_mutex);
+ free(self->data_mutex);
+ }
+ if (self->filepath)
+ free(self->filepath);
+ if (self->configuration)
+ g_hash_table_destroy(self->configuration);
+ free(self);
+ }
+ return NULL;
+ }
+
+ ConfigParserState state;
+
+ while ((read = getline(&line, &len, fp)) != -1) {
+ /* printf("Retrieved line of length %zu :\n", read); */
+ /* printf("%s", line); */
+
+ if (strlen(line) == 0)
+ continue;
+
+ switch (type) {
+ case CCT_INI:
+ plugin_internal_ConfigData_parseLineIni(self, &state, line);
+ break;
+ case CCT_GIT:
+ plugin_internal_ConfigData_parseLineGit(self, &state, line);
+ break;
+ case CCT_CSV_COMMA:
+ plugin_internal_ConfigData_parseLineCsv(self, &state, line, ',');
+ break;
+ case CCT_CSV_TAB:
+ plugin_internal_ConfigData_parseLineCsv(self, &state, line, '\t');
+ break;
+ case CCT_CSV_COLON:
+ plugin_internal_ConfigData_parseLineCsv(self, &state, line, ':');
+ break;
+ case CCT_CSV_SEMICOLON:
+ plugin_internal_ConfigData_parseLineCsv(self, &state, line, ';');
+ break;
+ default:
+ break;
+ }
+
+ free(line);
+ line = NULL;
+ }
+
+/* printf("configuration file %s was loaded\n", filepath); */
+ fclose(fp);
+
+ endfunc;
+ return self;
+}
+
+/******************************************************************************/
+static
+void plugin_internal_ConfigData_cbMapStrSectionEntryCopy(gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ startfunc;
+
+ plugin_internal_MapStrStr *copy_section = (plugin_internal_MapStrStr *)user_data;
+ g_hash_table_insert(copy_section, strdup((char *)key), strdup((char *)value));
+
+ endfunc;
+}
+
+/******************************************************************************/
+static
+void plugin_internal_ConfigData_cbMapStrSectionCopy(gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ startfunc;
+
+ plugin_internal_MapStrSection *copy_configuration = (plugin_internal_MapStrSection *)user_data;
+
+ plugin_internal_MapStrStr *section = (plugin_internal_MapStrStr *)value;
+
+ plugin_internal_MapStrStr *copy_section =
+ g_hash_table_new_full(g_str_hash, /* Hash function */
+ g_str_equal, /* Comparator */
+ plugin_internal_ConfigData_cbMapStrSectionFreeData, /* Key destructor */
+ plugin_internal_ConfigData_cbMapStrSectionFreeData); /* Val destructor */
+
+ g_hash_table_foreach(section, (GHFunc)plugin_internal_ConfigData_cbMapStrSectionEntryCopy, copy_section);
+
+ g_hash_table_insert(copy_configuration, strdup((char *)key), copy_section);
+
+ endfunc;
+}
+
+/******************************************************************************/
+static
+gpointer plugin_internal_ConfigData_cbListSectionCopy(gconstpointer src,
+ gpointer data)
+{
+ startfunc;
+
+ UNUSED(data);
+
+ plugin_internal_MapStrStr *section = (plugin_internal_MapStrStr *)src;
+
+ plugin_internal_MapStrStr *copy_section =
+ g_hash_table_new_full(g_str_hash, /* Hash function */
+ g_str_equal, /* Comparator */
+ plugin_internal_ConfigData_cbMapStrSectionFreeData, /* Key destructor */
+ plugin_internal_ConfigData_cbMapStrSectionFreeData); /* Val destructor */
+
+ g_hash_table_foreach(section,
+ (GHFunc)plugin_internal_ConfigData_cbMapStrSectionEntryCopy,
+ copy_section);
+
+ endfunc;
+ return copy_section;
+}
+
+/******************************************************************************/
+#if 0
+static
+plugin_internal_ConfigData *
+plugin_internal_ConfigData_copy(const plugin_internal_ConfigData *source)
+{
+ startfunc;
+
+ if (NULL == source) {
+ return NULL;
+ }
+
+ plugin_internal_ConfigData *self;
+ self = (plugin_internal_ConfigData *)calloc(1, sizeof(plugin_internal_ConfigData));
+
+ GMutex *data_mutex = (GMutex *)calloc(1, sizeof(GMutex));
+ g_mutex_init(data_mutex);
+
+ g_mutex_lock(source->data_mutex);
+
+ self->data_mutex = data_mutex;
+ self->filepath = strdup(source->filepath);
+ self->type = source->type;
+
+ self->sections = NULL;
+
+ self->configuration =
+ g_hash_table_new_full(g_str_hash, /* Hash function */
+ g_str_equal, /* Comparator */
+ plugin_internal_ConfigData_cbMapStrSectionFreeData, /* Key destructor */
+ plugin_internal_ConfigData_cbMapStrSectionFreeData);/* Val destructor */
+
+ /* copy source->configuration to self->configuration */
+ g_hash_table_foreach(source->configuration,
+ (GHFunc)plugin_internal_ConfigData_cbMapStrSectionCopy,
+ self->configuration);
+
+ /* copy source->sections to self->sections */
+ self->sections = g_list_copy_deep(source->sections,
+ plugin_internal_ConfigData_cbListSectionCopy,
+ NULL);
+
+ g_mutex_unlock(source->data_mutex);
+
+ endfunc;
+ return NULL;
+}
+#endif
+/******************************************************************************/
+static
+void plugin_internal_ConfigData_delete(plugin_internal_ConfigData *self)
+{
+ startfunc;
+
+ if (self) {
+ plugin_internal_ConfigData_clear(self);
+ }
+
+ endfunc;
+}
+
+/******************************************************************************
+ * PRIVATE
+ ******************************************************************************/
+static
+void
+plugin_internal_ConfigData_parseLineIni(plugin_internal_ConfigData *self,
+ ConfigParserState *state,
+ const char *line)
+{
+ startfunc;
+
+ if (NULL == self || NULL == line) {
+ return;
+ }
+
+ if (line[0] == ';')
+ return;
+
+ if (line[0] == '[') {
+ line = plugin_internal_trim((char *)line);
+
+ char *begin = strchr((char *)line, '[');
+ char *end = strrchr((char *)line, ']');
+
+ if (NULL == end) {
+ printf("Invalid section name %p\n", line);
+ return;
+ }
+
+ int section_name_len = end - begin - 1;
+
+ char *section_name = (char *)calloc(1, section_name_len + 1);
+ if (NULL == section_name) {
+ return;
+ }
+
+ strncpy(section_name, line + 1, section_name_len);
+ section_name[section_name_len] = '\0';
+
+ plugin_internal_MapStrStr *section =
+ g_hash_table_new_full(g_str_hash, /* Hash function */
+ g_str_equal, /* Comparator */
+ plugin_internal_ConfigData_cbMapStrSectionFreeData, /* Key destructor */
+ plugin_internal_ConfigData_cbMapStrSectionFreeData); /* Val destructor */
+
+ self->sections = g_list_append(self->sections, section);
+ /*sections.push_back(MapStrStr()); */
+
+ /*MapStrStr *section = &(sections[sections.size() - 1]); */
+ g_hash_table_insert(self->configuration, strdup(section_name), section);
+
+ /* configuration[section_name] = section; */
+
+ state->current_section_name = section_name;
+ state->current_section = section;
+ } else {
+ /* ---------------------------------------------------------------------
+ * |0|1|2|3|4|5|6|7|8|
+ * ---------------------------------------------------------------------
+ * |K|E|Y|1|=|V|A|L|1|
+ * ---------------------------------------------------------------------
+ * pch = 4
+ * len_key = 4
+ * len_val = 4
+ * len = 9
+ */
+ line = plugin_internal_trim((char *)line);
+ const char *pch = strchr((char *)line, '=');
+
+ if (pch != NULL) {
+ int len = strlen(line);
+ int key_len = pch - line + 1 ; /* +'\0' */
+ int value_len = len - key_len + 1; /* +'\0' */
+
+ char *key = (char *)calloc(1, key_len);
+ char *value = (char *)calloc(1, value_len);
+
+ if (NULL != key && NULL != value) {
+ strncpy(key, line, key_len - 1);
+ key[key_len - 1] = '\0';
+
+ strncpy(value, pch + 1, value_len - 1);
+ value[value_len - 1] = '\0';
+
+ g_hash_table_insert(state->current_section, strdup(key), strdup(value));
+ }
+ if (NULL != key) {
+ free(key);
+ key = NULL;
+ }
+ if (NULL != value) {
+ free(value);
+ value = NULL;
+ }
+ }
+ }
+
+ endfunc;
+}
+
+/******************************************************************************/
+static
+void
+plugin_internal_ConfigData_parseLineGit(plugin_internal_ConfigData *self,
+ ConfigParserState *state,
+ const char *line)
+{
+ startfunc;
+
+ if (NULL == self) {
+ return;
+ }
+
+ UNUSED(state);
+ UNUSED(line);
+
+ endfunc;
+}
+
+/******************************************************************************/
+static
+void
+plugin_internal_ConfigData_parseLineCsv(plugin_internal_ConfigData *self,
+ ConfigParserState *state,
+ const char *line,
+ char separator)
+{
+ startfunc;
+
+ if (NULL == self) {
+ return;
+ }
+
+ UNUSED(state);
+ UNUSED(line);
+ UNUSED(separator);
+
+ endfunc;
+}
+
+/******************************************************************************/
+static
+void plugin_internal_ConfigData_cbDestroySectionsList(gpointer data)
+{
+ startfunc;
+
+ plugin_internal_MapStrStr *section = (plugin_internal_MapStrStr *)data;
+ g_hash_table_destroy(section);
+
+ endfunc;
+}
+
+/******************************************************************************/
+static
+void plugin_internal_ConfigData_clear(plugin_internal_ConfigData *self)
+{
+ startfunc;
+
+ if (NULL == self) {
+ return;
+ }
+
+ free(self->filepath);
+
+ self->type = CCT_INVALID;
+
+ g_hash_table_destroy(self->configuration);
+ self->configuration = NULL;
+ g_list_free_full(self->sections, plugin_internal_ConfigData_cbDestroySectionsList);
+
+ endfunc;
+}
+
+/******************************************************************************/
+static
+bool
+plugin_internal_ConfigData_hasKey(const plugin_internal_ConfigData *self,
+ const char *section_name,
+ const char *section_key)
+{
+ startfunc;
+
+ if (NULL == self || NULL == self->configuration) {
+ return false;
+ }
+
+ g_mutex_lock(self->data_mutex);
+
+ gconstpointer lookup_key = (gconstpointer)section_name;
+ gpointer orig_key = NULL; /* key of self->configuration */
+ gpointer value = NULL; /* value of self->configuration */
+
+ gboolean result = g_hash_table_lookup_extended(self->configuration,
+ lookup_key,
+ &orig_key,
+ &value);
+
+ if (TRUE == result && value) {
+ plugin_internal_MapStrStr *ptrMapSection = (plugin_internal_MapStrStr *)value ;
+
+ lookup_key = (gconstpointer)section_key;
+ orig_key = NULL; /* key of ptrMapSection */
+ value = NULL; /* value of ptrMapSection */
+
+ result = g_hash_table_lookup_extended(ptrMapSection,
+ lookup_key,
+ &orig_key,
+ &value);
+ }
+
+ g_mutex_unlock(self->data_mutex);
+
+ endfunc;
+ return result;
+}
+
+/******************************************************************************
+ * PUBLIC
+ ******************************************************************************/
+static
+bool
+plugin_internal_ConfigData_hasSection(const plugin_internal_ConfigData *self,
+ const char *section_name)
+{
+ startfunc;
+
+ if (NULL == self) {
+ return false;
+ }
+
+ g_mutex_lock(self->data_mutex);
+
+ gconstpointer lookup_key = (gconstpointer)section_name;
+ gpointer orig_key = NULL; /* key of self->configuration */
+ gpointer value = NULL; /* value of self->configuration */
+
+ gboolean result = g_hash_table_lookup_extended(self->configuration,
+ lookup_key,
+ &orig_key,
+ &value);
+
+ g_mutex_unlock(self->data_mutex);
+
+ endfunc;
+ return result;
+}
+
+/******************************************************************************/
+static
+bool
+plugin_internal_ConfigData_hasSectionAndKey(const plugin_internal_ConfigData *self,
+ const char *section_name,
+ const char *section_key)
+{
+ startfunc;
+
+ if (NULL == self) {
+ return false;
+ }
+
+ g_mutex_lock(self->data_mutex);
+
+ gconstpointer lookup_key = (gconstpointer)section_name;
+ gpointer orig_key = NULL; /* key of self->configuration */
+ gpointer value = NULL; /* value of self->configuration */
+
+ gboolean result = g_hash_table_lookup_extended(self->configuration,
+ lookup_key,
+ &orig_key,
+ &value);
+
+ if (TRUE == result && value) {
+ plugin_internal_MapStrStr *ptrMapSection = (plugin_internal_MapStrStr *)value ;
+ lookup_key = (gconstpointer)section_key;
+ orig_key = NULL; /* key of ptrMapSection */
+ value = NULL; /* value of ptrMapSection */
+
+ result = g_hash_table_lookup_extended(ptrMapSection,
+ lookup_key,
+ &orig_key,
+ &value);
+ }
+
+ g_mutex_unlock(self->data_mutex);
+
+ endfunc;
+ return result;
+}
+
+/******************************************************************************/
+static
+const char *
+plugin_internal_ConfigData_getFilepath(const plugin_internal_ConfigData *self)
+{
+ startfunc;
+
+ if (NULL == self) {
+ return NULL;
+ }
+
+ g_mutex_lock(self->data_mutex);
+
+ const char *result = self->filepath;
+
+ g_mutex_unlock(self->data_mutex);
+
+ endfunc;
+ return result;
+}
+
+/******************************************************************************/
+static
+PluginConfigType
+plugin_internal_ConfigData_getType(const plugin_internal_ConfigData *self)
+{
+ startfunc;
+
+ if (NULL == self) {
+ return CCT_INVALID;
+ }
+
+ g_mutex_lock(self->data_mutex);
+
+ PluginConfigType result = self->type;
+
+ g_mutex_unlock(self->data_mutex);
+
+ endfunc;
+ return result;
+}
+
+/******************************************************************************/
+static
+const char *
+plugin_internal_ConfigData_getEntry(const plugin_internal_ConfigData *self,
+ const char *section_name,
+ const char *section_key)
+{
+ startfunc;
+
+ if (NULL == self) {
+ return NULL;
+ }
+
+ g_mutex_lock(self->data_mutex);
+
+ gconstpointer lookup_key = (gconstpointer)section_name;
+ gpointer orig_key = NULL; /* key of self->configuration */
+ gpointer value = NULL; /* value of self->configuration */
+
+ gboolean result = g_hash_table_lookup_extended(self->configuration,
+ lookup_key,
+ &orig_key,
+ &value);
+
+ if (TRUE == result && value) {
+ plugin_internal_MapStrStr *ptrMapSection = (plugin_internal_MapStrStr *)value ;
+
+ lookup_key = (gconstpointer)section_key;
+ orig_key = NULL; /* key of ptrMapSection */
+ value = NULL; /* value of ptrMapSection */
+
+ result = g_hash_table_lookup_extended(ptrMapSection,
+ lookup_key,
+ &orig_key,
+ &value);
+ }
+
+ g_mutex_unlock(self->data_mutex);
+
+ endfunc;
+ return (char *)value;
+}
+
+/******************************************************************************
+ * Config class
+ ******************************************************************************/
+/**
+ * @brief General-purpose, class for loading and reading configuration from
+ * simple plaintext files.
+ **/
+typedef struct plugin_Config {
+ bool _loaded;
+ plugin_internal_ConfigData *_configuration;
+} plugin_Config;
+
+/******************************************************************************
+ * Declarations (methods of Config class)
+ ******************************************************************************/
+
+/**
+ * @brief Construct object of type plugin_Config
+ *
+ * @return plugin_Config*
+ **/
+static
+plugin_Config *plugin_Config_new();
+
+/**
+ * @brief Destroy object of type plugin_Config
+ *
+ * @param self pointer to object of type plugin_Config
+ * @return void
+ **/
+static
+void plugin_Config_delete(plugin_Config *self);
+
+/**
+ * @brief Loads configuration to memory and/or gets raw data from configuration.
+ *
+ * @param self pointer to object of type plugin_Config
+ * @param section will return value attached to a key from this section
+ * @param key will return value attached to this key
+ * @return char*
+ **/
+static
+const char *
+plugin_Config_getRaw(plugin_Config *self, const char *section, const char *key);
+
+/**
+ * @brief Loads the configuration from a given file into memory.
+ *
+ * @param self pointer to object of type plugin_Config
+ * @param filepath path to the configuration file that will be loaded
+ * @param type expected type of configuration file, this value determines
+ * how the file is parsed
+ * @return int return 1 if successful, 0 otherwise
+ */
+static
+int
+plugin_Config_load(plugin_Config *self, const char *filepath, PluginConfigType type);
+
+/**
+ * @brief Unloads the configuration from the memory.
+ *
+ * The configuration is automatically unloaded when the Config object is
+ * destoyed, so this method does not have to be executed unless you need
+ * to extremely lower memory usage and few bytes matter.
+ *
+ * @param self pointer to object of type plugin_Config
+ * @return void
+ **/
+static void plugin_Config_unload(plugin_Config *self);
+
+/**
+* @brief Checks wheteher config file has been loaded.
+*
+* @return int return 1 if successful, 0 otherwise
+**/
+static bool plugin_Config_isLoaded(plugin_Config *self);
+
+/**
+ * @brief From loaded configuration, gets string value attached to given key.
+ *
+ * @param self pointer to object of type plugin_Config
+ * @param section ...
+ * @param key ...
+ * @return char* value attached to the key from the section
+ **/
+static
+const char *
+plugin_Config_getString(plugin_Config *self, const char *section, const char *key);
+
+/**
+ * @brief From loaded configuration, gets integer value attached to given key.
+ *
+ * @param self pointer to object of type plugin_Config
+ * @param section will return value attached to a key from this section
+ * @param key will return value attached to this key
+ * @return int
+ **/
+static
+int plugin_Config_getInt(plugin_Config *self, const char *section, const char *key);
+
+/**
+ * @brief From _loaded configuration, gets double value attached to given key.
+ *
+ * @param self pointer to object of type plugin_Config
+ * @param section will return value attached to a key from this section
+ * @param key will return value attached to this key
+ * @return double
+ **/
+static
+double getDouble(plugin_Config *self, const char *section, const char *key);
+
+/******************************************************************************
+ * Definitiions (methods of Config class)
+ ******************************************************************************/
+static
+plugin_Config *plugin_Config_new()
+{
+ startfunc;
+
+ plugin_Config *self;
+ self = (plugin_Config *)calloc(1, sizeof(plugin_Config));
+
+ if (NULL == self) {
+ return NULL;
+ }
+
+ self->_loaded = false;
+ self->_configuration = NULL;
+
+ endfunc;
+ return self;
+}
+
+/******************************************************************************/
+static
+void plugin_Config_delete(plugin_Config *self)
+{
+ startfunc;
+
+ if (self && self->_configuration) {
+ free(self->_configuration);
+ self->_configuration = NULL;
+ } else {
+ plugin_config_error("Invalid parameter");
+ }
+ free(self);
+
+ endfunc;
+}
+
+/******************************************************************************/
+static
+const char *
+plugin_Config_getRaw(plugin_Config *self, const char *section, const char *key)
+{
+ startfunc;
+
+ const char *ret = NULL;
+
+ if (self && self->_configuration) {
+ if (plugin_internal_ConfigData_hasSectionAndKey(
+ (const plugin_internal_ConfigData *)self->_configuration, section, key)) {
+ ret = plugin_internal_ConfigData_getEntry((const plugin_internal_ConfigData *)self->_configuration,
+ section,
+ key);
+ }
+ } else {
+ plugin_config_error("Invalid parameter");
+ }
+
+ endfunc;
+ return ret;
+}
+
+/******************************************************************************/
+static
+int plugin_Config_load(plugin_Config *self, const char *filepath, PluginConfigType type)
+{
+ startfunc;
+ int ret = 0;
+
+ if (self) {
+ if (self->_configuration) {
+ plugin_internal_ConfigData_delete(self->_configuration);
+ self->_configuration = NULL;
+ }
+
+ if (filepath && strlen(filepath) > 0) {
+ self->_configuration = plugin_internal_ConfigData_new(filepath, type);
+
+ if (self->_configuration) {
+ self->_loaded = 1;
+ ret = 1;
+ }
+ }
+ } else {
+ plugin_config_error("Invalid parameter");
+ }
+
+ endfunc;
+ return ret;
+}
+
+/******************************************************************************/
+static
+void plugin_Config_unload(plugin_Config *self)
+{
+ startfunc;
+
+ if (self && self->_configuration) {
+ plugin_internal_ConfigData_delete(self->_configuration);
+ self->_configuration = NULL;
+ self->_loaded = false;
+ } else {
+ plugin_config_error("Invalid parameter");
+ }
+
+ endfunc;
+}
+
+/******************************************************************************/
+static
+bool plugin_Config_isLoaded(plugin_Config *self)
+{
+ startfunc;
+
+ bool ret = false;
+
+ if (self) {
+ ret = self->_loaded;
+ } else {
+ plugin_config_error("Invalid parameter");
+ }
+
+ endfunc;
+ return ret;
+}
+
+/******************************************************************************/
+static
+const char *
+plugin_Config_getString(plugin_Config *self, const char *section, const char *key)
+{
+ plugin_config_debug_func();
+
+ return plugin_Config_getRaw(self, section, key);
+}
+
+
+/******************************************************************************/
+static
+int plugin_Config_getInt(plugin_Config *self, const char *section, const char *key)
+{
+ plugin_config_debug_func();
+
+ const char *result = plugin_Config_getRaw(self, section, key);
+ if (NULL == result) {
+ return INT_MIN;
+ }
+
+ return atoi(result);
+
+}
+
+/******************************************************************************/
+static
+double plugin_Config_getDouble(plugin_Config *self, const char *section, const char *key)
+{
+ plugin_config_debug_func();
+
+ const char *result = plugin_Config_getRaw(self, section, key);
+ if (NULL == result) {
+ return DBL_MIN;
+ }
+
+ return atof(result);
+}
+
+/******************************************************************************
+ * C API implementation
+ ******************************************************************************/
+
+/******************************************************************************/
+ConfigHandle plugin_config_create()
+{
+ plugin_config_debug_func();
+
+ return (ConfigHandle)plugin_Config_new();
+}
+
+/******************************************************************************/
+void plugin_config_delete(ConfigHandle config_handle)
+{
+ startfunc;
+
+ plugin_Config_delete((plugin_Config *)config_handle);
+
+ endfunc;
+}
+
+/******************************************************************************/
+void plugin_config_load(ConfigHandle config_handle, const char *filepath,
+ PluginConfigType type)
+{
+ startfunc;
+
+ if (config_handle) {
+ plugin_Config *pConfig = (plugin_Config *)(config_handle);
+ plugin_Config_load(pConfig, filepath, type);
+ } else {
+ plugin_config_error("Invalid parameter");
+ }
+
+ endfunc;
+}
+
+/******************************************************************************/
+void plugin_config_unload(ConfigHandle config_handle)
+{
+ startfunc;
+
+ if (config_handle) {
+ plugin_Config *pConfig = (plugin_Config *)(config_handle);
+ plugin_Config_unload(pConfig);
+ } else {
+ plugin_config_error("Invalid parameter");
+ }
+
+ endfunc;
+}
+
+/******************************************************************************/
+const char *plugin_config_get_string(ConfigHandle config_handle,
+ const char *section, const char *key)
+{
+ startfunc;
+
+ const char *val = NULL;
+
+ if (config_handle) {
+ plugin_Config *pConfig = (plugin_Config *)(config_handle);
+ val = plugin_Config_getString(pConfig, section, key);
+ } else {
+ plugin_config_error("Invalid parameter");
+ }
+
+ endfunc;
+ return val;
+}
+
+/******************************************************************************/
+int plugin_config_get_int(ConfigHandle config_handle, const char *section, const char *key)
+{
+ startfunc;
+
+ int ret = 0;
+
+ if (config_handle) {
+ plugin_Config *pConfig = (plugin_Config *)(config_handle);
+ ret = plugin_Config_getInt(pConfig, section, key);
+ } else {
+ plugin_config_error("Invalid parameter");
+ }
+
+ endfunc;
+ return ret;
+}
+
+/******************************************************************************/
+double plugin_config_get_double(ConfigHandle config_handle, const char *section, const char *key)
+{
+ startfunc;
+
+ double ret = 0;
+
+ if (config_handle) {
+ plugin_Config *pConfig = (plugin_Config *)(config_handle);
+ ret = plugin_Config_getDouble(pConfig, section, key);
+ } else {
+ plugin_config_error("Invalid parameter");
+ }
+
+ endfunc;
+ return ret;
+}
+
+/******************************************************************************/
+bool plugin_config_is_loaded(ConfigHandle config_handle)
+{
+ startfunc;
+ bool ret = false;
+
+ if (config_handle) {
+ plugin_Config *pConfig = (plugin_Config *)(config_handle);
+ ret = plugin_Config_isLoaded(pConfig);
+ } else {
+ plugin_config_error("Invalid parameter");
+ }
+
+ endfunc;
+ return ret;
+}
--- /dev/null
+/*
+* 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 PLUGIN_CONFIG_H_INCLUDED
+#define PLUGIN_CONFIG_H_INCLUDED
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#include <stdbool.h>
+
+/**
+ * @file pluginConfig.h
+ * @author Dawid Kozinski (d.kozinski@samsung.com)
+ *
+ * @brief Plugin configuration parser done in C++.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "pluginConfigTypes.h"
+
+ /**
+ * @brief ...
+ **/
+ typedef void *ConfigHandle;
+
+ /**
+ * @brief General-purpose, class for loading and reading configuration from
+ * simple plaintext files.
+ **/
+
+ /**
+ * @brief Creates a new empty Config object and returns an opaque "handle"
+ *
+ * @return ConfigHandle an opaque pointer to Config object.
+ **/
+ API
+ ConfigHandle plugin_config_create();
+
+ /**
+ * @brief Destroy config object
+ *
+ * @param config_handle an opaque pointer to Config object
+ * @return void
+ **/
+ API
+ void plugin_config_delete(ConfigHandle config_handle);
+
+ /**
+ * @brief Loads the configuration from given file to memory.
+ *
+ * @param config_handle an opaque pointer to Config object
+ * @param filepath configuration will be _loaded from given filepath
+ * @param type expected type of configuration file, this value determines how
+ * the file is parsed
+ * @return void
+ **/
+ API
+ void plugin_config_load(ConfigHandle config_handle, const char *filepath, PluginConfigType type);
+
+ /**
+ * @brief Unloads the configuration from the memory.
+ *
+ * The configuration is automatically un_loaded when the program is exitting,
+ * so this method does not have to be executed unless you need to extremely
+ * lower memory usage and few bytes matter.
+ *
+ * @param config_handle an opaque pointer to Config object
+ * @return void
+ **/
+ API
+ void plugin_config_unload(ConfigHandle config_handle);
+
+ /**
+ * @brief From _loaded configuration, gets string value attached to given key.
+ *
+ * @param config_handle an opaque pointer to Config object
+ * @param section will return value attached to a key from this section
+ * @param key will return value attached to this key
+ * @return :string
+ **/
+ API
+ const char *plugin_config_get_string(ConfigHandle config_handle, const char *section, const char *key);
+
+ /**
+ * @brief From _loaded configuration, gets integer value attached to given key.
+ *
+ * @param config_handle an opaque pointer to Config object
+ * @param section will return value attached to a key from this section
+ * @param key will return value attached to this key
+ * @return int
+ **/
+ API
+ int plugin_config_get_int(ConfigHandle config_handle, const char *section, const char *key);
+
+ /**
+ * @brief From _loaded configuration, gets double value attached to given key.
+ *
+ * @param config_handle an opaque pointer to Config object
+ * @param section will return value attached to a key from this section
+ * @param key will return value attached to this key
+ * @return double
+ **/
+ API
+ double plugin_config_get_double(ConfigHandle config_handle, const char *section, const char *key);
+
+ /**
+ * @brief Checks wheteher config file has been loaded.
+ *
+ * @param config_handle an opaque pointer to Config object
+ * @return 0 if config is not loaded
+ * 1 if config is loaded
+ **/
+ API
+ bool plugin_config_is_loaded(ConfigHandle config_handle);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* PLUGIN_CONFIG_H_INCLUDED */
+
--- /dev/null
+/*
+* 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 __PLUGIN_CONFIG_LOG_H__
+#define __PLUGIN_CONFIG_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 PLUGIN_CONFIG
+ *
+ * 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 PLUGIN_CONFIG: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 "PLUGIN_CONFIG"
+
+#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 plugin_config_gettid() 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 plugin_config_retv_if(expr, val) do { \
+ if(expr) { \
+ LOGE(FONT_COLOR_PURPLE"[%d]"FONT_COLOR_RESET, plugin_config_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 plugin_config_debug(fmt, arg...) do { \
+ LOGD(FONT_COLOR_GREEN"[%d]"fmt""FONT_COLOR_RESET, plugin_config_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 plugin_config_info(fmt, arg...) do { \
+ LOGI(FONT_COLOR_BLUE"[%d]"fmt""FONT_COLOR_RESET, plugin_config_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 plugin_config_warning(fmt, arg...) do { \
+ LOGW(FONT_COLOR_YELLOW"[%d]"fmt""FONT_COLOR_RESET, plugin_config_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 plugin_config_error(fmt, arg...) do { \
+ LOGE(FONT_COLOR_RED"[%d]"fmt""FONT_COLOR_RESET, plugin_config_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 plugin_config_fatal(fmt, arg...) do { \
+ LOGF(FONT_COLOR_BOLDRED"[%d]"fmt""FONT_COLOR_RESET, plugin_config_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 plugin_config_debug_func(fmt, arg...) do { \
+ LOGD(FONT_COLOR_CYAN"[%d]"fmt""FONT_COLOR_RESET, plugin_config_gettid(), ##arg); \
+} while (0)
+
+#define startfunc plugin_config_debug_func("+- START -");
+#define endfunc plugin_config_debug_func("+- END -");
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __PLUGIN_CONFIG_LOG_H__ */
--- /dev/null
+/*
+* 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 PLUGIN_CONFIG_TYPES
+#define PLUGIN_CONFIG_TYPES
+
+/**
+ * @file pluginConfigTypes.h
+ * @author Dawid Kozinski (d.kozinski@samsung.com)
+ *
+ * @brief Plugin configuration parser done in C++.
+ */
+
+/**
+ * @brief Types of supported configuration files.
+ **/
+typedef enum PluginConfigType
+{
+ /**
+ * @brief INI file format, as defined here: https://en.wikipedia.org/wiki/INI_file#Format
+ **/
+ CCT_INI = 1,
+
+ /**
+ * @brief Git config file format, as defined here:
+ **/
+ CCT_GIT = 1 << 1,
+
+ /**
+ * @brief Three column CSV file, columns are: section, key, value.
+ * They are separated with commas.
+ **/
+ CCT_CSV_COMMA = 1 << 2,
+
+ /**
+ * @brief Three column CSV file, columns are: section, key, value.
+ * They are separated with tabs.
+ **/
+ CCT_CSV_TAB = 1 << 3,
+
+ /**
+ * @brief Three column CSV file, columns are: section, key, value.
+ * They are separated with colons.
+ **/
+ CCT_CSV_COLON = 1 << 4,
+
+ /**
+ * @brief Three column CSV file, columns are: section, key, value.
+ * They are separated with semicolons.
+ **/
+ CCT_CSV_SEMICOLON = 1 << 5,
+
+ /**
+ * @brief As the name suggessts.
+ **/
+ CCT_INVALID = 0
+} PluginConfigType;
+
+#endif /* PLUGIN_CONFIG_TYPES */
#ifndef __TIZEN_SOCIAL_LIBSERVICE_PLUGIN_MESSAGE_H__
#define __TIZEN_SOCIAL_LIBSERVICE_PLUGIN_MESSAGE_H__
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
#include <stdint.h>
#include <stdbool.h>
typedef struct _plugin_message_array_s *plugin_message_array_h;
-
+API
int plugin_message_create(plugin_message_h *message);
+API
void plugin_message_destroy(plugin_message_h message);
+API
int plugin_message_set_value_number(plugin_message_h message, plugin_message_element_e field, pmnumber value);
+API
int plugin_message_get_value_number(plugin_message_h message, plugin_message_element_e field, pmnumber *value);
+API
int plugin_message_set_value_string(plugin_message_h message, plugin_message_element_e field, const char *value);
+API
int plugin_message_get_value_string(plugin_message_h message, plugin_message_element_e field, char **value);
+API
int plugin_message_set_value_bool(plugin_message_h message, plugin_message_element_e field, bool value);
+API
int plugin_message_get_value_bool(plugin_message_h message, plugin_message_element_e field, bool *value);
+API
int plugin_message_set_param_number(plugin_message_h message, int param_index, pmnumber value);
+API
int plugin_message_get_param_number(plugin_message_h message, int param_index, pmnumber *value);
+API
int plugin_message_set_param_string(plugin_message_h message, int param_index, const char *value);
+API
int plugin_message_get_param_string(plugin_message_h message, int param_index, char **value);
+API
int plugin_message_set_param_bool(plugin_message_h message, int param_index, bool value);
+API
int plugin_message_get_param_bool(plugin_message_h message, int param_index, bool *value);
+API
int plugin_message_set_param_array(plugin_message_h message, int param_index, plugin_message_array_h value);
+API
int plugin_message_get_param_array(plugin_message_h message, int param_index, plugin_message_array_h *value);
+API
int plugin_message_set_opt_param_number(plugin_message_h message, int param_index, pmnumber value);
+API
int plugin_message_get_opt_param_number(plugin_message_h message, int param_index, pmnumber *value);
+API
int plugin_message_set_opt_param_string(plugin_message_h message, int param_index, const char *value);
+API
int plugin_message_get_opt_param_string(plugin_message_h message, int param_index, char **value);
+API
int plugin_message_set_opt_param_bool(plugin_message_h message, int param_index, bool value);
+API
int plugin_message_get_opt_param_bool(plugin_message_h message, int param_index, bool *value);
+API
int plugin_message_set_opt_param_array(plugin_message_h message, int param_index, plugin_message_array_h value);
+API
int plugin_message_get_opt_param_array(plugin_message_h message, int param_index, plugin_message_array_h *value);
+API
int plugin_message_serialize(plugin_message_h message, char **data);
+API
int plugin_message_deserialize(const char *data, plugin_message_h *message);
+API
int plugin_message_array_create(const plugin_data_type *type_string, plugin_message_array_h *array);
+API
void plugin_message_array_destroy(plugin_message_array_h array);
+API
int plugin_message_array_add_element(plugin_message_array_h array, ...);
+API
int plugin_message_array_get_element(plugin_message_array_h array, int idx, ...);
#ifdef __cplusplus
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/**
+ * @file trimming.c
+ * @author Dawid Kozinski (d.kozinski@samsung.com)
+ *
+ * @brief Trimming functions taken from
+ * http://stackoverflow.com/questions/122616/how-do-i-trim-leading-trailing-whitespace-in-a-standard-way
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+/**
+* @brief trim from start, i.e. left side
+* Trimming leading whitespace from string
+*
+* @param s ...
+* @return :char*
+**/
+char *plugin_internal_ltrim(char *s);
+
+/**
+* @brief trim from end, i.e. right side
+* Trimming trailing whitespace from string
+*
+* @param s ...
+* @return :char*
+**/
+char *plugin_internal_rtrim(char *s);
+
+/**
+* @brief trim from both ends
+* Trimming leading and trailing whitespace from string
+* @param s ...
+* @return :string&
+**/
+char *plugin_internal_trim(char *s);
+
+/* ////////////////////////////////////////////////////////////////////////////////
+ // Implementation
+ //////////////////////////////////////////////////////////////////////////////// */
+char *plugin_internal_ltrim(char *s)
+{
+ char *newstart = s;
+
+ while (isspace(*newstart)) {
+ ++newstart;
+ }
+
+ /* newstart points to first non-whitespace char (which might be '\0') */
+ memmove(s, newstart, strlen(newstart) + 1); /* don't forget to move the '\0' terminator */
+
+ return s;
+}
+
+char *plugin_internal_rtrim(char *s)
+{
+ char *end = s + strlen(s);
+
+ /* find the last non-whitespace character */
+ while ((end != s) && isspace(*(end - 1))) {
+ --end;
+ }
+
+ /* at this point either (end == s) and s is either empty or all whitespace
+ so it needs to be made empty, or
+ end points just past the last non-whitespace character (it might point
+ at the '\0' terminator, in which case there's no problem writing
+ another there). */
+ *end = '\0';
+
+ return s;
+}
+
+char *plugin_internal_trim(char *s)
+{
+ return plugin_internal_rtrim(plugin_internal_ltrim(s));
+}
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_H__
+
+#include <tizen.h>
+#include <bundle.h>
+#include <service_adaptor_client_plugin.h>
+#include <service_adaptor_client_storage.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef TIZEN_ERROR_SERVICE_ADAPTOR
+#define TIZEN_ERROR_SERVICE_ADAPTOR -0x02F30000
+#endif
+
+/**
+ * @file service_adaptor_client.h
+ */
+
+/**
+ * @addtogroup SERVICE_ADAPTOR_MODULE
+
+ * @{
+ */
+
+
+/**
+ * @brief Enumerations of result code for Service Adaptor
+ */
+typedef enum
+{
+ SERVICE_ADAPTOR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Success */
+ SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Service plugin does not support API */
+ SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< The parameter is invalid */
+ SERVICE_ADAPTOR_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< API time out */
+ SERVICE_ADAPTOR_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< There is no data available */
+ SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ SERVICE_ADAPTOR_ERROR_UNKNOWN = TIZEN_ERROR_UNKNOWN, /**< Unknown error */
+ SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE = TIZEN_ERROR_SERVICE_ADAPTOR | 0x01, /**< IPC Connection unstabled */
+ SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED = TIZEN_ERROR_SERVICE_ADAPTOR | 0x02, /**< The error occured from Plugin, See detail from service_adaptor_get_last_result() and Plugin SPEC */
+ SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED = TIZEN_ERROR_SERVICE_ADAPTOR | 0x03, /**< Need Authorization */
+ SERVICE_ADAPTOR_ERROR_INVALID_STATE = TIZEN_ERROR_SERVICE_ADAPTOR | 0x04, /**< The handle state is invalid for processing API */
+}service_adaptor_error_e;
+
+/**
+* @brief The handle for connection and managing plugin handle of Service Adaptor
+* @details The handle can be created by service_adaptor_create()<br>
+* When a handle is no longer needed, use service_adaptor_destroy()
+* @see #service_adaptor_create()
+* @see #service_adaptor_destroy()
+*/
+typedef struct _service_adaptor_s *service_adaptor_h;
+
+/**
+* @brief Callback for service_adaptor_foreach_plugin API
+*
+* @param[in] plugin_uri The service plugin's unique uri, this value be set by plugin
+* @param[in] service_mask Masked value for <b>installed</b> service plugins, this value can be masked multiple enum (#service_plugin_service_type_e)
+* @param[in] user_data Passed data from #service_adaptor_foreach_plugin()
+* @remarks @a service_mask check using 'bit and' operation with #service_plugin_service_type_e
+* @remarks - for example,
+* @remarks if(@a service_mask & SERVICE_PLUGIN_SERVICE_STORAGE)
+* @remarks { @a USING_STORAGE_CODE }
+* @remarks Do not release memory of @a plugin_uri
+* @see service_plugin_service_type_e
+* @return @c true to continue with the next iteration of the loop,
+* otherwise @c false to break out of the loop
+* @pre service_adaptor_foreach_plugin() will invoke this callback.
+*/
+typedef bool (*service_adaptor_plugin_cb)(char *plugin_uri,
+ int service_mask,
+ void *user_data);
+/*==================================================================================================
+ FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+* @brief Create Service Adaptor
+* @since_tizen 2.4
+*
+* @param[out] service_adaptor The Service Adaptor handle
+* @remarks @a service_adaptor must be released memory using service_adaptor_destroy(), when a program no longer needs any function of Service Adaptor
+* @see service_adaptor_destroy()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_adaptor_create(service_adaptor_h *service_adaptor);
+
+/**
+* @brief Destroy Service Adaptor
+* @details It must called after a program no longer needs any function of Service Adaptor
+* @since_tizen 2.4
+*
+* @param[in] service_adaptor The handle of Service Adaptor
+* @see service_adaptor_create()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre @a service_adaptor must be issued by service_adaptor_create()
+*/
+int service_adaptor_destroy(service_adaptor_h service_adaptor);
+
+/**
+* @brief Foreach the list of plugin
+* @details Iterate to all installed plugin
+* @since_tizen 2.4
+*
+* @param[in] service_adaptor The handle of Service Adaptor
+* @param[in] callback The callback for foreach plugin
+* @param[in] user_data Passed data to callback
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no available plugins
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre @a service_adaptor must be issued by service_adaptor_create()
+*/
+int service_adaptor_foreach_plugin(service_adaptor_h service_adaptor,
+ service_adaptor_plugin_cb callback,
+ void *user_data);
+
+/**
+* @brief Create service plugin handle
+* @details Create plugin handle using @a plugin_uri
+* @since_tizen 2.4
+*
+* @param[in] service_adaptor The handle of Service Adaptor
+* @param[in] plugin_uri The specfic string for use plugin, this values are set by plugin
+* @param[out] plugin The handle for use Plugin APIs
+* @remarks @a plugin must be released memory using service_plugin_destroy() when you no longer needs plugin's API
+* @see service_plugin_destroy()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre @a service_adaptor must be issued by service_adaptor_create()
+*/
+int service_adaptor_create_plugin(service_adaptor_h service_adaptor,
+ const char *plugin_uri,
+ service_plugin_h *plugin);
+
+/**
+* @brief Gets service specfic last result
+* @details This function retrieves the last error code that be issued from plugin.<br>
+* When if API function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, gets using this function.
+* @since_tizen 2.4
+*
+* @param[out] err The error number that is defined service plugin SPEC
+* @remarks Thread safe functions
+* @remarks The result number's detail specification is defined service plugin or provider.
+* @remarks The detail error message can be got using service_adaptor_get_last_error_message()
+* @see service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no result
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_adaptor_get_last_result(int *err);
+
+/**
+* @brief Gets service specfic last result error message
+* @details This function retrieves the last error code that be issued from plugin.<br>
+* When if API function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, gets using this function.
+* @since_tizen 2.4
+*
+* @param[out] message The error message that is defined service plugin SPEC
+* @remarks @a message must be released using free()
+* @remarks Thread safe functions
+* @remarks The result string's detail specification is defined service plugin or provider.
+* @see service_adaptor_get_last_result()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no error message
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_adaptor_get_last_error_message(char **message);
+
+/**
+* @brief Gets Plugin Property
+* @since_tizen 2.4
+*
+* @param[in] plugin The handle for use Plugin APIs
+* @param[in] key The key of plugin property
+* @param[out] value The value of plugin property that matched @a key
+* @remarks Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
+* @remarks @a value must be released using free()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no property
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see SERVICE_PLUGIN_PROPERTY_APP_KEY
+* @see SERVICE_PLUGIN_PROPERTY_APP_SECRET
+* @see SERVICE_PLUGIN_PROPERTY_USER_ID
+*/
+int service_plugin_get_property(service_plugin_h plugin,
+ const char *key,
+ char **value);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_PLUGIN_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_PLUGIN_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup SERVICE_PLUGIN_MODULE
+
+ * @{
+ */
+
+/**
+ * @brief Type of service in plugin
+ */
+typedef enum
+{
+ SERVICE_PLUGIN_SERVICE_AUTH = (0x01 << 0), /**< Auth service type flag */
+ SERVICE_PLUGIN_SERVICE_STORAGE = (0x01 << 1), /**< Storage service type flag */
+}service_plugin_service_type_e;
+
+/**
+* @brief Definition for the service_plugin property: The application id be issued from service provider for 3rd party developer.
+* @since_tizen 2.4
+* @see service_plugin_add_property()
+* @see service_plugin_remove_property()
+* @see service_plugin_get_property()
+ */
+#define SERVICE_PLUGIN_PROPERTY_APP_KEY "http://tizen.org/service-adaptor/plugin/property/app_key"
+
+/**
+* @brief Definition for the service_plugin property: The application password be issued from service provider for 3rd party developer.
+* @since_tizen 2.4
+* @see service_plugin_add_property()
+* @see service_plugin_remove_property()
+* @see service_plugin_get_property()
+*/
+#define SERVICE_PLUGIN_PROPERTY_APP_SECRET "http://tizen.org/service-adaptor/plugin/property/app_secret"
+
+/**
+* @brief Definition for the service_plugin property: The user id for using specific service.
+* @since_tizen 2.4
+* @see service_plugin_add_property()
+* @see service_plugin_remove_property()
+* @see service_plugin_get_property()
+*/
+#define SERVICE_PLUGIN_PROPERTY_USER_ID "http://tizen.org/service-adaptor/plugin/property/user_id"
+
+
+/**
+* @brief The Plugn handle for Service Adaptor
+* @details The handle can be created by service_adaptor_create_plugin()<br>
+* When a handle is no longer needed, use service_plugin_destroy()
+* @see service_adaptor_create_plugin()
+* @see service_plugin_destroy()
+*/
+typedef struct _service_plugin_s *service_plugin_h;
+
+/**
+* @brief Destroy Service Adaptor
+* @details It must called after a program no longer needs APIs of specfic plugin
+* @since_tizen 2.4
+*
+* @param[in] plugin The handle for use Plugin APIs
+* @see service_adaptor_create_plugin()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre @a plugin must be issued by service_adaptor_create_plugin()
+*/
+int service_plugin_destroy(service_plugin_h plugin);
+
+/**
+* @brief Add Plugin Property
+* @details The plguin property is used for plugin's basic or optional requirement.<br>
+* This value is not used in Adaptor layer, but it can be uesd to important Key for plugin with service provider.<br>
+* @since_tizen 2.4
+*
+* @param[in] plugin The handle for use Plugin APIs
+* @param[in] key The key of plugin property
+* @param[in] value The value of plugin property that matched @a key
+* @remarks Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
+* @remarks If the @a key already exists in the property its current value is replaced with the new @a value.
+* @remarks @a plugin must be released memory using #service_plugin_destroy() when you no longer needs plugin's API
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see SERVICE_PLUGIN_PROPERTY_APP_KEY
+* @see SERVICE_PLUGIN_PROPERTY_APP_SECRET
+* @see SERVICE_PLUGIN_PROPERTY_USER_ID
+* @pre @a plugin must be issued by service_adaptor_create_plugin()
+*/
+int service_plugin_add_property(service_plugin_h plugin,
+ const char *key,
+ const char *value);
+
+/**
+* @brief Remove Plugin Property
+* @since_tizen 2.4
+*
+* @param[in] plugin The handle for use Plugin APIs
+* @param[in] key The key of plugin property
+* @remarks Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see SERVICE_PLUGIN_PROPERTY_APP_KEY
+* @see SERVICE_PLUGIN_PROPERTY_APP_SECRET
+* @see SERVICE_PLUGIN_PROPERTY_USER_ID
+*/
+int service_plugin_remove_property(service_plugin_h plugin,
+ const char *key);
+
+/**
+* @brief Gets Plugin Property
+* @since_tizen 2.4
+*
+* @param[in] plugin The handle for use Plugin APIs
+* @param[in] key The key of plugin property
+* @param[out] value The value of plugin property that matched @a key
+* @remarks Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
+* @remarks @a value must be released using free()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no property
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see SERVICE_PLUGIN_PROPERTY_APP_KEY
+* @see SERVICE_PLUGIN_PROPERTY_APP_SECRET
+* @see SERVICE_PLUGIN_PROPERTY_USER_ID
+* @pre The function get property already set by service_adaptor_set_plugin_property()
+*/
+int service_plugin_get_property(service_plugin_h plugin,
+ const char *key,
+ char **value);
+
+/**
+* @brief Requests start initalization for service plugin
+* @since_tizen 2.4
+*
+* @param[in] plugin The handle for use Plugin APIs
+* @param[in] service_mask The flag for use service plugins, this flag can be masked multiple enum (#service_plugin_service_type_e)
+* @remarks @a service_mask must be input using 'bit or' operation with #service_plugin_service_type_e
+* @remarks - for example,
+* @remarks <b>int</b> @a service_mask |= SERVIE_PLUGIN_SERVICE_AUTH;
+* @remarks @a service_mask |= SERVICE_PLUGIN_SERVICE_STORAGE;
+* @remarks <b>int</b> ret = service_plugin_start(@a m_plugin, @a service_mask);
+* @remarks If a program needs to stop plugin manually, use #service_plugin_stop(). <br>But in #service_plugin_destroy(), automatically stop service plugin
+* @see service_plugin_service_type_e
+* @see service_plugin_stop()
+* @return 0 on success, otherwise a negative error value
+* @return If return value is #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED, request authorization to signup application
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED Need authorization
+* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_plugin_start(service_plugin_h plugin,
+ int service_mask);
+
+/**
+* @brief Requests stop manually for service plugin
+* @since_tizen 2.4
+*
+* @param[in] plugin The handle for use Plugin APIs
+* @remarks If a program needs to stop plugin manually, use this function. <br>But in #service_plugin_destroy(), automatically stop service plugin
+* @remarks @a plugin must be released memory using #service_plugin_destroy() when you no longer needs plugin's API
+* @see service_plugin_start()
+* @see service_plugin_destroy()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre service_plugin_start()
+*/
+int service_plugin_stop(service_plugin_h plugin);
+
+/**
+ * @}
+ */
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_PLUGIN_H__ */
--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: service_adaptor_client_storage.h
+ * Desc: Service Adaptor APIs
+ * Created on: Oct, 2014
+ * Author: Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ *****************************************************************************/
+/**
+ * @file service_adaptor_client_storage.h
+ * @brief Defines interface of Service Adaptor's Storage
+ * @version 0.1
+ */
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_STORAGE_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_STORAGE_H__
+
+#include <service_adaptor_client_plugin.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file service_adaptor_client_storage.h
+ */
+
+/**
+ * @addtogroup SERVICE_ADAPTOR_STORAGE_MODULE
+
+ * @{
+ */
+
+/**
+* @brief The handle of async task for storage service
+* @see #service_storage_create_download_task()
+* @see #service_storage_create_upload_task()
+*/
+typedef struct _service_storage_task_s *service_storage_task_h;
+
+/**
+* @brief The handle of file or directory in storage
+* @see #service_storage_file_clone()
+* @see #service_storage_file_destroy()
+*/
+typedef struct _service_storage_file_s *service_storage_file_h;
+
+/**
+* @brief The list handle of file or directory in storage
+* @see #service_storage_file_list_clone()
+* @see #service_storage_file_list_destroy()
+*/
+typedef struct _service_storage_file_list_s *service_storage_file_list_h;
+
+/**
+ * @brief Type of storage task
+ */
+typedef enum
+{
+ SERVICE_STORAGE_TASK_IN_PROGRESS = 1, /**< The task is progressing */
+ SERVICE_STORAGE_TASK_COMPLETED = 2, /**< The task was completed */
+ SERVICE_STORAGE_TASK_CANCELED = 3, /**< The task was canceled */
+ SERVICE_STORAGE_TASK_FAILED = 4, /**< The task was failed */
+} service_storage_task_state_e;
+
+/**
+* @brief Callback for changing state of storage task
+*
+* @param[in] state The state of storage task
+* @param[in] user_data The user data passed from #service_storage_set_task_state_changed_cb()
+* @return void
+* @see #service_storage_unset_task_state_changed_cb()
+* @pre #service_storage_set_task_state_changed_cb() will invoke this callback.
+*/
+typedef void (*service_storage_task_state_cb)(service_storage_task_state_e state,
+ void *user_data);
+
+/**
+* @brief Callback for progress of storage task
+*
+* @param[in] progress The progressed amount of storage task
+* @param[in] total The total amount of storage task
+* @param[in] user_data The user data passed from #service_storage_set_task_progress_cb()
+* @return void
+* @see #service_storage_unset_task_progress_cb()
+* @pre #service_storage_set_task_progress_cb() will invoke this callback.
+*/
+typedef void (*service_storage_task_progress_cb)(unsigned long long progress,
+ unsigned long long total,
+ void *user_data);
+
+/**
+* @brief Callback for getting async storage operation result
+*
+* @param[in] result Result code for storage async operation (see #service_adaptor_error_e)
+* @param[in] user_data Passed data from request function
+* @remarks If the @a result value is #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see #service_adaptor_error_e
+* @see service_storage_remove()
+* @return void
+* @pre #service_storage_remove() will invoke this callback.
+*/
+typedef void (*service_storage_result_cb)(int result,
+ void *user_data);
+
+
+/**
+* @brief Callback for getting file list API
+*
+* @param[in] result Result code for #service_storage_get_file_list() (see #service_adaptor_error_e)
+* @param[in] list The handle of file list
+* @param[in] user_data Passed data from #service_storage_get_file_list()
+* @remarks If the @a result value is #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see #service_adaptor_error_e
+* @see #service_storage_file_list_h
+* @return void
+* @pre #service_storage_get_file_list() will invoke this callback.
+*/
+typedef void (*service_storage_file_list_cb)(int result,
+ service_storage_file_list_h list,
+ void *user_data);
+
+/**
+* @brief Callback for service_storage_file_list_foreach_file API
+*
+* @param[in] file The handle of file
+* @param[in] user_data Passed data from #service_storage_file_list_foreach_file()
+* @see #service_storage_file_h
+* @return @c true to continue with the next iteration of the loop,
+* otherwise @c false to break out of the loop
+* @pre #service_storage_file_list_foreach_file() will invoke this callback.
+*/
+typedef bool (*service_storage_file_cb)(service_storage_file_h file,
+ void *user_data);
+
+/**
+* @brief Gets file list from storage, asynchronously.
+* @since_tizen 2.4
+* @privlevel public
+* @privilege %http://tizen.org/privilege/internet
+*
+* @param[in] plugin The handle for use Plugin APIs
+* @param[in] dir_path The dir path (Physical path)
+* @param[in] callback The callback for getting file list
+* @param[in] user_data The user data to be passed to the callback function
+* @remarks For the @a dir_path, "/" means root path.
+* @remarks Reference details for <b>"Logical path"</b> and <b>"Physical path"</b> at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page
+* @see service_plugin_start()
+* @see service_storage_file_list_cb()
+* @see service_adaptor_get_last_result()
+* @see service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED Permission denied
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre API prerequires #service_plugin_start()
+* @post #service_storage_file_list_cb() will be invoked
+*/
+int service_storage_get_file_list(service_plugin_h plugin,
+ const char *dir_path,
+ service_storage_file_list_cb callback,
+ void *user_data);
+
+/**
+* @brief Removes file or directory in storage
+* @since_tizen 2.4
+* @privlevel public
+* @privilege %http://tizen.org/privilege/internet
+*
+* @param[in] plugin The handle for use Plugin APIs
+* @param[in] remove_path The target file or directory for remove (Physical path)
+* @param[in] callback The callback for getting result this operation
+* @param[in] user_data The user data to be passed to the callback function
+* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @remarks Reference details for <b>"Logical path"</b> and <b>"Physical path"</b> at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page
+* @see service_plugin_start()
+* @see service_storage_result_cb()
+* @see service_adaptor_get_last_result()
+* @see service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED Permission denied
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre API prerequires #service_plugin_start()
+* @post #service_storage_result_cb() will be invoked
+*/
+int service_storage_remove(service_plugin_h plugin,
+ const char *remove_path,
+ service_storage_result_cb callback,
+ void *user_data);
+
+/**
+* @brief Creates storage task for upload file to storage
+* @since_tizen 2.4
+* @privlevel public
+* @privilege %http://tizen.org/privilege/internet
+*
+* @param[in] plugin The handle for use Plugin APIs
+* @param[in] file_path The upload file path in local (Logical path)
+* @param[in] upload_path The upload target path in storage (Physical path)
+* @param[out] task The handle of download task
+* @remarks @a task must be released memory using service_storage_destroy_task() when the task no longer run
+* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @remarks Reference details for <b>"Logical path"</b> and <b>"Physical path"</b> at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page
+* @remarks http://tizen.org/privilege/mediastorage is needed if @a file_path is relevant to media storage.
+* @remarks http://tizen.org/privilege/externalstorage is needed if @a file_path is relevant to external storage.
+* @see service_plugin_start()
+* @see service_storage_destroy_task()
+* @see service_adaptor_get_last_result()
+* @see service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED Permission denied
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files
+* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre API prerequires #service_plugin_start()
+*/
+int service_storage_create_upload_task(service_plugin_h plugin,
+ const char *file_path,
+ const char *upload_path,
+ service_storage_task_h *task);
+
+/**
+* @brief Creates storage task for download file from storage
+* @since_tizen 2.4
+* @privlevel public
+* @privilege %http://tizen.org/privilege/internet
+*
+* @param[in] plugin The handle for use Plugin APIs
+* @param[in] storage_path The source file path in storage (Physical path)
+* @param[in] download_path The download path in local (Logical path)
+* @param[out] task The handle of download task
+* @remarks @a task must be released memory using service_storage_destroy_task() when the task no longer run
+* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @remarks Reference details for <b>"Logical path"</b> and <b>"Physical path"</b> at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page
+* @remarks http://tizen.org/privilege/mediastorage is needed if @a download_path is relevant to media storage.
+* @remarks http://tizen.org/privilege/externalstorage is needed if @a download_path is relevant to external storage.
+* @see service_plugin_start()
+* @see service_storage_destroy_task()
+* @see service_adaptor_get_last_result()
+* @see service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED Permission denied
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files
+* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre API prerequires #service_plugin_start()
+*/
+int service_storage_create_download_task(service_plugin_h plugin,
+ const char *storage_path,
+ const char *download_path,
+ service_storage_task_h *task);
+
+/**
+* @brief Creates storage task for download thumbnail from storage
+* @since_tizen 2.4
+* @privlevel public
+* @privilege %http://tizen.org/privilege/internet
+*
+* @param[in] plugin The handle for use Plugin APIs
+* @param[in] storage_path The source file path in storage (Physical path)
+* @param[in] download_path The download path in local (Logical path)
+* @param[in] thumbnail_size The size <b>level</b> of thumbnail, the level is defined service plugin SPEC
+* @param[out] task The handle of download task
+* @remarks If @a thumbnail_size is <b>0</b>, gets default size thumbnail, the default size must be defined plugin SPEC
+* @remarks If @a thumbnail_size is <b>-1</b>, gets minimum size thumbnail be supported plugin
+* @remarks If @a thumbnail_size is <b>-2</b>, gets maximum size thumbnail be supported plugin
+* @remarks @a task must be released memory using service_storage_destroy_task() when the task no longer run
+* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @remarks Reference details for <b>"Logical path"</b> and <b>"Physical path"</b> at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page
+* @remarks http://tizen.org/privilege/mediastorage is needed if @a download_path is relevant to media storage.
+* @remarks http://tizen.org/privilege/externalstorage is needed if @a download_path is relevant to external storage.
+* @see service_plugin_start()
+* @see service_adaptor_get_last_result()
+* @see service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED Permission denied
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_STATE The handle's state is invalid
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no thumbnail data
+* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED Not supported API in this plugin
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre API prerequires #service_plugin_start()
+*/
+int service_storage_create_download_thumbnail_task (service_plugin_h plugin,
+ const char *storage_path,
+ const char *download_path,
+ int thumbnail_size,
+ service_storage_task_h *task);
+
+/**
+* @brief Destroys storage task
+* @since_tizen 2.4
+*
+* @param[in] task The handle of storage task
+* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @see service_storage_create_download_task()
+* @see service_storage_create_upload_task()
+* @see service_adaptor_get_last_result()
+* @see service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_storage_destroy_task(service_storage_task_h task);
+
+/**
+* @brief Starts storage task, asynchronously.
+* @since_tizen 2.4
+*
+* @param[in] task The handle of storage task
+* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @see service_storage_create_upload_task()
+* @see service_storage_create_download_task()
+* @see service_storage_create_download_thumbnail_task()
+* @see service_adaptor_get_last_result()
+* @see service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_storage_start_task(service_storage_task_h task);
+
+/**
+* @brief Cancels storage task, asynchronously.
+* @since_tizen 2.4
+*
+* @param[in] task The handle of storage task
+* @remarks @a task must be released memory using service_storage_destroy_task() when the task no longer run
+* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @see service_storage_start_task()
+* @see service_adaptor_get_last_result()
+* @see service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_storage_cancel_task(service_storage_task_h task);
+
+/**
+* @brief Sets a callback function to be invoked when progress of the task running.
+* @since_tizen 2.4
+*
+* @param[in] task The handle of storage task
+* @param[in] callback The callback function to register
+* @param[in] user_data The user data to be passed to the callback function
+* @remarks This function must be called before starting task (see #service_storage_start_task())
+* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @see service_storage_start_task()
+* @see service_adaptor_get_last_result()
+* @see service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @post #service_storage_task_progress_cb() will be invoked
+*/
+int service_storage_set_task_progress_cb(service_storage_task_h task,
+ service_storage_task_progress_cb callback,
+ void *user_data);
+
+/**
+* @brief Unsets the progress callback function.
+* @since_tizen 2.4
+*
+* @param[in] task The handle of storage task
+* @remarks This function must be called before starting task (see #service_storage_start_task())
+* @see service_storage_start_task()
+* @see service_storage_set_task_progress_cb()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_unset_task_progress_cb(service_storage_task_h task);
+
+
+/**
+* @brief Sets a callback function to be invoked when change of the task running state.
+* @since_tizen 2.4
+*
+* @param[in] task The handle of storage task
+* @param[in] callback The callback function to register
+* @param[in] user_data The user data to be passed to the callback function
+* @remarks This function must be called before starting task (see #service_storage_start_task())
+* @remarks If the function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @see service_storage_start_task()
+* @see service_adaptor_get_last_result()
+* @see service_adaptor_get_last_error_message()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @post #service_storage_task_state_cb() will be invoked
+*/
+int service_storage_set_task_state_changed_cb(service_storage_task_h task,
+ service_storage_task_state_cb callback,
+ void *user_data);
+
+/**
+* @brief Unsets the state changed callback function.
+* @since_tizen 2.4
+*
+* @param[in] task The handle of storage task
+* @remarks This function must be called before starting task (see #service_storage_start_task())
+* @see service_storage_start_task()
+* @see service_storage_set_task_progress_cb()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_unset_task_state_changed_cb(service_storage_task_h task);
+
+/**
+* @brief Clones the file list handle
+* @since_tizen 2.4
+*
+* @param[in] src_list The source handle
+* @param[out] dst_list The destination handle
+* @remarks @a file must be released memory using service_storage_file_list_destroy() when you no longer needs this handle
+* @see service_storage_file_list_h
+* @see service_storage_file_list_destroy()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_file_list_clone(service_storage_file_list_h src_list,
+ service_storage_file_list_h *dst_list);
+
+/**
+* @brief Destroys the file list handle
+* @since_tizen 2.4
+*
+* @param[in] list The file list handle
+* @remarks It must be used for cloned file list handle
+* @see service_storage_file_list_h
+* @see service_storage_file_list_clone()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_file_list_destroy(service_storage_file_list_h list);
+
+/**
+* @brief Gets length of the file list handle
+* @since_tizen 2.4
+*
+* @param[in] list The file list handle
+* @param[out] length The length of the file list handle
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_file_list_get_length(service_storage_file_list_h list,
+ int *length);
+
+/**
+* @brief Foreach All of the file from file list
+* @since_tizen 2.4
+*
+* @param[in] list The file list handle
+* @param[in] callback The callback for foreach file
+* @param[in] user_data Passed data to callback
+* @see #service_storage_file_cb
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files
+*/
+int service_storage_file_list_foreach_file(service_storage_file_list_h list,
+ service_storage_file_cb callback,
+ void *user_data);
+
+/**
+* @brief Clones the file handle
+* @since_tizen 2.4
+*
+* @param[in] src_file The source handle
+* @param[out] dst_file The destination handle
+* @remarks @a file must be released memory using service_storage_file_destroy() when you no longer needs this handle
+* @see #service_storage_file_h
+* @see #service_storage_file_destroy()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_file_clone(service_storage_file_h src_file,
+ service_storage_file_h *dst_file);
+
+/**
+* @brief Destroys the file handle
+* @details This function must be used for cloned file handle.
+* @since_tizen 2.4
+*
+* @param[in] file The handle of file or directory in storage
+* @see service_storage_file_h
+* @see service_storage_file_clone()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_file_destroy(service_storage_file_h file);
+
+/**
+* @brief Gets whether directory or file for file handle
+* @since_tizen 2.4
+*
+* @param[in] file The handle of file or directory in storage
+* @param[out] is_dir true on directory, false on file
+* @see service_storage_file_h
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_file_is_dir(service_storage_file_h file,
+ bool *is_dir);
+
+/**
+* @brief Gets size of handle
+* @since_tizen 2.4
+*
+* @param[in] file The handle of file or directory in storage
+* @param[out] size The size of file (byte)
+* @see service_storage_file_h
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+*/
+int service_storage_file_get_size(service_storage_file_h file,
+ unsigned long long *size);
+
+/**
+* @brief Gets logical path from file handle
+* @since_tizen 2.4
+*
+* @param[in] file The handle of file or directory in storage
+* @param[out] path The logical path of file
+* @remarks @a path must be released using free()
+* @remarks Reference details for <b>"Logical path"</b> and <b>"Physical path"</b> at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page
+* @see #service_storage_file_h
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no data
+*/
+int service_storage_file_get_logical_path(service_storage_file_h file,
+ char **path);
+
+/**
+* @brief Gets physical path from file handle
+* @since_tizen 2.4
+*
+* @param[in] file The handle of file or directory in storage
+* @param[out] path The physical path of file
+* @remarks @a path must be released using free()
+* @remarks Reference details for <b>"Logical path"</b> and <b>"Physical path"</b> at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page
+* @see #service_storage_file_h
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no data
+*/
+int service_storage_file_get_physical_path(service_storage_file_h file,
+ char **path);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_STORAGE_H__ */
BuildRequires: pkgconfig(capi-appfw-package-manager)
BuildRequires: pkgconfig(capi-appfw-service-application)
BuildRequires: pkgconfig(json-glib-1.0)
-#BuildRequires: pkgconfig(libsmack)
+#BuildRequires: pkgconfig(security-server)
#BuildRequires: pkgconfig(service-discovery)
#BuildRequires: pkgconfig(service-federation)
#BuildRequires: service-discovery-devel
%setup -q
%build
-export CFLAGS="${CFLAGS} -fPIC -Wall -g -fvisibility=hidden -fdata-sections -ffunction-sections"
-export CXXFLAGS="${CXXFLAGS} -fPIC -Wall -g -fvisibility=hidden"
+#export CFLAGS="${CFLAGS} -fPIC -Wall -g -fvisibility=hidden -fdata-sections -ffunction-sections"
+export CFLAGS="${CFLAGS} -fPIC -Wall -g -fdata-sections -ffunction-sections"
+#export CXXFLAGS="${CXXFLAGS} -fPIC -Wall -g -fvisibility=hidden"
+export CXXFLAGS="${CXXFLAGS} -fPIC -Wall -g"
export LDFLAGS="${LDFLAGS} -Wl,--hash-style=both -Wl,--rpath=%{_prefix}/lib -Wl,--as-needed"
%if 0%{?sec_build_binary_debug_enable}
rm -rf %{buildroot}
%make_install
+mkdir -p %{buildroot}%{_libdir}/service-provider/auth
+mkdir -p %{buildroot}%{_libdir}/service-provider/storage
+mkdir -p %{buildroot}%{_libdir}/service-provider/contact
+mkdir -p %{buildroot}%{_libdir}/service-provider/message
+mkdir -p %{buildroot}%{_libdir}/service-provider/push
+mkdir -p %{buildroot}%{_libdir}/service-provider/shop
+
mkdir -p %{buildroot}%{_unitdir_user}/default.target.wants
install -m 0644 %SOURCE1 %{buildroot}%{_unitdir_user}/service-adaptor.service
ln -s ../service-adaptor.service %{buildroot}%{_unitdir_user}/default.target.wants/service-adaptor.service
%manifest service-adaptor.manifest
%defattr(-,root,root,-)
%{_libdir}/lib*.so.*
-#%{_bindir}/service-adaptor-server
+%{_libdir}/service-provider
+%{_libdir}/service-provider/*
+%{_bindir}/service-adaptor-server
#%{_bindir}/sal-test
%{_unitdir_user}/service-adaptor.service
%{_unitdir_user}/default.target.wants/service-adaptor.service
%{_libdir}/lib*.so
%{_libdir}/pkgconfig/service-adaptor.pc
%{_includedir}/*.h
-#%{_includedir}/service-adaptor/*.h
-#%{_includedir}/service-provider/*.h
+%{_includedir}/service-adaptor/*.h
+%{_includedir}/service-provider/*.h
/usr/share/license/%{name}-devel
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(sal-server)
+
+SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+ SET(CMAKE_BUILD_TYPE "Debug")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+
+MESSAGE("")
+MESSAGE(">>> current directory: ${CMAKE_CURRENT_SOURCE_DIR}")
+MESSAGE(">>> Build type: ${CMAKE_BUILD_TYPE}")
+
+#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VISIBILITY} -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--gc-sections -fPIE")
+
+ADD_DEFINITIONS("-DAUTH_PLUGIN_PATH=\"${PROVIDER_PATH}/auth\"")
+ADD_DEFINITIONS("-DSTORAGE_PLUGIN_PATH=\"${PROVIDER_PATH}/storage\"")
+ADD_DEFINITIONS("-DCONTACT_PLUGIN_PATH=\"${PROVIDER_PATH}/contact\"")
+ADD_DEFINITIONS("-DMESSAGE_PLUGIN_PATH=\"${PROVIDER_PATH}/message\"")
+ADD_DEFINITIONS("-DPUSH_PLUGIN_PATH=\"${PROVIDER_PATH}/push\"")
+ADD_DEFINITIONS("-DSHOP_PLUGIN_PATH=\"${PROVIDER_PATH}/shop\"")
+
+##########################################################
+# Define Execute File
+##########################################################
+
+SET(MAIN-EXE "service-adaptor-server")
+FILE(GLOB MAIN-SRCS
+ ${CMAKE_SOURCE_DIR}/server/src/*.c
+ ${CMAKE_SOURCE_DIR}/server/src/dbus/*.c
+ ${CMAKE_SOURCE_DIR}/server/src/util/*.c
+)
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_SOURCE_DIR}/common/plugin_config
+
+ ${CMAKE_SOURCE_DIR}/adaptor/auth-adaptor
+ ${CMAKE_SOURCE_DIR}/adaptor/contact-adaptor
+ ${CMAKE_SOURCE_DIR}/adaptor/storage-adaptor
+ ${CMAKE_SOURCE_DIR}/adaptor/message-adaptor
+ ${CMAKE_SOURCE_DIR}/adaptor/push-adaptor
+ ${CMAKE_SOURCE_DIR}/adaptor/shop-adaptor
+
+ ${CMAKE_SOURCE_DIR}/server/inc
+ ${CMAKE_SOURCE_DIR}/server/inc/dbus
+ ${CMAKE_SOURCE_DIR}/server/inc/util
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(main_pkgs REQUIRED glib-2.0 gobject-2.0 gio-2.0 gthread-2.0 dlog bundle capi-base-common capi-appfw-application capi-appfw-app-manager capi-appfw-package-manager)
+
+FOREACH(flag ${main_pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -std=gnu99")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+ADD_DEFINITIONS("-DSERVICE_ADAPTOR_DEBUGGING")
+ADD_DEFINITIONS("-D_SERVICE_ADAPTOR_IPC_SERVER")
+
+ADD_EXECUTABLE(${MAIN-EXE} ${MAIN-SRCS})
+TARGET_LINK_LIBRARIES(${MAIN-EXE} ${main_pkgs_LDFLAGS} plugin-config auth-adaptor contact-adaptor storage-adaptor message-adaptor push-adaptor shop-adaptor)
+INSTALL(TARGETS ${MAIN-EXE} DESTINATION bin)
+
+SET(SAL-SERVER-HEADERS
+ ${CMAKE_SOURCE_DIR}/server/inc/dbus/dbus-server.h
+ ${CMAKE_SOURCE_DIR}/server/inc/service-adaptor.h
+)
+
+INSTALL(FILES ${SAL-SERVER-HEADERS} DESTINATION include/service-adaptor)
+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(sal-server)
-
-SET(CMAKE_SKIP_BUILD_RPATH TRUE)
-
-IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
- SET(CMAKE_BUILD_TYPE "Debug")
-ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
-
-MESSAGE("")
-MESSAGE(">>> current directory: ${CMAKE_CURRENT_SOURCE_DIR}")
-MESSAGE(">>> Build type: ${CMAKE_BUILD_TYPE}")
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VISIBILITY} -fvisibility=hidden")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--gc-sections -fPIE")
-
-
-##########################################################
-# Define Execute File
-##########################################################
-
-SET(MAIN-EXE "service-adaptor-server")
-SET(MAIN-SRCS
- ${CMAKE_SOURCE_DIR}/server/sal_base.c
- ${CMAKE_SOURCE_DIR}/server/sal_engine.c
-# ${CMAKE_SOURCE_DIR}/server/sal_contact.c
-# ${CMAKE_SOURCE_DIR}/server/sal_storage.c
-# ${CMAKE_SOURCE_DIR}/server/sal_resource.c
-# ${CMAKE_SOURCE_DIR}/server/sal_observer.c
- ${CMAKE_SOURCE_DIR}/server/sal_main.c
-)
-
-INCLUDE_DIRECTORIES(
-# ${CMAKE_SOURCE_DIR}/include
- ${CMAKE_SOURCE_DIR}/common/base
- ${CMAKE_SOURCE_DIR}/common/ipc-server
- ${CMAKE_SOURCE_DIR}/common/ipc-adaptor
- ${CMAKE_SOURCE_DIR}/server
-# ${CMAKE_SOURCE_DIR}/client
-# ${CMAKE_SOURCE_DIR}/adaptor/auth-adaptor
-# ${CMAKE_SOURCE_DIR}/adaptor/contact-adaptor
-## ${CMAKE_SOURCE_DIR}/adaptor/storage-adaptor
- # ${CMAKE_SOURCE_DIR}/adaptor/resource-adaptor
-)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(main_pkgs REQUIRED dlog glib-2.0 capi-base-common capi-appfw-application capi-appfw-app-manager capi-appfw-package-manager libsmack)
-
-FOREACH(flag ${main_pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -std=gnu99")
-SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
-
-ADD_DEFINITIONS("-DSERVICE_ADAPTOR_DEBUGGING")
-ADD_DEFINITIONS("-D_SERVICE_ADAPTOR_IPC_SERVER")
-
-ADD_EXECUTABLE(${MAIN-EXE} ${MAIN-SRCS})
-TARGET_LINK_LIBRARIES(${MAIN-EXE} ${main_pkgs_LDFLAGS} sal-common-base sal-common-server sal-common-adaptor)
-INSTALL(TARGETS ${MAIN-EXE} DESTINATION bin)
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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__ */
+
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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_DISCONNECT_SERVICE_ADAPTOR_METHOD DBUS_SERVICE_ADAPTOR "_disconnect_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__ */
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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();
+
+// 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__ */
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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 __PING_MANAGER_H__
+#define __PING_MANAGER_H__
+
+#include <glib.h>
+
+#define DETAILED_PEER
+
+#ifndef DETAILED_PEER
+typedef int peer_info_t;
+#else
+typedef struct _peer_info_s {
+ int pid;
+ char *name;
+} peer_info_s;
+typedef struct _peer_info_s *peer_info_t;
+#endif
+
+/*************************************************
+ * Public function prototype
+ *************************************************/
+
+void ping_manager_init(int interval, GMainLoop *loop);
+
+void ping_manager_deinit(void);
+
+int ping_manager_peer_connected(peer_info_t info);
+
+int ping_manager_peer_disconnected(peer_info_t info);
+
+int ping_manager_get_connected_count(void);
+
+
+
+#endif /* __PING_MANAGER_H__ */
--- /dev/null
+/*
+* 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__ */
--- /dev/null
+/*
+* 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");
+}
--- /dev/null
+/*
+* 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();
+}
--- /dev/null
+/*
+* 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 */
--- /dev/null
+/*
+* 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;
+}
+
--- /dev/null
+/*
+* 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");
+}
--- /dev/null
+/*
+* 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-log.h"
+#include "service-adaptor.h"
+#include "service-adaptor-type.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='" 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_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='" "(s)" "' name='req' direction='in'/>"
+" <arg type='t' name='error_code' direction='out'/>"
+" <arg type='s' name='error_msg' direction='out'/>"
+" </method>"
+" <method name='" DBUS_DISCONNECT_SERVICE_ADAPTOR_METHOD "'>"
+" <arg type='" "(s)" "' name='req' direction='in'/>"
+" <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 */
--- /dev/null
+/*
+* 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"
+
+#include "util/ping_manager.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;
+ }
+ }
+
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ char *client_profile = NULL;
+ g_variant_get(in_parameters, private_service_adaptor_essential_s_type, &client_profile);
+ service_adaptor_info("[DM] client profile <%s>", client_profile);
+ char client_name[1024] = {0, };
+ int client_pid = 0;
+ int sr = sscanf(client_profile, "%s%d", client_name, &client_pid);
+ if (sr == 2) {
+ service_adaptor_info("[DM] client<%s> pid<%d>", client_name, client_pid);
+ #ifndef DETAILED_PEER
+ ping_manager_peer_connected(client_pid);
+ #else
+ peer_info_s info;
+ info.pid = client_pid;
+ info.name = strdup(client_name);
+ ping_manager_peer_connected(&info);
+ free(info.name);
+ info.name = NULL;
+ #endif
+ }
+
+ 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, DBUS_DISCONNECT_SERVICE_ADAPTOR_METHOD)) {
+ GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
+ char *client_profile = NULL;
+ g_variant_get(in_parameters, private_service_adaptor_essential_s_type, &client_profile);
+ service_adaptor_info("[DM] client profile <%s>", client_profile);
+ char client_name[1024] = {0, };
+ int client_pid = 0;
+ int sr = sscanf(client_profile, "%s%d", client_name, &client_pid);
+ if (sr == 2) {
+ service_adaptor_info("[DM][dis] client<%s> pid<%d>", client_name, client_pid);
+ #ifndef DETAILED_PEER
+ ping_manager_peer_disconnected(client_pid);
+ #else
+ peer_info_s info;
+ info.pid = client_pid;
+ info.name = strdup(client_name);
+ ping_manager_peer_disconnected(&info);
+ free(info.name);
+ info.name = NULL;
+ #endif
+ }
+
+ service_adaptor_info("Client Disconnected Successful");
+ g_dbus_method_invocation_return_value(invocation, g_variant_new("(ts)", (uint64_t) ret_code, ret_msg));
+ } 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;
+}
+
--- /dev/null
+/*
+* 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);
+ }
+}
--- /dev/null
+/*
+* 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;
+}
--- /dev/null
+/*
+* 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;
+}
--- /dev/null
+/*
+* 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;
+}
--- /dev/null
+/*
+* 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;
+}
--- /dev/null
+/*
+* 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(MESSAGE_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;
+}
--- /dev/null
+/*
+* 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 */
+}
+
--- /dev/null
+/*
+* 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"*/
+#ifdef SA_PUSH_ON_DEMAND_ENABLE
+#define SERVICE_ADAPTOR_SERVICE_FILE_PATH "/opt/share/service-adaptor/services/"
+#define SERVICE_ADAPTOR_PUSH_ENABLED_PATH "/opt/share/service-adaptor/.push/"
+#endif
+
+#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");
+
+#ifdef SA_PUSH_ON_DEMAND_ENABLE
+ _load_all_push_service_file();
+#endif
+
+ 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");
+
+#ifdef SA_PUSH_ON_DEMAND_ENABLE
+ _unload_all_push_service_file();
+#endif
+}
+
+
+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;
+ }
+
+#ifdef SA_PUSH_ON_DEMAND_ENABLE
+ 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);
+#endif
+
+ 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;
+ }
+
+#ifdef SA_PUSH_ON_DEMAND_ENABLE
+ 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);
+#endif
+
+ 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;
+}
--- /dev/null
+/*
+* 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;
+}
--- /dev/null
+/*
+* 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;
+}
--- /dev/null
+/*
+* 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 "util/ping_manager.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
+ ******************************************************************************/
+
+static GMainLoop *g_default_loop = NULL;
+
+/******************************************************************************
+ * 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
+}
+
+static void __glog_handler_cb(const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *message,
+ gpointer user_data)
+{
+ service_adaptor_error("============================================================");
+ service_adaptor_error("============================================================");
+ service_adaptor_error("================== Critical GLib Error =====================");
+ service_adaptor_error("============================================================");
+ service_adaptor_error("============================================================");
+ service_adaptor_error("=== Log Domain : %s", log_domain);
+ service_adaptor_error("=== Level : %d", (int)log_level);
+ service_adaptor_error("=== Message : %s", message);
+ service_adaptor_error("============================================================");
+ service_adaptor_error("============================================================");
+}
+
+static void glog_handler_init()
+{
+ service_adaptor_info("glib log handler init : %d",
+ (int)g_log_set_handler("GLib", G_LOG_LEVEL_CRITICAL, __glog_handler_cb, NULL));
+}
+
+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;
+
+ glog_handler_init();
+
+ /* 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");
+/* TODO it will be activated for on-demand
+ ping_manager_init(5, g_default_loop);
+*/
+
+ /* 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_debug("Service Adaptor: Deinitialize");
+
+ if (NULL == g_service_adaptor) {
+ service_adaptor_error("Invalid argument");
+ return;
+ }
+
+ service_adaptor_h service_adaptor = g_service_adaptor;
+ g_service_adaptor = NULL;
+ 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
+
+ /* mainloop of main thread */
+ loop = g_main_loop_new(NULL, FALSE);
+ g_default_loop = loop;
+
+ ret = service_adaptor_init();
+
+ if (SERVICE_ADAPTOR_INTERNAL_ERROR_NONE != ret) {
+ service_adaptor_error("Service Adaptor initialize error: %d\n", ret);
+ return -1;
+ }
+
+ /* 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
+}
+
--- /dev/null
+/*
+* 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;
+*/
+ return 0;
+}
+
+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;
+*/
+ return 0;
+}
+
+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;
+}
--- /dev/null
+/*
+* 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 <stdint.h>
+
+#include <glib.h>
+
+#include "service-adaptor-log.h"
+#include "util/ping_manager.h"
+#include "service-adaptor-push.h"
+
+/*************************************************
+ * Type definition
+ *************************************************/
+
+#define POINTER_TO_PINFO(pt) ((peer_info_t)(intptr_t) (pt))
+#ifndef DETAILED_PEER
+ #define PINFO_TO_POINTER(pi) ((void *)(intptr_t) (pi))
+#else
+ #define PINFO_TO_POINTER(pi) ((void *) (pi))
+#endif
+#define COMPARE_PINFO(a, b) ((a) - (b))
+
+#define DAEMON_CONTINUE FALSE
+#define DAEMON_WILL_STOP TRUE
+
+#define NO_ANY_ACCESS TRUE
+#define ACCESS_EXISTED FALSE
+
+#define PEERS_INFO_DEBUG
+
+/*************************************************
+ * Global valuable
+ *************************************************/
+
+/* static GAsyncQueue *peers_list = NULL; */
+static GList *peers_list = NULL;
+G_LOCK_DEFINE(locker);
+static GMainContext *main_ctx = NULL;
+static gboolean g_ping_watcher_stop = TRUE;
+
+#ifdef PEERS_INFO_DEBUG
+static int repet_print_count = 0;
+static int repet_print_count_max = 5;
+#endif
+
+gboolean g_suspend_flag = DAEMON_CONTINUE;
+gboolean g_suspend_flag_integrity = ACCESS_EXISTED;
+
+/*************************************************
+ * Internal function prototype
+ *************************************************/
+
+static void __remove_peer_info(peer_info_t pinfo);
+
+static void __add_peer_info(peer_info_t pinfo);
+
+static int __get_peers_length(void);
+
+static gboolean __ping_watcher_cb(gpointer user_data);
+
+static void __peer_info_destroy(void *info);
+
+/*************************************************
+ * Internal function definition
+ *************************************************/
+
+static void __remove_peer_info(peer_info_t pinfo)
+{
+ G_LOCK(locker);
+ #ifndef DETAILED_PEER
+ peers_list = g_list_remove(peers_list, PINFO_TO_POINTER(pinfo));
+ #else
+ int len = (int)g_list_length(peers_list);
+ peer_info_t find = NULL, current = NULL;
+ for (int i = 0; i < len; i++) {
+ current = (peer_info_t)g_list_nth_data(peers_list, i);
+ if (current) {
+ if (current->pid == pinfo->pid) {
+ find = current;
+ break;
+ }
+ }
+ }
+ peers_list = g_list_remove(peers_list, PINFO_TO_POINTER(find));
+ __peer_info_destroy(PINFO_TO_POINTER(find));
+ #endif
+
+ #ifdef PEERS_INFO_DEBUG
+ repet_print_count = 0;
+ #endif
+
+ G_UNLOCK(locker);
+}
+
+static void __add_peer_info(peer_info_t pinfo)
+{
+ G_LOCK(locker);
+ #ifndef DETAILED_PEER
+ peers_list = g_list_append(peers_list, PINFO_TO_POINTER(pinfo));
+ #else
+ peer_info_t pi = (peer_info_t) calloc(1, sizeof(peer_info_s));
+ if (pi) {
+ pi->pid = pinfo->pid;
+ pi->name = strdup((pinfo->name) ? (pinfo->name) : "");
+ peers_list = g_list_append(peers_list, PINFO_TO_POINTER(pi));
+ }
+ #endif
+
+ g_suspend_flag_integrity = ACCESS_EXISTED;
+
+ #ifdef PEERS_INFO_DEBUG
+ repet_print_count = 0;
+ #endif
+
+ G_UNLOCK(locker);
+}
+
+#ifdef PEERS_INFO_DEBUG
+void _print_info_cb(gpointer data, gpointer user_data)
+{
+ #ifndef DETAILED_PEER
+ service_adaptor_info("--- > iterator : %d", (int) POINTER_TO_PINFO(data));
+ #else
+ service_adaptor_info("--- > iterator : <%d> %s", (POINTER_TO_PINFO(data))->pid, (POINTER_TO_PINFO(data))->name);
+ #endif
+}
+#endif
+
+static int __get_peers_length()
+{
+ G_LOCK(locker);
+ #ifdef PEERS_INFO_DEBUG
+ g_list_foreach(peers_list, _print_info_cb, NULL);
+ #endif
+ int ret = (int) g_list_length(peers_list);
+ G_UNLOCK(locker);
+
+ push_activate_h *push_services = NULL;
+ int push_len = 0;
+ service_adaptor_ref_enabled_push_services(&push_services, &push_len);
+
+ ret += push_len;
+ #ifdef PEERS_INFO_DEBUG
+ #ifndef DETAILED_PEER
+ service_adaptor_info("--- > registered push : %d files", push_len);
+ #else
+ for (int k = 0; k < push_len; k++) {
+ service_adaptor_info("--- > registered push : %s", push_services[k]->file_name);
+ }
+ #endif
+ #endif
+ free(push_services);
+ push_services = NULL;
+
+ return ret;
+}
+
+static gboolean __ping_watcher_cb(gpointer user_data)
+{
+ #ifdef PEERS_INFO_DEBUG
+ if (repet_print_count_max >= (++repet_print_count)) {
+ #endif
+
+ service_adaptor_info("=== === === ping manager loop === === ===");
+
+ int len = __get_peers_length();
+ service_adaptor_info("--- peers len : %d", len);
+ if (len == 0) {
+ if (g_suspend_flag == DAEMON_WILL_STOP) {
+ if (g_suspend_flag_integrity == ACCESS_EXISTED) {
+ service_adaptor_info("--- --- violated integrity");
+ service_adaptor_info("--- --- suspend dleay to next term");
+ g_suspend_flag = DAEMON_WILL_STOP;
+ g_suspend_flag_integrity = NO_ANY_ACCESS;
+ } else {
+ /* daemon stop */
+ service_adaptor_info("--- --- start daemon termination");
+ g_ping_watcher_stop = FALSE;
+
+ if (user_data) {
+ service_adaptor_info("--- --- quit main loop");
+ g_main_loop_quit((GMainLoop *)user_data);
+ }
+ }
+ } else { /* == DAEMON_CONTINUE */
+ g_suspend_flag = DAEMON_WILL_STOP;
+ g_suspend_flag_integrity = NO_ANY_ACCESS;
+
+ }
+ } else {
+ service_adaptor_info("--- --- clears suspend flag");
+ g_suspend_flag = DAEMON_CONTINUE;
+ g_suspend_flag_integrity = ACCESS_EXISTED;
+ }
+
+ service_adaptor_info("=== === === return %s === === ===",
+ (g_ping_watcher_stop == TRUE)?"TRUE":"FALSE");
+
+ #ifdef PEERS_INFO_DEBUG
+ }
+ #endif
+ return g_ping_watcher_stop;
+}
+
+static void __peer_info_destroy(void *info)
+{
+ #ifdef DETAILED_PEER
+ peer_info_t find = (peer_info_t)info;
+ if (find) {
+ free(find->name);
+ find->name = NULL;
+ free(find);
+ }
+ #endif
+}
+
+static void __ping_manager_clear_cb(gpointer data)
+{
+ service_adaptor_info("Func start <%s>", __FUNCTION__);
+ ping_manager_deinit();
+}
+
+/*************************************************
+ * Public function prototype
+ *************************************************/
+
+void ping_manager_init(int interval, GMainLoop *loop)
+{
+ service_adaptor_info("Func start <%s>", __FUNCTION__);
+ peers_list = NULL;
+
+ #ifdef PEERS_INFO_DEBUG
+ repet_print_count = 0;
+ #endif
+
+ main_ctx = g_main_context_default();
+ GSource *src = g_timeout_source_new_seconds(interval);
+ g_source_set_callback(src, __ping_watcher_cb, (void *)loop, __ping_manager_clear_cb);
+ g_source_attach(src, main_ctx);
+}
+
+void ping_manager_deinit(void)
+{
+ service_adaptor_info("Func start <%s>", __FUNCTION__);
+ G_LOCK(locker);
+ g_list_free_full(peers_list, __peer_info_destroy);
+ peers_list = NULL;
+ G_UNLOCK(locker);
+}
+
+int ping_manager_peer_connected(peer_info_t info)
+{
+ service_adaptor_info("Func start <%s> [%d]", __FUNCTION__, (int)info);
+ __remove_peer_info(info);
+ __add_peer_info(info);
+ int ret = __get_peers_length();
+ service_adaptor_info("peers length : %d", ret);
+ return ret;
+}
+
+int ping_manager_peer_disconnected(peer_info_t info)
+{
+ service_adaptor_info("Func start <%s> [%d]", __FUNCTION__, (int)info);
+ __remove_peer_info(info);
+ int ret = __get_peers_length();
+ service_adaptor_info("peers length : %d", ret);
+ return ret;
+}
+
+int ping_manager_get_connected_count(void)
+{
+ service_adaptor_info("Func start <%s>", __FUNCTION__);
+ int ret = __get_peers_length();
+ service_adaptor_info("peers length : %d", ret);
+ return ret;
+}
+
--- /dev/null
+/*
+* 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;
+}
+
+
Requires: capi-base-common bundle
Version: @VERSION@
-Libs: -L${libdir} -lservice-adaptor-client -lservice-provider
+Libs: -L${libdir} -lservice-adaptor-client -lauth-adaptor -lcontact-adaptor -lstorage-adaptor -lmessage-adaptor -lpush-adaptor -lshop-adaptor
Cflags: -I${includedir}/service-adaptor -I${includedir}/service-provider