Re-architect to align dependency 97/55497/18 devel/tizen_3.0
authorJiwon Kim <jiwon177.kim@samsung.com>
Thu, 24 Dec 2015 05:35:17 +0000 (14:35 +0900)
committerJiwon Kim <jiwon177.kim@samsung.com>
Tue, 16 Feb 2016 00:07:39 +0000 (16:07 -0800)
- Separate internal module for supporting IPC-changeable and platform-changeable.
  -> ipc-* modules can be replaced to any other IPC (likes socket)
  -> api/* modules can be replaced to any other platform (now it has dependency with Tizen Application)
- Fix cyclic dependency issue between internal shared libraries.
- Add "Service Provider" feature for supporting downloadable plugin.
- Design thread policy about latency and to process job for server-daemon.

Change-Id: I80e3c03061002b18e6feb8b739ab4e5f1e8e60ea
Signed-off-by: Jiwon Kim <jiwon177.kim@samsung.com>
Signed-off-by: Jiwon Kim <jwkim0000@gmail.com>
112 files changed:
CMakeLists.txt
Documentation/architecture/Dependency.txt [new file with mode: 0644]
api/CMakeLists.txt [new file with mode: 0644]
api/client/sal_client_internal.c [new file with mode: 0644]
api/client/sal_client_internal.h [new file with mode: 0644]
api/client/sal_client_types.h [new file with mode: 0644]
api/client/sal_service_adaptor.c [new file with mode: 0644]
api/client/sal_service_adaptor.h [new file with mode: 0644]
api/client/sal_service_auth.c [new file with mode: 0644]
api/client/sal_service_auth.h [new file with mode: 0644]
api/client/sal_service_auth_internal.h [new file with mode: 0644]
api/client/sal_service_storage.c [new file with mode: 0644]
api/client/sal_service_storage.h [new file with mode: 0644]
api/client/sal_service_storage_internal.h [new file with mode: 0644]
api/client/sal_service_task.c [new file with mode: 0644]
api/client/sal_service_task.h [new file with mode: 0644]
api/client/sal_service_task_internal.h [new file with mode: 0644]
api/provider/sal_provider_base.c [new file with mode: 0644]
api/provider/sal_provider_base.h [new file with mode: 0644]
api/provider/sal_provider_internal.h [new file with mode: 0644]
api/provider/sal_provider_service.c [new file with mode: 0644]
api/provider/sal_provider_service.h [new file with mode: 0644]
api/provider/sal_provider_storage.c [new file with mode: 0644]
api/provider/sal_provider_storage.h [new file with mode: 0644]
client/CMakeLists.txt [deleted file]
client/sal_auth_provider.c [deleted file]
client/sal_auth_provider.h [deleted file]
client/sal_service_adaptor.c [deleted file]
client/sal_service_adaptor.h [deleted file]
client/sal_service_adaptor_internal.h [deleted file]
client/sal_service_auth.c [deleted file]
client/sal_service_auth.h [deleted file]
client/sal_service_auth_internal.h [deleted file]
client/sal_service_provider.c [deleted file]
client/sal_service_provider.h [deleted file]
client/sal_service_storage.c [deleted file]
client/sal_service_storage.h [deleted file]
client/sal_service_storage_internal.h [deleted file]
client/sal_service_task.c [deleted file]
client/sal_service_task.h [deleted file]
client/sal_service_task_internal.h [deleted file]
client/sal_storage_provider.c [deleted file]
client/sal_storage_provider.h [deleted file]
common/CMakeLists.txt
common/base/sal_ipc.c [new file with mode: 0644]
common/base/sal_ipc.h [new file with mode: 0644]
common/base/sal_log.h [new file with mode: 0644]
common/base/sal_types.h [new file with mode: 0644]
common/ipc-adaptor/sal_ipc_adaptor.c [new file with mode: 0644]
common/ipc-adaptor/sal_ipc_adaptor.h [new file with mode: 0644]
common/ipc-adaptor/sal_ipc_adaptor_types.h [new file with mode: 0644]
common/ipc-adaptor/sal_ipc_client_auth.c [new file with mode: 0644]
common/ipc-adaptor/sal_ipc_client_auth.h [new file with mode: 0644]
common/ipc-adaptor/sal_ipc_client_core.c [new file with mode: 0644]
common/ipc-adaptor/sal_ipc_client_core.h [new file with mode: 0644]
common/ipc-adaptor/sal_ipc_client_storage.c [new file with mode: 0644]
common/ipc-adaptor/sal_ipc_client_storage.h [new file with mode: 0644]
common/ipc-client/sal_ipc_client.c
common/ipc-client/sal_ipc_client.h
common/ipc-client/sal_ipc_client_auth.c
common/ipc-client/sal_ipc_client_auth.h
common/ipc-client/sal_ipc_client_core.c
common/ipc-client/sal_ipc_client_core.h
common/ipc-client/sal_ipc_client_storage.c
common/ipc-client/sal_ipc_client_storage.h
common/ipc-provider/sal_ipc_provider.c [new file with mode: 0644]
common/ipc-provider/sal_ipc_provider.h [new file with mode: 0644]
common/ipc-provider/sal_ipc_provider_base.c [new file with mode: 0644]
common/ipc-provider/sal_ipc_provider_base.h [new file with mode: 0644]
common/ipc-provider/sal_ipc_provider_storage.c [new file with mode: 0644]
common/ipc-provider/sal_ipc_provider_storage.h [new file with mode: 0644]
common/ipc-provider/sal_ipc_provider_types.h [new file with mode: 0644]
common/ipc-server/sal_ipc_server.c
common/ipc-server/sal_ipc_server.h
common/ipc-server/sal_ipc_server_auth.c
common/ipc-server/sal_ipc_server_auth.h
common/ipc-server/sal_ipc_server_core.c
common/ipc-server/sal_ipc_server_core.h
common/ipc-server/sal_ipc_server_storage.c
common/ipc-server/sal_ipc_server_storage.h
common/ipc-server/sal_ipc_server_types.h [new file with mode: 0644]
common/sal_ipc.c [deleted file]
common/sal_ipc.h [deleted file]
include/service_adaptor_client.h
include/service_adaptor_client_plugin.h
include/service_adaptor_client_storage.h
include/service_adaptor_client_type.h [new file with mode: 0644]
include/service_adaptor_errors.h [deleted file]
include/service_adaptor_internal.h [deleted file]
include/service_adaptor_type.h [new file with mode: 0644]
include/service_adaptor_types.h [deleted file]
include/service_provider.h
include/service_provider_types.h [new file with mode: 0644]
include/storage_provider.h [new file with mode: 0644]
packaging/service-adaptor.spec
server/CMakeLists.txt
server/sal_auth.c [deleted file]
server/sal_auth.h [deleted file]
server/sal_base.c [new file with mode: 0644]
server/sal_base.h [new file with mode: 0644]
server/sal_contact.c
server/sal_contact.h
server/sal_engine.c [new file with mode: 0644]
server/sal_engine.h [new file with mode: 0644]
server/sal_main.c
server/sal_observer.c
server/sal_observer.h
server/sal_resource.c
server/sal_resource.h
server/sal_storage.c
server/sal_storage.h
service-adaptor.pc.in

index 7f2a71f9070f777853d593dfd187fd92d181ab3e..057b59c99d19ade90ca2a679f6bed87331780fc2 100644 (file)
@@ -16,7 +16,7 @@ MESSAGE(">>> Build type: ${CMAKE_BUILD_TYPE}")
 ##########################################################
 # Define Adaptor
 ##########################################################
-ADD_SUBDIRECTORY(adaptor)
+#ADD_SUBDIRECTORY(adaptor)
 
 ##########################################################
 # Define BASE LIB
@@ -26,7 +26,7 @@ ADD_SUBDIRECTORY(common)
 ##########################################################
 # Define Adaptor API
 ##########################################################
-ADD_SUBDIRECTORY(client)
+ADD_SUBDIRECTORY(api)
 
 ##########################################################
 # Define Adaptor Manager & Execute File
@@ -36,7 +36,7 @@ ADD_SUBDIRECTORY(server)
 ##########################################################
 # Define Test App
 ##########################################################
-ADD_SUBDIRECTORY(test)
+#ADD_SUBDIRECTORY(test)
 
 ##########################################################
 # Define Install Files
diff --git a/Documentation/architecture/Dependency.txt b/Documentation/architecture/Dependency.txt
new file mode 100644 (file)
index 0000000..9a5f8a8
--- /dev/null
@@ -0,0 +1,49 @@
+*forder tree
+
+│
+├── api
+│   â”œâ”€â”€ client       : libservice-adaptor-client.so
+│   â””── provider     : libservice-provider.so
+│
+├── server           : sal-server (executable)
+│
+├── client
+│   â”œâ”€â”€ ipc-client   : libsal-ipc-client.so
+│   â””── ipc-server   : libsal-ipc-server.so
+│
+├── provider
+│   â”œâ”€â”€ ipc-adaptor  : libsal-ipc-adaptor.so
+│   â””── ipc-provider : libsal-ipc-provider.so
+│
+└── common
+    â””── base         : libsal-commom-base.so
+
+
+*dependency
+ -- graph
+
+             client        server        provider
+             â†™ â†“           â†™ â†“ â†˜            â†“ â†˜
+   ipc-client     ipc-server    ipc-adaptor     ipc-provider
+       â†“              â†“              â†“               â†“
+                            base
+
+ -- tree
+
+client
+    â”œâ”€â”€ ipc-client
+    â”‚   â””── base
+    â””── base
+
+server
+    â”œâ”€â”€ ipc-server
+    â”‚   â””── base
+    â”œâ”€â”€ ipc-adaptor
+    â”‚   â””── base
+    â””── base
+
+provider
+    â”œâ”€â”€ ipc-provider
+    â”‚   â””── base
+    â””── base
+
diff --git a/api/CMakeLists.txt b/api/CMakeLists.txt
new file mode 100644 (file)
index 0000000..36d1845
--- /dev/null
@@ -0,0 +1,123 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(sal-api)
+
+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(VISIBILITY "-DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\"")
+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")
+
+##########################################################
+# 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
+)
+
+INCLUDE_DIRECTORIES(
+        ${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
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(adaptor_client_pkgs REQUIRED dlog glib-2.0 capi-appfw-application bundle)
+
+FOREACH(flag ${adaptor_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(${ADAPTOR-CLIENT-LIB} SHARED ${ADAPTOR-CLIENT-SRCS})
+
+TARGET_LINK_LIBRARIES(${ADAPTOR-CLIENT-LIB} ${adaptor_client_pkgs_LDFLAGS} sal-common-base sal-common-client)
+SET_TARGET_PROPERTIES(${ADAPTOR-CLIENT-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${ADAPTOR-CLIENT-LIB} PROPERTIES VERSION ${VERSION})
+
+INSTALL(TARGETS ${ADAPTOR-CLIENT-LIB} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+
+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
+)
+
+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)
diff --git a/api/client/sal_client_internal.c b/api/client/sal_client_internal.c
new file mode 100644 (file)
index 0000000..ce0aeed
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Auth Adaptor Client
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this oauth1 except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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 "sal_log.h"
+#include "sal_ipc.h"
+
+#include "sal_client_internal.h"
+#include <service_adaptor_type.h>
+
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+API int sal_client_return_ipc_ret(int ipc_client_ret)
+{
+       switch (ipc_client_ret) {
+       case SAL_ERROR_NONE:
+               SAL_INFO("== API remote ret : %s", "SERVICE_ADAPTOR_ERROR_NONE");
+               return SERVICE_ADAPTOR_ERROR_NONE;
+       case SAL_ERROR_NOT_SUPPORTED:
+               SAL_ERR("== API remote ret : %s", "SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED");
+               return SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED;
+       case SAL_ERROR_INVALID_PARAMETER:
+               SAL_ERR("== API remote ret : %s", "SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER");
+               return SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER;
+       case SAL_ERROR_TIMED_OUT:
+               SAL_ERR("== API remote ret : %s", "SERVICE_ADAPTOR_ERROR_TIMED_OUT");
+               return SERVICE_ADAPTOR_ERROR_TIMED_OUT;
+       case SAL_ERROR_NO_DATA:
+               SAL_ERR("== API remote ret : %s", "SERVICE_ADAPTOR_ERROR_NO_DATA");
+               return SERVICE_ADAPTOR_ERROR_NO_DATA;
+       case SAL_ERROR_PERMISSION_DENIED:
+               SAL_ERR("== API remote ret : %s", "SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED");
+               return SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED;
+       case SAL_ERROR_IPC_UNSTABLE:
+               SAL_ERR("== API remote ret : %s", "SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE");
+               return SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE;
+       case SAL_ERROR_PLUGIN_FAILED:
+               SAL_ERR("== API remote ret : %s", "SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED");
+               return SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED;
+       case SAL_ERROR_NOT_AUTHORIZED:
+               SAL_ERR("== API remote ret : %s", "SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED");
+               return SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED;
+       case SAL_ERROR_INVALID_STATE:
+               SAL_ERR("== API remote ret : %s", "SERVICE_ADAPTOR_ERROR_INVALID_STATE");
+               return SERVICE_ADAPTOR_ERROR_INVALID_STATE;
+       default:
+               SAL_ERR("== API remote ret : %d, %s", ipc_client_ret, "SERVICE_ADAPTOR_ERROR_UNKNOWN");
+               return SERVICE_ADAPTOR_ERROR_UNKNOWN;
+       }
+}
diff --git a/api/client/sal_client_internal.h b/api/client/sal_client_internal.h
new file mode 100644 (file)
index 0000000..7c91e51
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Service Adaptor Client
+ *
+ * Copyright (c) 2014 - 2015 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 __SAL_CLIENT_INTERNAL_H__
+#define __SAL_CLIENT_INTERNAL_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+
+int sal_client_return_ipc_ret(int ipc_client_ret);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SAL_CLIENT_INTERNAL_H__ */
diff --git a/api/client/sal_client_types.h b/api/client/sal_client_types.h
new file mode 100644 (file)
index 0000000..604e8d3
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Service Auth Internal
+ *
+ * Copyright (c) 2014 - 2015 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 __SAL_CLIENT_TYPES_H__
+#define __SAL_CLIENT_TYPES_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <glib.h>
+
+/**
+ * @brief Describes infromation about Adaptor Handle
+ */
+typedef struct _service_adaptor_s {
+       int pid;
+       char *uri;
+
+       GList *plugins;         /* char **plugins (uri) */
+       GList *started_plugins; /* service_plugin_h **started_plugins */
+} service_adaptor_s;
+
+/**
+ * @brief Describes infromation about Plugin Handle
+ */
+typedef struct _service_plugin_s {
+       char *uri;
+       char *handle;
+       GHashTable *property;
+} service_plugin_s;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SAL_CLIENT_TYPES_H__ */
diff --git a/api/client/sal_service_adaptor.c b/api/client/sal_service_adaptor.c
new file mode 100644 (file)
index 0000000..63439ac
--- /dev/null
@@ -0,0 +1,420 @@
+/*
+ * Service Adaptor
+ *
+ * Copyright (c) 2014 - 2015 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 <string.h>
+#include <unistd.h>
+#include <glib.h>
+
+#include <app.h>
+
+#include <service_adaptor_client.h>
+
+#include "sal_log.h"
+#include "sal_ipc.h"
+#include "sal_types.h"
+
+#include "sal_ipc_client.h"
+
+#include "sal_client_types.h"
+#include "sal_client_internal.h"
+
+/*
+#include "service_adaptor_errors.h"
+#include "service_adaptor_internal.h"
+#include "sal_service_adaptor.h"
+#include "sal_service_task.h"
+#include "sal_service_task_internal.h"
+#include "sal_ipc_client.h"
+#include "sal_ipc_client_core.h"
+#include "sal_ipc_client_auth.h"
+
+#include "sal_client_internal.h"
+*/
+
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+static service_adaptor_h g_service_adaptor = NULL;
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+static void __destroy_service_adaptor(service_adaptor_h handle);
+
+static void __destroy_service_plugin(service_plugin_h handle);
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+static void __destroy_service_adaptor(service_adaptor_h handle)
+{
+}
+
+static void __destroy_service_plugin(service_plugin_h handle)
+{
+       if (handle) {
+               if (handle->property)
+                       g_hash_table_unref(handle->property);
+               handle->property = NULL;
+               SAL_FREE(handle->uri);
+               SAL_FREE(handle);
+       }
+}
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+API int service_adaptor_connect()
+{
+       SAL_FN_CALL;
+
+       g_service_adaptor = (service_adaptor_h) g_malloc0(sizeof(service_adaptor_s));
+       RETV_IF(NULL == g_service_adaptor, SERVICE_ADAPTOR_ERROR_OUT_OF_MEMORY);
+
+       char *uri = NULL;
+
+       app_get_id(&uri);
+
+       if (NULL == uri) {
+               char path[1024] = {0,};
+               int path_len = 0;
+
+               path_len = readlink("/proc/self/exe", path, 1024);
+               if (0 == path_len)
+                       uri = strdup("notfound");
+               else
+                       uri = strndup(path, path_len);
+
+               RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_OUT_OF_MEMORY);
+       }
+
+       g_service_adaptor->uri = uri;
+       uri = NULL;
+
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       GList *plugins = NULL;
+
+       ret = sal_ipc_client_init();
+       TRYM_IF(SAL_ERROR_NONE != ret, "ipc init failed : %d", ret);
+
+       int pid = (int)getpid();
+       ret = ipc_service_adaptor_connect(pid, uri, &plugins);
+       TRYM_IF(SAL_ERROR_NONE != ret, "API remote failed : %d", ret);
+
+       g_service_adaptor->pid = pid;
+       g_service_adaptor->plugins = plugins;
+
+       return sal_client_return_ipc_ret(ret);
+
+catch:
+       SAL_FREE(g_service_adaptor->uri);
+       SAL_FREE(g_service_adaptor);
+
+       return sal_client_return_ipc_ret(ret);
+}
+
+API int service_adaptor_disconnect()
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == g_service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_STATE);
+
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+/*
+       ret = service_task_disconnect();
+       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "service_task_disconnect() Failed");
+*/
+       ret = ipc_service_adaptor_disconnect(g_service_adaptor->pid, g_service_adaptor->uri);
+/*     RETV_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_UNKNOWN);*/
+       SAL_DBG("disconnect ret : %d", ret);
+
+       ret = sal_ipc_client_deinit();
+/*     RETV_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_UNKNOWN);*/
+       SAL_DBG("deinit ret : %d", ret);
+
+       /* TODO: free memory in adaptor */
+       __destroy_service_adaptor(g_service_adaptor);
+       g_service_adaptor = NULL;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+
+API int service_adaptor_create(service_adaptor_h *handle)
+{
+       RETV_IF(NULL == handle, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       if (NULL == g_service_adaptor) {
+               /* TODO add handling for duplicated connect */
+               int ret = service_adaptor_connect();
+               if (ret)
+                       return ret;
+       }
+       *handle = g_service_adaptor;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_adaptor_destroy(service_adaptor_h handle)
+{
+       RETV_IF(NULL == handle, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       return service_adaptor_disconnect();
+}
+
+
+API int service_adaptor_foreach_plugin(service_adaptor_h handle, service_adaptor_plugin_cb callback, void *user_data)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == handle, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       RETV_IF(0 == g_list_length(g_service_adaptor->plugins), SERVICE_ADAPTOR_ERROR_NO_DATA);
+
+       SAL_FOREACH_GLIST(iter, g_service_adaptor->plugins) {
+               char *_uri = (char *)iter->data;
+               bool ret = callback(_uri, (SERVICE_PLUGIN_SERVICE_AUTH | SERVICE_PLUGIN_SERVICE_STORAGE), user_data);
+               if (false == ret)
+                       break;
+       }
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_adaptor_get_last_result(int *err)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == err, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       *err = sal_ipc_client_get_last_error();
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_adaptor_get_last_error_message(char **message)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == message, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       char *_msg = sal_ipc_client_get_last_message();
+       RETV_IF(NULL == _msg, SERVICE_ADAPTOR_ERROR_NO_DATA);
+       RETV_IF('\0' == _msg[0], SERVICE_ADAPTOR_ERROR_NO_DATA);
+
+       char *ret = strdup(_msg);
+       RETV_IF(NULL == ret, SERVICE_ADAPTOR_ERROR_OUT_OF_MEMORY);
+
+       *message = ret;
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_adaptor_create_plugin(service_adaptor_h adaptor, const char *plugin_uri, service_plugin_h *plugin)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == plugin_uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       RETV_IF(NULL == g_service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_STATE);
+
+/*     int ret = ipc_service_plugin_create(uri);
+       RETV_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+*/
+       service_plugin_h service_plugin = NULL;
+       char *_uri = NULL;
+       GHashTable *_property = NULL;
+
+       service_plugin = (service_plugin_h) g_malloc0(sizeof(service_plugin_s));
+       TRYM_IF(NULL == service_plugin, "Out of memory");
+
+       _uri = strdup(plugin_uri);
+       TRYM_IF(NULL == service_plugin, "Out of memory");
+
+       _property = g_hash_table_new(g_str_hash, g_str_equal);
+       TRYM_IF(NULL == _property, "Out of memory");
+
+       service_plugin->uri = _uri;
+       service_plugin->property = _property;
+       *plugin = service_plugin;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+
+catch:
+       SAL_FREE(_uri);
+       __destroy_service_plugin(service_plugin);
+       service_plugin = NULL;
+
+       return SERVICE_ADAPTOR_ERROR_OUT_OF_MEMORY;
+}
+
+API int service_plugin_destroy(service_plugin_h plugin)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == g_service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_STATE);
+
+       /*int ret = ipc_service_plugin_stop(plugin->uri);
+       SAL_DBG("plugin destroy ret : %d", ret);
+       */
+
+       g_service_adaptor->plugins = g_list_remove(g_service_adaptor->plugins, (gpointer)plugin);
+       __destroy_service_plugin(plugin);
+       plugin = NULL;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_plugin_add_property(service_plugin_h plugin, const char *key, const char *value)
+{
+       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == value, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       RETV_IF(NULL == g_service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_STATE);
+
+       char *_key = g_strdup(key);
+       TRYM_IF(NULL == _key, "Out of memory");
+
+       char *_value = g_strdup(value);
+       TRYM_IF(NULL == _value, "Out of memory");
+
+       g_hash_table_insert(plugin->property, g_strdup(key), g_strdup(value));
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+
+catch:
+       SAL_FREE(_key);
+       SAL_FREE(_value);
+
+       return SERVICE_ADAPTOR_ERROR_OUT_OF_MEMORY;
+}
+
+API int service_plugin_remove_property(service_plugin_h plugin, const char *key)
+{
+       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       RETV_IF(NULL == g_service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_STATE);
+
+       g_hash_table_remove(plugin->property, key);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_plugin_get_property(service_plugin_h plugin, const char *key, char **value)
+{
+       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == value, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       RETV_IF(NULL == g_service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_STATE);
+
+       char *find_data = NULL;
+       find_data = (char *)g_hash_table_lookup(plugin->property, key);
+       RETV_IF(NULL == find_data, SERVICE_ADAPTOR_ERROR_NO_DATA);
+
+       char *_value = strdup(find_data);
+       RETV_IF(NULL == _value, SERVICE_ADAPTOR_ERROR_OUT_OF_MEMORY);
+
+       *value = _value;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+/*
+API int service_plugin_login(service_plugin_h plugin, service_plugin_login_cb callback, void *user_data)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == g_service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       // TODO: login this plugin via service adaptor (dbus)
+
+       callback(SERVICE_ADAPTOR_ERROR_NONE, user_data);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+*/
+
+API int service_plugin_start(service_plugin_h plugin, int service_mask)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(0 >= service_mask, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       RETV_IF(NULL == g_service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_STATE);
+
+       RETV_IF(NULL == g_service_adaptor->uri, SERVICE_ADAPTOR_ERROR_UNKNOWN);
+       RETV_IF(NULL == plugin->uri, SERVICE_ADAPTOR_ERROR_UNKNOWN);
+
+       char *plugin_handle = NULL;
+       int ret = ipc_service_plugin_start(g_service_adaptor->pid,
+                       g_service_adaptor->uri, plugin->uri, &plugin_handle);
+
+       if (!ret) {
+               g_service_adaptor->started_plugins = g_list_append(g_service_adaptor->started_plugins, plugin);
+               plugin->handle = plugin_handle;
+       }
+
+       return sal_client_return_ipc_ret(ret);
+}
+
+API int service_plugin_stop(service_plugin_h plugin)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       RETV_IF(NULL == g_service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_STATE);
+       RETV_IF(NULL == plugin->handle, SERVICE_ADAPTOR_ERROR_INVALID_STATE);
+
+       int ret = ipc_service_plugin_stop(plugin->handle);
+       /* TODO add retry logic if ipc failed */
+       SAL_ERR("ipc stop failed : %d", ret);
+
+       SAL_FREE(plugin->handle);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+/*
+int service_plugin_get_uri(service_plugin_h plugin, char **uri)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == g_service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == g_list_find(g_service_adaptor->started_plugins, plugin), SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       *uri = strdup(plugin->uri);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+*/
diff --git a/api/client/sal_service_adaptor.h b/api/client/sal_service_adaptor.h
new file mode 100644 (file)
index 0000000..8808040
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Service Adaptor
+ *
+ * Copyright (c) 2014 - 2015 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__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* TODO : Inhouse APIs will be descripted */
+
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SERVICE_ADAPTOR_H__ */
diff --git a/api/client/sal_service_auth.c b/api/client/sal_service_auth.c
new file mode 100644 (file)
index 0000000..867597f
--- /dev/null
@@ -0,0 +1,230 @@
+/*
+ * Auth Adaptor Client
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this oauth1 except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+
+#include <app.h>
+#include "sal_service_auth.h"
+/*
+#include "service_adaptor_errors.h"
+#include "service_adaptor_internal.h"
+#include "sal_service_adaptor.h"
+#include "sal_service_adaptor_internal.h"
+#include "sal_service_task.h"
+#include "sal_service_task_internal.h"
+#include "sal_service_auth_internal.h"
+#include "sal_ipc_client_auth.h"
+*/
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+/*
+int service_auth_oauth1_start(service_auth_oauth1_h oauth1)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == oauth1->plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       char *uri = NULL;
+
+       ret = service_plugin_get_uri(oauth1->plugin, &uri);
+       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "service_plugin_get_uri() Failed(%d)", ret);
+
+       service_auth_oauth1_h auth_oauth1 = NULL;
+       ret = ipc_service_auth_oauth1(uri, oauth1, &auth_oauth1);
+       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "ipc_service_auth_oauth1() Failed(%d)", ret);
+
+       RETV_IF(NULL == oauth1->callback, SERVICE_ADAPTOR_ERROR_NONE);
+
+       oauth1->callback(SERVICE_ADAPTOR_ERROR_NONE, auth_oauth1, oauth1->user_data);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+int service_auth_oauth1_stop(service_auth_oauth1_h oauth1)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+*/
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+/*
+API int service_auth_oauth1_create(service_plugin_h plugin, service_auth_oauth1_h *oauth1)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_auth_oauth1_h auth_oauth1 = (service_auth_oauth1_h) g_malloc0(sizeof(service_auth_oauth1_s));
+       auth_oauth1->plugin = plugin;
+
+       *oauth1 = auth_oauth1;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_auth_oauth1_oauth1_clone(service_auth_oauth1_h src_oauth1, service_auth_oauth1_h *dst_oauth1)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == src_oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == dst_oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_auth_oauth1_h auth_oauth1 = (service_auth_oauth1_h) g_malloc0(sizeof(service_auth_oauth1_s));
+       auth_oauth1->plugin = src_oauth1->plugin;
+       auth_oauth1->callback = src_oauth1->callback;
+       auth_oauth1->access_token = strdup(src_oauth1->access_token);
+       auth_oauth1->operation = strdup(src_oauth1->operation);
+
+       *dst_oauth1 = auth_oauth1;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_auth_oauth1_oauth1_destroy(service_auth_oauth1_h oauth1)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       SAL_FREE(oauth1->access_token);
+       SAL_FREE(oauth1->operation);
+       SAL_FREE(oauth1);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_auth_oauth1_set_callback(service_auth_oauth1_h oauth1, service_auth_oauth1_cb callback, void *user_data)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       oauth1->callback = callback;
+       oauth1->user_data = user_data;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_auth_oauth1_unset_callback(service_auth_oauth1_h oauth1)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       oauth1->callback = NULL;
+       oauth1->user_data = NULL;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_auth_oauth1_set_access_token(service_auth_oauth1_h oauth1, const char *access_token)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == access_token, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       oauth1->access_token = strdup(access_token);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_auth_oauth1_get_access_token(service_auth_oauth1_h oauth1, char **access_token)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == access_token, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       *access_token = strdup(oauth1->access_token);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_auth_oauth1_set_operation(service_auth_oauth1_h oauth1, const char *operation)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == operation, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       oauth1->operation = strdup(operation);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_auth_oauth1_get_operation(service_auth_oauth1_h oauth1, char **operation)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == operation, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       *operation = strdup(oauth1->operation);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_auth_oauth1_create_task(service_auth_oauth1_h oauth1, service_task_h *task)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_task_h service_task = (service_task_h) g_malloc0(sizeof(service_task_s));
+       service_task->oauth1 = oauth1;
+
+       *task = service_task;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_auth_oauth1_destroy_task(service_task_h task)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       SAL_FREE(task);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+*/
diff --git a/api/client/sal_service_auth.h b/api/client/sal_service_auth.h
new file mode 100644 (file)
index 0000000..5e9f483
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Service Auth
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this oauth1 except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_AUTH_H__
+#define __SERVICE_AUTH_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/*
+#include "sal_service_adaptor.h"
+#include "sal_service_task.h"
+
+#define SERVICE_AUTH_OAUTH1_0_GET_ACCESS_TOKEN_URI     "http://tizen.org/service-adaptor/auth/oauth1.0/get_access_token"
+#define SERVICE_AUTH_OAUTH1_0_GET_EXTRA_DATA_URI       "http://tizen.org/service-adaptor/auth/oauth1.0/get_extra_data"
+
+#define SERVICE_AUTH_OAUTH2_0_GET_ACCESS_TOKEN_URI     "http://tizen.org/service-adaptor/auth/oauth2.0/get_access_token"
+#define SERVICE_AUTH_OAUTH2_0_GET_EXTRA_DATA_URI       "http://tizen.org/service-adaptor/auth/oauth2.0/get_extra_data"
+
+typedef struct _service_auth_oauth1_s *service_auth_oauth1_h;
+
+typedef void (*service_auth_oauth1_cb)(int result, service_auth_oauth1_h oauth1, void *user_data);
+typedef void (*service_auth_oauth1_get_access_token_cb)(int result, const char *access_token, void *user_data);
+*/
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+/*
+int service_auth_oauth1_create(service_plugin_h plugin, service_auth_oauth1_h *oauth1);
+int service_auth_oauth1_clone(service_auth_oauth1_h src_oauth1, service_auth_oauth1_h *dst_oauth1);
+int service_auth_oauth1_destroy(service_auth_oauth1_h oauth1);
+int service_auth_oauth1_set_callback(service_auth_oauth1_h oauth1, service_auth_oauth1_cb callback, void *user_data);
+int service_auth_oauth1_unset_callback(service_auth_oauth1_h oauth1);
+int service_auth_oauth1_set_access_token(service_auth_oauth1_h oauth1, const char *access_token);
+int service_auth_oauth1_get_access_token(service_auth_oauth1_h oauth1, char **access_token);
+int service_auth_oauth1_set_operation(service_auth_oauth1_h oauth1, const char *operation);
+int service_auth_oauth1_get_operation(service_auth_oauth1_h oauth1, char **operation);
+int service_auth_oauth1_create_task(service_auth_oauth1_h oauth1, service_task_h *task);
+int service_auth_oauth1_destroy_task(service_task_h task);
+*/
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SERVICE_AUTH_H__ */
diff --git a/api/client/sal_service_auth_internal.h b/api/client/sal_service_auth_internal.h
new file mode 100644 (file)
index 0000000..850338a
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Service Auth Internal
+ *
+ * Copyright (c) 2014 - 2015 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_AUTH_INTERNAL_H__
+#define __SERVICE_AUTH_INTERNAL_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/*
+#include <glib.h>
+
+#include "sal_service_adaptor.h"
+#include "sal_service_auth.h"
+
+typedef struct _service_auth_oauth1_s
+{
+       service_plugin_h plugin;
+       service_auth_oauth1_cb callback;
+       void *user_data;
+
+       char *access_token;
+       char *operation;
+} service_auth_oauth1_s;
+*/
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+/*
+int service_auth_oauth1_start(service_auth_oauth1_h oauth1);
+int service_auth_oauth1_stop(service_auth_oauth1_h oauth1);
+*/
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SERVICE_AUTH_INTERNAL_H__ */
diff --git a/api/client/sal_service_storage.c b/api/client/sal_service_storage.c
new file mode 100644 (file)
index 0000000..302dca7
--- /dev/null
@@ -0,0 +1,630 @@
+/*
+ * Service Storage
+ *
+ * Copyright (c) 2014 - 2015 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 <string.h>
+#include <glib.h>
+
+#include <app.h>
+#include "sal_service_storage.h"
+/*
+#include "service_adaptor_errors.h"
+#include "service_adaptor_internal.h"
+#include "sal_service_adaptor.h"
+#include "sal_service_adaptor_internal.h"
+#include "sal_service_task.h"
+#include "sal_service_task_internal.h"
+#include "sal_service_storage_internal.h"
+#include "sal_ipc_client_storage.h"
+*/
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+/*
+int service_storage_cloud_start(service_storage_cloud_file_h file)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == file->plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       char *uri = NULL;
+
+       ret = service_plugin_get_uri(file->plugin, &uri);
+       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "service_plugin_get_uri() Failed(%d)", ret);
+
+       service_storage_cloud_file_h cloud_file = NULL;
+       ret = ipc_service_storage_cloud_file(uri, file, &cloud_file);
+       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "ipc_service_storage_cloud_file() Failed(%d)", ret);
+
+       RETV_IF(NULL == file->callback, SERVICE_ADAPTOR_ERROR_NONE);
+
+       file->callback(SERVICE_ADAPTOR_ERROR_NONE, cloud_file,  file->user_data);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+int service_storage_cloud_stop(service_storage_cloud_file_h file)
+{
+       SAL_FN_CALL;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+*/
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+/*
+API int service_storage_cloud_file_create(service_plugin_h plugin, service_storage_cloud_file_h *file)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) g_malloc0(sizeof(service_storage_cloud_file_s));
+       cloud_file->plugin = plugin;
+       cloud_file->callback = NULL;
+       cloud_file->is_dir = false;
+       cloud_file->size = 0;
+       cloud_file->dir_path = NULL;
+       cloud_file->local_path = NULL;
+       cloud_file->cloud_path = NULL;
+       cloud_file->operation = NULL;
+       cloud_file->files = NULL;
+
+       *file = cloud_file;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_cloud_file_clone(service_storage_cloud_file_h src_file, service_storage_cloud_file_h *dst_file)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == src_file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == dst_file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) g_malloc0(sizeof(service_storage_cloud_file_s));
+       cloud_file->plugin = src_file->plugin;
+       cloud_file->callback = src_file->callback;
+       cloud_file->is_dir = src_file->is_dir;
+       cloud_file->size = src_file->size;
+       cloud_file->dir_path = g_strdup(src_file->dir_path);
+       cloud_file->local_path = g_strdup(src_file->local_path);
+       cloud_file->cloud_path = g_strdup(src_file->cloud_path);
+       cloud_file->operation = g_strdup(src_file->operation);
+       // TODO: g_list_copy_deep()
+       if (NULL != src_file->files) {
+               cloud_file->files = g_list_copy(src_file->files);
+       } else {
+               cloud_file->files = NULL;
+       }
+
+       *dst_file = cloud_file;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_cloud_file_destroy(service_storage_cloud_file_h file)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       SAL_FREE(file->dir_path);
+       SAL_FREE(file->local_path);
+       SAL_FREE(file->cloud_path);
+       SAL_FREE(file->operation);
+       SAL_FREE(file);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_cloud_file_set_callback(service_storage_cloud_file_h file, service_storage_cloud_file_cb callback, void *user_data)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       file->callback = callback;
+       file->user_data = user_data;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_cloud_file_unset_callback(service_storage_cloud_file_h file)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       file->callback = NULL;
+       file->user_data = NULL;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_cloud_file_set_cloud_path(service_storage_cloud_file_h file, const char *cloud_path)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cloud_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       file->cloud_path = strdup(cloud_path);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_cloud_file_get_cloud_path(service_storage_cloud_file_h file, char **cloud_path)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cloud_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       *cloud_path = g_strdup(file->cloud_path);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_cloud_file_set_local_path(service_storage_cloud_file_h file, const char *local_path)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == local_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       file->local_path = strdup(local_path);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_cloud_file_get_local_path(service_storage_cloud_file_h file, char **local_path)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == local_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       *local_path = g_strdup(file->local_path);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_cloud_file_set_size(service_storage_cloud_file_h file, unsigned long long size)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       file->size = size;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_cloud_file_get_size(service_storage_cloud_file_h file, unsigned long long *size)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == size, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       *size = file->size;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_cloud_file_set_operation(service_storage_cloud_file_h file, const char *operation)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == operation, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       file->operation = strdup(operation);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_cloud_file_get_operation(service_storage_cloud_file_h file, char **operation)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == operation, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       *operation = g_strdup(file->operation);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_cloud_file_is_directory(service_storage_cloud_file_h file, bool *is_dir)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == is_dir, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       *is_dir = file->is_dir;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_cloud_file_foreach_file(service_storage_cloud_file_h file, service_storage_cloud_file_cb callback, void *user_data)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       RETV_IF(false == file->is_dir, SERVICE_ADAPTOR_ERROR_NO_DATA);
+
+       RETV_IF(0 == g_list_length(file->files), SERVICE_ADAPTOR_ERROR_NO_DATA);
+
+       for (GList *list = g_list_first(file->files); list != NULL; list = list->next) {
+               service_storage_cloud_file_h file_data = (service_storage_cloud_file_h) list->data;
+
+               bool ret = callback(SERVICE_ADAPTOR_ERROR_NONE, file_data, user_data);
+               RETV_IF(false == ret, SERVICE_ADAPTOR_ERROR_NONE);
+       }
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_cloud_file_create_task(service_storage_cloud_file_h file, service_task_h *task)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_task_h service_task = (service_task_h) g_malloc0(sizeof(service_task_s));
+       service_task->cloud_file = file;
+
+       *task = service_task;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_cloud_file_destroy_task(service_task_h task)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       SAL_FREE(task);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+*/
+/******************************************************************************
+ * 2.4 Public interface definition
+ ******************************************************************************/
+/*
+API int service_storage_get_file_list(service_plugin_h plugin,
+                                               const char *dir_path,
+                                               service_storage_file_list_cb callback,
+                                               void *user_data)
+{
+       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == dir_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_storage_cloud_file_h file = NULL;
+       service_storage_cloud_file_create(plugin, &file);
+       service_storage_cloud_file_set_operation(file, SERVICE_STORAGE_CLOUD_GET_FILE_LIST_URI);
+       service_storage_cloud_file_set_cloud_path(file, dir_path);
+
+       service_task_h service_task = (service_task_h) g_malloc0(sizeof(service_task_s));
+       service_task->cloud_file = file;
+       service_task->storage_file_list_callback = callback;
+       service_task->user_data = user_data;
+
+       return service_task_start(service_task);
+}
+
+API int service_storage_remove(service_plugin_h plugin,
+                                               const char *remove_path,
+                                               service_storage_result_cb callback,
+                                               void *user_data)
+{
+       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == remove_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_storage_cloud_file_h file = NULL;
+       service_storage_cloud_file_create(plugin, &file);
+       service_storage_cloud_file_set_operation(file, SERVICE_STORAGE_CLOUD_REMOVE_FILE_URI);
+       service_storage_cloud_file_set_cloud_path(file, remove_path);
+
+       service_task_h service_task = (service_task_h) g_malloc0(sizeof(service_task_s));
+       service_task->cloud_file = file;
+       service_task->storage_result_callback = callback;
+       service_task->user_data = user_data;
+
+       return service_task_start(service_task);
+}
+
+API int service_storage_create_upload_task(service_plugin_h plugin,
+                                               const char *file_path,
+                                               const char *upload_path,
+                                               service_storage_task_h *task)
+{
+       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == file_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == upload_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_storage_cloud_file_h file = NULL;
+       service_storage_cloud_file_create(plugin, &file);
+       service_storage_cloud_file_set_operation(file, SERVICE_STORAGE_CLOUD_UPLOAD_FILE_URI);
+       service_storage_cloud_file_set_cloud_path(file, upload_path);
+       service_storage_cloud_file_set_local_path(file, file_path);
+
+       service_task_h service_task = (service_task_h) g_malloc0(sizeof(service_task_s));
+       service_task->cloud_file = file;
+
+       *task = (service_storage_task_h) service_task;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_create_download_task(service_plugin_h plugin,
+                                               const char *storage_path,
+                                               const char *download_path,
+                                               service_storage_task_h *task)
+{
+       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == storage_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == download_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_storage_cloud_file_h file = NULL;
+       service_storage_cloud_file_create(plugin, &file);
+       service_storage_cloud_file_set_operation(file, SERVICE_STORAGE_CLOUD_DOWNLOAD_FILE_URI);
+       service_storage_cloud_file_set_cloud_path(file, storage_path);
+       service_storage_cloud_file_set_local_path(file, download_path);
+
+       service_task_h service_task = (service_task_h) g_malloc0(sizeof(service_task_s));
+       service_task->cloud_file = file;
+
+       *task = (service_storage_task_h) service_task;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API 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)
+{
+       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == storage_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == download_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(0 > thumbnail_size, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_storage_cloud_file_h file = NULL;
+       service_storage_cloud_file_create(plugin, &file);
+       service_storage_cloud_file_set_operation(file, SERVICE_STORAGE_CLOUD_DOWNLOAD_FILE_THUMBNAIL_URI);
+       service_storage_cloud_file_set_cloud_path(file, storage_path);
+       service_storage_cloud_file_set_local_path(file, download_path);
+
+       service_task_h service_task = (service_task_h) g_malloc0(sizeof(service_task_s));
+       service_task->cloud_file = file;
+
+       *task = (service_storage_task_h) service_task;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_destroy_task(service_storage_task_h task)
+{
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       return service_storage_cloud_file_destroy_task((service_task_h) task);
+}
+
+API int service_storage_start_task(service_storage_task_h task)
+{
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       return service_task_start((service_task_h) task);
+}
+
+API int service_storage_cancel_task(service_storage_task_h task)
+{
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+//     return service_task_stop((service_task_h) task);
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_set_task_progress_cb(service_storage_task_h task,
+                                               service_storage_task_progress_cb callback,
+                                               void *user_data)
+{
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_task_h service_task = (service_task_h) task;
+       service_task->storage_progress_callback = callback;
+       service_task->user_data = user_data;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_unset_task_progress_cb(service_storage_task_h task)
+{
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_task_h service_task = (service_task_h) task;
+       service_task->storage_progress_callback = NULL;
+       service_task->user_data = NULL;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_set_task_state_changed_cb(service_storage_task_h task,
+                                               service_storage_task_state_cb callback,
+                                               void *user_data)
+{
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_task_h service_task = (service_task_h) task;
+       service_task->storage_state_callback = callback;
+       service_task->user_data = user_data;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_unset_task_state_changed_cb(service_storage_task_h task)
+{
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_task_h service_task = (service_task_h) task;
+       service_task->storage_state_callback = NULL;
+       service_task->user_data = NULL;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_file_list_clone(service_storage_file_list_h src_list,
+                                               service_storage_file_list_h *dst_list)
+{
+       RETV_IF(NULL == src_list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == dst_list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       *dst_list = src_list;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_file_list_destroy(service_storage_file_list_h list)
+{
+       RETV_IF(NULL == list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_file_list_get_length(service_storage_file_list_h list,
+                                               int *length)
+{
+       RETV_IF(NULL == list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == length, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_storage_cloud_file_h file = (service_storage_cloud_file_h) list;
+       *length = file->size;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_file_list_foreach_file(service_storage_file_list_h list,
+                                               service_storage_file_cb callback,
+                                               void *user_data)
+{
+       RETV_IF(NULL == list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_storage_cloud_file_h file = (service_storage_cloud_file_h) list;
+       callback((service_storage_file_h) file, user_data);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_file_clone(service_storage_file_h src_file,
+                                               service_storage_file_h *dst_file)
+{
+       RETV_IF(NULL == src_file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == dst_file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       *dst_file = src_file;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_file_destroy(service_storage_file_h file)
+{
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_file_is_dir(service_storage_file_h file,
+                                               bool *is_dir)
+{
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == is_dir, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) file;
+       *is_dir = cloud_file->is_dir;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_file_get_size(service_storage_file_h file,
+                                               unsigned long long *size)
+{
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == size, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) file;
+       *size = cloud_file->size;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_file_get_logical_path(service_storage_file_h file,
+                                               char **path)
+{
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) file;
+       *path = strdup(cloud_file->cloud_path);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_storage_file_get_physical_path(service_storage_file_h file,
+                                               char **path)
+{
+       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) file;
+       *path = strdup(cloud_file->cloud_path);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+*/
diff --git a/api/client/sal_service_storage.h b/api/client/sal_service_storage.h
new file mode 100644 (file)
index 0000000..f2459ce
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Service Storage
+ *
+ * Copyright (c) 2014 - 2015 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_STORAGE_H__
+#define __SERVICE_STORAGE_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/*
+#include "sal_service_adaptor.h"
+#include "sal_service_task.h"
+
+#define SERVICE_STORAGE_CLOUD_REMOVE_FILE_URI   "http://tizen.org/service-adaptor/storage/cloud/remove_file"
+#define SERVICE_STORAGE_CLOUD_DOWNLOAD_FILE_URI "http://tizen.org/service-adaptor/storage/cloud/download_file"
+#define SERVICE_STORAGE_CLOUD_UPLOAD_FILE_URI   "http://tizen.org/service-adaptor/storage/cloud/upload_file"
+#define SERVICE_STORAGE_CLOUD_DOWNLOAD_FILE_THUMBNAIL_URI       "http://tizen.org/service-adaptor/storage/cloud/download_file_thumbnail"
+#define SERVICE_STORAGE_CLOUD_GET_FILE_LIST_URI "http://tizen.org/service-adaptor/storage/cloud/get_file_list"
+
+typedef struct _service_storage_cloud_file_s *service_storage_cloud_file_h;
+
+typedef bool (*service_storage_cloud_file_cb)(int result, service_storage_cloud_file_h file, void *user_data);
+*/
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+/*
+int service_storage_cloud_file_create(service_plugin_h plugin, service_storage_cloud_file_h *file);
+int service_storage_cloud_file_clone(service_storage_cloud_file_h src_file, service_storage_cloud_file_h *dst_file);
+
+int service_storage_cloud_file_destroy(service_storage_cloud_file_h file);
+int service_storage_cloud_file_set_callback(service_storage_cloud_file_h file, service_storage_cloud_file_cb callback, void *user_data);
+int service_storage_cloud_file_unset_callback(service_storage_cloud_file_h file);
+int service_storage_cloud_file_set_cloud_path(service_storage_cloud_file_h file, const char *cloud_path);
+int service_storage_cloud_file_get_cloud_path(service_storage_cloud_file_h file, char **cloud_path);
+int service_storage_cloud_file_set_local_path(service_storage_cloud_file_h file, const char *local_path);
+int service_storage_cloud_file_get_local_path(service_storage_cloud_file_h file, char **local_path);
+int service_storage_cloud_file_set_size(service_storage_cloud_file_h file, unsigned long long size);
+int service_storage_cloud_file_get_size(service_storage_cloud_file_h file, unsigned long long *size);
+int service_storage_cloud_file_set_operation(service_storage_cloud_file_h file, const char *operation);
+int service_storage_cloud_file_get_operation(service_storage_cloud_file_h file, char **operation);
+int service_storage_cloud_file_is_directory(service_storage_cloud_file_h file, bool *is_dir);
+int service_storage_cloud_file_foreach_file(service_storage_cloud_file_h file, service_storage_cloud_file_cb callback, void *user_data);
+int service_storage_cloud_file_create_task(service_storage_cloud_file_h file, service_task_h *task);
+int service_storage_cloud_file_destroy_task(service_task_h task);
+
+// 2.4
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SERVICE_STORAGE_H__ */
diff --git a/api/client/sal_service_storage_internal.h b/api/client/sal_service_storage_internal.h
new file mode 100644 (file)
index 0000000..ecfbc9b
--- /dev/null
@@ -0,0 +1,162 @@
+/*
+ * Service Storage Internal
+ *
+ * Copyright (c) 2014 - 2015 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_STORAGE_INTERNAL_H__
+#define __SERVICE_STORAGE_INTERNAL_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/*
+#include <glib.h>
+
+#include "sal_service_adaptor.h"
+#include "sal_service_storage.h"
+
+typedef struct _service_storage_cloud_file_s
+{
+       service_plugin_h plugin;
+       service_storage_cloud_file_cb callback;
+       void *user_data;
+
+       bool is_dir;
+       char *dir_path;
+       char *local_path;
+       char *cloud_path;
+       unsigned long long size;
+       char *operation;
+
+       GList *files;
+} service_storage_cloud_file_s;
+
+typedef struct _service_storage_task_s
+{
+        char *service_handle_name;
+}service_storage_task_t;
+*/
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+/*
+int service_storage_cloud_start(service_storage_cloud_file_h file);
+int service_storage_cloud_stop(service_storage_cloud_file_h file);
+*/
+/*==================================================================================================
+                                       2.4 FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/**
+ * 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;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SERVICE_STORAGE_INTERNAL_H__ */
diff --git a/api/client/sal_service_task.c b/api/client/sal_service_task.c
new file mode 100644 (file)
index 0000000..c3960fd
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ * Service Task
+ *
+ * Copyright (c) 2014 - 2015 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 <string.h>
+#include <glib.h>
+#include <gio/gio.h>
+
+#include <app.h>
+
+#include "service_adaptor_errors.h"
+#include "service_adaptor_internal.h"
+#include "sal_service_adaptor.h"
+#include "sal_service_adaptor_internal.h"
+#include "sal_service_task.h"
+#include "sal_service_task_internal.h"
+#include "sal_service_auth_internal.h"
+#include "sal_service_storage_internal.h"
+
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+GList *service_tasks = NULL;
+GThreadPool *thread_pool = NULL;
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+static void _service_task_async_func(gpointer data, gpointer user_data)
+{
+       service_task_h task = (service_task_h) data;
+
+       if (NULL != task->oauth1) {
+               service_auth_oauth1_start(task->oauth1);
+       } else if (NULL != task->cloud_file) {
+               service_storage_cloud_start(task->cloud_file);
+       } else {
+               return;
+       }
+
+       /* TODO: in IPC */
+       if (NULL != task->storage_progress_callback) {
+               task->storage_progress_callback(100, 100, task->user_data);
+       }
+       if (NULL != task->storage_state_callback) {
+               task->storage_state_callback(SERVICE_STORAGE_TASK_COMPLETED, task->user_data);
+       }
+       if (NULL != task->storage_result_callback) {
+               task->storage_result_callback(SERVICE_ADAPTOR_ERROR_NONE, task->user_data);
+       }
+       if (NULL != task->storage_file_list_callback) {
+               service_storage_cloud_file_h file_list = (service_storage_cloud_file_h) g_malloc0(sizeof(service_storage_cloud_file_s));
+               file_list->is_dir = false;
+               file_list->cloud_path = "/sample.txt";
+               file_list->size = 1;
+               task->storage_file_list_callback(SERVICE_ADAPTOR_ERROR_NONE, (service_storage_cloud_file_h) file_list, task->user_data);
+       }
+}
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+API int service_task_connect()
+{
+       SAL_FN_CALL;
+
+       thread_pool = g_thread_pool_new(_service_task_async_func, NULL, -1, FALSE, NULL);
+       RETVM_IF(NULL == thread_pool, SERVICE_ADAPTOR_ERROR_SYSTEM, "g_thread_pool_new() Failed");
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_task_disconnect()
+{
+       SAL_FN_CALL;
+
+       /* TODO: stop current stated task */
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_task_start(service_task_h task)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       service_tasks = g_list_append(service_tasks, task);
+
+       g_thread_pool_push(thread_pool, (gpointer) task, NULL);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_task_stop(service_task_h task)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       if (NULL != task->cloud_file) {
+               service_storage_cloud_stop(task->cloud_file);
+       } else {
+               return SERVICE_ADAPTOR_ERROR_NO_DATA;
+       }
+
+       service_tasks = g_list_remove(service_tasks, task);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_task_set_uri(service_task_h task, const char *uri)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       task->uri = strdup(uri);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_task_get_uri(service_task_h task, char **uri)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       *uri = g_strdup(task->uri);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_task_set_progress_callback(service_task_h task, service_task_progress_cb callback, void *user_data)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       task->progress_callback = callback;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_task_unset_progress_callback(service_task_h task)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       task->progress_callback = NULL;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_task_set_state_changed_callback(service_task_h task, service_task_state_changed_cb callback, void *user_data)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       task->state_callback = callback;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int  service_task_unset_state_changed_callback(service_task_h task)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       task->state_callback = NULL;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
diff --git a/api/client/sal_service_task.h b/api/client/sal_service_task.h
new file mode 100644 (file)
index 0000000..0825e24
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Service Task
+ *
+ * Copyright (c) 2014 - 2015 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_TASK_H__
+#define __SERVICE_TASK_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/*
+typedef enum _service_task_state_e
+{
+       SERVICE_TASK_IN_PROGRESS        = 1,
+       SERVICE_TASK_COMPLETED          = 2,
+       SERVICE_TASK_CANCELED           = 3,
+       SERVICE_TASK_FAILED             = 4
+} service_task_state_e;
+
+typedef struct _service_task_s *service_task_h;
+
+typedef void (*service_task_progress_cb)(service_task_h task, unsigned long long progress, unsigned long long total, void *user_data);
+
+typedef void (*service_task_state_changed_cb)(service_task_h task, service_task_state_e state, void *user_data);
+*/
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+/*
+int service_task_start(service_task_h task);
+int service_task_stop(service_task_h task);
+int service_task_set_uri(service_task_h task, const char *uri);
+int service_task_get_uri(service_task_h task, char **uri);
+int service_task_set_progress_callback(service_task_h task, service_task_progress_cb callback, void *user_data);
+int service_task_unset_progress_callback(service_task_h task);
+int service_task_set_state_changed_callback(service_task_h task, service_task_state_changed_cb callback, void *user_data);
+int service_task_unset_state_changed_callback(service_task_h task);
+*/
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SERVICE_TASK_H__ */
diff --git a/api/client/sal_service_task_internal.h b/api/client/sal_service_task_internal.h
new file mode 100644 (file)
index 0000000..9a1763a
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Service Task Internal
+ *
+ * Copyright (c) 2014 - 2015 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_TASK_INTERNAL_H__
+#define __SERVICE_TASK_INTERNAL_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/*
+#include "sal_service_task.h"
+#include "sal_service_auth.h"
+#include "sal_service_storage.h"
+
+typedef struct _service_task_s
+{
+       char *uri;
+       service_task_progress_cb progress_callback;
+       service_task_state_changed_cb state_callback;
+
+       service_auth_oauth1_h oauth1;
+       service_storage_cloud_file_h cloud_file;
+
+       // temp
+       service_storage_task_progress_cb storage_progress_callback;
+       service_storage_task_state_cb storage_state_callback;
+       service_storage_result_cb storage_result_callback;
+       service_storage_file_list_cb storage_file_list_callback;
+       void *user_data;
+} service_task_s;
+*/
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
+/*
+int service_task_connect();
+int service_task_disconnect();
+*/
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SERVICE_TASK_INTERNAL_H__ */
diff --git a/api/provider/sal_provider_base.c b/api/provider/sal_provider_base.c
new file mode 100644 (file)
index 0000000..5d69c78
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * Auth Plugin Client
+ *
+ * Copyright (c) 2014 - 2015 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 <string.h>
+#include <glib.h>
+
+#include "sal_provider_base.h"
+
+static void __session_start_cb(ipc_provider_session_h session, const char *client_uri);
+
+static void __session_stop_cb(ipc_provider_session_h session, const char *session_uri);
+
+static ipc_provider_base_req_s __base_req_handler = {
+               __session_start_cb,
+               __session_stop_cb,
+       };
+
+ipc_provider_base_req_s *sal_provider_base_init(void)
+{
+       return &__base_req_handler;
+}
+
+static void __session_start_cb(ipc_provider_session_h session, const char *client_uri)
+{
+}
+
+static void __session_stop_cb(ipc_provider_session_h session, const char *session_uri)
+{
+}
+
+/*
+#include "service_adaptor_errors.h"
+#include "service_adaptor_internal.h"
+#include "sal_service_provider.h"
+#include "sal_auth_provider.h"
+
+API int auth_provider_create(auth_provider_h *provider)
+{
+       SAL_FN_CALL;
+
+       auth_provider_h auth_provider = (auth_provider_h) g_malloc0(sizeof(auth_provider_s));
+
+       auth_provider->oauth1_get_access_token = NULL;
+       auth_provider->oauth1_get_extra_data = NULL;
+
+       auth_provider->oauth2_get_access_token = NULL;
+       auth_provider->oauth2_get_extra_data = NULL;
+
+       *provider = auth_provider;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API app_control_h auth_provider_message(auth_provider_h provider, const char *operation, void *user_data)
+{
+       SAL_FN_CALL;
+
+       app_control_h reply = NULL;
+
+       RETV_IF(NULL == provider, reply);
+
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if (0 == strcmp(operation, OAUTH1_0_GET_ACCESS_TOKEN_URI)) {
+               app_control_create(&reply);
+
+               char *access_token = NULL;
+               ret = provider->oauth1_get_access_token(&access_token);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+                       SAL_ERR("oauth1_get_access_token() Fail (%d)", ret);
+                       app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_FAILURE);
+                       return reply;
+               }
+
+               app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_SUCCESS);
+               app_control_add_extra_data(reply, OAUTH1_0_ACCESS_TOKEN_KEY, access_token);
+       }
+
+       return reply;
+}
+
+API int auth_provider_add_extra_data(auth_provider_h provider, app_control_h reply)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == provider, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == reply, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       app_control_add_extra_data(reply, PLUGIN_KEY_AUTH, PLUGIN_VALUE_TRUE);
+
+       if (NULL != provider->oauth1_get_access_token) {
+               app_control_add_extra_data(reply, OAUTH1_0_GET_ACCESS_TOKEN_URI, PLUGIN_VALUE_TRUE);
+       }
+
+       if (NULL != provider->oauth1_get_extra_data) {
+               app_control_add_extra_data(reply, OAUTH1_0_GET_EXTRA_DATA_URI, PLUGIN_VALUE_TRUE);
+       }
+
+       if (NULL != provider->oauth2_get_access_token) {
+               app_control_add_extra_data(reply, OAUTH2_0_GET_ACCESS_TOKEN_URI, PLUGIN_VALUE_TRUE);
+       }
+
+       if (NULL != provider->oauth2_get_extra_data) {
+               app_control_add_extra_data(reply, OAUTH2_0_GET_EXTRA_DATA_URI, PLUGIN_VALUE_TRUE);
+       }
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+*/
diff --git a/api/provider/sal_provider_base.h b/api/provider/sal_provider_base.h
new file mode 100644 (file)
index 0000000..6b32944
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Auth Plugin Client
+ *
+ * Copyright (c) 2014 - 2015 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 __SAL_PROVIDER_BASE_H__
+#define __SAL_PROVIDER_BASE_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "sal_ipc_provider_base.h"
+
+ipc_provider_base_req_s *sal_provider_base_init(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SAL_PROVIDER_BASE_H__ */
diff --git a/api/provider/sal_provider_internal.h b/api/provider/sal_provider_internal.h
new file mode 100644 (file)
index 0000000..d5b406e
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Service Provider internal
+ *
+ * Copyright (c) 2014 - 2015 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 __SAL_PROVIDER_INTERNAL_H__
+#define __SAL_PROVIDER_INTERNAL_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SAL_PROVIDER_INTERNAL_H__ */
diff --git a/api/provider/sal_provider_service.c b/api/provider/sal_provider_service.c
new file mode 100644 (file)
index 0000000..ab6287c
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+ * Service Plugin Client
+ *
+ * Copyright (c) 2014 - 2015 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 <string.h>
+#include <glib.h>
+
+#include "sal_log.h"
+#include "sal_ipc.h"
+#include "sal_types.h"
+#include "sal_ipc_provider.h"
+
+#include <app_control.h>
+#include <service_app.h>
+
+#include "service_adaptor_type.h"
+#include "service_provider.h"
+
+#define ERROR_MESSAGE_MAX_LENGTH     2048
+
+static __thread int last_error_code = 0;
+
+static __thread char last_error_message[ERROR_MESSAGE_MAX_LENGTH] = {0, };
+
+
+USER_DATA_TYPEDEF(_ipc_state_data_t, 2);
+
+static void __ipc_connection_callback(ipc_provider_connection_state_e state, void *user_data)
+{
+       SAL_FN_CALL;
+
+       USER_DATA_DEFINE(_ipc_state_data_t, _callback_data) = (USER_DATA_TYPE(_ipc_state_data_t) *)user_data;
+       service_provider_channel_cb callback = (service_provider_channel_cb)USER_DATA_ELEMENT(_callback_data, 0);
+       void *_user_data = (void *)USER_DATA_ELEMENT(_callback_data, 1);
+
+       int ret = SERVICE_PROVIDER_RECOMMENDED_DEFAULT;
+       if (IPC_PROVIDER_CONNECTION_OPENED == state) {
+               ret = callback(SERVICE_PROVIDER_CHANNEL_OPENED, _user_data);
+               if (SERVICE_PROVIDER_APPLICATION_SHUTDOWN == ret) {
+                       SAL_INFO("Application termication");
+                       /* TODO release internal memory */
+                       USER_DATA_DESTROY(_callback_data);
+                       service_app_exit();
+               } else { /* default (alive) */
+
+               }
+       } else {
+               ret = callback(SERVICE_PROVIDER_CHANNEL_CLOSED, _user_data);
+               /* TODO release internal memory */
+               if (SERVICE_PROVIDER_APPLICATION_CONTINUE == ret) {
+
+               } else { /* default (shutdown) */
+                       SAL_INFO("Application termication");
+                       USER_DATA_DESTROY(_callback_data);
+                       service_app_exit();
+               }
+       }
+
+       SAL_FN_END;
+}
+
+API int service_provider_set_storage_provider (storage_provider_s *storage_provider, void *user_data)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == storage_provider, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == storage_provider->open, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == storage_provider->read, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == storage_provider->write, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == storage_provider->fsync, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == storage_provider->close, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == storage_provider->remove, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == storage_provider->rename, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == storage_provider->mkdir, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == storage_provider->chmod, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == storage_provider->access, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == storage_provider->stat, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == storage_provider->opendir, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == storage_provider->readdir, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == storage_provider->closedir, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_provider_open_channel(app_control_h app_control,
+               service_provider_channel_cb callback,
+               void *user_data)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == app_control, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       int ret = 0;
+       char *_operation = NULL;
+       ret = app_control_get_operation(app_control, &_operation);
+
+       RETVM_IF(APP_CONTROL_ERROR_OUT_OF_MEMORY == ret, SERVICE_ADAPTOR_ERROR_OUT_OF_MEMORY, "Out of Memory");
+       RETVM_IF(NULL == _operation, SERVICE_ADAPTOR_ERROR_NO_DATA, "No operation data");
+
+       if (0 != g_strcmp0(APP_CONTROL_OPERATION_SERVICE_PROVIDER_CHANNEL, _operation)) {
+               SAL_ERR("operation ID is not matched");
+               free(_operation);
+               return SERVICE_ADAPTOR_ERROR_NO_DATA;
+       }
+
+       USER_DATA_DEFINE(_ipc_state_data_t, _callback_data) = NULL;
+
+       USER_DATA_VAL(_callback_data) = USER_DATA_CREATE(_ipc_state_data_t);
+
+       if (NULL == USER_DATA_VAL(_callback_data)) {
+               SAL_ERR("Out of memory");
+               free(_operation);
+               return SERVICE_ADAPTOR_ERROR_OUT_OF_MEMORY;
+       }
+
+       USER_DATA_ELEMENT(_callback_data, 0) = (user_data_t)callback;
+       USER_DATA_ELEMENT(_callback_data, 1) = (user_data_t)user_data;
+
+       ipc_provider_base_req_s *base_req = sal_provider_base_init();
+       ipc_provider_storage_req_s *storage_req = sal_provider_storage_init();
+
+       ret = sal_ipc_provider_init(base_req,
+                       storage_req,
+                       __ipc_connection_callback,
+                       USER_DATA_VAL(_callback_data));
+
+       free(_operation);
+
+       return sal_provider_return_ipc_ret(ret);
+}
+
+API int service_provider_set_last_error(int code, const char *message)
+{
+       SAL_FN_CALL;
+       SAL_ERR("<thread-safe> set last error : [%d][%s]", code, message);
+
+       last_error_code = code;
+       if (message)
+               snprintf(last_error_message, ERROR_MESSAGE_MAX_LENGTH, "%s", message);
+       else
+               last_error_message[0] = '\0';
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API int service_provider_set_session_event_cb(service_provider_session_event_cb callback, void *user_data)
+{
+       SAL_FN_CALL;
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+API int service_provider_unset_session_event_cb(void)
+{
+       SAL_FN_CALL;
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+API int service_provider_get_session_property(service_provider_session_h session, const char *key, char **value)
+{
+       SAL_FN_CALL;
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+API int service_provider_foreach_session_property(service_provider_session_h session, service_provider_session_property_cb callback, void *user_data)
+{
+       SAL_FN_CALL;
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+API int service_provider_get_session_service_mask(service_provider_session_h session, int *service_mask)
+{
+       SAL_FN_CALL;
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
diff --git a/api/provider/sal_provider_service.h b/api/provider/sal_provider_service.h
new file mode 100644 (file)
index 0000000..da9027c
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Service Plugin Client
+ *
+ * Copyright (c) 2014 - 2015 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_PLUGIN_CLIENT_H__
+#define __SERVICE_PLUGIN_CLIENT_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "sal_provider_base.h"
+#include "sal_provider_storage.h"
+
+/**
+ * @brief Describes infromation about Plugin Handle
+ */
+typedef struct _service_provider_s
+{
+       service_adaptor_error_e (*connect)(void);
+       service_adaptor_error_e (*disconnect)(void);
+
+       auth_provider_h auth_provider;
+       storage_provider_h storage_provider;
+
+       char *uri;
+       char *name;
+} service_provider_s;
+typedef struct _service_provider_s *service_provider_h;
+
+/*
+int service_provider_create(service_provider_h *provider);
+int service_provider_destroy(service_provider_h provider);
+int service_provider_set_auth_provider(service_provider_h provider, auth_provider_h auth_provider);
+int service_provider_unset_auth_provider(service_provider_h provider);
+int service_provider_set_storage_provider(service_provider_h provider, storage_provider_h storage_provider);
+int service_provider_unset_storage_provider(service_provider_h provider);
+int service_provider_message(service_provider_h provider, app_control_h app_control, void *user_data);
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SERVICE_PLUGIN_CLIENT_H__ */
diff --git a/api/provider/sal_provider_storage.c b/api/provider/sal_provider_storage.c
new file mode 100644 (file)
index 0000000..ec07d81
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * Storage Plugin Client
+ *
+ * Copyright (c) 2014 - 2015 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 <string.h>
+#include <glib.h>
+
+#include "sal_provider_storage.h"
+
+static void __download_cb(ipc_provider_session_h session, const char *session_uri,
+               const char *local_path, const char *cloud_path);
+
+static ipc_provider_storage_req_s __storage_req_handler = {
+               __download_cb,
+       };
+
+ipc_provider_storage_req_s *sal_provider_storage_init(void)
+
+{
+       return &__storage_req_handler;
+}
+
+static void __download_cb(ipc_provider_session_h session, const char *session_uri,
+               const char *local_path, const char *cloud_path)
+{
+}
+
+
+/*
+#include <app.h>
+
+#include "service_adaptor_errors.h"
+#include "service_adaptor_internal.h"
+#include "cloud_service.h"
+#include "sal_service_provider.h"
+#include "sal_storage_provider.h"
+
+API int storage_provider_create(storage_provider_h *provider)
+{
+       SAL_FN_CALL;
+
+       storage_provider_h storage_provider = (storage_provider_h) g_malloc0(sizeof(storage_provider_s));
+
+       storage_provider->cloud_remove_file = NULL;
+
+       *provider = storage_provider;
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+API app_control_h storage_provider_message(storage_provider_h provider, const char *operation, void *user_data)
+{
+       SAL_FN_CALL;
+
+       app_control_h reply = NULL;
+
+       RETV_IF(NULL == provider, reply);
+
+       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+
+       if (0 == strcmp(operation, CLOUD_REMOVE_FILE_URI)) {
+               app_control_create(&reply);
+
+               char *cloud_path = NULL;
+               app_control_get_extra_data((app_control_h) user_data, CLOUD_CLOUD_PATH_KEY, &cloud_path);
+
+               ret = provider->cloud_remove_file(cloud_path);
+
+               if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
+                       SAL_ERR("cloud_remove_file() Fail (%d)", ret);
+                       app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_FAILURE);
+                       return reply;
+               }
+
+               app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_SUCCESS);
+       }
+
+       return reply;
+}
+
+API int storage_provider_add_extra_data(storage_provider_h provider, app_control_h reply)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == provider, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == reply, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+
+       app_control_add_extra_data(reply, PLUGIN_KEY_STORAGE, PLUGIN_VALUE_TRUE);
+
+       if (NULL != provider->cloud_remove_file) {
+               app_control_add_extra_data(reply, CLOUD_REMOVE_FILE_URI, PLUGIN_VALUE_TRUE);
+       }
+
+       return SERVICE_ADAPTOR_ERROR_NONE;
+}
+
+
+
+API int storage_provider_stat_set_path (storage_provider_stat_h stat, const char *path);
+API int storage_provider_stat_set_size (storage_provider_stat_h stat, unsigned long long size);
+API int storage_provider_stat_set_dir (storage_provider_stat_h stat, bool is_dir);
+API int storage_provider_stat_set_mode (storage_provider_stat_h stat, int mode);
+API int storage_provider_stat_set_atime (storage_provider_stat_h stat, unsigned long long timestamp);
+API int storage_provider_stat_set_mtime (storage_provider_stat_h stat, unsigned long long timestamp);
+API int storage_provider_stat_set_ctime (storage_provider_stat_h stat, unsigned long long timestamp);
+*/
diff --git a/api/provider/sal_provider_storage.h b/api/provider/sal_provider_storage.h
new file mode 100644 (file)
index 0000000..1220238
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Storage Plugin Client
+ *
+ * Copyright (c) 2014 - 2015 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 __STORAGE_PLUGIN_CLIENT_H__
+#define __STORAGE_PLUGIN_CLIENT_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "sal_ipc_provider_storage.h"
+
+ipc_provider_storage_req_s *sal_provider_storage_init(void);
+
+/*
+#include <app.h>
+
+#include "service_adaptor_errors.h"
+
+#define CLOUD_LOCAL_PATH_KEY   "local_path"
+#define CLOUD_CLOUD_PATH_KEY   "cloud_path"
+*/
+/**
+ * @brief Describes infromation about Cloud Service
+ * @key name, ...
+ */
+/*
+#define CLOUD_REMOVE_FILE_URI   "http://tizen.org/service-adaptor/storage/cloud/remove_file"
+#define CLOUD_DOWNLOAD_FILE_URI "http://tizen.org/service-adaptor/storage/cloud/download_file"
+#define CLOUD_UPLOAD_FILE_URI   "http://tizen.org/service-adaptor/storage/cloud/upload_file"
+#define CLOUD_DOWNLOAD_FILE_THUMBNAIL_URI       "http://tizen.org/service-adaptor/storage/cloud/download_file_thumbnail"
+#define CLOUD_GET_FILE_LIST_URI "http://tizen.org/service-adaptor/storage/cloud/get_file_list"
+*/
+/**
+ * @brief Describes infromation about Storage Plugin Handle
+ */
+/*
+typedef struct _storage_provider_s
+{
+       // Cloud
+       service_adaptor_error_e (*cloud_remove_file)(const char *cloud_path);
+       service_adaptor_error_e (*cloud_download_file)(const char *cloud_path, const char *local_path);
+       service_adaptor_error_e (*cloud_upload_file)(const char *local_path, const char *cloud_path);
+       service_adaptor_error_e (*cloud_download_file_thumbnail)(const char *cloud_path, const char *local_path);
+
+       // Posix
+} storage_provider_s;
+typedef struct _storage_provider_s *storage_provider_h;
+
+int storage_provider_create(storage_provider_h *provider);
+app_control_h storage_provider_message(storage_provider_h provider, const char *operation, void *user_data);
+int storage_provider_add_extra_data(storage_provider_h provider, app_control_h reply);
+*/
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __STORAGE_PLUGIN_CLIENT_H__ */
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
deleted file mode 100644 (file)
index 9c026d8..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(sal-client)
-
-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(VISIBILITY "-DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\"")
-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")
-
-##########################################################
-# Define Service Adaptor CLIENT
-##########################################################
-
-SET(ADAPTOR-CLIENT-LIB "service-adaptor-client")
-SET(ADAPTOR-CLIENT-SRCS
-        ${CMAKE_SOURCE_DIR}/client/sal_service_adaptor.c
-        ${CMAKE_SOURCE_DIR}/client/sal_service_task.c
-        ${CMAKE_SOURCE_DIR}/client/sal_service_auth.c
-        ${CMAKE_SOURCE_DIR}/client/sal_service_storage.c
-)
-
-INCLUDE_DIRECTORIES(
-        ${CMAKE_SOURCE_DIR}/include
-        ${CMAKE_SOURCE_DIR}/common
-        ${CMAKE_SOURCE_DIR}/common/ipc-client
-        ${CMAKE_SOURCE_DIR}/client
-        ${CMAKE_SOURCE_DIR}/adaptor/auth-adaptor
-        ${CMAKE_SOURCE_DIR}/adaptor/contact-adaptor
-        ${CMAKE_SOURCE_DIR}/adaptor/storage-adaptor
-)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(adaptor_client_pkgs REQUIRED dlog glib-2.0 capi-appfw-application)
-
-FOREACH(flag ${adaptor_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(${ADAPTOR-CLIENT-LIB} SHARED ${ADAPTOR-CLIENT-SRCS})
-
-TARGET_LINK_LIBRARIES(${ADAPTOR-CLIENT-LIB} ${adaptor_client_pkgs_LDFLAGS} sal-common-client)
-SET_TARGET_PROPERTIES(${ADAPTOR-CLIENT-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
-SET_TARGET_PROPERTIES(${ADAPTOR-CLIENT-LIB} PROPERTIES VERSION ${VERSION})
-
-INSTALL(TARGETS ${ADAPTOR-CLIENT-LIB} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
-
-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_types.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/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
-)
-
-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}/client/sal_service_provider.c
-        ${CMAKE_SOURCE_DIR}/client/sal_auth_provider.c
-        ${CMAKE_SOURCE_DIR}/client/sal_storage_provider.c
-)
-
-INCLUDE_DIRECTORIES(
-        ${CMAKE_SOURCE_DIR}/include
-        ${CMAKE_SOURCE_DIR}/client
-        ${CMAKE_SOURCE_DIR}/adaptor/auth-adaptor
-        ${CMAKE_SOURCE_DIR}/adaptor/contact-adaptor
-        ${CMAKE_SOURCE_DIR}/adaptor/storage-adaptor
-)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(plugin_client_pkgs REQUIRED dlog glib-2.0 capi-appfw-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}/client/sal_service_provider.h
-        ${CMAKE_SOURCE_DIR}/client/sal_auth_provider.h
-        ${CMAKE_SOURCE_DIR}/client/sal_storage_provider.h
-)
-
-INSTALL(FILES ${SAL-PLUGIN-CLIENT-HEADERS} DESTINATION include/service-provider)
diff --git a/client/sal_auth_provider.c b/client/sal_auth_provider.c
deleted file mode 100644 (file)
index 8bdb5c7..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Auth Plugin Client
- *
- * Copyright (c) 2014 - 2015 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 <string.h>
-#include <glib.h>
-
-#include <app.h>
-
-#include "service_adaptor_errors.h"
-#include "service_adaptor_internal.h"
-#include "sal_service_provider.h"
-#include "sal_auth_provider.h"
-
-API int auth_provider_create(auth_provider_h *provider)
-{
-       SAL_FN_CALL;
-
-       auth_provider_h auth_provider = (auth_provider_h) g_malloc0(sizeof(auth_provider_s));
-
-       auth_provider->oauth1_get_access_token = NULL;
-       auth_provider->oauth1_get_extra_data = NULL;
-
-       auth_provider->oauth2_get_access_token = NULL;
-       auth_provider->oauth2_get_extra_data = NULL;
-
-       *provider = auth_provider;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API app_control_h auth_provider_message(auth_provider_h provider, const char *operation, void *user_data)
-{
-       SAL_FN_CALL;
-
-       app_control_h reply = NULL;
-
-       RETV_IF(NULL == provider, reply);
-
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
-
-       if (0 == strcmp(operation, OAUTH1_0_GET_ACCESS_TOKEN_URI)) {
-               app_control_create(&reply);
-
-               char *access_token = NULL;
-               ret = provider->oauth1_get_access_token(&access_token);
-
-               if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
-                       SAL_ERR("oauth1_get_access_token() Fail (%d)", ret);
-                       app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_FAILURE);
-                       return reply;
-               }
-
-               app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_SUCCESS);
-               app_control_add_extra_data(reply, OAUTH1_0_ACCESS_TOKEN_KEY, access_token);
-       }
-
-       return reply;
-}
-
-API int auth_provider_add_extra_data(auth_provider_h provider, app_control_h reply)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == provider, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == reply, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       app_control_add_extra_data(reply, PLUGIN_KEY_AUTH, PLUGIN_VALUE_TRUE);
-
-       if (NULL != provider->oauth1_get_access_token) {
-               app_control_add_extra_data(reply, OAUTH1_0_GET_ACCESS_TOKEN_URI, PLUGIN_VALUE_TRUE);
-       }
-
-       if (NULL != provider->oauth1_get_extra_data) {
-               app_control_add_extra_data(reply, OAUTH1_0_GET_EXTRA_DATA_URI, PLUGIN_VALUE_TRUE);
-       }
-
-       if (NULL != provider->oauth2_get_access_token) {
-               app_control_add_extra_data(reply, OAUTH2_0_GET_ACCESS_TOKEN_URI, PLUGIN_VALUE_TRUE);
-       }
-
-       if (NULL != provider->oauth2_get_extra_data) {
-               app_control_add_extra_data(reply, OAUTH2_0_GET_EXTRA_DATA_URI, PLUGIN_VALUE_TRUE);
-       }
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
diff --git a/client/sal_auth_provider.h b/client/sal_auth_provider.h
deleted file mode 100644 (file)
index 2c91809..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Auth Plugin Client
- *
- * Copyright (c) 2014 - 2015 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 __AUTH_PLUGIN_CLIENT_H__
-#define __AUTH_PLUGIN_CLIENT_H__
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include <app.h>
-
-#include "service_adaptor_errors.h"
-
-#define OAUTH1_0_ACCESS_TOKEN_KEY      "access_token"
-
-#define OAUTH1_0_GET_ACCESS_TOKEN_URI  "http://tizen.org/service-adaptor/auth/oauth1.0/get_access_token"
-#define OAUTH1_0_GET_EXTRA_DATA_URI    "http://tizen.org/service-adaptor/auth/oauth1.0/get_extra_data"
-
-#define OAUTH2_0_GET_ACCESS_TOKEN_URI  "http://tizen.org/service-adaptor/auth/oauth2.0/get_access_token"
-#define OAUTH2_0_GET_EXTRA_DATA_URI    "http://tizen.org/service-adaptor/auth/oauth2.0/get_extra_data"
-
-/**
- * @brief Describes infromation about Auth Plugin Handle
- */
-typedef struct _auth_provider_s
-{
-       // oAuth 1.0
-       service_adaptor_error_e (*oauth1_get_access_token)(char **access_token);
-       service_adaptor_error_e (*oauth1_get_extra_data)(const char *key, char **value);
-
-       // oAuth 2.0
-       service_adaptor_error_e (*oauth2_get_access_token)(char **access_token);
-       service_adaptor_error_e (*oauth2_get_extra_data)(const char *key, char **value);
-} auth_provider_s;
-typedef struct _auth_provider_s *auth_provider_h;
-
-int auth_provider_create(auth_provider_h *provider);
-app_control_h auth_provider_message(auth_provider_h provider, const char *operation, void *user_data);
-int auth_provider_add_extra_data(auth_provider_h provider, app_control_h reply);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __AUTH_PLUGIN_CLIENT_H__ */
diff --git a/client/sal_service_adaptor.c b/client/sal_service_adaptor.c
deleted file mode 100644 (file)
index 7c1d05e..0000000
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- * Service Adaptor
- *
- * Copyright (c) 2014 - 2015 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 <string.h>
-#include <unistd.h>
-#include <glib.h>
-
-#include <app.h>
-
-#include "service_adaptor_errors.h"
-#include "service_adaptor_internal.h"
-#include "sal_service_adaptor.h"
-#include "sal_service_task.h"
-#include "sal_service_task_internal.h"
-#include "sal_ipc_client.h"
-#include "sal_ipc_client_core.h"
-#include "sal_ipc_client_auth.h"
-
-/******************************************************************************
- * Global variables and defines
- ******************************************************************************
-
-/**
- * @brief Describes infromation about Adaptor Handle
- */
-typedef struct _service_adaptor_s {
-       char *uri;
-
-       GList *plugins;         /* char **plugins (uri) */
-       GList *started_plugins; /* service_plugin_h **started_plugins */
-} service_adaptor_s;
-/* typedef struct _service_adaptor_s *service_adaptor_h; */
-
-/**
- * @brief Describes infromation about Plugin Handle
- */
-typedef struct _service_plugin_s {
-       char *uri;
-       GHashTable *property;
-} service_plugin_s;
-
-service_adaptor_h service_adaptor = NULL;
-
-/******************************************************************************
- * Private interface
- ******************************************************************************/
-
-/******************************************************************************
- * Private interface definition
- ******************************************************************************/
-
-/******************************************************************************
- * Public interface definition
- ******************************************************************************/
-
-API int service_adaptor_create(service_adaptor_h *service_adaptor)
-{
-       RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       *service_adaptor = (service_adaptor_h) g_malloc0(sizeof(service_adaptor_s));
-
-       return service_adaptor_connect();
-}
-
-API int service_adaptor_destroy(service_adaptor_h service_adaptor)
-{
-       RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       return service_adaptor_disconnect();
-}
-
-API int service_adaptor_connect()
-{
-       SAL_FN_CALL;
-
-       service_adaptor = (service_adaptor_h) g_malloc0(sizeof(service_adaptor_s));
-
-       char *uri = NULL;
-
-       app_get_id(&uri);
-
-       if (NULL == uri) {
-               char path[1024] = {0,};
-               int path_len = 0;
-
-               path_len = readlink("/proc/self/exe", path, 1024);
-               RETV_IF(0 == path_len, SERVICE_ADAPTOR_ERROR_SYSTEM);
-
-               uri = strndup(path, path_len);
-       }
-
-       service_adaptor->uri = strdup(uri);
-
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
-       ret = sal_ipc_client_init();
-       RETV_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_INTERNAL);
-
-       GList *plugins = NULL;
-       ret = ipc_service_adaptor_connect(uri, &plugins);
-       RETV_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_INTERNAL);
-
-       ret = service_task_connect();
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "service_task_connect() Failed");
-
-       service_adaptor->plugins = plugins;
-
-       SAL_FREE(uri);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_adaptor_disconnect()
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
-       ret = service_task_disconnect();
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "service_task_disconnect() Failed");
-
-       ret = ipc_service_adaptor_disconnect(service_adaptor->uri);
-       RETV_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_INTERNAL);
-
-       ret = sal_ipc_client_deinit();
-       RETV_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_INTERNAL);
-
-       /* TODO: free memory in adaptor */
-       SAL_FREE(service_adaptor);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_adaptor_foreach_plugin(service_adaptor_h service_adaptor, service_adaptor_plugin_cb callback, void *user_data)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       return service_adaptor_foreach_service_plugin(callback, user_data);
-}
-
-API int service_adaptor_foreach_service_plugin(service_adaptor_plugin_cb callback, void *user_data)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       RETV_IF(0 == g_list_length(service_adaptor->plugins), SERVICE_ADAPTOR_ERROR_NO_DATA);
-
-       for (GList *list = g_list_first(service_adaptor->plugins); list != NULL; list = list->next) {
-               char * uri = (char *) list->data;
-
-               bool ret = callback(uri, 0, user_data);
-               RETV_IF(false == ret, SERVICE_ADAPTOR_ERROR_NONE);
-       }
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_adaptor_get_last_result(int *err)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == err, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_adaptor_get_last_error_message(char **message)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == message, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       return SERVICE_ADAPTOR_ERROR_NO_DATA;
-}
-
-API int service_adaptor_create_plugin(service_adaptor_h service_adaptor, const char *plugin_uri, service_plugin_h *plugin)
-{
-       RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       return service_plugin_create(plugin_uri, plugin);
-}
-
-API int service_plugin_create(const char *uri, service_plugin_h *plugin)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       int ret = ipc_service_plugin_create(uri);
-       RETV_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_plugin_h service_plugin = (service_plugin_h) g_malloc0(sizeof(service_plugin_s));
-
-       service_plugin->uri = strdup(uri);
-       service_plugin->property = g_hash_table_new(g_str_hash, g_str_equal);
-
-       *plugin = service_plugin;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_plugin_destroy(service_plugin_h plugin)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       int ret = ipc_service_plugin_destroy(plugin->uri);
-       RETV_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       /* TODO: free memeory of plugin */
-       SAL_FREE(plugin);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_plugin_add_property(service_plugin_h plugin, const char *key, const char *value)
-{
-       RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == key, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == value, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       g_hash_table_insert(plugin->property, g_strdup(key), g_strdup(value));
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_plugin_remove_property(service_plugin_h plugin, const char *key)
-{
-       RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == key, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       g_hash_table_remove(plugin->property, key);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_plugin_get_property(service_plugin_h plugin, const char *key, char **value)
-{
-       RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == key, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == value, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       if (0 < g_hash_table_size(plugin->property)) {
-               GHashTableIter iter;
-               gpointer iter_key, iter_value;
-
-               g_hash_table_iter_init(&iter, plugin->property);
-               while (g_hash_table_iter_next(&iter, &iter_key, &iter_value)) {
-                       if (strcmp(key, (char *) iter_key) == 0) {
-                               *value = g_strdup(iter_value);
-                               return SERVICE_ADAPTOR_ERROR_NONE;
-                       }
-               }
-       }
-
-       return SERVICE_ADAPTOR_ERROR_NO_DATA;
-}
-
-API int service_plugin_login(service_plugin_h plugin, service_plugin_login_cb callback, void *user_data)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       /* TODO: login this plugin via service adaptor (dbus) */
-
-       callback(SERVICE_ADAPTOR_ERROR_NONE, user_data);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_plugin_start(service_plugin_h plugin, int service_mask)
-{
-       RETV_IF(0 >= service_mask, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       return service_plugin_start_all(plugin);
-}
-
-API int service_plugin_start_all(service_plugin_h plugin)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       /* TODO: check this plugin via service adaptor (dbus), use or not use?, must be logined. */
-
-       service_adaptor->started_plugins = g_list_append(service_adaptor->started_plugins, plugin);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_plugin_stop(service_plugin_h plugin)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       /* TODO: notify to stop this plugin to service adaptor (dbus) */
-
-       for (GList *list = g_list_first(service_adaptor->started_plugins); list != NULL; list = list->next) {
-               service_plugin_h service_plugin = (service_plugin_h) list->data;
-
-               if (0 == strcmp(service_plugin->uri, plugin->uri)) {
-                       service_adaptor->started_plugins = g_list_remove(service_adaptor->started_plugins, list);
-
-                       return SERVICE_ADAPTOR_ERROR_NONE;
-               }
-       }
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-int service_plugin_get_uri(service_plugin_h plugin, char **uri)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == g_list_find(service_adaptor->started_plugins, plugin), SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       *uri = strdup(plugin->uri);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
diff --git a/client/sal_service_adaptor.h b/client/sal_service_adaptor.h
deleted file mode 100644 (file)
index 93e4e7d..0000000
+++ /dev/null
@@ -1,489 +0,0 @@
-/*
- * Service Adaptor
- *
- * Copyright (c) 2014 - 2015 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__
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include <glib.h>
-
-/**
- * @addtogroup  SERVICE_ADAPTOR_MODULE
- * @{
- */
-
-/**
- * @brief Type of service in plugin
- */
-typedef enum _service_plugin_type_e
-{
-       SERVICE_PLUGIN_AUTH     = (0x01 << 0),          /**< Auth service type flag */
-       SERVICE_PLUGIN_STORAGE  = (0x01 << 1),          /**< Storage service type flag */
-} service_plugin_type_e;
-
-/** 2.4
- * @brief Type of service in plugin
- */
-typedef enum _service_plugin_service_type_e
-{
-        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"
-
-/** 2.4
-* @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 The handle for connection and managing handle of Service Plugin
- * @details The handle can be created by service_plugin_create()<br>
- *  When a handle is no longer needed, use service_plugin_destroy()
- * @see #service_plugin_create()
- * @see #service_plugin_destroy()
- */
-typedef struct _service_plugin_s *service_plugin_h;
-
-/**
- * @brief Callback for service_adaptor_foreach_plugin API
- *
- * @param[in]    uri      The service plugin's unique uri, this value be set by plugin
- * @param[in]    service_mask    Masked value for <b>installed</b> service plugins, this value can be masked multiple enum (#service_plugin_service_type_e)
- * @param[in]    user_data       Passed data from #service_adaptor_foreach_plugin()
- * @remarks      @a service_mask check using 'bit and' operation with #service_plugin_service_type_e
- * @remarks      - for example,
- * @remarks      &nbsp;&nbsp;&nbsp;&nbsp;        if(@a service_mask & SERVICE_PLUGIN_SERVICE_STORAGE)
- * @remarks      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;        { @a USING_STORAGE_CODE }
- * @remarks Do not release memory of @a plugin_uri
- * @see          service_plugin_service_type_e
- * @return @c true to continue with the next iteration of the loop,
- *         otherwise @c false to break out of the loop
- * @pre  service_adaptor_foreach_plugin() will invoke this callback.
- */
-typedef bool (*service_adaptor_plugin_cb)(const char *uri,
-               int service_mask,
-               void *user_data);
-
-/**
- * @brief Callback for service_plugin_login API
- *
- * @param[in]    result
- * @param[in]    user_data       Passed data from #service_plugin_login()
- * @remarks
- * @return void
- * @pre  service_plugin_login() will invoke this callback.
- */
-typedef void (*service_plugin_login_cb)(int result,
-               void *user_data);
-
-/*==================================================================================================
-                                         FUNCTION PROTOTYPES
-==================================================================================================*/
-
-/** 2.4
-* @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);
-
-/** 2.4
-* @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 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_connect();
-
-/**
- * @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_disconnect();
-
-/** 2.4
-* @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 Foreach the list of plugin
- * @details Iterate to all installed plugin
- * @since_tizen 2.4
- *
- * @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_service_plugin(service_adaptor_plugin_cb callback,
-               void *user_data);
-
-/**
- * @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);
-
-/*
-int service_adaptor_add_plugin(service_adaptor_h adaptor_client, const char *plugin_uri);
-int service_adaptor_remove_plugin(service_adaptor_h adaptor_client, const char *plugin_uri);
-int service_adaptor_get_auth(service_adaptor_h adaptor_client, const char *uri, service_auth_h *auth);
-*/
-
-/** 2.4
-* @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 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_plugin_create(const char *uri, service_plugin_h *plugin);
-
-/**
- * @brief        Destroy service plugin handle
- * @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 Logins Plugin using Property
- * @since_tizen 3.0
- *
- * @param[in]    plugin  The handle for use Plugin APIs
- * @param[in]    callback        The callback for login
- * @param[in]    user_data       Passed data to callback
- * @remarks
- * @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
- * @pre  The function get property already set by service_adaptor_set_plugin_property()
- */
-int service_plugin_login(service_plugin_h plugin, service_plugin_login_cb callback, void *user_data);
-
-/** 2.4
-* @brief Requests start initalization for service plugin
-* @since_tizen 2.4
-*
-* @param[in]    plugin          The handle for use Plugin APIs
-* @param[in]    service_mask    The flag for use service plugins, this flag can be masked multiple enum (#service_plugin_service_type_e)
-* @remarks      @a service_mask must be input using 'bit or' operation with #service_plugin_service_type_e
-* @remarks      - for example,
-* @remarks      &nbsp;&nbsp;&nbsp;&nbsp;        <b>int</b> @a service_mask |= SERVIE_PLUGIN_SERVICE_AUTH;
-* @remarks      &nbsp;&nbsp;&nbsp;&nbsp;        @a service_mask |= SERVICE_PLUGIN_SERVICE_STORAGE;
-* @remarks      &nbsp;&nbsp;&nbsp;&nbsp;        <b>int</b> ret = service_plugin_start(@a m_plugin, @a service_mask);
-* @remarks      If a program needs to stop plugin manually, use #service_plugin_stop(). <br>But in #service_plugin_destroy(), automatically stop service plugin
-* @see          service_plugin_service_type_e
-* @see          service_plugin_stop()
-* @return 0 on success, otherwise a negative error value
-* @return If return value is #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED, request authorization to signup application
-* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
-* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED Need authorization
-* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
-* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
-* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
-*/
-int service_plugin_start(service_plugin_h plugin,
-                                                int service_mask);
-
-/**
- * @brief Requests start initalization for service plugin
- * @since_tizen 2.4
- *
- * @param[in]    plugin          The handle for use Plugin APIs
- * @remarks      @a service_mask must be input using 'bit or' operation with #service_plugin_service_type_e
- * @remarks      - for example,
- * @remarks      &nbsp;&nbsp;&nbsp;&nbsp;        <b>int</b> @a service_mask |= SERVIE_PLUGIN_SERVICE_AUTH;
- * @remarks      &nbsp;&nbsp;&nbsp;&nbsp;        @a service_mask |= SERVICE_PLUGIN_SERVICE_STORAGE;
- * @remarks      &nbsp;&nbsp;&nbsp;&nbsp;        <b>int</b> ret = service_plugin_start(@a m_plugin, @a service_mask);
- * @remarks      If a program needs to stop plugin manually, use #service_plugin_stop(). <br>But in #service_plugin_destroy(), automatically stop service plugin
- * @see          service_plugin_service_type_e
- * @see          service_plugin_stop()
- * @return 0 on success, otherwise a negative error value
- * @return If return value is #SERVICE_ADAPTOR_ERROR_NOT_AUTHOLIZED, request signup to autholization application
- * @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
- * @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #SERVICE_ADAPTOR_ERROR_NOT_AUTHOLIZED Need atholization
- * @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_all(service_plugin_h plugin);
-
-/**
- * @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 /* __SERVICE_ADAPTOR_H__ */
diff --git a/client/sal_service_adaptor_internal.h b/client/sal_service_adaptor_internal.h
deleted file mode 100644 (file)
index 1b04bf4..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Service Adaptor Client
- *
- * Copyright (c) 2014 - 2015 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_CLIENT_INTERNAL_H__
-#define __SERVICE_ADAPTOR_CLIENT_INTERNAL_H__
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include "sal_service_adaptor.h"
-
-/*==================================================================================================
-                                         FUNCTION PROTOTYPES
-==================================================================================================*/
-
-int service_plugin_get_uri(service_plugin_h plugin, char **uri);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SERVICE_ADAPTOR_CLIENT_INTERNAL_H__ */
diff --git a/client/sal_service_auth.c b/client/sal_service_auth.c
deleted file mode 100644 (file)
index 2c57cbb..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Auth Adaptor Client
- *
- * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this oauth1 except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <glib.h>
-
-#include <app.h>
-
-#include "service_adaptor_errors.h"
-#include "service_adaptor_internal.h"
-#include "sal_service_adaptor.h"
-#include "sal_service_adaptor_internal.h"
-#include "sal_service_task.h"
-#include "sal_service_task_internal.h"
-#include "sal_service_auth.h"
-#include "sal_service_auth_internal.h"
-#include "sal_ipc_client_auth.h"
-
-/******************************************************************************
- * Global variables and defines
- ******************************************************************************/
-
-/******************************************************************************
- * Private interface
- ******************************************************************************/
-
-/******************************************************************************
- * Private interface definition
- ******************************************************************************/
-
-int service_auth_oauth1_start(service_auth_oauth1_h oauth1)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == oauth1->plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
-       char *uri = NULL;
-
-       ret = service_plugin_get_uri(oauth1->plugin, &uri);
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "service_plugin_get_uri() Failed(%d)", ret);
-
-       service_auth_oauth1_h auth_oauth1 = NULL;
-       ret = ipc_service_auth_oauth1(uri, oauth1, &auth_oauth1);
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "ipc_service_auth_oauth1() Failed(%d)", ret);
-
-       RETV_IF(NULL == oauth1->callback, SERVICE_ADAPTOR_ERROR_NONE);
-
-       oauth1->callback(SERVICE_ADAPTOR_ERROR_NONE, auth_oauth1, oauth1->user_data);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-int service_auth_oauth1_stop(service_auth_oauth1_h oauth1)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-/******************************************************************************
- * Public interface definition
- ******************************************************************************/
-
-API int service_auth_oauth1_create(service_plugin_h plugin, service_auth_oauth1_h *oauth1)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_auth_oauth1_h auth_oauth1 = (service_auth_oauth1_h) g_malloc0(sizeof(service_auth_oauth1_s));
-       auth_oauth1->plugin = plugin;
-
-       *oauth1 = auth_oauth1;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_auth_oauth1_oauth1_clone(service_auth_oauth1_h src_oauth1, service_auth_oauth1_h *dst_oauth1)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == src_oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == dst_oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_auth_oauth1_h auth_oauth1 = (service_auth_oauth1_h) g_malloc0(sizeof(service_auth_oauth1_s));
-       auth_oauth1->plugin = src_oauth1->plugin;
-       auth_oauth1->callback = src_oauth1->callback;
-       auth_oauth1->access_token = strdup(src_oauth1->access_token);
-       auth_oauth1->operation = strdup(src_oauth1->operation);
-
-       *dst_oauth1 = auth_oauth1;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_auth_oauth1_oauth1_destroy(service_auth_oauth1_h oauth1)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       SAL_FREE(oauth1->access_token);
-       SAL_FREE(oauth1->operation);
-       SAL_FREE(oauth1);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_auth_oauth1_set_callback(service_auth_oauth1_h oauth1, service_auth_oauth1_cb callback, void *user_data)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       oauth1->callback = callback;
-       oauth1->user_data = user_data;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_auth_oauth1_unset_callback(service_auth_oauth1_h oauth1)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       oauth1->callback = NULL;
-       oauth1->user_data = NULL;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_auth_oauth1_set_access_token(service_auth_oauth1_h oauth1, const char *access_token)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == access_token, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       oauth1->access_token = strdup(access_token);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_auth_oauth1_get_access_token(service_auth_oauth1_h oauth1, char **access_token)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == access_token, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       *access_token = strdup(oauth1->access_token);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_auth_oauth1_set_operation(service_auth_oauth1_h oauth1, const char *operation)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == operation, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       oauth1->operation = strdup(operation);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_auth_oauth1_get_operation(service_auth_oauth1_h oauth1, char **operation)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == operation, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       *operation = strdup(oauth1->operation);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_auth_oauth1_create_task(service_auth_oauth1_h oauth1, service_task_h *task)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_task_h service_task = (service_task_h) g_malloc0(sizeof(service_task_s));
-       service_task->oauth1 = oauth1;
-
-       *task = service_task;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_auth_oauth1_destroy_task(service_task_h task)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       SAL_FREE(task);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
diff --git a/client/sal_service_auth.h b/client/sal_service_auth.h
deleted file mode 100644 (file)
index 97a5a3a..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Service Auth
- *
- * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this oauth1 except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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_AUTH_H__
-#define __SERVICE_AUTH_H__
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include "sal_service_adaptor.h"
-#include "sal_service_task.h"
-
-#define SERVICE_AUTH_OAUTH1_0_GET_ACCESS_TOKEN_URI     "http://tizen.org/service-adaptor/auth/oauth1.0/get_access_token"
-#define SERVICE_AUTH_OAUTH1_0_GET_EXTRA_DATA_URI       "http://tizen.org/service-adaptor/auth/oauth1.0/get_extra_data"
-
-#define SERVICE_AUTH_OAUTH2_0_GET_ACCESS_TOKEN_URI     "http://tizen.org/service-adaptor/auth/oauth2.0/get_access_token"
-#define SERVICE_AUTH_OAUTH2_0_GET_EXTRA_DATA_URI       "http://tizen.org/service-adaptor/auth/oauth2.0/get_extra_data"
-
-typedef struct _service_auth_oauth1_s *service_auth_oauth1_h;
-
-typedef void (*service_auth_oauth1_cb)(int result, service_auth_oauth1_h oauth1, void *user_data);
-typedef void (*service_auth_oauth1_get_access_token_cb)(int result, const char *access_token, void *user_data);
-
-/*==================================================================================================
-                                         FUNCTION PROTOTYPES
-==================================================================================================*/
-
-int service_auth_oauth1_create(service_plugin_h plugin, service_auth_oauth1_h *oauth1);
-int service_auth_oauth1_clone(service_auth_oauth1_h src_oauth1, service_auth_oauth1_h *dst_oauth1);
-int service_auth_oauth1_destroy(service_auth_oauth1_h oauth1);
-int service_auth_oauth1_set_callback(service_auth_oauth1_h oauth1, service_auth_oauth1_cb callback, void *user_data);
-int service_auth_oauth1_unset_callback(service_auth_oauth1_h oauth1);
-int service_auth_oauth1_set_access_token(service_auth_oauth1_h oauth1, const char *access_token);
-int service_auth_oauth1_get_access_token(service_auth_oauth1_h oauth1, char **access_token);
-int service_auth_oauth1_set_operation(service_auth_oauth1_h oauth1, const char *operation);
-int service_auth_oauth1_get_operation(service_auth_oauth1_h oauth1, char **operation);
-int service_auth_oauth1_create_task(service_auth_oauth1_h oauth1, service_task_h *task);
-int service_auth_oauth1_destroy_task(service_task_h task);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SERVICE_AUTH_H__ */
diff --git a/client/sal_service_auth_internal.h b/client/sal_service_auth_internal.h
deleted file mode 100644 (file)
index 8dbfae1..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Service Auth Internal
- *
- * Copyright (c) 2014 - 2015 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_AUTH_INTERNAL_H__
-#define __SERVICE_AUTH_INTERNAL_H__
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include <glib.h>
-
-#include "sal_service_adaptor.h"
-#include "sal_service_auth.h"
-
-typedef struct _service_auth_oauth1_s
-{
-       service_plugin_h plugin;
-       service_auth_oauth1_cb callback;
-       void *user_data;
-
-       char *access_token;
-       char *operation;
-} service_auth_oauth1_s;
-
-/*==================================================================================================
-                                         FUNCTION PROTOTYPES
-==================================================================================================*/
-
-int service_auth_oauth1_start(service_auth_oauth1_h oauth1);
-int service_auth_oauth1_stop(service_auth_oauth1_h oauth1);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SERVICE_AUTH_INTERNAL_H__ */
diff --git a/client/sal_service_provider.c b/client/sal_service_provider.c
deleted file mode 100644 (file)
index 019f8c7..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Service Plugin Client
- *
- * Copyright (c) 2014 - 2015 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 <string.h>
-#include <glib.h>
-
-#include <app.h>
-
-#include "service_adaptor_errors.h"
-#include "service_adaptor_internal.h"
-#include "sal_service_provider.h"
-
-API int service_provider_create(service_provider_h *provider)
-{
-       SAL_FN_CALL;
-
-       service_provider_h service_provider = (service_provider_h) g_malloc0(sizeof(service_provider_s));
-
-       service_provider->connect = NULL;
-       service_provider->disconnect = NULL;
-
-       *provider = service_provider;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_provider_destroy(service_provider_h provider)
-{
-       SAL_FN_CALL;
-
-       /* TODO: free internal value of provider */
-       SAL_FREE(provider);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_provider_set_auth_provider(service_provider_h provider, auth_provider_h auth_provider)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == provider, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == auth_provider, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       provider->auth_provider = auth_provider;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_provider_unset_auth_provider(service_provider_h provider)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == provider, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       provider->auth_provider = NULL;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_provider_set_storage_provider(service_provider_h provider, storage_provider_h storage_provider)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == provider, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == storage_provider, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       provider->storage_provider = storage_provider;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_provider_unset_storage_provider(service_provider_h provider)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == provider, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       provider->storage_provider = NULL;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_provider_message(service_provider_h provider, app_control_h app_control, void *user_data)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == provider, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       char *operation = NULL;
-       app_control_get_operation(app_control, &operation);
-
-       RETV_IF(NULL == operation, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
-
-       app_control_h reply = NULL;
-
-       if (0 == strcmp(operation, PLUGIN_CONNECT_URI)) {
-               app_control_create(&reply);
-               ret = provider->connect();
-
-               if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
-                       SAL_ERR("connect() Fail (%d)", ret);
-                       app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_FAILURE);
-                       goto catch;
-               }
-
-               app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_SUCCESS);
-
-               auth_provider_add_extra_data(provider->auth_provider, reply);
-               storage_provider_add_extra_data(provider->storage_provider, reply);
-
-               /* TODO: another adaptor */
-       } else if (0 == strcmp(operation, PLUGIN_DISCONNECT_URI)) {
-               app_control_create(&reply);
-               ret = provider->disconnect();
-
-               if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
-                       SAL_ERR("connect() Fail (%d)", ret);
-                       app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_FAILURE);
-                       goto catch;
-               }
-
-               app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_SUCCESS);
-       } else {
-               reply = auth_provider_message(provider->auth_provider, operation, app_control);
-               TRY_IF(NULL != reply, "auth_plugin_client_message() Finded");
-
-               reply = storage_provider_message(provider->storage_provider, operation, app_control);
-               TRY_IF(NULL != reply, "storage_plugin_client_message() Finded");
-       }
-
-catch:
-       app_control_reply_to_launch_request(reply, app_control, APP_CONTROL_RESULT_SUCCEEDED);
-       app_control_destroy(reply);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
diff --git a/client/sal_service_provider.h b/client/sal_service_provider.h
deleted file mode 100644 (file)
index bbdad47..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Service Plugin Client
- *
- * Copyright (c) 2014 - 2015 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_PLUGIN_CLIENT_H__
-#define __SERVICE_PLUGIN_CLIENT_H__
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include <app.h>
-
-#include "sal_auth_provider.h"
-#include "sal_storage_provider.h"
-
-#define PLUGIN_RESULT_KEY              "result"
-#define PLUGIN_RESULT_VALUE_SUCCESS    "success"
-#define PLUGIN_RESULT_VALUE_FAILURE    "failure"
-
-#define PLUGIN_KEY_AUTH                        "auth_plugin"
-#define PLUGIN_KEY_STORAGE             "storage_plugin"
-#define PLUGIN_VALUE_TRUE              "true"
-#define PLUGIN_VALUE_FALSE             "false"
-
-#define PLUGIN_CONNECT_URI             "connect"
-#define PLUGIN_DISCONNECT_URI          "disconnect"
-
-/**
- * @brief Describes infromation about Plugin Handle
- */
-typedef struct _service_provider_s
-{
-       service_adaptor_error_e (*connect)(void);
-       service_adaptor_error_e (*disconnect)(void);
-
-       auth_provider_h auth_provider;
-       storage_provider_h storage_provider;
-
-       char *uri;
-       char *name;
-} service_provider_s;
-typedef struct _service_provider_s *service_provider_h;
-
-int service_provider_create(service_provider_h *provider);
-int service_provider_destroy(service_provider_h provider);
-int service_provider_set_auth_provider(service_provider_h provider, auth_provider_h auth_provider);
-int service_provider_unset_auth_provider(service_provider_h provider);
-int service_provider_set_storage_provider(service_provider_h provider, storage_provider_h storage_provider);
-int service_provider_unset_storage_provider(service_provider_h provider);
-int service_provider_message(service_provider_h provider, app_control_h app_control, void *user_data);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SERVICE_PLUGIN_CLIENT_H__ */
diff --git a/client/sal_service_storage.c b/client/sal_service_storage.c
deleted file mode 100644 (file)
index a8e1126..0000000
+++ /dev/null
@@ -1,629 +0,0 @@
-/*
- * Service Storage
- *
- * Copyright (c) 2014 - 2015 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 <string.h>
-#include <glib.h>
-
-#include <app.h>
-
-#include "service_adaptor_errors.h"
-#include "service_adaptor_internal.h"
-#include "sal_service_adaptor.h"
-#include "sal_service_adaptor_internal.h"
-#include "sal_service_task.h"
-#include "sal_service_task_internal.h"
-#include "sal_service_storage.h"
-#include "sal_service_storage_internal.h"
-#include "sal_ipc_client_storage.h"
-
-/******************************************************************************
- * Global variables and defines
- ******************************************************************************/
-
-/******************************************************************************
- * Private interface
- ******************************************************************************/
-
-/******************************************************************************
- * Private interface definition
- ******************************************************************************/
-
-int service_storage_cloud_start(service_storage_cloud_file_h file)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == file->plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
-       char *uri = NULL;
-
-       ret = service_plugin_get_uri(file->plugin, &uri);
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "service_plugin_get_uri() Failed(%d)", ret);
-
-       service_storage_cloud_file_h cloud_file = NULL;
-       ret = ipc_service_storage_cloud_file(uri, file, &cloud_file);
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "ipc_service_storage_cloud_file() Failed(%d)", ret);
-
-       RETV_IF(NULL == file->callback, SERVICE_ADAPTOR_ERROR_NONE);
-
-       file->callback(SERVICE_ADAPTOR_ERROR_NONE, cloud_file,  file->user_data);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-int service_storage_cloud_stop(service_storage_cloud_file_h file)
-{
-       SAL_FN_CALL;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-/******************************************************************************
- * Public interface definition
- ******************************************************************************/
-
-API int service_storage_cloud_file_create(service_plugin_h plugin, service_storage_cloud_file_h *file)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) g_malloc0(sizeof(service_storage_cloud_file_s));
-       cloud_file->plugin = plugin;
-       cloud_file->callback = NULL;
-       cloud_file->is_dir = false;
-       cloud_file->size = 0;
-       cloud_file->dir_path = NULL;
-       cloud_file->local_path = NULL;
-       cloud_file->cloud_path = NULL;
-       cloud_file->operation = NULL;
-       cloud_file->files = NULL;
-
-       *file = cloud_file;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_cloud_file_clone(service_storage_cloud_file_h src_file, service_storage_cloud_file_h *dst_file)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == src_file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == dst_file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) g_malloc0(sizeof(service_storage_cloud_file_s));
-       cloud_file->plugin = src_file->plugin;
-       cloud_file->callback = src_file->callback;
-       cloud_file->is_dir = src_file->is_dir;
-       cloud_file->size = src_file->size;
-       cloud_file->dir_path = g_strdup(src_file->dir_path);
-       cloud_file->local_path = g_strdup(src_file->local_path);
-       cloud_file->cloud_path = g_strdup(src_file->cloud_path);
-       cloud_file->operation = g_strdup(src_file->operation);
-       /* TODO: g_list_copy_deep() */
-       if (NULL != src_file->files) {
-               cloud_file->files = g_list_copy(src_file->files);
-       } else {
-               cloud_file->files = NULL;
-       }
-
-       *dst_file = cloud_file;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_cloud_file_destroy(service_storage_cloud_file_h file)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       SAL_FREE(file->dir_path);
-       SAL_FREE(file->local_path);
-       SAL_FREE(file->cloud_path);
-       SAL_FREE(file->operation);
-       SAL_FREE(file);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_cloud_file_set_callback(service_storage_cloud_file_h file, service_storage_cloud_file_cb callback, void *user_data)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       file->callback = callback;
-       file->user_data = user_data;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_cloud_file_unset_callback(service_storage_cloud_file_h file)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       file->callback = NULL;
-       file->user_data = NULL;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_cloud_file_set_cloud_path(service_storage_cloud_file_h file, const char *cloud_path)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cloud_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       file->cloud_path = strdup(cloud_path);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_cloud_file_get_cloud_path(service_storage_cloud_file_h file, char **cloud_path)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == cloud_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       *cloud_path = g_strdup(file->cloud_path);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_cloud_file_set_local_path(service_storage_cloud_file_h file, const char *local_path)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == local_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       file->local_path = strdup(local_path);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_cloud_file_get_local_path(service_storage_cloud_file_h file, char **local_path)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == local_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       *local_path = g_strdup(file->local_path);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_cloud_file_set_size(service_storage_cloud_file_h file, unsigned long long size)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       file->size = size;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_cloud_file_get_size(service_storage_cloud_file_h file, unsigned long long *size)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == size, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       *size = file->size;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_cloud_file_set_operation(service_storage_cloud_file_h file, const char *operation)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == operation, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       file->operation = strdup(operation);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_cloud_file_get_operation(service_storage_cloud_file_h file, char **operation)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == operation, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       *operation = g_strdup(file->operation);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_cloud_file_is_directory(service_storage_cloud_file_h file, bool *is_dir)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == is_dir, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       *is_dir = file->is_dir;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_cloud_file_foreach_file(service_storage_cloud_file_h file, service_storage_cloud_file_cb callback, void *user_data)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       RETV_IF(false == file->is_dir, SERVICE_ADAPTOR_ERROR_NO_DATA);
-
-       RETV_IF(0 == g_list_length(file->files), SERVICE_ADAPTOR_ERROR_NO_DATA);
-
-       for (GList *list = g_list_first(file->files); list != NULL; list = list->next) {
-               service_storage_cloud_file_h file_data = (service_storage_cloud_file_h) list->data;
-
-               bool ret = callback(SERVICE_ADAPTOR_ERROR_NONE, file_data, user_data);
-               RETV_IF(false == ret, SERVICE_ADAPTOR_ERROR_NONE);
-       }
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_cloud_file_create_task(service_storage_cloud_file_h file, service_task_h *task)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_task_h service_task = (service_task_h) g_malloc0(sizeof(service_task_s));
-       service_task->cloud_file = file;
-
-       *task = service_task;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_cloud_file_destroy_task(service_task_h task)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       SAL_FREE(task);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-/******************************************************************************
- * 2.4 Public interface definition
- ******************************************************************************/
-
-API int service_storage_get_file_list(service_plugin_h plugin,
-                                               const char *dir_path,
-                                               service_storage_file_list_cb callback,
-                                               void *user_data)
-{
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == dir_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_storage_cloud_file_h file = NULL;
-       service_storage_cloud_file_create(plugin, &file);
-       service_storage_cloud_file_set_operation(file, SERVICE_STORAGE_CLOUD_GET_FILE_LIST_URI);
-       service_storage_cloud_file_set_cloud_path(file, dir_path);
-
-       service_task_h service_task = (service_task_h) g_malloc0(sizeof(service_task_s));
-       service_task->cloud_file = file;
-       service_task->storage_file_list_callback = callback;
-       service_task->user_data = user_data;
-
-       return service_task_start(service_task);
-}
-
-API int service_storage_remove(service_plugin_h plugin,
-                                               const char *remove_path,
-                                               service_storage_result_cb callback,
-                                               void *user_data)
-{
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == remove_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_storage_cloud_file_h file = NULL;
-       service_storage_cloud_file_create(plugin, &file);
-       service_storage_cloud_file_set_operation(file, SERVICE_STORAGE_CLOUD_REMOVE_FILE_URI);
-       service_storage_cloud_file_set_cloud_path(file, remove_path);
-
-       service_task_h service_task = (service_task_h) g_malloc0(sizeof(service_task_s));
-       service_task->cloud_file = file;
-       service_task->storage_result_callback = callback;
-       service_task->user_data = user_data;
-
-       return service_task_start(service_task);
-}
-
-API int service_storage_create_upload_task(service_plugin_h plugin,
-                                               const char *file_path,
-                                               const char *upload_path,
-                                               service_storage_task_h *task)
-{
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == file_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == upload_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_storage_cloud_file_h file = NULL;
-       service_storage_cloud_file_create(plugin, &file);
-       service_storage_cloud_file_set_operation(file, SERVICE_STORAGE_CLOUD_UPLOAD_FILE_URI);
-       service_storage_cloud_file_set_cloud_path(file, upload_path);
-       service_storage_cloud_file_set_local_path(file, file_path);
-
-       service_task_h service_task = (service_task_h) g_malloc0(sizeof(service_task_s));
-       service_task->cloud_file = file;
-
-       *task = (service_storage_task_h) service_task;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_create_download_task(service_plugin_h plugin,
-                                               const char *storage_path,
-                                               const char *download_path,
-                                               service_storage_task_h *task)
-{
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == storage_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == download_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_storage_cloud_file_h file = NULL;
-       service_storage_cloud_file_create(plugin, &file);
-       service_storage_cloud_file_set_operation(file, SERVICE_STORAGE_CLOUD_DOWNLOAD_FILE_URI);
-       service_storage_cloud_file_set_cloud_path(file, storage_path);
-       service_storage_cloud_file_set_local_path(file, download_path);
-
-       service_task_h service_task = (service_task_h) g_malloc0(sizeof(service_task_s));
-       service_task->cloud_file = file;
-
-       *task = (service_storage_task_h) service_task;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API 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)
-{
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == storage_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == download_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(0 > thumbnail_size, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_storage_cloud_file_h file = NULL;
-       service_storage_cloud_file_create(plugin, &file);
-       service_storage_cloud_file_set_operation(file, SERVICE_STORAGE_CLOUD_DOWNLOAD_FILE_THUMBNAIL_URI);
-       service_storage_cloud_file_set_cloud_path(file, storage_path);
-       service_storage_cloud_file_set_local_path(file, download_path);
-
-       service_task_h service_task = (service_task_h) g_malloc0(sizeof(service_task_s));
-       service_task->cloud_file = file;
-
-       *task = (service_storage_task_h) service_task;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_destroy_task(service_storage_task_h task)
-{
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       return service_storage_cloud_file_destroy_task((service_task_h) task);
-}
-
-API int service_storage_start_task(service_storage_task_h task)
-{
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       return service_task_start((service_task_h) task);
-}
-
-API int service_storage_cancel_task(service_storage_task_h task)
-{
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-/*     return service_task_stop((service_task_h) task); */
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_set_task_progress_cb(service_storage_task_h task,
-                                               service_storage_task_progress_cb callback,
-                                               void *user_data)
-{
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_task_h service_task = (service_task_h) task;
-       service_task->storage_progress_callback = callback;
-       service_task->user_data = user_data;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_unset_task_progress_cb(service_storage_task_h task)
-{
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_task_h service_task = (service_task_h) task;
-       service_task->storage_progress_callback = NULL;
-       service_task->user_data = NULL;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_set_task_state_changed_cb(service_storage_task_h task,
-                                               service_storage_task_state_cb callback,
-                                               void *user_data)
-{
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_task_h service_task = (service_task_h) task;
-       service_task->storage_state_callback = callback;
-       service_task->user_data = user_data;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_unset_task_state_changed_cb(service_storage_task_h task)
-{
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_task_h service_task = (service_task_h) task;
-       service_task->storage_state_callback = NULL;
-       service_task->user_data = NULL;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_file_list_clone(service_storage_file_list_h src_list,
-                                               service_storage_file_list_h *dst_list)
-{
-       RETV_IF(NULL == src_list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == dst_list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       *dst_list = src_list;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_file_list_destroy(service_storage_file_list_h list)
-{
-       RETV_IF(NULL == list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_file_list_get_length(service_storage_file_list_h list,
-                                               int *length)
-{
-       RETV_IF(NULL == list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == length, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_storage_cloud_file_h file = (service_storage_cloud_file_h) list;
-       *length = file->size;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_file_list_foreach_file(service_storage_file_list_h list,
-                                               service_storage_file_cb callback,
-                                               void *user_data)
-{
-       RETV_IF(NULL == list, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_storage_cloud_file_h file = (service_storage_cloud_file_h) list;
-       callback((service_storage_file_h) file, user_data);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_file_clone(service_storage_file_h src_file,
-                                               service_storage_file_h *dst_file)
-{
-       RETV_IF(NULL == src_file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == dst_file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       *dst_file = src_file;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_file_destroy(service_storage_file_h file)
-{
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_file_is_dir(service_storage_file_h file,
-                                               bool *is_dir)
-{
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == is_dir, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) file;
-       *is_dir = cloud_file->is_dir;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_file_get_size(service_storage_file_h file,
-                                               unsigned long long *size)
-{
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == size, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) file;
-       *size = cloud_file->size;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_file_get_logical_path(service_storage_file_h file,
-                                               char **path)
-{
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) file;
-       *path = strdup(cloud_file->cloud_path);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_storage_file_get_physical_path(service_storage_file_h file,
-                                               char **path)
-{
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) file;
-       *path = strdup(cloud_file->cloud_path);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
diff --git a/client/sal_service_storage.h b/client/sal_service_storage.h
deleted file mode 100644 (file)
index 16e973a..0000000
+++ /dev/null
@@ -1,652 +0,0 @@
-/*
- * Service Storage
- *
- * Copyright (c) 2014 - 2015 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_STORAGE_H__
-#define __SERVICE_STORAGE_H__
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include "sal_service_adaptor.h"
-#include "sal_service_task.h"
-
-#define SERVICE_STORAGE_CLOUD_REMOVE_FILE_URI   "http://tizen.org/service-adaptor/storage/cloud/remove_file"
-#define SERVICE_STORAGE_CLOUD_DOWNLOAD_FILE_URI "http://tizen.org/service-adaptor/storage/cloud/download_file"
-#define SERVICE_STORAGE_CLOUD_UPLOAD_FILE_URI   "http://tizen.org/service-adaptor/storage/cloud/upload_file"
-#define SERVICE_STORAGE_CLOUD_DOWNLOAD_FILE_THUMBNAIL_URI       "http://tizen.org/service-adaptor/storage/cloud/download_file_thumbnail"
-#define SERVICE_STORAGE_CLOUD_GET_FILE_LIST_URI "http://tizen.org/service-adaptor/storage/cloud/get_file_list"
-
-typedef struct _service_storage_cloud_file_s *service_storage_cloud_file_h;
-
-typedef bool (*service_storage_cloud_file_cb)(int result, service_storage_cloud_file_h file, void *user_data);
-
-/*==================================================================================================
-                                         FUNCTION PROTOTYPES
-==================================================================================================*/
-
-int service_storage_cloud_file_create(service_plugin_h plugin, service_storage_cloud_file_h *file);
-int service_storage_cloud_file_clone(service_storage_cloud_file_h src_file, service_storage_cloud_file_h *dst_file);
-
-int service_storage_cloud_file_destroy(service_storage_cloud_file_h file);
-int service_storage_cloud_file_set_callback(service_storage_cloud_file_h file, service_storage_cloud_file_cb callback, void *user_data);
-int service_storage_cloud_file_unset_callback(service_storage_cloud_file_h file);
-int service_storage_cloud_file_set_cloud_path(service_storage_cloud_file_h file, const char *cloud_path);
-int service_storage_cloud_file_get_cloud_path(service_storage_cloud_file_h file, char **cloud_path);
-int service_storage_cloud_file_set_local_path(service_storage_cloud_file_h file, const char *local_path);
-int service_storage_cloud_file_get_local_path(service_storage_cloud_file_h file, char **local_path);
-int service_storage_cloud_file_set_size(service_storage_cloud_file_h file, unsigned long long size);
-int service_storage_cloud_file_get_size(service_storage_cloud_file_h file, unsigned long long *size);
-int service_storage_cloud_file_set_operation(service_storage_cloud_file_h file, const char *operation);
-int service_storage_cloud_file_get_operation(service_storage_cloud_file_h file, char **operation);
-int service_storage_cloud_file_is_directory(service_storage_cloud_file_h file, bool *is_dir);
-int service_storage_cloud_file_foreach_file(service_storage_cloud_file_h file, service_storage_cloud_file_cb callback, void *user_data);
-int service_storage_cloud_file_create_task(service_storage_cloud_file_h file, service_task_h *task);
-int service_storage_cloud_file_destroy_task(service_task_h task);
-
-// 2.4 
-
-/**
-* @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
-
-#endif /* __SERVICE_STORAGE_H__ */
diff --git a/client/sal_service_storage_internal.h b/client/sal_service_storage_internal.h
deleted file mode 100644 (file)
index 490a636..0000000
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Service Storage Internal
- *
- * Copyright (c) 2014 - 2015 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_STORAGE_INTERNAL_H__
-#define __SERVICE_STORAGE_INTERNAL_H__
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include <glib.h>
-
-#include "sal_service_adaptor.h"
-#include "sal_service_storage.h"
-
-typedef struct _service_storage_cloud_file_s
-{
-       service_plugin_h plugin;
-       service_storage_cloud_file_cb callback;
-       void *user_data;
-
-       bool is_dir;
-       char *dir_path;
-       char *local_path;
-       char *cloud_path;
-       unsigned long long size;
-       char *operation;
-
-       GList *files;
-} service_storage_cloud_file_s;
-
-typedef struct _service_storage_task_s
-{
-        char *service_handle_name;
-}service_storage_task_t;
-
-/*==================================================================================================
-                                         FUNCTION PROTOTYPES
-==================================================================================================*/
-
-int service_storage_cloud_start(service_storage_cloud_file_h file);
-int service_storage_cloud_stop(service_storage_cloud_file_h file);
-
-/*==================================================================================================
-                                       2.4 FUNCTION PROTOTYPES
-==================================================================================================*/
-
-/**
- * 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;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SERVICE_STORAGE_INTERNAL_H__ */
diff --git a/client/sal_service_task.c b/client/sal_service_task.c
deleted file mode 100644 (file)
index c3960fd..0000000
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Service Task
- *
- * Copyright (c) 2014 - 2015 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 <string.h>
-#include <glib.h>
-#include <gio/gio.h>
-
-#include <app.h>
-
-#include "service_adaptor_errors.h"
-#include "service_adaptor_internal.h"
-#include "sal_service_adaptor.h"
-#include "sal_service_adaptor_internal.h"
-#include "sal_service_task.h"
-#include "sal_service_task_internal.h"
-#include "sal_service_auth_internal.h"
-#include "sal_service_storage_internal.h"
-
-/******************************************************************************
- * Global variables and defines
- ******************************************************************************/
-
-GList *service_tasks = NULL;
-GThreadPool *thread_pool = NULL;
-
-/******************************************************************************
- * Private interface
- ******************************************************************************/
-
-/******************************************************************************
- * Private interface definition
- ******************************************************************************/
-
-static void _service_task_async_func(gpointer data, gpointer user_data)
-{
-       service_task_h task = (service_task_h) data;
-
-       if (NULL != task->oauth1) {
-               service_auth_oauth1_start(task->oauth1);
-       } else if (NULL != task->cloud_file) {
-               service_storage_cloud_start(task->cloud_file);
-       } else {
-               return;
-       }
-
-       /* TODO: in IPC */
-       if (NULL != task->storage_progress_callback) {
-               task->storage_progress_callback(100, 100, task->user_data);
-       }
-       if (NULL != task->storage_state_callback) {
-               task->storage_state_callback(SERVICE_STORAGE_TASK_COMPLETED, task->user_data);
-       }
-       if (NULL != task->storage_result_callback) {
-               task->storage_result_callback(SERVICE_ADAPTOR_ERROR_NONE, task->user_data);
-       }
-       if (NULL != task->storage_file_list_callback) {
-               service_storage_cloud_file_h file_list = (service_storage_cloud_file_h) g_malloc0(sizeof(service_storage_cloud_file_s));
-               file_list->is_dir = false;
-               file_list->cloud_path = "/sample.txt";
-               file_list->size = 1;
-               task->storage_file_list_callback(SERVICE_ADAPTOR_ERROR_NONE, (service_storage_cloud_file_h) file_list, task->user_data);
-       }
-}
-
-/******************************************************************************
- * Public interface definition
- ******************************************************************************/
-
-API int service_task_connect()
-{
-       SAL_FN_CALL;
-
-       thread_pool = g_thread_pool_new(_service_task_async_func, NULL, -1, FALSE, NULL);
-       RETVM_IF(NULL == thread_pool, SERVICE_ADAPTOR_ERROR_SYSTEM, "g_thread_pool_new() Failed");
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_task_disconnect()
-{
-       SAL_FN_CALL;
-
-       /* TODO: stop current stated task */
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_task_start(service_task_h task)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       service_tasks = g_list_append(service_tasks, task);
-
-       g_thread_pool_push(thread_pool, (gpointer) task, NULL);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_task_stop(service_task_h task)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       if (NULL != task->cloud_file) {
-               service_storage_cloud_stop(task->cloud_file);
-       } else {
-               return SERVICE_ADAPTOR_ERROR_NO_DATA;
-       }
-
-       service_tasks = g_list_remove(service_tasks, task);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_task_set_uri(service_task_h task, const char *uri)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       task->uri = strdup(uri);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_task_get_uri(service_task_h task, char **uri)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       *uri = g_strdup(task->uri);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_task_set_progress_callback(service_task_h task, service_task_progress_cb callback, void *user_data)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       task->progress_callback = callback;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_task_unset_progress_callback(service_task_h task)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       task->progress_callback = NULL;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int service_task_set_state_changed_callback(service_task_h task, service_task_state_changed_cb callback, void *user_data)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == callback, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       task->state_callback = callback;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API int  service_task_unset_state_changed_callback(service_task_h task)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       task->state_callback = NULL;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
diff --git a/client/sal_service_task.h b/client/sal_service_task.h
deleted file mode 100644 (file)
index 6f038e2..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Service Task
- *
- * Copyright (c) 2014 - 2015 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_TASK_H__
-#define __SERVICE_TASK_H__
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-typedef enum _service_task_state_e
-{
-       SERVICE_TASK_IN_PROGRESS        = 1,
-       SERVICE_TASK_COMPLETED          = 2,
-       SERVICE_TASK_CANCELED           = 3,
-       SERVICE_TASK_FAILED             = 4
-} service_task_state_e;
-
-typedef struct _service_task_s *service_task_h;
-
-typedef void (*service_task_progress_cb)(service_task_h task, unsigned long long progress, unsigned long long total, void *user_data);
-
-typedef void (*service_task_state_changed_cb)(service_task_h task, service_task_state_e state, void *user_data);
-
-/*==================================================================================================
-                                         FUNCTION PROTOTYPES
-==================================================================================================*/
-
-int service_task_start(service_task_h task);
-int service_task_stop(service_task_h task);
-int service_task_set_uri(service_task_h task, const char *uri);
-int service_task_get_uri(service_task_h task, char **uri);
-int service_task_set_progress_callback(service_task_h task, service_task_progress_cb callback, void *user_data);
-int service_task_unset_progress_callback(service_task_h task);
-int service_task_set_state_changed_callback(service_task_h task, service_task_state_changed_cb callback, void *user_data);
-int service_task_unset_state_changed_callback(service_task_h task);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SERVICE_TASK_H__ */
diff --git a/client/sal_service_task_internal.h b/client/sal_service_task_internal.h
deleted file mode 100644 (file)
index 981fbef..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Service Task Internal
- *
- * Copyright (c) 2014 - 2015 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_TASK_INTERNAL_H__
-#define __SERVICE_TASK_INTERNAL_H__
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include "sal_service_task.h"
-#include "sal_service_auth.h"
-#include "sal_service_storage.h"
-
-typedef struct _service_task_s
-{
-       char *uri;
-       service_task_progress_cb progress_callback;
-       service_task_state_changed_cb state_callback;
-
-       service_auth_oauth1_h oauth1;
-       service_storage_cloud_file_h cloud_file;
-
-       // temp
-       service_storage_task_progress_cb storage_progress_callback;
-       service_storage_task_state_cb storage_state_callback;
-       service_storage_result_cb storage_result_callback;
-       service_storage_file_list_cb storage_file_list_callback;
-       void *user_data;
-} service_task_s;
-
-/*==================================================================================================
-                                         FUNCTION PROTOTYPES
-==================================================================================================*/
-
-int service_task_connect();
-int service_task_disconnect();
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SERVICE_TASK_INTERNAL_H__ */
diff --git a/client/sal_storage_provider.c b/client/sal_storage_provider.c
deleted file mode 100644 (file)
index 60f56d8..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Storage Plugin Client
- *
- * Copyright (c) 2014 - 2015 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 <string.h>
-#include <glib.h>
-
-#include <app.h>
-
-#include "service_adaptor_errors.h"
-#include "service_adaptor_internal.h"
-#include "cloud_service.h"
-#include "sal_service_provider.h"
-#include "sal_storage_provider.h"
-
-API int storage_provider_create(storage_provider_h *provider)
-{
-       SAL_FN_CALL;
-
-       storage_provider_h storage_provider = (storage_provider_h) g_malloc0(sizeof(storage_provider_s));
-
-       storage_provider->cloud_remove_file = NULL;
-
-       *provider = storage_provider;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
-API app_control_h storage_provider_message(storage_provider_h provider, const char *operation, void *user_data)
-{
-       SAL_FN_CALL;
-
-       app_control_h reply = NULL;
-
-       RETV_IF(NULL == provider, reply);
-
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
-
-       if (0 == strcmp(operation, CLOUD_REMOVE_FILE_URI)) {
-               app_control_create(&reply);
-
-               char *cloud_path = NULL;
-               app_control_get_extra_data((app_control_h) user_data, CLOUD_CLOUD_PATH_KEY, &cloud_path);
-
-               ret = provider->cloud_remove_file(cloud_path);
-
-               if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
-                       SAL_ERR("cloud_remove_file() Fail (%d)", ret);
-                       app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_FAILURE);
-                       return reply;
-               }
-
-               app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_SUCCESS);
-       }
-
-       return reply;
-}
-
-API int storage_provider_add_extra_data(storage_provider_h provider, app_control_h reply)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == provider, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == reply, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       app_control_add_extra_data(reply, PLUGIN_KEY_STORAGE, PLUGIN_VALUE_TRUE);
-
-       if (NULL != provider->cloud_remove_file) {
-               app_control_add_extra_data(reply, CLOUD_REMOVE_FILE_URI, PLUGIN_VALUE_TRUE);
-       }
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
diff --git a/client/sal_storage_provider.h b/client/sal_storage_provider.h
deleted file mode 100644 (file)
index bf61e06..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Storage Plugin Client
- *
- * Copyright (c) 2014 - 2015 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 __STORAGE_PLUGIN_CLIENT_H__
-#define __STORAGE_PLUGIN_CLIENT_H__
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include <app.h>
-
-#include "service_adaptor_errors.h"
-
-#define CLOUD_LOCAL_PATH_KEY   "local_path"
-#define CLOUD_CLOUD_PATH_KEY   "cloud_path"
-
-/**
- * @brief Describes infromation about Cloud Service
- * @key name, ...
- */
-#define CLOUD_REMOVE_FILE_URI   "http://tizen.org/service-adaptor/storage/cloud/remove_file"
-#define CLOUD_DOWNLOAD_FILE_URI "http://tizen.org/service-adaptor/storage/cloud/download_file"
-#define CLOUD_UPLOAD_FILE_URI   "http://tizen.org/service-adaptor/storage/cloud/upload_file"
-#define CLOUD_DOWNLOAD_FILE_THUMBNAIL_URI       "http://tizen.org/service-adaptor/storage/cloud/download_file_thumbnail"
-#define CLOUD_GET_FILE_LIST_URI "http://tizen.org/service-adaptor/storage/cloud/get_file_list"
-
-/**
- * @brief Describes infromation about Storage Plugin Handle
- */
-typedef struct _storage_provider_s
-{
-       // Cloud
-       service_adaptor_error_e (*cloud_remove_file)(const char *cloud_path);
-       service_adaptor_error_e (*cloud_download_file)(const char *cloud_path, const char *local_path);
-       service_adaptor_error_e (*cloud_upload_file)(const char *local_path, const char *cloud_path);
-       service_adaptor_error_e (*cloud_download_file_thumbnail)(const char *cloud_path, const char *local_path);
-
-       // Posix
-} storage_provider_s;
-typedef struct _storage_provider_s *storage_provider_h;
-
-int storage_provider_create(storage_provider_h *provider);
-app_control_h storage_provider_message(storage_provider_h provider, const char *operation, void *user_data);
-int storage_provider_add_extra_data(storage_provider_h provider, app_control_h reply);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __STORAGE_PLUGIN_CLIENT_H__ */
index 5a074c8f4a4c0d372e214fffa7bef79cf420c5b6..312d0b4a5fa707e9c154c2425fb23fb9f9b87752 100644 (file)
@@ -22,12 +22,12 @@ ADD_DEFINITIONS("-DSERVICE_ADAPTOR_DEBUGGING")
 
 SET(COMMON-BASE-LIB "sal-common-base")
 SET(COMMON-BASE-SRCS
-        ${CMAKE_SOURCE_DIR}/common/sal_ipc.c
+        ${CMAKE_SOURCE_DIR}/common/base/sal_ipc.c
 )
 
 INCLUDE_DIRECTORIES(
         ${CMAKE_SOURCE_DIR}/include
-        ${CMAKE_SOURCE_DIR}/common
+        ${CMAKE_SOURCE_DIR}/common/base
 )
 
 INCLUDE(FindPkgConfig)
@@ -51,6 +51,14 @@ SET_TARGET_PROPERTIES(${COMMON-BASE-LIB} PROPERTIES VERSION ${VERSION})
 
 INSTALL(TARGETS ${COMMON-BASE-LIB} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
 
+SET(SAL-COMMON_BASE-HEADERS
+        ${CMAKE_SOURCE_DIR}/common/base/sal_log.h
+        ${CMAKE_SOURCE_DIR}/common/base/sal_ipc.h
+        ${CMAKE_SOURCE_DIR}/common/base/sal_types.h
+)
+
+INSTALL(FILES ${SAL-COMMON-BASE-HEADERS} DESTINATION include/service-adaptor)
+
 ##########################################################
 # Define common server
 ##########################################################
@@ -58,20 +66,20 @@ INSTALL(TARGETS ${COMMON-BASE-LIB} DESTINATION ${LIB_INSTALL_DIR} COMPONENT Runt
 SET(COMMON-SERVER-LIB "sal-common-server")
 SET(COMMON-SERVER-SRCS
         ${CMAKE_SOURCE_DIR}/common/ipc-server/sal_ipc_server.c
-       ${CMAKE_SOURCE_DIR}/common/ipc-server/sal_ipc_server_core.c
-       ${CMAKE_SOURCE_DIR}/common/ipc-server/sal_ipc_server_auth.c
-       ${CMAKE_SOURCE_DIR}/common/ipc-server/sal_ipc_server_storage.c
+        ${CMAKE_SOURCE_DIR}/common/ipc-server/sal_ipc_server_core.c
+        ${CMAKE_SOURCE_DIR}/common/ipc-server/sal_ipc_server_auth.c
+        ${CMAKE_SOURCE_DIR}/common/ipc-server/sal_ipc_server_storage.c
 )
 
 INCLUDE_DIRECTORIES(
-        ${CMAKE_SOURCE_DIR}/include
-        ${CMAKE_SOURCE_DIR}/adaptor/auth-adaptor
-        ${CMAKE_SOURCE_DIR}/adaptor/contact-adaptor
-        ${CMAKE_SOURCE_DIR}/adaptor/storage-adaptor
-        ${CMAKE_SOURCE_DIR}/adaptor/resource-adaptor
-        ${CMAKE_SOURCE_DIR}/common
+#        ${CMAKE_SOURCE_DIR}/include
+#        ${CMAKE_SOURCE_DIR}/adaptor/auth-adaptor
+#        ${CMAKE_SOURCE_DIR}/adaptor/contact-adaptor
+#        ${CMAKE_SOURCE_DIR}/adaptor/storage-adaptor
+#        ${CMAKE_SOURCE_DIR}/adaptor/resource-adaptor
+#        ${CMAKE_SOURCE_DIR}/common/base
         ${CMAKE_SOURCE_DIR}/common/ipc-server
-        ${CMAKE_SOURCE_DIR}/server
+#        ${CMAKE_SOURCE_DIR}/server
 )
 
 INCLUDE(FindPkgConfig)
@@ -89,7 +97,7 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -std=gnu99")
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
 
 ADD_LIBRARY(${COMMON-SERVER-LIB} SHARED ${COMMON-SERVER-SRCS})
-TARGET_LINK_LIBRARIES(${COMMON-SERVER-LIB} ${common_server_pkgs_LDFLAGS} sal-common-base auth-adaptor storage-adaptor)
+TARGET_LINK_LIBRARIES(${COMMON-SERVER-LIB} ${common_server_pkgs_LDFLAGS} sal-common-base)
 SET_TARGET_PROPERTIES(${COMMON-SERVER-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
 SET_TARGET_PROPERTIES(${COMMON-SERVER-LIB} PROPERTIES VERSION ${VERSION})
 
@@ -108,10 +116,10 @@ SET(COMMON-CLIENT-SRCS
 )
 
 INCLUDE_DIRECTORIES(
-        ${CMAKE_SOURCE_DIR}/include
-        ${CMAKE_SOURCE_DIR}/common
+#        ${CMAKE_SOURCE_DIR}/include
+#        ${CMAKE_SOURCE_DIR}/common/base
         ${CMAKE_SOURCE_DIR}/common/ipc-client
-        ${CMAKE_SOURCE_DIR}/client
+#        ${CMAKE_SOURCE_DIR}/client
 )
 
 INCLUDE(FindPkgConfig)
@@ -134,3 +142,69 @@ SET_TARGET_PROPERTIES(${COMMON-CLIENT-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR}
 SET_TARGET_PROPERTIES(${COMMON-CLIENT-LIB} PROPERTIES VERSION ${VERSION})
 
 INSTALL(TARGETS ${COMMON-CLIENT-LIB} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+
+##########################################################
+# Define common provider
+##########################################################
+
+SET(COMMON-PROVIDER-LIB "sal-common-provider")
+SET(COMMON-PROVIDER-SRCS
+        ${CMAKE_SOURCE_DIR}/common/ipc-provider/sal_ipc_provider.c
+        ${CMAKE_SOURCE_DIR}/common/ipc-provider/sal_ipc_provider_base.c
+        ${CMAKE_SOURCE_DIR}/common/ipc-provider/sal_ipc_provider_storage.c
+)
+
+INCLUDE_DIRECTORIES(
+        ${CMAKE_SOURCE_DIR}/common/ipc-provider
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(common_provider_pkgs REQUIRED dlog glib-2.0 gio-2.0 capi-appfw-application)
+
+FOREACH(flag ${common_provider_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(${COMMON-PROVIDER-LIB} SHARED ${COMMON-PROVIDER-SRCS})
+TARGET_LINK_LIBRARIES(${COMMON-PROVIDER-LIB} ${common_provider_pkgs_LDFLAGS} sal-common-base)
+SET_TARGET_PROPERTIES(${COMMON-PROVIDER-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${COMMON-PROVIDER-LIB} PROPERTIES VERSION ${VERSION})
+
+INSTALL(TARGETS ${COMMON-PROVIDER-LIB} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+
+##########################################################
+# Define common adaptor
+##########################################################
+
+SET(COMMON-ADAPTOR-LIB "sal-common-adaptor")
+SET(COMMON-ADAPTOR-SRCS
+        ${CMAKE_SOURCE_DIR}/common/ipc-adaptor/sal_ipc_adaptor.c
+)
+
+INCLUDE_DIRECTORIES(
+        ${CMAKE_SOURCE_DIR}/common/ipc-adaptor
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(common_adaptor_pkgs REQUIRED dlog glib-2.0 gio-2.0 capi-appfw-application)
+
+FOREACH(flag ${common_adaptor_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(${COMMON-ADAPTOR-LIB} SHARED ${COMMON-ADAPTOR-SRCS})
+TARGET_LINK_LIBRARIES(${COMMON-ADAPTOR-LIB} ${common_adaptor_pkgs_LDFLAGS} sal-common-base)
+SET_TARGET_PROPERTIES(${COMMON-ADAPTOR-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${COMMON-ADAPTOR-LIB} PROPERTIES VERSION ${VERSION})
+
+INSTALL(TARGETS ${COMMON-ADAPTOR-LIB} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+
+
diff --git a/common/base/sal_ipc.c b/common/base/sal_ipc.c
new file mode 100644 (file)
index 0000000..8c9729d
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Service Adaptor IPC
+ *
+ * Copyright (c) 2014 - 2015 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 <gio/gio.h>
+
+#include "sal_types.h"
+#include "sal_log.h"
+#include "sal_ipc.h"
+
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+API char *ipc_insure_g_variant_dup_string(GVariant *string)
+{
+       char *ret = g_variant_dup_string(string, NULL);
+
+       if (0 == strcmp(ret, "")) {
+               SAL_FREE(ret);
+       }
+
+       return ret;
+}
+
+API void ipc_insure_g_variant_builder_add_array_string(GVariantBuilder *builder, const char *str)
+{
+       if (NULL == str) {
+               g_variant_builder_add(builder, "(s)", "");
+       } else {
+               g_variant_builder_add(builder, "(s)", str);
+       }
+}
+
+API char *ipc_make_return_type(const char *type)
+{
+       return g_strdup_printf("(%sis)", SAL_IPC_STR(type));
+}
+
+API void ipc_create_error_msg(int code, char **ipc_msg)
+{
+       switch (code) {
+       case SAL_ERROR_NONE:
+               *ipc_msg = NULL;
+               break;
+       case SAL_ERROR_INTERNAL:
+               *ipc_msg = strdup("SAL_ERROR_INTERNAL");
+               break;
+       default:
+               *ipc_msg = strdup("SAL_ERROR_UNKNOWN");
+               break;
+       }
+}
+
+API void ipc_create_variant_info(GVariant *parameters, int size, GVariant ***var_info)
+{
+       for (size_t i = 0; i < size; i++) {
+               *(var_info +i) = (GVariant **) g_variant_get_child_value(parameters, i);
+       }
+}
+
+API void ipc_destroy_variant_info(GVariant **var_info, int size)
+{
+       for (size_t i = 0; i < size; i++) {
+               g_variant_unref(var_info[i]);
+       }
+}
+
+API void ipc_free_reply_data(ipc_reply_data_h reply)
+{
+       SAL_FN_CALL;
+
+       RET_IF(NULL == reply);
+
+       SAL_FREE(reply->type);
+       SAL_FREE(reply);
+
+       SAL_FN_END;
+}
diff --git a/common/base/sal_ipc.h b/common/base/sal_ipc.h
new file mode 100644 (file)
index 0000000..b8d4606
--- /dev/null
@@ -0,0 +1,322 @@
+/*
+ * Service Adaptor IPC
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yongjin Kim <youth.kim@samsung.com>
+ *          Jinhyeong Ahn <jinh.ahn@samsung.com>
+ *          Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_CONVERGENCE_SAL_IPC_H__
+#define __TIZEN_CONVERGENCE_SAL_IPC_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <glib.h>
+#include <gio/gio.h>
+
+/**
+ * ##################################
+ * # { client - server IPC protocol
+ */
+
+/**
+ * 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"
+
+/**
+ * struct for dbus.
+ */
+#define service_adaptor_connect_req_s_type_length 2
+#define service_adaptor_connect_req_s_type \
+       "(" \
+       "i" /* int pid */ \
+       "s" /* char *uri */ \
+       ")"
+
+#define service_adaptor_connect_res_s_type_length 1
+#define service_adaptor_connect_res_s_type \
+       "(" \
+       "a(s)" /* char **uri */ \
+       ")"
+
+#define service_adaptor_disconnect_s_type_length 2
+#define service_adaptor_disconnect_s_type \
+       "(" \
+       "i" /* int pid */ \
+       "s" /* char *uri */ \
+       ")"
+
+#define service_plugin_start_req_s_type_length 3
+#define service_plugin_start_req_s_type \
+       "(" \
+       "i" /* int pid */ \
+       "s" /* char *uri */ \
+       "s" /* char *plugin_uri */ \
+       ")"
+
+#define service_plugin_start_res_s_type_length 1
+#define service_plugin_start_res_s_type \
+       "(" \
+       "s" /* char *plugin_handle */ \
+       ")"
+
+#define service_plugin_stop_s_type_length 1
+#define service_plugin_stop_s_type \
+       "(" \
+       "s" /* char *plugin_handle */ \
+       ")"
+
+#define service_auth_oauth1_s_type_length 2
+#define service_auth_oauth1_s_type \
+       "(" \
+       "s" /* char *access_token */ \
+       "s" /* char *operation */ \
+       ")"
+
+#define service_auth_oauth1_req_s_type_length 2
+#define service_auth_oauth1_req_s_type \
+       "(" \
+       "s" /* char *uri */ \
+       service_auth_oauth1_s_type /* service_auth_oauth1_s oauth1 */ \
+       ")"
+
+#define service_auth_oauth1_res_s_type_length 1
+#define service_auth_oauth1_res_s_type \
+       "(" \
+       service_auth_oauth1_s_type /* service_auth_oauth1_s oauth1 */ \
+       ")"
+
+#define service_storage_cloud_file_s_type_length 6
+#define service_storage_cloud_file_s_type \
+       "(" \
+       "b" /* bool is_dir */ \
+       "s" /* char *dir_path */ \
+       "s" /* char *local_path */ \
+       "s" /* char *cloud_path */ \
+       "t" /* uint64 size */ \
+       "s" /* char *operation */ \
+       ")"
+
+#define service_storage_cloud_file_req_s_type_length 2
+#define service_storage_cloud_file_req_s_type \
+       "(" \
+       "s" /* char *uri */ \
+       service_storage_cloud_file_s_type /* service_storage_cloud_file_s file */ \
+       ")"
+
+#define service_storage_cloud_file_res_s_type_length 2
+#define service_storage_cloud_file_res_s_type \
+       "(" \
+       service_storage_cloud_file_s_type /* service_storage_cloud_file_s file */ \
+       "a" service_storage_cloud_file_s_type /* GList *files */  \
+       ")"
+
+/**
+ * array of structures
+ */
+#define plugin_list_type                               "a(s)"
+#define file_list_type                                 "a" service_storage_cloud_file_s_type
+
+/**
+ * append error code to the type
+ */
+#define RETURN_LENGTH                                  3
+
+/**
+ * DBus APIs
+ */
+#define DBUS_SERVICE_ADAPTOR                   "dbus_00"
+#define DBUS_SERVICE_AUTH                              "dbus_02"
+#define DBUS_SERVICE_STORAGE                   "dbus_03"
+#define DBUS_NAME_LENGTH                               7
+
+#define DBUS_SERVICE_ADAPTOR_CONNECT_METHOD            DBUS_SERVICE_ADAPTOR "_connect"
+#define DBUS_SERVICE_ADAPTOR_DISCONNECT_METHOD DBUS_SERVICE_ADAPTOR "_disconnect"
+
+#define DBUS_SERVICE_PLUGIN_START_METHOD               DBUS_SERVICE_ADAPTOR "_plugin_start"
+#define DBUS_SERVICE_PLUGIN_STOP_METHOD                        DBUS_SERVICE_ADAPTOR "_plugin_stop"
+
+#define DBUS_SERVICE_AUTH_OAUTH1_METHOD                        DBUS_SERVICE_AUTH "_service_auth_oauth1"
+
+#define DBUS_SERVICE_STORAGE_CLOUD_FILE_METHOD DBUS_SERVICE_STORAGE "_service_storage_cloud_file"
+
+#define DBUS_SERVICE_ADAPTOR_NOTIFY_SIGNAL             DBUS_SERVICE_ADAPTOR "_service_adaptor_signal_notify"
+
+/**
+ * # client - server IPC protocol End  }
+ * ##################################
+ */
+
+
+/**
+ * ##################################
+ * # { adaptor - provider IPC protocol
+ */
+
+#define SERVICE_PROVIDER_BUS_NAME_PREFIX       "serviceprovider"
+
+#define SERVICE_PROVIDER_BUS_INTERFACE         "org.tizen.serviceprovider.ineterface"
+
+#define SERVICE_PROVIDER_BASE_PREFIX           "base_"
+#define SERVICE_PROVIDER_AUTH_PREFIX           "auth_"
+#define SERVICE_PROVIDER_STORAGE_PREFIX                "stor_"
+#define SERVICE_PROVIDER_PREFIX_LEN                    5
+
+/*
+ * DBus Methods
+ */
+
+/*
+ * Provider:base - Session start callback
+**/
+#define SERVICE_PROVIDER_BASE_SESSION_START            SERVICE_PROVIDER_BASE_PREFIX "session_start"
+/* req param len */
+#define SERVICE_PROVIDER_BASE_SESSION_START_REQ_LEN 1
+/* req params */
+#define SERVICE_PROVIDER_BASE_SESSION_START_REQ        \
+       "(" \
+       "s" /* client info */\
+       ")"
+/* res param len */
+#define SERVICE_PROVIDER_BASE_SESSION_START_RES_LEN 4
+/* res params */
+#define SERVICE_PROVIDER_BASE_SESSION_START_RES        \
+       "(" \
+       "s" /* session info */\
+       "i" /* result */\
+       "i" /* error code */\
+       "s" /* error message */\
+       ")"
+
+/*
+ * Provider:base - Session stop callback
+**/
+#define SERVICE_PROVIDER_BASE_SESSION_STOP             SERVICE_PROVIDER_BASE_PREFIX "session_stop"
+/* req param len */
+#define SERVICE_PROVIDER_BASE_SESSION_STOP_REQ_LEN 1
+/* req params */
+#define SERVICE_PROVIDER_BASE_SESSION_STOP_REQ \
+       "(" \
+       "s" /* session info */\
+       ")"
+/* res param len */
+#define SERVICE_PROVIDER_BASE_SESSION_STOP_RES_LEN 3
+/* res params */
+#define SERVICE_PROVIDER_BASE_SESSION_STOP_RES \
+       "(" \
+       "i" /* result */\
+       "i" /* error code */\
+       "s" /* error message */\
+       ")"
+
+/*
+ * Provider:storage - Open callback
+**/
+#define SERVICE_PROVIDER_STORAGE_DOWNLOAD              SERVICE_PROVIDER_STORAGE_PREFIX "download"
+/* req param len */
+#define SERVICE_PROVIDER_STORAGE_DOWNLOAD_REQ_LEN      3
+/* req params */
+#define SERVICE_PROVIDER_STORAGE_DOWNLOAD_REQ \
+       "("\
+       "s" /* session uri */\
+       "s" /* local path */\
+       "s" /* cloud path */\
+       ")"
+
+/* res param len */
+#define SERVICE_PROVIDER_STORAGE_DOWNLOAD_RES_LEN 4
+/* res params */
+#define SERVICE_PROVIDER_STORAGE_DOWNLOAD_RES \
+       "(" \
+       "i" /* fd */\
+       "i" /* result */\
+       "i" /* error code */\
+       "s" /* error message */\
+       ")"
+
+/*
+ * Provider:storage - Close callback
+**/
+#define SERVICE_PROVIDER_STORAGE_CLOSE                 "close"
+/* req param len */
+#define SERVICE_PROVIDER_STORAGE_CLOSE_REQ_LEN 2
+/* req params */
+#define SERVICE_PROVIDER_STPRAGE_CLOSE_REQ \
+       "("\
+       "s" /* session info */\
+       "i" /* fd */\
+       ")"
+/* res param len */
+#define SERVICE_PROVIDER_STORAGE_CLOSE_RES_LEN 3
+/* res params */
+#define SERVICE_PROVIDER_STORAGE_CLOSE_RES \
+       "(" \
+       "i" /* result */\
+       "i" /* error code */\
+       "s" /* error message */\
+       ")"
+
+/**
+ * # adaptor - provider IPC protocol End  }
+ * ##################################
+ */
+
+
+typedef struct _ipc_reply_data_s
+{
+       GDBusMethodInvocation *invocation;
+       char *type;
+} ipc_reply_data_s;
+typedef struct _ipc_reply_data_s *ipc_reply_data_h;
+
+char *ipc_insure_g_variant_dup_string(GVariant *string);
+void ipc_insure_g_variant_builder_add_array_string(GVariantBuilder *builder, const char *str);
+char *ipc_make_return_type(const char *type);
+void ipc_create_error_msg(int code, char **ipc_msg);
+void ipc_create_variant_info(GVariant *parameters, int size, GVariant ***var_info);
+void ipc_destroy_variant_info(GVariant **var_info, int size);
+void ipc_free_reply_data(ipc_reply_data_h reply);
+
+#define SAL_IPC_RETURN_TYPE(type)   "(" type "iis)"
+#define SAL_IPC_SIMPLE_TYPE         "(iis)"
+#define SAL_IPC_SAFE_STR(str)          ((str) ? (str) : "")
+#define SAL_IPC_STR(x)                         (x==NULL)?"":x
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_CONVERGENCE_SAL_IPC_H__ */
diff --git a/common/base/sal_log.h b/common/base/sal_log.h
new file mode 100644 (file)
index 0000000..d152d5f
--- /dev/null
@@ -0,0 +1,172 @@
+/*
+ * Service Adaptor
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yongjin Kim <youth.kim@samsung.com>
+ *          Jinhyeong Ahn <jinh.ahn@samsung.com>
+ *          Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_CONVERGENCE_SAL_LOG_H__
+#define __TIZEN_CONVERGENCE_SAL_LOG_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#ifdef API
+#undef API
+#endif
+#define API __attribute__ ((visibility("default")))
+
+#define LOG_TAG "SERVICE-ADAPTOR"
+#include <dlog.h>
+#define DLOG(prio, fmt, arg...) \
+        do { SLOG(prio, LOG_TAG, fmt, ##arg); } while (0)
+
+
+#if defined(_SERVICE_ADAPTOR_IPC_SERVER)
+#define IPC_ROLE "[SERVER]"
+#elif defined(_SERVICE_ADAPTOR_IPC_CLIENT)
+#define IPC_ROLE "[CLIENT]"
+#else
+#define IPC_ROLE "[LIB]"
+#endif
+
+/**
+ * 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 */
+
+#define INFO(fmt, arg...) SLOGI(FONT_COLOR_YELLOW""IPC_ROLE" "fmt""FONT_COLOR_RESET, ##arg)
+#define ERR(fmt, arg...) SLOGE(FONT_COLOR_RED""IPC_ROLE" "fmt""FONT_COLOR_RESET, ##arg)
+#define DBG(fmt, arg...) SLOGD(IPC_ROLE" "fmt, ##arg)
+#define WARN(fmt, arg...) SLOGD(IPC_ROLE" "fmt, ##arg)
+#define VERBOSE(fmt, arg...) SLOGV(IPC_ROLE" "fmt, ##arg)
+
+#ifdef SERVICE_ADAPTOR_DEBUGGING
+
+        #define SAL_FN_CALL DBG(">>>>>>>> called")
+        #define SAL_FN_END DBG("<<<<<<<< ended")
+
+        #define SAL_DBG(fmt, arg...) DBG(fmt, ##arg)
+        #define SAL_WARN(fmt, arg...) WARN(fmt, ##arg)
+        #define SAL_ERR(fmt, arg...) ERR(fmt, ##arg)
+        #define SAL_INFO(fmt, arg...) INFO(fmt, ##arg)
+        #define SAL_VERBOSE(fmt, arg...) VERBOSE(fmt, ##arg)
+
+#else /* SERVICE_ADAPTOR_DEBUGGING */
+        #define SAL_FN_CALL
+        #define SAL_FN_END
+
+        #define SAL_DBG(fmt, arg...)
+        #define SAL_WARN(fmt, arg...)
+        #define SAL_ERR(fmt, arg...) ERR(fmt, ##arg)
+        #define SAL_INFO(fmt, arg...)
+        #define SAL_VERBOSE(fmt, arg...)
+
+#endif /* SERVICE_ADAPTOR_DEBUGGING */
+
+#define WARN_IF(expr, fmt, arg...) do { \
+        if (expr) { \
+                SAL_WARN(fmt, ##arg); \
+        } \
+} while (0)
+#define RET_IF(expr) do { \
+        if (expr) { \
+                SAL_ERR("(%s)", #expr); \
+                return; \
+        } \
+} while (0)
+#define RETV_IF(expr, val) do { \
+        if (expr) { \
+                SAL_ERR("(%s)", #expr); \
+                return (val); \
+        } \
+} while (0)
+#define RETM_IF(expr, fmt, arg...) do { \
+        if (expr) { \
+                SAL_ERR(fmt, ##arg); \
+                return; \
+        } \
+} while (0)
+#define RETVM_IF(expr, val, fmt, arg...) do { \
+        if (expr) { \
+                SAL_ERR(fmt, ##arg); \
+                return (val); \
+        } \
+} while (0)
+#define TRY_IF(expr) do { \
+        if (expr) { \
+                SAL_INFO("Throw (%s)", #expr); \
+                goto catch; \
+        } \
+} while (0)
+#define TRYM_IF(expr, fmt, arg...) do { \
+        if (expr) { \
+                SAL_ERR(fmt, ##arg); \
+                goto catch; \
+        } \
+} while (0)
+#define TRYVM_IF(expr, val, fmt, arg...) do { \
+        if (expr) { \
+                SAL_ERR(fmt, ##arg); \
+                val; \
+               goto catch; \
+        } \
+} while (0)
+
+#define SAL_STRDUP(dst, ptr) do { \
+       if (ptr) \
+               dst = strdup(ptr); \
+       else \
+               dst = NULL; \
+} while(0)
+
+#define SAL_FREE(ptr) do { \
+       if (ptr) \
+               free(ptr); \
+       ptr = NULL; \
+} while(0)
+
+#define SAL_STR_REPLACE(__string, __old_char, __new_char)      \
+               for (char *ch = (__string); *ch; ch++) { \
+                       if ((__old_char) == *ch) \
+                               *ch = (__new_char); \
+               }
+
+#define SAL_FOREACH_GLIST(iterator, list)      for (GList *iterator = g_list_first(list); iterator; iterator = g_list_next(iterator))
+
+#define SAL_SIZE_OF_TAB(arr)   (int)(sizeof(arr) / sizeof(arr[0]))
+
+#endif /* __TIZEN_CONVERGENCE_SAL_LOG_H__ */
diff --git a/common/base/sal_types.h b/common/base/sal_types.h
new file mode 100644 (file)
index 0000000..039b43e
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Service Adaptor
+ *
+ * Copyright (c) 2014 - 2015 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_CONVERGENCE_SERVICE_ADAPTOR_TYPES_INTERNAL_H__
+#define __TIZEN_CONVERGENCE_SERVICE_ADAPTOR_TYPES_INTERNAL_H__
+
+#include <stdint.h>
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+/*
+ * @brief It just be used internally
+*/
+
+typedef enum
+{
+       SAL_ERROR_NONE                      = TIZEN_ERROR_NONE,                     /**< Success */
+       SAL_ERROR_NOT_SUPPORTED             = TIZEN_ERROR_NOT_SUPPORTED,            /**< Service plugin does not support API */
+       SAL_ERROR_INVALID_PARAMETER         = TIZEN_ERROR_INVALID_PARAMETER,        /**< The parameter is invalid */
+       SAL_ERROR_TIMED_OUT                 = TIZEN_ERROR_TIMED_OUT,                /**< API time out */
+       SAL_ERROR_NO_DATA                   = TIZEN_ERROR_NO_DATA,                  /**< There is no data available */
+       SAL_ERROR_PERMISSION_DENIED         = TIZEN_ERROR_PERMISSION_DENIED,        /**< Permission denied */
+       SAL_ERROR_UNKNOWN                   = TIZEN_ERROR_UNKNOWN,                  /**< Unknown error */
+       SAL_ERROR_IPC_UNSTABLE              = TIZEN_ERROR_SERVICE_ADAPTOR | 0x01,   /**< IPC Connection unstabled */
+       SAL_ERROR_PLUGIN_FAILED             = TIZEN_ERROR_SERVICE_ADAPTOR | 0x02,   /**< The error occured from Plugin, See detail from service_adaptor_get_last_result() and Plugin SPEC */
+       SAL_ERROR_NOT_AUTHORIZED            = TIZEN_ERROR_SERVICE_ADAPTOR | 0x03,   /**< Need Autholization */
+       SAL_ERROR_INVALID_STATE             = TIZEN_ERROR_SERVICE_ADAPTOR | 0x04,   /**< The handle state is invalid for processing API */
+       SAL_ERROR_SYSTEM                    = TIZEN_ERROR_SERVICE_ADAPTOR | 0xf1,   /**< Internal system module error */
+       SAL_ERROR_INTERNAL                  = TIZEN_ERROR_SERVICE_ADAPTOR | 0xf2,   /**< Implementation Error */
+} sal_error_e;
+
+
+typedef enum
+{
+       SAL_SERVICE_BASE                = 0x0,
+       SAL_SERVICE_STORAGE             = (0x1 << 1),
+} sal_service_type_e;
+
+
+typedef void *user_data_t;
+
+#define INT_TO_USER_DATA(x)            ((user_data_t)(intptr_t)x)
+
+#define USER_DATA_TO_INT(x)            ((int)(intptr_t)x)
+
+#define USER_DATA_TYPE(name)   struct __sal_user_data_ ## name ## _s
+
+#define USER_DATA_VAL(name)            __g_data_ ## name
+
+#define USER_DATA_DESTROY_FUNC g_free
+
+/*
+ * @breif      Type definition on global area
+ */
+#define USER_DATA_TYPEDEF(type_name, val_count) USER_DATA_TYPE(type_name) { user_data_t values[val_count]; }
+
+/*
+ * @breif      Define valuable (pointer, not allocated)
+ * @pre                USER_DATA_TYPEDEF()
+ */
+#define USER_DATA_DEFINE(type_name, val_name)  USER_DATA_TYPE(type_name) *USER_DATA_VAL(val_name)
+
+/*
+ * @breif      Allocate memory
+ * @pre                USER_DATA_TYPEDEF()
+ */
+#define USER_DATA_CREATE(type_name)            (USER_DATA_TYPE(type_name) *)g_malloc0(sizeof(USER_DATA_TYPE(type_name)))
+
+/*
+ * @breif      Release memory of valuable
+ * @pre                USER_DATA_CREATE()
+ */
+#define USER_DATA_DESTROY(val_name)                    do { USER_DATA_DESTROY_FUNC(USER_DATA_VAL(val_name)); USER_DATA_VAL(val_name) = NULL; } while (0)
+
+/*
+ * @breif      Refer to user data slot
+ * @pre                USER_DATA_CREATE()
+ */
+#define USER_DATA_ELEMENT(val_name, index)     USER_DATA_VAL(val_name)->values[index]
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_CONVERGENCE_SERVICE_ADAPTOR_TYPES_INTERNAL_H__ */
diff --git a/common/ipc-adaptor/sal_ipc_adaptor.c b/common/ipc-adaptor/sal_ipc_adaptor.c
new file mode 100644 (file)
index 0000000..887e61b
--- /dev/null
@@ -0,0 +1,468 @@
+/*
+ * Service Adaptor IPC Client
+ *
+ * Copyright (c) 2014 - 2015 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 <gio/gio.h>
+#include <app_control.h>
+
+#include "sal_types.h"
+#include "sal_log.h"
+#include "sal_ipc.h"
+
+#include "sal_ipc_adaptor.h"
+
+/******************************************************************************
+ * Global variables and defines
+******************************************************************************/
+
+/*
+#define ERROR_MESSAGE_MAX_LENGH                2048
+
+static __thread int last_error_code = 0;
+
+static __thread char last_error_message[ERROR_MESSAGE_MAX_LENGH] = {0, };
+*/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+static int __launch_app(const char *app_id,
+               const char *operation);
+
+static void __proxy_created_cb(GObject *source_object,
+               GAsyncResult *res,
+               gpointer user_data);
+
+static void __on_name_appeared(GDBusConnection *connection,
+               const gchar *name,
+               const gchar *name_owner,
+               gpointer user_data);
+
+static void __on_name_vanished(GDBusConnection *connection,
+               const gchar *name,
+               gpointer user_data);
+
+static void __on_signal(GDBusProxy *proxy,
+               gchar *sender_name,
+               gchar *signal_name,
+               GVariant *parameters,
+               gpointer user_data);
+
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+static int __launch_app(const char *app_id, const char *operation)
+{
+       SAL_FN_CALL;
+       int ret = SAL_ERROR_NONE;
+
+       app_control_h app_control = NULL;
+       ret = app_control_create(&app_control);
+       TRYM_IF(ret, "app_control create failed : %d", ret);
+
+       ret = app_control_set_app_id(app_control, app_id);
+       TRYM_IF(ret, "app_control set app_id failed : %d", ret);
+
+       ret = app_control_set_operation(app_control, operation);
+       TRYM_IF(ret, "app_control set operation failed : %d", ret);
+
+       ret = app_control_send_launch_request(app_control, NULL, NULL);
+       TRYM_IF(ret, "app_control send launch request failed : %d", ret);
+
+       app_control_destroy(app_control);
+       app_control = NULL;
+
+       SAL_FN_END;
+       return ret;
+
+catch:
+       if (app_control)
+               app_control_destroy(app_control);
+
+       return SAL_ERROR_INTERNAL;
+}
+
+/* 0: adaptor handle, 1: callback, 2: user_data */
+USER_DATA_TYPEDEF(ipc_adaptor_data_t, 3);
+
+static void __proxy_created_cb(GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+       SAL_FN_CALL;
+       GError *error = NULL;
+       GDBusProxy *_proxy = g_dbus_proxy_new_for_bus_finish(res, &error);
+       if (error) {
+               SAL_ERR("Getting proxy error : %d, %s", error->code, error->message);
+               g_error_free(error);
+               error = NULL;
+       } else if (_proxy) {
+               SAL_INFO("Getting proxy success");
+               USER_DATA_DEFINE(ipc_adaptor_data_t, _callback_data) = (USER_DATA_TYPE(ipc_adaptor_data_t) *)user_data;
+               sal_ipc_adaptor_h _adaptor = (sal_ipc_adaptor_h)USER_DATA_ELEMENT(_callback_data, 0);
+               _adaptor->proxy = _proxy;
+
+               g_signal_connect(_proxy,
+                       "g-signal",
+                       G_CALLBACK(__on_signal),
+                       user_data);
+       }
+       SAL_FN_END;
+}
+
+static void __on_name_appeared(GDBusConnection *connection,
+               const gchar *name,
+               const gchar *name_owner,
+               gpointer user_data)
+{
+       SAL_FN_CALL;
+
+       SAL_INFO("Provider Appeared : name<%s>, name_owner<%s>", name, name_owner);
+       USER_DATA_DEFINE(ipc_adaptor_data_t, _callback_data) = (USER_DATA_TYPE(ipc_adaptor_data_t) *)user_data;
+       sal_ipc_adaptor_h adaptor = (sal_ipc_adaptor_h)USER_DATA_ELEMENT(_callback_data, 0);
+       sal_ipc_adaptor_launch_cb callback = (sal_ipc_adaptor_launch_cb)USER_DATA_ELEMENT(_callback_data, 1);
+       void *data = (void *)USER_DATA_ELEMENT(_callback_data, 2);
+
+       adaptor->connected = true;
+       callback(adaptor, true, data);
+
+       SAL_FN_END;
+}
+
+static void __on_name_vanished(GDBusConnection *connection,
+               const gchar *name,
+               gpointer user_data)
+{
+       SAL_FN_CALL;
+
+       SAL_INFO("Provider Vanished : name<%s>", name);
+       USER_DATA_DEFINE(ipc_adaptor_data_t, _callback_data) = (USER_DATA_TYPE(ipc_adaptor_data_t) *)user_data;
+       sal_ipc_adaptor_h adaptor = (sal_ipc_adaptor_h)USER_DATA_ELEMENT(_callback_data, 0);
+       sal_ipc_adaptor_launch_cb callback = (sal_ipc_adaptor_launch_cb)USER_DATA_ELEMENT(_callback_data, 1);
+       void *data = (void *)USER_DATA_ELEMENT(_callback_data, 2);
+
+       adaptor->connected = false;
+       callback(adaptor, false, data);
+
+       SAL_FN_END;
+}
+
+static void __on_signal(GDBusProxy *proxy,
+               gchar *sender_name,
+               gchar *signal_name,
+               GVariant *parameters,
+               gpointer user_data)
+{
+       SAL_FN_CALL;
+
+       SAL_FN_END;
+}
+
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+API int sal_ipc_adaptor_create(const char *plugin_uri, GMainContext *context, sal_ipc_adaptor_h *adaptor)
+{
+       SAL_FN_CALL;
+
+#if !GLIB_CHECK_VERSION(2, 35, 0)
+       g_type_init();
+#endif
+
+       int ret = SAL_ERROR_NONE;
+       RETV_IF(NULL == plugin_uri, SAL_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == adaptor, SAL_ERROR_INVALID_PARAMETER);
+
+       sal_ipc_adaptor_h _adaptor = NULL;
+       char *_uri = NULL;
+       GMainContext *_ctx = NULL;
+
+       _adaptor = g_malloc0(sizeof(sal_ipc_adaptor_s));
+//     TRYVM_IF(NULL == _adaptor, ret = SAL_ERROR_OUT_OF_MEMORY, "Out of Memory");
+       TRYVM_IF(NULL == _adaptor, ret = SAL_ERROR_SYSTEM, "Out of Memory");
+
+       _uri = strdup(plugin_uri);
+//     TRYVM_IF(NULL == _uri, ret = SAL_ERROR_OUT_OF_MEMORY, "Out of Memory");
+       TRYVM_IF(NULL == _uri, ret = SAL_ERROR_SYSTEM, "Out of Memory");
+
+       if (context)
+               _ctx = context;
+       else if (NULL == (_ctx = g_main_context_get_thread_default()))
+               _ctx = g_main_context_default();
+
+       _adaptor->plugin_uri = _uri;
+       _adaptor->ipc_context = _ctx;
+       _adaptor->watcher_id = 0U;
+       _adaptor->proxy = NULL;
+       _adaptor->connected = false;
+
+       *adaptor = _adaptor;
+
+       SAL_FN_END;
+       return ret;
+
+catch:
+       free(_uri);
+       free(_adaptor);
+
+       return ret;
+}
+
+API int sal_ipc_adaptor_destroy(sal_ipc_adaptor_h adaptor)
+{
+       SAL_FN_CALL;
+       int ret = SAL_ERROR_NONE;
+
+       RETV_IF(NULL == adaptor, SAL_ERROR_INVALID_PARAMETER);
+
+       free(adaptor->plugin_uri);
+       if (adaptor->proxy)
+               g_object_unref(adaptor->proxy);
+       if (adaptor->watcher_id)
+               g_bus_unwatch_name(adaptor->watcher_id);
+
+       adaptor->plugin_uri = NULL;
+       adaptor->ipc_context = NULL;
+       adaptor->watcher_id = 0U;
+       adaptor->proxy = NULL;
+       adaptor->connected = false;
+       g_free(adaptor);
+
+       SAL_FN_END;
+       return ret;
+}
+
+API int sal_ipc_adaptor_channel_open_with_provider(sal_ipc_adaptor_h adaptor, sal_ipc_adaptor_launch_cb callback, void *user_data)
+{
+       SAL_FN_CALL;
+       int ret = SAL_ERROR_NONE;
+
+       RETV_IF(NULL == adaptor, SAL_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == callback, SAL_ERROR_INVALID_PARAMETER);
+
+       USER_DATA_DEFINE(ipc_adaptor_data_t, _callback_data) = NULL;
+       USER_DATA_VAL(_callback_data) = USER_DATA_CREATE(ipc_adaptor_data_t);
+//     RETV_IF(NULL == USER_DATA_VAL(_callback_data), SAL_ERROR_OUT_OF_MEMORY);
+       RETV_IF(NULL == USER_DATA_VAL(_callback_data), SAL_ERROR_SYSTEM);
+
+       USER_DATA_ELEMENT(_callback_data, 0) = (user_data_t)adaptor;
+       USER_DATA_ELEMENT(_callback_data, 1) = (user_data_t)callback;
+       USER_DATA_ELEMENT(_callback_data, 2) = (user_data_t)user_data;
+
+       const char *_operation = "http://tizen.org/appcontrol/operation/service-provider/channel";
+       ret = __launch_app(adaptor->plugin_uri, _operation);
+       RETV_IF(ret, SAL_ERROR_INTERNAL);
+
+       char *bus_name = NULL;
+       char *obj_path = NULL;
+
+       bus_name = g_strdup_printf("%s.%s", SERVICE_PROVIDER_BUS_NAME_PREFIX, adaptor->plugin_uri);
+       TRYM_IF(NULL == bus_name, "Out of memory");
+
+       obj_path = g_strdup(bus_name);
+       TRYM_IF(NULL == obj_path, "Out of memory");
+       SAL_STR_REPLACE(obj_path, '.', '/');
+
+       g_dbus_proxy_new_for_bus(G_BUS_TYPE_SESSION,
+                       G_DBUS_PROXY_FLAGS_NONE,
+                       (GDBusInterfaceInfo *)NULL,
+                       bus_name,
+                       obj_path,
+                       SERVICE_PROVIDER_BUS_INTERFACE,
+                       (GCancellable *)NULL,
+                       (GAsyncReadyCallback)__proxy_created_cb,
+                       (gpointer)USER_DATA_VAL(_callback_data));
+
+       guint watcher_id = g_bus_watch_name(G_BUS_TYPE_SESSION,
+                       bus_name,
+                       G_BUS_NAME_WATCHER_FLAGS_NONE,
+                       __on_name_appeared,
+                       __on_name_vanished,
+                       (gpointer)USER_DATA_VAL(_callback_data),
+                       (GDestroyNotify)USER_DATA_DESTROY_FUNC);
+
+       adaptor->watcher_id = watcher_id;
+
+       SAL_FN_END;
+       return ret;
+
+catch:
+       USER_DATA_DESTROY(_callback_data);
+       g_free(bus_name);
+       free(obj_path);
+
+       SAL_FN_END;
+       return ret;
+}
+
+API int sal_ipc_adaptor_channel_close_with_provider(sal_ipc_adaptor_h adaptor)
+{
+       SAL_FN_CALL;
+       int ret = SAL_ERROR_NONE;
+
+       RETV_IF(NULL == adaptor, SAL_ERROR_INVALID_PARAMETER);
+
+       if (adaptor->watcher_id)
+               g_bus_unwatch_name(adaptor->watcher_id);
+       adaptor->watcher_id = 0U;
+
+       if (adaptor->proxy)
+               g_object_unref(adaptor->proxy);
+       adaptor->proxy = NULL;
+
+       adaptor->connected = false;
+
+       SAL_FN_END;
+       return ret;
+}
+
+/*
+
+API void sal_ipc_client_init_last_error(void)
+{
+       last_error_code = 0;
+       last_error_message[0] = '\0';
+}
+
+API void sal_ipc_client_set_last_error(int error, const char *message)
+{
+       SAL_ERR("<thread-safe> set last error : [%d][%s]", error, message);
+
+       last_error_code = error;
+       if (!message)
+               last_error_message[0] = '\0';
+       else
+               snprintf(last_error_message, ERROR_MESSAGE_MAX_LENGH, "%s", message);
+}
+
+API int sal_ipc_client_get_last_error(void)
+{
+       return last_error_code;
+}
+
+API char *sal_ipc_client_get_last_message(void)
+{
+       return last_error_message;
+}
+
+API int sal_ipc_client_get_interface(GDBusProxy **interface)
+{
+       SAL_FN_CALL;
+
+       *interface = interface_proxy;
+
+       return SAL_ERROR_NONE;
+}
+
+API int sal_ipc_client_call_request(const char *request_method, GVariant *request_data, const char *reply_type, GVariant **reply_info)
+{
+       GError *error = NULL;
+       GVariant *reply = NULL;
+       int ret = SAL_ERROR_NONE;
+
+       GDBusProxy *interface_proxy = NULL;
+       ret = sal_ipc_client_get_interface(&interface_proxy);
+       RETV_IF(SAL_ERROR_NONE != ret, SAL_ERROR_INTERNAL);
+
+       reply = g_dbus_proxy_call_sync(interface_proxy,
+                       request_method,
+                       request_data,
+                       G_DBUS_CALL_FLAGS_NONE,
+                       G_MAXINT,
+                       NULL,
+                       &error);
+
+       RETVM_IF(NULL == reply, SAL_ERROR_INTERNAL, "IPC Request Failed: %s", error->message);
+       RETV_IF(false == g_variant_is_of_type(reply, (GVariantType *) reply_type), SAL_ERROR_INTERNAL);
+
+       *reply_info = reply;
+
+       return SAL_ERROR_NONE;
+}
+
+API int sal_ipc_client_get_simple_response(GVariant *response)
+{
+    int reply_size = RETURN_LENGTH;
+
+    GVariant *reply_info[reply_size];
+    ipc_create_variant_info(response, reply_size, (GVariant ***) &reply_info);
+
+    int idx = 0;
+    int ret = g_variant_get_int32(reply_info[idx++]);
+
+       SAL_INFO("<<- ipc remote ret : %d ->>", ret);
+       switch (ret) {
+       case SAL_ERROR_NONE:
+               SAL_DBG("case : SAL_ERROR_NONE");
+               break;
+       case SAL_ERROR_PLUGIN_FAILED:
+               SAL_DBG("case : SAL_ERROR_PLUGIN_FAILED");
+       int ipc_ecode = g_variant_get_int32(reply_info[idx++]);
+               char *ipc_msg = ipc_insure_g_variant_dup_string(reply_info[idx++]);
+
+               sal_ipc_client_set_last_error(ipc_ecode, ipc_msg);
+               SAL_FREE(ipc_msg);
+               break;
+       default:
+               SAL_DBG("case : default");
+               break;
+       }
+
+       ipc_destroy_variant_info(reply_info, reply_size);
+
+       return ret;
+}
+
+API int sal_ipc_client_get_data_response(GVariant *response, GVariant **data)
+{
+    int reply_size = RETURN_LENGTH + 1;
+
+    GVariant *reply_info[reply_size];
+    ipc_create_variant_info(response, reply_size, (GVariant ***) &reply_info);
+
+    int idx = 1;
+    int ret = g_variant_get_int32(reply_info[idx++]);
+
+       SAL_INFO("<<- ipc remote ret : %d ->>", ret);
+       switch (ret) {
+       case SAL_ERROR_NONE:
+               SAL_DBG("case : SAL_ERROR_NONE");
+               *data = g_variant_ref(reply_info[0]);
+               break;
+       case SAL_ERROR_PLUGIN_FAILED:
+               SAL_DBG("case : SAL_ERROR_PLUGIN_FAILED");
+       int ipc_ecode = g_variant_get_int32(reply_info[idx++]);
+               char *ipc_msg = ipc_insure_g_variant_dup_string(reply_info[idx++]);
+
+               sal_ipc_client_set_last_error(ipc_ecode, ipc_msg);
+               SAL_FREE(ipc_msg);
+               break;
+       default:
+               SAL_DBG("case : default");
+               break;
+       }
+
+       ipc_destroy_variant_info(reply_info, reply_size);
+
+       return ret;
+}
+*/
diff --git a/common/ipc-adaptor/sal_ipc_adaptor.h b/common/ipc-adaptor/sal_ipc_adaptor.h
new file mode 100644 (file)
index 0000000..27562eb
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Service Adaptor Client IPC
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yongjin Kim <youth.kim@samsung.com>
+ *          Jinhyeong Ahn <jinh.ahn@samsung.com>
+ *          Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_CONVERGENCE_SAL_IPC_ADAPTOR_H__
+#define __TIZEN_CONVERGENCE_SAL_IPC_ADAPTOR_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "sal_ipc_adaptor_types.h"
+
+typedef void (*sal_ipc_adaptor_launch_cb)(sal_ipc_adaptor_h adaptor, bool is_alived, void *user_data);
+
+API int sal_ipc_adaptor_create(const char *plugin_uri, GMainContext *context, sal_ipc_adaptor_h *adaptor);
+
+API int sal_ipc_adaptor_destroy(sal_ipc_adaptor_h adaptor);
+
+API int sal_ipc_adaptor_channel_open_with_provider(sal_ipc_adaptor_h adaptor, sal_ipc_adaptor_launch_cb callback, void *user_data);
+
+API int sal_ipc_adaptor_channel_close_with_provider(sal_ipc_adaptor_h adaptor);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_CONVERGENCE_SAL_IPC_ADAPTOR_H__ */
+
diff --git a/common/ipc-adaptor/sal_ipc_adaptor_types.h b/common/ipc-adaptor/sal_ipc_adaptor_types.h
new file mode 100644 (file)
index 0000000..8cd419e
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Service Adaptor Client IPC
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yongjin Kim <youth.kim@samsung.com>
+ *          Jinhyeong Ahn <jinh.ahn@samsung.com>
+ *          Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_CONVERGENCE_SAL_IPC_ADAPTOR_TYPES_H__
+#define __TIZEN_CONVERGENCE_SAL_IPC_ADAPTOR_TYPES_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <glib.h>
+#include <gio/gio.h>
+
+typedef struct _sal_ipc_adaptor_s
+{
+       char *plugin_uri;
+       GMainContext    *ipc_context;
+       guint                   watcher_id;
+       GDBusProxy              *proxy;
+       bool                    connected;
+} sal_ipc_adaptor_s;
+typedef sal_ipc_adaptor_s *sal_ipc_adaptor_h;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_CONVERGENCE_SAL_IPC_ADAPTOR_TYPES_H__ */
+
diff --git a/common/ipc-adaptor/sal_ipc_client_auth.c b/common/ipc-adaptor/sal_ipc_client_auth.c
new file mode 100644 (file)
index 0000000..796c070
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Service Adaptor IPC Client
+ *
+ * Copyright (c) 2014 - 2015 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 <gio/gio.h>
+
+#include "sal_types.h"
+#include "sal_log.h"
+#include "sal_ipc.h"
+#include "sal_ipc_client.h"
+#include "sal_ipc_client_auth.h"
+
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+
diff --git a/common/ipc-adaptor/sal_ipc_client_auth.h b/common/ipc-adaptor/sal_ipc_client_auth.h
new file mode 100644 (file)
index 0000000..d75e204
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Service Adaptor Client Auth IPC
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yongjin Kim <youth.kim@samsung.com>
+ *          Jinhyeong Ahn <jinh.ahn@samsung.com>
+ *          Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_CONVERGENCE_SAL_IPC_CLIENT_AUTH_H__
+#define __TIZEN_CONVERGENCE_SAL_IPC_CLIENT_AUTH_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/*
+#include "sal_service_auth.h"
+
+int ipc_service_auth_oauth1(const char *uri, service_auth_oauth1_h req_oauth1, service_auth_oauth1_h *res_oauth1);
+*/
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_CONVERGENCE_SAL_IPC_CLIENT_AUTH_H__ */
+
diff --git a/common/ipc-adaptor/sal_ipc_client_core.c b/common/ipc-adaptor/sal_ipc_client_core.c
new file mode 100644 (file)
index 0000000..55f2961
--- /dev/null
@@ -0,0 +1,211 @@
+/*
+ * Service Adaptor IPC Client
+ *
+ * Copyright (c) 2014 - 2015 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 <gio/gio.h>
+
+#include "sal_types.h"
+#include "sal_log.h"
+#include "sal_ipc.h"
+#include "sal_ipc_client.h"
+#include "sal_ipc_client_core.h"
+
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/*
+ * @param[in]  response        Gvariant response
+ * @param[out] list            plugin list
+ */
+static void __get_connect_res(GVariant *response, GList **list);
+
+/*
+ * @param[in]  response                Gvariant response
+ * @param[out] plugin_handle   identifier of plugin handle
+ */
+static void __get_plugin_start_res(GVariant *response, char **plugin_handle);
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+static void __get_connect_res(GVariant *response, GList **list)
+{
+       SAL_FN_CALL;
+
+       GVariantIter *plugin_iter = NULL;
+       plugin_iter  = g_variant_iter_new(response);
+       GList *_plugin_list = NULL;
+
+       char *_plugin_uri = NULL;
+       while (g_variant_iter_loop(plugin_iter, "(s)", &_plugin_uri)) {
+
+               SAL_DBG("<iter> plugin_uri : %s", _plugin_uri);
+               if (_plugin_uri && ('\0' != _plugin_uri))
+                       _plugin_list = g_list_append(_plugin_list, (void *)_plugin_uri);
+               else
+                       free(_plugin_uri);
+               _plugin_uri = NULL;
+       }
+
+       g_variant_iter_free(plugin_iter);
+       plugin_iter = NULL;
+
+/*
+       if (0 == g_list_length(_plugin_list)) {
+               ret = SAL_ERROR_NO_DATA;
+       }
+*/
+
+       *list = _plugin_list;
+
+       SAL_FN_END;
+}
+
+static void __get_plugin_start_res(GVariant *response, char **plugin_handle)
+{
+       SAL_FN_CALL;
+       char *_str = NULL;
+       g_variant_get(response, service_plugin_start_res_s_type, &_str);
+       if (_str && ('\0' == _str[0]))
+               SAL_FREE(_str);
+
+       *plugin_handle = _str;
+       SAL_FN_END;
+}
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+API int ipc_service_adaptor_connect(int pid, const char *uri, GList **plugins)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == uri, SAL_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == plugins, SAL_ERROR_INVALID_PARAMETER);
+
+       int ret = SAL_ERROR_NONE;
+
+       /* Call dbus request */
+       char *request_method = DBUS_SERVICE_ADAPTOR_CONNECT_METHOD;
+       GVariant *request_data = g_variant_new("(" service_adaptor_connect_req_s_type ")", pid, uri);
+
+       char *reply_type = SAL_IPC_RETURN_TYPE(service_adaptor_connect_res_s_type);
+       GVariant *reply = NULL;
+
+       ret = sal_ipc_client_call_request(request_method, request_data, reply_type, &reply);
+       RETVM_IF(SAL_ERROR_NONE != ret, ret, "ipc_client_call_request() Failed(%d)", ret);
+
+       /* Parse response */
+       GVariant *reply_data = NULL;
+       ret = sal_ipc_client_get_data_response(reply, &reply_data);
+       if (!ret && reply_data) {
+               __get_connect_res(reply_data, plugins);
+               g_variant_unref(reply_data);
+       }
+
+       SAL_FN_END;
+       return ret;
+}
+
+API int ipc_service_adaptor_disconnect(int pid, const char *uri)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == uri, SAL_ERROR_INVALID_PARAMETER);
+
+       int ret = SAL_ERROR_NONE;
+
+       /* Call dbus request */
+       char *request_method = DBUS_SERVICE_ADAPTOR_DISCONNECT_METHOD;
+       GVariant *request_data = g_variant_new("(" service_adaptor_disconnect_s_type ")", pid, uri);
+
+       char *reply_type = SAL_IPC_SIMPLE_TYPE;
+       GVariant *reply = NULL;
+
+       ret = sal_ipc_client_call_request(request_method, request_data, reply_type, &reply);
+       RETVM_IF(SAL_ERROR_NONE != ret, ret, "ipc_client_call_request() Failed(%d)", ret);
+
+       ret = sal_ipc_client_get_simple_response(reply);
+
+       SAL_FN_END;
+       return ret;
+}
+
+
+API int ipc_service_plugin_start(int pid, const char *uri, const char *plugin_uri, char **plugin_handle)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == uri, SAL_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == plugin_uri, SAL_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == plugin_handle, SAL_ERROR_INVALID_PARAMETER);
+
+       int ret = SAL_ERROR_NONE;
+
+       char *request_method = DBUS_SERVICE_PLUGIN_START_METHOD;
+       GVariant *request_data = g_variant_new("(" service_plugin_start_req_s_type ")", pid, uri, plugin_uri);
+
+       char *reply_type = SAL_IPC_RETURN_TYPE(service_plugin_start_res_s_type);
+       GVariant *reply = NULL;
+
+       ret = sal_ipc_client_call_request(request_method, request_data, reply_type, &reply);
+       RETVM_IF(SAL_ERROR_NONE != ret, ret, "ipc_client_call_request() Failed(%d)", ret);
+
+       /* Parse response */
+       GVariant *reply_data = NULL;
+       ret = sal_ipc_client_get_data_response(reply, &reply_data);
+       if (!ret && reply_data) {
+               __get_plugin_start_res(reply_data, plugin_handle);
+               g_variant_unref(reply_data);
+       }
+
+       SAL_FN_END;
+       return ret;
+}
+
+API int ipc_service_plugin_stop(const char *plugin_handle)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == plugin_handle, SAL_ERROR_INVALID_PARAMETER);
+
+       int ret = SAL_ERROR_NONE;
+
+       char *request_method = DBUS_SERVICE_PLUGIN_STOP_METHOD;
+       GVariant *request_data = g_variant_new("(" service_plugin_stop_s_type ")", plugin_handle);
+
+       char *reply_type = SAL_IPC_SIMPLE_TYPE;
+       GVariant *reply = NULL;
+
+       ret = sal_ipc_client_call_request(request_method, request_data, reply_type, &reply);
+       RETVM_IF(SAL_ERROR_NONE != ret, ret, "ipc_client_call_request() Failed(%d)", ret);
+
+       ret = sal_ipc_client_get_simple_response(reply);
+
+       SAL_FN_END;
+       return ret;
+}
+
diff --git a/common/ipc-adaptor/sal_ipc_client_core.h b/common/ipc-adaptor/sal_ipc_client_core.h
new file mode 100644 (file)
index 0000000..40a55fa
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Service Adaptor Client Core IPC
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yongjin Kim <youth.kim@samsung.com>
+ *          Jinhyeong Ahn <jinh.ahn@samsung.com>
+ *          Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_CONVERGENCE_SAL_IPC_CLIENT_CORE_H__
+#define __TIZEN_CONVERGENCE_SAL_IPC_CLIENT_CORE_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <glib.h>
+
+int ipc_service_adaptor_connect(int pid, const char *uri, GList **plugins);
+
+int ipc_service_adaptor_disconnect(int pid, const char *uri);
+
+int ipc_service_plugin_start(int pid, const char *uri, const char *plugin_uri, char **plugin_handle);
+
+int ipc_service_plugin_stop(const char *plugin_handle);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_CONVERGENCE_SAL_IPC_CLIENT_CORE_H__ */
+
diff --git a/common/ipc-adaptor/sal_ipc_client_storage.c b/common/ipc-adaptor/sal_ipc_client_storage.c
new file mode 100644 (file)
index 0000000..13eb27d
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * Service Adaptor IPC Client
+ *
+ * Copyright (c) 2014 - 2015 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 <gio/gio.h>
+
+#include "sal_types.h"
+#include "sal_log.h"
+#include "sal_ipc.h"
+#include "sal_ipc_client.h"
+#include "sal_ipc_client_storage.h"
+
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+/*
+int _get_cloud_file(GVariant *reply_info, service_storage_cloud_file_h *file)
+{
+       service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) g_malloc0(sizeof(service_storage_cloud_file_s));
+
+       int info_size = service_storage_cloud_file_res_s_type_length;
+       GVariant *info[info_size];
+       ipc_create_variant_info(reply_info, info_size, (GVariant ***) &info);
+
+       int idx = 0;
+       int file_info_size = service_storage_cloud_file_s_type_length;
+       GVariant *file_info[file_info_size];
+       ipc_create_variant_info(info[idx++], file_info_size, (GVariant ***) &file_info);
+
+       int idx2 = 0;
+       cloud_file->is_dir = g_variant_get_boolean(file_info[idx2++]);
+       cloud_file->dir_path = ipc_insure_g_variant_dup_string(file_info[idx2++]);
+       cloud_file->local_path = ipc_insure_g_variant_dup_string(file_info[idx2++]);
+       cloud_file->cloud_path = ipc_insure_g_variant_dup_string(file_info[idx2++]);
+       cloud_file->size = g_variant_get_uint64(file_info[idx2++]);
+       cloud_file->operation = ipc_insure_g_variant_dup_string(file_info[idx2++]);
+
+       ipc_destroy_variant_info(file_info, file_info_size);
+
+       gsize files_size = g_variant_n_children(info[idx]);
+
+       for (gsize i = 0; i < files_size; i++) {
+               GVariant *files_struct;
+               GVariant *files_entry_v = g_variant_get_child_value(info[idx], i);
+               files_struct = g_variant_get_child_value(files_entry_v, 0);
+
+               cloud_file->files = g_list_append(cloud_file->files, ipc_insure_g_variant_dup_string(files_struct));
+
+               g_variant_unref(files_struct);
+       }
+
+       ipc_destroy_variant_info(info, info_size);
+
+       // TODO: reorder files because it is just serialized. it makes tree structure.
+
+       *file = cloud_file;
+
+       return SAL_ERROR_NONE;
+}
+*/
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+/*
+API int ipc_service_storage_cloud_file(const char *uri, service_storage_cloud_file_h req_file, service_storage_cloud_file_h *res_file)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == uri, SAL_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == req_file, SAL_ERROR_INVALID_PARAMETER);
+
+       int ret = SAL_ERROR_NONE;
+
+       char *request_method = DBUS_SERVICE_STORAGE_CLOUD_FILE_METHOD;
+       GVariant *request_data = g_variant_new("(" service_storage_cloud_file_req_s_type ")", uri, req_file->is_dir, SAL_IPC_STR(req_file->dir_path), SAL_IPC_STR(req_file->local_path), SAL_IPC_STR(req_file->cloud_path), req_file->size, SAL_IPC_STR(req_file->operation));
+
+       char *reply_type = service_storage_cloud_file_res_s_type;
+       int reply_size = RETURN_LENGTH + 1;
+       GVariant *reply = NULL;
+
+       ret = sal_ipc_client_call_request(request_method, request_data, reply_type, &reply);
+       RETVM_IF(SAL_ERROR_NONE != ret, ret, "ipc_client_call_request() Failed(%d)", ret);
+
+       GVariant *reply_info[reply_size];
+       ipc_create_variant_info(reply, reply_size, (GVariant ***) &reply_info);
+
+       int idx = 0;
+       service_storage_cloud_file_h cloud_file = NULL;
+       _get_cloud_file(reply_info[idx++], &cloud_file);
+
+       int ipc_ret = g_variant_get_int32(reply_info[idx++]);
+       char *ipc_msg = ipc_insure_g_variant_dup_string(reply_info[idx++]);
+
+       ipc_destroy_variant_info(reply_info, reply_size);
+
+       g_variant_unref(reply);
+
+       RETVM_IF(SAL_ERROR_NONE != ipc_ret, SAL_ERROR_INTERNAL, "IPC Result Failed(%d): %s", ipc_ret, ipc_msg);
+
+       *res_file = cloud_file;
+
+       SAL_FREE(ipc_msg);
+
+       return SAL_ERROR_NONE;
+}
+*/
diff --git a/common/ipc-adaptor/sal_ipc_client_storage.h b/common/ipc-adaptor/sal_ipc_client_storage.h
new file mode 100644 (file)
index 0000000..a86eb1e
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Service Adaptor Client Storage IPC
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yongjin Kim <youth.kim@samsung.com>
+ *          Jinhyeong Ahn <jinh.ahn@samsung.com>
+ *          Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_CONVERGENCE_SAL_IPC_CLIENT_STORAGE_H__
+#define __TIZEN_CONVERGENCE_SAL_IPC_CLIENT_STORAGE_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/*
+#include "sal_service_storage.h"
+
+int ipc_service_storage_cloud_file(const char *uri, service_storage_cloud_file_h req_file, service_storage_cloud_file_h *res_file);
+*/
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_CONVERGENCE_SAL_IPC_CLIENT_STORAGE_H__ */
+
index 9082af66b75c1a87b97489de25c4f961f51124f5..6156b5fc613c40dfc3d8bb5f3086535610b4a4b6 100644 (file)
 #include <glib.h>
 #include <gio/gio.h>
 
-#include "service_adaptor_errors.h"
-#include "service_adaptor_internal.h"
+#include "sal_types.h"
+#include "sal_log.h"
 #include "sal_ipc.h"
 
 /******************************************************************************
  * Global variables and defines
  ******************************************************************************/
+#define ERROR_MESSAGE_MAX_LENGH                2048
+
+static __thread int last_error_code = 0;
+
+static __thread char last_error_message[ERROR_MESSAGE_MAX_LENGH] = {0, };
 
 /**
  * Service Adaptor D-Bus client thread data
@@ -74,9 +79,9 @@ static GDBusProxy *interface_proxy = NULL;
 
 static gpointer _dbus_client_thread_func(gpointer data);
 
-static service_adaptor_error_e _dbus_client_start(dbus_client_thread_data_h thread_data);
+static int _dbus_client_start(dbus_client_thread_data_h thread_data);
 
-static service_adaptor_error_e _dbus_client_stop();
+static int _dbus_client_stop();
 
 static void _on_name_appeared(GDBusConnection *connection,
                const gchar *name,
@@ -116,7 +121,7 @@ static gpointer _dbus_client_thread_func(gpointer data)
 
        ret = _dbus_client_start(data);
 
-       if (SERVICE_ADAPTOR_ERROR_NONE == ret) {
+       if (SAL_ERROR_NONE == ret) {
                g_main_loop_run(dbus_client_loop);
        }
 
@@ -140,21 +145,21 @@ static gpointer _dbus_client_thread_func(gpointer data)
  * @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 service_adaptor_error_e _dbus_client_start(dbus_client_thread_data_h thread_data)
+static int _dbus_client_start(dbus_client_thread_data_h thread_data)
 {
        SAL_FN_CALL;
 
        GError *error = NULL;
 
-       RETV_IF(NULL != connection, SERVICE_ADAPTOR_ERROR_INTERNAL);
-       RETV_IF(NULL != interface_proxy, SERVICE_ADAPTOR_ERROR_INTERNAL);
+       RETV_IF(NULL != connection, SAL_ERROR_INTERNAL);
+       RETV_IF(NULL != interface_proxy, SAL_ERROR_INTERNAL);
 
        connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
 
        if (NULL == connection) {
                g_error_free(error);
 
-               return SERVICE_ADAPTOR_ERROR_INTERNAL;
+               return SAL_ERROR_INTERNAL;
        }
 
        interface_proxy = g_dbus_proxy_new_sync(connection,
@@ -172,7 +177,7 @@ static service_adaptor_error_e _dbus_client_start(dbus_client_thread_data_h thre
                g_object_unref(connection);
                connection = NULL;
 
-               return SERVICE_ADAPTOR_ERROR_INTERNAL;
+               return SAL_ERROR_INTERNAL;
        }
 
        watcher_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM,
@@ -190,7 +195,7 @@ static service_adaptor_error_e _dbus_client_start(dbus_client_thread_data_h thre
                g_object_unref(connection);
                connection = NULL;
 
-               return SERVICE_ADAPTOR_ERROR_INTERNAL;
+               return SAL_ERROR_INTERNAL;
        }
 
        int res = g_signal_connect(interface_proxy,
@@ -208,10 +213,10 @@ static service_adaptor_error_e _dbus_client_start(dbus_client_thread_data_h thre
                g_bus_unwatch_name(watcher_id);
                watcher_id = 0;
 
-               return SERVICE_ADAPTOR_ERROR_INTERNAL;
+               return SAL_ERROR_INTERNAL;
        }
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       return SAL_ERROR_NONE;
 }
 
 /**
@@ -219,7 +224,7 @@ static service_adaptor_error_e _dbus_client_start(dbus_client_thread_data_h thre
  *
  * Deinitialises Service Adaptor D-Bus client internal structures.
  */
-static service_adaptor_error_e _dbus_client_stop()
+static int _dbus_client_stop()
 {
        SAL_FN_CALL;
 
@@ -238,7 +243,7 @@ static service_adaptor_error_e _dbus_client_stop()
                watcher_id = 0;
        }
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       return SAL_ERROR_NONE;
 }
 
 /**
@@ -331,16 +336,43 @@ static void _on_signal(GDBusProxy *proxy,
  * Public interface definition
  ******************************************************************************/
 
-API service_adaptor_error_e sal_ipc_client_get_interface(GDBusProxy **interface)
+API void sal_ipc_client_init_last_error(void)
+{
+       last_error_code = 0;
+       last_error_message[0] = '\0';
+}
+
+API void sal_ipc_client_set_last_error(int error, const char *message)
+{
+       SAL_ERR("<thread-safe> set last error : [%d][%s]", error, message);
+
+       last_error_code = error;
+       if (!message)
+               last_error_message[0] = '\0';
+       else
+               snprintf(last_error_message, ERROR_MESSAGE_MAX_LENGH, "%s", message);
+}
+
+API int sal_ipc_client_get_last_error(void)
+{
+       return last_error_code;
+}
+
+API char *sal_ipc_client_get_last_message(void)
+{
+       return last_error_message;
+}
+
+API int sal_ipc_client_get_interface(GDBusProxy **interface)
 {
        SAL_FN_CALL;
 
        *interface = interface_proxy;
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       return SAL_ERROR_NONE;
 }
 
-API service_adaptor_error_e sal_ipc_client_init()
+API int sal_ipc_client_init()
 {
        SAL_FN_CALL;
 
@@ -351,7 +383,7 @@ API service_adaptor_error_e sal_ipc_client_init()
        g_type_init();
 #endif
 
-       RETVM_IF(NULL != dbus_client_thread, SERVICE_ADAPTOR_ERROR_INTERNAL, "D-Bus client thread is already running");
+       RETVM_IF(NULL != dbus_client_thread, SAL_ERROR_INTERNAL, "D-Bus client thread is already running");
 
        dbus_client_thread_data_h thread_data =
                        (dbus_client_thread_data_h) malloc(sizeof(dbus_client_thread_data_s));
@@ -367,16 +399,16 @@ API service_adaptor_error_e sal_ipc_client_init()
        while (!thread_data->connection_cond_signaled) {
                if (!g_cond_wait_until(&thread_data->connection_cond, &thread_data->connection_mutex, timeout)) {
                        g_mutex_unlock(&thread_data->connection_mutex);
-                       return SERVICE_ADAPTOR_ERROR_INTERNAL;
+                       return SAL_ERROR_INTERNAL;
                }
        }
 
        g_mutex_unlock(&thread_data->connection_mutex);
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       return SAL_ERROR_NONE;
 }
 
-API service_adaptor_error_e sal_ipc_client_deinit()
+API int sal_ipc_client_deinit()
 {
        SAL_FN_CALL;
 
@@ -401,18 +433,18 @@ API service_adaptor_error_e sal_ipc_client_deinit()
                g_main_context_unref(dbus_client_context);
                dbus_client_context = NULL;
        }
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       return SAL_ERROR_NONE;
 }
 
 API int sal_ipc_client_call_request(const char *request_method, GVariant *request_data, const char *reply_type, GVariant **reply_info)
 {
        GError *error = NULL;
        GVariant *reply = NULL;
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       int ret = SAL_ERROR_NONE;
 
        GDBusProxy *interface_proxy = NULL;
        ret = sal_ipc_client_get_interface(&interface_proxy);
-       RETV_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_INTERNAL);
+       RETV_IF(SAL_ERROR_NONE != ret, SAL_ERROR_INTERNAL);
 
        reply = g_dbus_proxy_call_sync(interface_proxy,
                        request_method,
@@ -422,11 +454,78 @@ API int sal_ipc_client_call_request(const char *request_method, GVariant *reques
                        NULL,
                        &error);
 
-       RETVM_IF(NULL == reply, SERVICE_ADAPTOR_ERROR_INTERNAL, "IPC Request Failed: %s", error->message);
-       RETV_IF(false == g_variant_is_of_type(reply, (GVariantType *) ipc_make_return_type(reply_type)), SERVICE_ADAPTOR_ERROR_INTERNAL);
+       RETVM_IF(NULL == reply, SAL_ERROR_INTERNAL, "IPC Request Failed: %s", error->message);
+       RETV_IF(false == g_variant_is_of_type(reply, (GVariantType *) reply_type), SAL_ERROR_INTERNAL);
 
        *reply_info = reply;
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       return SAL_ERROR_NONE;
+}
+
+API int sal_ipc_client_get_simple_response(GVariant *response)
+{
+    int reply_size = RETURN_LENGTH;
+
+    GVariant *reply_info[reply_size];
+    ipc_create_variant_info(response, reply_size, (GVariant ***) &reply_info);
+
+    int idx = 0;
+    int ret = g_variant_get_int32(reply_info[idx++]);
+
+       SAL_INFO("<<- ipc remote ret : %d ->>", ret);
+       switch (ret) {
+       case SAL_ERROR_NONE:
+               SAL_DBG("case : SAL_ERROR_NONE");
+               break;
+       case SAL_ERROR_PLUGIN_FAILED:
+               SAL_DBG("case : SAL_ERROR_PLUGIN_FAILED");
+       int ipc_ecode = g_variant_get_int32(reply_info[idx++]);
+               char *ipc_msg = ipc_insure_g_variant_dup_string(reply_info[idx++]);
+
+               sal_ipc_client_set_last_error(ipc_ecode, ipc_msg);
+               SAL_FREE(ipc_msg);
+               break;
+       default:
+               SAL_DBG("case : default");
+               break;
+       }
+
+       ipc_destroy_variant_info(reply_info, reply_size);
+
+       return ret;
+}
+
+API int sal_ipc_client_get_data_response(GVariant *response, GVariant **data)
+{
+    int reply_size = RETURN_LENGTH + 1;
+
+    GVariant *reply_info[reply_size];
+    ipc_create_variant_info(response, reply_size, (GVariant ***) &reply_info);
+
+    int idx = 1;
+    int ret = g_variant_get_int32(reply_info[idx++]);
+
+       SAL_INFO("<<- ipc remote ret : %d ->>", ret);
+       switch (ret) {
+       case SAL_ERROR_NONE:
+               SAL_DBG("case : SAL_ERROR_NONE");
+               *data = g_variant_ref(reply_info[0]);
+               break;
+       case SAL_ERROR_PLUGIN_FAILED:
+               SAL_DBG("case : SAL_ERROR_PLUGIN_FAILED");
+       int ipc_ecode = g_variant_get_int32(reply_info[idx++]);
+               char *ipc_msg = ipc_insure_g_variant_dup_string(reply_info[idx++]);
+
+               sal_ipc_client_set_last_error(ipc_ecode, ipc_msg);
+               SAL_FREE(ipc_msg);
+               break;
+       default:
+               SAL_DBG("case : default");
+               break;
+       }
+
+       ipc_destroy_variant_info(reply_info, reply_size);
+
+       return ret;
 }
 
index b88fd99ac748848783592bc0b5edaf089cd9eb0c..4235f902cef1b1c02d5afa4fb39da9045c31fadc 100644 (file)
@@ -36,14 +36,29 @@ extern "C"
 #include <glib.h>
 #include <gio/gio.h>
 
-#include "service_adaptor_errors.h"
-#include "sal_ipc.h"
+#include "sal_ipc_client_core.h"
+#include "sal_ipc_client_auth.h"
+#include "sal_ipc_client_storage.h"
+
+int sal_ipc_client_init(void);
+
+int sal_ipc_client_deinit(void);
 
-service_adaptor_error_e sal_ipc_client_init();
-service_adaptor_error_e sal_ipc_client_deinit();
-service_adaptor_error_e sal_ipc_client_get_interface(GDBusProxy **interface);
 int sal_ipc_client_call_request(const char *request_method, GVariant *request_data, const char *reply_type, GVariant **reply_info);
 
+int sal_ipc_client_get_simple_response(GVariant *response);
+
+int sal_ipc_client_get_data_response(GVariant *response, GVariant **data);
+
+
+API void sal_ipc_client_init_last_error(void);
+
+API void sal_ipc_client_set_last_error(int error, const char *message);
+
+API int sal_ipc_client_get_last_error(void);
+
+API char *sal_ipc_client_get_last_message(void);
+
 #ifdef __cplusplus
 }
 #endif
index 99cf1d87e00d4ca0eb415e2e6fd3a888f29e941b..796c07016851503713885c6c62b549a4dbb12808 100644 (file)
 #include <glib.h>
 #include <gio/gio.h>
 
-#include "service_adaptor_errors.h"
-#include "service_adaptor_internal.h"
+#include "sal_types.h"
+#include "sal_log.h"
+#include "sal_ipc.h"
 #include "sal_ipc_client.h"
 #include "sal_ipc_client_auth.h"
-#include "sal_service_auth.h"
-#include "sal_service_auth_internal.h"
 
 /******************************************************************************
  * Global variables and defines
  * Private interface definition
  ******************************************************************************/
 
-int _get_oauth1(GVariant *reply_info, service_auth_oauth1_h *oauth1)
-{
-       service_auth_oauth1_h auth_oauth1 = (service_auth_oauth1_h) g_malloc0(sizeof(service_auth_oauth1_s));
-
-       int info_size = service_auth_oauth1_res_s_type_length;
-       GVariant *info[info_size];
-       ipc_create_variant_info(reply_info, info_size, (GVariant ***) &info);
-
-       int idx = 0;
-       int auth_info_size = service_auth_oauth1_s_type_length;
-       GVariant *auth_info[auth_info_size];
-       ipc_create_variant_info(info[idx++], auth_info_size, (GVariant ***) &auth_info);
-
-       int idx2 = 0;
-       auth_oauth1->access_token = ipc_insure_g_variant_dup_string(auth_info[idx2++]);
-       auth_oauth1->operation = ipc_insure_g_variant_dup_string(auth_info[idx2++]);
-
-       ipc_destroy_variant_info(auth_info, auth_info_size);
-
-       ipc_destroy_variant_info(info, info_size);
-
-       *oauth1 = auth_oauth1;
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
-
 /******************************************************************************
  * Public interface definition
  ******************************************************************************/
 
-API int ipc_service_auth_oauth1(const char *uri, service_auth_oauth1_h req_oauth1, service_auth_oauth1_h *res_oauth1)
-{
-       SAL_FN_CALL;
-
-       RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == req_oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
-
-       char *request_method = DBUS_SERVICE_AUTH_OAUTH1_METHOD;
-       GVariant *request_data = g_variant_new("(" service_auth_oauth1_req_s_type ")", uri, SAL_IPC_STR(req_oauth1->access_token), SAL_IPC_STR(req_oauth1->operation));
-
-       char *reply_type = service_auth_oauth1_res_s_type;
-       int reply_size = RETURN_LENGTH + 1;
-       GVariant *reply = NULL;
-
-       ret = sal_ipc_client_call_request(request_method, request_data, reply_type, &reply);
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "ipc_client_call_request() Failed(%d)", ret);
-
-       GVariant *reply_info[reply_size];
-       ipc_create_variant_info(reply, reply_size, (GVariant ***) &reply_info);
-
-       int idx = 0;
-       service_auth_oauth1_h oauth1 = NULL;
-       _get_oauth1(reply_info[idx++], &oauth1);
-
-       int ipc_ret = g_variant_get_int32(reply_info[idx++]);
-       char *ipc_msg = ipc_insure_g_variant_dup_string(reply_info[idx++]);
-
-       ipc_destroy_variant_info(reply_info, reply_size);
-
-       g_variant_unref(reply);
-
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ipc_ret, SERVICE_ADAPTOR_ERROR_INTERNAL, "IPC Result Failed(%d): %s", ipc_ret, ipc_msg);
-
-       *res_oauth1 = oauth1;
-
-       SAL_FREE(ipc_msg);
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
index 56b553fdbf052a18efb7701e6d2cbdc764d606f7..d75e20427f4584fa9b50ab0b57326c2adda771f6 100644 (file)
 extern "C"
 {
 #endif
-
+/*
 #include "sal_service_auth.h"
 
 int ipc_service_auth_oauth1(const char *uri, service_auth_oauth1_h req_oauth1, service_auth_oauth1_h *res_oauth1);
-
+*/
 #ifdef __cplusplus
 }
 #endif
index d0a32ff26778ace4226ef62f520ad889d96fd94c..55f2961adca41f6e128cbcd483852f07c3d64e36 100644 (file)
@@ -20,8 +20,9 @@
 #include <glib.h>
 #include <gio/gio.h>
 
-#include "service_adaptor_errors.h"
-#include "service_adaptor_internal.h"
+#include "sal_types.h"
+#include "sal_log.h"
+#include "sal_ipc.h"
 #include "sal_ipc_client.h"
 #include "sal_ipc_client_core.h"
 
  * Private interface
  ******************************************************************************/
 
-/******************************************************************************
- * Private interface definition
- ******************************************************************************/
+/*
+ * @param[in]  response        Gvariant response
+ * @param[out] list            plugin list
+ */
+static void __get_connect_res(GVariant *response, GList **list);
+
+/*
+ * @param[in]  response                Gvariant response
+ * @param[out] plugin_handle   identifier of plugin handle
+ */
+static void __get_plugin_start_res(GVariant *response, char **plugin_handle);
 
 /******************************************************************************
- * Public interface definition
+ * Private interface definition
  ******************************************************************************/
 
-API int ipc_service_adaptor_connect(const char *uri, GList **plugins)
+static void __get_connect_res(GVariant *response, GList **list)
 {
        SAL_FN_CALL;
 
-       RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       GVariantIter *plugin_iter = NULL;
+       plugin_iter  = g_variant_iter_new(response);
+       GList *_plugin_list = NULL;
 
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       char *_plugin_uri = NULL;
+       while (g_variant_iter_loop(plugin_iter, "(s)", &_plugin_uri)) {
 
-       char *request_method = DBUS_SERVICE_ADAPTOR_CONNECT_METHOD;
-       GVariant *request_data = g_variant_new("(" service_adaptor_connect_req_s_type ")", uri);
-
-       char *reply_type = service_adaptor_connect_res_s_type;
-       int reply_size = RETURN_LENGTH + 1;
-       GVariant *reply = NULL;
+               SAL_DBG("<iter> plugin_uri : %s", _plugin_uri);
+               if (_plugin_uri && ('\0' != _plugin_uri))
+                       _plugin_list = g_list_append(_plugin_list, (void *)_plugin_uri);
+               else
+                       free(_plugin_uri);
+               _plugin_uri = NULL;
+       }
 
-       ret = sal_ipc_client_call_request(request_method, request_data, reply_type, &reply);
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "ipc_client_call_request() Failed(%d)", ret);
+       g_variant_iter_free(plugin_iter);
+       plugin_iter = NULL;
 
-       GVariant *reply_info[reply_size];
-       ipc_create_variant_info(reply, reply_size, (GVariant ***) &reply_info);
+/*
+       if (0 == g_list_length(_plugin_list)) {
+               ret = SAL_ERROR_NO_DATA;
+       }
+*/
 
-       int idx = 0;
-       int info_size = service_adaptor_connect_res_s_type_length;
-       GVariant *info[info_size];
-       ipc_create_variant_info(reply_info[idx++], info_size, (GVariant ***) &info);
+       *list = _plugin_list;
 
-       int idx2 = 0;
-       GList *plugin_list = NULL;
-       gsize uri_info_size = g_variant_n_children(info[idx2]);
+       SAL_FN_END;
+}
 
-       for (gsize i = 0; i < uri_info_size; i++) {
-               GVariant *uri_info_struct;
-               GVariant *uri_info_entry_v = g_variant_get_child_value(info[idx2], i);
-               uri_info_struct = g_variant_get_child_value(uri_info_entry_v, 0);
+static void __get_plugin_start_res(GVariant *response, char **plugin_handle)
+{
+       SAL_FN_CALL;
+       char *_str = NULL;
+       g_variant_get(response, service_plugin_start_res_s_type, &_str);
+       if (_str && ('\0' == _str[0]))
+               SAL_FREE(_str);
 
-               plugin_list = g_list_append(plugin_list, ipc_insure_g_variant_dup_string(uri_info_struct));
+       *plugin_handle = _str;
+       SAL_FN_END;
+}
 
-               g_variant_unref(uri_info_struct);
-       }
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
 
-       *plugins = plugin_list;
+API int ipc_service_adaptor_connect(int pid, const char *uri, GList **plugins)
+{
+       SAL_FN_CALL;
 
-       int ipc_ret = g_variant_get_int32(reply_info[idx++]);
-       char *ipc_msg = ipc_insure_g_variant_dup_string(reply_info[idx++]);
+       RETV_IF(NULL == uri, SAL_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == plugins, SAL_ERROR_INVALID_PARAMETER);
 
-       ipc_destroy_variant_info(reply_info, reply_size);
+       int ret = SAL_ERROR_NONE;
 
-       g_variant_unref(reply);
+       /* Call dbus request */
+       char *request_method = DBUS_SERVICE_ADAPTOR_CONNECT_METHOD;
+       GVariant *request_data = g_variant_new("(" service_adaptor_connect_req_s_type ")", pid, uri);
 
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ipc_ret, SERVICE_ADAPTOR_ERROR_INTERNAL, "IPC Result Failed(%d): %s", ipc_ret, ipc_msg);
+       char *reply_type = SAL_IPC_RETURN_TYPE(service_adaptor_connect_res_s_type);
+       GVariant *reply = NULL;
 
-       SAL_FREE(ipc_msg);
+       ret = sal_ipc_client_call_request(request_method, request_data, reply_type, &reply);
+       RETVM_IF(SAL_ERROR_NONE != ret, ret, "ipc_client_call_request() Failed(%d)", ret);
+
+       /* Parse response */
+       GVariant *reply_data = NULL;
+       ret = sal_ipc_client_get_data_response(reply, &reply_data);
+       if (!ret && reply_data) {
+               __get_connect_res(reply_data, plugins);
+               g_variant_unref(reply_data);
+       }
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       SAL_FN_END;
+       return ret;
 }
 
-API int ipc_service_adaptor_disconnect(const char *uri)
+API int ipc_service_adaptor_disconnect(int pid, const char *uri)
 {
        SAL_FN_CALL;
 
-       RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == uri, SAL_ERROR_INVALID_PARAMETER);
 
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       int ret = SAL_ERROR_NONE;
 
+       /* Call dbus request */
        char *request_method = DBUS_SERVICE_ADAPTOR_DISCONNECT_METHOD;
-       GVariant *request_data = g_variant_new("(" service_adaptor_disconnect_s_type ")", uri);
+       GVariant *request_data = g_variant_new("(" service_adaptor_disconnect_s_type ")", pid, uri);
 
-       char *reply_type = NULL;
-       int reply_size = RETURN_LENGTH;
+       char *reply_type = SAL_IPC_SIMPLE_TYPE;
        GVariant *reply = NULL;
 
        ret = sal_ipc_client_call_request(request_method, request_data, reply_type, &reply);
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "ipc_client_call_request() Failed(%d)", ret);
+       RETVM_IF(SAL_ERROR_NONE != ret, ret, "ipc_client_call_request() Failed(%d)", ret);
 
-       GVariant *reply_info[reply_size];
-       ipc_create_variant_info(reply, reply_size, (GVariant ***) &reply_info);
+       ret = sal_ipc_client_get_simple_response(reply);
 
-       int idx = 0;
-       int ipc_ret = g_variant_get_int32(reply_info[idx++]);
-       char *ipc_msg = ipc_insure_g_variant_dup_string(reply_info[idx++]);
-
-       ipc_destroy_variant_info(reply_info, reply_size);
-
-       g_variant_unref(reply);
-
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ipc_ret, SERVICE_ADAPTOR_ERROR_INTERNAL, "IPC Result Failed(%d): %s", ipc_ret, ipc_msg);
-
-       SAL_FREE(ipc_msg);
-
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       SAL_FN_END;
+       return ret;
 }
 
-API int ipc_service_plugin_create(const char *uri)
+
+API int ipc_service_plugin_start(int pid, const char *uri, const char *plugin_uri, char **plugin_handle)
 {
        SAL_FN_CALL;
 
-       RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == uri, SAL_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == plugin_uri, SAL_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == plugin_handle, SAL_ERROR_INVALID_PARAMETER);
 
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       int ret = SAL_ERROR_NONE;
 
-       char *request_method = DBUS_SERVICE_PLUGIN_CREATE_METHOD;
-       GVariant *request_data = g_variant_new("(" service_plugin_create_s_type ")", uri);
+       char *request_method = DBUS_SERVICE_PLUGIN_START_METHOD;
+       GVariant *request_data = g_variant_new("(" service_plugin_start_req_s_type ")", pid, uri, plugin_uri);
 
-       char *reply_type = NULL;
-       int reply_size = RETURN_LENGTH;
+       char *reply_type = SAL_IPC_RETURN_TYPE(service_plugin_start_res_s_type);
        GVariant *reply = NULL;
 
        ret = sal_ipc_client_call_request(request_method, request_data, reply_type, &reply);
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "ipc_client_call_request() Failed(%d)", ret);
-
-       GVariant *reply_info[reply_size];
-       ipc_create_variant_info(reply, reply_size, (GVariant ***) &reply_info);
-
-       int idx = 0;
-       int ipc_ret = g_variant_get_int32(reply_info[idx++]);
-       char *ipc_msg = ipc_insure_g_variant_dup_string(reply_info[idx++]);
-
-       ipc_destroy_variant_info(reply_info, reply_size);
-
-       g_variant_unref(reply);
-
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ipc_ret, SERVICE_ADAPTOR_ERROR_INTERNAL, "IPC Result Failed(%d): %s", ipc_ret, ipc_msg);
-
-       SAL_FREE(ipc_msg);
+       RETVM_IF(SAL_ERROR_NONE != ret, ret, "ipc_client_call_request() Failed(%d)", ret);
+
+       /* Parse response */
+       GVariant *reply_data = NULL;
+       ret = sal_ipc_client_get_data_response(reply, &reply_data);
+       if (!ret && reply_data) {
+               __get_plugin_start_res(reply_data, plugin_handle);
+               g_variant_unref(reply_data);
+       }
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       SAL_FN_END;
+       return ret;
 }
 
-API int ipc_service_plugin_destroy(const char *uri)
+API int ipc_service_plugin_stop(const char *plugin_handle)
 {
        SAL_FN_CALL;
 
-       RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == plugin_handle, SAL_ERROR_INVALID_PARAMETER);
 
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       int ret = SAL_ERROR_NONE;
 
-       char *request_method = DBUS_SERVICE_PLUGIN_DESTROY_METHOD;
-       GVariant *request_data = g_variant_new("(" service_plugin_destroy_s_type ")", uri);
+       char *request_method = DBUS_SERVICE_PLUGIN_STOP_METHOD;
+       GVariant *request_data = g_variant_new("(" service_plugin_stop_s_type ")", plugin_handle);
 
-       char *reply_type = NULL;
-       int reply_size = RETURN_LENGTH;
+       char *reply_type = SAL_IPC_SIMPLE_TYPE;
        GVariant *reply = NULL;
 
        ret = sal_ipc_client_call_request(request_method, request_data, reply_type, &reply);
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "ipc_client_call_request() Failed(%d)", ret);
-
-       GVariant *reply_info[reply_size];
-       ipc_create_variant_info(reply, reply_size, (GVariant ***) &reply_info);
-
-       int idx = 0;
-       int ipc_ret = g_variant_get_int32(reply_info[idx++]);
-       char *ipc_msg = ipc_insure_g_variant_dup_string(reply_info[idx++]);
-
-       ipc_destroy_variant_info(reply_info, reply_size);
-
-       g_variant_unref(reply);
-
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ipc_ret, SERVICE_ADAPTOR_ERROR_INTERNAL, "IPC Result Failed(%d): %s", ipc_ret, ipc_msg);
+       RETVM_IF(SAL_ERROR_NONE != ret, ret, "ipc_client_call_request() Failed(%d)", ret);
 
-       SAL_FREE(ipc_msg);
+       ret = sal_ipc_client_get_simple_response(reply);
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       SAL_FN_END;
+       return ret;
 }
 
index a4f1ea31bbbc416f1950cac8e841f9e3c3387182..40a55fa38b8c269422464b86de818c4435d96bcb 100644 (file)
@@ -35,11 +35,13 @@ extern "C"
 
 #include <glib.h>
 
-int ipc_service_adaptor_connect(const char *uri, GList **plugins);
-int ipc_service_adaptor_disconnect(const char *uri);
-int ipc_service_plugin_create(const char *uri);
-int ipc_service_plugin_destroy(const char *uri);
+int ipc_service_adaptor_connect(int pid, const char *uri, GList **plugins);
 
+int ipc_service_adaptor_disconnect(int pid, const char *uri);
+
+int ipc_service_plugin_start(int pid, const char *uri, const char *plugin_uri, char **plugin_handle);
+
+int ipc_service_plugin_stop(const char *plugin_handle);
 
 #ifdef __cplusplus
 }
index 901709e8bdf81d7222946d2a478497e6bceca03d..13eb27d6b29502d03390602ad51e14ff6486a39d 100644 (file)
 #include <glib.h>
 #include <gio/gio.h>
 
-#include "service_adaptor_errors.h"
-#include "service_adaptor_internal.h"
+#include "sal_types.h"
+#include "sal_log.h"
+#include "sal_ipc.h"
 #include "sal_ipc_client.h"
 #include "sal_ipc_client_storage.h"
-#include "sal_service_storage.h"
-#include "sal_service_storage_internal.h"
 
 /******************************************************************************
  * Global variables and defines
@@ -38,7 +37,7 @@
 /******************************************************************************
  * Private interface definition
  ******************************************************************************/
-
+/*
 int _get_cloud_file(GVariant *reply_info, service_storage_cloud_file_h *file)
 {
        service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) g_malloc0(sizeof(service_storage_cloud_file_s));
@@ -76,25 +75,25 @@ int _get_cloud_file(GVariant *reply_info, service_storage_cloud_file_h *file)
 
        ipc_destroy_variant_info(info, info_size);
 
-       /* TODO: reorder files because it is just serialized. it makes tree structure. */
+       // TODO: reorder files because it is just serialized. it makes tree structure.
 
        *file = cloud_file;
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       return SAL_ERROR_NONE;
 }
-
+*/
 /******************************************************************************
  * Public interface definition
  ******************************************************************************/
-
+/*
 API int ipc_service_storage_cloud_file(const char *uri, service_storage_cloud_file_h req_file, service_storage_cloud_file_h *res_file)
 {
        SAL_FN_CALL;
 
-       RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == req_file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == uri, SAL_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == req_file, SAL_ERROR_INVALID_PARAMETER);
 
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       int ret = SAL_ERROR_NONE;
 
        char *request_method = DBUS_SERVICE_STORAGE_CLOUD_FILE_METHOD;
        GVariant *request_data = g_variant_new("(" service_storage_cloud_file_req_s_type ")", uri, req_file->is_dir, SAL_IPC_STR(req_file->dir_path), SAL_IPC_STR(req_file->local_path), SAL_IPC_STR(req_file->cloud_path), req_file->size, SAL_IPC_STR(req_file->operation));
@@ -104,7 +103,7 @@ API int ipc_service_storage_cloud_file(const char *uri, service_storage_cloud_fi
        GVariant *reply = NULL;
 
        ret = sal_ipc_client_call_request(request_method, request_data, reply_type, &reply);
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "ipc_client_call_request() Failed(%d)", ret);
+       RETVM_IF(SAL_ERROR_NONE != ret, ret, "ipc_client_call_request() Failed(%d)", ret);
 
        GVariant *reply_info[reply_size];
        ipc_create_variant_info(reply, reply_size, (GVariant ***) &reply_info);
@@ -120,11 +119,12 @@ API int ipc_service_storage_cloud_file(const char *uri, service_storage_cloud_fi
 
        g_variant_unref(reply);
 
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ipc_ret, SERVICE_ADAPTOR_ERROR_INTERNAL, "IPC Result Failed(%d): %s", ipc_ret, ipc_msg);
+       RETVM_IF(SAL_ERROR_NONE != ipc_ret, SAL_ERROR_INTERNAL, "IPC Result Failed(%d): %s", ipc_ret, ipc_msg);
 
        *res_file = cloud_file;
 
        SAL_FREE(ipc_msg);
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       return SAL_ERROR_NONE;
 }
+*/
index ed25d22d5d16d346190ac7440f2a67c736ba7b6c..a86eb1e1e39a537d082c7f14791d2d7dffb1fa4f 100644 (file)
 extern "C"
 {
 #endif
-
+/*
 #include "sal_service_storage.h"
 
 int ipc_service_storage_cloud_file(const char *uri, service_storage_cloud_file_h req_file, service_storage_cloud_file_h *res_file);
-
+*/
 #ifdef __cplusplus
 }
 #endif
diff --git a/common/ipc-provider/sal_ipc_provider.c b/common/ipc-provider/sal_ipc_provider.c
new file mode 100644 (file)
index 0000000..a0d30ab
--- /dev/null
@@ -0,0 +1,446 @@
+/*
+ * Service Adaptor IPC Server
+ *
+ * Copyright (c) 2014 - 2015 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 <gio/gio.h>
+#include <app.h>
+
+#include "sal_types.h"
+#include "sal_log.h"
+#include "sal_ipc.h"
+
+#include "sal_ipc_provider.h"
+
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/**
+ * D-Bus server thread pool
+ */
+static GThreadPool *thread_pool = NULL;
+
+/**
+ * Compiled introspection data describing D-Bus interface
+ */
+static GDBusNodeInfo *introspection_data = NULL;
+
+/**
+ * D-Bus server owner id
+ */
+static guint owner_id = 0;
+
+/**
+ * D-Bus connection used by server
+ */
+static GDBusConnection *dbus_connection = NULL;
+
+/*
+ * Do not free
+ */
+static char *g_dbus_busname = NULL;
+
+/*
+ * Do not free
+ */
+static char *g_dbus_objectpath = NULL;
+
+/**
+ * Introspection data describing D-Bus interface
+ */
+static const gchar introspection_xml[] =
+"<node>"
+"  <interface name='" SERVICE_PROVIDER_BUS_INTERFACE "'>"
+"    <method name='" SERVICE_PROVIDER_BASE_SESSION_START "'>"
+"      <arg type='" SERVICE_PROVIDER_BASE_SESSION_START_REQ "' name='req' direction='in'/>"
+"      <arg type='" SERVICE_PROVIDER_BASE_SESSION_START_RES "' name='res' direction='out'/>"
+"    </method>"
+"    <method name='" SERVICE_PROVIDER_BASE_SESSION_STOP "'>"
+"      <arg type='" SERVICE_PROVIDER_BASE_SESSION_STOP_REQ "' name='req' direction='in'/>"
+"      <arg type='" SERVICE_PROVIDER_BASE_SESSION_STOP_RES "' name='res' direction='out'/>"
+"    </method>"
+"    <method name='" SERVICE_PROVIDER_STORAGE_DOWNLOAD "'>"
+"      <arg type='" SERVICE_PROVIDER_STORAGE_DOWNLOAD_REQ "' name='req' direction='in'/>"
+"      <arg type='" SERVICE_PROVIDER_STORAGE_DOWNLOAD_RES "' name='res' direction='out'/>"
+"    </method>"
+"  </interface>"
+"</node>";
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+USER_DATA_TYPEDEF(ipc_state_data_t, 2);
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+static void _method_call_async_func(gpointer data, gpointer user_data)
+{
+       SAL_FN_CALL;
+
+       RET_IF(NULL == data);
+
+       ipc_provider_session_h handle = (ipc_provider_session_h)data;
+
+       SAL_INFO("Call %s", handle->method_name);
+
+       if (0 == strncmp(SERVICE_PROVIDER_STORAGE_PREFIX, handle->method_name, SERVICE_PROVIDER_PREFIX_LEN)) {
+               ipc_provider_storage_method_call(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)
+{
+       SAL_FN_CALL;
+
+       ipc_provider_session_h handle = (ipc_provider_session_h) g_malloc0(sizeof(ipc_provider_session_s));
+
+       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;
+
+       if (0 == strncmp(SERVICE_PROVIDER_BASE_PREFIX, method_name, SERVICE_PROVIDER_PREFIX_LEN)) {
+               GMainContext *global_main_context = g_main_context_default();
+               g_main_context_invoke(global_main_context, ipc_provider_base_method_call, (user_data_t)handle);
+       } else { /* == SAL_SERVICE_STORAGE */
+               g_thread_pool_push(thread_pool, (user_data_t)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)
+{
+       SAL_FN_CALL;
+
+       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)
+{
+       SAL_FN_CALL;
+
+       gboolean ret = false;
+
+       if (NULL == *error) {
+               ret = true;
+       }
+
+       return ret;
+}
+
+/**
+ * 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 Service Adaptor D-Bus server is acquired.
+ *
+ * Callback function called when D-Bus bus name for Service Adaptor 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)
+{
+       SAL_FN_CALL;
+
+       guint registration_id;
+       char *_object_path = g_dbus_objectpath;
+
+       registration_id = g_dbus_connection_register_object(connection,
+                       _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 Service Adaptor D-Bus server is acquired.
+ *
+ * Callback function called when D-Bus name for Service Adaptor 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)
+{
+       SAL_FN_CALL;
+
+       dbus_connection = connection;
+       g_object_ref(dbus_connection);
+
+
+       USER_DATA_DEFINE(ipc_state_data_t, _callback_data) = (USER_DATA_TYPE(ipc_state_data_t) *)user_data;
+       ipc_provider_connection_cb callback = (ipc_provider_connection_cb)USER_DATA_ELEMENT(_callback_data, 0);
+       void *_user_data = (void *)USER_DATA_ELEMENT(_callback_data, 1);
+
+       if (callback)
+               callback(IPC_PROVIDER_CONNECTION_OPENED, _user_data);
+}
+
+/**
+ * @brief Callback function called when the Service Adaptor D-Bus name is lost or connection has been closed.
+ *
+ * Callback function called when the Service Adaptor 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)
+{
+       SAL_FN_CALL;
+
+       USER_DATA_DEFINE(ipc_state_data_t, _callback_data) = (USER_DATA_TYPE(ipc_state_data_t) *)user_data;
+       ipc_provider_connection_cb callback = (ipc_provider_connection_cb)USER_DATA_ELEMENT(_callback_data, 0);
+       void *_user_data = (void *)USER_DATA_ELEMENT(_callback_data, 1);
+
+       if (callback)
+               callback(IPC_PROVIDER_CONNECTION_CLOSED, _user_data);
+
+       if (NULL != dbus_connection) {
+               g_object_unref(dbus_connection);
+               dbus_connection = NULL;
+       }
+
+       SAL_INFO("Unexpected D-bus bus name lost");
+
+       /* Send SIGINT to main thread to stop File Manager process and cleanly close Service Adaptor */
+       /* kill(getpid(), SIGINT); */
+}
+
+int _sal_ipc_provider_start()
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL != introspection_data, SAL_ERROR_INTERNAL);
+       RETV_IF(0 != owner_id, SAL_ERROR_INTERNAL);
+
+       return SAL_ERROR_NONE;
+}
+
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+API int sal_ipc_provider_init(ipc_provider_base_req_s *base_method,
+               ipc_provider_storage_req_s *storage_method,
+               ipc_provider_connection_cb callback,
+               void *user_data)
+{
+       SAL_FN_CALL;
+
+       RETVM_IF(NULL == base_method, SAL_ERROR_INVALID_PARAMETER, "Please check param");
+       RETVM_IF(NULL == storage_method, SAL_ERROR_INVALID_PARAMETER, "Please check param");
+       RETVM_IF(NULL == callback, SAL_ERROR_INVALID_PARAMETER, "Please check param");
+
+       introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
+       RETVM_IF(NULL == introspection_data, SAL_ERROR_INTERNAL, "g_dbus_node_info_new_for_xml() Failed");
+
+       char *app_id = NULL;
+       char *bus_name = NULL;
+       char *obj_path = NULL;
+
+       USER_DATA_DEFINE(ipc_state_data_t, _callback_data) = NULL;
+
+       USER_DATA_VAL(_callback_data) = USER_DATA_CREATE(ipc_state_data_t);
+       TRYM_IF(NULL == USER_DATA_VAL(_callback_data), "Out of memory");
+       USER_DATA_ELEMENT(_callback_data, 0) = (user_data_t)callback;
+       USER_DATA_ELEMENT(_callback_data, 1) = (user_data_t)user_data;
+
+       int ret = app_get_id(&app_id);
+       TRYM_IF(APP_ERROR_NONE != ret, "app_id get failed");
+       TRYM_IF(NULL == app_id, "Out of memory");
+
+       bus_name = g_strdup_printf("%s.%s", SERVICE_PROVIDER_BUS_NAME_PREFIX, app_id);
+       TRYM_IF(NULL == bus_name, "Out of memory");
+
+       obj_path = g_strdup(bus_name);
+       TRYM_IF(NULL == obj_path, "Out of memory");
+
+       SAL_STR_REPLACE(obj_path, '.', '/');
+
+       thread_pool = g_thread_pool_new(_method_call_async_func, NULL, -1, FALSE, NULL);
+       TRYM_IF(NULL == thread_pool, "g_thread_pool_new() Failed");
+
+       owner_id = g_bus_own_name(G_BUS_TYPE_SESSION,
+                       bus_name,
+                       G_BUS_NAME_OWNER_FLAGS_NONE,
+                       _on_bus_acquired,
+                       _on_name_acquired,
+                       _on_name_lost,
+                       USER_DATA_VAL(_callback_data),
+                       (GDestroyNotify)USER_DATA_DESTROY_FUNC);
+
+       TRYM_IF(0 == owner_id, "Dbus own name failed");
+
+       g_dbus_busname = bus_name;
+       g_dbus_objectpath = obj_path;
+
+       return SAL_ERROR_NONE;
+
+catch:
+       USER_DATA_DESTROY(_callback_data);
+       SAL_FREE(obj_path);
+       SAL_FREE(bus_name);
+       SAL_FREE(app_id);
+       if (introspection_data) {
+               g_dbus_node_info_unref(introspection_data);
+               introspection_data = NULL;
+       }
+
+       if (NULL != thread_pool) {
+               g_thread_pool_free(thread_pool, TRUE, TRUE);
+               thread_pool = NULL;
+       }
+
+       return SAL_ERROR_SYSTEM;
+}
+
+API int sal_ipc_provider_deinit()
+{
+       SAL_FN_CALL;
+
+       SAL_FREE(g_dbus_busname);
+       SAL_FREE(g_dbus_objectpath);
+
+       if (NULL != thread_pool) {
+               g_thread_pool_free(thread_pool, TRUE, TRUE);
+               thread_pool = NULL;
+       }
+
+       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;
+       }
+
+       return SAL_ERROR_NONE;
+}
+
+API int sal_ipc_provider_emit_signal(const char *signal_name, GVariant *parameters)
+{
+       RETVM_IF(0 >= owner_id, SAL_ERROR_INTERNAL, "Bus not ready");
+       RETVM_IF(NULL == dbus_connection, SAL_ERROR_INTERNAL, "Bus not ready");
+       RETVM_IF(NULL == g_dbus_busname, SAL_ERROR_INTERNAL, "Bus not ready");
+       RETVM_IF(NULL == g_dbus_objectpath, SAL_ERROR_INTERNAL, "Bus not ready");
+
+       RETVM_IF(NULL == signal_name, SAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
+       RETVM_IF(NULL == parameters, SAL_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       GError *err = NULL;
+       g_dbus_connection_emit_signal(dbus_connection, g_dbus_busname, g_dbus_objectpath,
+                       SERVICE_PROVIDER_BUS_INTERFACE, signal_name, parameters, &err);
+       if (err) {
+               SAL_ERR("Signal emit error : %d, %s", err->code, err->message);
+               g_error_free(err);
+               err = NULL;
+               return SAL_ERROR_IPC_UNSTABLE;
+       }
+       return SAL_ERROR_NONE;
+}
diff --git a/common/ipc-provider/sal_ipc_provider.h b/common/ipc-provider/sal_ipc_provider.h
new file mode 100644 (file)
index 0000000..b93c5a6
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Service Adaptor Server IPC
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yongjin Kim <youth.kim@samsung.com>
+ *          Jinhyeong Ahn <jinh.ahn@samsung.com>
+ *          Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_CONVERGENCE_SAL_IPC_PROVIDER_H__
+#define __TIZEN_CONVERGENCE_SAL_IPC_PROVIDER_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <glib.h>
+
+#include "sal_ipc_provider_types.h"
+#include "sal_ipc_provider_base.h"
+#include "sal_ipc_provider_storage.h"
+
+typedef enum
+{
+       IPC_PROVIDER_CONNECTION_OPENED = 1,
+       IPC_PROVIDER_CONNECTION_CLOSED = 2,
+} ipc_provider_connection_state_e;
+
+typedef void (*ipc_provider_connection_cb)(ipc_provider_connection_state_e state, void *user_data);
+
+int sal_ipc_provider_init(ipc_provider_base_req_s *base_method,
+               ipc_provider_storage_req_s *storage_method,
+               ipc_provider_connection_cb callback,
+               void *user_data);
+
+int sal_ipc_provider_deinit(void);
+
+int sal_ipc_provider_emit_signal(const char *signal_name, GVariant *parameters);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_CONVERGENCE_SAL_IPC_PROVIDER_H__ */
+
diff --git a/common/ipc-provider/sal_ipc_provider_base.c b/common/ipc-provider/sal_ipc_provider_base.c
new file mode 100644 (file)
index 0000000..fff09c5
--- /dev/null
@@ -0,0 +1,302 @@
+/*
+ * Service Adaptor IPC Server
+ *
+ * Copyright (c) 2014 - 2015 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 <stdint.h>
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "sal_types.h"
+#include "sal_log.h"
+#include "sal_ipc.h"
+#include "sal_ipc_provider_base.h"
+
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/* request callback internal */
+static void __session_start_cb(ipc_provider_session_h session);
+
+static void __session_stop_cb(ipc_provider_session_h session);
+
+
+/* response function internal */
+static void __response_session_start(ipc_provider_session_h session, const char *session_uri);
+
+static void __response_session_stop(ipc_provider_session_h session);
+
+static void __response_fail(ipc_provider_session_h session, int result, int error_code, const char *message);
+
+
+/* response fail function internal */
+static void __simple_fail_cb(ipc_provider_session_h session, int ret, int err, const char *message);
+
+static void __session_start_fail_cb(ipc_provider_session_h session, int ret, int err, const char *message);
+
+/* signal function internal */
+static void __channel_opened_signal(void);
+
+static void __channel_closed_signal(void);
+
+
+/* method call function */
+static gboolean __base_method_call(void *data);
+
+
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+struct _dbus_interface_map
+{
+       char *method_name;
+       void (*func)(ipc_provider_session_h session);
+};
+
+static struct _dbus_interface_map __interface_map[] = {
+                       {SERVICE_PROVIDER_BASE_SESSION_START,   __session_start_cb},
+                       {SERVICE_PROVIDER_BASE_SESSION_STOP,    __session_stop_cb},
+       };
+
+struct _dbus_fail_response_map
+{
+       char *method_name;
+       void (*func)(ipc_provider_session_h session, int ret, int err, const char *message);
+};
+
+static struct _dbus_fail_response_map __fail_response_map[] = {
+               {SERVICE_PROVIDER_BASE_SESSION_START,   __session_start_fail_cb},
+               {SERVICE_PROVIDER_BASE_SESSION_STOP,    __simple_fail_cb},
+       };
+
+
+static ipc_provider_base_req_s req_callbacks = {0, };
+
+static ipc_provider_base_res_s response_methods = {
+               __response_session_start,
+               __response_session_stop,
+               __response_fail,
+       };
+
+static ipc_provider_base_signal_s signal_methods = {
+               __channel_opened_signal,
+               __channel_closed_signal,
+       };
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+/* request callbacks  */
+static void __session_start_cb(ipc_provider_session_h session)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("gets parameters from gvriant");
+       char *_client_uri = NULL;
+       g_variant_get_child(session->parameters, 0,
+                       SAL_IPC_REQ_TYPE(SERVICE_PROVIDER_BASE_SESSION_START),
+                       &_client_uri);
+
+       SAL_DBG("invokes callback");
+       req_callbacks.session_start_cb(session, _client_uri);
+       /* TODO support service_mask*/
+
+       SAL_FREE(_client_uri);
+
+       SAL_FN_END;
+}
+
+static void __session_stop_cb(ipc_provider_session_h session)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("gets parameters from gvriant");
+       char *_session_uri = NULL;
+       g_variant_get_child(session->parameters, 0,
+                       SAL_IPC_REQ_TYPE(SERVICE_PROVIDER_BASE_SESSION_STOP),
+                       &_session_uri);
+
+       SAL_DBG("invokes callback");
+       req_callbacks.session_stop_cb(session, _session_uri);
+
+       SAL_FREE(_session_uri);
+
+       SAL_FN_END;
+}
+
+
+/* response functions  */
+static void __response_session_start(ipc_provider_session_h session, const char *session_uri)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("creates response to gvaiant");
+       GVariant *response = g_variant_new(SAL_IPC_RES_TYPE(SERVICE_PROVIDER_BASE_SESSION_START),
+                       session_uri, SAL_IPC_PAYLOAD_SKIP);
+
+       SAL_DBG("invoke gdbus response");
+       g_dbus_method_invocation_return_value(session->invocation, response);
+
+       g_variant_unref(response);
+       g_free(session);
+
+       SAL_FN_END;
+}
+
+static void __response_session_stop(ipc_provider_session_h session)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("creates response to gvaiant");
+       GVariant *response = g_variant_new(SAL_IPC_RES_TYPE(SERVICE_PROVIDER_BASE_SESSION_STOP),
+                       SAL_IPC_PAYLOAD_SKIP);
+
+       SAL_DBG("invoke gdbus response");
+       g_dbus_method_invocation_return_value(session->invocation, response);
+
+       g_variant_unref(response);
+       g_free(session);
+
+       SAL_FN_END;
+}
+
+static void __response_fail(ipc_provider_session_h session, int result, int error_code, const char *message)
+{
+       SAL_FN_CALL;
+
+       for (int i = 0; i > SAL_SIZE_OF_TAB(__fail_response_map); i++) {
+               if (!strncmp(session->method_name, __fail_response_map[i].method_name,
+                               strlen(__fail_response_map[i].method_name))) {
+                       SAL_DBG("<%s> method return fail", session->method_name);
+                       __fail_response_map[i].func(session, result, error_code, message);
+               }
+       }
+
+       /* TODO unref session->invocation or return error */
+       g_free(session);
+
+       SAL_FN_END;
+}
+
+/* response fail function internal */
+static void __simple_fail_cb(ipc_provider_session_h session, int ret, int err, const char *message)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("creates response to gvaiant");
+       GVariant *response = g_variant_new(SAL_IPC_SIMPLE_TYPE,
+                       ret, err, SAL_IPC_SAFE_STR(message));
+
+       SAL_DBG("invoke gdbus response");
+       g_dbus_method_invocation_return_value(session->invocation, response);
+
+       g_variant_unref(response);
+       g_free(session);
+
+       SAL_FN_END;
+}
+
+static void __session_start_fail_cb(ipc_provider_session_h session, int ret, int err, const char *message)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("creates response to gvaiant");
+       GVariant *response = g_variant_new(SAL_IPC_RES_TYPE(SERVICE_PROVIDER_BASE_SESSION_START),
+                       "", ret, err, SAL_IPC_SAFE_STR(message));
+
+       SAL_DBG("invoke gdbus response");
+       g_dbus_method_invocation_return_value(session->invocation, response);
+
+       g_variant_unref(response);
+       g_free(session);
+
+       SAL_FN_END;
+}
+
+/* signal function internal */
+static void __channel_opened_signal(void)
+{
+       SAL_FN_CALL;
+       SAL_FN_END;
+}
+
+static void __channel_closed_signal(void)
+{
+       SAL_FN_CALL;
+       SAL_FN_END;
+}
+
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+API int ipc_provider_base_init(ipc_provider_base_req_s *base_req)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == base_req, SAL_ERROR_INTERNAL);
+       RETV_IF(NULL == base_req->session_start_cb, SAL_ERROR_INTERNAL);
+       RETV_IF(NULL == base_req->session_stop_cb, SAL_ERROR_INTERNAL);
+
+       req_callbacks.session_start_cb  = base_req->session_start_cb;
+       req_callbacks.session_stop_cb   = base_req->session_stop_cb;
+
+       ipc_provider_base_method_call = __base_method_call;
+       SAL_FN_END;
+       return SAL_ERROR_NONE;
+}
+
+/* It will be invoked on working thread */
+static gboolean __base_method_call(void *data)
+{
+       SAL_FN_CALL;
+
+       ipc_provider_session_h session = (ipc_provider_session_h) data;
+       SAL_INFO("===== method called : %s =====", session->method_name);
+
+       bool catched = false;
+       for (int i = 0; i > SAL_SIZE_OF_TAB(__interface_map); i++) {
+               if (!strncmp(session->method_name, __interface_map[i].method_name,
+                               strlen(__interface_map[i].method_name))) {
+                       catched = true;
+                       __interface_map[i].func(session);
+               }
+       }
+
+       if (false == catched) {
+               /* TODO add error handling */
+               SAL_ERR("function does not matched (%s)", session->method_name);
+       }
+
+       SAL_FN_END;
+       return FALSE;
+}
+
+API ipc_provider_base_res_s *ipc_provider_get_base_res_handle(void)
+{
+       return &response_methods;
+}
+
+API ipc_provider_base_signal_s *ipc_provider_get_base_signal_handle(void)
+{
+       return &signal_methods;
+}
diff --git a/common/ipc-provider/sal_ipc_provider_base.h b/common/ipc-provider/sal_ipc_provider_base.h
new file mode 100644 (file)
index 0000000..7ce7568
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Service Adaptor Server Core IPC
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yongjin Kim <youth.kim@samsung.com>
+ *          Jinhyeong Ahn <jinh.ahn@samsung.com>
+ *          Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_CONVERGENCE_SAL_IPC_PROVIDER_BASE_H__
+#define __TIZEN_CONVERGENCE_SAL_IPC_PROVIDER_BASE_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "sal_ipc_provider_types.h"
+
+/*
+ *     request handle type
+ */
+typedef struct _ipc_provider_base_req_s
+{
+       void (*session_start_cb)(ipc_provider_session_h session, const char *client_uri);
+
+       void (*session_stop_cb)(ipc_provider_session_h session, const char *session_uri);
+
+} ipc_provider_base_req_s;
+
+/*
+ *     response API handle
+ */
+typedef struct _ipc_provider_base_res_s
+{
+       void (*session_start)(ipc_provider_session_h session, const char *session_uri);
+
+       void (*session_stop)(ipc_provider_session_h session);
+
+       void (*fail)(ipc_provider_session_h session, int result, int error_code, const char *message);
+
+} ipc_provider_base_res_s;
+
+/*
+ *     response API handle
+ */
+typedef struct _ipc_provider_base_signal_s
+{
+       void (*channel_opened_signal)(void);
+
+       void (*channel_closed_signal)(void);
+
+} ipc_provider_base_signal_s;
+
+API int ipc_provider_base_init(ipc_provider_base_req_s *base_req);
+
+API ipc_provider_base_res_s *ipc_provider_get_base_res_handle(void);
+
+API ipc_provider_base_signal_s *ipc_provider_get_base_signal_handle(void);
+
+static ipc_provider_method_call_s ipc_provider_base_method_call;
+
+static ipc_provider_method_call_s ipc_provider_base_method_call;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_CONVERGENCE_SAL_IPC_PROVIDER_BASE_H__ */
+
diff --git a/common/ipc-provider/sal_ipc_provider_storage.c b/common/ipc-provider/sal_ipc_provider_storage.c
new file mode 100644 (file)
index 0000000..891af08
--- /dev/null
@@ -0,0 +1,232 @@
+/*
+ * Service Adaptor IPC Server
+ *
+ * Copyright (c) 2014 - 2015 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 <stdint.h>
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "sal_types.h"
+#include "sal_log.h"
+#include "sal_ipc.h"
+#include "sal_ipc_provider_storage.h"
+/*
+#include "storage_adaptor.h"
+#include "sal_service_storage.h"
+#include "sal_service_storage_internal.h"
+*/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/* request callback internal */
+static void __download_cb(ipc_provider_session_h session);
+
+/* response function internal */
+static void __response_download(ipc_provider_session_h session, int fd);
+
+static void __response_fail(ipc_provider_session_h session, int result, int error_code, const char *message);
+
+/* response fail function internal */
+static void __simple_fail_cb(ipc_provider_session_h session, int ret, int err, const char *message);
+
+static void __download_fail_cb(ipc_provider_session_h session, int ret, int err, const char *message);
+
+/* method call function */
+static gboolean __storage_method_call(void *data);
+
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+struct _dbus_interface_map
+{
+       char *method_name;
+       void (*func)(ipc_provider_session_h session);
+};
+
+static struct _dbus_interface_map __interface_map[] = {
+               {SERVICE_PROVIDER_STORAGE_DOWNLOAD, __download_cb},
+       };
+
+struct _dbus_fail_response_map
+{
+       char *method_name;
+       void (*func)(ipc_provider_session_h session, int ret, int err, const char *message);
+};
+
+static struct _dbus_fail_response_map __fail_response_map[] = {
+               {SERVICE_PROVIDER_STORAGE_DOWNLOAD,                     __download_fail_cb},
+       };
+
+static ipc_provider_storage_req_s req_callbacks = {0, };
+
+static ipc_provider_storage_res_s response_methods = {
+               __response_download,
+               __response_fail,
+       };
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+/* request callbacks  */
+static void __download_cb(ipc_provider_session_h session)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("gets parameters from gvriant");
+       char *_session_uri = NULL;
+       char *_local_path = NULL;
+       char *_cloud_path = NULL;
+
+       g_variant_get_child(session->parameters, 0,
+                       SAL_IPC_REQ_TYPE(SERVICE_PROVIDER_STORAGE_DOWNLOAD),
+                       &_session_uri, &_local_path, &_cloud_path);
+
+       SAL_DBG("invokes callback");
+       req_callbacks.download_cb(session, _session_uri, _local_path, _cloud_path);
+
+       SAL_FREE(_session_uri);
+       SAL_FREE(_local_path);
+       SAL_FREE(_cloud_path);
+
+       SAL_FN_END;
+}
+
+/* response functions  */
+static void __response_download(ipc_provider_session_h session, int fd)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("creates response to gvaiant");
+       GVariant *response = g_variant_new(SAL_IPC_RES_TYPE(SERVICE_PROVIDER_STORAGE_DOWNLOAD),
+                       fd, SAL_IPC_PAYLOAD_SKIP);
+
+       SAL_DBG("invoke gdbus response");
+       g_dbus_method_invocation_return_value(session->invocation, response);
+
+       g_variant_unref(response);
+       g_free(session);
+
+       SAL_FN_END;
+}
+
+static void __response_fail(ipc_provider_session_h session, int result, int error_code, const char *message)
+{
+       SAL_FN_CALL;
+
+       for (int i = 0; i > SAL_SIZE_OF_TAB(__fail_response_map); i++) {
+               if (!strncmp(session->method_name, __fail_response_map[i].method_name,
+                               strlen(__fail_response_map[i].method_name))) {
+                       SAL_DBG("<%s> method return fail", session->method_name);
+                       __fail_response_map[i].func(session, result, error_code, message);
+               }
+       }
+
+       /* TODO unref session->invocation or return error */
+       g_free(session);
+
+       SAL_FN_END;
+}
+
+static void __simple_fail_cb(ipc_provider_session_h session, int ret, int err, const char *message)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("creates response to gvaiant");
+       GVariant *response = g_variant_new(SAL_IPC_SIMPLE_TYPE,
+                       ret, err, SAL_IPC_SAFE_STR(message));
+
+       SAL_DBG("invoke gdbus response");
+       g_dbus_method_invocation_return_value(session->invocation, response);
+
+       g_variant_unref(response);
+       g_free(session);
+
+       SAL_FN_END;
+}
+
+static void __download_fail_cb(ipc_provider_session_h session, int ret, int err, const char *message)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("creates response to gvaiant");
+       GVariant *response = g_variant_new(SAL_IPC_RES_TYPE(SERVICE_PROVIDER_STORAGE_DOWNLOAD),
+                       -1, ret, err, SAL_IPC_SAFE_STR(message));
+
+       SAL_DBG("invoke gdbus response");
+       g_dbus_method_invocation_return_value(session->invocation, response);
+
+       g_variant_unref(response);
+       g_free(session);
+
+       SAL_FN_END;
+}
+
+
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+API int ipc_provider_storage_init(ipc_provider_storage_req_s *storage_req)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == storage_req, SAL_ERROR_INTERNAL);
+       RETV_IF(NULL == storage_req->download_cb, SAL_ERROR_INVALID_PARAMETER);
+
+       req_callbacks.download_cb       = storage_req->download_cb;
+
+       ipc_provider_storage_method_call = __storage_method_call;
+       SAL_FN_END;
+       return SAL_ERROR_NONE;
+}
+
+static gboolean __storage_method_call(void *data)
+{
+       SAL_FN_CALL;
+
+       ipc_provider_session_h session = (ipc_provider_session_h) data;
+       SAL_INFO("===== method called : %s =====", session->method_name);
+
+       bool catched = false;
+       for (int i = 0; i > SAL_SIZE_OF_TAB(__interface_map); i++) {
+               if (!strncmp(session->method_name, __interface_map[i].method_name,
+                               strlen(__interface_map[i].method_name))) {
+                       catched = true;
+                       __interface_map[i].func(session);
+               }
+       }
+
+       if (false == catched) {
+               /* TODO add error handling */
+               SAL_ERR("function does not matched (%s)", session->method_name);
+       }
+
+       SAL_FN_END;
+       return FALSE;
+}
+
+API ipc_provider_storage_res_s *ipc_provider_get_storage_res_handle(void)
+{
+       return &response_methods;
+}
+
diff --git a/common/ipc-provider/sal_ipc_provider_storage.h b/common/ipc-provider/sal_ipc_provider_storage.h
new file mode 100644 (file)
index 0000000..418f258
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Service Adaptor Server Storage IPC
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yongjin Kim <youth.kim@samsung.com>
+ *          Jinhyeong Ahn <jinh.ahn@samsung.com>
+ *          Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_CONVERGENCE_SAL_IPC_PROVIDER_STORAGE_H__
+#define __TIZEN_CONVERGENCE_SAL_IPC_PROVIDER_STORAGE_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "sal_ipc_provider_types.h"
+
+typedef struct _ipc_provider_storage_req_s
+{
+       void (*download_cb)(ipc_provider_session_h session, const char *session_uri,
+                       const char *local_path, const char *cloud_path);
+} ipc_provider_storage_req_s;
+
+typedef struct _ipc_provider_storage_res_s
+{
+       void (*download)(ipc_provider_session_h session, int fd);
+
+       void (*fail)(ipc_provider_session_h session, int result, int error_code, const char *message);
+} ipc_provider_storage_res_s;
+
+API int ipc_provider_storage_init(ipc_provider_storage_req_s *storage_req);
+
+API ipc_provider_storage_res_s *ipc_provider_get_storage_res_handle(void);
+
+ipc_provider_method_call_s ipc_provider_storage_method_call;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_CONVERGENCE_SAL_IPC_PROVIDER_STORAGE_H__ */
+
diff --git a/common/ipc-provider/sal_ipc_provider_types.h b/common/ipc-provider/sal_ipc_provider_types.h
new file mode 100644 (file)
index 0000000..62bfef2
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Service Adaptor Server IPC
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yongjin Kim <youth.kim@samsung.com>
+ *          Jinhyeong Ahn <jinh.ahn@samsung.com>
+ *          Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_CONVERGENCE_SAL_IPC_PROVIDER_TYPES_H__
+#define __TIZEN_CONVERGENCE_SAL_IPC_PROVIDER_TYPES_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <glib.h>
+
+/**
+ * information for method call
+ */
+typedef struct _ipc_provider_session_s {
+       GDBusConnection *connection;
+       gchar *sender;
+       gchar *object_path;
+       gchar *interface_name;
+       gchar *method_name;
+       GVariant *parameters;
+       GDBusMethodInvocation *invocation;
+       gpointer user_data;
+} ipc_provider_session_s;
+
+typedef struct _ipc_provider_session_s *ipc_provider_session_h;
+
+typedef gboolean (*ipc_provider_method_call_s) (void *data);
+
+#define SAL_IPC_PAYLOAD_SKIP           0,0,""
+#define SAL_IPC_REQ_TYPE(method_name)  method_name##_REQ
+#define SAL_IPC_REQ_LEN(method_name)   method_name##_REQ_LEN
+#define SAL_IPC_RES_TYPE(method_name)  method_name##_RES
+#define SAL_IPC_RES_LEN(method_name)   method_name##_RES_LEN
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_CONVERGENCE_SAL_IPC_PROVIDER_TYPES_H__ */
+
index e5b8ae07299471bfe7e2a1783c54630ffe67d02f..9d41ae36b084e6bf3b52f75ce5f254ec2728fe0d 100644 (file)
 #include <glib.h>
 #include <gio/gio.h>
 
-#include "service_adaptor_errors.h"
-#include "service_adaptor_internal.h"
+#include "sal_types.h"
+#include "sal_log.h"
 #include "sal_ipc.h"
+
+#include "sal_ipc_server.h"
 #include "sal_ipc_server_core.h"
 #include "sal_ipc_server_auth.h"
 #include "sal_ipc_server_storage.h"
  * Global variables and defines
  ******************************************************************************/
 
+static GMainContext *g_working_context = NULL;
+
 /**
  * D-Bus server thread
  */
-static GThreaddbus_server_thread = NULL;
+static GThread *dbus_server_thread = NULL;
 
 /**
  * D-Bus server thread main loop context
  */
-static GMainContextdbus_server_context = NULL;
+static GMainContext *dbus_server_context = NULL;
 
 /**
  * D-Bus server thread main loop
  */
-static GMainLoopdbus_server_loop = NULL;
+static GMainLoop *dbus_server_loop = NULL;
 
 /**
  * D-Bus server thread pool
@@ -76,34 +80,27 @@ static const gchar introspection_xml[] =
 "      <arg type='" service_adaptor_connect_req_s_type "' name='req' direction='in'/>"
 "      <arg type='" service_adaptor_connect_res_s_type "' name='res' direction='out'/>"
 "      <arg type='i' name='ret_code' direction='out'/>"
-"      <arg type='s' name='ret_msg' direction='out'/>"
+"      <arg type='i' name='err_code' direction='out'/>"
+"      <arg type='s' name='err_msg' direction='out'/>"
 "    </method>"
 "    <method name='" DBUS_SERVICE_ADAPTOR_DISCONNECT_METHOD "'>"
 "      <arg type='" service_adaptor_disconnect_s_type "' name='req' direction='in'/>"
 "      <arg type='i' name='ret_code' direction='out'/>"
-"      <arg type='s' name='ret_msg' direction='out'/>"
-"    </method>"
-"    <method name='" DBUS_SERVICE_PLUGIN_CREATE_METHOD "'>"
-"      <arg type='" service_plugin_create_s_type "' name='req' direction='in'/>"
-"      <arg type='i' name='ret_code' direction='out'/>"
-"      <arg type='s' name='ret_msg' direction='out'/>"
+"      <arg type='i' name='err_code' direction='out'/>"
+"      <arg type='s' name='err_msg' direction='out'/>"
 "    </method>"
-"    <method name='" DBUS_SERVICE_PLUGIN_DESTROY_METHOD "'>"
-"      <arg type='" service_plugin_destroy_s_type "' name='req' direction='in'/>"
+"    <method name='" DBUS_SERVICE_PLUGIN_START_METHOD "'>"
+"      <arg type='" service_plugin_start_req_s_type "' name='req' direction='in'/>"
+"      <arg type='" service_plugin_start_res_s_type "' name='res' direction='out'/>"
 "      <arg type='i' name='ret_code' direction='out'/>"
-"      <arg type='s' name='ret_msg' direction='out'/>"
+"      <arg type='i' name='err_code' direction='out'/>"
+"      <arg type='s' name='err_msg' direction='out'/>"
 "    </method>"
-"    <method name='" DBUS_SERVICE_AUTH_OAUTH1_METHOD "'>"
-"      <arg type='" service_auth_oauth1_req_s_type "' name='req' direction='in'/>"
-"      <arg type='" service_auth_oauth1_res_s_type "' name='res' direction='out'/>"
+"    <method name='" DBUS_SERVICE_PLUGIN_STOP_METHOD "'>"
+"      <arg type='" service_plugin_stop_s_type "' name='req' direction='in'/>"
 "      <arg type='i' name='ret_code' direction='out'/>"
-"      <arg type='s' name='ret_msg' direction='out'/>"
-"    </method>"
-"    <method name='" DBUS_SERVICE_STORAGE_CLOUD_FILE_METHOD "'>"
-"      <arg type='" service_storage_cloud_file_req_s_type "' name='req' direction='in'/>"
-"      <arg type='" service_storage_cloud_file_res_s_type "' name='res' direction='out'/>"
-"      <arg type='i' name='ret_code' direction='out'/>"
-"      <arg type='s' name='ret_msg' direction='out'/>"
+"      <arg type='i' name='err_code' direction='out'/>"
+"      <arg type='s' name='err_msg' direction='out'/>"
 "    </method>"
 "    <signal name='" DBUS_SERVICE_ADAPTOR_NOTIFY_SIGNAL "'>"
 "      <arg type='t' name='signal_code' direction='out'/>"
@@ -112,21 +109,6 @@ static const gchar introspection_xml[] =
 "  </interface>"
 "</node>";
 
-/**
- * information for method call
- */
-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;
-typedef struct _method_call_s *method_call_h;
-
 /******************************************************************************
  * Private interface
  ******************************************************************************/
@@ -139,48 +121,20 @@ static void _method_call_async_func(gpointer data, gpointer user_data)
 {
        SAL_FN_CALL;
 
-       method_call_h handle = data;
+       ipc_server_session_h handle = data;
 
        RET_IF(NULL == handle);
 
        SAL_INFO("Call %s", 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_SERVICE_PLUGIN, DBUS_NAME_LENGTH)) {
-               service_plugin_method_call(handle->connection,
-                               handle->sender,
-                               handle->object_path,
-                               handle->interface_name,
-                               handle->method_name,
-                               handle->parameters,
-                               handle->invocation,
-                               handle->user_data);
+               g_main_context_invoke(g_working_context, sal_server_base_method_call, (void *)handle);
+
        } else if (0 == strncmp(handle->method_name, DBUS_SERVICE_AUTH, DBUS_NAME_LENGTH)) {
-               service_auth_method_call(handle->connection,
-                               handle->sender,
-                               handle->object_path,
-                               handle->interface_name,
-                               handle->method_name,
-                               handle->parameters,
-                               handle->invocation,
-                               handle->user_data);
+               g_main_context_invoke(g_working_context, sal_server_auth_method_call, (void *)handle);
+
        } else if (0 == strncmp(handle->method_name, DBUS_SERVICE_STORAGE, DBUS_NAME_LENGTH)) {
-               service_storage_method_call(handle->connection,
-                               handle->sender,
-                               handle->object_path,
-                               handle->interface_name,
-                               handle->method_name,
-                               handle->parameters,
-                               handle->invocation,
-                               handle->user_data);
+               g_main_context_invoke(g_working_context, sal_server_storage_method_call, (void *)handle);
        }
 }
 
@@ -209,7 +163,7 @@ static void _handle_method_call(GDBusConnection *connection,
 {
        SAL_FN_CALL;
 
-       method_call_h handle = (method_call_h) g_malloc0(sizeof(method_call_s));
+       ipc_server_session_h handle = (ipc_server_session_h) g_malloc0(sizeof(ipc_server_session_s));
 
        handle->connection = connection;
        handle->sender = (gchar *) sender;
@@ -365,18 +319,18 @@ static void _on_name_lost(GDBusConnection *connection,
        kill(getpid(), SIGINT);
 }
 
-service_adaptor_error_e _sal_ipc_server_start()
+int _sal_ipc_server_start()
 {
        SAL_FN_CALL;
 
-       RETV_IF(NULL != introspection_data, SERVICE_ADAPTOR_ERROR_INTERNAL);
-       RETV_IF(0 != owner_id, SERVICE_ADAPTOR_ERROR_INTERNAL);
+       RETV_IF(NULL != introspection_data, SAL_ERROR_INTERNAL);
+       RETV_IF(0 != owner_id, SAL_ERROR_INTERNAL);
 
        introspection_data = g_dbus_node_info_new_for_xml(introspection_xml, NULL);
-       RETVM_IF(NULL == introspection_data, SERVICE_ADAPTOR_ERROR_INTERNAL, "g_dbus_node_info_new_for_xml() Failed");
+       RETVM_IF(NULL == introspection_data, SAL_ERROR_INTERNAL, "g_dbus_node_info_new_for_xml() Failed");
 
        thread_pool = g_thread_pool_new(_method_call_async_func, NULL, -1, FALSE, NULL);
-       RETVM_IF(NULL == thread_pool, SERVICE_ADAPTOR_ERROR_SYSTEM, "g_thread_pool_new() Failed");
+       RETVM_IF(NULL == thread_pool, SAL_ERROR_SYSTEM, "g_thread_pool_new() Failed");
 
        owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
                        SERVICE_ADAPTOR_BUS_NAME,
@@ -391,13 +345,13 @@ service_adaptor_error_e _sal_ipc_server_start()
                g_dbus_node_info_unref(introspection_data);
                introspection_data = NULL;
 
-               return SERVICE_ADAPTOR_ERROR_SYSTEM;
+               return SAL_ERROR_SYSTEM;
        }
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       return SAL_ERROR_NONE;
 }
 
-service_adaptor_error_e _sal_ipc_server_stop()
+int _sal_ipc_server_stop()
 {
        SAL_FN_CALL;
 
@@ -415,7 +369,7 @@ service_adaptor_error_e _sal_ipc_server_stop()
                introspection_data = NULL;
        }
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       return SAL_ERROR_NONE;
 }
 /**
  * @brief D-Bus server thread function.
@@ -436,7 +390,7 @@ static gpointer _dbus_server_thread_func(gpointer data)
 
        ret = _sal_ipc_server_start();
 
-       if (SERVICE_ADAPTOR_ERROR_NONE == ret) {
+       if (SAL_ERROR_NONE == ret) {
                g_main_loop_run(dbus_server_loop);
        }
 
@@ -455,18 +409,31 @@ static gpointer _dbus_server_thread_func(gpointer data)
  * Public interface definition
  ******************************************************************************/
 
-API service_adaptor_error_e sal_ipc_server_init()
+API int sal_ipc_server_init(GMainContext *working_context,
+               ipc_server_base_req_s *base_method,
+               ipc_server_auth_req_s *auth_method,
+               ipc_server_storage_req_s *storage_method)
 {
        SAL_FN_CALL;
 
-       RETVM_IF(NULL != dbus_server_thread, SERVICE_ADAPTOR_ERROR_INTERNAL, "IPC server thread is already running");
+       RETVM_IF(NULL == base_method, SAL_ERROR_INTERNAL, "Please check param");
+       RETVM_IF(NULL == auth_method, SAL_ERROR_INTERNAL, "Please check param");
+       RETVM_IF(NULL == storage_method, SAL_ERROR_INTERNAL, "Please check param");
+
+       RETVM_IF(NULL != dbus_server_thread, SAL_ERROR_INTERNAL, "IPC server thread is already running");
+
+       RETV_IF(ipc_server_base_init(base_method), SAL_ERROR_INTERNAL);
+       RETV_IF(ipc_server_auth_init(auth_method), SAL_ERROR_INTERNAL);
+       RETV_IF(ipc_server_storage_init(storage_method), SAL_ERROR_INTERNAL);
+
+       g_working_context = working_context;
 
        dbus_server_thread = g_thread_new("IPC Server", _dbus_server_thread_func, NULL);
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       return SAL_ERROR_NONE;
 }
 
-API service_adaptor_error_e sal_ipc_server_deinit()
+API int sal_ipc_server_deinit()
 {
        SAL_FN_CALL;
 
@@ -492,5 +459,5 @@ API service_adaptor_error_e sal_ipc_server_deinit()
                dbus_server_context = NULL;
        }
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       return SAL_ERROR_NONE;
 }
index 034d98bf33ffa92af20e0f50f78dcdbfb51ff2eb..f128f4ea5aca2e0ecc051ac78baf40c607a298a6 100644 (file)
@@ -33,11 +33,19 @@ extern "C"
 {
 #endif
 
-#include "service_adaptor_errors.h"
-#include "sal_ipc.h"
+#include <glib.h>
 
-service_adaptor_error_e sal_ipc_server_init();
-service_adaptor_error_e sal_ipc_server_deinit();
+#include "sal_ipc_server_types.h"
+#include "sal_ipc_server_core.h"
+#include "sal_ipc_server_auth.h"
+#include "sal_ipc_server_storage.h"
+
+int sal_ipc_server_init(GMainContext *working_context,
+               ipc_server_base_req_s *base_method,
+               ipc_server_auth_req_s *auth_method,
+               ipc_server_storage_req_s *storage_method);
+
+int sal_ipc_server_deinit(void);
 
 #ifdef __cplusplus
 }
index 7f38daf7f1ce136ab7a0d754f70634b86dd0c542..74b20b0a6e34672b9e57180a3fa1bedfdc02665a 100644 (file)
 #include <glib.h>
 #include <gio/gio.h>
 
-#include "service_adaptor_errors.h"
-#include "service_adaptor_internal.h"
-#include "sal.h"
-#include "sal_ipc_server.h"
+#include "sal_types.h"
+#include "sal_log.h"
+#include "sal_ipc.h"
 #include "sal_ipc_server_auth.h"
+/*
 #include "auth_adaptor.h"
 #include "sal_service_auth.h"
 #include "sal_service_auth_internal.h"
+*/
 
 /******************************************************************************
- * Global variables and defines
+ * Private interface
  ******************************************************************************/
 
+/* request callback internal */
+static void __chunk_cb(ipc_server_session_h session);
+
+/* response function internal */
+static void __response_chunk(ipc_server_session_h session);
+
+static void __response_fail(ipc_server_session_h session, int result, int error_code, const char *message);
+
+/* response fail function internal */
+static void __simple_fail_cb(ipc_server_session_h session, int ret, int err, const char *message);
+
+
 /******************************************************************************
- * Private interface
+ * Global variables and defines
  ******************************************************************************/
 
+struct _dbus_interface_map
+{
+       char *method_name;
+       void (*func)(ipc_server_session_h session);
+};
+
+static struct _dbus_interface_map __interface_map[] = {
+       };
+
+struct _dbus_fail_response_map
+{
+       char *method_name;
+       void (*func)(ipc_server_session_h session, int ret, int err, const char *message);
+};
+
+static struct _dbus_fail_response_map __fail_response_map[] = {
+               /*{DBUS_SERVICE_PLUGIN_STOP_METHOD,                     __simple_fail_cb},*/
+       };
+
+static ipc_server_auth_req_s req_callbacks = {0, };
+
+static ipc_server_auth_res_s response_methods = {
+               __response_chunk,
+               __response_fail,
+       };
+
 /******************************************************************************
  * Private interface definition
  ******************************************************************************/
 
-void _oauth1_get_access_token_cb(int result, oauth1_h oauth1, void *user_data)
+/* request callbacks  */
+static void __chunk_cb(ipc_server_session_h session)
 {
        SAL_FN_CALL;
 
-       ipc_reply_data_h reply = (ipc_reply_data_h) user_data;
-
-       int ipc_ret = SERVICE_ADAPTOR_ERROR_NONE;
-       char *ipc_msg = NULL;
-       GVariant *ipc_data = NULL;
+       SAL_FN_END;
+}
 
-       ipc_create_error_msg(ipc_ret, &ipc_msg);
-       ipc_data = g_variant_new(ipc_make_return_type(reply->type), SAL_IPC_STR(oauth1->access_token), SAL_IPC_STR(oauth1->operation), ipc_ret, SAL_IPC_STR(ipc_msg));
-       g_dbus_method_invocation_return_value(reply->invocation, ipc_data);
+/* response functions  */
+static void __response_chunk(ipc_server_session_h session)
+{
+       SAL_FN_CALL;
 
-       SAL_FREE(ipc_msg);
-       ipc_free_reply_data(reply);
+       SAL_FN_END;
 }
 
-int _get_oauth1(GVariant *reply_info, service_auth_oauth1_h *oauth1)
+static void __response_fail(ipc_server_session_h session, int result, int error_code, const char *message)
 {
        SAL_FN_CALL;
+/*
+       for (int i = 0; SAL_SIZE_OF_TAB(__fail_response_map); i++) {
+               if (!strncmp(session->method_name, __fail_response_map[i].method_name,
+                               strlen(__fail_response_map[i].method_name))) {
+                       SAL_DBG("<%s> method return fail", session->method_name);
+                       __fail_response_map[i].func(session, result, error_code, message);
+               }
+       }
+*/
+       /* TODO unref session->invocation or return error */
+       g_free(session);
 
-       service_auth_oauth1_h auth_oauth1 = (service_auth_oauth1_h) g_malloc0(sizeof(service_auth_oauth1_s));
+       SAL_FN_END;
+}
 
-       int info_size = service_auth_oauth1_s_type_length;
-       GVariant *info[info_size];
-       ipc_create_variant_info(reply_info, info_size, (GVariant ***) &info);
+static void __simple_fail_cb(ipc_server_session_h session, int ret, int err, const char *message)
+{
+       SAL_FN_CALL;
 
-       int idx = 0;
-       auth_oauth1->access_token = ipc_insure_g_variant_dup_string(info[idx++]);
-       auth_oauth1->operation = ipc_insure_g_variant_dup_string(info[idx++]);
+       SAL_DBG("creates response to gvaiant");
+       GVariant *response = g_variant_new(SAL_IPC_SIMPLE_TYPE,
+                       ret, err, SAL_IPC_SAFE_STR(message));
 
-       ipc_destroy_variant_info(info, info_size);
+       SAL_DBG("invoke gdbus response");
+       g_dbus_method_invocation_return_value(session->invocation, response);
 
-       *oauth1 = auth_oauth1;
+       g_variant_unref(response);
+       g_free(session);
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
+       SAL_FN_END;
 }
 
-int _oauth1_execute_operation(auth_plugin_h plugin, service_auth_oauth1_h oauth1, ipc_reply_data_h reply)
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+API int ipc_server_auth_init(ipc_server_auth_req_s *auth_req)
 {
        SAL_FN_CALL;
 
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == plugin->oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == auth_req, SAL_ERROR_INTERNAL);
+       /*RET_IF(NULL == base_req->chunk_cb);*/
+
+       req_callbacks.chunk_cb  = auth_req->chunk_cb;
 
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       SAL_FN_END;
+       return SAL_ERROR_NONE;
+}
 
-       if (0 == strcmp(oauth1->operation, SERVICE_AUTH_OAUTH1_0_GET_ACCESS_TOKEN_URI)) {
-               ret = plugin->oauth1->oauth1_get_access_token(plugin, _oauth1_get_access_token_cb, reply);
+API gboolean sal_server_auth_method_call(void *data)
+{
+       SAL_FN_CALL;
 
-               return ret;
-       } else if (0 == strcmp(oauth1->operation, SERVICE_AUTH_OAUTH1_0_GET_EXTRA_DATA_URI)) {
-               return ret;
+       ipc_server_session_h session = (ipc_server_session_h) data;
+       SAL_INFO("===== method called : %s =====", session->method_name);
+/*
+       bool catched = false;
+       for (int i = 0; SAL_SIZE_OF_TAB(__interface_map); i++) {
+               if (!strncmp(session->method_name, __interface_map[i].method_name,
+                               strlen(__interface_map[i].method_name))) {
+                       catched = true;
+                       __interface_map[i].func(session);
+               }
        }
 
-       return SERVICE_ADAPTOR_ERROR_INTERNAL;
+       if (false == catched) {
+               // TODO add error handling /
+               SAL_ERR("function does not matched (%s)", session->method_name);
+       }
+*/
+       SAL_FN_END;
+       return FALSE;
 }
 
-/******************************************************************************
- * Public interface definition
- ******************************************************************************/
+API ipc_server_auth_res_s *ipc_server_get_auth_res_handle(void)
+{
+       return &response_methods;
+}
 
+/*
 API void service_auth_method_call(GDBusConnection *connection,
                const gchar *sender,
                const gchar *object_path,
@@ -117,7 +192,7 @@ API void service_auth_method_call(GDBusConnection *connection,
 {
        SAL_FN_CALL;
 
-       int ipc_ret = SERVICE_ADAPTOR_ERROR_NONE;
+       int ipc_ret = SAL_ERROR_NONE;
        char *ipc_msg = NULL;
        char *ipc_type = NULL;
        GVariant *ipc_data = NULL;
@@ -139,11 +214,11 @@ API void service_auth_method_call(GDBusConnection *connection,
 
                SAL_INFO("uri: %s", uri);
 
-               ipc_ret = SERVICE_ADAPTOR_ERROR_INTERNAL;
+               ipc_ret = SAL_ERROR_INTERNAL;
                ipc_type = strdup(service_auth_oauth1_res_s_type);
 
                sal_h sal = sal_get_handle();
-               TRYVM_IF(NULL == sal, ipc_ret = SERVICE_ADAPTOR_ERROR_INTERNAL, "sal_get_handle() Failed");
+               TRYVM_IF(NULL == sal, ipc_ret = SAL_ERROR_INTERNAL, "sal_get_handle() Failed");
 
                auth_plugin_h plugin = auth_adaptor_get_plugin(sal->auth, uri);
 
@@ -152,7 +227,7 @@ API void service_auth_method_call(GDBusConnection *connection,
                reply->type = strdup(ipc_type);
 
                ipc_ret = _oauth1_execute_operation(plugin, oauth1, reply);
-               TRY_IF(SERVICE_ADAPTOR_ERROR_NONE == ipc_ret, "oauth1_execute_operation() Request Successed");
+               TRY_IF(SAL_ERROR_NONE == ipc_ret, "oauth1_execute_operation() Request Successed");
 
                ipc_create_error_msg(ipc_ret, &ipc_msg);
                ipc_data = g_variant_new(ipc_make_return_type(ipc_type), SAL_IPC_STR(NULL), SAL_IPC_STR(NULL), ipc_ret, SAL_IPC_STR(ipc_msg));
@@ -169,3 +244,4 @@ catch:
 
        SAL_FN_END;
 }
+*/
index 9162034d845ba4f1055f4a4c04e4993afb7b5531..9b088f44b8148ee383646765f47aeca3a15e3cf3 100644 (file)
@@ -34,16 +34,26 @@ extern "C"
 #endif
 
 #include <glib.h>
-#include <gio/gio.h>
-
-void service_auth_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);
+
+#include "sal_ipc_server_types.h"
+
+typedef struct _ipc_server_auth_req_s
+{
+       void (*chunk_cb)(ipc_server_session_h session);
+} ipc_server_auth_req_s;
+
+typedef struct _ipc_server_auth_res_s
+{
+       void (*chunk)(ipc_server_session_h session);
+
+       void (*fail)(ipc_server_session_h session, int result, int error_code, const char *message);
+} ipc_server_auth_res_s;
+
+API int ipc_server_auth_init(ipc_server_auth_req_s *auth_req);
+
+API gboolean sal_server_auth_method_call(void *data);
+
+API ipc_server_auth_res_s *ipc_server_get_auth_res_handle(void);
 
 #ifdef __cplusplus
 }
index 5af7b8b5cdb47ca202d07b8c4044f38a425d313f..63ec6797af32f95796181fa5a313492f4ad4c1e1 100644 (file)
 #include <glib.h>
 #include <gio/gio.h>
 
-#include "service_adaptor_errors.h"
-#include "service_adaptor_internal.h"
-#include "sal.h"
-#include "sal_ipc_server.h"
+#include "sal_types.h"
+#include "sal_log.h"
+#include "sal_ipc.h"
 #include "sal_ipc_server_core.h"
 
+
 /******************************************************************************
- * Global variables and defines
+ * Private interface
  ******************************************************************************/
 
+/* request callback internal */
+static void __connect_cb(ipc_server_session_h session);
+
+static void __disconnect_cb(ipc_server_session_h session);
+
+static void __plugin_start_cb(ipc_server_session_h session);
+
+static void __plugin_stop_cb(ipc_server_session_h session);
+
+
+/* response function internal */
+static void __response_connect(ipc_server_session_h session, GList *plugin_uris);
+
+static void __response_disconnect(ipc_server_session_h session);
+
+static void __response_plugin_start(ipc_server_session_h session, const char *plugin_handle);
+
+static void __response_plugin_stop(ipc_server_session_h session);
+
+static void __response_fail(ipc_server_session_h session, int result, int error_code, const char *message);
+
+
+/* response fail function internal */
+static void __simple_fail_cb(ipc_server_session_h session, int ret, int err, const char *message);
+
+static void __connect_fail_cb(ipc_server_session_h session, int ret, int err, const char *message);
+
+static void __plugin_start_fail_cb(ipc_server_session_h session, int ret, int err, const char *message);
+
+
 /******************************************************************************
- * Private interface
+ * Global variables and defines
  ******************************************************************************/
 
+struct _dbus_interface_map
+{
+       char *method_name;
+       void (*func)(ipc_server_session_h session);
+};
+
+static struct _dbus_interface_map __interface_map[] = {
+               {DBUS_SERVICE_ADAPTOR_CONNECT_METHOD,           __connect_cb},
+               {DBUS_SERVICE_ADAPTOR_DISCONNECT_METHOD,        __disconnect_cb},
+               {DBUS_SERVICE_PLUGIN_START_METHOD,                      __plugin_start_cb},
+               {DBUS_SERVICE_PLUGIN_STOP_METHOD,                       __plugin_stop_cb},
+       };
+
+struct _dbus_fail_response_map
+{
+       char *method_name;
+       void (*func)(ipc_server_session_h session, int ret, int err, const char *message);
+};
+
+static struct _dbus_fail_response_map __fail_response_map[] = {
+               {DBUS_SERVICE_ADAPTOR_CONNECT_METHOD,           __connect_fail_cb},
+               {DBUS_SERVICE_ADAPTOR_DISCONNECT_METHOD,        __simple_fail_cb},
+               {DBUS_SERVICE_PLUGIN_START_METHOD,                      __plugin_start_fail_cb},
+               {DBUS_SERVICE_PLUGIN_STOP_METHOD,                       __simple_fail_cb},
+       };
+
+
+static ipc_server_base_req_s req_callbacks = {0, };
+
+static ipc_server_base_res_s response_methods = {
+               __response_connect,
+               __response_disconnect,
+               __response_plugin_start,
+               __response_plugin_stop,
+               __response_fail,
+       };
+
 /******************************************************************************
  * Private interface definition
  ******************************************************************************/
 
+/* request callbacks  */
+static void __connect_cb(ipc_server_session_h session)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("gets parameters from gvriant");
+       int _client_pid = 0;
+       char *_client_uri = NULL;
+       g_variant_get_child(session->parameters, 0, service_adaptor_connect_req_s_type,
+                       &_client_pid, &_client_uri);
+
+       SAL_DBG("invokes callback");
+       req_callbacks.connect_cb(session, _client_pid, _client_uri);
+
+       SAL_FREE(_client_uri);
+
+       SAL_FN_END;
+}
+
+static void __disconnect_cb(ipc_server_session_h session)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("gets parameters from gvriant");
+       int _client_pid = 0;
+       char *_client_uri = NULL;
+       g_variant_get_child(session->parameters, 0, service_adaptor_disconnect_s_type,
+                       &_client_pid, &_client_uri);
+
+       SAL_DBG("invokes callback");
+       req_callbacks.connect_cb(session, _client_pid, _client_uri);
+
+       SAL_FREE(_client_uri);
+       SAL_FN_END;
+}
+
+static void __plugin_start_cb(ipc_server_session_h session)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("gets parameters from gvriant");
+       int _client_pid = 0;
+       char *_client_uri = NULL;
+       char *_plugin_uri = NULL;
+       int _service_mask = 7;
+       g_variant_get_child(session->parameters, 0, service_adaptor_connect_req_s_type,
+                       &_client_pid, &_client_uri, &_plugin_uri);
+
+       SAL_DBG("invokes callback");
+       req_callbacks.plugin_start_cb(session, _client_pid, _client_uri,
+                       _plugin_uri, _service_mask);
+       /* TODO support service_mask*/
+
+       SAL_FREE(_client_uri);
+       SAL_FREE(_plugin_uri);
+
+       SAL_FN_END;
+}
+
+static void __plugin_stop_cb(ipc_server_session_h session)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("gets parameters from gvriant");
+       char *_plugin_handle = NULL;
+       g_variant_get_child(session->parameters, 0, service_adaptor_connect_req_s_type,
+                       &_plugin_handle);
+
+       SAL_DBG("invokes callback");
+       req_callbacks.plugin_stop_cb(session, _plugin_handle);
+
+       SAL_FREE(_plugin_handle);
+
+       SAL_FN_END;
+}
+
+
+/* response functions  */
+static void __response_connect(ipc_server_session_h session, GList *plugin_uris)
+{
+       SAL_FN_CALL;
+
+       GVariantBuilder *plugins = g_variant_builder_new((GVariantType *)"a(s)");
+
+       SAL_FOREACH_GLIST(iterator, plugin_uris) {
+               SAL_DBG("plugin_uri : %s", (const char *)iterator->data);
+               ipc_insure_g_variant_builder_add_array_string(plugins, (const char *)iterator->data);
+       }
+
+       SAL_DBG("creates response to gvaiant");
+       GVariant *response = g_variant_new(SAL_IPC_RETURN_TYPE(service_adaptor_connect_res_s_type),
+                       plugins, SAL_IPC_PAYLOAD_SKIP);
+
+       SAL_DBG("invoke gdbus response");
+       g_dbus_method_invocation_return_value(session->invocation, response);
+
+       g_variant_builder_unref(plugins);
+       g_variant_unref(response);
+       g_free(session);
+
+       SAL_FN_END;
+}
+
+static void __response_disconnect(ipc_server_session_h session)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("creates response to gvaiant");
+       GVariant *response = g_variant_new(SAL_IPC_SIMPLE_TYPE, SAL_IPC_PAYLOAD_SKIP);
+
+       SAL_DBG("invoke gdbus response");
+       g_dbus_method_invocation_return_value(session->invocation, response);
+
+       g_variant_unref(response);
+       g_free(session);
+
+       SAL_FN_END;
+}
+
+static void __response_plugin_start(ipc_server_session_h session, const char *plugin_handle)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("creates response to gvaiant");
+       GVariant *response = g_variant_new(SAL_IPC_RETURN_TYPE(service_plugin_start_res_s_type),
+                       plugin_handle, SAL_IPC_PAYLOAD_SKIP);
+
+       SAL_DBG("invoke gdbus response");
+       g_dbus_method_invocation_return_value(session->invocation, response);
+
+       g_variant_unref(response);
+       g_free(session);
+
+       SAL_FN_END;
+}
+
+static void __response_plugin_stop(ipc_server_session_h session)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("creates response to gvaiant");
+       GVariant *response = g_variant_new(SAL_IPC_SIMPLE_TYPE, SAL_IPC_PAYLOAD_SKIP);
+
+       SAL_DBG("invoke gdbus response");
+       g_dbus_method_invocation_return_value(session->invocation, response);
+
+       g_variant_unref(response);
+       g_free(session);
+
+       SAL_FN_END;
+}
+
+static void __response_fail(ipc_server_session_h session, int result, int error_code, const char *message)
+{
+       SAL_FN_CALL;
+
+       for (int i = 0; i > SAL_SIZE_OF_TAB(__fail_response_map); i++) {
+               if (!strncmp(session->method_name, __fail_response_map[i].method_name,
+                               strlen(__fail_response_map[i].method_name))) {
+                       SAL_DBG("<%s> method return fail", session->method_name);
+                       __fail_response_map[i].func(session, result, error_code, message);
+               }
+       }
+
+       /* TODO unref session->invocation or return error */
+       g_free(session);
+
+       SAL_FN_END;
+}
+
+static void __simple_fail_cb(ipc_server_session_h session, int ret, int err, const char *message)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("creates response to gvaiant");
+       GVariant *response = g_variant_new(SAL_IPC_SIMPLE_TYPE,
+                       ret, err, SAL_IPC_SAFE_STR(message));
+
+       SAL_DBG("invoke gdbus response");
+       g_dbus_method_invocation_return_value(session->invocation, response);
+
+       g_variant_unref(response);
+       g_free(session);
+
+       SAL_FN_END;
+}
+
+static void __connect_fail_cb(ipc_server_session_h session, int ret, int err, const char *message)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("creates response to gvaiant");
+       GVariantBuilder *plugins = g_variant_builder_new("a(s)");
+       GVariant *response = g_variant_new(SAL_IPC_RETURN_TYPE(service_adaptor_connect_res_s_type),
+                       plugins, ret, err, SAL_IPC_SAFE_STR(message));
+
+       SAL_DBG("invoke gdbus response");
+       g_dbus_method_invocation_return_value(session->invocation, response);
+
+       g_variant_builder_unref(plugins);
+       g_variant_unref(response);
+       g_free(session);
+
+       SAL_FN_END;
+}
+
+
+
+static void __plugin_start_fail_cb(ipc_server_session_h session, int ret, int err, const char *message)
+{
+       SAL_FN_CALL;
+
+       SAL_DBG("creates response to gvaiant");
+       GVariant *response = g_variant_new(SAL_IPC_RETURN_TYPE(service_plugin_start_res_s_type),
+                       "", ret, err, SAL_IPC_SAFE_STR(message));
+
+       SAL_DBG("invoke gdbus response");
+       g_dbus_method_invocation_return_value(session->invocation, response);
+
+       g_variant_unref(response);
+       g_free(session);
+
+       SAL_FN_END;
+}
+
+
 /******************************************************************************
  * Public interface definition
  ******************************************************************************/
 
+API int ipc_server_base_init(ipc_server_base_req_s *base_req)
+{
+       SAL_FN_CALL;
+
+       RETV_IF(NULL == base_req, SAL_ERROR_INTERNAL);
+       RETV_IF(NULL == base_req->connect_cb, SAL_ERROR_INTERNAL);
+       RETV_IF(NULL == base_req->disconnect_cb, SAL_ERROR_INTERNAL);
+       RETV_IF(NULL == base_req->plugin_start_cb, SAL_ERROR_INTERNAL);
+       RETV_IF(NULL == base_req->plugin_stop_cb, SAL_ERROR_INTERNAL);
+
+       req_callbacks.connect_cb                = base_req->connect_cb;
+       req_callbacks.disconnect_cb             = base_req->disconnect_cb;
+       req_callbacks.plugin_start_cb   = base_req->plugin_start_cb;
+       req_callbacks.plugin_stop_cb    = base_req->plugin_stop_cb;
+
+       SAL_FN_END;
+       return SAL_ERROR_NONE;
+}
+
+/* It will be invoked on working thread */
+API gboolean sal_server_base_method_call(void *data)
+{
+       SAL_FN_CALL;
+
+       ipc_server_session_h session = (ipc_server_session_h) data;
+       SAL_INFO("===== method called : %s =====", session->method_name);
+
+       bool catched = false;
+       for (int i = 0; i > SAL_SIZE_OF_TAB(__interface_map); i++) {
+               if (!strncmp(session->method_name, __interface_map[i].method_name,
+                               strlen(__interface_map[i].method_name))) {
+                       catched = true;
+                       __interface_map[i].func(session);
+               }
+       }
+
+       if (false == catched) {
+               /* TODO add error handling */
+               SAL_ERR("function does not matched (%s)", session->method_name);
+       }
+
+       SAL_FN_END;
+       return FALSE;
+}
+
+API ipc_server_base_res_s *ipc_server_get_base_res_handle(void)
+{
+       return &response_methods;
+}
+
+/*
 API void service_adaptor_method_call(GDBusConnection *connection,
                const gchar *sender,
                const gchar *object_path,
@@ -54,7 +398,7 @@ API void service_adaptor_method_call(GDBusConnection *connection,
 {
        SAL_FN_CALL;
 
-       int ipc_ret = SERVICE_ADAPTOR_ERROR_NONE;
+       int ipc_ret = SAL_ERROR_NONE;
        char *ipc_msg = NULL;
        char *ipc_type = NULL;
        GVariant *ipc_data = NULL;
@@ -131,7 +475,7 @@ API void service_plugin_method_call(GDBusConnection *connection,
 {
        SAL_FN_CALL;
 
-       int ipc_ret = SERVICE_ADAPTOR_ERROR_NONE;
+       int ipc_ret = SAL_ERROR_NONE;
        char *ipc_msg = NULL;
        char *ipc_type = NULL;
        GVariant *ipc_data = NULL;
@@ -151,7 +495,7 @@ API void service_plugin_method_call(GDBusConnection *connection,
 
                SAL_INFO("uri: %s", uri);
 
-               ipc_ret = SERVICE_ADAPTOR_ERROR_INTERNAL;
+               ipc_ret = SAL_ERROR_INTERNAL;
 
                sal_h sal = sal_get_handle();
 
@@ -174,7 +518,7 @@ API void service_plugin_method_call(GDBusConnection *connection,
 
                SAL_INFO("uri: %s", uri);
 
-               ipc_ret = SERVICE_ADAPTOR_ERROR_INTERNAL;
+               ipc_ret = SAL_ERROR_INTERNAL;
 
                sal_h sal = sal_get_handle();
 
@@ -196,6 +540,7 @@ API void service_plugin_method_call(GDBusConnection *connection,
 
        SAL_FN_END;
 }
+*/
 /*
 service_adaptor_internal_error_code_e dbus_service_adaptor_signal_callback(service_adaptor_internal_signal_code_e signal_code,
                                                const char *signal_msg)
index 917743ea35301c92cfdf2fce0d31b0f482fd04f5..4cdb2d73f10d154ad18398e3237c2835b69d48a8 100644 (file)
@@ -36,6 +36,44 @@ extern "C"
 #include <glib.h>
 #include <gio/gio.h>
 
+#include "sal_ipc_server_types.h"
+
+typedef struct _ipc_server_base_req_s
+{
+       void (*connect_cb)(ipc_server_session_h session, int pid, const char *client_uri);
+
+       void (*disconnect_cb)(ipc_server_session_h session, int pid, const char *client_uri);
+
+       void (*plugin_start_cb)(ipc_server_session_h session,
+                       int client_pid, const char *client_uri,
+                       const char *plugin_uri, int service_mask); /* TODO: add property param */
+
+       void (*plugin_stop_cb)(ipc_server_session_h session,
+                       const char *plugin_handle);
+
+} ipc_server_base_req_s;
+
+typedef struct _ipc_server_base_res_s
+{
+       void (*connect)(ipc_server_session_h session, GList *plugin_uris);
+
+       void (*disconnect)(ipc_server_session_h session);
+
+       void (*plugin_start)(ipc_server_session_h session, const char *plugin_handle);
+
+       void (*plugin_stop)(ipc_server_session_h session);
+
+       void (*fail)(ipc_server_session_h session, int result, int error_code, const char *message);
+} ipc_server_base_res_s;
+
+
+API int ipc_server_base_init(ipc_server_base_req_s *base_req);
+
+API gboolean sal_server_base_method_call(void *data);
+
+API ipc_server_base_res_s *ipc_server_get_base_res_handle(void);
+
+/*
 void service_adaptor_method_call(GDBusConnection *connection,
                const gchar *sender,
                const gchar *object_path,
@@ -53,7 +91,7 @@ void service_plugin_method_call(GDBusConnection *connection,
                GVariant *parameters,
                GDBusMethodInvocation *invocation,
                gpointer user_data);
-
+*/
 #ifdef __cplusplus
 }
 #endif
index 565d4add030aa27c8d89fc8a0f7934c3d650c97f..84ee46ba17cbd0a902042dfe9b7e28cf9de4ce9e 100644 (file)
 #include <glib.h>
 #include <gio/gio.h>
 
-#include "service_adaptor_errors.h"
-#include "service_adaptor_internal.h"
-#include "sal.h"
-#include "sal_ipc_server.h"
+#include "sal_types.h"
+#include "sal_log.h"
+#include "sal_ipc.h"
 #include "sal_ipc_server_storage.h"
+/*
 #include "storage_adaptor.h"
 #include "sal_service_storage.h"
 #include "sal_service_storage_internal.h"
+*/
 
 /******************************************************************************
- * Global variables and defines
+ * Private interface
  ******************************************************************************/
 
+/* request callback internal */
+static void __chunk_cb(ipc_server_session_h session);
+
+/* response function internal */
+static void __response_chunk(ipc_server_session_h session);
+
+static void __response_fail(ipc_server_session_h session, int result, int error_code, const char *message);
+
+/* response fail function internal */
+static void __simple_fail_cb(ipc_server_session_h session, int ret, int err, const char *message);
+
+
 /******************************************************************************
- * Private interface
+ * Global variables and defines
  ******************************************************************************/
 
+struct _dbus_interface_map
+{
+       char *method_name;
+       void (*func)(ipc_server_session_h session);
+};
+
+static struct _dbus_interface_map __interface_map[] = {
+       };
+
+struct _dbus_fail_response_map
+{
+       char *method_name;
+       void (*func)(ipc_server_session_h session, int ret, int err, const char *message);
+};
+
+static struct _dbus_fail_response_map __fail_response_map[] = {
+               /*{DBUS_SERVICE_PLUGIN_STOP_METHOD,                     __simple_fail_cb},*/
+       };
+
+static ipc_server_storage_req_s req_callbacks = {0, };
+
+static ipc_server_storage_res_s response_methods = {
+               __response_chunk,
+               __response_fail,
+       };
+
 /******************************************************************************
  * Private interface definition
  ******************************************************************************/
 
-void _cloud_remove_file_cb(int result, cloud_file_h file, void *user_data)
+/* request callbacks  */
+static void __chunk_cb(ipc_server_session_h session)
 {
        SAL_FN_CALL;
 
-       ipc_reply_data_h reply = (ipc_reply_data_h) user_data;
-
-       int ipc_ret = SERVICE_ADAPTOR_ERROR_NONE;
-       char *ipc_msg = NULL;
-       GVariant *ipc_data = NULL;
+       SAL_FN_END;
+}
 
-       GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE(file_list_type));
+/* response functions  */
+static void __response_chunk(ipc_server_session_h session)
+{
+       SAL_FN_CALL;
 
-       ipc_create_error_msg(ipc_ret, &ipc_msg);
-       ipc_data = g_variant_new(ipc_make_return_type(reply->type), file->is_dir, SAL_IPC_STR(file->dir_path), SAL_IPC_STR(file->local_path), SAL_IPC_STR(file->cloud_path), file->size, SAL_IPC_STR(file->operation), builder, ipc_ret, SAL_IPC_STR(ipc_msg));
-       g_dbus_method_invocation_return_value(reply->invocation, ipc_data);
+       SAL_FN_END;
+}
 
-       SAL_FREE(ipc_msg);
-       ipc_free_reply_data(reply);
-       g_variant_builder_unref(builder);
+static void __response_fail(ipc_server_session_h session, int result, int error_code, const char *message)
+{
+       SAL_FN_CALL;
+/*
+       for (int i = 0; __fail_response_map[i]; i++) {
+               if (!strncmp(session->method_name, __fail_response_map[i].method_name,
+                               strlen(__fail_response_map[i].method_name))) {
+                       SAL_DBG("<%s> method return fail", session->method_name);
+                       __fail_response_map[i].func(session, result, error_code, message);
+               }
+       }
+*/
+       /* TODO unref session->invocation or return error */
+       g_free(session);
 
        SAL_FN_END;
 }
 
-int _get_cloud_file(GVariant *reply_info, service_storage_cloud_file_h *file)
+static void __simple_fail_cb(ipc_server_session_h session, int ret, int err, const char *message)
 {
        SAL_FN_CALL;
 
-       service_storage_cloud_file_h cloud_file = (service_storage_cloud_file_h) g_malloc0(sizeof(service_storage_cloud_file_s));
+       SAL_DBG("creates response to gvaiant");
+       GVariant *response = g_variant_new(SAL_IPC_SIMPLE_TYPE,
+                       ret, err, SAL_IPC_SAFE_STR(message));
 
-       int info_size = service_storage_cloud_file_s_type_length;
-       GVariant *info[info_size];
-       ipc_create_variant_info(reply_info, info_size, (GVariant ***) &info);
+       SAL_DBG("invoke gdbus response");
+       g_dbus_method_invocation_return_value(session->invocation, response);
 
-       int idx = 0;
-       cloud_file->is_dir = g_variant_get_boolean(info[idx++]);
-       cloud_file->dir_path = ipc_insure_g_variant_dup_string(info[idx++]);
-       cloud_file->local_path = ipc_insure_g_variant_dup_string(info[idx++]);
-       cloud_file->cloud_path = ipc_insure_g_variant_dup_string(info[idx++]);
-       cloud_file->size = g_variant_get_uint64(info[idx++]);
-       cloud_file->operation = ipc_insure_g_variant_dup_string(info[idx++]);
+       g_variant_unref(response);
+       g_free(session);
 
-       ipc_destroy_variant_info(info, info_size);
+       SAL_FN_END;
+}
 
-       *file = cloud_file;
 
-       return SERVICE_ADAPTOR_ERROR_NONE;
-}
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
 
-int _cloud_execute_operation(storage_plugin_h plugin, service_storage_cloud_file_h file, ipc_reply_data_h reply)
+API int ipc_server_storage_init(ipc_server_storage_req_s *storage_req)
 {
        SAL_FN_CALL;
 
-       RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == plugin->cloud, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-       RETV_IF(NULL == file, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
-
-       if (0 == strcmp(file->operation, SERVICE_STORAGE_CLOUD_REMOVE_FILE_URI)) {
-               ret = plugin->cloud->cloud_remove_file(plugin, file->cloud_path, _cloud_remove_file_cb, reply);
-
-               return ret;
-       } else if (0 == strcmp(file->operation, SERVICE_STORAGE_CLOUD_DOWNLOAD_FILE_URI)) {
-               ret = plugin->cloud->cloud_remove_file(plugin, file->cloud_path, _cloud_remove_file_cb, reply);
+       RETV_IF(NULL == storage_req, SAL_ERROR_INTERNAL);
+       /*RET_IF(NULL == base_req->chunk_cb);*/
 
-               return ret;
-       } else if (0 == strcmp(file->operation, SERVICE_STORAGE_CLOUD_UPLOAD_FILE_URI)) {
-               ret = plugin->cloud->cloud_remove_file(plugin, file->cloud_path, _cloud_remove_file_cb, reply);
+       req_callbacks.chunk_cb  = storage_req->chunk_cb;
 
-               return ret;
-       } else if (0 == strcmp(file->operation, SERVICE_STORAGE_CLOUD_DOWNLOAD_FILE_THUMBNAIL_URI)) {
-               ret = plugin->cloud->cloud_remove_file(plugin, file->cloud_path, _cloud_remove_file_cb, reply);
+       SAL_FN_END;
+       return SAL_ERROR_NONE;
+}
 
-               return ret;
-       } else if (0 == strcmp(file->operation, SERVICE_STORAGE_CLOUD_GET_FILE_LIST_URI)) {
-               ret = plugin->cloud->cloud_remove_file(plugin, file->cloud_path, _cloud_remove_file_cb, reply);
+API gboolean sal_server_storage_method_call(void *data)
+{
+       SAL_FN_CALL;
 
-               return ret;
+       ipc_server_session_h session = (ipc_server_session_h) data;
+       SAL_INFO("===== method called : %s =====", session->method_name);
+/*
+       bool catched = false;
+       for (int i = 0; __interface_map[i]; i++) {
+               if (!strncmp(session->method_name, __interface_map[i].method_name,
+                               strlen(__interface_map[i].method_name))) {
+                       catched = true;
+                       __interface_map[i].func(session);
+               }
        }
 
-       return SERVICE_ADAPTOR_ERROR_INTERNAL;
+       if (false == catched) {
+               // TODO add error handling /
+               SAL_ERR("function does not matched (%s)", session->method_name);
+       }
+*/
+       SAL_FN_END;
+       return FALSE;
 }
 
-/******************************************************************************
- * Public interface definition
- ******************************************************************************/
+API ipc_server_storage_res_s *ipc_server_get_storage_res_handle(void)
+{
+       return &response_methods;
+}
 
+/*
 API void service_storage_method_call(GDBusConnection *connection,
                const gchar *sender,
                const gchar *object_path,
@@ -140,7 +192,7 @@ API void service_storage_method_call(GDBusConnection *connection,
 {
        SAL_FN_CALL;
 
-       int ipc_ret = SERVICE_ADAPTOR_ERROR_NONE;
+       int ipc_ret = SAL_ERROR_NONE;
        char *ipc_msg = NULL;
        char *ipc_type = NULL;
        GVariant *ipc_data = NULL;
@@ -162,11 +214,11 @@ API void service_storage_method_call(GDBusConnection *connection,
 
                SAL_INFO("uri: %s", uri);
 
-               ipc_ret = SERVICE_ADAPTOR_ERROR_INTERNAL;
+               ipc_ret = SAL_ERROR_INTERNAL;
                ipc_type = strdup(service_storage_cloud_file_res_s_type);
 
                sal_h sal = sal_get_handle();
-               TRYVM_IF(NULL == sal, ipc_ret = SERVICE_ADAPTOR_ERROR_INTERNAL, "sal_get_handle() Failed");
+               TRYVM_IF(NULL == sal, ipc_ret = SAL_ERROR_INTERNAL, "sal_get_handle() Failed");
 
                storage_plugin_h plugin = storage_adaptor_get_plugin(sal->storage, uri);
 
@@ -175,7 +227,7 @@ API void service_storage_method_call(GDBusConnection *connection,
                reply->type = strdup(ipc_type);
 
                ipc_ret = _cloud_execute_operation(plugin, file, reply);
-               TRY_IF(SERVICE_ADAPTOR_ERROR_NONE == ipc_ret, "cloud_execute_operation() Request Successed");
+               TRY_IF(SAL_ERROR_NONE == ipc_ret, "cloud_execute_operation() Request Successed");
 
                GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE(file_list_type));
                ipc_create_error_msg(ipc_ret, &ipc_msg);
@@ -194,3 +246,4 @@ catch:
 
        SAL_FN_END;
 }
+*/
index 9289cd226647f1f5f537ef583c100d57f825cb5c..346fb27155449e161013175c783cf37531fdbc8a 100644 (file)
@@ -36,6 +36,27 @@ extern "C"
 #include <glib.h>
 #include <gio/gio.h>
 
+#include "sal_ipc_server_types.h"
+
+typedef struct _ipc_server_storage_req_s
+{
+       void (*chunk_cb)(ipc_server_session_h session);
+} ipc_server_storage_req_s;
+
+typedef struct _ipc_server_storage_res_s
+{
+       void (*chunk)(ipc_server_session_h session);
+
+       void (*fail)(ipc_server_session_h session, int result, int error_code, const char *message);
+} ipc_server_storage_res_s;
+
+API int ipc_server_storage_init(ipc_server_storage_req_s *storage_req);
+
+API gboolean sal_server_storage_method_call(void *data);
+
+API ipc_server_storage_res_s *ipc_server_get_storage_res_handle(void);
+
+/*
 void service_storage_method_call(GDBusConnection *connection,
                const gchar *sender,
                const gchar *object_path,
@@ -44,7 +65,7 @@ void service_storage_method_call(GDBusConnection *connection,
                GVariant *parameters,
                GDBusMethodInvocation *invocation,
                gpointer user_data);
-
+*/
 #ifdef __cplusplus
 }
 #endif
diff --git a/common/ipc-server/sal_ipc_server_types.h b/common/ipc-server/sal_ipc_server_types.h
new file mode 100644 (file)
index 0000000..82ada6a
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Service Adaptor Server IPC
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yongjin Kim <youth.kim@samsung.com>
+ *          Jinhyeong Ahn <jinh.ahn@samsung.com>
+ *          Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_CONVERGENCE_SAL_IPC_SERVER_TYPES_H__
+#define __TIZEN_CONVERGENCE_SAL_IPC_SERVER_TYPES_H__
+
+#ifndef API
+#define API __attribute__ ((visibility("default")))
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <glib.h>
+#include <gio/gio.h>
+
+/**
+ * information for method call
+ */
+typedef struct _ipc_server_session_s {
+       GDBusConnection *connection;
+       gchar *sender;
+       gchar *object_path;
+       gchar *interface_name;
+       gchar *method_name;
+       GVariant *parameters;
+       GDBusMethodInvocation *invocation;
+       gpointer user_data;
+} ipc_server_session_s;
+
+typedef struct _ipc_server_session_s *ipc_server_session_h;
+
+#define SAL_IPC_PAYLOAD_SKIP           0,0,""
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_CONVERGENCE_SAL_IPC_SERVER_TYPES_H__ */
+
diff --git a/common/sal_ipc.c b/common/sal_ipc.c
deleted file mode 100644 (file)
index 5348ace..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Service Adaptor IPC
- *
- * Copyright (c) 2014 - 2015 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 <gio/gio.h>
-
-#include "service_adaptor_errors.h"
-#include "service_adaptor_internal.h"
-#include "sal_ipc.h"
-
-/******************************************************************************
- * Global variables and defines
- ******************************************************************************/
-
-/******************************************************************************
- * Private interface
- ******************************************************************************/
-
-/******************************************************************************
- * Private interface definition
- ******************************************************************************/
-
-/******************************************************************************
- * Public interface definition
- ******************************************************************************/
-
-API char *ipc_insure_g_variant_dup_string(GVariant *string)
-{
-       char *ret = g_variant_dup_string(string, NULL);
-
-       if (0 == strcmp(ret, "")) {
-               SAL_FREE(ret);
-       }
-
-       return ret;
-}
-
-API void ipc_insure_g_variant_builder_add_array_string(GVariantBuilder *builder, const char *str)
-{
-       if (NULL == str) {
-               g_variant_builder_add(builder, "(s)", "");
-       } else {
-               g_variant_builder_add(builder, "(s)", str);
-       }
-}
-
-API char *ipc_make_return_type(const char *type)
-{
-       return g_strdup_printf("(%sis)", SAL_IPC_STR(type));
-}
-
-API void ipc_create_error_msg(int code, char **ipc_msg)
-{
-       switch (code) {
-       case SERVICE_ADAPTOR_ERROR_NONE:
-               *ipc_msg = NULL;
-               break;
-       case SERVICE_ADAPTOR_ERROR_INTERNAL:
-               *ipc_msg = strdup("SERVICE_ADAPTOR_ERROR_INTERNAL");
-               break;
-       default:
-               *ipc_msg = strdup("SERVICE_ADAPTOR_ERROR_UNKNOWN");
-               break;
-       }
-}
-
-API void ipc_create_variant_info(GVariant *parameters, int size, GVariant ***var_info)
-{
-       for (size_t i = 0; i < size; i++) {
-               *(var_info +i) = (GVariant **) g_variant_get_child_value(parameters, i);
-       }
-}
-
-API void ipc_destroy_variant_info(GVariant **var_info, int size)
-{
-       for (size_t i = 0; i < size; i++) {
-               g_variant_unref(var_info[i]);
-       }
-}
-
-API void ipc_free_reply_data(ipc_reply_data_h reply)
-{
-       SAL_FN_CALL;
-
-       RET_IF(NULL == reply);
-
-       SAL_FREE(reply->type);
-       SAL_FREE(reply);
-
-       SAL_FN_END;
-}
diff --git a/common/sal_ipc.h b/common/sal_ipc.h
deleted file mode 100644 (file)
index 3561e01..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Service Adaptor IPC
- *
- * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Yongjin Kim <youth.kim@samsung.com>
- *          Jinhyeong Ahn <jinh.ahn@samsung.com>
- *          Jiwon Kim <jiwon177.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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_CONVERGENCE_SAL_IPC_H__
-#define __TIZEN_CONVERGENCE_SAL_IPC_H__
-
-#ifndef API
-#define API __attribute__ ((visibility("default")))
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include <glib.h>
-#include <gio/gio.h>
-
-#define SAL_IPC_STR(x) (x==NULL)?"":x
-
-/**
- * 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"
-
-/**
- * struct for dbus.
- */
-#define service_adaptor_connect_req_s_type_length 1
-#define service_adaptor_connect_req_s_type \
-       "(" \
-       "s" /* char *uri */ \
-       ")"
-
-#define service_adaptor_connect_res_s_type_length 1
-#define service_adaptor_connect_res_s_type \
-       "(" \
-       "a(s)" /* char **uri */ \
-       ")"
-
-#define service_adaptor_disconnect_s_type_length 1
-#define service_adaptor_disconnect_s_type \
-       "(" \
-       "s" /* char *uri */ \
-       ")"
-
-#define service_plugin_create_s_type_length 1
-#define service_plugin_create_s_type \
-       "(" \
-       "s" /* char *uri */ \
-       ")"
-
-#define service_plugin_destroy_s_type_length 1
-#define service_plugin_destroy_s_type \
-       "(" \
-       "s" /* char *uri */ \
-       ")"
-
-#define service_auth_oauth1_s_type_length 2
-#define service_auth_oauth1_s_type \
-       "(" \
-       "s" /* char *access_token */ \
-       "s" /* char *operation */ \
-       ")"
-
-#define service_auth_oauth1_req_s_type_length 2
-#define service_auth_oauth1_req_s_type \
-       "(" \
-       "s" /* char *uri */ \
-       service_auth_oauth1_s_type /* service_auth_oauth1_s oauth1 */ \
-       ")"
-
-#define service_auth_oauth1_res_s_type_length 1
-#define service_auth_oauth1_res_s_type \
-       "(" \
-       service_auth_oauth1_s_type /* service_auth_oauth1_s oauth1 */ \
-       ")"
-
-#define service_storage_cloud_file_s_type_length 6
-#define service_storage_cloud_file_s_type \
-       "(" \
-       "b" /* bool is_dir */ \
-       "s" /* char *dir_path */ \
-       "s" /* char *local_path */ \
-       "s" /* char *cloud_path */ \
-       "t" /* uint64 size */ \
-       "s" /* char *operation */ \
-       ")"
-
-#define service_storage_cloud_file_req_s_type_length 2
-#define service_storage_cloud_file_req_s_type \
-       "(" \
-       "s" /* char *uri */ \
-       service_storage_cloud_file_s_type /* service_storage_cloud_file_s file */ \
-       ")"
-
-#define service_storage_cloud_file_res_s_type_length 2
-#define service_storage_cloud_file_res_s_type \
-       "(" \
-       service_storage_cloud_file_s_type /* service_storage_cloud_file_s file */ \
-       "a" service_storage_cloud_file_s_type /* GList *files */  \
-       ")"
-
-/**
- * array of structures
- */
-#define plugin_list_type                               "a(s)"
-#define file_list_type                                 "a" service_storage_cloud_file_s_type
-
-/**
- * append error code to the type
- */
-#define RETURN_LENGTH                                  2
-
-/**
- * DBus APIs
- */
-#define DBUS_SERVICE_ADAPTOR                           "dbus_00"
-#define DBUS_SERVICE_PLUGIN                            "dbus_01"
-#define DBUS_SERVICE_AUTH                              "dbus_02"
-#define DBUS_SERVICE_STORAGE                           "dbus_03"
-#define DBUS_NAME_LENGTH                               7
-
-#define DBUS_SERVICE_ADAPTOR_CONNECT_METHOD            DBUS_SERVICE_ADAPTOR "_service_adaptor_connect"
-#define DBUS_SERVICE_ADAPTOR_DISCONNECT_METHOD         DBUS_SERVICE_ADAPTOR "_service_adaptor_disconnect"
-
-#define DBUS_SERVICE_PLUGIN_CREATE_METHOD              DBUS_SERVICE_PLUGIN "_service_plugin_create"
-#define DBUS_SERVICE_PLUGIN_DESTROY_METHOD             DBUS_SERVICE_PLUGIN "_service_plugin_destroy"
-
-#define DBUS_SERVICE_AUTH_OAUTH1_METHOD                        DBUS_SERVICE_AUTH "_service_auth_oauth1"
-
-#define DBUS_SERVICE_STORAGE_CLOUD_FILE_METHOD         DBUS_SERVICE_STORAGE "_service_storage_cloud_file"
-
-#define DBUS_SERVICE_ADAPTOR_NOTIFY_SIGNAL             DBUS_SERVICE_ADAPTOR "_service_adaptor_signal_notify"
-
-typedef struct _ipc_reply_data_s
-{
-       GDBusMethodInvocation *invocation;
-       char *type;
-} ipc_reply_data_s;
-typedef struct _ipc_reply_data_s *ipc_reply_data_h;
-
-char *ipc_insure_g_variant_dup_string(GVariant *string);
-void ipc_insure_g_variant_builder_add_array_string(GVariantBuilder *builder, const char *str);
-char *ipc_make_return_type(const char *type);
-void ipc_create_error_msg(int code, char **ipc_msg);
-void ipc_create_variant_info(GVariant *parameters, int size, GVariant ***var_info);
-void ipc_destroy_variant_info(GVariant **var_info, int size);
-void ipc_free_reply_data(ipc_reply_data_h reply);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __TIZEN_CONVERGENCE_SAL_IPC_H__ */
index 3d01f7ad7aea9c309982cd36e487b7796f2a3682..dfe44c10b9dbd5a6368363d8b1be84ed82983959 100644 (file)
 /*
- * Service Adaptor
- *
- * Copyright (c) 2014 - 2015 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.
- *
+* 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 <bundle.h>
+#include <service_adaptor_type.h>
+#include <service_adaptor_client_plugin.h>
+#include <service_adaptor_client_storage.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file service_adaptor_client.h
  */
 
-#ifndef __TIZEN_CONVERGENCE_SERVICE_ADAPTOR_CLIENT_H__
-#define __TIZEN_CONVERGENCE_SERVICE_ADAPTOR_CLIENT_H__
+/**
+ * @addtogroup SERVICE_PLUGIN_MODULE
+ * @{
+ */
+
+/**
+* @brief The handle for connection and managing plugin handle of Service Adaptor
+* @details The handle can be created by service_adaptor_create()<br>
+*  When a handle is no longer needed, use service_adaptor_destroy()
+* @since_tizen 2.4
+*
+* @see #service_adaptor_create()
+* @see #service_adaptor_destroy()
+*/
+typedef struct _service_adaptor_s *service_adaptor_h;
+
+/**
+* @since_tizen 2.4
+* @brief Callback for service_adaptor_foreach_plugin API
+*
+* @param[in]   plugin_uri      The service plugin's unique uri, this value be set by plugin
+* @param[in]   service_mask    Masked value for <b>installed</b> service plugins, this value can be masked multiple enum (#service_plugin_service_type_e)
+* @param[in]   user_data       Passed data from #service_adaptor_foreach_plugin()
+* @remarks     @a service_mask check using 'bit and' operation with #service_plugin_service_type_e
+* @remarks     - for example,
+* @remarks     &nbsp;&nbsp;&nbsp;&nbsp;        if(@a service_mask & SERVICE_PLUGIN_SERVICE_STORAGE)
+* @remarks     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;        { @a USING_STORAGE_CODE }
+* @remarks Do not release memory of @a plugin_uri
+* @see         service_plugin_service_type_e
+* @return @c true to continue with the next iteration of the loop,
+*         otherwise @c false to break out of the loop
+* @pre service_adaptor_foreach_plugin() will invoke this callback.
+*/
+typedef bool (*service_adaptor_plugin_cb)(char *plugin_uri,
+                                               int service_mask,
+                                               void *user_data);
+/*==================================================================================================
+                                         FUNCTION PROTOTYPES
+==================================================================================================*/
 
-#include <service_adaptor_errors.h>
+/**
+* @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);
 
-#include "sal_service_adaptor.h"
-#include "sal_service_task.h"
-#include "sal_service_auth.h"
-#include "sal_service_storage.h"
+/**
+* @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);
 
-#include "service_adaptor_client_plugin.h"
-#include "service_adaptor_client_storage.h"
+/**
+* @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);
+
+/**
+ * @}
+ */
 
-#endif /* __TIZEN_CONVERGENCE_SERVICE_ADAPTOR_CLIENT_H__ */
+#ifdef __cplusplus
+}
+#endif
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_H__ */
index 6addbbb88c39baf79539378d2220b75dd3e283e6..f82922351a4c76f924930f88d3a6252f7aa519b4 100644 (file)
 /*
- * Service Adaptor
- *
- * Copyright (c) 2014 - 2015 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.
- *
+* 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__
+
+#include <service_adaptor_type.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup SERVICE_PLUGIN_MODULE
+ * @{
  */
 
-#ifndef __TIZEN_CONVERGENCE_SERVICE_ADAPTOR_CLIENT_PLUGIN_H__
-#define __TIZEN_CONVERGENCE_SERVICE_ADAPTOR_CLIENT_PLUGIN_H__
+/**
+* @brief The Plugn handle for Service Adaptor
+* @details The handle can be created by service_adaptor_create_plugin()<br>
+*  When a handle is no longer needed, use service_plugin_destroy()
+* @since_tizen 2.4
+*
+* @see service_adaptor_create_plugin()
+* @see service_plugin_destroy()
+*/
+typedef struct _service_plugin_s *service_plugin_h;
+
+/**
+* @brief       Destroy Service Adaptor
+* @details     It must called after a program no longer needs APIs of specfic plugin
+* @since_tizen 2.4
+*
+* @param[in]   plugin  The handle for use Plugin APIs
+* @see service_adaptor_create_plugin()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre @a plugin must be issued by service_adaptor_create_plugin()
+*/
+int service_plugin_destroy(service_plugin_h plugin);
+
+/**
+* @brief Add Plugin Property
+* @details The plguin property is used for plugin's basic or optional requirement.<br>
+*  This value is not used in Adaptor layer, but it can be uesd to important Key for plugin with service provider.<br>
+* @since_tizen 2.4
+*
+* @param[in]   plugin  The handle for use Plugin APIs
+* @param[in]   key     The key of plugin property
+* @param[in]   value   The value of plugin property that matched @a key
+* @remarks     Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
+* @remarks     If the @a key already exists in the property its current value is replaced with the new @a value.
+* @remarks     @a plugin must be released memory using #service_plugin_destroy() when you no longer needs plugin's API
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see SERVICE_PLUGIN_PROPERTY_APP_KEY
+* @see SERVICE_PLUGIN_PROPERTY_APP_SECRET
+* @see SERVICE_PLUGIN_PROPERTY_USER_ID
+* @pre @a plugin must be issued by service_adaptor_create_plugin()
+*/
+int service_plugin_add_property(service_plugin_h plugin,
+                                               const char *key,
+                                               const char *value);
+
+/**
+* @brief Remove Plugin Property
+* @since_tizen 2.4
+*
+* @param[in]   plugin  The handle for use Plugin APIs
+* @param[in]   key     The key of plugin property
+* @remarks     Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see SERVICE_PLUGIN_PROPERTY_APP_KEY
+* @see SERVICE_PLUGIN_PROPERTY_APP_SECRET
+* @see SERVICE_PLUGIN_PROPERTY_USER_ID
+*/
+int service_plugin_remove_property(service_plugin_h plugin,
+                                               const char *key);
+
+/**
+* @brief Gets Plugin Property
+* @since_tizen 2.4
+*
+* @param[in]   plugin  The handle for use Plugin APIs
+* @param[in]   key     The key of plugin property
+* @param[out]  value   The value of plugin property that matched @a key
+* @remarks     Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX)
+* @remarks     @a value must be released using free()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no property
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see SERVICE_PLUGIN_PROPERTY_APP_KEY
+* @see SERVICE_PLUGIN_PROPERTY_APP_SECRET
+* @see SERVICE_PLUGIN_PROPERTY_USER_ID
+* @pre The function get property already set by service_adaptor_set_plugin_property()
+*/
+int service_plugin_get_property(service_plugin_h plugin,
+                                               const char *key,
+                                               char **value);
+
+/**
+* @brief Requests start initalization for service plugin
+* @since_tizen 2.4
+*
+* @param[in]   plugin          The handle for use Plugin APIs
+* @param[in]   service_mask    The flag for use service plugins, this flag can be masked multiple enum (#service_plugin_service_type_e)
+* @remarks     @a service_mask must be input using 'bit or' operation with #service_plugin_service_type_e
+* @remarks     - for example,
+* @remarks     &nbsp;&nbsp;&nbsp;&nbsp;        <b>int</b> @a service_mask |= SERVIE_PLUGIN_SERVICE_AUTH;
+* @remarks     &nbsp;&nbsp;&nbsp;&nbsp;        @a service_mask |= SERVICE_PLUGIN_SERVICE_STORAGE;
+* @remarks     &nbsp;&nbsp;&nbsp;&nbsp;        <b>int</b> ret = service_plugin_start(@a m_plugin, @a service_mask);
+* @remarks     If a program needs to stop plugin manually, use #service_plugin_stop(). <br>But in #service_plugin_destroy(), automatically stop service plugin
+* @see         service_plugin_service_type_e
+* @see         service_plugin_stop()
+* @return 0 on success, otherwise a negative error value
+* @return If return value is #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED, request authorization to signup application
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED Need authorization
+* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+*/
+int service_plugin_start(service_plugin_h plugin,
+                                               int service_mask);
+
+/**
+* @brief Requests stop manually for service plugin
+* @since_tizen 2.4
+*
+* @param[in]   plugin          The handle for use Plugin APIs
+* @remarks     If a program needs to stop plugin manually, use this function. <br>But in #service_plugin_destroy(), automatically stop service plugin
+* @remarks     @a plugin must be released memory using #service_plugin_destroy() when you no longer needs plugin's API
+* @see         service_plugin_start()
+* @see         service_plugin_destroy()
+* @return 0 on success, otherwise a negative error value
+* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon
+* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @pre service_plugin_start()
+*/
+int service_plugin_stop(service_plugin_h plugin);
+
+/**
+ * @}
+ */
 
-#endif /* __TIZEN_CONVERGENCE_SERVICE_ADAPTOR_CLIENT_PLUGIN_H__ */
+#ifdef __cplusplus
+}
+#endif
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_PLUGIN_H__ */
index e11169d85d21f184f748df4b232bedf9e1fdbe91..fcdb135b8d97f6ae4fdb27bd14d8148251dd32d3 100644 (file)
 /*
- * Service Adaptor
- *
- * Copyright (c) 2014 - 2015 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.
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/******************************************************************************
+ * File: service_adaptor_client_storage.h
+ * Desc: Service Adaptor APIs
+ * Created on: Oct, 2014
+ * Author: Jiwon Kim <jiwon177.kim@samsung.com>
  *
+ *****************************************************************************/
+/**
+ *     @file           service_adaptor_client_storage.h
+ *     @brief          Defines interface of Service Adaptor's Storage
+ *     @version        0.1
+ */
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_STORAGE_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_STORAGE_H__
+
+#include <service_adaptor_client_plugin.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file service_adaptor_client_storage.h
+ */
+
+/**
+ * @addtogroup  SERVICE_ADAPTOR_STORAGE_MODULE
+
+ * @{
+ */
+
+/**
+* @brief The handle of async task for storage service
+* @since_tizen 2.4
+*
+* @see #service_storage_create_download_task()
+* @see #service_storage_create_upload_task()
+*/
+typedef struct _service_storage_task_s *service_storage_task_h;
+
+/**
+* @brief The handle of file or directory in storage
+* @since_tizen 2.4
+*
+* @see #service_storage_file_clone()
+* @see #service_storage_file_destroy()
+*/
+typedef struct _service_storage_file_s *service_storage_file_h;
+
+/**
+* @brief The list handle of file or directory in storage
+* @since_tizen 2.4
+*
+* @see #service_storage_file_list_clone()
+* @see #service_storage_file_list_destroy()
+*/
+typedef struct _service_storage_file_list_s *service_storage_file_list_h;
+
+/**
+ * @brief Type of storage task
+ * @since_tizen 2.4
  */
+typedef enum
+{
+       SERVICE_STORAGE_TASK_IN_PROGRESS        = 1,    /**< The task is progressing */
+       SERVICE_STORAGE_TASK_COMPLETED          = 2,    /**< The task was completed */
+       SERVICE_STORAGE_TASK_CANCELED           = 3,    /**< The task was canceled */
+       SERVICE_STORAGE_TASK_FAILED             = 4,    /**< The task was failed */
+} service_storage_task_state_e;
+
+/**
+* @brief Callback for changing state of storage task
+* @since_tizen 2.4
+*
+* @param[in]   state           The state of storage task
+* @param[in]   user_data       The user data passed from #service_storage_set_task_state_changed_cb()
+* @see #service_storage_unset_task_state_changed_cb()
+* @pre #service_storage_set_task_state_changed_cb() will invoke this callback.
+*/
+typedef void (*service_storage_task_state_cb)(service_storage_task_state_e state,
+                                               void *user_data);
+
+/**
+* @brief Callback for progress of storage task
+* @since_tizen 2.4
+*
+* @param[in]   progress        The progressed amount of storage task
+* @param[in]   total           The total amount of storage task
+* @param[in]   user_data       The user data passed from #service_storage_set_task_progress_cb()
+* @see #service_storage_unset_task_progress_cb()
+* @pre #service_storage_set_task_progress_cb() will invoke this callback.
+*/
+typedef void (*service_storage_task_progress_cb)(unsigned long long progress,
+                                               unsigned long long total,
+                                               void *user_data);
+
+/**
+* @brief Callback for getting async storage operation result
+* @since_tizen 2.4
+*
+* @param[in]   result          Result code for storage async operation (see #service_adaptor_error_e)
+* @param[in]   user_data       Passed data from request function
+* @remarks     If the @a result value is #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see #service_adaptor_error_e
+* @see service_storage_remove()
+* @pre #service_storage_remove() will invoke this callback.
+*/
+typedef void (*service_storage_result_cb)(int result,
+                                               void *user_data);
+
+
+/**
+* @brief Callback for getting file list API
+* @since_tizen 2.4
+*
+* @param[in]   result          Result code for #service_storage_get_file_list() (see #service_adaptor_error_e)
+* @param[in]   list            The handle of file list
+* @param[in]   user_data       Passed data from #service_storage_get_file_list()
+* @remarks     If the @a result value is #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin.
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_NONE Successful
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal
+* @remarks     The @a result values #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error
+* @see #service_adaptor_error_e
+* @see #service_storage_file_list_h
+* @pre #service_storage_get_file_list() will invoke this callback.
+*/
+typedef void (*service_storage_file_list_cb)(int result,
+                                               service_storage_file_list_h list,
+                                               void *user_data);
+
+/**
+* @brief Callback for service_storage_file_list_foreach_file API
+* @since_tizen 2.4
+*
+* @param[in]   file            The handle of file
+* @param[in]   user_data       Passed data from #service_storage_file_list_foreach_file()
+* @see #service_storage_file_h
+* @return @c true to continue with the next iteration of the loop,
+*         otherwise @c false to break out of the loop
+* @pre #service_storage_file_list_foreach_file() will invoke this callback.
+*/
+typedef bool (*service_storage_file_cb)(service_storage_file_h file,
+                                               void *user_data);
 
-#ifndef __TIZEN_CONVERGENCE_SERVICE_ADAPTOR_CLIENT_STORAGE_H__
-#define __TIZEN_CONVERGENCE_SERVICE_ADAPTOR_CLIENT_STORAGE_H__
+/**
+* @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);
+
+/**
+ * @}
+ */
 
-#endif /* __TIZEN_CONVERGENCE_SERVICE_ADAPTOR_CLIENT_STORAGE_H__ */
+#ifdef __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_STORAGE_H__ */
diff --git a/include/service_adaptor_client_type.h b/include/service_adaptor_client_type.h
new file mode 100644 (file)
index 0000000..af3ab76
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_TYPE_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_TYPE_H__
+
+#include <stdint.h>
+#include "service_adaptor_client.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define TASK_MESSAGE_FORWARD_ONLINE_MESSAGE    -100
+#define TASK_MESSAGE_FORWARD_UNREAD_MESSAGE    -101
+#define TASK_MESSAGE_CHANNEL_DISCONNECTED_MESSAGE      -102
+
+///////////////// private feature
+#define PRIVATE_SIGNAL_FILE_PROGRESS_ID                        11000
+#define PRIVATE_SIGNAL_FILE_TRANSFER_COMPLETION_ID     11001
+///////////////// private feature
+
+#define SIGNAL_STORAGE_FILE_PROGRESS_ID                1000
+#define SIGNAL_STORAGE_FILE_STATE_CHANGED_ID   1001
+#define SIGNAL_SERVICE_ADAPTOR                 9000
+
+//////////////////////////////////////////////////////////////////////////////////
+///// Signal Task area
+//////////////////////
+
+typedef struct _service_storage_task_s
+{
+       char *service_handle_name;
+       long long int task_id;  // file_uid (matched fd)
+       void *param1;
+       void *param2;
+       void *param3;
+
+       int operation;          // 1: upload, 2: download, 3:thumbnail (TEMP)
+       int state;
+       service_storage_task_state_cb state_callback;
+       void *state_user_data;
+       service_storage_task_progress_cb progress_callback;
+       void *progress_user_data;
+}service_storage_task_t;
+
+/**
+* @brief Describes infromation about task
+*/
+typedef struct _service_adaptor_task_s
+{
+       int64_t id;                     /**< specifies status as none*/
+       uint32_t callback;              /**< specifies status as none*/
+       void *handle;                   /**< specifies status as none*/
+       void *user_data;
+} service_adaptor_task_s;
+
+/**
+* @brief Describes infromation about Service Adaptor's error
+* @remarks 'msg' is need free()
+*/
+typedef struct _service_adaptor_error_s
+{
+       long long int code;                     /**< specifies status as none*/
+       char *msg;                              /**< specifies status as none*/
+} service_adaptor_error_s;
+
+#define __SAFE_STRDUP(x)        (x) ? strdup((x)) : NULL
+#define __SAFE_FREE(x)         do { free(x); (x) = NULL; } while (0)
+#define _assign_error_code(src, tgt)   do { \
+                                               sac_error("Error occured a : (%lld) (%s)", (long long int)((src)->code), (src)->msg); \
+                                               __assign_error_code((src), (tgt)); \
+                                       } while (0)
+
+#define _set_error_code(tgt, code, msg)        do { \
+                                               sac_error("Error occured b : (%d) (%s)", (int)(code), (msg)); \
+                                               __set_error_code((tgt), (code), (msg)); \
+                                       } while (0)
+
+
+/**
+* @brief The handle for Task
+*/
+typedef service_adaptor_task_s *service_adaptor_task_h;
+
+int _queue_add_task(int64_t id,
+                                               uint32_t callback,
+                                               void *handle,
+                                               void *user_data);
+
+int _queue_del_task(service_adaptor_task_h task);
+
+service_adaptor_task_h _queue_get_task(int64_t id);
+
+void _queue_clear_task(void);
+
+int _signal_queue_add_task(int64_t id,
+                                               uint32_t callback,
+                                               void *handle,
+                                               void *user_data);
+
+service_adaptor_task_h _signal_queue_get_task(int64_t id);
+
+int _signal_queue_del_task(service_adaptor_task_h task);
+
+void _signal_queue_clear_task(void);
+
+int service_adaptor_check_handle_validate(service_adaptor_h handle);
+
+
+/**
+ * @brief Enumerations of signal code for Service Adaptor
+ */
+typedef enum _service_adaptor_signal_code_e
+{
+       SERVICE_ADAPTOR_SIGNAL_INITIALIZED              = 1,    /* Service adaptor finished initalization */
+       SERVICE_ADAPTOR_SIGNAL_NEW_PLUGIN               = 2,    /* New Plugins loaded in a running time */
+       SERVICE_ADAPTOR_SIGNAL_ACTIVATE_PLUGIN          = 3,    /* Some Plugins be activated by policy or user atholization or etc */
+       SERVICE_ADAPTOR_SIGNAL_SHUTDOWN                 = 4,    /* Service adaptor was shutdowned by unsuspected issue */
+} service_adaptor_signal_code_e;
+
+//////////////////////
+///// Signal Task area
+//////////////////////////////////////////////////////////////////////////////////
+
+
+//////////////////////////////////////////////////////////////////////////////////
+///// Storage Task area
+//////////////////////
+
+
+//////////////////////
+///// Storage Task area
+//////////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifdef __cplusplus
+}
+#endif /* __cpluscplus */
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_TYPE_H__ */
diff --git a/include/service_adaptor_errors.h b/include/service_adaptor_errors.h
deleted file mode 100644 (file)
index d811555..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Service Adaptor
- *
- * Copyright (c) 2014 - 2015 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_CONVERGENCE_SERVICE_ADAPTOR_ERRORS_H__
-#define __TIZEN_CONVERGENCE_SERVICE_ADAPTOR_ERRORS_H__
-
-#include <tizen.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#ifndef TIZEN_ERROR_SERVICE_ADAPTOR
-#define TIZEN_ERROR_SERVICE_ADAPTOR     -0x02F30000
-#endif
-
-/**
- * @file service_adaptor_errors.h
- */
-
-/**
- * @addtogroup CAPI_CONVERGENCE_SERVICE_ADAPTOR_ERROR_MODULE
- * @{
- */
-
-/**
- * @brief Enumeration for service adaptor errors.
- *
- * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 3.0 @endif
- *
- */
-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_AUTHOLIZED            = TIZEN_ERROR_SERVICE_ADAPTOR | 0x03,   /**< Need Autholization */
-       SERVICE_ADAPTOR_ERROR_INVALID_STATE             = TIZEN_ERROR_SERVICE_ADAPTOR | 0x04,   /**< The handle state is invalid for processing API */
-       SERVICE_ADAPTOR_ERROR_SYSTEM                    = TIZEN_ERROR_SERVICE_ADAPTOR | 0x05,   /**< Internal system module error */
-       SERVICE_ADAPTOR_ERROR_INTERNAL                  = TIZEN_ERROR_SERVICE_ADAPTOR | 0x06,   /**< Implementation Error */
-} service_adaptor_error_e;
-
- /**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __TIZEN_CONVERGENCE_SERVICE_ADAPTOR_ERRORS_H__ */
diff --git a/include/service_adaptor_internal.h b/include/service_adaptor_internal.h
deleted file mode 100644 (file)
index d5cef4d..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Service Adaptor
- *
- * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Yongjin Kim <youth.kim@samsung.com>
- *          Jinhyeong Ahn <jinh.ahn@samsung.com>
- *          Jiwon Kim <jiwon177.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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_CONVERGENCE_SAL_INTERNAL_H__
-#define __TIZEN_CONVERGENCE_SAL_INTERNAL_H__
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#ifdef API
-#undef API
-#endif
-#define API __attribute__ ((visibility("default")))
-
-#define LOG_TAG "SERVICE-ADAPTOR"
-#include <dlog.h>
-#define DLOG(prio, fmt, arg...) \
-        do { SLOG(prio, LOG_TAG, fmt, ##arg); } while (0)
-
-
-#if defined(_SERVICE_ADAPTOR_IPC_SERVER)
-#define IPC_ROLE "[SERVER]"
-#elif defined(_SERVICE_ADAPTOR_IPC_CLIENT)
-#define IPC_ROLE "[CLIENT]"
-#else
-#define IPC_ROLE "[LIB]"
-#endif
-
-/**
- * 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 */
-
-#define INFO(fmt, arg...) SLOGI(FONT_COLOR_YELLOW""IPC_ROLE" "fmt""FONT_COLOR_RESET, ##arg)
-#define ERR(fmt, arg...) SLOGE(FONT_COLOR_RED""IPC_ROLE" "fmt""FONT_COLOR_RESET, ##arg)
-#define DBG(fmt, arg...) SLOGD(IPC_ROLE" "fmt, ##arg)
-#define WARN(fmt, arg...) SLOGD(IPC_ROLE" "fmt, ##arg)
-#define VERBOSE(fmt, arg...) SLOGV(IPC_ROLE" "fmt, ##arg)
-
-#ifdef SERVICE_ADAPTOR_DEBUGGING
-
-        #define SAL_FN_CALL DBG(">>>>>>>> called")
-        #define SAL_FN_END DBG("<<<<<<<< ended")
-
-        #define SAL_DBG(fmt, arg...) DBG(fmt, ##arg)
-        #define SAL_WARN(fmt, arg...) WARN(fmt, ##arg)
-        #define SAL_ERR(fmt, arg...) ERR(fmt, ##arg)
-        #define SAL_INFO(fmt, arg...) INFO(fmt, ##arg)
-        #define SAL_VERBOSE(fmt, arg...) VERBOSE(fmt, ##arg)
-
-#else /* SERVICE_ADAPTOR_DEBUGGING */
-        #define SAL_FN_CALL
-        #define SAL_FN_END
-
-        #define SAL_DBG(fmt, arg...)
-        #define SAL_WARN(fmt, arg...)
-        #define SAL_ERR(fmt, arg...) ERR(fmt, ##arg)
-        #define SAL_INFO(fmt, arg...)
-        #define SAL_VERBOSE(fmt, arg...)
-
-#endif /* SERVICE_ADAPTOR_DEBUGGING */
-
-#define WARN_IF(expr, fmt, arg...) do { \
-        if (expr) { \
-                SAL_WARN(fmt, ##arg); \
-        } \
-} while (0)
-#define RET_IF(expr) do { \
-        if (expr) { \
-                SAL_ERR("(%s)", #expr); \
-                return; \
-        } \
-} while (0)
-#define RETV_IF(expr, val) do { \
-        if (expr) { \
-                SAL_ERR("(%s)", #expr); \
-                return (val); \
-        } \
-} while (0)
-#define RETM_IF(expr, fmt, arg...) do { \
-        if (expr) { \
-                SAL_ERR(fmt, ##arg); \
-                return; \
-        } \
-} while (0)
-#define RETVM_IF(expr, val, fmt, arg...) do { \
-        if (expr) { \
-                SAL_ERR(fmt, ##arg); \
-                return (val); \
-        } \
-} while (0)
-#define TRY_IF(expr, fmt, arg...) do { \
-        if (expr) { \
-                SAL_INFO(fmt, ##arg); \
-                goto catch; \
-        } \
-} while (0)
-#define TRYM_IF(expr, fmt, arg...) do { \
-        if (expr) { \
-                SAL_ERR(fmt, ##arg); \
-                goto catch; \
-        } \
-} while (0)
-#define TRYVM_IF(expr, val, fmt, arg...) do { \
-        if (expr) { \
-                SAL_ERR(fmt, ##arg); \
-                val; \
-               goto catch; \
-        } \
-} while (0)
-
-#define SAL_STRDUP(dst, ptr) do { \
-       if (ptr) \
-               dst = strdup(ptr); \
-       else \
-               dst = NULL; \
-} while(0)
-
-#define SAL_FREE(ptr) do { \
-       if (ptr) \
-               free(ptr); \
-       ptr = NULL; \
-} while(0)
-
-#endif /* __TIZEN_CONVERGENCE_SAL_INTERNAL_H__ */
diff --git a/include/service_adaptor_type.h b/include/service_adaptor_type.h
new file mode 100644 (file)
index 0000000..6678740
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+* 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_TYPE_H__
+#define __TIZEN_SOCIAL_SERVICE_ADAPTOR_TYPE_H__
+
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file service_adaptor_type.h
+ */
+
+/**
+ * @addtogroup SERVICE_ADAPTOR_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumerations of result code for Service Adaptor
+ * @since_tizen 2.4
+ */
+typedef enum
+{
+       SERVICE_ADAPTOR_ERROR_NONE                                      = TIZEN_ERROR_NONE,                                             /**< Success */
+       SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED                     = TIZEN_ERROR_NOT_SUPPORTED,                    /**< Service plugin does not support API */
+       SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER         = TIZEN_ERROR_INVALID_PARAMETER,                /**< The parameter is invalid */
+       SERVICE_ADAPTOR_ERROR_TIMED_OUT                         = TIZEN_ERROR_TIMED_OUT,                                /**< API time out */
+       SERVICE_ADAPTOR_ERROR_NO_DATA                           = TIZEN_ERROR_NO_DATA,                                  /**< There is no data available */
+       SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED         = TIZEN_ERROR_PERMISSION_DENIED,                /**< Permission denied */
+       SERVICE_ADAPTOR_ERROR_UNKNOWN                           = TIZEN_ERROR_UNKNOWN,                                  /**< Unknown error */
+       SERVICE_ADAPTOR_ERROR_OUT_OF_MEMORY                     = TIZEN_ERROR_OUT_OF_MEMORY,                    /**< Out of memory */
+       SERVICE_ADAPTOR_ERROR_NETWORK_UNREACHABLE       = TIZEN_ERROR_NETWORK_UNREACHABLE,              /**< Network is unreachable */
+       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 Type of service in plugin
+ * @since_tizen 2.4
+ */
+typedef enum
+{
+       SERVICE_PLUGIN_SERVICE_AUTH     = (0x01 << 0),          /**< Auth service type flag */
+       SERVICE_PLUGIN_SERVICE_STORAGE  = (0x01 << 1),          /**< Storage service type flag */
+}service_plugin_service_type_e;
+
+/**
+* @brief Definition for the service_plugin property: The application id be issued from service provider for 3rd party developer.
+* @since_tizen 2.4
+*
+* @see service_plugin_add_property()
+* @see service_plugin_remove_property()
+* @see service_plugin_get_property()
+ */
+#define SERVICE_PLUGIN_PROPERTY_APP_KEY                "http://tizen.org/service-adaptor/plugin/property/app_key"
+
+/**
+* @brief Definition for the service_plugin property: The application password be issued from service provider for 3rd party developer.
+* @since_tizen 2.4
+*
+* @see service_plugin_add_property()
+* @see service_plugin_remove_property()
+* @see service_plugin_get_property()
+*/
+#define SERVICE_PLUGIN_PROPERTY_APP_SECRET     "http://tizen.org/service-adaptor/plugin/property/app_secret"
+
+/**
+* @brief Definition for the service_plugin property: The user id for using specific service.
+* @since_tizen 2.4
+*
+* @see service_plugin_add_property()
+* @see service_plugin_remove_property()
+* @see service_plugin_get_property()
+*/
+#define SERVICE_PLUGIN_PROPERTY_USER_ID                "http://tizen.org/service-adaptor/plugin/property/user_id"
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_TYPE_H__ */
diff --git a/include/service_adaptor_types.h b/include/service_adaptor_types.h
deleted file mode 100644 (file)
index 1a98384..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Service Adaptor
- *
- * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Yongjin Kim <youth.kim@samsung.com>
- *          Jinhyeong Ahn <jinh.ahn@samsung.com>
- *          Jiwon Kim <jiwon177.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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_CONVERGENCE_SERVICE_ADAPTOR_TYPES_H__
-#define __TIZEN_CONVERGENCE_SERVICE_ADAPTOR_TYPES_H__
-
-#include <stdio.h>
-#include <glib.h>
-
-#include "auth_adaptor.h"
-#include "contact_adaptor.h"
-#include "storage_adaptor.h"
-#include "resource_adaptor.h"
-
-typedef struct _service_adaptor_s
-{
-       GList *svc_list;
-
-       auth_adaptor_h                  auth;
-       contact_adaptor_h               contact;
-       storage_adaptor_h               storage;
-       resource_adaptor_h              resource;
-
-       auth_adaptor_listener_h         auth_listener;
-       contact_adaptor_listener_h      contact_listener;
-       storage_adaptor_listener_h      storage_listener;
-       resource_adaptor_listener_h      resource_listener;
-
-       GMutex mutex;
-       GCond cond;
-       int start;
-} service_adaptor_s;
-typedef struct _service_adaptor_s *service_adaptor_h;
-
-#endif /* __TIZEN_CONVERGENCE_SERVICE_ADAPTOR_TYPES_H__ */
index 509f2367739f24cfe80b7f3fad0326d0034ce395..19a6368a9321797c039d66b4c4be856f363407dc 100644 (file)
 /*
- * Service Provider
+* 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_PROVIDER_H__
+#define __TIZEN_SOCIAL_SERVICE_PROVIDER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <service_provider_types.h>
+
+/**
+ * @addtogroup SERVICE_PROVIDER_MODULE
+
+ * @{
+ */
+
+/**
+ * @brief      Sets storage provider
+ * @details    It means the Service Provider provides storage feature.\n
+ * The #storage_provider_s 's elements (callbacks) are called by Service Adaptor.
+ * @since_tizen 3.0
+ *
+ * @param[in]  storage_provider        storage_provider spec
+ * @param[in]  user_data               Passed data to callback
+ *
+ * @remarks    It should be called in app_created_cb() callback.
+ * @remarks    For working successfully, #service_provider_open_channel() must be called in on_app_control().
+ * @remarks    All of the structure elements(callbacks) must assigned to provider's functions.
+ * @remarks    If some element(s) is(are) NULL, you can not provide storage features.
+ * @remarks    Be careful to assign dangling pointer, during initialization of structure.
+ * @remarks    The provider callbacks will be invoked on <b>additional thread</b>(Not main thread).
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @code
+ * bool service_app_create(void *data)
+ * {
+ *     //...
+ *
+ *     struct storage_provider_s _storage_cb = {NULL, }; // Assigning "{NULL, }" is important
+ *     _storage_cb.open = __internal_open_cb;
+ *     // Todo: Set all callbacks
+ *
+ *     int ret = service_provider_set_storage_provider(&_storage_cb, NULL);
  *
- * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *     // Todo: add your code here.
+ *     return true;
+ * }
+ * @endcode
+ */
+int service_provider_set_storage_provider(storage_provider_s *storage_provider, void *user_data);
+
+/**
+ * @brief      Open communication channel and provides control right to Service Adaptor
+ * @details    It is important API for Service Provider.\n
+ * All of the communication with Service Adaptor can be started from this API.
+ * If Service Adaptor needs to make communication channel with Service Provider, it can send app-control with APP_CONTROL_OPERATION_SERVICE_PROVIDER_CHANNEL operation.\n
+ * At that time, Service Provider calls this API with app_control_h, the service channel is opened in this API.\n
+ * \n
+ * From this API, the @a channel will be opened between Service Adaptor and Service Provider.\n
+ * \n
+ * Refer to @ref SERVICE_PROVIDER_MODULE_CHANNEL_DESCRIPTION
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in]  app_control     Handle of app-control
+ * @param[in]  callback        The callback will be invoked after channel opened/closed
+ * @param[in]  user_data       Passed data to callback
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * @remarks    It must be called in app_control_cb()
+ * @remarks    If return value is #SERVICE_ADAPTOR_ERROR_NO_DATA, there is no matched App Control operation ID
+ * @remarks    After this API called successfully, the application can be terminated by Service Adaptor when a channel is closed.\n
+ * When the Service Provider receives to request of closing channel, service_app_exit() can be called according return value from channel event callback.
  *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * @return 0 on success, otherwise a negative error value
+ * @retval     #SERVICE_ADAPTOR_ERROR_NONE                                     Successful
+ * @retval     #SERVICE_ADAPTOR_ERROR_NO_DATA                          There is no data available
+ * @retval     #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER        Invalid parameter
+ * @retval     #SERVICE_ADAPTOR_ERROR_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
  *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * @see #APP_CONTROL_OPERATION_SERVICE_PROVIDER_CHANNEL
+ * @pre        For provide Storage feature, service_provider_set_storage_provider() must be called before this.
+ * @post #service_provider_channel_cb() will be invoked
  *
+ * @code
+ * void service_app_control(app_control_h app_control, void *data)
+ * {
+ *     char *_operation = NULL;
+ *     int ret = app_control_get_operation(app_control, &_operation);
+ *
+ *     if (!ret && !strncmp(APP_CONTROL_OPERATION_SERVICE_PROVIDER_CHANNEL, _operation, strlen(APP_CONTROL_OPERATION_SERVICE_PROVIDER_CHANNEL)))
+ *         ret = service_provider_open_channel(app_control, __channel_state_cb, NULL);
+ *
+ *     // Todo: add your code here.
+ *     return;
+ * }
+ * @endcode
  */
+int service_provider_open_channel(app_control_h app_control, service_provider_channel_cb callback, void *user_data);
 
-#ifndef __TIZEN_CONVERGENCE_SERVICE_PROVIDER_H__
-#define __TIZEN_CONVERGENCE_SERVICE_PROVIDER_H__
+/**
+ * @brief Provides detailed error message to API user
+ * @details If some provider callback will returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, it should be called before return.\n
+ * The client can obtain detailed message using #service_adaptor_get_last_result() and  #service_adaptor_get_last_error_message().
+ * @since_tizen 3.0
+ *
+ * @param[in]  code    Error code
+ * @param[in]  message Error message
+ *
+ * @remarks    It must be called in provider callback.
+ * @remarks    It is worked thread safely.
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see        storage_provider_s
+ */
+int service_provider_set_last_error(int code, const char *message);
 
-#include "service_adaptor_errors.h"
-#include "sal_service_provider.h"
-#include "sal_auth_provider.h"
+/**
+ * @brief Sets session event callback
+ * @details The @a session will be started/stopped by Service Adaptor.\n
+ * Originally, it is requested from client.\n
+ * \n
+ * Refer to @ref SERVICE_PROVIDER_MODULE_SESSION_DESCRIPTION
+ * @since_tizen 3.0
+ *
+ * @param[in]  callback        The callback will be invoked when a session event occurred
+ * @param[in]  user_data       Passed data to callback
+ *
+ * @remarks    For getting callback successfully, you must call #service_provider_open_channel() in app_control_cb()
+ * @remarks    This API should be called in app_create_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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see        #service_provider_open_channel()
+ * @see #service_provider_session_event_cb()
+ * @see        #service_plugin_start()
+ * @see        #service_plugin_stop()
+ */
+int service_provider_set_session_event_cb(service_provider_session_event_cb callback, void *user_data);
+
+/**
+ * @brief Unsets session event callback
+ * @since_tizen 3.0
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval     #SERVICE_ADAPTOR_ERROR_NONE                                     Successful
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ */
+int service_provider_unset_session_event_cb(void);
+
+/**
+ * @brief Gets property of session information
+ * @details    The 'property' is kept until to stop session.\n
+ * The property was added by client.\n
+ * Service Provider can check that client has a right for using self.
+ * @since_tizen 3.0
+ *
+ * @param[in]  session         The handle of session information
+ * @param[in]  key                     The key of property
+ * @param[out] value           The value of property
+ *
+ * @remarks    Do not release of memory for a @a value
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see        #service_plugin_add_property()
+ */
+int service_provider_get_session_property(service_provider_session_h session, const char *key, char **value);
+
+/**
+ * @brief Foreach the properties of session
+ * @details    The 'property' was added from client.\n
+ * @since_tizen 3.0
+ *
+ * @param[in]  session         The handle of session information
+ * @param[in]  callback        The callback for foreach property
+ * @param[in]  user_data       Passed data to callback
+ *
+ * @remarks    The foreach callback will be invoked from same thread.
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval     #SERVICE_ADAPTOR_ERROR_NONE                                     Successful
+ * @retval     #SERVICE_ADAPTOR_ERROR_NO_DATA                          There is no data available
+ * @retval     #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER        Invalid parameter
+ * @retval     #SERVICE_ADAPTOR_ERROR_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see        #service_plugin_add_property()
+ * @see        service_provider_session_property_cb()
+ */
+int service_provider_foreach_session_property(service_provider_session_h session, service_provider_session_property_cb callback, void *user_data);
+
+/**
+ * @brief Gets service mask from session.
+ * @details    The 'service_mask' was set by client.\n
+ * Service Provider can check which service will be needed, and start initialize.
+ * @since_tizen 3.0
+ *
+ * @param[in]  session                 The handle of session information
+ * @param[out] service_mask    The flag for use service plugins, this flag can be masked multiple enum (#service_plugin_service_type_e)
+ * @remarks    @a service_mask should be checked using 'bit and' operation with #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_PARAMETER        Invalid parameter
+ * @retval     #SERVICE_ADAPTOR_ERROR_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @code
+ * {
+ *     // ...
+ *     int m_mask = 0;
+ *     int ret = service_provider_get_session_service_mask(m_session, &m_mask);
+ *     if (ret == SERVICE_ADAPTOR_ERROR_NONE) {
+ *         if (m_mask & SERVICE_PLUGIN_SERVICE_STORAGE) {
+ *             // Todo: Initialize storage service
+ *         }
+ *         // ...
+ *     }
+ *     // ...
+ *     return ret;
+ * }
+ * @endcode
+ */
+int service_provider_get_session_service_mask(service_provider_session_h session, int *service_mask);
+
+/**
+ * @}
+ */
 
-#endif /* __TIZEN_CONVERGENCE_SERVICE_PROVIDER_H__ */
+#ifdef __cplusplus
+}
+#endif
+#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_PROVIDER_H__ */
diff --git a/include/service_provider_types.h b/include/service_provider_types.h
new file mode 100644 (file)
index 0000000..4a3ccf3
--- /dev/null
@@ -0,0 +1,988 @@
+/*
+* 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_PROVIDER_TYPE_H__
+#define __TIZEN_SOCIAL_SERVICE_PROVIDER_TYPE_H__
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <service_adaptor_type.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup SERVICE_PROVIDER_MODULE
+
+ * @{
+ */
+
+/**
+ * @brief Definition of app_control operation for providing control to Service Adaptor
+ * @details The Service Provider must be able to receive app-control with this operation
+ * @since_tizen 3.0
+ *
+ * @see service_provider_open_channel()
+ */
+#define APP_CONTROL_OPERATION_SERVICE_PROVIDER_CHANNEL "http://tizen.org/appcontrol/operation/service-provider/channel"
+
+/**
+ * @brief      The object of user session
+ * @details    The session is logical object that is bound to client who use plugin\n
+ * There are multiple session can exist for a one client, because client can use different multiple property for a plugin.\n
+ * Session is created by Service Adaptor and you can obtain this handle in a #storage_provider_s 's callback functions.
+ * @since_tizen 3.0
+ *
+ * @remarks    If you need to divide callback's requester, you can use session handle in callback functions.\n
+ */
+typedef struct _service_provider_session_s *service_provider_session_h;
+
+/**
+ * @}
+ */
+
+
+/**
+ * @addtogroup STORAGE_PROVIDER_MODULE
+ * @{
+ */
+
+/**
+ * @brief The status information of file or directory
+ * @details It includes file's timestamp, size, path and flag for checking directory\n
+ * It designed similar to <b>struct stat</b> in <b><sys/stat.h></b>
+ * @since_tizen 3.0
+*/
+typedef struct _storage_provider_stat_s *storage_provider_stat_h;
+
+/**
+ * @}
+ */
+
+
+/**
+ * @addtogroup SERVICE_PROVIDER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumerations of choice about application state
+ * @details    The application(Service Provider)'s life cycle can be changed by this values
+ * @since_tizen 3.0
+ *
+ * @see        service_provider_channel_cb()
+ */
+typedef enum
+{
+       SERVICE_PROVIDER_RECOMMENDED_DEFAULT    = 0,    /**< The next life cycle will be decided to recommended state  */
+       SERVICE_PROVIDER_APPLICATION_CONTINUE   = 1,    /**< The application will be alive */
+       SERVICE_PROVIDER_APPLICATION_SHUTDOWN   = 2,    /**< The application will be terminated */
+} service_provider_life_cycle_e;
+
+/**
+ * @brief Enumerations of state type for channel between Service Adaptor and Service Provider
+ * @since_tizen 3.0
+ *
+ * @see        service_provider_channel_cb()
+ */
+typedef enum
+{
+       SERVICE_PROVIDER_CHANNEL_OPENED = 1,    /**< The channel was opened */
+       SERVICE_PROVIDER_CHANNEL_CLOSED = 2,    /**< The channel was closed */
+} service_provider_channel_state_e;
+
+/**
+ * @brief Enumerations of event type for client session
+ * @since_tizen 3.0
+ *
+ * @see        service_provider_session_event_cb()
+ */
+typedef enum
+{
+    SERVICE_PROVIDER_SESSION_STARTED    = 1,   /**< The new session was started */
+    SERVICE_PROVIDER_SESSION_STOPPED    = 2,   /**< The session was stopped */
+} service_provider_session_event_e;
+
+/**
+ * @}
+ */
+
+
+/**
+ * @addtogroup STORAGE_PROVIDER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Enumerations of flag for file open
+ * @details    It will be set to #storage_provider_open_cb() 's \a flag parameter.\n
+ * These flags follow \b POSIX. So, almost flags similar to \b POSIX.
+ * Please refer to \b <sys/stat.h> and \b <fcntl.h>
+ *
+ * @since_tizen 3.0
+ *
+ * @remarks    STORAGE_PROVIDER_FLAG_O_THUMBNAIL is specific flag for Service Adaptor.
+ *
+ * @see        storage_provider_open_cb()
+ */
+typedef enum
+{
+       STORAGE_PROVIDER_FLAG_O_RDONLY          = 0x0000,       /**< Open for reading only */
+       STORAGE_PROVIDER_FLAG_O_WRONLY          = 0x0001,       /**< Open for writing only */
+
+       STORAGE_PROVIDER_FLAG_O_CREAT           = 0x0100,       /**< If the file not exists, the file shall be created */
+       STORAGE_PROVIDER_FLAG_O_EXCL            = 0x0200,       /**< If O_CREAT and O_EXCL are set, open() shall fail if the file exists. */
+       STORAGE_PROVIDER_FLAG_O_TRUNC           = 0x0800,       /**< If the file exists, its length shall be truncated to 0 */
+       STORAGE_PROVIDER_FLAG_O_APPEND          = 0x1000,       /**< If set, the file offset shall be set to the end of the file prior to each write */
+       STORAGE_PROVIDER_FLAG_O_THUMBNAIL       = 0xf000,       /**< If set, open thumbnail of file */
+} storage_provider_flag_e;
+
+/**
+ * @}
+ */
+
+
+/**
+ * @addtogroup SERVICE_PROVIDER_MODULE
+
+ * @{
+ */
+
+/**
+ * @brief Callback for getting channel state
+ * @details    Channel is important object for Service Provider.\n
+ * All of the communication is consisted of Channel.\n
+ * \n
+ * <b>Channel opened</b> : \a state is #SERVICE_PROVIDER_CHANNEL_OPENED.\n
+ * "Channel opened" means starting assignment of the Service Provider.\n
+ * \li If function \b returns #SERVICE_PROVIDER_APPLICATION_CONTINUE, working flow will going successfully. (default)\n
+ * \li But, function \b returns #SERVICE_PROVIDER_APPLICATION_SHUTDOWN, the channel will be closed and application will be \b terminated.\n
+ * \li #SERVICE_PROVIDER_RECOMMENDED_DEFAULT has same logic with #SERVICE_PROVIDER_APPLICATION_CONTINUE \n
+ *
+ * <b>Channel closed</b> : \a state is #SERVICE_PROVIDER_CHANNEL_CLOSED.\n
+ * Otherwise, "Channel closed" means that Service Adaptor doesn't need Service Provider now.\n
+ * \li If function \b returns #SERVICE_PROVIDER_APPLICATION_SHUTDOWN, application will be \b terminated. (default)\n
+ * \li But, function \b returns #SERVICE_PROVIDER_APPLICATION_CONTINUE, application keep on launch state. (Not recomended)\n
+ * \li #SERVICE_PROVIDER_RECOMMENDED_DEFAULT has same logic with #SERVICE_PROVIDER_APPLICATION_SHUTDOWN \n
+ *
+ * @since_tizen 3.0
+ *
+ * @param[in]  state           The state type of channel
+ * @param[in]  user_data   The user data passed from #service_provider_open_channel()
+ *
+ * @remarks    For resource efficiency, recommends to terminate provider application.
+ * @remarks    Application can be terminated after this callback.
+ * @remarks    Recommend return \c true, for efficiency of managing.
+ *
+ * @return     #service_provider_life_cycle_e must be returned.
+ * @retval     #SERVICE_PROVIDER_RECOMMENDED_DEFAULT   The next life cycle will be decided to recommended state
+ * @retval     #SERVICE_PROVIDER_APPLICATION_CONTINUE  The application will be alive
+ * @retval     #SERVICE_PROVIDER_APPLICATION_SHUTDOWN  The application will be terminated
+ *
+ * @see #service_provider_channel_state_e
+ * @pre #service_provider_open_channel() will invoke this callback.
+ *
+ * @code
+ * int __channel_state_cb(service_provider_channel_state_e state, void *user_data)
+ * {
+ *     if (state == SERVICE_PROVIDER_CHANNEL_OPENED) {
+ *
+ *         // if provider state is fine
+ *         if (__check_internal_state_fine()) {
+ *
+ *             // keep on launch state and start provider (recommended)
+ *             // same effect with return SERVICE_PROVIDER_APPLICATION_CONTINUE
+ *             return SERVICE_PROVIDER_RECOMMENDED_DEFAULT;
+ *         } else {  // if provider state is bad
+ *
+ *             // application will be terminated
+ *             return SERVICE_PROVIDER_APPLICATION_SHUTDOWN;
+ *         }
+ *
+ *     } else if (state == SERVICE_PROVIDER_CHANNEL_CLOSED) {
+ *
+ *         // if provider need to remain task
+ *         if (__check_remain_task_exist()) {
+ *
+ *             // keep on launch state and do remain work
+ *             return SERVICE_PROVIDER_APPLICATION_CONTINUE;
+ *         } else {  // if provider can be terminated
+ *
+ *             // application will be terminated (recommended)
+ *             // same effect with return SERVICE_PROVIDER_APPLICATION_SHUTDOWN
+ *             return SERVICE_PROVIDER_RECOMMENDED_DEFAULT;
+ *         }
+ *
+ *     }
+ *     // return Recommend default
+ *     return SERVICE_PROVIDER_RECOMMENDED_DEFAULT;
+ * }
+ *
+ * @endcode
+ */
+typedef int (*service_provider_channel_cb)(service_provider_channel_state_e state, void *user_data);
+
+/**
+ * @brief Callback for getting session event
+ * @details    If Provider needs to check property's validation, recommends in this callback.\n
+ * \n
+ * If session \a event flag is "started", maybe someone called #service_plugin_start().\n
+ * Otherwise, session \a event flag is "stopped", maybe someone called #service_plugin_stop().\n
+ * So in this callback, Service Provider response or prepare to client request.\n
+ * \n
+ * But sometimes, session is opened/closed by management policy of Service Adaptor (without client request).
+ * @since_tizen 3.0
+ *
+ * @param[in]  session         The handle of session
+ * @param[in]  event           The event type of session
+ * @param[in]  user_data   The user data passed from #service_provider_set_session_event_cb()
+ *
+ * @see #service_provider_session_event_e
+ * @see #service_provider_set_session_event_cb()
+*/
+typedef void (*service_provider_session_event_cb)(service_provider_session_h session, service_provider_session_event_e event, void *user_data);
+
+/**
+ * @brief Callback for interating property
+ * @since_tizen 3.0
+ *
+ * @param[in]  session         The handle of session information
+ * @param[in]  key                     The key of property
+ * @param[in]  value           The value of property
+ * @param[in]  user_data       Passed data from request function
+ *
+ * @return @c true to continue with the next iteration of the loop,
+ *         otherwise @c false to break out of the loop
+ * @pre  service_provider_foreach_session_property() will invoke this callback.
+ */
+typedef bool (*service_provider_session_property_cb)(service_provider_session_h session, const char *key, const char *value, void *user_data);
+
+/**
+ * @}
+ */
+
+
+/**
+ * @addtogroup STORAGE_PROVIDER_MODULE
+ * @{
+ */
+
+/**
+ * @brief      Initialize to perform operation likes read or write
+ * @details    The provider can prepare to storage operation.\n
+ * As a case, provider can creating libcurl handle \b or creating socket \b or checking device network status \b or allocating memory space \b or etc... various of initialization logic can be performed at this callback.\n
+ * It is fair with #storage_provider_close_cb(). Close callback will be invoked after completing task.\n
+ * \n
+ * This API design is based POSIX API. Please refer to 'open()'.\n
+ * But, the target of open must be a file on storage.
+ * @since_tizen 3.0
+ *
+ * @param[in]  session         Handle of user session
+ * @param[in]  fd                      File descriptor for a file
+ * @param[in]  path            File path on storage
+ * @param[in]  flags           Flags are masked multiply
+ * @param[in]  options         Optional flags be depended on \a flags \n
+ * This parameter is ignored unless the \a flags is not masked #STORAGE_PROVIDER_FLAG_O_WRONLY or #STORAGE_PROVIDER_FLAG_O_THUMBNAIL.
+ * @param[in]  timeout         Operation time out (millisecond)
+ * @param[in]  user_data       Passed data from #service_provider_set_storage_provider()
+ *
+ * @remarks    Callback must be finished in timeout.
+ * @remarks    Callback will be invoked on <b>additional thread</b>(Not main thread).
+ * @remarks    \a fd is unique identifier for a task, and it is kept until finishing task. In same task logic, fd of open_cb, read_cb(write_cb), close_cb  are same.\n
+ * \n
+ * @remarks    \a flags can be masked multiple flag enums. And the \b enum is defined to #storage_provider_flag_e \n
+ * \n
+ * @remarks    If #STORAGE_PROVIDER_FLAG_O_WRONLY is set to \a flags (without #STORAGE_PROVIDER_FLAG_O_THUMBNAIL), \a options is <b>access mode</b> \n
+ * Supporting bellow <b>access mode</b> and it can be masked multiple mode using 'bit and' for a parameter \b \a options.
+ * \li \c \b S_IRWXU 00700 user (file owner) has read, write and execute permission
+ * \li \c \b S_IRUSR 00400 user has read permission
+ * \li \c \b S_IWUSR 00200 user has write permission
+ * \li \c \b S_IXUSR 00100 user has execute permission
+ * \li \c \b S_IRWXG 00070 group has read, write and execute permission
+ * \li \c \b S_IRGRP 00040 group has read permission
+ * \li \c \b S_IWGRP 00020 group has write permission
+ * \li \c \b S_IXGRP 00010 group has execute permission
+ * \li \c \b S_IRWXO 00007 others have read, write and execute permission
+ * \li \c \b S_IROTH 00004 others have read permission
+ * \li \c \b S_IWOTH 00002 others have write permission
+ * \li \c \b S_IXOTH 00001 others have execute permission
+ * \li Upper constant is defined in \b <fcntl.h>
+ * \li Sometimes the access right for \b group and \b others means \b share
+ * \n
+ * @remarks    If #STORAGE_PROVIDER_FLAG_O_THUMBNAIL is set to \a flags, \a options is <b>thumbnail size</b> \n
+ * Supporting bellow <b>thumbnail size</b> and it releates with service_storage_create_download_thumbnail_task()
+ * \li \c \b 0 default size
+ * \li \c \b -1        minimum size
+ * \li \c \b -2        maximum size
+ * \n
+ * @remarks    If not be set #STORAGE_PROVIDER_FLAG_O_WRONLY or #STORAGE_PROVIDER_FLAG_O_THUMBNAIL, \a options is 0 (zero, not valid).\n
+ * \n
+ * @remarks    Sometimes authentication is vitiated by user request or expiring or some policy, then return #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED
+ * @remarks    Before returnning #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, you should call #service_provider_set_last_error().
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval     #SERVICE_ADAPTOR_ERROR_NONE                                     Successful
+ * @retval     #SERVICE_ADAPTOR_ERROR_NOT_SUPPORTED            Not supported operation
+ * @retval     #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER        Invalid parameter
+ * @retval     #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED        Permission denied
+ * @retval     #SERVICE_ADAPTOR_ERROR_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_NETWORK_UNREACHABLE      Network is unreachable
+ * @retval     #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED            Failed by internal plugin issue
+ * @retval     #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED           Need authorized
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see        storage_provider_flag_e
+ * @see        storage_provider_read_cb()
+ * @see        storage_provider_write_cb()
+ * @see        storage_provider_close_cb()
+ * @see service_provider_set_last_error()
+ *
+ * @pre        #service_provider_set_storage_provider() must be called in app_create_cb()
+ * @pre        #service_provider_open_channel() must be called in app_control_cb()
+ */
+typedef int (*storage_provider_open_cb)(service_provider_session_h session,
+                                               int fd,
+                                               const char *path,
+                                               int flags,
+                                               int options,
+                                               int timeout,
+                                               void *user_data);
+
+/**
+ * @brief Read data from descriptor of storage file on storage
+ * @details    Provider should try to read data as much as buf_size, but sometimes it can not read enough.
+ * Then, just assign byte to "result" as amount of read.
+ * \n
+ * This API design is based POSIX API. Please refer to 'read()'.\n
+ * @since_tizen 3.0
+ *
+ * @param[in]  session         Handle of user session
+ * @param[in]  fd                      File descriptor for a file
+ * @param[in,out] buffer       Buffer for getting data
+ * @param[in]  buf_size        Size of buffer
+ * @param[in]  timeout         Operation time out (millisecond)
+ * @param[out] result          On success, the number of bytes read is returned (zero indicates end of file)
+ * @param[in]  user_data       Passed data from #service_provider_set_storage_provider()
+ *
+ * @remarks    Callback must be finished in timeout.
+ * @remarks    Callback will be invoked on <b>additional thread</b>(Not main thread).
+ * @remarks    \a buffer is already allocated memory space as \a buf_size.\n
+ * You can just write data to \a buffer.\n
+ * \n
+ * @remarks    \a result must be input likes bellow
+ * \li \c \b 0 zero indicates end of file.
+ * \li \c <b>positive value</b>        the number of bytes read.
+ * \li \c <b>negative value</b>        can be assigned I/O error (used by POSIX 'read()').
+ * \n
+ * @remarks    Sometimes authentication is vitiated by user request or expiring or some policy, then return #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED
+ * @remarks    Before returnning #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, you should call #service_provider_set_last_error().
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_NETWORK_UNREACHABLE      Network is unreachable
+ * @retval     #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED            Failed by internal plugin issue
+ * @retval     #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED           Need authorized
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see        storage_provider_open_cb()
+ * @see        storage_provider_close_cb()
+ * @see service_provider_set_last_error()
+ *
+ * @pre        #service_provider_set_storage_provider() must be called in app_create_cb()
+ * @pre        #service_provider_open_channel() must be called in app_control_cb()
+ */
+typedef int (*storage_provider_read_cb)(service_provider_session_h session,
+                                               int fd,
+                                               char *buffer,
+                                               int buf_size,
+                                               int timeout,
+                                               int *result,
+                                               void *user_data);
+
+/**
+ * @brief Write data to descriptor of storage file on storage
+ * @details    Provider should try to write data as much as buf_size, but sometimes it can not write enough.
+ * Then, just assign byte to "result" as amount of write.\n
+ * \n
+ * This API design is based POSIX API. Please refer to 'write()'.\n
+ * @since_tizen 3.0
+ *
+ * @param[in]  session         Handle of user session
+ * @param[in]  fd                      File descriptor for a file
+ * @param[in]  buffer          Buffer for writting data
+ * @param[in]  buf_size        Size of buffer
+ * @param[in]  timeout         Operation time out (millisecond)
+ * @param[out] result          On success, the number of bytes written is returned (zero indicates nothing was written)
+ * @param[in]  user_data       Passed data from #service_provider_set_storage_provider()
+ *
+ * @remarks    Callback must be finished in timeout.
+ * @remarks    Callback will be invoked on <b>additional thread</b>(Not main thread).
+ * @remarks    \a result must be input likes bellow
+ * \li \c \b 0 zero indicates nothing was written.
+ * \li \c <b>positive value</b>        the number of bytes written.
+ * \li \c <b>negative value</b>        can be assigned I/O error (used by POSIX 'write()').
+ * \n
+ * @remarks    Sometimes authentication is vitiated by user request or expiring or some policy, then return #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED
+ * @remarks    Before returnning #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, you should call #service_provider_set_last_error().
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_NETWORK_UNREACHABLE      Network is unreachable
+ * @retval     #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED            Failed by internal plugin issue
+ * @retval     #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED           Need authorized
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see        storage_provider_open_cb()
+ * @see        storage_provider_close_cb()
+ * @see service_provider_set_last_error()
+ *
+ * @pre        #service_provider_set_storage_provider() must be called in app_create_cb()
+ * @pre        #service_provider_open_channel() must be called in app_control_cb()
+ */
+typedef int (*storage_provider_write_cb)(service_provider_session_h session,
+                                               int fd,
+                                               char *buffer,
+                                               int buf_size,
+                                               int timeout,
+                                               int *result,
+                                               void *user_data);
+
+/**
+ * @brief Synchronize a file's in-core state with local device from fd
+ * @details    Provider transfers ("flushes") all modified in-core data of (i.e., modified buffer cache pages for) the file referred to by the file descriptor fd to the disk device (or other permanent storage device).\n
+ * \n
+ * This API design is based POSIX API. Please refer to 'fsync()'.\n
+ * @since_tizen 3.0
+ *
+ * @param[in]  session         Handle of user session
+ * @param[in]  fd                      File descriptor for a file
+ * @param[in]  timeout         Operation time out (millisecond)
+ * @param[in]  user_data       Passed data from #service_provider_set_storage_provider()
+ *
+ * @remarks    Callback must be finished in timeout.
+ * @remarks    Callback will be invoked on <b>additional thread</b>(Not main thread).
+ * @remarks    Sometimes authentication is vitiated by user request or expiring or some policy, then return #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED
+ * @remarks    Before returnning #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, you should call #service_provider_set_last_error().
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_NETWORK_UNREACHABLE      Network is unreachable
+ * @retval     #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED            Failed by internal plugin issue
+ * @retval     #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED           Need authorized
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see        storage_provider_open_cb()
+ * @see        storage_provider_read_cb()
+ * @see        storage_provider_write_cb()
+ * @see        storage_provider_close_cb()
+ * @see service_provider_set_last_error()
+ *
+ * @pre        #service_provider_set_storage_provider() must be called in app_create_cb()
+ * @pre        #service_provider_open_channel() must be called in app_control_cb()
+ */
+typedef int (*storage_provider_fsync_cb)(service_provider_session_h session,
+                                               int fd,
+                                               int timeout,
+                                               void *user_data);
+
+/**
+ * @brief      Finalize to perform operation likes read or write
+ * @details    The provider can finalize to storage operation.\n
+ * As a case, provider can releasing libcurl handle \b or closing socket \b or or releasing memory space \b or etc... various of finalization logic can be performed at this callback.\n
+ * It is fair with #storage_provider_open_cb(). Open callback must be invoked before this.\n
+ * \n
+ * This API design is based POSIX API. Please refer to 'close()'.\n
+ * But, the target of close must be a file on storage.
+ * @since_tizen 3.0
+ *
+ * @param[in]  session         Handle of user session
+ * @param[in]  fd                      File descriptor for a file
+ * @param[in]  timeout         Operation time out (millisecond)
+ * @param[in]  user_data       Passed data from #service_provider_set_storage_provider()
+ *
+ * @remarks    Callback must be finished in timeout.
+ * @remarks    Callback will be invoked on <b>additional thread</b>(Not main thread).
+ * @remarks    Sometimes authentication is vitiated by user request or expiring or some policy, then return #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED
+ * @remarks    Before returnning #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, you should call #service_provider_set_last_error().
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_NETWORK_UNREACHABLE      Network is unreachable
+ * @retval     #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED            Failed by internal plugin issue
+ * @retval     #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED           Need authorized
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see        storage_provider_open_cb()
+ * @see        storage_provider_read_cb()
+ * @see        storage_provider_write_cb()
+ * @see service_provider_set_last_error()
+ *
+ * @pre        #service_provider_set_storage_provider() must be called in app_create_cb()
+ * @pre        #service_provider_open_channel() must be called in app_control_cb()
+ */
+typedef int (*storage_provider_close_cb)(service_provider_session_h session,
+                                               int fd,
+                                               int timeout,
+                                               void *user_data);
+
+/**
+ * @brief Removes file or (empty) directory on storage
+ * @details    This API design is based POSIX API. Please refer to 'remove()'.\n
+ * But, the target of remove must be a file or directory on storage.
+ * @since_tizen 3.0
+ *
+ * @param[in]  session         Handle of user session
+ * @param[in]  path            File path on storage
+ * @param[in]  timeout         Operation time out (millisecond)
+ * @param[in]  user_data       Passed data from #service_provider_set_storage_provider()
+ *
+ * @remarks    Callback must be finished in timeout.
+ * @remarks    Callback will be invoked on <b>additional thread</b>(Not main thread).
+ * @remarks    Sometimes authentication is vitiated by user request or expiring or some policy, then return #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED
+ * @remarks    Before returnning #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, you should call #service_provider_set_last_error().
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_NETWORK_UNREACHABLE      Network is unreachable
+ * @retval     #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED            Failed by internal plugin issue
+ * @retval     #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED           Need authorized
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see service_provider_set_last_error()
+ *
+ * @pre        #service_provider_set_storage_provider() must be called in app_create_cb()
+ * @pre        #service_provider_open_channel() must be called in app_control_cb()
+ */
+typedef int (*storage_provider_remove_cb)(service_provider_session_h session,
+                                               const char *path,
+                                               int timeout,
+                                               void *user_data);
+
+/**
+ * @brief Renames file or direvtory on storage
+ * @details    This API design is based POSIX API. Please refer to 'rename()'.\n
+ * But, the target of rename must be a file or directory on storage.
+ * @since_tizen 3.0
+ *
+ * @param[in]  session         Handle of user session
+ * @param[in]  src_path        Source file path on storage
+ * @param[in]  dst_path        Destination file path on storage
+ * @param[in]  timeout         Operation time out (millisecond)
+ * @param[in]  user_data       Passed data from #service_provider_set_storage_provider()
+ *
+ * @remarks    Callback must be finished in timeout.
+ * @remarks    Callback will be invoked on <b>additional thread</b>(Not main thread).
+ * @remarks    Sometimes authentication is vitiated by user request or expiring or some policy, then return #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED
+ * @remarks    Before returnning #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, you should call #service_provider_set_last_error().
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_NETWORK_UNREACHABLE      Network is unreachable
+ * @retval     #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED            Failed by internal plugin issue
+ * @retval     #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED           Need authorized
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see service_provider_set_last_error()
+ *
+ * @pre        #service_provider_set_storage_provider() must be called in app_create_cb()
+ * @pre        #service_provider_open_channel() must be called in app_control_cb()
+ */
+typedef int (*storage_provider_rename_cb)(service_provider_session_h session,
+                                               const char *src_path,
+                                               const char *dst_path,
+                                               int timeout,
+                                               void *user_data);
+
+/**
+ * @brief Makes directory on storage
+ * @details    This API design is based POSIX API. Please refer to 'mkdir()'.\n
+ * But, the target of mkdir must be a directory on storage.
+ * @since_tizen 3.0
+ *
+ * @param[in]  session         Handle of user session
+ * @param[in]  path            Directory path on storage
+ * @param[in]  timeout         Operation time out (millisecond)
+ * @param[in]  user_data       Passed data from #service_provider_set_storage_provider()
+ *
+ * @remarks    Callback must be finished in timeout.
+ * @remarks    Callback will be invoked on <b>additional thread</b>(Not main thread).
+ * @remarks    Sometimes authentication is vitiated by user request or expiring or some policy, then return #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED
+ * @remarks    Before returnning #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, you should call #service_provider_set_last_error().
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_NETWORK_UNREACHABLE      Network is unreachable
+ * @retval     #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED            Failed by internal plugin issue
+ * @retval     #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED           Need authorized
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see service_provider_set_last_error()
+ *
+ * @pre        #service_provider_set_storage_provider() must be called in app_create_cb()
+ * @pre        #service_provider_open_channel() must be called in app_control_cb()
+ */
+typedef int (*storage_provider_mkdir_cb)(service_provider_session_h session,
+                                               const char *path,
+                                               int timeout,
+                                               void *user_data);
+
+/**
+ * @brief Changes to access mode of file or directory on storage
+ * @details    If target path is exist on cloud, it can modify access right for other user.\n
+ * This API design is based POSIX API. Please refer to 'chmod()'.\n
+ * But, the target of chmod must be a file or directory on storage.
+ * @since_tizen 3.0
+ *
+ * @param[in]  session         Handle of user session
+ * @param[in]  path            Directory path on storage
+ * @param[in]  mode            Access mode
+ * @param[in]  timeout         Operation time out (millisecond)
+ * @param[in]  user_data       Passed data from #service_provider_set_storage_provider()
+ *
+ * @remarks    Callback must be finished in timeout.
+ * @remarks    Callback will be invoked on <b>additional thread</b>(Not main thread).
+ * @remarks    Supporting bellow <b>access mode</b> and it can be masked multiple mode using 'bit and' for a parameter \b \a mode.
+ * \li \c \b S_IRWXU 00700 user (file owner) has read, write and execute permission
+ * \li \c \b S_IRUSR 00400 user has read permission
+ * \li \c \b S_IWUSR 00200 user has write permission
+ * \li \c \b S_IXUSR 00100 user has execute permission
+ * \li \c \b S_IRWXG 00070 group has read, write and execute permission
+ * \li \c \b S_IRGRP 00040 group has read permission
+ * \li \c \b S_IWGRP 00020 group has write permission
+ * \li \c \b S_IXGRP 00010 group has execute permission
+ * \li \c \b S_IRWXO 00007 others have read, write and execute permission
+ * \li \c \b S_IROTH 00004 others have read permission
+ * \li \c \b S_IWOTH 00002 others have write permission
+ * \li \c \b S_IXOTH 00001 others have execute permission
+ * \li Upper constant is defined in \b <fcntl.h>
+ * \li Sometimes the access right for \b group and \b others means \b share
+ * \n
+ * @remarks    Sometimes authentication is vitiated by user request or expiring or some policy, then return #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED
+ * @remarks    Before returnning #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, you should call #service_provider_set_last_error().
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_NETWORK_UNREACHABLE      Network is unreachable
+ * @retval     #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED            Failed by internal plugin issue
+ * @retval     #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED           Need authorized
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see service_provider_set_last_error()
+ *
+ * @pre        #service_provider_set_storage_provider() must be called in app_create_cb()
+ * @pre        #service_provider_open_channel() must be called in app_control_cb()
+ */
+typedef int (*storage_provider_chmod_cb)(service_provider_session_h session,
+                                               const char *path,
+                                               int mode,
+                                               int timeout,
+                                               void *user_data);
+
+/**
+ * @brief Check user's permissions for file or directory
+ * @details    This API design is based POSIX API. Please refer to 'access()'.\n
+ * But, the target of access must be a file or directory on storage.
+ * @since_tizen 3.0
+ *
+ * @param[in]  session                 Handle of user session
+ * @param[in]  path                    Directory path on storage
+ * @param[in]  accessibility   The flags for checking accessibility
+ * @param[in]  timeout                 Operation time out (millisecond)
+ * @param[in]  user_data               Passed data from #service_provider_set_storage_provider()
+ *
+ * @remarks    Callback must be finished in timeout.
+ * @remarks    Callback will be invoked on <b>additional thread</b>(Not main thread).
+ * @remarks    Supporting bellow <b>accessibility flags</b> and it can be masked multiple flags using 'bit and' for a parameter \b \a accessibility.
+ * \li \c \b R_OK      4       Test for read permission.
+ * \li \c \b W_OK      2       Test for write permission.
+ * \li \c \b X_OK      1       Test for execute permission.
+ * \li \c \b F_OK      0       Test for existence.
+ * \li Upper constant is defined in \b <unistd.h>
+ * \n
+ * @remarks    If access right is not exist, it must return #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED
+ * @remarks    Sometimes authentication is vitiated by user request or expiring or some policy, then return #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED
+ * @remarks    Before returnning #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, you should call #service_provider_set_last_error().
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_NETWORK_UNREACHABLE      Network is unreachable
+ * @retval     #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED            Failed by internal plugin issue
+ * @retval     #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED           Need authorized
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see service_provider_set_last_error()
+ *
+ * @pre        #service_provider_set_storage_provider() must be called in app_create_cb()
+ * @pre        #service_provider_open_channel() must be called in app_control_cb()
+ */
+typedef int (*storage_provider_access_cb)(service_provider_session_h session,
+                                               const char *path,
+                                               int accessibility,
+                                               int timeout,
+                                               void *user_data);
+
+/**
+ * @brief Gets status information of file or direstory on storage
+ * @details The status includes file's timestamp, size, path and flag for checking directory.\n
+ * \n
+ * This API design is based POSIX API. Please refer to 'stat()'.\n
+ * But, the target of stat must be a file or directory on storage.
+ * @since_tizen 3.0
+ *
+ * @param[in]  session         Handle of user session
+ * @param[in]  path            Directory path on storage
+ * @param[in,out] stat         Status of file
+ * @param[in]  timeout         Operation time out (millisecond)
+ * @param[in]  user_data       Passed data from #service_provider_set_storage_provider()
+ *
+ * @remarks    Callback must be finished in timeout.
+ * @remarks    Callback will be invoked on <b>additional thread</b>(Not main thread).
+ * @remarks    For returning success, provider must fill status to \a stat handle.
+ * @remarks    \a stat is already allocated memory space.
+ * @remarks    Sometimes authentication is vitiated by user request or expiring or some policy, then return #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED
+ * @remarks    Before returnning #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, you should call #service_provider_set_last_error().
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_NETWORK_UNREACHABLE      Network is unreachable
+ * @retval     #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED            Failed by internal plugin issue
+ * @retval     #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED           Need authorized
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see        #storage_provider_stat_h
+ * @see storage_provider_stat_set_path()
+ * @see        storage_provider_stat_set_size()
+ * @see        storage_provider_stat_set_dir()
+ * @see        storage_provider_stat_set_mode()
+ * @see        storage_provider_stat_set_atime()
+ * @see        storage_provider_stat_set_mtime()
+ * @see        storage_provider_stat_set_ctime()
+ * @see service_provider_set_last_error()
+ *
+ * @pre        #service_provider_set_storage_provider() must be called in app_create_cb()
+ * @pre        #service_provider_open_channel() must be called in app_control_cb()
+ */
+typedef int (*storage_provider_stat_cb)(service_provider_session_h session,
+                                               const char *path,
+                                               storage_provider_stat_h stat,
+                                               int timeout,
+                                               void *user_data);
+
+/**
+ * @brief Open and gets status information of directory entries on storage.
+ * @details    It should get all of the status information of directory of storage.\n
+ * After this callback, #storage_provider_readdir_cb() will be invoked and requires \a stat handle of entry element.\n
+ * \n
+ * This API design is based POSIX API. Please refer to 'opendir()'.\n
+ * But, the target of opendir must be a directory on storage.
+ * @since_tizen 3.0
+ *
+ * @param[in]  session         Handle of user session
+ * @param[in]  fd                      Descriptor of a directory
+ * @param[in]  path            Directory path on storage
+ * @param[in]  timeout         Operation time out (millisecond)
+ * @param[in]  user_data       Passed data from #service_provider_set_storage_provider()
+ *
+ * @remarks    Callback must be finished in timeout.
+ * @remarks    Callback will be invoked on <b>additional thread</b>(Not main thread).
+ * @remarks    \a fd is unique identifier for a task, and it is kept until finishing task. In same task logic, fd of opendir_cb, readdir_cb, closedir_cb  are same.\n
+ * @remarks    Sometimes authentication is vitiated by user request or expiring or some policy, then return #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED
+ * @remarks    Before returnning #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, you should call #service_provider_set_last_error().
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_NETWORK_UNREACHABLE      Network is unreachable
+ * @retval     #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED            Failed by internal plugin issue
+ * @retval     #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED           Need authorized
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see        storage_provider_readdir_cb()
+ * @see        storage_provider_closedir_cb()
+ * @see service_provider_set_last_error()
+ *
+ * @pre        #service_provider_set_storage_provider() must be called in app_create_cb()
+ * @pre        #service_provider_open_channel() must be called in app_control_cb()
+ */
+typedef int (*storage_provider_opendir_cb)(service_provider_session_h session,
+                                               int fd,
+                                               const char *path,
+                                               int timeout,
+                                               void *user_data);
+
+/**
+ * @brief Reads file status information of directory element.
+ * @details    Iterates of information from fd.\n
+ * It can obtains status information in due order.\n
+ * It will be invoked until callback returns #SERVICE_ADAPTOR_ERROR_NO_DATA.\n
+ * \n
+ * This API design is based POSIX API. Please refer to 'readdir()'.\n
+ * But, the target of readdir must be a directory on storage.
+ * @since_tizen 3.0
+ *
+ * @param[in]  session         Handle of user session
+ * @param[in]  fd                      Descriptor of a directory
+ * @param[in,out] stat         Status of file
+ * @param[in]  timeout         Operation time out (millisecond)
+ * @param[in]  user_data       Passed data from #service_provider_set_storage_provider()
+ *
+ * @remarks    Callback must be finished in timeout.
+ * @remarks    Callback will be invoked on <b>additional thread</b>(Not main thread).
+ * @remarks    If end of diretory entry, callback must returns #SERVICE_ADAPTOR_ERROR_NO_DATA and do not set any data to \a stat handle.
+ * @remarks    For returning success, provider must fill status to \a stat handle.
+ * @remarks    \a stat is already allocated memory space.
+ * @remarks    Sometimes authentication is vitiated by user request or expiring or some policy, then return #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED
+ * @remarks    Before returnning #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, you should call #service_provider_set_last_error().
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval     #SERVICE_ADAPTOR_ERROR_NONE                                     Successful
+ * @retval     #SERVICE_ADAPTOR_ERROR_NO_DATA                          There is no data available
+ * @retval     #SERVICE_ADAPTOR_ERROR_PERMISSION_DENIED        Permission denied
+ * @retval     #SERVICE_ADAPTOR_ERROR_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_NETWORK_UNREACHABLE      Network is unreachable
+ * @retval     #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED            Failed by internal plugin issue
+ * @retval     #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED           Need authorized
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see        #storage_provider_stat_h
+ * @see storage_provider_stat_set_path()
+ * @see        storage_provider_stat_set_size()
+ * @see        storage_provider_stat_set_dir()
+ * @see        storage_provider_stat_set_mode()
+ * @see        storage_provider_stat_set_atime()
+ * @see        storage_provider_stat_set_mtime()
+ * @see        storage_provider_stat_set_ctime()
+ * @see        storage_provider_opendir_cb()
+ * @see        storage_provider_closedir_cb()
+ * @see service_provider_set_last_error()
+ *
+ * @pre        #service_provider_set_storage_provider() must be called in app_create_cb()
+ * @pre        #service_provider_open_channel() must be called in app_control_cb()
+ */
+typedef int (*storage_provider_readdir_cb)(service_provider_session_h session,
+                                               int fd,
+                                               storage_provider_stat_h stat,
+                                               int timeout,
+                                               void *user_data);
+
+/**
+ * @brief Finalize to perform operation likes readdir.
+ * @details    The provider can finalize to storage operation.\n
+ * \n
+ * This API design is based POSIX API. Please refer to 'closedir()'.\n
+ * But, the target of closedir must be a directory on storage.
+ * @since_tizen 3.0
+ *
+ * @param[in]  session         Handle of user session
+ * @param[in]  fd                      Descriptor of a directory
+ * @param[in]  timeout         Operation time out (millisecond)
+ * @param[in]  user_data       Passed data from #service_provider_set_storage_provider()
+ *
+ * @remarks    Callback must be finished in timeout.
+ * @remarks    Callback will be invoked on <b>additional thread</b>(Not main thread).
+ * @remarks    Sometimes authentication is vitiated by user request or expiring or some policy, then return #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED
+ * @remarks    Before returnning #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, you should call #service_provider_set_last_error().
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval     #SERVICE_ADAPTOR_ERROR_NONE                                     Successful
+ * @retval     #SERVICE_ADAPTOR_ERROR_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_NETWORK_UNREACHABLE      Network is unreachable
+ * @retval     #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED            Failed by internal plugin issue
+ * @retval     #SERVICE_ADAPTOR_ERROR_NOT_AUTHORIZED           Need authorized
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ *
+ * @see        storage_provider_opendir_cb()
+ * @see        storage_provider_readdir_cb()
+ * @see service_provider_set_last_error()
+ *
+ * @pre        #service_provider_set_storage_provider() must be called in app_create_cb()
+ * @pre        #service_provider_open_channel() must be called in app_control_cb()
+ */
+typedef int (*storage_provider_closedir_cb)(service_provider_session_h session,
+                                               int fd,
+                                               int timeout,
+                                               void *user_data);
+
+/**
+ * @brief      The structure type containing the set of callback functions for providing storage service.
+ * @details    For providing storage feature, all of the structure elements(callbacks) are assigned to provider's functions.
+ * @since_tizen 3.0
+ *
+ * @see        storage_provider_open_cb()
+ * @see        storage_provider_read_cb()
+ * @see        storage_provider_write_cb()
+ * @see        storage_provider_fsync_cb()
+ * @see        storage_provider_close_cb()
+ * @see        storage_provider_remove_cb()
+ * @see        storage_provider_rename_cb()
+ * @see        storage_provider_mkdir_cb()
+ * @see        storage_provider_chmod_cb()
+ * @see        storage_provider_access_cb()
+ * @see        storage_provider_stat_cb()
+ * @see        storage_provider_opendir_cb()
+ * @see        storage_provider_readdir_cb()
+ * @see        storage_provider_closedir_cb()
+*/
+typedef struct
+{
+       storage_provider_open_cb                open;           /**< This callback function must be able to initialize of operation for file on storage (likes POSIX 'open')*/
+       storage_provider_read_cb                read;           /**< This callback function must be able to read from descriptor of storage file on storage (likes POSIX 'read')*/
+       storage_provider_write_cb               write;          /**< This callback function must be able to write to descriptor of storage file on storage (likes POSIX 'write')*/
+       storage_provider_fsync_cb               fsync;          /**< This callback function must be able to synchronize changes to file or directory on storage (likes POSIX 'fsync')*/
+       storage_provider_close_cb               close;          /**< This callback function must be able to deinitialize of operation for file on storage (likes POSIX 'close')*/
+
+       storage_provider_remove_cb              remove;         /**< This callback function must be able to remove to file or directory on storage (likes POSIX 'remove')*/
+       storage_provider_rename_cb              rename;         /**< This callback function must be able to rename to file or directory on storage (likes POSIX 'rename')*/
+       storage_provider_mkdir_cb               mkdir;          /**< This callback function must be able to make directory on storage (likes POSIX 'mkdir')*/
+       storage_provider_chmod_cb               chmod;          /**< This callback function must be able to change mode of file or directory on storage (likes POSIX 'chmod')*/
+       storage_provider_access_cb              access;         /**< This callback function must be able to check user's permissions for file or directory on storage (likes POSIX 'access')*/
+       storage_provider_stat_cb                stat;           /**< This callback function must be able to get status for file or directory on storage (likes POSIX 'stat')*/
+
+       storage_provider_opendir_cb             opendir;        /**< This callback function must be able to get descriptor of storage directory  (likes POSIX 'opendir')*/
+       storage_provider_readdir_cb             readdir;        /**< This callback function must be able to get attribute of directory entry from descriptor of storage directory  (likes POSIX 'readdir')*/
+       storage_provider_closedir_cb    closedir;       /**< This callback function must be able to close descriptor of storage directory  (likes POSIX 'closedir')*/
+} storage_provider_s;
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __TIZEN_SOCIAL_SERVICE_PROVIDER_TYPE_H__ */
diff --git a/include/storage_provider.h b/include/storage_provider.h
new file mode 100644 (file)
index 0000000..266299c
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+* 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_PROVIDER_STORAGE_H__
+#define __TIZEN_SOCIAL_SERVICE_PROVIDER_STORAGE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <service_provider_type.h>
+
+/**
+ * @addtogroup STORAGE_PROVIDER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Sets file path to handle of stat
+ * @since_tizen 3.0
+ *
+ * @param[in]  stat            Status handle of file or directory
+ * @param[in]  path            Path of file on storage
+ *
+ * @remarks    For the description style of the \a \b path , follow the linux root file system.
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ */
+int storage_provider_stat_set_path(storage_provider_stat_h stat, const char *path);
+
+/**
+ * @brief Sets file size to handle of stat
+ * @since_tizen 3.0
+ *
+ * @param[in]  stat            Status handle of file or directory
+ * @param[in]  size            Size of file
+ *
+ * @remarks    For the unit of the \a \b size , use "byte".
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ */
+int storage_provider_stat_set_size(storage_provider_stat_h stat, unsigned long long size);
+
+/**
+ * @brief Sets diretory type to handle of stat
+ * @since_tizen 3.0
+ *
+ * @param[in]  stat            Status handle of file or directory
+ * @param[in]  is_dir          On true, it is directory
+ *
+ * @remarks    If not be called this API, the defalut type is \b false (not a directory).
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ */
+int storage_provider_stat_set_dir(storage_provider_stat_h stat, bool is_dir);
+
+/**
+ * @brief Sets access mode to handle of stat
+ * @details    The stat's perpose is getting files information.\n
+ * If provider sets illegal access mode, it can be a cause of malfunction.
+ * @since_tizen 3.0
+ *
+ * @param[in]  stat            Status handle of file or directory
+ * @param[in]  mode            Access mode
+ *
+ * @remarks    Supporting bellow <b>access mode</b> and it can be masked multiple mode using 'bit and' for a parameter \b \a mode.
+ * \li \c \b S_IRWXU 00700 user (file owner) has read, write and execute permission
+ * \li \c \b S_IRUSR 00400 user has read permission
+ * \li \c \b S_IWUSR 00200 user has write permission
+ * \li \c \b S_IXUSR 00100 user has execute permission
+ * \li \c \b S_IRWXG 00070 group has read, write and execute permission
+ * \li \c \b S_IRGRP 00040 group has read permission
+ * \li \c \b S_IWGRP 00020 group has write permission
+ * \li \c \b S_IXGRP 00010 group has execute permission
+ * \li \c \b S_IRWXO 00007 others have read, write and execute permission
+ * \li \c \b S_IROTH 00004 others have read permission
+ * \li \c \b S_IWOTH 00002 others have write permission
+ * \li \c \b S_IXOTH 00001 others have execute permission
+ * \li Upper constant is defined in \b <fcntl.h>
+ * \li Sometimes the access right for \b group and \b others means \b share
+ * \n
+ * @remarks    If not be called this API, the defalut mode is \b S_IRWXU.
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ */
+int storage_provider_stat_set_mode(storage_provider_stat_h stat, int mode);
+
+/**
+ * @brief Sets time of last access to handle of stat
+ * @since_tizen 3.0
+ *
+ * @param[in]  stat            Status handle of file or directory
+ * @param[in]  timestamp       Time of last access
+ *
+ * @remarks    For the description style of the \a \b timestamp , follow the Unix time (also known as POSIX time or Epoch time).
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ */
+int storage_provider_stat_set_atime(storage_provider_stat_h stat, unsigned long long timestamp);
+
+/**
+ * @brief Sets time of last modification to handle of stat
+ * @since_tizen 3.0
+ *
+ * @param[in]  stat            Status handle of file or directory
+ * @param[in]  timestamp       Time of last modification
+ *
+ * @remarks    For the description style of the \a \b timestamp , follow the Unix time (also known as POSIX time or Epoch time).
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ */
+int storage_provider_stat_set_mtime(storage_provider_stat_h stat, unsigned long long timestamp);
+
+/**
+ * @brief Sets time of last status change to handle of stat
+ * @since_tizen 3.0
+ *
+ * @param[in]  stat            Status handle of file or directory
+ * @param[in]  timestamp       Time of last status change
+ *
+ * @remarks    For the description style of the \a \b timestamp , follow the Unix time (also known as POSIX time or Epoch time).
+ *
+ * @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_OUT_OF_MEMORY            Out of memory
+ * @retval     #SERVICE_ADAPTOR_ERROR_UNKNOWN                          Unknown error
+ */
+int storage_provider_stat_set_ctime(storage_provider_stat_h stat, unsigned long long timestamp);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __TIZEN_SOCIAL_SERVICE_PROVIDER_STORAGE_H__ */
index c50af57287ed4d0177b70974b17d9faefc8b9823..d239048c9111c3823002830697f2975fc6ca0faf 100644 (file)
@@ -14,15 +14,17 @@ BuildRequires:  pkgconfig(gio-2.0)
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(gobject-2.0)
 BuildRequires:  pkgconfig(gthread-2.0)
+BuildRequires:  pkgconfig(bundle)
 BuildRequires:  pkgconfig(capi-base-common)
 BuildRequires:  pkgconfig(capi-appfw-application)
 BuildRequires:  pkgconfig(capi-appfw-app-manager)
 BuildRequires:  pkgconfig(capi-appfw-package-manager)
+BuildRequires:  pkgconfig(capi-appfw-service-application)
 BuildRequires:  pkgconfig(libsmack)
-BuildRequires:  pkgconfig(service-discovery)
-BuildRequires:  pkgconfig(service-federation)
-BuildRequires:  service-discovery-devel
-BuildRequires:  service-federation-devel
+#BuildRequires:  pkgconfig(service-discovery)
+#BuildRequires:  pkgconfig(service-federation)
+#BuildRequires:  service-discovery-devel
+#BuildRequires:  service-federation-devel
 
 %description
 Service Adaptor Framework Library/Binary package
@@ -81,7 +83,7 @@ cp LICENSE.APLv2 %{buildroot}/usr/share/license/service-adaptor-devel
 %defattr(-,root,root,-)
 %{_libdir}/lib*.so.*
 %{_bindir}/service-adaptor-server
-%{_bindir}/sal-test
+#%{_bindir}/sal-test
 %{_unitdir_user}/service-adaptor.service
 %{_unitdir_user}/default.target.wants/service-adaptor.service
 %{_datadir}/dbus-1/system-services/org.tizen.serviceadaptor.client.service
index a8ae0d366b9dfd562cecd7279172368be96a67e2..ea5a36f17d686e721be72901f5037b2381e64f02 100644 (file)
@@ -21,28 +21,30 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,--gc-sections -fPIE")
 
 SET(MAIN-EXE "service-adaptor-server")
 SET(MAIN-SRCS
-        ${CMAKE_SOURCE_DIR}/server/sal_auth.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_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
+#        ${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
+#        ${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 service-discovery service-federation)
+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}")
@@ -55,5 +57,5 @@ 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-server auth-adaptor contact-adaptor storage-adaptor resource-adaptor)
+TARGET_LINK_LIBRARIES(${MAIN-EXE} ${main_pkgs_LDFLAGS} sal-common-base sal-common-server sal-common-adaptor)
 INSTALL(TARGETS ${MAIN-EXE} DESTINATION bin)
diff --git a/server/sal_auth.c b/server/sal_auth.c
deleted file mode 100644 (file)
index 484fa30..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Service Adaptor
- *
- * Copyright (c) 2014 - 2015 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 "sal_auth.h"
-#include "service_adaptor_internal.h"
-
-/******************************************************************************
- * Global variables and defines
- ******************************************************************************/
-
-/******************************************************************************
- * Private interface
- ******************************************************************************/
-
-/******************************************************************************
- * Private interface definition
- ******************************************************************************/
-void _sal_auth_login_cb(const char *uri, void *user_data)
-{
-}
-
-/******************************************************************************
- * Public interface definition
- ******************************************************************************/
-
-auth_adaptor_listener_h sal_auth_register_listener(auth_adaptor_h auth)
-{
-       SAL_FN_CALL;
-
-       auth_adaptor_listener_h listener =
-                       (auth_adaptor_listener_h) g_malloc0(sizeof(auth_adaptor_listener_s));
-
-       listener->login_cb = _sal_auth_login_cb;
-
-       int ret = auth_adaptor_register_listener(auth, listener);
-
-       if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
-               SAL_FREE(listener);
-       }
-
-       return listener;
-}
diff --git a/server/sal_auth.h b/server/sal_auth.h
deleted file mode 100644 (file)
index 4a37fd3..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Service Adaptor
- *
- * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Yongjin Kim <youth.kim@samsung.com>
- *          Jinhyeong Ahn <jinh.ahn@samsung.com>
- *          Jiwon Kim <jiwon177.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT 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_CONVERGENCE_SAL_AUTH_H__
-#define __TIZEN_CONVERGENCE_SAL_AUTH_H__
-
-#include "auth_adaptor.h"
-
-auth_adaptor_listener_h sal_auth_register_listener(auth_adaptor_h auth);
-
-#endif /* __TIZEN_CONVERGENCE_SAL_AUTH_H__ */
diff --git a/server/sal_base.c b/server/sal_base.c
new file mode 100644 (file)
index 0000000..fba3315
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Service Adaptor
+ *
+ * Copyright (c) 2014 - 2015 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 "sal_log.h"
+#include "sal_types.h"
+#include "sal_ipc.h"
+
+#include "sal_base.h"
+
+#include "sal_ipc_server_core.h"
+
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+void client_connect_cb(ipc_server_session_h session, int pid, const char *client_uri)
+{
+       SAL_FN_CALL;
+       SAL_FN_END;
+}
+
+void client_disconnect_cb(ipc_server_session_h session, int pid, const char *client_uri)
+{
+       SAL_FN_CALL;
+       SAL_FN_END;
+}
+
+void client_plugin_start_cb(ipc_server_session_h session,
+               int client_pid, const char *client_uri,
+               const char *plugin_uri, int service_mask) /* TODO: add property param */
+{
+       SAL_FN_CALL;
+       SAL_FN_END;
+}
+
+void client_plugin_stop_cb(ipc_server_session_h session,
+               const char *plugin_handle)
+{
+       SAL_FN_CALL;
+       SAL_FN_END;
+}
diff --git a/server/sal_base.h b/server/sal_base.h
new file mode 100644 (file)
index 0000000..a4f7e6b
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Service Adaptor
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yongjin Kim <youth.kim@samsung.com>
+ *          Jinhyeong Ahn <jinh.ahn@samsung.com>
+ *          Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_CONVERGENCE_SAL_BASE_H__
+#define __TIZEN_CONVERGENCE_SAL_BASE_H__
+
+#include "sal_types.h"
+#include "sal_ipc_server_core.h"
+
+void client_connect_cb(ipc_server_session_h session, int pid, const char *client_uri);
+
+void client_disconnect_cb(ipc_server_session_h session, int pid, const char *client_uri);
+
+void client_plugin_start_cb(ipc_server_session_h session,
+               int client_pid, const char *client_uri,
+               const char *plugin_uri, int service_mask); /* TODO: add property param */
+
+void client_plugin_stop_cb(ipc_server_session_h session,
+               const char *plugin_handle);
+
+#endif /* __TIZEN_CONVERGENCE_SAL_BASE_H__ */
index 27be4f85a6b319c10d19d7104c13026da043836a..499e54ab53a4a02a4360274bd7f09552aa2b15df 100644 (file)
@@ -37,7 +37,7 @@
 /******************************************************************************
  * Public interface definition
  ******************************************************************************/
-
+/*
 contact_adaptor_listener_h sal_contact_register_listener(contact_adaptor_h contact)
 {
        int ret = SERVICE_ADAPTOR_ERROR_NONE;
@@ -53,3 +53,4 @@ contact_adaptor_listener_h sal_contact_register_listener(contact_adaptor_h conta
 
        return listener;
 }
+*/
index 7092783b1a73ece90be6385749a6fa1cc1f12889..2a36da04ea1c748e7e8b6c35e2b263d7597e0005 100644 (file)
@@ -23,9 +23,9 @@
 
 #ifndef __TIZEN_CONVERGENCE_SAL_CONTACT_H__
 #define __TIZEN_CONVERGENCE_SAL_CONTACT_H__
-
+/*
 #include "contact_adaptor.h"
 
 contact_adaptor_listener_h sal_contact_register_listener(contact_adaptor_h contact);
-
+*/
 #endif /* __TIZEN_CONVERGENCE_SAL_CONTACT_H__ */
diff --git a/server/sal_engine.c b/server/sal_engine.c
new file mode 100644 (file)
index 0000000..35a14b0
--- /dev/null
@@ -0,0 +1,326 @@
+/*
+ * Service Adaptor
+ *
+ * Copyright (c) 2014 - 2015 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 "sal_log.h"
+#include "sal_types.h"
+
+#include "sal_engine.h"
+
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
+
+static sal_engine_mode_e g_mode;
+
+/*
+static GMainLoop *ipc_engines[SAL_ENGINE_SERVICE] = NULL;
+
+static GMainLoop *ipc_adaptor_engine = NULL;
+
+static GMainLoop *main_engine = NULL;
+
+static GMainLoop *engines[SAL_ENGINE_SERVICE] = NULL;
+
+static GMainLoop *file_engine = NULL;
+*/
+static GMainLoop *engine_loops[5] = {NULL, };
+
+static GThread *engine_threads[5] = {NULL, };
+
+static char *engine_names[5] = {"main", "service", "file", "ipc server", "ipc adaptor"};
+
+USER_DATA_TYPEDEF(engine_task_data_t, 2);
+
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
+
+static void *__engine_runnable(void *user_data);
+
+static gboolean *__engine_task_runnable(void *data);
+
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
+
+static void *__engine_runnable(void *user_data)
+{
+       SAL_FN_CALL;
+       GMainLoop *loop = (GMainLoop *)user_data;
+       int n = 0;
+       for (n = SAL_ENGINE_MAIN; n < SAL_ENGINE_MAX; n++) {
+               if (loop == engine_loops[n])
+                       break;
+       }
+       if (SAL_ENGINE_MAX < n) {
+               SAL_ERR("Thread critical error");
+               return NULL;
+       }
+
+       GMainContext *ctx = g_main_loop_get_context(engine_loops[n]);
+       g_main_context_push_thread_default(ctx);
+
+       SAL_INFO("==: Engine thread running success <%s>, ", engine_names[n]);
+       g_main_loop_run(engine_loops[n]);
+       SAL_INFO("==: Engine thread loop finished <%s>, ", engine_names[n]);
+
+       g_main_context_pop_thread_default(ctx);
+
+       engine_threads[n] = NULL;
+       SAL_FN_END;
+       return NULL;
+}
+
+static gboolean *__engine_task_runnable(void *data)
+{
+       SAL_FN_CALL;
+       RETV_IF(NULL == data, FALSE);
+
+       USER_DATA_DEFINE(engine_task_data_t, task_data) = (USER_DATA_TYPE(engine_task_data_t) *)data;
+       sal_engine_task_logic callback = (sal_engine_task_logic)USER_DATA_ELEMENT(task_data, 0);
+       user_data_t user_data = (user_data_t)USER_DATA_ELEMENT(task_data, 1);
+
+       if (callback) {
+               SAL_DBG("----- Task handoff start -----");
+               callback(user_data);
+               SAL_DBG("----- Task handoff end -----");
+       }
+
+       SAL_FN_END;
+       return FALSE;
+}
+
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
+
+int sal_engine_init(sal_engine_mode_e mode)
+{
+       SAL_FN_CALL;
+       int ret = SAL_ERROR_NONE;
+       g_mode = mode;
+
+       GMainContext *main_context = NULL;
+       GMainContext *server_context = NULL;
+       GMainContext *file_context = NULL;
+       GMainContext *ipc_server_context = NULL;
+       GMainContext *ipc_adaptor_context = NULL;
+
+       main_context = g_main_context_new();
+       TRY_IF(NULL == main_context);
+       engine_loops[SAL_ENGINE_MAIN] = g_main_loop_new(main_context, FALSE);
+       TRY_IF(NULL == engine_loops[SAL_ENGINE_MAIN]);
+
+       server_context = g_main_context_new();
+       TRY_IF(NULL == server_context);
+       engine_loops[SAL_ENGINE_SERVICE] = g_main_loop_new(server_context, FALSE);
+       TRY_IF(NULL == server_context);
+
+       file_context = g_main_context_new();
+       TRY_IF(NULL == file_context);
+       engine_loops[SAL_ENGINE_FILE] = g_main_loop_new(file_context, FALSE);
+       TRY_IF(NULL == engine_loops[SAL_ENGINE_FILE]);
+
+       if (SAL_ENGINE_MODE_DEFAULT == mode) {
+               ipc_server_context = g_main_context_new();
+               TRY_IF(NULL == ipc_server_context);
+               engine_loops[SAL_ENGINE_IPC_SERVER] = g_main_loop_new(ipc_server_context, FALSE);
+               TRY_IF(NULL == engine_loops[SAL_ENGINE_IPC_SERVER]);
+
+               ipc_adaptor_context = g_main_context_new();
+               TRY_IF(NULL == ipc_adaptor_context);
+               engine_loops[SAL_ENGINE_IPC_ADAPTOR] = g_main_loop_new(ipc_adaptor_context, FALSE);
+               TRY_IF(NULL == engine_loops[SAL_ENGINE_IPC_ADAPTOR]);
+       } else {
+               ipc_server_context = main_context;
+               engine_loops[SAL_ENGINE_IPC_SERVER] = engine_loops[SAL_ENGINE_MAIN];
+
+               ipc_adaptor_context = server_context;
+               engine_loops[SAL_ENGINE_IPC_ADAPTOR] = engine_loops[SAL_ENGINE_SERVICE];
+       }
+
+       SAL_FN_END;
+       return ret;
+
+catch:
+       if (engine_loops[SAL_ENGINE_MAIN])
+               g_main_loop_unref(engine_loops[SAL_ENGINE_MAIN]);
+       if (engine_loops[SAL_ENGINE_SERVICE])
+               g_main_loop_unref(engine_loops[SAL_ENGINE_SERVICE]);
+       if (engine_loops[SAL_ENGINE_FILE])
+               g_main_loop_unref(engine_loops[SAL_ENGINE_FILE]);
+
+       if (SAL_ENGINE_MODE_DEFAULT == mode) {
+               if (engine_loops[SAL_ENGINE_IPC_SERVER])
+                       g_main_loop_unref(engine_loops[SAL_ENGINE_IPC_SERVER]);
+               if (engine_loops[SAL_ENGINE_IPC_ADAPTOR])
+                       g_main_loop_unref(engine_loops[SAL_ENGINE_IPC_ADAPTOR]);
+       }
+
+       if (main_context)
+               g_main_context_unref(main_context);
+       if (server_context)
+               g_main_context_unref(server_context);
+       if (file_context)
+               g_main_context_unref(file_context);
+
+       if (SAL_ENGINE_MODE_DEFAULT == mode) {
+               if (ipc_server_context)
+                       g_main_context_unref(ipc_server_context);
+               if (ipc_adaptor_context)
+                       g_main_context_unref(ipc_adaptor_context);
+       }
+
+       engine_loops[SAL_ENGINE_MAIN] = NULL;
+       engine_loops[SAL_ENGINE_SERVICE] = NULL;
+       engine_loops[SAL_ENGINE_FILE] = NULL;
+       engine_loops[SAL_ENGINE_IPC_SERVER] = NULL;
+       engine_loops[SAL_ENGINE_IPC_ADAPTOR] = NULL;
+
+       SAL_FN_END;
+//     return SAL_ERROR_OUT_OF_MEMORY;
+       return SAL_ERROR_SYSTEM;
+}
+
+int sal_engine_deinit()
+{
+       SAL_FN_CALL;
+       int ret = SAL_ERROR_NONE;
+       sal_engine_mode_e mode = g_mode;
+
+       if (engine_loops[SAL_ENGINE_MAIN]) {
+               g_main_context_unref(g_main_loop_get_context(engine_loops[SAL_ENGINE_MAIN]));
+               g_main_loop_unref(engine_loops[SAL_ENGINE_MAIN]);
+       }
+       if (engine_loops[SAL_ENGINE_SERVICE]) {
+               g_main_context_unref(g_main_loop_get_context(engine_loops[SAL_ENGINE_SERVICE]));
+               g_main_loop_unref(engine_loops[SAL_ENGINE_SERVICE]);
+       }
+       if (engine_loops[SAL_ENGINE_FILE])
+               g_main_context_unref(g_main_loop_get_context(engine_loops[SAL_ENGINE_FILE]));
+               g_main_loop_unref(engine_loops[SAL_ENGINE_FILE]);
+
+       if (SAL_ENGINE_MODE_DEFAULT == mode) {
+               if (engine_loops[SAL_ENGINE_IPC_SERVER]) {
+                       g_main_context_unref(g_main_loop_get_context(engine_loops[SAL_ENGINE_IPC_SERVER]));
+                       g_main_loop_unref(engine_loops[SAL_ENGINE_IPC_SERVER]);
+               }
+               if (engine_loops[SAL_ENGINE_IPC_ADAPTOR]) {
+                       g_main_context_unref(g_main_loop_get_context(engine_loops[SAL_ENGINE_IPC_ADAPTOR]));
+                       g_main_loop_unref(engine_loops[SAL_ENGINE_IPC_ADAPTOR]);
+               }
+       }
+
+       engine_loops[SAL_ENGINE_MAIN] = NULL;
+       engine_loops[SAL_ENGINE_SERVICE] = NULL;
+       engine_loops[SAL_ENGINE_FILE] = NULL;
+       engine_loops[SAL_ENGINE_IPC_SERVER] = NULL;
+       engine_loops[SAL_ENGINE_IPC_ADAPTOR] = NULL;
+
+       SAL_FN_END;
+       return ret;
+}
+
+GMainLoop *sal_get_engine_loop(sal_engine_e engine)
+{
+       if ((0 < engine) && (SAL_ENGINE_MAX > engine))
+               return engine_loops[engine];
+
+       return NULL;
+}
+
+int sal_engine_run(sal_engine_e engine)
+{
+       if ((SAL_ENGINE_MAIN > engine) || (SAL_ENGINE_MAX <= engine)) {
+               return SAL_ERROR_INVALID_PARAMETER;
+       }
+
+       if (g_main_loop_is_running(engine_loops[engine])) {
+               SAL_INFO("engine (%d) already running");
+               return SAL_ERROR_NONE;
+       }
+
+       engine_threads[engine] = g_thread_new(engine_names[engine], __engine_runnable, (void *)engine_loops[engine]);
+       RETVM_IF(NULL == engine_threads[engine], SAL_ERROR_INTERNAL, "Thread creation failed");
+
+       return SAL_ERROR_NONE;
+}
+
+int sal_engine_quit(sal_engine_e engine)
+{
+       if ((SAL_ENGINE_MAIN > engine) || (SAL_ENGINE_MAX <= engine)) {
+               return SAL_ERROR_INVALID_PARAMETER;
+       }
+
+       RETV_IF(NULL == engine_loops[engine], SAL_ERROR_NONE);
+
+       if (FALSE == g_main_loop_is_running(engine_loops[engine])) {
+               SAL_INFO("engine (%d) does not running");
+               return SAL_ERROR_INTERNAL;
+       }
+
+       g_main_loop_quit(engine_loops[engine]);
+
+       return SAL_ERROR_NONE;
+}
+
+int sal_engine_main_run()
+{
+       RETV_IF(NULL == engine_loops[SAL_ENGINE_MAIN], SAL_ERROR_INVALID_PARAMETER);
+
+       g_main_loop_run(engine_loops[SAL_ENGINE_MAIN]);
+
+       return SAL_ERROR_NONE;
+}
+
+int sal_engine_main_quit()
+{
+       RETV_IF(NULL == engine_loops[SAL_ENGINE_MAIN], SAL_ERROR_INVALID_PARAMETER);
+
+       if (FALSE == g_main_loop_is_running(engine_loops[SAL_ENGINE_MAIN])) {
+               SAL_INFO("engine (%d) does not running");
+               return SAL_ERROR_INTERNAL;
+       }
+
+       g_main_loop_quit(engine_loops[SAL_ENGINE_MAIN]);
+       return SAL_ERROR_NONE;
+}
+
+int sal_engine_task_handoff(sal_engine_e target_engine, sal_engine_task_logic logic, user_data_t data)
+{
+       SAL_FN_CALL;
+       RETV_IF(NULL == engine_threads[target_engine], SAL_ERROR_INTERNAL);
+       RETV_IF(FALSE == g_main_loop_is_running(engine_loops[target_engine]), SAL_ERROR_INTERNAL);
+
+       USER_DATA_DEFINE(engine_task_data_t, task_data) = USER_DATA_CREATE(engine_task_data_t);
+       RETV_IF(NULL == USER_DATA_VAL(task_data), SAL_ERROR_SYSTEM);
+
+       USER_DATA_ELEMENT(task_data, 0) = (user_data_t)logic;
+       USER_DATA_ELEMENT(task_data, 1) = (user_data_t)data;
+
+       g_main_context_invoke_full(g_main_loop_get_context(engine_loops[target_engine]),
+                       G_PRIORITY_DEFAULT, __engine_task_runnable,
+                       USER_DATA_VAL(task_data), USER_DATA_DESTROY_FUNC);
+
+       SAL_FN_END;
+       return SAL_ERROR_NONE;
+}
+
diff --git a/server/sal_engine.h b/server/sal_engine.h
new file mode 100644 (file)
index 0000000..6e23931
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Service Adaptor
+ *
+ * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yongjin Kim <youth.kim@samsung.com>
+ *          Jinhyeong Ahn <jinh.ahn@samsung.com>
+ *          Jiwon Kim <jiwon177.kim@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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_CONVERGENCE_SAL_ENGINE_H__
+#define __TIZEN_CONVERGENCE_SAL_ENGINE_H__
+
+#include "sal_types.h"
+
+#include <glib.h>
+
+typedef enum
+{
+       SAL_ENGINE_MODE_DEFAULT = 0,
+       SAL_ENGINE_MODE_SLIM    = 1,
+} sal_engine_mode_e;
+
+typedef enum
+{
+       SAL_ENGINE_MAIN = 0,
+       SAL_ENGINE_SERVICE = 1,
+       SAL_ENGINE_FILE = 2,
+       SAL_ENGINE_IPC_SERVER = 3,
+       SAL_ENGINE_IPC_ADAPTOR = 4,
+       SAL_ENGINE_MAX = 5,
+} sal_engine_e;
+
+
+typedef void (*sal_engine_task_logic)(user_data_t data);
+
+
+int sal_engine_init(sal_engine_mode_e mode);
+
+int sal_engine_deinit(void);
+
+GMainLoop *sal_get_engine_loop(sal_engine_e engine);
+
+int sal_engine_run(sal_engine_e engine);
+
+int sal_engine_quit(sal_engine_e engine);
+
+int sal_engine_main_run(void);
+
+int sal_engine_main_quit(void);
+
+int sal_engine_task_handoff(sal_engine_e target_engine, sal_engine_task_logic logic, user_data_t data);
+
+
+#endif /* __TIZEN_CONVERGENCE_SAL_ENGINE_H__ */
index 75139961882bb698cfeb5a9e4cd5accaa2665ee9..0f559784fc29d8bffc43078028c7f81facf545d0 100644 (file)
@@ -20,7 +20,7 @@
 #include <stdio.h>
 #include <glib-object.h>
 #include <glib-unix.h>
-
+/*
 #include <app.h>
 
 #include "service_adaptor_internal.h"
 
 #include "service_discovery.h"
 #include "service_federation.h"
+*/
+
+#include "sal_ipc_server.h"
+
+#include "sal_log.h"
+#include "sal_types.h"
+
+#include "sal_engine.h"
+#include "sal_base.h"
 
 /******************************************************************************
  * Global variables and defines
  ******************************************************************************/
+/*
 #define FILE_PATH_LEN  256
 
 static sal_h g_service_adaptor = NULL;
-
+*/
 /******************************************************************************
  * Private interface
  ******************************************************************************/
 
+static int __thread_engine_init(void);
+
+static int __thread_engine_deinit(void);
+
+static int __ipc_server_init(void);
+
+static int __ipc_server_deinit(void);
+
+static void __glog_handler_cb(const gchar *log_domain,
+               GLogLevelFlags log_level,
+               const gchar *message,
+               gpointer user_data);
+
 /******************************************************************************
  * Private interface definition
  ******************************************************************************/
 
+static void __glog_handler_cb(const gchar *log_domain,
+               GLogLevelFlags log_level,
+               const gchar *message,
+               gpointer user_data)
+{
+       SAL_ERR("============================================================");
+       SAL_ERR("============================================================");
+       SAL_ERR("================== Critical GLib Error =====================");
+       SAL_ERR("============================================================");
+       SAL_ERR("============================================================");
+       SAL_ERR("=== Log Domain : %s", log_domain);
+       SAL_ERR("=== Level : %d", (int)log_level);
+       SAL_ERR("=== Message : %s", message);
+       SAL_ERR("============================================================");
+       SAL_ERR("============================================================");
+}
+
 /**
  * @brief callback of app control
  *
  * @return      void.
  */
+/*
 static bool _app_control_extra_data_cb(app_control_h app_control, const char *key, void *user_data)
 {
        char *value = NULL;
@@ -68,12 +109,13 @@ static bool _app_control_extra_data_cb(app_control_h app_control, const char *ke
 
        return true;
 }
-
+*/
 /**
  * @brief callback of plugin connection
  *
  * @return      void.
  */
+/*
 static void _provider_connect_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
 {
        SAL_FN_CALL;
@@ -110,12 +152,13 @@ static void _provider_connect_cb(app_control_h request, app_control_h reply, app
 
        SAL_FN_END;
 }
-
+*/
 /**
  * @brief callback of plugin disconnection
  *
  * @return      void.
  */
+/*
 static void _provider_disconnect_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
 {
        SAL_FN_CALL;
@@ -132,16 +175,17 @@ static void _provider_disconnect_cb(app_control_h request, app_control_h reply,
        auth_adaptor_unregister_plugin_service(plugin);
        auth_adaptor_destroy_plugin(plugin);
 
-       /* TODO: destroy plugin of other adaptor */
+       // TODO: destroy plugin of other adaptor
 
        SAL_FN_END;
 }
-
+*/
 /**
  * @brief create spec file
  *
  * @return      void.
  */
+/*
 static service_adaptor_error_e _sal_create_spec_file(sal_h sal)
 {
        SAL_FN_CALL;
@@ -151,12 +195,13 @@ static service_adaptor_error_e _sal_create_spec_file(sal_h sal)
 
        return ret;
 }
-
+*/
 /**
  * @brief destroy spec file
  *
  * @return      void.
  */
+/*
 static service_adaptor_error_e _sal_destroy_spec_file(sal_h sal)
 {
        SAL_FN_CALL;
@@ -166,12 +211,13 @@ static service_adaptor_error_e _sal_destroy_spec_file(sal_h sal)
 
        return ret;
 }
-
+*/
 /**
  * @brief start service adaptor
  *
  * @return      void.
  */
+/*
 static service_adaptor_error_e _sal_start(sal_h sal)
 {
        SAL_FN_CALL;
@@ -201,12 +247,13 @@ static service_adaptor_error_e _sal_start(sal_h sal)
 
        return ret;
 }
-
+*/
 /**
  * @brief stop service adaptor
  *
  * @return      void.
  */
+/*
 static service_adaptor_error_e _sal_stop(sal_h sal)
 {
        SAL_FN_CALL;
@@ -225,51 +272,52 @@ static service_adaptor_error_e _sal_stop(sal_h sal)
 
        return ret;
 }
-
+*/
 /**
  * @brief create service adaptor
  *
  * @return      void.
  */
+/*
 static sal_h _sal_create()
 {
        SAL_FN_CALL;
 
        sal_h sal = NULL;
 
-       /* 1) create auth adaptor handle */
+       // 1) create auth adaptor handle
        auth_adaptor_h auth = auth_adaptor_create();
        TRYM_IF(NULL == auth, "sal_auth_create_handle() Fail");
 
-       /* 2) create contact adaptor handle */
+       // 2) create contact adaptor handle
        contact_adaptor_h contact = contact_adaptor_create();
        TRYM_IF(NULL == contact, "sal_contact_create_handle() Fail");
 
-       /* 3) create storage adaptor handle */
+       // 3) create storage adaptor handle
        storage_adaptor_h storage = storage_adaptor_create();
        TRYM_IF(NULL == storage, "sal_storage_create_handle() Fail");
 
-       /* 4) create resource adaptor handle */
+       // 4) create resource adaptor handle
        resource_adaptor_h resource = resource_adaptor_create();
        TRYM_IF(NULL == resource, "sal_resource_create_handle() Fail");
 
-       /* 5) register auth adaptor listener */
+       // 5) register auth adaptor listener
        auth_adaptor_listener_h auth_listener = sal_auth_register_listener(auth);
        TRYM_IF(NULL == auth_listener, "sal_auth_register_listener() Fail");
 
-       /* 6) register contact adaptor listener */
+       // 6) register contact adaptor listener
        contact_adaptor_listener_h contact_listener = sal_contact_register_listener(contact);
        TRYM_IF(NULL == contact_listener, "sal_contact_register_listener() Fail");
 
-       /* 7) register storage adaptor listener */
+       // 7) register storage adaptor listener
        storage_adaptor_listener_h storage_listener = sal_storage_register_listener(storage);
        TRYM_IF(NULL == storage_listener, "sal_storage_register_listener() Fail");
 
-       /* 8) register resource adaptor listener */
+       // 8) register resource adaptor listener
        resource_adaptor_listener_h resource_listener = sal_resource_register_listener(resource);
        TRYM_IF(NULL == resource_listener, "sal_resource_register_listener() Fail");
 
-       /* 9) create service adaptor */
+       // 9) create service adaptor
        sal = (sal_h) g_malloc0(sizeof(sal_s));
        TRYM_IF(NULL == sal, "could not create service adaptor");
 
@@ -282,75 +330,204 @@ static sal_h _sal_create()
        g_cond_init(&sal->cond);
 
 catch:
-       /* TODO: free */
+       // TODO: free
 
        return sal;
 }
+*/
 
 /**
  * @brief destroy service adaptor
  *
  * @return      void.
  */
+/*
 static void _sal_destroy(sal_h sal)
 {
        SAL_FN_CALL;
 
        RET_IF(NULL == sal);
 
-       /* 1) destroy service list */
+       // 1) destroy service list
        if (NULL != sal->svc_list) {
                g_list_free(sal->svc_list);
                sal->svc_list = NULL;
        }
 
-       /* 2) free service adaptor handle */
+       // 2) free service adaptor handle
        SAL_FREE(sal);
 
        SAL_FN_END;
 }
+*/
+
+static int __thread_engine_init()
+{
+       SAL_FN_CALL;
+       int ret = 0;
+       ret = sal_engine_init(SAL_ENGINE_MODE_DEFAULT);
+       RETVM_IF(SAL_ERROR_NONE != ret, ret, "Working thread init failed : %d", ret);
+
+       for (sal_engine_e en = (SAL_ENGINE_MAIN + 1); en < SAL_ENGINE_MAX; en++) {
+               ret = sal_engine_run(en);
+               TRYM_IF(ret, "Working therad(%d) running failed : %d", (int)en, ret);
+       }
+
+       SAL_FN_END;
+       return ret;
+
+catch:
+       for (sal_engine_e en = (SAL_ENGINE_MAIN + 1); en < SAL_ENGINE_MAX; en++) {
+               ret = sal_engine_quit(en);
+       }
+       sal_engine_deinit();
+
+       SAL_FN_END;
+       return SAL_ERROR_INTERNAL;
+}
+
+static int __thread_engine_deinit()
+{
+       SAL_FN_CALL;
+       int ret = 0;
+
+       for (sal_engine_e en = (SAL_ENGINE_MAIN + 1); en < SAL_ENGINE_MAX; en++) {
+               ret = sal_engine_quit(en);
+       }
+       sal_engine_deinit();
+
+       SAL_FN_END;
+       return SAL_ERROR_INTERNAL;
+}
+
+static void __temp_chunk_cb(ipc_server_session_h session)
+{}
+
+static void __ipc_server_open(user_data_t data)
+{
+       SAL_FN_CALL;
+       GMainLoop *loop = sal_get_engine_loop(SAL_ENGINE_SERVICE);
+       if (!loop)
+               return;
+
+       GMainContext *service_engine_context = g_main_loop_get_context(loop);
+
+       static ipc_server_base_req_s base_request = {client_connect_cb,
+                       client_disconnect_cb,
+                       client_plugin_start_cb,
+                       client_plugin_stop_cb};
+
+       static ipc_server_auth_req_s auth_request = {__temp_chunk_cb};
+
+       static ipc_server_storage_req_s storage_request = {__temp_chunk_cb};
+
+       int ret = sal_ipc_server_init(service_engine_context, &base_request, &auth_request, &storage_request);
+       if (ret) {
+               SAL_ERR("ipc server init error : %d", ret);
+       }
+
+       SAL_FN_END;
+}
+
+static void __ipc_server_close(user_data_t data)
+{
+       SAL_FN_CALL;
+
+       int ret = sal_ipc_server_deinit();
+       if (ret) {
+               SAL_ERR("ipc server deinit error : %d", ret);
+       }
+
+       SAL_FN_END;
+}
+
+static int __ipc_server_init(void)
+{
+       SAL_FN_CALL;
+       int ret = SAL_ERROR_NONE;
+
+       ret = sal_engine_task_handoff(SAL_ENGINE_IPC_SERVER, __ipc_server_open, NULL);
+
+       SAL_FN_END;
+       return ret;
+}
+
+static int __ipc_server_deinit(void)
+{
+       SAL_FN_CALL;
+       int ret = SAL_ERROR_NONE;
+
+       ret = sal_engine_task_handoff(SAL_ENGINE_IPC_SERVER, __ipc_server_close, NULL);
+
+       SAL_FN_END;
+       return ret;
+}
 
 /**
- * @brief init service adaptor
+ * @brief oiit service adaptor
  *
  * @return      void.
  */
-static service_adaptor_error_e _sal_init()
+static sal_error_e __sal_init()
 {
        SAL_FN_CALL;
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       int ret = SAL_ERROR_NONE;
+
+       g_log_set_handler("GLib", G_LOG_LEVEL_CRITICAL, __glog_handler_cb, NULL);
+
+       /* 1) create engine (based g_main_loop) */
+       ret = __thread_engine_init();
+       SAL_INFO("Initialize 1. Thread engine : %d", ret);
+       if (ret) {
+               return SAL_ERROR_INTERNAL;
+       }
+       sleep(1); // TODO fix sync with thread init
 
+       ret = __ipc_server_init();
+       SAL_INFO("Initialize 2. IPC Server : %d", ret);
+       if (ret) {
+               ret = __thread_engine_deinit();
+               return SAL_ERROR_INTERNAL;
+       }
        /* 1) create adaptor (memory allocation) */
+/*
        sal_h sal = _sal_create();
        RETVM_IF(NULL == sal, SERVICE_ADAPTOR_ERROR_INTERNAL, "_sal_create() Fail");
-
+*/
        /* 2) start adaptor (plugin loading) */
+/*
        ret = _sal_start(sal);
        RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_INTERNAL, "_sal_start() Fail(%d)", ret);
-
+*/
        /* 3) start adaptor (spec file creation) */
+/*
        ret = _sal_create_spec_file(sal);
        RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_INTERNAL, "_sal_create_spec_file() Fail(%d)", ret);
-
+*/
        /* 4) init dbus server */
+/*
        ret = sal_ipc_server_init();
        RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE, "sal_ipc_server_init() Fail(%d)", ret);
-
+*/
        /* 5) assign to global service adaptor handle */
+/*
        g_service_adaptor = sal;
-
+*/
        /* 6) register callback for package event */
+/*
        ret = sal_observer_start();
        RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "sal_observer_start() Fail(%d)", ret);
-
+*/
        /* 7) create service discovery */
+/*
        ret = service_discovery_create();
        RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "service_discovery_create() Fail(%d)", ret);
-
+*/
        /* 8) create service federation */
+/*
        ret = service_federation_create();
        RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "service_federation_create() Fail(%d)", ret);
-
+*/
        return ret;
 }
 
@@ -360,12 +537,15 @@ static service_adaptor_error_e _sal_init()
  * @param[in]   service_adaptor         specifies handle of service adaptor
  * @return      void.
  */
-static void _sal_deinit(sal_h sal)
+static void __sal_deinit()
 {
        SAL_FN_CALL;
 
-       RET_IF(NULL == sal);
+       //RET_IF(NULL == sal);
 
+       int ret = __thread_engine_deinit();
+
+/*
        sal_ipc_server_deinit();
 
        _sal_destroy_spec_file(sal);
@@ -375,7 +555,7 @@ static void _sal_deinit(sal_h sal)
        }
 
        _sal_destroy(sal);
-
+*/
        SAL_FN_END;
 }
 
@@ -387,7 +567,7 @@ static void _sal_deinit(sal_h sal)
  */
 static gint _sigterm_callback(void *data)
 {
-       g_main_loop_quit((GMainLoop*)data);
+       sal_engine_main_quit();
 
        return 0;
 }
@@ -401,7 +581,7 @@ static gint _sigterm_callback(void *data)
  */
 int main(int argc, char *argv[])
 {
-       int ret = SERVICE_ADAPTOR_ERROR_NONE;
+       int ret = SAL_ERROR_NONE;
        GMainLoop *loop = NULL;
 
 #if !GLIB_CHECK_VERSION(2, 32, 0)
@@ -411,11 +591,11 @@ int main(int argc, char *argv[])
        g_type_init();
 #endif
 
-       ret = _sal_init();
-       RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, 0, "_sal_init() Fail(%d)", ret);
+       ret = __sal_init();
+//     RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, 0, "_sal_init() Fail(%d)", ret);
 
        /* mainloop of main thread */
-       loop = g_main_loop_new(NULL, FALSE);
+//     loop = g_main_loop_new(NULL, FALSE);
 
        /* installing signal handlers */
        g_unix_signal_add_full(G_PRIORITY_HIGH, SIGINT,
@@ -424,13 +604,10 @@ int main(int argc, char *argv[])
                        _sigterm_callback, loop, NULL);
 
        /* start application's main loop */
-       g_main_loop_run(loop);
+       sal_engine_main_run();
 
-       /* cleanup after mainloop */
-       g_main_loop_unref(loop);
-
-       sal_h sal = sal_get_handle();
-       _sal_deinit(sal);
+//     sal_h sal = sal_get_handle();
+       __sal_deinit();
 
        return 0;
 }
@@ -438,7 +615,7 @@ int main(int argc, char *argv[])
 /******************************************************************************
  * Public interface definition
  ******************************************************************************/
-
+/*
 API sal_h sal_get_handle()
 {
        SAL_FN_CALL;
@@ -453,7 +630,7 @@ API char *sal_get_root_path()
        char *root_path = NULL;
        char tnfs_root_path[FILE_PATH_LEN] = {0,};
 
-       /* TODO: tmp -> need to use get_path APIs of TNFS */
+       // TODO: tmp -> need to use get_path APIs of TNFS
        snprintf(tnfs_root_path, FILE_PATH_LEN, "%s", "/opt/storage/tnfs");
        root_path = strdup(tnfs_root_path);
 
@@ -567,3 +744,4 @@ API char *sal_provider_get_uri(const char *package)
 
        return uri;
 }
+*/
index 0d900000c4ae3834407b2fd84d7c93e19d5ef837..9a0f712d19a098cafb50d2e1f3a97ef1b8922dde 100644 (file)
@@ -20,7 +20,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <glib.h>
-
+/*
 #include <tizen.h>
 #include <app.h>
 #include <app_info.h>
@@ -31,7 +31,7 @@
 #include "sal.h"
 #include "sal_observer.h"
 #include "auth_adaptor.h"
-
+*/
 /******************************************************************************
  * Global variables and defines
  ******************************************************************************/
@@ -50,6 +50,7 @@
  *
  * @return      void.
  */
+/*
 static bool _sal_app_meta_cb(const char *key, const char *value, void *user_data)
 {
        SAL_FN_CALL;
@@ -67,12 +68,14 @@ static bool _sal_app_meta_cb(const char *key, const char *value, void *user_data
 
        return true;
 }
+*/
 
 /**
  * @brief callback of app info
  *
  * @return      void.
  */
+/*
 static bool _sal_app_info_cb(package_info_app_component_type_e comp_type, const char *app_id, void *user_data)
 {
        SAL_FN_CALL;
@@ -93,12 +96,14 @@ static bool _sal_app_info_cb(package_info_app_component_type_e comp_type, const
 
        return true;
 }
+*/
 
 /**
  * @brief callback of package manager
  *
  * @return      void.
  */
+/*
 static void _sal_package_event_cb(const char *type,
                const char *package,
                package_manager_event_type_e event_type,
@@ -137,15 +142,16 @@ static void _sal_package_event_cb(const char *type,
                storage_adaptor_unregister_plugin_service(storage_plugin);
                storage_adaptor_destroy_plugin(storage_plugin);
 
-               /* TODO: destroy plugin of other adaptor */
+               // TODO: destroy plugin of other adaptor
        }
 }
-
+*/
 /**
  * @brief callback of package_manager_foreach_package_info()
  *
  * @return      void.
  */
+/*
 static bool _sal_package_info_cb(package_info_h package_info, void *user_data)
 {
        SAL_FN_CALL;
@@ -161,6 +167,7 @@ static bool _sal_package_info_cb(package_info_h package_info, void *user_data)
 
        return true;
 }
+*/
 
 /******************************************************************************
  * Public interface definition
@@ -171,6 +178,7 @@ static bool _sal_package_info_cb(package_info_h package_info, void *user_data)
  *
  * @return      void.
  */
+/*
 service_adaptor_error_e sal_observer_start()
 {
        SAL_FN_CALL;
@@ -185,12 +193,14 @@ service_adaptor_error_e sal_observer_start()
 
        return SERVICE_ADAPTOR_ERROR_NONE;
 }
+*/
 
 /**
  * @brief register existing plugin using package manager
  *
  * @return      void.
  */
+/*
 service_adaptor_error_e sal_observer_register_existed_plugin()
 {
        SAL_FN_CALL;
@@ -202,3 +212,4 @@ service_adaptor_error_e sal_observer_register_existed_plugin()
 
        return SERVICE_ADAPTOR_ERROR_NONE;
 }
+*/
index 01c962ee6232a428fc38f2a9e95ed912e1547ca4..ad1116019b908585c381b1d0e9c8dcd497349b09 100644 (file)
@@ -25,8 +25,8 @@
 #define __TIZEN_CONVERGENCE_SAL_OBSERVER_H__
 
 #include "service_adaptor_errors.h"
-
+/*
 service_adaptor_error_e sal_observer_start();
 service_adaptor_error_e sal_observer_register_existed_plugin();
-
+*/
 #endif /* __TIZEN_CONVERGENCE_SAL_OBSERVER_H__ */
index 7e7168a11e19d3fe1c6e5690adf0969445631eea..f1bc74c3b4472824e9193d76efe117ee87e649ee 100644 (file)
@@ -37,7 +37,7 @@
 /******************************************************************************
  * Public interface definition
  ******************************************************************************/
-
+/*
 resource_adaptor_listener_h sal_resource_register_listener(resource_adaptor_h resource)
 {
        int ret = SERVICE_ADAPTOR_ERROR_NONE;
@@ -53,3 +53,4 @@ resource_adaptor_listener_h sal_resource_register_listener(resource_adaptor_h re
 
        return listener;
 }
+*/
index e79c2f715d46d55a1d64a0831876f673a21e8fed..ef90567f4c4f2e0c6a2fb628d6609fd2d6a36b11 100644 (file)
@@ -23,9 +23,9 @@
 
 #ifndef __TIZEN_CONVERGENCE_SAL_RESOURCE_H__
 #define __TIZEN_CONVERGENCE_SAL_RESOURCE_H__
-
+/*
 #include "resource_adaptor.h"
 
 resource_adaptor_listener_h sal_resource_register_listener(resource_adaptor_h resource);
-
+*/
 #endif /* __TIZEN_CONVERGENCE_SAL_RESOURCE_H__ */
index a7e99b8d19818a6a72e56ea5cb078113fac3800a..4b4d1330243ecb57621c408a0a659f664db31fbb 100644 (file)
@@ -37,7 +37,7 @@
 /******************************************************************************
  * Public interface definition
  ******************************************************************************/
-
+/*
 storage_adaptor_listener_h sal_storage_register_listener(storage_adaptor_h storage)
 {
        int ret = SERVICE_ADAPTOR_ERROR_NONE;
@@ -53,3 +53,4 @@ storage_adaptor_listener_h sal_storage_register_listener(storage_adaptor_h stora
 
        return listener;
 }
+*/
index b01955e7a5e7298f44c085fa6d8fe4d615298a4d..7b12f505a9e1a12033e75ae2bdfd864c35f8f885 100644 (file)
@@ -25,7 +25,7 @@
 #define __TIZEN_CONVERGENCE_SAL_STORAGE_H__
 
 #include "storage_adaptor.h"
-
+/*
 storage_adaptor_listener_h sal_storage_register_listener(storage_adaptor_h storage);
-
+*/
 #endif /* __TIZEN_CONVERGENCE_SAL_STORAGE_H__ */
index ea30104e36cdd5382d8d2fdd10ee4ff390c9df11..f785c3a7ef0e286471884c3baa51c648ad56296a 100644 (file)
@@ -5,8 +5,8 @@ includedir=${prefix}/include
 Name: service-adaptor library
 Description: service-adaptor library 1.0
 
-Requires: capi-base-common
+Requires: capi-base-common bundle
 Version: @VERSION@
 
-Libs: -L${libdir} -lsal-common-client -lservice-adaptor-client -lservice-provider
+Libs: -L${libdir} -lservice-adaptor-client -lservice-provider
 Cflags: -I${includedir}/service-adaptor -I${includedir}/service-provider