From 4f12e3e3c887d5a27157ccb3c7d5e8da5fa25d90 Mon Sep 17 00:00:00 2001 From: Jiwon Kim Date: Fri, 26 Feb 2016 14:31:22 +0900 Subject: [PATCH] Clears repository for downgrade to version 1.x of service-adaptor framework Change-Id: Ic96882d6f328cd5b7c01edffc5c5d3b27a3e7737 Signed-off-by: Jiwon Kim --- CMakeLists.txt | 6 +- Documentation/architecture/Dependency.txt | 49 -- adaptor/{CMakeLists.txt => CMakeLists.txt.backup} | 0 adaptor/auth-adaptor/auth_adaptor.c | 349 -------- adaptor/auth-adaptor/auth_adaptor.h | 135 --- adaptor/auth-adaptor/oauth1_service.c | 164 ---- adaptor/auth-adaptor/oauth1_service.h | 104 --- adaptor/auth-adaptor/oauth2_service.c | 109 --- adaptor/auth-adaptor/oauth2_service.h | 103 --- adaptor/contact-adaptor/contact_adaptor.c | 39 - adaptor/contact-adaptor/contact_adaptor.h | 79 -- adaptor/resource-adaptor/resource_adaptor.c | 58 -- adaptor/resource-adaptor/resource_adaptor.h | 119 --- adaptor/storage-adaptor/cloud_service.c | 199 ----- adaptor/storage-adaptor/cloud_service.h | 114 --- adaptor/storage-adaptor/posix_service.h | 103 --- adaptor/storage-adaptor/storage_adaptor.c | 351 -------- adaptor/storage-adaptor/storage_adaptor.h | 132 --- api/client/sal_client_internal.c | 81 -- api/client/sal_client_internal.h | 47 - api/client/sal_client_types.h | 58 -- api/client/sal_service_adaptor.c | 420 --------- api/client/sal_service_adaptor.h | 46 - api/client/sal_service_auth.c | 230 ----- api/client/sal_service_auth.h | 66 -- api/client/sal_service_auth_internal.h | 58 -- api/client/sal_service_storage.c | 630 -------------- api/client/sal_service_storage.h | 75 -- api/client/sal_service_storage_internal.h | 162 ---- api/client/sal_service_task.c | 203 ----- api/client/sal_service_task.h | 63 -- api/client/sal_service_task_internal.h | 64 -- common/{CMakeLists.txt => CMakeLists.txt.backup} | 0 common/base/sal_ipc.c | 107 --- common/base/sal_ipc.h | 322 ------- common/base/sal_log.h | 172 ---- common/base/sal_types.h | 106 --- common/ipc-adaptor/sal_ipc_adaptor.c | 468 ---------- common/ipc-adaptor/sal_ipc_adaptor.h | 57 -- common/ipc-adaptor/sal_ipc_adaptor_types.h | 55 -- common/ipc-adaptor/sal_ipc_client_auth.c | 45 - common/ipc-adaptor/sal_ipc_client_auth.h | 45 - common/ipc-adaptor/sal_ipc_client_core.c | 211 ----- common/ipc-adaptor/sal_ipc_client_core.h | 51 -- common/ipc-adaptor/sal_ipc_client_storage.c | 130 --- common/ipc-adaptor/sal_ipc_client_storage.h | 45 - common/ipc-client/sal_ipc_client.c | 531 ------------ common/ipc-client/sal_ipc_client.h | 67 -- common/ipc-client/sal_ipc_client_auth.c | 45 - common/ipc-client/sal_ipc_client_auth.h | 45 - common/ipc-client/sal_ipc_client_core.c | 211 ----- common/ipc-client/sal_ipc_client_core.h | 51 -- common/ipc-client/sal_ipc_client_storage.c | 130 --- common/ipc-client/sal_ipc_client_storage.h | 45 - common/ipc-provider/sal_ipc_provider.c | 446 ---------- common/ipc-provider/sal_ipc_provider.h | 64 -- common/ipc-provider/sal_ipc_provider_base.c | 302 ------- common/ipc-provider/sal_ipc_provider_base.h | 91 -- common/ipc-provider/sal_ipc_provider_storage.c | 232 ----- common/ipc-provider/sal_ipc_provider_storage.h | 65 -- common/ipc-provider/sal_ipc_provider_types.h | 67 -- common/ipc-server/sal_ipc_server.c | 463 ---------- common/ipc-server/sal_ipc_server.h | 55 -- common/ipc-server/sal_ipc_server_auth.c | 247 ------ common/ipc-server/sal_ipc_server_auth.h | 63 -- common/ipc-server/sal_ipc_server_core.c | 572 ------------- common/ipc-server/sal_ipc_server_core.h | 100 --- common/ipc-server/sal_ipc_server_storage.c | 249 ------ common/ipc-server/sal_ipc_server_storage.h | 74 -- common/ipc-server/sal_ipc_server_types.h | 62 -- include/service_adaptor_client.h | 208 ----- include/service_adaptor_client_plugin.h | 174 ---- include/service_adaptor_client_storage.h | 642 -------------- include/service_adaptor_client_type.h | 154 ---- include/service_adaptor_type.h | 103 --- include/service_provider.h | 267 ------ include/service_provider_types.h | 988 ---------------------- include/storage_provider.h | 175 ---- server/{CMakeLists.txt => CMakeLists.txt.backup} | 0 server/sal.h | 73 -- server/sal_base.c | 72 -- server/sal_base.h | 41 - server/sal_coherence.c | 0 server/sal_contact.c | 56 -- server/sal_contact.h | 31 - server/sal_engine.c | 326 ------- server/sal_engine.h | 68 -- server/sal_generator.c | 0 server/sal_group.c | 0 server/sal_main.c | 747 ---------------- server/sal_observer.c | 215 ----- server/sal_observer.h | 32 - server/sal_resource.c | 56 -- server/sal_resource.h | 31 - server/sal_storage.c | 56 -- server/sal_storage.h | 31 - 96 files changed, 3 insertions(+), 15050 deletions(-) delete mode 100644 Documentation/architecture/Dependency.txt rename adaptor/{CMakeLists.txt => CMakeLists.txt.backup} (100%) delete mode 100644 adaptor/auth-adaptor/auth_adaptor.c delete mode 100644 adaptor/auth-adaptor/auth_adaptor.h delete mode 100644 adaptor/auth-adaptor/oauth1_service.c delete mode 100644 adaptor/auth-adaptor/oauth1_service.h delete mode 100644 adaptor/auth-adaptor/oauth2_service.c delete mode 100644 adaptor/auth-adaptor/oauth2_service.h delete mode 100644 adaptor/contact-adaptor/contact_adaptor.c delete mode 100644 adaptor/contact-adaptor/contact_adaptor.h delete mode 100644 adaptor/resource-adaptor/resource_adaptor.c delete mode 100644 adaptor/resource-adaptor/resource_adaptor.h delete mode 100644 adaptor/storage-adaptor/cloud_service.c delete mode 100644 adaptor/storage-adaptor/cloud_service.h delete mode 100644 adaptor/storage-adaptor/posix_service.h delete mode 100644 adaptor/storage-adaptor/storage_adaptor.c delete mode 100644 adaptor/storage-adaptor/storage_adaptor.h delete mode 100644 api/client/sal_client_internal.c delete mode 100644 api/client/sal_client_internal.h delete mode 100644 api/client/sal_client_types.h delete mode 100644 api/client/sal_service_adaptor.c delete mode 100644 api/client/sal_service_adaptor.h delete mode 100644 api/client/sal_service_auth.c delete mode 100644 api/client/sal_service_auth.h delete mode 100644 api/client/sal_service_auth_internal.h delete mode 100644 api/client/sal_service_storage.c delete mode 100644 api/client/sal_service_storage.h delete mode 100644 api/client/sal_service_storage_internal.h delete mode 100644 api/client/sal_service_task.c delete mode 100644 api/client/sal_service_task.h delete mode 100644 api/client/sal_service_task_internal.h rename common/{CMakeLists.txt => CMakeLists.txt.backup} (100%) delete mode 100644 common/base/sal_ipc.c delete mode 100644 common/base/sal_ipc.h delete mode 100644 common/base/sal_log.h delete mode 100644 common/base/sal_types.h delete mode 100644 common/ipc-adaptor/sal_ipc_adaptor.c delete mode 100644 common/ipc-adaptor/sal_ipc_adaptor.h delete mode 100644 common/ipc-adaptor/sal_ipc_adaptor_types.h delete mode 100644 common/ipc-adaptor/sal_ipc_client_auth.c delete mode 100644 common/ipc-adaptor/sal_ipc_client_auth.h delete mode 100644 common/ipc-adaptor/sal_ipc_client_core.c delete mode 100644 common/ipc-adaptor/sal_ipc_client_core.h delete mode 100644 common/ipc-adaptor/sal_ipc_client_storage.c delete mode 100644 common/ipc-adaptor/sal_ipc_client_storage.h delete mode 100644 common/ipc-client/sal_ipc_client.c delete mode 100644 common/ipc-client/sal_ipc_client.h delete mode 100644 common/ipc-client/sal_ipc_client_auth.c delete mode 100644 common/ipc-client/sal_ipc_client_auth.h delete mode 100644 common/ipc-client/sal_ipc_client_core.c delete mode 100644 common/ipc-client/sal_ipc_client_core.h delete mode 100644 common/ipc-client/sal_ipc_client_storage.c delete mode 100644 common/ipc-client/sal_ipc_client_storage.h delete mode 100644 common/ipc-provider/sal_ipc_provider.c delete mode 100644 common/ipc-provider/sal_ipc_provider.h delete mode 100644 common/ipc-provider/sal_ipc_provider_base.c delete mode 100644 common/ipc-provider/sal_ipc_provider_base.h delete mode 100644 common/ipc-provider/sal_ipc_provider_storage.c delete mode 100644 common/ipc-provider/sal_ipc_provider_storage.h delete mode 100644 common/ipc-provider/sal_ipc_provider_types.h delete mode 100644 common/ipc-server/sal_ipc_server.c delete mode 100644 common/ipc-server/sal_ipc_server.h delete mode 100644 common/ipc-server/sal_ipc_server_auth.c delete mode 100644 common/ipc-server/sal_ipc_server_auth.h delete mode 100644 common/ipc-server/sal_ipc_server_core.c delete mode 100644 common/ipc-server/sal_ipc_server_core.h delete mode 100644 common/ipc-server/sal_ipc_server_storage.c delete mode 100644 common/ipc-server/sal_ipc_server_storage.h delete mode 100644 common/ipc-server/sal_ipc_server_types.h delete mode 100644 include/service_adaptor_client.h delete mode 100644 include/service_adaptor_client_plugin.h delete mode 100644 include/service_adaptor_client_storage.h delete mode 100644 include/service_adaptor_client_type.h delete mode 100644 include/service_adaptor_type.h delete mode 100644 include/service_provider.h delete mode 100644 include/service_provider_types.h delete mode 100644 include/storage_provider.h rename server/{CMakeLists.txt => CMakeLists.txt.backup} (100%) delete mode 100644 server/sal.h delete mode 100644 server/sal_base.c delete mode 100644 server/sal_base.h delete mode 100644 server/sal_coherence.c delete mode 100644 server/sal_contact.c delete mode 100644 server/sal_contact.h delete mode 100644 server/sal_engine.c delete mode 100644 server/sal_engine.h delete mode 100644 server/sal_generator.c delete mode 100644 server/sal_group.c delete mode 100644 server/sal_main.c delete mode 100644 server/sal_observer.c delete mode 100644 server/sal_observer.h delete mode 100644 server/sal_resource.c delete mode 100644 server/sal_resource.h delete mode 100644 server/sal_storage.c delete mode 100644 server/sal_storage.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 057b59c..9a4e049 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,17 +21,17 @@ MESSAGE(">>> Build type: ${CMAKE_BUILD_TYPE}") ########################################################## # Define BASE LIB ########################################################## -ADD_SUBDIRECTORY(common) +#ADD_SUBDIRECTORY(common) ########################################################## # Define Adaptor API ########################################################## -ADD_SUBDIRECTORY(api) +#ADD_SUBDIRECTORY(api) ########################################################## # Define Adaptor Manager & Execute File ########################################################## -ADD_SUBDIRECTORY(server) +#ADD_SUBDIRECTORY(server) ########################################################## # Define Test App diff --git a/Documentation/architecture/Dependency.txt b/Documentation/architecture/Dependency.txt deleted file mode 100644 index 9a5f8a8..0000000 --- a/Documentation/architecture/Dependency.txt +++ /dev/null @@ -1,49 +0,0 @@ -*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/adaptor/CMakeLists.txt b/adaptor/CMakeLists.txt.backup similarity index 100% rename from adaptor/CMakeLists.txt rename to adaptor/CMakeLists.txt.backup diff --git a/adaptor/auth-adaptor/auth_adaptor.c b/adaptor/auth-adaptor/auth_adaptor.c deleted file mode 100644 index cdf7737..0000000 --- a/adaptor/auth-adaptor/auth_adaptor.c +++ /dev/null @@ -1,349 +0,0 @@ -/* - * Auth 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 -#include - -#include "auth_adaptor.h" -#include "service_adaptor_internal.h" - -/****************************************************************************** - * Global variables and defines - ******************************************************************************/ - -/****************************************************************************** - * Private interface - ******************************************************************************/ - -/****************************************************************************** - * Private interface definition - ******************************************************************************/ - -static void _auth_adaptor_free_plugin(auth_plugin_h plugin) -{ -} - -/****************************************************************************** - * Public interface definition - ******************************************************************************/ - -API auth_adaptor_h auth_adaptor_create() -{ - SAL_FN_CALL; - - auth_adaptor_h auth = (auth_adaptor_h) g_malloc0(sizeof(auth_adaptor_s)); - - g_mutex_init(&auth->mutex); - - return auth; -} - -API service_adaptor_error_e auth_adaptor_destroy(auth_adaptor_h auth) -{ - SAL_FN_CALL; - - RETV_IF(NULL == auth, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - g_mutex_lock(&auth->mutex); - - if (0 != auth->start) { - auth_adaptor_stop(auth); - } - - SAL_FREE(auth); - - g_mutex_unlock(&auth->mutex); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e auth_adaptor_start(auth_adaptor_h auth) -{ - SAL_FN_CALL; - - RETV_IF(NULL == auth, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - g_mutex_lock(&auth->mutex); - - auth->start = 1; - - g_mutex_unlock(&auth->mutex); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e auth_adaptor_stop(auth_adaptor_h auth) -{ - SAL_FN_CALL; - - RETV_IF(NULL == auth, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - /* TODO: notify auth adaptor stop to each plugin */ - - g_mutex_lock(&auth->mutex); - - auth->start = 0; - - g_mutex_unlock(&auth->mutex); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e auth_adaptor_register_listener(auth_adaptor_h auth, auth_adaptor_listener_h listener) -{ - SAL_FN_CALL; - - RETV_IF(NULL == auth, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == listener, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - /* TODO: register insert/ update/ delete callback for service-adaptor */ - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e auth_adaptor_unregister_listener(auth_adaptor_h auth, auth_adaptor_listener_h listener) -{ - SAL_FN_CALL; - - RETV_IF(NULL == auth, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == listener, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - /* TODO: unregister insert/ update/ delete callback for service-adaptor */ - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e auth_adaptor_create_plugin(const char *uri, const char *name, const char *package, auth_plugin_h *plugin) -{ - SAL_FN_CALL; - - RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == name, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == package, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - auth_plugin_h auth_plugin = (auth_plugin_h) g_malloc0(sizeof(auth_plugin_s)); - auth_plugin->uri = strdup(uri); - auth_plugin->name = strdup(name); - auth_plugin->package = strdup(package); - - g_mutex_init(&auth_plugin->mutex); - g_cond_init(&auth_plugin->cond); - - *plugin = auth_plugin; - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e auth_adaptor_destroy_plugin(auth_plugin_h plugin) -{ - SAL_FN_CALL; - - RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - SAL_FREE(plugin->uri); - SAL_FREE(plugin->name); - SAL_FREE(plugin); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e auth_adaptor_register_plugin_service(auth_plugin_h plugin, GHashTable *service) -{ - SAL_FN_CALL; - - RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == service, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - int ret = SERVICE_ADAPTOR_ERROR_NONE; - - plugin->oauth1 = (oauth1_service_h) g_malloc0(sizeof(oauth1_service_s)); - ret = oauth1_register_service(plugin->oauth1, service); - - if (SERVICE_ADAPTOR_ERROR_NONE != ret) { - SAL_INFO("could not find the function for oauth 1.0"); - SAL_FREE(plugin->oauth1); - } - - plugin->oauth2 = (oauth2_service_h) g_malloc0(sizeof(oauth2_service_s)); - ret = oauth2_register_service(plugin->oauth2, service); - - if (SERVICE_ADAPTOR_ERROR_NONE != ret) { - SAL_INFO("could not find the function for oauth 2.0"); - SAL_FREE(plugin->oauth2); - } - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e auth_adaptor_unregister_plugin_service(auth_plugin_h plugin) -{ - SAL_FN_CALL; - - RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - if (NULL != plugin->oauth1) { - oauth1_unregister_service(plugin->oauth1); - SAL_FREE(plugin->oauth1); - } - - if (NULL != plugin->oauth2) { - oauth2_unregister_service(plugin->oauth2); - SAL_FREE(plugin->oauth2); - } - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e auth_adaptor_add_plugin(auth_adaptor_h auth, auth_plugin_h plugin) -{ - SAL_FN_CALL; - - RETV_IF(NULL == auth, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - g_mutex_lock(&auth->mutex); - - auth->plugins = g_list_append(auth->plugins, plugin); - - g_mutex_unlock(&auth->mutex); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e auth_adaptor_remove_plugin(auth_adaptor_h auth, auth_plugin_h plugin) -{ - SAL_FN_CALL; - - RETV_IF(NULL == auth, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - g_mutex_lock(&auth->mutex); - - RETV_IF(NULL == g_list_find(auth->plugins, plugin), SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - auth->plugins = g_list_remove(auth->plugins, plugin); - - _auth_adaptor_free_plugin(plugin); - - g_mutex_unlock(&auth->mutex); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API auth_plugin_h auth_adaptor_get_plugin(auth_adaptor_h auth, const char *uri) -{ - SAL_FN_CALL; - - RETV_IF(NULL == auth, NULL); - RETV_IF(NULL == uri, NULL); - - g_mutex_lock(&auth->mutex); - - auth_plugin_h plugin = NULL; - - for (GList *list = g_list_first(auth->plugins); list != NULL; list = list->next) { - auth_plugin_h this = (auth_plugin_h) list->data; - - if (0 == strcmp(this->uri, uri)) { - plugin = this; - break; - } - } - - g_mutex_unlock(&auth->mutex); - - return plugin; -} - -API char *auth_adaptor_get_uri(auth_adaptor_h auth, const char *package) -{ - SAL_FN_CALL; - - RETV_IF(NULL == auth, NULL); - RETV_IF(NULL == package, NULL); - - g_mutex_lock(&auth->mutex); - - char *uri = NULL; - - for (GList *list = g_list_first(auth->plugins); list != NULL; list = list->next) { - auth_plugin_h this = (auth_plugin_h) list->data; - - if (0 == strcmp(this->package, package)) { - uri = this->uri; - break; - } - } - - g_mutex_unlock(&auth->mutex); - - return uri; -} - -API service_adaptor_error_e auth_adaptor_ref_plugin(auth_adaptor_h auth, const char *uri) -{ - SAL_FN_CALL; - - RETV_IF(NULL == auth, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - g_mutex_lock(&auth->mutex); - - int ret = SERVICE_ADAPTOR_ERROR_NO_DATA; - - for (GList *list = g_list_first(auth->plugins); list != NULL; list = list->next) { - auth_plugin_h this = (auth_plugin_h) list->data; - - if (0 == strcmp(this->uri, uri)) { - ret = SERVICE_ADAPTOR_ERROR_NONE; - /* TODO: increase ref count */ - break; - } - } - - g_mutex_unlock(&auth->mutex); - - return ret; -} - -API service_adaptor_error_e auth_adaptor_unref_plugin(auth_adaptor_h auth, const char *uri) -{ - SAL_FN_CALL; - - RETV_IF(NULL == auth, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - g_mutex_lock(&auth->mutex); - - int ret = SERVICE_ADAPTOR_ERROR_NO_DATA; - - for (GList *list = g_list_first(auth->plugins); list != NULL; list = list->next) { - auth_plugin_h this = (auth_plugin_h) list->data; - - if (0 == strcmp(this->uri, uri)) { - ret = SERVICE_ADAPTOR_ERROR_NONE; - /* TODO: decrease ref count */ - break; - } - } - - g_mutex_unlock(&auth->mutex); - - return ret; -} diff --git a/adaptor/auth-adaptor/auth_adaptor.h b/adaptor/auth-adaptor/auth_adaptor.h deleted file mode 100644 index c883d73..0000000 --- a/adaptor/auth-adaptor/auth_adaptor.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Auth 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 __AUTH_ADAPTOR_H__ -#define __AUTH_ADAPTOR_H__ - -#ifndef API -#define API __attribute__ ((visibility("default"))) -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include -#include -#include - -#include "service_adaptor_errors.h" -#include "oauth1_service.h" -#include "oauth2_service.h" - -/** - * @file auth_adaptor.h - */ - -/** - * @ingroup - * @defgroup - * - * @brief - * - * @section - * \#include - * - *
- * @{ - */ - -#define URI_AUTH "auth" -#define URI_OAUTH1_0 "auth/oauth1.0" -#define URI_OAUTH2_0 "auth/oauth2.0" - -/** - * @brief Describes infromation about Auth Spec - */ -typedef enum _auth_spec_e -{ - AUTH_SPEC_OAUTH1_0 = (1 << 0), - AUTH_SPEC_OAUTH2_0 = (1 << 1), -} auth_spec_e; - -/** - * @brief Describes infromation about Auth Plugin - */ -typedef struct _auth_plugin_s -{ - char *uri; - char *name; - char *package; - - oauth1_service_h oauth1; - oauth2_service_h oauth2; - - GMutex mutex; - GCond cond; - int login; -} auth_plugin_s; -typedef struct _auth_plugin_s *auth_plugin_h; - -/** - * @brief Describes infromation about Auth Adaptor - */ -typedef struct _auth_adaptor_s -{ - GList *plugins; // auth_plugin_h - - GMutex mutex; - int start; -} auth_adaptor_s; -typedef struct _auth_adaptor_s *auth_adaptor_h; - -/** - * @brief Describes infromation about Auth Adaptor Listener - */ -typedef struct _auth_adaptor_listener_s -{ - void (*login_cb)(const char *uri, void *user_data); -} auth_adaptor_listener_s; -typedef struct _auth_adaptor_listener_s *auth_adaptor_listener_h; - -auth_adaptor_h auth_adaptor_create(); -service_adaptor_error_e auth_adaptor_destroy(auth_adaptor_h auth); -service_adaptor_error_e auth_adaptor_start(auth_adaptor_h auth); -service_adaptor_error_e auth_adaptor_stop(auth_adaptor_h auth); -service_adaptor_error_e auth_adaptor_register_listener(auth_adaptor_h auth, auth_adaptor_listener_h listener); -service_adaptor_error_e auth_adaptor_unregister_listener(auth_adaptor_h auth, auth_adaptor_listener_h listener); -service_adaptor_error_e auth_adaptor_create_plugin(const char *uri, const char *name, const char *package, auth_plugin_h *plugin); -service_adaptor_error_e auth_adaptor_destroy_plugin(auth_plugin_h plugin); -service_adaptor_error_e auth_adaptor_register_plugin_service(auth_plugin_h plugin, GHashTable *service); -service_adaptor_error_e auth_adaptor_unregister_plugin_service(auth_plugin_h plugin); -service_adaptor_error_e auth_adaptor_add_plugin(auth_adaptor_h auth, auth_plugin_h plugin); -service_adaptor_error_e auth_adaptor_remove_plugin(auth_adaptor_h auth, auth_plugin_h plugin); -auth_plugin_h auth_adaptor_get_plugin(auth_adaptor_h auth, const char *uri); -char *auth_adaptor_get_uri(auth_adaptor_h auth, const char *package); -service_adaptor_error_e auth_adaptor_ref_plugin(auth_adaptor_h auth, const char *uri); -service_adaptor_error_e auth_adaptor_unref_plugin(auth_adaptor_h auth, const char *uri); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __AUTH_ADAPTOR_H__ */ diff --git a/adaptor/auth-adaptor/oauth1_service.c b/adaptor/auth-adaptor/oauth1_service.c deleted file mode 100644 index 541fa76..0000000 --- a/adaptor/auth-adaptor/oauth1_service.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * oAuth 1.0 Service - * - * 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 -#include - -#include - -#include "oauth1_service.h" -#include "auth_adaptor.h" -#include "service_adaptor_errors.h" -#include "service_adaptor_internal.h" - -#include "sal_service_provider.h" -#include "sal_auth_provider.h" - -/****************************************************************************** - * Global variables and defines - ******************************************************************************/ - -typedef struct _app_control_user_data_s { - void *callback; - void *user_data; -} app_control_user_data_s; -typedef struct _app_control_user_data_s *app_control_user_data_h; - -typedef int (*_get_access_token)(void *plugin, oauth1_cb callback, void *user_data); -typedef int (*_get_extra_data)(void *plugin, const char *key, oauth1_cb callback, void *user_data); - -/****************************************************************************** - * Private interface - ******************************************************************************/ - -/****************************************************************************** - * Private interface definition - ******************************************************************************/ - -/** - * @brief callback of service plugin - * - * @return void. - */ -static void _oauth1_get_access_token_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data) -{ - SAL_FN_CALL; - - RET_IF(APP_CONTROL_RESULT_FAILED == result); - RET_IF(NULL == user_data); - - char *ret_str = NULL; - app_control_get_extra_data(reply, PLUGIN_RESULT_KEY, &ret_str); - - char *access_token = NULL; - app_control_get_extra_data(reply, OAUTH1_0_ACCESS_TOKEN_KEY, &access_token); - - app_control_user_data_h app_control_user_data = (app_control_user_data_h) user_data; - oauth1_cb callback = (oauth1_cb) app_control_user_data->callback; - - RET_IF(NULL == callback); - - /* TODO: move this function for chaning result enum to general */ - int ret = SERVICE_ADAPTOR_ERROR_NONE; - - if (0 == strcmp(PLUGIN_RESULT_VALUE_FAILURE, ret_str)) { - ret = SERVICE_ADAPTOR_ERROR_INTERNAL; - } - - oauth1_h oauth1 = (oauth1_h) g_malloc0(sizeof(oauth1_s)); - oauth1->access_token = strdup(access_token); - - callback(ret, oauth1, app_control_user_data->user_data); - - SAL_FN_END; -} - -static int _oauth1_get_access_token(auth_plugin_h plugin, oauth1_cb callback, void *user_data) -{ - SAL_FN_CALL; - - RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - app_control_h request; - app_control_create(&request); - - app_control_set_app_id(request, plugin->uri); - app_control_set_operation(request, OAUTH1_0_GET_ACCESS_TOKEN_URI); - - app_control_user_data_h app_control_user_data = (app_control_user_data_h) g_malloc0(sizeof(app_control_user_data_s)); - app_control_user_data->callback = (void *) callback; - app_control_user_data->user_data = user_data; - - int res = app_control_send_launch_request(request, _oauth1_get_access_token_cb, app_control_user_data); - - if (APP_CONTROL_ERROR_NONE != res) { - return SERVICE_ADAPTOR_ERROR_SYSTEM; - } - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -static int _oauth1_get_extra_data(auth_plugin_h plugin, const char *key, oauth1_cb callback, void *user_data) -{ - SAL_FN_CALL; - - RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -/****************************************************************************** - * Public interface definition - ******************************************************************************/ - -API int oauth1_register_service(oauth1_service_h oauth1, GHashTable *service) -{ - SAL_FN_CALL; - - RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - int ret = SERVICE_ADAPTOR_ERROR_NO_DATA; - GHashTableIter iter; - gpointer iter_key, iter_value; - - g_hash_table_iter_init(&iter, service); - while (g_hash_table_iter_next(&iter, &iter_key, &iter_value)) { - if (0 == strcmp(iter_key, OAUTH1_0_GET_ACCESS_TOKEN_URI)) { - oauth1->oauth1_get_access_token = (_get_access_token) _oauth1_get_access_token; - ret = SERVICE_ADAPTOR_ERROR_NONE; - } else if (0 == strcmp(iter_key, OAUTH1_0_GET_EXTRA_DATA_URI)) { - oauth1->oauth1_get_extra_data = (_get_extra_data) _oauth1_get_extra_data; - ret = SERVICE_ADAPTOR_ERROR_NONE; - } - } - - return ret; -} - -API int oauth1_unregister_service(oauth1_service_h oauth1) -{ - SAL_FN_CALL; - - RETV_IF(NULL == oauth1, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - oauth1->oauth1_get_access_token = NULL; - oauth1->oauth1_get_extra_data = NULL; - - return SERVICE_ADAPTOR_ERROR_NONE; -} diff --git a/adaptor/auth-adaptor/oauth1_service.h b/adaptor/auth-adaptor/oauth1_service.h deleted file mode 100644 index f24bf64..0000000 --- a/adaptor/auth-adaptor/oauth1_service.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * oAuth 1.0 Service - * - * 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 __OAUTH1_SERVICE_H__ -#define __OAUTH1_SERVICE_H__ - -#ifndef API -#define API __attribute__ ((visibility("default"))) -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include - -/** - * @brief Describes infromation about oAuth1 Service - * @key name, ... - */ -typedef struct _oauth1_s -{ - char *access_token; - char *operation; -} oauth1_s; -typedef struct _oauth1_s *oauth1_h; - -/** -* @brief Callback for oauth1 API -* -* @param[in] access_token -* @param[in] user_data Passed data from #oauth1_get_access_token() -* @remarks -* @pre oauth1() will invoke this callback. -*/ -typedef void (*oauth1_cb)(int result, oauth1_h oauth1, void *user_data); - -/** - * @brief Describes infromation about oAuth 1.0 Service - * @key access token, ... - */ -typedef struct _oauth1_service_s -{ - int (*oauth1_get_access_token)(void *plugin, oauth1_cb callback, void *user_data); - int (*oauth1_get_extra_data)(void *plugin, const char *key, oauth1_cb callback, void *user_data); -} oauth1_service_s; -typedef struct _oauth1_service_s *oauth1_service_h; - -/*================================================================================================== - FUNCTION PROTOTYPES -==================================================================================================*/ - -/** -* @brief Register oAuth 1.0 Service -* @since_tizen 3.0 -* -* @param[in] oauth1 The oAuth 1.0 service handle -* @param[in] service -* @remarks -* @see oauth1_unregister_service() -* @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 oauth1_register_service(oauth1_service_h oauth1, GHashTable *service); - -/** -* @brief Unregister oAuth 1.0 Service -* @since_tizen 3.0 -* -* @param[in] oauth1 The oAuth 1.0 service handle -* @remarks -* @see oauth1_register_service() -* @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 oauth1_unregister_service(oauth1_service_h oauth1); - -#ifdef __cplusplus -} -#endif - -#endif /* __OAUTH1_SERVICE_H__ */ diff --git a/adaptor/auth-adaptor/oauth2_service.c b/adaptor/auth-adaptor/oauth2_service.c deleted file mode 100644 index 9d66f74..0000000 --- a/adaptor/auth-adaptor/oauth2_service.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * oAuth 2.0 Service - * - * 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 -#include - -#include - -#include "oauth2_service.h" -#include "auth_adaptor.h" -#include "service_adaptor_errors.h" -#include "service_adaptor_internal.h" - -#include "sal_auth_provider.h" - -/****************************************************************************** - * Global variables and defines - ******************************************************************************/ - -typedef struct _app_control_user_data_s { - void *callback; - void *user_data; -} app_control_user_data_s; -typedef struct _app_control_user_data_s *app_control_user_data_h; - -typedef int (*_get_access_token)(void *plugin, char **access_token, void *user_data); -typedef int (*_get_extra_data)(void *plugin, const char *key, char **value, void *user_data); - -/****************************************************************************** - * Private interface - ******************************************************************************/ - -/****************************************************************************** - * Private interface definition - ******************************************************************************/ - -static int _oauth2_get_access_token(auth_plugin_h plugin, char **access_token, void *user_data) -{ - SAL_FN_CALL; - - RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -static int _oauth2_get_extra_data(auth_plugin_h plugin, const char *key, char **value, void *user_data) -{ - SAL_FN_CALL; - - RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -/****************************************************************************** - * Public interface definition - ******************************************************************************/ - -API int oauth2_register_service(oauth2_service_h oauth2, GHashTable *service) -{ - SAL_FN_CALL; - - RETV_IF(NULL == oauth2, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - int ret = SERVICE_ADAPTOR_ERROR_NO_DATA; - GHashTableIter iter; - gpointer iter_key, iter_value; - - g_hash_table_iter_init(&iter, service); - while (g_hash_table_iter_next(&iter, &iter_key, &iter_value)) { - if (0 == strcmp(iter_key, OAUTH2_0_GET_ACCESS_TOKEN_URI)) { - oauth2->oauth2_get_access_token = (_get_access_token) _oauth2_get_access_token; - ret = SERVICE_ADAPTOR_ERROR_NONE; - } else if (0 == strcmp(iter_key, OAUTH2_0_GET_EXTRA_DATA_URI)) { - oauth2->oauth2_get_extra_data = (_get_extra_data) _oauth2_get_extra_data; - ret = SERVICE_ADAPTOR_ERROR_NONE; - } - } - - return ret; -} - -API int oauth2_unregister_service(oauth2_service_h oauth2) -{ - SAL_FN_CALL; - - RETV_IF(NULL == oauth2, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - oauth2->oauth2_get_access_token = NULL; - oauth2->oauth2_get_extra_data = NULL; - - return SERVICE_ADAPTOR_ERROR_NONE; -} diff --git a/adaptor/auth-adaptor/oauth2_service.h b/adaptor/auth-adaptor/oauth2_service.h deleted file mode 100644 index 201f807..0000000 --- a/adaptor/auth-adaptor/oauth2_service.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * oAuth 2.0 Service - * - * 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 __OAUTH2_SERVICE_H__ -#define __OAUTH2_SERVICE_H__ - -#ifndef API -#define API __attribute__ ((visibility("default"))) -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include - -/** -* @brief Callback for oauth2_get_access_token API -* -* @param[in] access_token -* @param[in] user_data Passed data from #oauth2_get_access_token() -* @remarks -* @pre oauth2_get_access_token() will invoke this callback. -*/ -typedef void (*oauth2_get_access_token_cb)(const char *access_token, void *user_data); - -/** -* @brief Callback for oauth2_get_extra_data API -* -* @param[in] value -* @param[in] user_data Passed data from #oauth2_get_access_token() -* @remarks -* @pre oauth2_get_extra_data() will invoke this callback. -*/ -typedef void (*oauth2_get_extra_data_cb)(const char *value, void *user_data); - -/** - * @brief Describes infromation about oAuth 2.0 Service - * @key access token, ... - */ -typedef struct _oauth2_service_s -{ - int (*oauth2_get_access_token)(void *plugin, char **access_token, void *user_data); - int (*oauth2_get_extra_data)(void *plugin, const char *key, char **value, void *user_data); -} oauth2_service_s; -typedef struct _oauth2_service_s *oauth2_service_h; - -/*================================================================================================== - FUNCTION PROTOTYPES -==================================================================================================*/ - -/** -* @brief Register oAuth 2.0 Service -* @since_tizen 3.0 -* -* @param[in] oauth2 The oAuth 2.0 service handle -* @param[in] service -* @remarks -* @see oauth2_unregister_service() -* @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 oauth2_register_service(oauth2_service_h oauth2, GHashTable *service); - -/** -* @brief Unregister oAuth 2.0 Service -* @since_tizen 3.0 -* -* @param[in] oauth2 The oAuth 2.0 service handle -* @remarks -* @see oauth2_register_service() -* @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 oauth2_unregister_service(oauth2_service_h oauth2); - -#ifdef __cplusplus -} -#endif - -#endif /* __OAUTH2_SERVICE_H__ */ diff --git a/adaptor/contact-adaptor/contact_adaptor.c b/adaptor/contact-adaptor/contact_adaptor.c deleted file mode 100644 index 202e65c..0000000 --- a/adaptor/contact-adaptor/contact_adaptor.c +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include - -#include "contact_adaptor.h" -#include "service_adaptor_internal.h" - -contact_adaptor_h contact_adaptor_create() -{ - contact_adaptor_h contact = (contact_adaptor_h) g_malloc0(sizeof(contact_adaptor_s)); - - return contact; -} - -service_adaptor_error_e contact_adaptor_destroy(contact_adaptor_h contact) -{ - SAL_FREE(contact); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -service_adaptor_error_e contact_adaptor_start(contact_adaptor_h contact) -{ - return SERVICE_ADAPTOR_ERROR_NONE; -} - -service_adaptor_error_e contact_adaptor_stop(contact_adaptor_h contact) -{ - return SERVICE_ADAPTOR_ERROR_NONE; -} - -service_adaptor_error_e contact_adaptor_register_listener(contact_adaptor_h contact, contact_adaptor_listener_h listener) -{ - return SERVICE_ADAPTOR_ERROR_NONE; -} - -service_adaptor_error_e contact_adaptor_unregister_listener(contact_adaptor_h contact, contact_adaptor_listener_h listener) -{ - return SERVICE_ADAPTOR_ERROR_NONE; -} diff --git a/adaptor/contact-adaptor/contact_adaptor.h b/adaptor/contact-adaptor/contact_adaptor.h deleted file mode 100644 index c497de7..0000000 --- a/adaptor/contact-adaptor/contact_adaptor.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Contact 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 __CONTACT_ADAPTOR_H__ -#define __CONTACT_ADAPTOR_H__ - -#ifndef API -#define API __attribute__ ((visibility("default"))) -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include "service_adaptor_errors.h" - -/** - * @file contact_adaptor.h - */ - -/** - * @ingroup - * @defgroup - * - * @brief - * - * @section - * \#include - * - *
- * @{ - */ - -typedef struct _contact_adaptor_s -{ - int i; -} contact_adaptor_s; -typedef struct _contact_adaptor_s *contact_adaptor_h; - -typedef struct _contact_adaptor_listener_s -{ - int i; -} contact_adaptor_listener_s; -typedef struct _contact_adaptor_listener_s *contact_adaptor_listener_h; - -API contact_adaptor_h contact_adaptor_create(); -API service_adaptor_error_e contact_adaptor_destroy(contact_adaptor_h contact); -API service_adaptor_error_e contact_adaptor_start(contact_adaptor_h contact); -API service_adaptor_error_e contact_adaptor_stop(contact_adaptor_h contact); -API service_adaptor_error_e contact_adaptor_register_listener(contact_adaptor_h contact, contact_adaptor_listener_h listener); -API service_adaptor_error_e contact_adaptor_unregister_listener(contact_adaptor_h contact, contact_adaptor_listener_h listener); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __CONTACT_ADAPTOR_H__ */ diff --git a/adaptor/resource-adaptor/resource_adaptor.c b/adaptor/resource-adaptor/resource_adaptor.c deleted file mode 100644 index 78e7cca..0000000 --- a/adaptor/resource-adaptor/resource_adaptor.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Resource 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 -#include - -#include "resource_adaptor.h" -#include "service_adaptor_internal.h" - -API resource_adaptor_h resource_adaptor_create() -{ - resource_adaptor_h resource = (resource_adaptor_h) g_malloc0(sizeof(resource_adaptor_s)); - - return resource; -} - -API service_adaptor_error_e resource_adaptor_destroy(resource_adaptor_h resource) -{ - SAL_FREE(resource); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e resource_adaptor_start(resource_adaptor_h resource) -{ - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e resource_adaptor_stop(resource_adaptor_h resource) -{ - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e resource_adaptor_register_listener(resource_adaptor_h resource, resource_adaptor_listener_h listener) -{ - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e resource_adaptor_unregister_listener(resource_adaptor_h resource, resource_adaptor_listener_h listener) -{ - return SERVICE_ADAPTOR_ERROR_NONE; -} diff --git a/adaptor/resource-adaptor/resource_adaptor.h b/adaptor/resource-adaptor/resource_adaptor.h deleted file mode 100644 index bb4081e..0000000 --- a/adaptor/resource-adaptor/resource_adaptor.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Resource 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 __RESOURCE_ADAPTOR_H__ -#define __RESOURCE_ADAPTOR_H__ - -#ifndef API -#define API __attribute__ ((visibility("default"))) -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include - -#include "service_adaptor_errors.h" - -/** - * @file resource_adaptor.h - */ - -/** - * @ingroup - * @defgroup - * - * @brief - * - * @section - * \#include - * - *
- * @{ - */ - -/** - * @brief Handle of Resource Plugin - */ -typedef struct resource_plugin_s *resource_plugin_h; - -/** - * @brief Describes infromation about SmartThings Service - * @key access token, ... - */ - typedef struct _resource_plugin_smartthings_service_s - { - int (*smartthings_get_resource)(resource_plugin_h plugin, char **resource_uri, void *user_data); - } resource_plugin_smartthings_service_s; - typedef struct resource_plugin_smartthings_service_s *resource_plugin_smartthings_service_h; - -/** - * @brief Describes infromation about Resource Plugin - */ -typedef struct _resource_plugin_s -{ - char *uri; - char *name; - - resource_plugin_smartthings_service_h smartthings; - - GMutex mutex; - int start; -} resource_plugin_s; - -/** - * @brief Describes infromation about Resource Adaptor - */ -typedef struct _resource_adaptor_s -{ - GList *plugins; // resource_plugin_h - - GMutex mutex; - int start; -} resource_adaptor_s; -typedef struct resource_adaptor_s *resource_adaptor_h; - -/** - * @brief Describes infromation about Resource Adaptor Listener - */ -typedef struct _resource_adaptor_listener_s -{ - void (*login_cb)(char *uri, void *user_data); -} resource_adaptor_listener_s; -typedef struct resource_adaptor_listener_s *resource_adaptor_listener_h; - -resource_adaptor_h resource_adaptor_create(); -service_adaptor_error_e resource_adaptor_destroy(resource_adaptor_h resource); -service_adaptor_error_e resource_adaptor_start(resource_adaptor_h resource); -service_adaptor_error_e resource_adaptor_stop(resource_adaptor_h resource); -service_adaptor_error_e resource_adaptor_register_listener(resource_adaptor_h resource, resource_adaptor_listener_h listener); -service_adaptor_error_e resource_adaptor_unregister_listener(resource_adaptor_h resource, resource_adaptor_listener_h listener); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __RESOURCE_ADAPTOR_H__ */ diff --git a/adaptor/storage-adaptor/cloud_service.c b/adaptor/storage-adaptor/cloud_service.c deleted file mode 100644 index a7de505..0000000 --- a/adaptor/storage-adaptor/cloud_service.c +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Storage 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 -#include -#include -#include -#include -#include - -#include - -#include "cloud_service.h" -#include "storage_adaptor.h" -#include "service_adaptor_errors.h" -#include "service_adaptor_internal.h" - -#include "sal_service_provider.h" -#include "sal_storage_provider.h" - -/****************************************************************************** - * Global variables and defines - ******************************************************************************/ - -typedef struct _app_control_user_data_s { - cloud_file_h file; - - void *callback; - void *user_data; -} app_control_user_data_s; -typedef struct _app_control_user_data_s *app_control_user_data_h; - -typedef int (*_remove_file)(void *plugin, const char *cloud_path, cloud_file_cb callback, void *user_data); - -/****************************************************************************** - * Private interface - ******************************************************************************/ - -/****************************************************************************** - * Private interface definition - ******************************************************************************/ - -int _make_cloud_file_by_local(const char *local_path, cloud_file_h *file) -{ - SAL_FN_CALL; - - RETV_IF(NULL == local_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - struct stat file_info; - RETV_IF(0 != stat(local_path, &file_info), SERVICE_ADAPTOR_ERROR_INTERNAL); - - char *path_tmp = strdup(local_path); - char *dir_path = dirname(path_tmp); - - cloud_file_h cloud_file = (cloud_file_h) g_malloc0(sizeof(cloud_file_s)); - cloud_file->dir_path = dir_path; - cloud_file->local_path = strdup(local_path); - cloud_file->cloud_path = NULL; - cloud_file->size = file_info.st_size; - - if (S_ISDIR(file_info.st_mode)) { - cloud_file->is_dir = true; - } - - *file = cloud_file; - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -int _make_cloud_file_by_cloud(const char *cloud_path, cloud_file_h *file) -{ - SAL_FN_CALL; - - RETV_IF(NULL == cloud_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - cloud_file_h cloud_file = (cloud_file_h) g_malloc0(sizeof(cloud_file_s)); - cloud_file->cloud_path = strdup(cloud_path); - - *file = cloud_file; - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -/** - * @brief callback of service plugin - * - * @return void. - */ -static void _cloud_remove_file_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data) -{ - SAL_FN_CALL; - - RET_IF(APP_CONTROL_RESULT_FAILED == result); - RET_IF(NULL == user_data); - - char *ret_str = NULL; - app_control_get_extra_data(reply, PLUGIN_RESULT_KEY, &ret_str); - - app_control_user_data_h app_control_user_data = (app_control_user_data_h) user_data; - cloud_file_cb callback = (cloud_file_cb) app_control_user_data->callback; - - RET_IF(NULL == callback); - - /* TODO: move this function for chaning result enum to general */ - int ret = SERVICE_ADAPTOR_ERROR_NONE; - - if (0 == strcmp(PLUGIN_RESULT_VALUE_FAILURE, ret_str)) { - ret = SERVICE_ADAPTOR_ERROR_INTERNAL; - } - - callback(ret, app_control_user_data->file, app_control_user_data->user_data); - - SAL_FN_END; -} - -static int _cloud_remove_file(storage_plugin_h plugin, const char *cloud_path, cloud_file_cb callback, void *user_data) -{ - SAL_FN_CALL; - - RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == cloud_path, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - app_control_h request; - app_control_create(&request); - - app_control_set_app_id(request, plugin->uri); - app_control_set_operation(request, CLOUD_REMOVE_FILE_URI); - - app_control_add_extra_data(request, CLOUD_CLOUD_PATH_KEY, cloud_path); - - cloud_file_h file = NULL; - _make_cloud_file_by_cloud(cloud_path, &file); - file->operation = strdup(CLOUD_REMOVE_FILE_URI); - - app_control_user_data_h app_control_user_data = (app_control_user_data_h) g_malloc0(sizeof(app_control_user_data_s)); - app_control_user_data->file = file; - app_control_user_data->callback = (void *) callback; - app_control_user_data->user_data = user_data; - - int res = app_control_send_launch_request(request, _cloud_remove_file_cb, app_control_user_data); - - if (APP_CONTROL_ERROR_NONE != res) { - return SERVICE_ADAPTOR_ERROR_SYSTEM; - } - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -/****************************************************************************** - * Public interface definition - ******************************************************************************/ - -API int cloud_register_service(cloud_service_h cloud, GHashTable *service) -{ - SAL_FN_CALL; - - RETV_IF(NULL == cloud, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - int ret = SERVICE_ADAPTOR_ERROR_NO_DATA; - GHashTableIter iter; - gpointer iter_key, iter_value; - - g_hash_table_iter_init(&iter, service); - while (g_hash_table_iter_next(&iter, &iter_key, &iter_value)) { - if (0 == strcmp(iter_key, CLOUD_REMOVE_FILE_URI)) { - cloud->cloud_remove_file = (_remove_file) _cloud_remove_file; - ret = SERVICE_ADAPTOR_ERROR_NONE; - } - } - - return ret; -} - -API int cloud_unregister_service(cloud_service_h cloud) -{ - SAL_FN_CALL; - - RETV_IF(NULL == cloud, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - cloud->cloud_remove_file = NULL; - - return SERVICE_ADAPTOR_ERROR_NONE; -} diff --git a/adaptor/storage-adaptor/cloud_service.h b/adaptor/storage-adaptor/cloud_service.h deleted file mode 100644 index 731cfc7..0000000 --- a/adaptor/storage-adaptor/cloud_service.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Cloud Service - * - * 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 __CLOUD_SERVICE_H__ -#define __CLOUD_SERVICE_H__ - -#ifndef API -#define API __attribute__ ((visibility("default"))) -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include - -/** - * @brief Describes infromation about Cloud Service - * @key name, ... - */ -typedef struct _cloud_file_s -{ - bool is_dir; - char *dir_path; - char *local_path; - char *cloud_path; - unsigned long long size; - char *operation; - - GList *files; -} cloud_file_s; -typedef struct _cloud_file_s *cloud_file_h; - -/** -* @brief Callback for Cloud File Operation API -* -* @param[in] plugin -* @param[in] path -* @param[in] callback -* @param[in] user_data Passed data from #oauth1_get_access_token() -* @remarks -* @pre cloud_remove_file() will invoke this callback. -*/ -typedef void (*cloud_file_cb)(int result, cloud_file_h cloud_file, void *user_data); - -/** - * @brief Describes infromation about Cloud Service - * @key name, ... - */ -typedef struct _cloud_service_s -{ - int (*cloud_remove_file)(void *plugin, const char *cloud_path, cloud_file_cb callback, void *user_data); - int (*cloud_download_file)(void *plugin, const char *cloud_path, const char *local_path, cloud_file_cb callback, void *user_data); - int (*cloud_upload_file)(void *plugin, const char *local_path, const char *cloud_path, cloud_file_cb callback, void *user_data); - int (*cloud_download_file_thumbnail)(void *plugin, const char *cloud_path, const char *local_path, cloud_file_cb callback, void *user_data); - int (*cloud_get_file_list)(void *plugin, const char *cloud_path, const char *local_path, cloud_file_cb callback, void *user_data); -} cloud_service_s; -typedef struct _cloud_service_s *cloud_service_h; - -/*================================================================================================== - FUNCTION PROTOTYPES -==================================================================================================*/ - -/** -* @brief Register Cloud Service -* @since_tizen 3.0 -* -* @param[in] cloud The Cloud service handle -* @param[in] service -* @remarks -* @see cloud_unregister_service() -* @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 cloud_register_service(cloud_service_h cloud, GHashTable *service); - -/** -* @brief Unregister Cloud Service -* @since_tizen 3.0 -* -* @param[in] cloud The Cloud service handle -* @remarks -* @see cloud_register_service() -* @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 cloud_unregister_service(cloud_service_h cloud); - -#ifdef __cplusplus -} -#endif - -#endif /* __CLOUD_SERVICE_H__ */ diff --git a/adaptor/storage-adaptor/posix_service.h b/adaptor/storage-adaptor/posix_service.h deleted file mode 100644 index 880292b..0000000 --- a/adaptor/storage-adaptor/posix_service.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * POSIX Service - * - * 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 __POSIX_SERVICE_H__ -#define __POSIX_SERVICE_H__ - -#ifndef API -#define API __attribute__ ((visibility("default"))) -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include - -/** - * @brief Describes infromation about Cloud Service - * @key name, ... - */ -typedef struct _posix_service_s -{ - int (*posix_open_service)(void *plugin, - const char *path, - int flags, - void *user_data); - - int (*posix_read_service)(void *plugin, - const char *path, - char **buf, - size_t size, - off_t offset, - void *user_data); - - int (*posix_write_service)(void *plugin, - const char *path, - const char *buf, - size_t size, - off_t offset, - void *user_data); - - int (*posix_close_service)(void *plugin, - const char *path, - int flags, - void *user_data); -} posix_service_s; -typedef struct _posix_service_s *posix_service_h; - -/*================================================================================================== - FUNCTION PROTOTYPES -==================================================================================================*/ - -/** -* @brief Register Posix Service -* @since_tizen 3.0 -* -* @param[in] cloud The Cloud service handle -* @param[in] service -* @remarks -* @see cloud_unregister_service() -* @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 posix_register_service(posix_service_h posix, GHashTable *service); - -/** -* @brief Unregister Cloud Service -* @since_tizen 3.0 -* -* @param[in] cloud The Cloud service handle -* @remarks -* @see cloud_register_service() -* @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 posix_unregister_service(posix_service_h posix); - -#ifdef __cplusplus -} -#endif - -#endif /* __POSIX_SERVICE_H__ */ diff --git a/adaptor/storage-adaptor/storage_adaptor.c b/adaptor/storage-adaptor/storage_adaptor.c deleted file mode 100644 index c2738c0..0000000 --- a/adaptor/storage-adaptor/storage_adaptor.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * Storage 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 -#include - -#include "storage_adaptor.h" -#include "service_adaptor_internal.h" - -/****************************************************************************** - * Global variables and defines - ******************************************************************************/ - -/****************************************************************************** - * Private interface - ******************************************************************************/ - -/****************************************************************************** - * Private interface definition - ******************************************************************************/ - -static void _storage_adaptor_free_plugin(storage_plugin_h plugin) -{ -} - -/****************************************************************************** - * Public interface definition - ******************************************************************************/ - -API storage_adaptor_h storage_adaptor_create() -{ - SAL_FN_CALL; - - storage_adaptor_h storage = (storage_adaptor_h) g_malloc0(sizeof(storage_adaptor_s)); - - g_mutex_init(&storage->mutex); - - return storage; -} - -API service_adaptor_error_e storage_adaptor_destroy(storage_adaptor_h storage) -{ - SAL_FN_CALL; - - RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - g_mutex_lock(&storage->mutex); - - if (0 != storage->start) { - storage_adaptor_stop(storage); - } - - SAL_FREE(storage); - - g_mutex_unlock(&storage->mutex); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e storage_adaptor_start(storage_adaptor_h storage) -{ - SAL_FN_CALL; - - RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - g_mutex_lock(&storage->mutex); - - storage->start = 1; - - g_mutex_unlock(&storage->mutex); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e storage_adaptor_stop(storage_adaptor_h storage) -{ - SAL_FN_CALL; - - RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - /* TODO: notify storage adaptor stop to each plugin */ - - g_mutex_lock(&storage->mutex); - - storage->start = 0; - - g_mutex_unlock(&storage->mutex); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e storage_adaptor_register_listener(storage_adaptor_h storage, storage_adaptor_listener_h listener) -{ - SAL_FN_CALL; - - RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == listener, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - /* TODO: register insert/ update/ delete callback for service-adaptor */ - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e storage_adaptor_unregister_listener(storage_adaptor_h storage, storage_adaptor_listener_h listener) -{ - SAL_FN_CALL; - - RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == listener, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - /* TODO: unregister insert/ update/ delete callback for service-adaptor */ - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e storage_adaptor_create_plugin(const char *uri, const char *name, const char *package, storage_plugin_h *plugin) -{ - SAL_FN_CALL; - - RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == name, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == package, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - storage_plugin_h storage_plugin = (storage_plugin_h) g_malloc0(sizeof(storage_plugin_s)); - storage_plugin->uri = strdup(uri); - storage_plugin->name = strdup(name); - storage_plugin->package = strdup(package); - - g_mutex_init(&storage_plugin->mutex); - g_cond_init(&storage_plugin->cond); - - *plugin = storage_plugin; - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e storage_adaptor_destroy_plugin(storage_plugin_h plugin) -{ - SAL_FN_CALL; - - RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - SAL_FREE(plugin->uri); - SAL_FREE(plugin->name); - SAL_FREE(plugin); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e storage_adaptor_register_plugin_service(storage_plugin_h plugin, GHashTable *service) -{ - SAL_FN_CALL; - - RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == service, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - int ret = SERVICE_ADAPTOR_ERROR_NONE; - - plugin->cloud = (cloud_service_h) g_malloc0(sizeof(cloud_service_s)); - ret = cloud_register_service(plugin->cloud, service); - - if (SERVICE_ADAPTOR_ERROR_NONE != ret) { - SAL_INFO("could not find the function for cloud"); - SAL_FREE(plugin->cloud); - } -/* - plugin->posix = (posix_service_h) g_malloc0(sizeof(posix_service_s)); - ret = posix_register_service(plugin->posix, service); - - if (SERVICE_ADAPTOR_ERROR_NONE != ret) - { - SAL_INFO("could not find the function for posix"); - SAL_FREE(plugin->posix); - } - */ - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e storage_adaptor_unregister_plugin_service(storage_plugin_h plugin) -{ - SAL_FN_CALL; - - RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - if (NULL != plugin->cloud) { - cloud_unregister_service(plugin->cloud); - SAL_FREE(plugin->cloud); - } - /* - if (NULL != plugin->posix) - { - posix_unregister_service(plugin->posix); - SAL_FREE(plugin->posix); - } - */ - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e storage_adaptor_add_plugin(storage_adaptor_h storage, storage_plugin_h plugin) -{ - SAL_FN_CALL; - - RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - g_mutex_lock(&storage->mutex); - - storage->plugins = g_list_append(storage->plugins, plugin); - - g_mutex_unlock(&storage->mutex); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e storage_adaptor_remove_plugin(storage_adaptor_h storage, storage_plugin_h plugin) -{ - SAL_FN_CALL; - - RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - g_mutex_lock(&storage->mutex); - - RETV_IF(NULL == g_list_find(storage->plugins, plugin), SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - storage->plugins = g_list_remove(storage->plugins, plugin); - - _storage_adaptor_free_plugin(plugin); - - g_mutex_unlock(&storage->mutex); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API storage_plugin_h storage_adaptor_get_plugin(storage_adaptor_h storage, const char *uri) -{ - SAL_FN_CALL; - - RETV_IF(NULL == storage, NULL); - RETV_IF(NULL == uri, NULL); - - g_mutex_lock(&storage->mutex); - - storage_plugin_h plugin = NULL; - - for (GList *list = g_list_first(storage->plugins); list != NULL; list = list->next) { - storage_plugin_h this = (storage_plugin_h) list->data; - - if (0 == strcmp(this->uri, uri)) { - plugin = this; - break; - } - } - - g_mutex_unlock(&storage->mutex); - - return plugin; -} - -API char *storage_adaptor_get_uri(storage_adaptor_h storage, const char *package) -{ - SAL_FN_CALL; - - RETV_IF(NULL == storage, NULL); - RETV_IF(NULL == package, NULL); - - g_mutex_lock(&storage->mutex); - - char *uri = NULL; - - for (GList *list = g_list_first(storage->plugins); list != NULL; list = list->next) { - storage_plugin_h this = (storage_plugin_h) list->data; - - if (0 == strcmp(this->package, package)) { - uri = this->uri; - break; - } - } - - g_mutex_unlock(&storage->mutex); - - return uri; -} - -API service_adaptor_error_e storage_adaptor_ref_plugin(storage_adaptor_h storage, const char *uri) -{ - SAL_FN_CALL; - - RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - g_mutex_lock(&storage->mutex); - - int ret = SERVICE_ADAPTOR_ERROR_NO_DATA; - - for (GList *list = g_list_first(storage->plugins); list != NULL; list = list->next) { - storage_plugin_h this = (storage_plugin_h) list->data; - - if (0 == strcmp(this->uri, uri)) { - ret = SERVICE_ADAPTOR_ERROR_NONE; - /* TODO: increase ref count */ - break; - } - } - - g_mutex_unlock(&storage->mutex); - - return ret; -} - -API service_adaptor_error_e storage_adaptor_unref_plugin(storage_adaptor_h storage, const char *uri) -{ - SAL_FN_CALL; - - RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - g_mutex_lock(&storage->mutex); - - int ret = SERVICE_ADAPTOR_ERROR_NO_DATA; - - for (GList *list = g_list_first(storage->plugins); list != NULL; list = list->next) { - storage_plugin_h this = (storage_plugin_h) list->data; - - if (0 == strcmp(this->uri, uri)) { - ret = SERVICE_ADAPTOR_ERROR_NONE; - /* TODO: decrease ref count */ - break; - } - } - - g_mutex_unlock(&storage->mutex); - - return ret; -} diff --git a/adaptor/storage-adaptor/storage_adaptor.h b/adaptor/storage-adaptor/storage_adaptor.h deleted file mode 100644 index fa08897..0000000 --- a/adaptor/storage-adaptor/storage_adaptor.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Storage 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 __STORAGE_ADAPTOR_H__ -#define __STORAGE_ADAPTOR_H__ - -#ifndef API -#define API __attribute__ ((visibility("default"))) -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include - -#include "service_adaptor_errors.h" -#include "cloud_service.h" -//#include "posix_service.h" - -/** - * @file storage_adaptor.h - */ - -/** - * @ingroup - * @defgroup - * - * @brief - * - * @section - * \#include - * - *
- * @{ - */ - -#define URI_STORAGE "storage" -#define URI_CLOUD "storage/cloud" -#define URI_POSIX "storage/posix" - -/** - * @brief Describes infromation about Storage Spec - */ -typedef enum _storage_spec_e -{ - STORAGE_SPEC_CLOUD = (1 << 0), - STORAGE_SPEC_POSIX = (1 << 1), -} storage_spec_e; - -/** - * @brief Describes infromation about Storage Plugin - */ -typedef struct _storage_plugin_s -{ - char *uri; - char *name; - char *package; - - cloud_service_h cloud; -// posix_service_h posix; - - GMutex mutex; - GCond cond; -} storage_plugin_s; -typedef struct _storage_plugin_s *storage_plugin_h; - -/** - * @brief Describes infromation about Storage Adaptor - */ -typedef struct _storage_adaptor_s -{ - GList *plugins; // storage_plugin_h - - GMutex mutex; - int start; -} storage_adaptor_s; -typedef struct _storage_adaptor_s *storage_adaptor_h; - -/** - * @brief Describes infromation about Storage Adaptor Listener - */ -typedef struct _storage_adaptor_listener_s -{ - void (*create_file_cb)(const char *uri, const char *path, void *user_data); -} storage_adaptor_listener_s; -typedef struct _storage_adaptor_listener_s *storage_adaptor_listener_h; - -storage_adaptor_h storage_adaptor_create(); -service_adaptor_error_e storage_adaptor_destroy(storage_adaptor_h storage); -service_adaptor_error_e storage_adaptor_start(storage_adaptor_h storage); -service_adaptor_error_e storage_adaptor_stop(storage_adaptor_h storage); -service_adaptor_error_e storage_adaptor_register_listener(storage_adaptor_h storage, storage_adaptor_listener_h listener); -service_adaptor_error_e storage_adaptor_unregister_listener(storage_adaptor_h storage, storage_adaptor_listener_h listener); -service_adaptor_error_e storage_adaptor_create_plugin(const char *uri, const char *name, const char *package, storage_plugin_h *plugin); -service_adaptor_error_e storage_adaptor_destroy_plugin(storage_plugin_h plugin); -service_adaptor_error_e storage_adaptor_register_plugin_service(storage_plugin_h plugin, GHashTable *service); -service_adaptor_error_e storage_adaptor_unregister_plugin_service(storage_plugin_h plugin); -service_adaptor_error_e storage_adaptor_add_plugin(storage_adaptor_h storage, storage_plugin_h plugin); -service_adaptor_error_e storage_adaptor_remove_plugin(storage_adaptor_h storage, storage_plugin_h plugin); -storage_plugin_h storage_adaptor_get_plugin(storage_adaptor_h storage, const char *uri); -char *storage_adaptor_get_uri(storage_adaptor_h storage, const char *package); -service_adaptor_error_e storage_adaptor_ref_plugin(storage_adaptor_h storage, const char *uri); -service_adaptor_error_e storage_adaptor_unref_plugin(storage_adaptor_h storage, const char *uri); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* __STORAGE_ADAPTOR_H__ */ diff --git a/api/client/sal_client_internal.c b/api/client/sal_client_internal.c deleted file mode 100644 index ce0aeed..0000000 --- a/api/client/sal_client_internal.c +++ /dev/null @@ -1,81 +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 - -#include "sal_log.h" -#include "sal_ipc.h" - -#include "sal_client_internal.h" -#include - -/****************************************************************************** - * 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 deleted file mode 100644 index 7c91e51..0000000 --- a/api/client/sal_client_internal.h +++ /dev/null @@ -1,47 +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 __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 deleted file mode 100644 index 604e8d3..0000000 --- a/api/client/sal_client_types.h +++ /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 __SAL_CLIENT_TYPES_H__ -#define __SAL_CLIENT_TYPES_H__ - -#ifndef API -#define API __attribute__ ((visibility("default"))) -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include - -/** - * @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 deleted file mode 100644 index 63439ac..0000000 --- a/api/client/sal_service_adaptor.c +++ /dev/null @@ -1,420 +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 -#include -#include -#include - -#include - -#include - -#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 deleted file mode 100644 index 8808040..0000000 --- a/api/client/sal_service_adaptor.h +++ /dev/null @@ -1,46 +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 - -/* 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 deleted file mode 100644 index 867597f..0000000 --- a/api/client/sal_service_auth.c +++ /dev/null @@ -1,230 +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 -#include -#include - -#include -#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 deleted file mode 100644 index 5e9f483..0000000 --- a/api/client/sal_service_auth.h +++ /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/api/client/sal_service_auth_internal.h b/api/client/sal_service_auth_internal.h deleted file mode 100644 index 850338a..0000000 --- a/api/client/sal_service_auth_internal.h +++ /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 - -#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 deleted file mode 100644 index 302dca7..0000000 --- a/api/client/sal_service_storage.c +++ /dev/null @@ -1,630 +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 -#include -#include - -#include -#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 deleted file mode 100644 index f2459ce..0000000 --- a/api/client/sal_service_storage.h +++ /dev/null @@ -1,75 +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 -*/ - -#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 deleted file mode 100644 index ecfbc9b..0000000 --- a/api/client/sal_service_storage_internal.h +++ /dev/null @@ -1,162 +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 - -#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 deleted file mode 100644 index c3960fd..0000000 --- a/api/client/sal_service_task.c +++ /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 -#include -#include -#include - -#include - -#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 deleted file mode 100644 index 0825e24..0000000 --- a/api/client/sal_service_task.h +++ /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/api/client/sal_service_task_internal.h b/api/client/sal_service_task_internal.h deleted file mode 100644 index 9a1763a..0000000 --- a/api/client/sal_service_task_internal.h +++ /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/common/CMakeLists.txt b/common/CMakeLists.txt.backup similarity index 100% rename from common/CMakeLists.txt rename to common/CMakeLists.txt.backup diff --git a/common/base/sal_ipc.c b/common/base/sal_ipc.c deleted file mode 100644 index 8c9729d..0000000 --- a/common/base/sal_ipc.c +++ /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 -#include - -#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 deleted file mode 100644 index b8d4606..0000000 --- a/common/base/sal_ipc.h +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Service Adaptor IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 -#include - -/** - * ################################## - * # { 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 deleted file mode 100644 index d152d5f..0000000 --- a/common/base/sal_log.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Service Adaptor - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 -#include -#include - -#ifdef API -#undef API -#endif -#define API __attribute__ ((visibility("default"))) - -#define LOG_TAG "SERVICE-ADAPTOR" -#include -#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 deleted file mode 100644 index 039b43e..0000000 --- a/common/base/sal_types.h +++ /dev/null @@ -1,106 +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_TYPES_INTERNAL_H__ -#define __TIZEN_CONVERGENCE_SERVICE_ADAPTOR_TYPES_INTERNAL_H__ - -#include -#include - -#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 deleted file mode 100644 index 887e61b..0000000 --- a/common/ipc-adaptor/sal_ipc_adaptor.c +++ /dev/null @@ -1,468 +0,0 @@ -/* - * 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 -#include -#include - -#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(" 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 deleted file mode 100644 index 27562eb..0000000 --- a/common/ipc-adaptor/sal_ipc_adaptor.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Service Adaptor Client IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 -#include - -#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 deleted file mode 100644 index 8cd419e..0000000 --- a/common/ipc-adaptor/sal_ipc_adaptor_types.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Service Adaptor Client IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 -#include - -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 deleted file mode 100644 index 796c070..0000000 --- a/common/ipc-adaptor/sal_ipc_client_auth.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 -#include - -#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 deleted file mode 100644 index d75e204..0000000 --- a/common/ipc-adaptor/sal_ipc_client_auth.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Service Adaptor Client Auth IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 deleted file mode 100644 index 55f2961..0000000 --- a/common/ipc-adaptor/sal_ipc_client_core.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - * 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 -#include - -#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(" 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 deleted file mode 100644 index 40a55fa..0000000 --- a/common/ipc-adaptor/sal_ipc_client_core.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Service Adaptor Client Core IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 - -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 deleted file mode 100644 index 13eb27d..0000000 --- a/common/ipc-adaptor/sal_ipc_client_storage.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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 -#include - -#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 deleted file mode 100644 index a86eb1e..0000000 --- a/common/ipc-adaptor/sal_ipc_client_storage.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Service Adaptor Client Storage IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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__ */ - diff --git a/common/ipc-client/sal_ipc_client.c b/common/ipc-client/sal_ipc_client.c deleted file mode 100644 index 6156b5f..0000000 --- a/common/ipc-client/sal_ipc_client.c +++ /dev/null @@ -1,531 +0,0 @@ -/* - * 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 -#include - -#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 - */ -typedef struct _dbus_client_thread_data_s { - GMutex connection_mutex; /* Mutex used to protect connection status data */ - GCond connection_cond; /* Conditional variable used to signal that connection was established */ - int connection_cond_signaled; /* Additional variable used to signal that connection was established */ -} dbus_client_thread_data_s; -typedef struct _dbus_client_thread_data_s *dbus_client_thread_data_h; - -/** - * D-Bus client thread. - */ -static GThread *dbus_client_thread = NULL; - -/** - * D-Bus client thread main loop context. - */ -static GMainContext *dbus_client_context = NULL; - -/** - * D-Bus client thread main loop. - */ -static GMainLoop *dbus_client_loop = NULL; - -/** - * Service Adaptor D-Bus bus watcher id. - */ -static guint watcher_id = 0; - -/** - * D-Bus connection to vService Channel - */ -static GDBusConnection *connection = NULL; - -/** - * D-Bus proxy to Service Adaptor Client interface - */ -static GDBusProxy *interface_proxy = NULL; - -/****************************************************************************** - * Private interface - ******************************************************************************/ - -static gpointer _dbus_client_thread_func(gpointer data); - -static int _dbus_client_start(dbus_client_thread_data_h thread_data); - -static int _dbus_client_stop(); - -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 - ******************************************************************************/ - -/** - * @brief D-Bus client thread function. - * - * D-Bus client thread function. It initialises all client D-Bus interfaces. - * @param data Data passed to thread. - * @return Result data from thread (always NULL in this implementation). - */ -static gpointer _dbus_client_thread_func(gpointer data) -{ - SAL_FN_CALL; - - int ret = 0; - - dbus_client_context = g_main_context_new(); - dbus_client_loop = g_main_loop_new(dbus_client_context, FALSE); - g_main_context_push_thread_default(dbus_client_context); - - ret = _dbus_client_start(data); - - if (SAL_ERROR_NONE == ret) { - g_main_loop_run(dbus_client_loop); - } - - _dbus_client_stop(); - - g_main_context_pop_thread_default(dbus_client_context); - g_main_loop_unref(dbus_client_loop); - dbus_client_loop = NULL; - g_main_context_unref(dbus_client_context); - dbus_client_context = NULL; - - free(data); - - return NULL; -} - -/** - * @brief Initialises Service Adaptor D-Bus client internal structures. - * - * Initialises Service Adaptor D-Bus client internal structures. - * @param thread_data Pointer to thread data used to signal that connection was successfully established. - * @return 0 on success, error code when some structures could not be initialised. - */ -static int _dbus_client_start(dbus_client_thread_data_h thread_data) -{ - SAL_FN_CALL; - - GError *error = NULL; - - 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 SAL_ERROR_INTERNAL; - } - - interface_proxy = g_dbus_proxy_new_sync(connection, - G_DBUS_PROXY_FLAGS_NONE, - NULL, - SERVICE_ADAPTOR_BUS_NAME, - SERVICE_ADAPTOR_OBJECT_PATH, - SERVICE_ADAPTOR_INTERFACE, - NULL, - &error); - - if (NULL == interface_proxy) { - g_error_free(error); - - g_object_unref(connection); - connection = NULL; - - return SAL_ERROR_INTERNAL; - } - - watcher_id = g_bus_watch_name(G_BUS_TYPE_SYSTEM, - SERVICE_ADAPTOR_BUS_NAME, - G_BUS_NAME_WATCHER_FLAGS_NONE, - _on_name_appeared, - _on_name_vanished, - thread_data, - NULL); - - if (0 == watcher_id) { - g_object_unref(interface_proxy); - interface_proxy = NULL; - - g_object_unref(connection); - connection = NULL; - - return SAL_ERROR_INTERNAL; - } - - int res = g_signal_connect(interface_proxy, - "g-signal", - G_CALLBACK(_on_signal), - NULL); - - if (0 == res) { - g_object_unref(interface_proxy); - interface_proxy = NULL; - - g_object_unref(connection); - connection = NULL; - - g_bus_unwatch_name(watcher_id); - watcher_id = 0; - - return SAL_ERROR_INTERNAL; - } - - return SAL_ERROR_NONE; -} - -/** - * @brief Deinitialises Service Adaptor D-Bus client internal structures. - * - * Deinitialises Service Adaptor D-Bus client internal structures. - */ -static int _dbus_client_stop() -{ - SAL_FN_CALL; - - if (NULL != interface_proxy) { - g_object_unref(interface_proxy); - interface_proxy = NULL; - } - - if (NULL != connection) { - g_object_unref(connection); - connection = NULL; - } - - if (0 != watcher_id) { - g_bus_unwatch_name(watcher_id); - watcher_id = 0; - } - - return SAL_ERROR_NONE; -} - -/** - * @brief Service Adaptor availability callback function. - * - * Service Adaptor availability callback function. Called when Service Adaptor appears at D-Bus bus. - * @param connection D-Bus connection. - * @param name The name being watched. - * @param name_owner Unique name of the owner of the name being watched. - * @param user_data User data passed to g_bus_watch_name(). - */ -static void _on_name_appeared(GDBusConnection *connection, - const gchar *name, - const gchar *name_owner, - gpointer user_data) -{ - SAL_FN_CALL; - - dbus_client_thread_data_h thread_data = (dbus_client_thread_data_h) user_data; - - if (NULL != thread_data) { - g_mutex_lock(&thread_data->connection_mutex); - thread_data->connection_cond_signaled = 1; - g_cond_signal(&thread_data->connection_cond); - g_mutex_unlock(&thread_data->connection_mutex); - } -} - -/** - * @brief Service Adaptor availability callback function. - * - * Service Adaptor availability callback function. Called when Service Adaptor disappears from D-Bus bus. - * @param connection D-Bus connection. - * @param name he name being watched. - * @param user_data User data passed to g_bus_watch_name(). - */ -static void _on_name_vanished(GDBusConnection *connection, - const gchar *name, - gpointer user_data) -{ - SAL_FN_CALL; - - if (NULL != interface_proxy) { - g_object_unref(interface_proxy); - interface_proxy = NULL; - } - - if (NULL != connection) { - g_object_unref(connection); - connection = NULL; - } - - if (0 != watcher_id) { - g_bus_unwatch_name(watcher_id); - watcher_id = 0; - } -} - -/** - * @brief Service Adaptor signals handler. - * - * Service Adaptor signals handler. It is called when Service Adaptor sends signal over D-Bus. - * @param proxy D-Bus proxy object. - * @param sender_name The unique bus name of the remote caller. - * @param signal_name Signal name. - * @param parameters Signal parameters. - * @param user_data The user_data gpointer. - */ -static void _on_signal(GDBusProxy *proxy, - gchar *sender_name, - gchar *signal_name, - GVariant *parameters, - gpointer user_data) -{ - SAL_FN_CALL; - - if (0 == strncmp(signal_name, DBUS_SERVICE_ADAPTOR, DBUS_NAME_LENGTH)) { - /* TODO: */ -/* - on_service_signal(proxy, - sender_name, - signal_name, - parameters, - user_data); -*/ - } -} - -/****************************************************************************** - * Public interface definition - ******************************************************************************/ - -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(" 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_init() -{ - SAL_FN_CALL; - -#if !GLIB_CHECK_VERSION(2, 32, 0) - g_thread_init(NULL); -#endif -#if !GLIB_CHECK_VERSION(2, 35, 0) - g_type_init(); -#endif - - 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)); - - g_mutex_init(&thread_data->connection_mutex); - g_cond_init(&thread_data->connection_cond); - thread_data->connection_cond_signaled = 0; - - dbus_client_thread = g_thread_new("Service Adaptor D-Bus Client", _dbus_client_thread_func, thread_data); - - gint64 timeout = g_get_monotonic_time() + 5 * G_TIME_SPAN_SECOND; - g_mutex_lock(&thread_data->connection_mutex); - while (!thread_data->connection_cond_signaled) { - if (!g_cond_wait_until(&thread_data->connection_cond, &thread_data->connection_mutex, timeout)) { - g_mutex_unlock(&thread_data->connection_mutex); - return SAL_ERROR_INTERNAL; - } - } - - g_mutex_unlock(&thread_data->connection_mutex); - - return SAL_ERROR_NONE; -} - -API int sal_ipc_client_deinit() -{ - SAL_FN_CALL; - - if (NULL != dbus_client_loop) { - if (g_main_loop_is_running(dbus_client_loop)) { - g_main_loop_quit(dbus_client_loop); - } - } - - if (NULL != dbus_client_thread) { - g_thread_join(dbus_client_thread); - dbus_client_thread = NULL; - } - - if (NULL != dbus_client_loop) { - g_main_loop_unref(dbus_client_loop); - dbus_client_loop = NULL; - } - - if (NULL != dbus_client_context) { - g_main_context_pop_thread_default(dbus_client_context); - g_main_context_unref(dbus_client_context); - dbus_client_context = NULL; - } - 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-client/sal_ipc_client.h b/common/ipc-client/sal_ipc_client.h deleted file mode 100644 index 4235f90..0000000 --- a/common/ipc-client/sal_ipc_client.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Service Adaptor Client IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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_H__ -#define __TIZEN_CONVERGENCE_SAL_IPC_CLIENT_H__ - -#ifndef API -#define API __attribute__ ((visibility("default"))) -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include - -#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); - -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 - -#endif /* __TIZEN_CONVERGENCE_SAL_IPC_CLIENT_H__ */ - diff --git a/common/ipc-client/sal_ipc_client_auth.c b/common/ipc-client/sal_ipc_client_auth.c deleted file mode 100644 index 796c070..0000000 --- a/common/ipc-client/sal_ipc_client_auth.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 -#include - -#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-client/sal_ipc_client_auth.h b/common/ipc-client/sal_ipc_client_auth.h deleted file mode 100644 index d75e204..0000000 --- a/common/ipc-client/sal_ipc_client_auth.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Service Adaptor Client Auth IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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-client/sal_ipc_client_core.c b/common/ipc-client/sal_ipc_client_core.c deleted file mode 100644 index 55f2961..0000000 --- a/common/ipc-client/sal_ipc_client_core.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - * 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 -#include - -#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(" 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-client/sal_ipc_client_core.h b/common/ipc-client/sal_ipc_client_core.h deleted file mode 100644 index 40a55fa..0000000 --- a/common/ipc-client/sal_ipc_client_core.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Service Adaptor Client Core IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 - -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-client/sal_ipc_client_storage.c b/common/ipc-client/sal_ipc_client_storage.c deleted file mode 100644 index 13eb27d..0000000 --- a/common/ipc-client/sal_ipc_client_storage.c +++ /dev/null @@ -1,130 +0,0 @@ -/* - * 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 -#include - -#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-client/sal_ipc_client_storage.h b/common/ipc-client/sal_ipc_client_storage.h deleted file mode 100644 index a86eb1e..0000000 --- a/common/ipc-client/sal_ipc_client_storage.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Service Adaptor Client Storage IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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__ */ - diff --git a/common/ipc-provider/sal_ipc_provider.c b/common/ipc-provider/sal_ipc_provider.c deleted file mode 100644 index a0d30ab..0000000 --- a/common/ipc-provider/sal_ipc_provider.c +++ /dev/null @@ -1,446 +0,0 @@ -/* - * 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 -#include -#include - -#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[] = -"" -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -""; - -/****************************************************************************** - * 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 deleted file mode 100644 index b93c5a6..0000000 --- a/common/ipc-provider/sal_ipc_provider.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Service Adaptor Server IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 - -#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 deleted file mode 100644 index fff09c5..0000000 --- a/common/ipc-provider/sal_ipc_provider_base.c +++ /dev/null @@ -1,302 +0,0 @@ -/* - * 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 -#include -#include - -#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 deleted file mode 100644 index 7ce7568..0000000 --- a/common/ipc-provider/sal_ipc_provider_base.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Service Adaptor Server Core IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 -#include - -#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 deleted file mode 100644 index 891af08..0000000 --- a/common/ipc-provider/sal_ipc_provider_storage.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - * 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 -#include -#include - -#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 deleted file mode 100644 index 418f258..0000000 --- a/common/ipc-provider/sal_ipc_provider_storage.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Service Adaptor Server Storage IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 -#include - -#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 deleted file mode 100644 index 62bfef2..0000000 --- a/common/ipc-provider/sal_ipc_provider_types.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Service Adaptor Server IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 - -/** - * 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__ */ - diff --git a/common/ipc-server/sal_ipc_server.c b/common/ipc-server/sal_ipc_server.c deleted file mode 100644 index 9d41ae3..0000000 --- a/common/ipc-server/sal_ipc_server.c +++ /dev/null @@ -1,463 +0,0 @@ -/* - * 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 -#include - -#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 GThread *dbus_server_thread = NULL; - -/** - * D-Bus server thread main loop context - */ -static GMainContext *dbus_server_context = NULL; - -/** - * D-Bus server thread main loop - */ -static GMainLoop *dbus_server_loop = NULL; - -/** - * 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; - -/** - * Introspection data describing D-Bus interface - */ -static const gchar introspection_xml[] = -"" -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -""; - -/****************************************************************************** - * Private interface - ******************************************************************************/ - -/****************************************************************************** - * Private interface definition - ******************************************************************************/ - -static void _method_call_async_func(gpointer data, gpointer user_data) -{ - SAL_FN_CALL; - - 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)) { - 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)) { - 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)) { - g_main_context_invoke(g_working_context, sal_server_storage_method_call, (void *)handle); - } -} - -/** - * @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_server_session_h handle = (ipc_server_session_h) g_malloc0(sizeof(ipc_server_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; - - g_thread_pool_push(thread_pool, (gpointer) handle, NULL); -} - -/** - * @brief Service Adaptor D-Bus interface get property call handler. - * - * Service Adaptor D-Bus interface get property call handler. - * @param connection A GDBusConnection. - * @param sender The unique bus name of the remote caller. - * @param object_path The object path that the method was invoked on. - * @param interface_name The D-Bus interface name for the property. - * @param property_name The name of the property to get the value of. - * @param error Return location for error. - * @param user_data The user_data gpointer passed to g_dbus_connection_register_object(). - * @return A GVariant with the value for property_name or NULL if error is set. If the returned GVariant - * is floating, it is consumed - otherwise its reference count is decreased by one. - */ -static GVariant *_handle_get_property(GDBusConnection *connection, - const gchar *sender, - const gchar *object_path, - const gchar *interface_name, - const gchar *property_name, - GError **error, - gpointer user_data) -{ - 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; - - registration_id = g_dbus_connection_register_object(connection, - SERVICE_ADAPTOR_OBJECT_PATH, - introspection_data->interfaces[0], - &interface_vtable, - NULL, /* user_data */ - NULL, /* user_data_free_func */ - NULL); /* GError** */ - - g_assert(registration_id > 0); -} - -/** - * @brief Callback function called when D-Bus name for 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); -} - -/** - * @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; - - 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_server_start() -{ - SAL_FN_CALL; - - 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, 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, SAL_ERROR_SYSTEM, "g_thread_pool_new() Failed"); - - owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, - SERVICE_ADAPTOR_BUS_NAME, - G_BUS_NAME_OWNER_FLAGS_NONE, - _on_bus_acquired, - _on_name_acquired, - _on_name_lost, - NULL, - NULL); - - if (0 == owner_id) { - g_dbus_node_info_unref(introspection_data); - introspection_data = NULL; - - return SAL_ERROR_SYSTEM; - } - - return SAL_ERROR_NONE; -} - -int _sal_ipc_server_stop() -{ - SAL_FN_CALL; - - if (NULL != thread_pool) { - g_thread_pool_free(thread_pool, TRUE, TRUE); - } - - if (0 != owner_id) { - g_bus_unown_name(owner_id); - owner_id = 0; - } - - if (NULL != introspection_data) { - g_dbus_node_info_unref(introspection_data); - introspection_data = NULL; - } - - return SAL_ERROR_NONE; -} -/** - * @brief D-Bus server thread function. - * - * D-Bus server thread function. It initialises structures and callbacks needed to export D-Bus interfaces. - * @param data Data passed to thread. - * @return Result data from thread (always NULL in this implementation). - */ -static gpointer _dbus_server_thread_func(gpointer data) -{ - SAL_FN_CALL; - - int ret = 0; - - dbus_server_context = g_main_context_new(); - dbus_server_loop = g_main_loop_new(dbus_server_context, FALSE); - g_main_context_push_thread_default(dbus_server_context); - - ret = _sal_ipc_server_start(); - - if (SAL_ERROR_NONE == ret) { - g_main_loop_run(dbus_server_loop); - } - - _sal_ipc_server_stop(); - - g_main_context_pop_thread_default(dbus_server_context); - g_main_loop_unref(dbus_server_loop); - dbus_server_loop = NULL; - g_main_context_unref(dbus_server_context); - dbus_server_context = NULL; - - return NULL; -} - -/****************************************************************************** - * Public interface definition - ******************************************************************************/ - -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 == 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 SAL_ERROR_NONE; -} - -API int sal_ipc_server_deinit() -{ - SAL_FN_CALL; - - if (NULL != dbus_server_loop) { - if (g_main_loop_is_running(dbus_server_loop)) { - g_main_loop_quit(dbus_server_loop); - } - } - - if (NULL != dbus_server_thread) { - g_thread_join(dbus_server_thread); - dbus_server_thread = NULL; - } - - if (NULL != dbus_server_loop) { - g_main_loop_unref(dbus_server_loop); - dbus_server_loop = NULL; - } - - if (NULL != dbus_server_context) { - g_main_context_pop_thread_default(dbus_server_context); - g_main_context_unref(dbus_server_context); - dbus_server_context = NULL; - } - - return SAL_ERROR_NONE; -} diff --git a/common/ipc-server/sal_ipc_server.h b/common/ipc-server/sal_ipc_server.h deleted file mode 100644 index f128f4e..0000000 --- a/common/ipc-server/sal_ipc_server.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Service Adaptor Server IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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_H__ -#define __TIZEN_CONVERGENCE_SAL_IPC_SERVER_H__ - -#ifndef API -#define API __attribute__ ((visibility("default"))) -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include - -#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 -} -#endif - -#endif /* __TIZEN_CONVERGENCE_SAL_IPC_SERVER_H__ */ - diff --git a/common/ipc-server/sal_ipc_server_auth.c b/common/ipc-server/sal_ipc_server_auth.c deleted file mode 100644 index 74b20b0..0000000 --- a/common/ipc-server/sal_ipc_server_auth.c +++ /dev/null @@ -1,247 +0,0 @@ -/* - * 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 -#include -#include - -#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" -*/ - -/****************************************************************************** - * 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); - - -/****************************************************************************** - * 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 - ******************************************************************************/ - -/* request callbacks */ -static void __chunk_cb(ipc_server_session_h session) -{ - SAL_FN_CALL; - - SAL_FN_END; -} - -/* response functions */ -static void __response_chunk(ipc_server_session_h session) -{ - SAL_FN_CALL; - - 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; 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; -} - - -/****************************************************************************** - * Public interface definition - ******************************************************************************/ - -API int ipc_server_auth_init(ipc_server_auth_req_s *auth_req) -{ - SAL_FN_CALL; - - RETV_IF(NULL == auth_req, SAL_ERROR_INTERNAL); - /*RET_IF(NULL == base_req->chunk_cb);*/ - - req_callbacks.chunk_cb = auth_req->chunk_cb; - - SAL_FN_END; - return SAL_ERROR_NONE; -} - -API gboolean sal_server_auth_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; 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_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, - const gchar *interface_name, - const gchar *method_name, - GVariant *parameters, - GDBusMethodInvocation *invocation, - gpointer user_data) -{ - SAL_FN_CALL; - - int ipc_ret = SAL_ERROR_NONE; - char *ipc_msg = NULL; - char *ipc_type = NULL; - GVariant *ipc_data = NULL; - - char *uri = NULL; - - GVariant *in_parameters = g_variant_get_child_value(parameters, 0); - - if (0 == g_strcmp0(method_name, DBUS_SERVICE_AUTH_OAUTH1_METHOD)) { - int idx = 0; - int size = service_auth_oauth1_req_s_type_length; - GVariant *req_info[size]; - - ipc_create_variant_info(in_parameters, size, (GVariant ***) &req_info); - - char *uri = ipc_insure_g_variant_dup_string(req_info[idx++]); - service_auth_oauth1_h oauth1 = NULL; - _get_oauth1(req_info[idx++], &oauth1); - - SAL_INFO("uri: %s", uri); - - 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 = SAL_ERROR_INTERNAL, "sal_get_handle() Failed"); - - auth_plugin_h plugin = auth_adaptor_get_plugin(sal->auth, uri); - - ipc_reply_data_h reply = (ipc_reply_data_h) g_malloc0(sizeof(ipc_reply_data_s)); - reply->invocation = invocation; - reply->type = strdup(ipc_type); - - ipc_ret = _oauth1_execute_operation(plugin, oauth1, reply); - 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)); - - ipc_destroy_variant_info(req_info, size); - } - - g_dbus_method_invocation_return_value(invocation, ipc_data); - -catch: - SAL_FREE(uri); - SAL_FREE(ipc_msg); - SAL_FREE(ipc_type); - - SAL_FN_END; -} -*/ diff --git a/common/ipc-server/sal_ipc_server_auth.h b/common/ipc-server/sal_ipc_server_auth.h deleted file mode 100644 index 9b088f4..0000000 --- a/common/ipc-server/sal_ipc_server_auth.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Service Adaptor Server Auth IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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_AUTH_H__ -#define __TIZEN_CONVERGENCE_SAL_IPC_SERVER_AUTH_H__ - -#ifndef API -#define API __attribute__ ((visibility("default"))) -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include - -#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 -} -#endif - -#endif /* __TIZEN_CONVERGENCE_SAL_IPC_SERVER_AUTH_H__ */ - diff --git a/common/ipc-server/sal_ipc_server_core.c b/common/ipc-server/sal_ipc_server_core.c deleted file mode 100644 index 63ec679..0000000 --- a/common/ipc-server/sal_ipc_server_core.c +++ /dev/null @@ -1,572 +0,0 @@ -/* - * 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 -#include -#include - -#include "sal_types.h" -#include "sal_log.h" -#include "sal_ipc.h" -#include "sal_ipc_server_core.h" - - -/****************************************************************************** - * 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); - - -/****************************************************************************** - * 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, - const gchar *interface_name, - const gchar *method_name, - GVariant *parameters, - GDBusMethodInvocation *invocation, - gpointer user_data) -{ - SAL_FN_CALL; - - int ipc_ret = SAL_ERROR_NONE; - char *ipc_msg = NULL; - char *ipc_type = NULL; - GVariant *ipc_data = NULL; - - char *uri = NULL; - - GVariant *in_parameters = g_variant_get_child_value(parameters, 0); - - if (0 == g_strcmp0(method_name, DBUS_SERVICE_ADAPTOR_CONNECT_METHOD)) { - int idx = 0; - int size = service_adaptor_connect_req_s_type_length; - GVariant *req_info[size]; - - ipc_create_variant_info(in_parameters, size, (GVariant ***) &req_info); - - char *uri = ipc_insure_g_variant_dup_string(req_info[idx++]); - - SAL_INFO("uri: %s", uri); - - ipc_type = strdup(service_adaptor_connect_res_s_type); - ipc_ret = sal_adaptor_connect(uri); - - int plugins_size = 0; - char **plugins = NULL; - GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE(plugin_list_type)); - - ipc_ret = sal_adaptor_get_plugins(&plugins, &plugins_size); - - for (gsize i = 0; i < plugins_size; i++) { - ipc_insure_g_variant_builder_add_array_string(builder, plugins[i]); - } - - ipc_create_error_msg(ipc_ret, &ipc_msg); - ipc_data = g_variant_new(ipc_make_return_type(ipc_type), builder, ipc_ret, SAL_IPC_STR(ipc_msg)); - - g_variant_builder_unref(builder); - ipc_destroy_variant_info(req_info, size); - } else if (0 == g_strcmp0(method_name, DBUS_SERVICE_ADAPTOR_DISCONNECT_METHOD)) { - int idx = 0; - int size = service_adaptor_disconnect_s_type_length; - GVariant *req_info[size]; - - ipc_create_variant_info(in_parameters, size, (GVariant ***) &req_info); - - char *uri = ipc_insure_g_variant_dup_string(req_info[idx++]); - - SAL_INFO("uri: %s", uri); - - ipc_ret = sal_adaptor_disconnect(uri); - - ipc_create_error_msg(ipc_ret, &ipc_msg); - ipc_data = g_variant_new(ipc_make_return_type(ipc_type), ipc_ret, SAL_IPC_STR(ipc_msg)); - - ipc_destroy_variant_info(req_info, size); - } - - g_dbus_method_invocation_return_value(invocation, ipc_data); - - SAL_FREE(uri); - SAL_FREE(ipc_msg); - SAL_FREE(ipc_type); - - SAL_FN_END; -} - -API void service_plugin_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; - - int ipc_ret = SAL_ERROR_NONE; - char *ipc_msg = NULL; - char *ipc_type = NULL; - GVariant *ipc_data = NULL; - - char *uri = NULL; - - GVariant *in_parameters = g_variant_get_child_value(parameters, 0); - - if (0 == g_strcmp0(method_name, DBUS_SERVICE_PLUGIN_CREATE_METHOD)) { - int idx = 0; - int size = service_plugin_create_s_type_length; - GVariant *req_info[size]; - - ipc_create_variant_info(in_parameters, size, (GVariant ***) &req_info); - - char *uri = ipc_insure_g_variant_dup_string(req_info[idx++]); - - SAL_INFO("uri: %s", uri); - - ipc_ret = SAL_ERROR_INTERNAL; - - sal_h sal = sal_get_handle(); - - if (NULL != sal) { - ipc_ret = auth_adaptor_ref_plugin(sal->auth, uri); - } - - ipc_create_error_msg(ipc_ret, &ipc_msg); - ipc_data = g_variant_new(ipc_make_return_type(ipc_type), ipc_ret, SAL_IPC_STR(ipc_msg)); - - ipc_destroy_variant_info(req_info, size); - } else if (0 == g_strcmp0(method_name, DBUS_SERVICE_PLUGIN_DESTROY_METHOD)) { - int idx = 0; - int size = service_plugin_destroy_s_type_length; - GVariant *req_info[size]; - - ipc_create_variant_info(in_parameters, size, (GVariant ***) &req_info); - - char *uri = ipc_insure_g_variant_dup_string(req_info[idx++]); - - SAL_INFO("uri: %s", uri); - - ipc_ret = SAL_ERROR_INTERNAL; - - sal_h sal = sal_get_handle(); - - if (NULL != sal) { - ipc_ret = auth_adaptor_unref_plugin(sal->auth, uri); - } - - ipc_create_error_msg(ipc_ret, &ipc_msg); - ipc_data = g_variant_new(ipc_make_return_type(ipc_type), ipc_ret, SAL_IPC_STR(ipc_msg)); - - ipc_destroy_variant_info(req_info, size); - } - - g_dbus_method_invocation_return_value(invocation, ipc_data); - - SAL_FREE(uri); - SAL_FREE(ipc_msg); - SAL_FREE(ipc_type); - - 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) -{ - SAL_FN_CALL; - - GError* error = NULL; - GDBusConnection *dbus_connection = dbus_get_connection(); - - if (NULL != dbus_connection) { - GVariant *response = g_variant_new("(ts)", (uint64_t) signal_code, signal_msg); - - g_dbus_connection_emit_signal(dbus_connection, - NULL, - SERVICE_ADAPTOR_OBJECT_PATH, - SERVICE_ADAPTOR_INTERFACE, - DBUS_SERVICE_ADAPTOR_SIGNAL, - response, - &error ); - - if (NULL != error) { - service_adaptor_debug("Unable to send msg: %s", error->message); - return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS; - } - } - - return SERVICE_ADAPTOR_INTERNAL_ERROR_NONE; -} -*/ diff --git a/common/ipc-server/sal_ipc_server_core.h b/common/ipc-server/sal_ipc_server_core.h deleted file mode 100644 index 4cdb2d7..0000000 --- a/common/ipc-server/sal_ipc_server_core.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Service Adaptor Server Core IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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_CORE_H__ -#define __TIZEN_CONVERGENCE_SAL_IPC_SERVER_CORE_H__ - -#ifndef API -#define API __attribute__ ((visibility("default"))) -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include - -#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, - const gchar *interface_name, - const gchar *method_name, - GVariant *parameters, - GDBusMethodInvocation *invocation, - gpointer user_data); - -void service_plugin_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); -*/ -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_CONVERGENCE_SAL_IPC_SERVER_CORE_H__ */ - diff --git a/common/ipc-server/sal_ipc_server_storage.c b/common/ipc-server/sal_ipc_server_storage.c deleted file mode 100644 index 84ee46b..0000000 --- a/common/ipc-server/sal_ipc_server_storage.c +++ /dev/null @@ -1,249 +0,0 @@ -/* - * 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 -#include -#include - -#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" -*/ - -/****************************************************************************** - * 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); - - -/****************************************************************************** - * 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 - ******************************************************************************/ - -/* request callbacks */ -static void __chunk_cb(ipc_server_session_h session) -{ - SAL_FN_CALL; - - SAL_FN_END; -} - -/* response functions */ -static void __response_chunk(ipc_server_session_h session) -{ - SAL_FN_CALL; - - 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; __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; -} - -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; -} - - -/****************************************************************************** - * Public interface definition - ******************************************************************************/ - -API int ipc_server_storage_init(ipc_server_storage_req_s *storage_req) -{ - SAL_FN_CALL; - - RETV_IF(NULL == storage_req, SAL_ERROR_INTERNAL); - /*RET_IF(NULL == base_req->chunk_cb);*/ - - req_callbacks.chunk_cb = storage_req->chunk_cb; - - SAL_FN_END; - return SAL_ERROR_NONE; -} - -API gboolean sal_server_storage_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; __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); - } - } - - 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_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, - const gchar *interface_name, - const gchar *method_name, - GVariant *parameters, - GDBusMethodInvocation *invocation, - gpointer user_data) -{ - SAL_FN_CALL; - - int ipc_ret = SAL_ERROR_NONE; - char *ipc_msg = NULL; - char *ipc_type = NULL; - GVariant *ipc_data = NULL; - - char *uri = NULL; - - GVariant *in_parameters = g_variant_get_child_value(parameters, 0); - - if (0 == g_strcmp0(method_name, DBUS_SERVICE_STORAGE_CLOUD_FILE_METHOD)) { - int idx = 0; - int size = service_storage_cloud_file_req_s_type_length; - GVariant *req_info[size]; - - ipc_create_variant_info(in_parameters, size, (GVariant ***) &req_info); - - char *uri = ipc_insure_g_variant_dup_string(req_info[idx++]); - service_storage_cloud_file_h file = NULL; - _get_cloud_file(req_info[idx++], &file); - - SAL_INFO("uri: %s", uri); - - 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 = SAL_ERROR_INTERNAL, "sal_get_handle() Failed"); - - storage_plugin_h plugin = storage_adaptor_get_plugin(sal->storage, uri); - - ipc_reply_data_h reply = (ipc_reply_data_h) g_malloc0(sizeof(ipc_reply_data_s)); - reply->invocation = invocation; - reply->type = strdup(ipc_type); - - ipc_ret = _cloud_execute_operation(plugin, file, reply); - 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); - ipc_data = g_variant_new(ipc_make_return_type(ipc_type), false, "", "", 0, 0, builder, ipc_ret, SAL_IPC_STR(ipc_msg)); - - g_variant_builder_unref(builder); - ipc_destroy_variant_info(req_info, size); - } - - g_dbus_method_invocation_return_value(invocation, ipc_data); - -catch: - SAL_FREE(uri); - SAL_FREE(ipc_msg); - SAL_FREE(ipc_type); - - SAL_FN_END; -} -*/ diff --git a/common/ipc-server/sal_ipc_server_storage.h b/common/ipc-server/sal_ipc_server_storage.h deleted file mode 100644 index 346fb27..0000000 --- a/common/ipc-server/sal_ipc_server_storage.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Service Adaptor Server Storage IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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_STORAGE_H__ -#define __TIZEN_CONVERGENCE_SAL_IPC_SERVER_STORAGE_H__ - -#ifndef API -#define API __attribute__ ((visibility("default"))) -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - -#include -#include - -#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, - const gchar *interface_name, - const gchar *method_name, - GVariant *parameters, - GDBusMethodInvocation *invocation, - gpointer user_data); -*/ -#ifdef __cplusplus -} -#endif - -#endif /* __TIZEN_CONVERGENCE_SAL_IPC_SERVER_STORAGE_H__ */ - diff --git a/common/ipc-server/sal_ipc_server_types.h b/common/ipc-server/sal_ipc_server_types.h deleted file mode 100644 index 82ada6a..0000000 --- a/common/ipc-server/sal_ipc_server_types.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Service Adaptor Server IPC - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 -#include - -/** - * 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/include/service_adaptor_client.h b/include/service_adaptor_client.h deleted file mode 100644 index dfe44c1..0000000 --- a/include/service_adaptor_client.h +++ /dev/null @@ -1,208 +0,0 @@ -/* -* 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 -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file 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()
-* 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 installed service plugins, this value can be masked multiple enum (#service_plugin_service_type_e) -* @param[in] user_data Passed data from #service_adaptor_foreach_plugin() -* @remarks @a service_mask check using 'bit and' operation with #service_plugin_service_type_e -* @remarks - for example, -* @remarks      if(@a service_mask & SERVICE_PLUGIN_SERVICE_STORAGE) -* @remarks          { @a USING_STORAGE_CODE } -* @remarks Do not release memory of @a plugin_uri -* @see service_plugin_service_type_e -* @return @c true to continue with the next iteration of the loop, -* otherwise @c false to break out of the loop -* @pre service_adaptor_foreach_plugin() will invoke this callback. -*/ -typedef bool (*service_adaptor_plugin_cb)(char *plugin_uri, - int service_mask, - void *user_data); -/*================================================================================================== - FUNCTION PROTOTYPES -==================================================================================================*/ - -/** -* @brief Create Service Adaptor -* @since_tizen 2.4 -* -* @param[out] service_adaptor The Service Adaptor handle -* @remarks @a service_adaptor must be released memory using service_adaptor_destroy(), when a program no longer needs any function of Service Adaptor -* @see service_adaptor_destroy() -* @return 0 on success, otherwise a negative error value -* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful -* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error -*/ -int service_adaptor_create(service_adaptor_h *service_adaptor); - -/** -* @brief Destroy Service Adaptor -* @details It must called after a program no longer needs any function of Service Adaptor -* @since_tizen 2.4 -* -* @param[in] service_adaptor The handle of Service Adaptor -* @see service_adaptor_create() -* @return 0 on success, otherwise a negative error value -* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful -* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error -* @pre @a service_adaptor must be issued by service_adaptor_create() -*/ -int service_adaptor_destroy(service_adaptor_h service_adaptor); - -/** -* @brief Foreach the list of plugin -* @details Iterate to all installed plugin -* @since_tizen 2.4 -* -* @param[in] service_adaptor The handle of Service Adaptor -* @param[in] callback The callback for foreach plugin -* @param[in] user_data Passed data to callback -* @return 0 on success, otherwise a negative error value -* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful -* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no available plugins -* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error -* @pre @a service_adaptor must be issued by service_adaptor_create() -*/ -int service_adaptor_foreach_plugin(service_adaptor_h service_adaptor, - service_adaptor_plugin_cb callback, - void *user_data); - -/** -* @brief Create service plugin handle -* @details Create plugin handle using @a plugin_uri -* @since_tizen 2.4 -* -* @param[in] service_adaptor The handle of Service Adaptor -* @param[in] plugin_uri The specfic string for use plugin, this values are set by plugin -* @param[out] plugin The handle for use Plugin APIs -* @remarks @a plugin must be released memory using service_plugin_destroy() when you no longer needs plugin's API -* @see service_plugin_destroy() -* @return 0 on success, otherwise a negative error value -* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful -* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error -* @pre @a service_adaptor must be issued by service_adaptor_create() -*/ -int service_adaptor_create_plugin(service_adaptor_h service_adaptor, - const char *plugin_uri, - service_plugin_h *plugin); - -/** -* @brief Gets service specfic last result -* @details This function retrieves the last error code that be issued from plugin.
-* 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.
-* When if API function returns #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, gets using this function. -* @since_tizen 2.4 -* -* @param[out] message The error message that is defined service plugin SPEC -* @remarks @a message must be released using free() -* @remarks Thread safe functions -* @remarks The result string's detail specification is defined service plugin or provider. -* @see service_adaptor_get_last_result() -* @return 0 on success, otherwise a negative error value -* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful -* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no error message -* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error -*/ -int service_adaptor_get_last_error_message(char **message); - -/** -* @brief Gets Plugin Property -* @since_tizen 2.4 -* -* @param[in] plugin The handle for use Plugin APIs -* @param[in] key The key of plugin property -* @param[out] value The value of plugin property that matched @a key -* @remarks Some kind of property key(Not mandatory) is defined in this API (That is named to SERVICE_PLUGIN_PROPERTY_XXX) -* @remarks @a value must be released using free() -* @return 0 on success, otherwise a negative error value -* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful -* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no property -* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error -* @see SERVICE_PLUGIN_PROPERTY_APP_KEY -* @see SERVICE_PLUGIN_PROPERTY_APP_SECRET -* @see SERVICE_PLUGIN_PROPERTY_USER_ID -*/ -int service_plugin_get_property(service_plugin_h plugin, - const char *key, - char **value); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif -#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_H__ */ diff --git a/include/service_adaptor_client_plugin.h b/include/service_adaptor_client_plugin.h deleted file mode 100644 index f829223..0000000 --- a/include/service_adaptor_client_plugin.h +++ /dev/null @@ -1,174 +0,0 @@ -/* -* 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 - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup SERVICE_PLUGIN_MODULE - * @{ - */ - -/** -* @brief The Plugn handle for Service Adaptor -* @details The handle can be created by service_adaptor_create_plugin()
-* 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.
-* This value is not used in Adaptor layer, but it can be uesd to important Key for plugin with service provider.
-* @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      int @a service_mask |= SERVIE_PLUGIN_SERVICE_AUTH; -* @remarks      @a service_mask |= SERVICE_PLUGIN_SERVICE_STORAGE; -* @remarks      int ret = service_plugin_start(@a m_plugin, @a service_mask); -* @remarks If a program needs to stop plugin manually, use #service_plugin_stop().
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.
But in #service_plugin_destroy(), automatically stop service plugin -* @remarks @a plugin must be released memory using #service_plugin_destroy() when you no longer needs plugin's API -* @see service_plugin_start() -* @see service_plugin_destroy() -* @return 0 on success, otherwise a negative error value -* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful -* @retval #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out -* @retval #SERVICE_ADAPTOR_ERROR_IPC_UNSTABLE IPC failed with Service Adaptor Daemon -* @retval #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error -* @pre service_plugin_start() -*/ -int service_plugin_stop(service_plugin_h plugin); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif -#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_PLUGIN_H__ */ diff --git a/include/service_adaptor_client_storage.h b/include/service_adaptor_client_storage.h deleted file mode 100644 index fcdb135..0000000 --- a/include/service_adaptor_client_storage.h +++ /dev/null @@ -1,642 +0,0 @@ -/* -* 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 - * - *****************************************************************************/ -/** - * @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 - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file service_adaptor_client_storage.h - */ - -/** - * @addtogroup SERVICE_ADAPTOR_STORAGE_MODULE - - * @{ - */ - -/** -* @brief The handle of async task for storage service -* @since_tizen 2.4 -* -* @see #service_storage_create_download_task() -* @see #service_storage_create_upload_task() -*/ -typedef struct _service_storage_task_s *service_storage_task_h; - -/** -* @brief The handle of file or directory in storage -* @since_tizen 2.4 -* -* @see #service_storage_file_clone() -* @see #service_storage_file_destroy() -*/ -typedef struct _service_storage_file_s *service_storage_file_h; - -/** -* @brief The list handle of file or directory in storage -* @since_tizen 2.4 -* -* @see #service_storage_file_list_clone() -* @see #service_storage_file_list_destroy() -*/ -typedef struct _service_storage_file_list_s *service_storage_file_list_h; - -/** - * @brief Type of storage task - * @since_tizen 2.4 - */ -typedef enum -{ - SERVICE_STORAGE_TASK_IN_PROGRESS = 1, /**< The task is progressing */ - SERVICE_STORAGE_TASK_COMPLETED = 2, /**< The task was completed */ - SERVICE_STORAGE_TASK_CANCELED = 3, /**< The task was canceled */ - SERVICE_STORAGE_TASK_FAILED = 4, /**< The task was failed */ -} service_storage_task_state_e; - -/** -* @brief Callback for changing state of storage task -* @since_tizen 2.4 -* -* @param[in] state The state of storage task -* @param[in] user_data The user data passed from #service_storage_set_task_state_changed_cb() -* @see #service_storage_unset_task_state_changed_cb() -* @pre #service_storage_set_task_state_changed_cb() will invoke this callback. -*/ -typedef void (*service_storage_task_state_cb)(service_storage_task_state_e state, - void *user_data); - -/** -* @brief Callback for progress of storage task -* @since_tizen 2.4 -* -* @param[in] progress The progressed amount of storage task -* @param[in] total The total amount of storage task -* @param[in] user_data The user data passed from #service_storage_set_task_progress_cb() -* @see #service_storage_unset_task_progress_cb() -* @pre #service_storage_set_task_progress_cb() will invoke this callback. -*/ -typedef void (*service_storage_task_progress_cb)(unsigned long long progress, - unsigned long long total, - void *user_data); - -/** -* @brief Callback for getting async storage operation result -* @since_tizen 2.4 -* -* @param[in] result Result code for storage async operation (see #service_adaptor_error_e) -* @param[in] user_data Passed data from request function -* @remarks If the @a result value is #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin. -* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_NONE Successful -* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files -* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out -* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal -* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error -* @see #service_adaptor_error_e -* @see service_storage_remove() -* @pre #service_storage_remove() will invoke this callback. -*/ -typedef void (*service_storage_result_cb)(int result, - void *user_data); - - -/** -* @brief Callback for getting file list API -* @since_tizen 2.4 -* -* @param[in] result Result code for #service_storage_get_file_list() (see #service_adaptor_error_e) -* @param[in] list The handle of file list -* @param[in] user_data Passed data from #service_storage_get_file_list() -* @remarks If the @a result value is #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED, error code and error message can be obtained using #service_adaptor_get_last_result() and #service_adaptor_get_last_error_message() method. Error codes and messages are described in Service Plugin. -* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_NONE Successful -* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_NO_DATA There is no files -* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_TIMED_OUT Timed out -* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_PLUGIN_FAILED Failed in Plugin internal -* @remarks The @a result values #SERVICE_ADAPTOR_ERROR_UNKNOWN Unknown error -* @see #service_adaptor_error_e -* @see #service_storage_file_list_h -* @pre #service_storage_get_file_list() will invoke this callback. -*/ -typedef void (*service_storage_file_list_cb)(int result, - service_storage_file_list_h list, - void *user_data); - -/** -* @brief Callback for service_storage_file_list_foreach_file API -* @since_tizen 2.4 -* -* @param[in] file The handle of file -* @param[in] user_data Passed data from #service_storage_file_list_foreach_file() -* @see #service_storage_file_h -* @return @c true to continue with the next iteration of the loop, -* otherwise @c false to break out of the loop -* @pre #service_storage_file_list_foreach_file() will invoke this callback. -*/ -typedef bool (*service_storage_file_cb)(service_storage_file_h file, - void *user_data); - -/** -* @brief Gets file list from storage, asynchronously. -* @since_tizen 2.4 -* @privlevel public -* @privilege %http://tizen.org/privilege/internet -* -* @param[in] plugin The handle for use Plugin APIs -* @param[in] dir_path The dir path (Physical path) -* @param[in] callback The callback for getting file list -* @param[in] user_data The user data to be passed to the callback function -* @remarks For the @a dir_path, "/" means root path. -* @remarks Reference details for "Logical path" and "Physical path" 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 "Logical path" and "Physical path" 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 "Logical path" and "Physical path" 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 "Logical path" and "Physical path" 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 level of thumbnail, the level is defined service plugin SPEC -* @param[out] task The handle of download task -* @remarks If @a thumbnail_size is 0, gets default size thumbnail, the default size must be defined plugin SPEC -* @remarks If @a thumbnail_size is -1, gets minimum size thumbnail be supported plugin -* @remarks If @a thumbnail_size is -2, 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 "Logical path" and "Physical path" 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 "Logical path" and "Physical path" 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 "Logical path" and "Physical path" at @ref SERVICE_ADAPTOR_STORAGE_MODULE_OVERVIEW page -* @see #service_storage_file_h -* @return 0 on success, otherwise a negative error value -* @retval #SERVICE_ADAPTOR_ERROR_NONE Successful -* @retval #SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #SERVICE_ADAPTOR_ERROR_NO_DATA There is no data -*/ -int service_storage_file_get_physical_path(service_storage_file_h file, - char **path); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif /* __cpluscplus */ -#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_CLIENT_STORAGE_H__ */ diff --git a/include/service_adaptor_client_type.h b/include/service_adaptor_client_type.h deleted file mode 100644 index af3ab76..0000000 --- a/include/service_adaptor_client_type.h +++ /dev/null @@ -1,154 +0,0 @@ -/* -* 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 -#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_type.h b/include/service_adaptor_type.h deleted file mode 100644 index 6678740..0000000 --- a/include/service_adaptor_type.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -* 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 - -#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_provider.h b/include/service_provider.h deleted file mode 100644 index 19a6368..0000000 --- a/include/service_provider.h +++ /dev/null @@ -1,267 +0,0 @@ -/* -* 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 - -/** - * @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 additional thread(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); - * - * // 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 - * - * @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. - * - * @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 #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); - -/** - * @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); - -/** - * @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); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif -#endif /* __TIZEN_SOCIAL_SERVICE_ADAPTOR_PROVIDER_H__ */ diff --git a/include/service_provider_types.h b/include/service_provider_types.h deleted file mode 100644 index 4a3ccf3..0000000 --- a/include/service_provider_types.h +++ /dev/null @@ -1,988 +0,0 @@ -/* -* 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 -#include -#include - -#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 struct stat in - * @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 and \b - * - * @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 - * Channel opened : \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 - * - * Channel closed : \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 additional thread(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 access mode \n - * Supporting bellow access mode 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 - * \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 thumbnail size \n - * Supporting bellow thumbnail size 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 additional thread(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 positive value the number of bytes read. - * \li \c negative value 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 additional thread(Not main thread). - * @remarks \a result must be input likes bellow - * \li \c \b 0 zero indicates nothing was written. - * \li \c positive value the number of bytes written. - * \li \c negative value 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 additional thread(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 additional thread(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 additional thread(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 additional thread(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 additional thread(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 additional thread(Not main thread). - * @remarks Supporting bellow access mode 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 - * \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 additional thread(Not main thread). - * @remarks Supporting bellow accessibility flags 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 - * \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 additional thread(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 additional thread(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 additional thread(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 additional thread(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 deleted file mode 100644 index 266299c..0000000 --- a/include/storage_provider.h +++ /dev/null @@ -1,175 +0,0 @@ -/* -* 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 - -/** - * @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 access mode 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 - * \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__ */ diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt.backup similarity index 100% rename from server/CMakeLists.txt rename to server/CMakeLists.txt.backup diff --git a/server/sal.h b/server/sal.h deleted file mode 100644 index 3581e9e..0000000 --- a/server/sal.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Service Adaptor - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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_H__ -#define __TIZEN_CONVERGENCE_SAL_H__ - -#include - -#include "service_adaptor_errors.h" - -#include "auth_adaptor.h" -#include "contact_adaptor.h" -#include "storage_adaptor.h" -#include "resource_adaptor.h" - -typedef struct _sal_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; -} sal_s; -typedef struct _sal_s *sal_h; - -typedef struct _provider_user_data_s -{ - char *uri; - char *name; - char *package; -} provider_user_data_s; -typedef struct _provider_user_data_s *provider_user_data_h; - -sal_h sal_get_handle(); -char *sal_get_root_path(); -service_adaptor_error_e sal_adaptor_connect(const char *uri); -service_adaptor_error_e sal_adaptor_disconnect(const char *uri); -service_adaptor_error_e sal_adaptor_get_plugins(char ***plugins, int *plugins_size); -service_adaptor_error_e sal_provider_connect(const char *uri, const char *name, const char *package); -service_adaptor_error_e sal_provider_disconnect(const char *uri); -char *sal_provider_get_uri(const char *package); - -#endif /* __TIZEN_CONVERGENCE_SAL_H__ */ diff --git a/server/sal_base.c b/server/sal_base.c deleted file mode 100644 index fba3315..0000000 --- a/server/sal_base.c +++ /dev/null @@ -1,72 +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 - -#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 deleted file mode 100644 index a4f7e6b..0000000 --- a/server/sal_base.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Service Adaptor - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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__ */ diff --git a/server/sal_coherence.c b/server/sal_coherence.c deleted file mode 100644 index e69de29..0000000 diff --git a/server/sal_contact.c b/server/sal_contact.c deleted file mode 100644 index 499e54a..0000000 --- a/server/sal_contact.c +++ /dev/null @@ -1,56 +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 - -#include "sal_contact.h" -#include "service_adaptor_internal.h" - -/****************************************************************************** - * Global variables and defines - ******************************************************************************/ - -/****************************************************************************** - * Private interface - ******************************************************************************/ - -/****************************************************************************** - * Private interface definition - ******************************************************************************/ - -/****************************************************************************** - * Public interface definition - ******************************************************************************/ -/* -contact_adaptor_listener_h sal_contact_register_listener(contact_adaptor_h contact) -{ - int ret = SERVICE_ADAPTOR_ERROR_NONE; - - contact_adaptor_listener_h listener = - (contact_adaptor_listener_h) g_malloc0(sizeof(contact_adaptor_listener_s)); - - ret = contact_adaptor_register_listener(contact, listener); - - if (SERVICE_ADAPTOR_ERROR_NONE != ret) { - SAL_FREE(listener); - } - - return listener; -} -*/ diff --git a/server/sal_contact.h b/server/sal_contact.h deleted file mode 100644 index 2a36da0..0000000 --- a/server/sal_contact.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Service Adaptor - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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_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 deleted file mode 100644 index 35a14b0..0000000 --- a/server/sal_engine.c +++ /dev/null @@ -1,326 +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 - -#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 deleted file mode 100644 index 6e23931..0000000 --- a/server/sal_engine.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Service Adaptor - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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 - -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__ */ diff --git a/server/sal_generator.c b/server/sal_generator.c deleted file mode 100644 index e69de29..0000000 diff --git a/server/sal_group.c b/server/sal_group.c deleted file mode 100644 index e69de29..0000000 diff --git a/server/sal_main.c b/server/sal_main.c deleted file mode 100644 index 0f55978..0000000 --- a/server/sal_main.c +++ /dev/null @@ -1,747 +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 -#include -#include -/* -#include - -#include "service_adaptor_internal.h" - -#include "sal.h" -#include "sal_auth.h" -#include "sal_contact.h" -#include "sal_storage.h" -#include "sal_resource.h" -#include "sal_observer.h" -#include "sal_ipc_server.h" -#include "sal_service_provider.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; - - app_control_get_extra_data(app_control, key, &value); - SAL_INFO("PLUGIN Key (%s): %s", key, value); - - g_hash_table_insert((GHashTable *) user_data, (char *) key, value); - - 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; - - RET_IF(APP_CONTROL_RESULT_FAILED == result); - - sal_h sal = sal_get_handle(); - RETM_IF(NULL == sal, "sal_get_handle() Fail"); - - GHashTable *service = g_hash_table_new(g_str_hash, g_str_equal); - app_control_foreach_extra_data(reply, _app_control_extra_data_cb, (void *) service); - - provider_user_data_h provider_user_data = (provider_user_data_h) user_data; - - GHashTableIter iter; - gpointer iter_key, iter_value; - - g_hash_table_iter_init(&iter, service); - while (g_hash_table_iter_next(&iter, &iter_key, &iter_value)) { - if (0 == strcmp(iter_key, PLUGIN_KEY_AUTH)) { - auth_plugin_h plugin = NULL; - auth_adaptor_create_plugin(provider_user_data->uri, provider_user_data->name, provider_user_data->package, &plugin); - auth_adaptor_register_plugin_service(plugin, service); - auth_adaptor_add_plugin(sal->auth, plugin); - } else if (0 == strcmp(iter_key, PLUGIN_KEY_STORAGE)) { - storage_plugin_h plugin = NULL; - storage_adaptor_create_plugin(provider_user_data->uri, provider_user_data->name, provider_user_data->package, &plugin); - storage_adaptor_register_plugin_service(plugin, service); - storage_adaptor_add_plugin(sal->storage, plugin); - } - } - - g_hash_table_destroy(service); - - 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; - - RET_IF(APP_CONTROL_RESULT_FAILED == result); - - sal_h sal = sal_get_handle(); - RETM_IF(NULL == sal, "sal_get_handle() Fail"); - - char *uri = (char *) user_data; - - auth_plugin_h plugin = auth_adaptor_get_plugin(sal->auth, uri); - auth_adaptor_remove_plugin(sal->auth, plugin); - auth_adaptor_unregister_plugin_service(plugin); - auth_adaptor_destroy_plugin(plugin); - - // 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; - - int ret = 0; - RETV_IF(NULL == sal, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - return ret; -} -*/ -/** - * @brief destroy spec file - * - * @return void. - */ -/* -static service_adaptor_error_e _sal_destroy_spec_file(sal_h sal) -{ - SAL_FN_CALL; - - int ret = 0; - RETV_IF(NULL == sal, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - return ret; -} -*/ -/** - * @brief start service adaptor - * - * @return void. - */ -/* -static service_adaptor_error_e _sal_start(sal_h sal) -{ - SAL_FN_CALL; - - int ret = 0; - RETV_IF(NULL == sal, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - ret = auth_adaptor_start(sal->auth); - RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_INTERNAL, "auth_adaptor_start() Fail(%d)", ret); - - ret = contact_adaptor_start(sal->contact); - RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_INTERNAL, "contact_adaptor_start() Fail(%d)", ret); - - ret = storage_adaptor_start(sal->storage); - RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_INTERNAL, "storage_adaptor_start() Fail(%d)", ret); - - ret = resource_adaptor_start(sal->resource); - RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_INTERNAL, "resource_adaptor_start() Fail(%d)", ret); - - ret = sal_observer_register_existed_plugin(); - RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "sal_observer_register_existed_plugin() Fail(%d)", ret); - - g_mutex_lock(&sal->mutex); - sal->start = sal->start + 1; - g_cond_signal(&sal->cond); - g_mutex_unlock(&sal->mutex); - - return ret; -} -*/ -/** - * @brief stop service adaptor - * - * @return void. - */ -/* -static service_adaptor_error_e _sal_stop(sal_h sal) -{ - SAL_FN_CALL; - - int ret = 0; - RETV_IF(NULL == sal, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETVM_IF(0 == sal->start, SERVICE_ADAPTOR_ERROR_INTERNAL, "could not start service adaptor"); - - ret += auth_adaptor_stop(sal->auth); - ret += contact_adaptor_stop(sal->contact); - ret += storage_adaptor_stop(sal->storage); - ret += resource_adaptor_stop(sal->resource); - RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_INTERNAL, "could not stop service adaptor(%d)", ret); - - sal->start = 0; - - 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 - auth_adaptor_h auth = auth_adaptor_create(); - TRYM_IF(NULL == auth, "sal_auth_create_handle() Fail"); - - // 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 - storage_adaptor_h storage = storage_adaptor_create(); - TRYM_IF(NULL == storage, "sal_storage_create_handle() Fail"); - - // 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 - 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 - 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 - 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 - 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 - sal = (sal_h) g_malloc0(sizeof(sal_s)); - TRYM_IF(NULL == sal, "could not create service adaptor"); - - sal->auth = auth; - sal->contact = contact; - sal->storage = storage; - sal->resource = resource; - - g_mutex_init(&sal->mutex); - g_cond_init(&sal->cond); - -catch: - // 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 - if (NULL != sal->svc_list) { - g_list_free(sal->svc_list); - sal->svc_list = NULL; - } - - // 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 oiit service adaptor - * - * @return void. - */ -static sal_error_e __sal_init() -{ - SAL_FN_CALL; - 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; -} - -/** - * @brief deinit service adaptor - * - * @param[in] service_adaptor specifies handle of service adaptor - * @return void. - */ -static void __sal_deinit() -{ - SAL_FN_CALL; - - //RET_IF(NULL == sal); - - int ret = __thread_engine_deinit(); - -/* - sal_ipc_server_deinit(); - - _sal_destroy_spec_file(sal); - - if (0 < sal->start) { - _sal_stop(sal); - } - - _sal_destroy(sal); -*/ - SAL_FN_END; -} - -/** - * @brief main signal function - * - * @param[in] data specifies user data passed by main function - * @return void. - */ -static gint _sigterm_callback(void *data) -{ - sal_engine_main_quit(); - - return 0; -} - -/** - * @brief main function - * - * @param[in] argc specifies count of arguments - * @param[in] argv specifies value list of arguments - * @return void. - */ -int main(int argc, char *argv[]) -{ - int ret = SAL_ERROR_NONE; - GMainLoop *loop = NULL; - -#if !GLIB_CHECK_VERSION(2, 32, 0) - g_thread_init(NULL); -#endif -#if !GLIB_CHECK_VERSION(2, 35, 0) - g_type_init(); -#endif - - 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); - - /* installing signal handlers */ - g_unix_signal_add_full(G_PRIORITY_HIGH, SIGINT, - _sigterm_callback, loop, NULL); - g_unix_signal_add_full(G_PRIORITY_HIGH, SIGTERM, - _sigterm_callback, loop, NULL); - - /* start application's main loop */ - sal_engine_main_run(); - -// sal_h sal = sal_get_handle(); - __sal_deinit(); - - return 0; -} - -/****************************************************************************** - * Public interface definition - ******************************************************************************/ -/* -API sal_h sal_get_handle() -{ - SAL_FN_CALL; - - return g_service_adaptor; -} - -API char *sal_get_root_path() -{ - SAL_FN_CALL; - - char *root_path = NULL; - char tnfs_root_path[FILE_PATH_LEN] = {0,}; - - // 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); - - return root_path; -} - -API service_adaptor_error_e sal_adaptor_connect(const char *uri) -{ - SAL_FN_CALL; - - RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - SAL_INFO("uri: %s", uri); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e sal_adaptor_disconnect(const char *uri) -{ - SAL_FN_CALL; - - RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - SAL_INFO("uri: %s", uri); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e sal_adaptor_get_plugins(char ***plugins, int *plugins_size) -{ - SAL_FN_CALL; - - RETV_IF(NULL == g_service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == g_service_adaptor->auth, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - int size = g_list_length(g_service_adaptor->auth->plugins); - RETV_IF(0 == size, SERVICE_ADAPTOR_ERROR_NO_DATA); - - int i = 0; - char **uri = (char **) g_malloc0(sizeof(char *) * size); - - for (GList *list = g_list_first(g_service_adaptor->auth->plugins); list != NULL; list = list->next) { - auth_plugin_h this = (auth_plugin_h) list->data; - - uri[i] = strdup(this->uri); - } - - *plugins = uri; - *plugins_size = size; - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e sal_provider_connect(const char *uri, const char *name, const char *package) -{ - SAL_FN_CALL; - - RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - app_control_h request; - app_control_create(&request); - - app_control_set_app_id(request, uri); - app_control_set_operation(request, PLUGIN_CONNECT_URI); - - provider_user_data_h provider_user_data = (provider_user_data_h) g_malloc0(sizeof(provider_user_data_s)); - provider_user_data->uri = strdup(uri); - provider_user_data->name = strdup(name); - provider_user_data->package = strdup(package); - - int ret = app_control_send_launch_request(request, _provider_connect_cb, provider_user_data); - - RETVM_IF(APP_CONTROL_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_SYSTEM, "app_control_send_launch_request() Fail(%d)", ret); - - app_control_destroy(request); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API service_adaptor_error_e sal_provider_disconnect(const char *uri) -{ - SAL_FN_CALL; - - RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER); - - app_control_h request; - app_control_create(&request); - - app_control_set_app_id(request, uri); - app_control_set_operation(request, PLUGIN_DISCONNECT_URI); - - int ret = app_control_send_launch_request(request, _provider_disconnect_cb, (void *) uri); - - RETVM_IF(APP_CONTROL_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_SYSTEM, "app_control_send_launch_request() Fail(%d)", ret); - - app_control_destroy(request); - - return SERVICE_ADAPTOR_ERROR_NONE; -} - -API char *sal_provider_get_uri(const char *package) -{ - SAL_FN_CALL; - - RETV_IF(NULL == package, NULL); - - sal_h sal = sal_get_handle(); - RETVM_IF(NULL == sal, NULL, "sal_get_handle() Fail"); - - char *uri = auth_adaptor_get_uri(sal->auth, package); - - return uri; -} -*/ diff --git a/server/sal_observer.c b/server/sal_observer.c deleted file mode 100644 index 9a0f712..0000000 --- a/server/sal_observer.c +++ /dev/null @@ -1,215 +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 -#include -#include -/* -#include -#include -#include -#include - -#include "service_adaptor_internal.h" - -#include "sal.h" -#include "sal_observer.h" -#include "auth_adaptor.h" -*/ -/****************************************************************************** - * Global variables and defines - ******************************************************************************/ -#define SAL_PLUGIN_METADATA_KEY_ADAPTOR "service-adaptor" - -/****************************************************************************** - * Private interface - ******************************************************************************/ - -/****************************************************************************** - * Private interface definition - ******************************************************************************/ - -/** - * @brief callback of app info - * - * @return void. - */ -/* -static bool _sal_app_meta_cb(const char *key, const char *value, void *user_data) -{ - SAL_FN_CALL; - - provider_user_data_h provider_user_data = (provider_user_data_h) user_data; - - if ((NULL != key) && (NULL != value)) { - if (0 == strncmp(SAL_PLUGIN_METADATA_KEY_ADAPTOR, key, strlen(SAL_PLUGIN_METADATA_KEY_ADAPTOR))) { - SAL_INFO("%s: %s", provider_user_data->uri, value); - int ret = sal_provider_connect(provider_user_data->uri, value, provider_user_data->package); - - RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, false, "sal_plugin_connect() Fail(%d)", ret); - } - } - - 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; - - app_info_h app_info = NULL; - int ret = PACKAGE_MANAGER_ERROR_NONE; - char *package = (char *) user_data; - - provider_user_data_h provider_user_data = (provider_user_data_h) g_malloc0(sizeof(provider_user_data_s)); - provider_user_data->uri = strdup(app_id); - provider_user_data->package = strdup(package); - - app_info_create(app_id, &app_info); - ret = app_info_foreach_metadata(app_info, _sal_app_meta_cb, provider_user_data); - RETVM_IF(PACKAGE_MANAGER_ERROR_NONE != ret, false, "app_info_foreach_metadata() Fail(%d)", ret); - - app_info_destroy(app_info); - - 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, - package_manager_event_state_e event_state, - int progress, - package_manager_error_e error, - void *user_data) -{ - SAL_FN_CALL; - - if ((PACKAGE_MANAGER_EVENT_TYPE_INSTALL == event_type) && (PACKAGE_MANAGER_EVENT_STATE_COMPLETED == event_state)) { - int ret = PACKAGE_MANAGER_ERROR_NONE; - package_info_h p_info = NULL; - - ret = package_manager_get_package_info(package, &p_info); - RETM_IF(PACKAGE_MANAGER_ERROR_NONE != ret, "package_manager_get_package_info() Fail(%d)", ret); - - ret = package_info_foreach_app_from_package(p_info, PACKAGE_INFO_ALLAPP, _sal_app_info_cb, (void *) package); - RETM_IF(PACKAGE_MANAGER_ERROR_NONE != ret, "package_info_foreach_app_from_package() Fail(%d)", ret); - - ret = package_info_destroy(p_info); - RETM_IF(PACKAGE_MANAGER_ERROR_NONE != ret, "package_info_destroy() Fail(%d)", ret); - } else if ((PACKAGE_MANAGER_EVENT_TYPE_UNINSTALL == event_type) && (PACKAGE_MANAGER_EVENT_STATE_COMPLETED == event_state)) { - sal_h sal = sal_get_handle(); - RETM_IF(NULL == sal, "sal_get_handle() Fail"); - - char *uri = sal_provider_get_uri(package); - - auth_plugin_h auth_plugin = auth_adaptor_get_plugin(sal->auth, uri); - auth_adaptor_remove_plugin(sal->auth, auth_plugin); - auth_adaptor_unregister_plugin_service(auth_plugin); - auth_adaptor_destroy_plugin(auth_plugin); - - storage_plugin_h storage_plugin = storage_adaptor_get_plugin(sal->storage, uri); - storage_adaptor_remove_plugin(sal->storage, storage_plugin); - storage_adaptor_unregister_plugin_service(storage_plugin); - storage_adaptor_destroy_plugin(storage_plugin); - - // 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; - - int ret = PACKAGE_MANAGER_ERROR_NONE; - - char *package = NULL; - ret = package_info_get_package(package_info, &package); - RETVM_IF(PACKAGE_MANAGER_ERROR_NONE != ret, false, "package_info_get_package() Fail(%d)", ret); - - ret = package_info_foreach_app_from_package(package_info, PACKAGE_INFO_ALLAPP, _sal_app_info_cb, package); - RETVM_IF(PACKAGE_MANAGER_ERROR_NONE != ret, false, "package_info_foreach_app_from_package() Fail(%d)", ret); - - return true; -} -*/ - -/****************************************************************************** - * Public interface definition - ******************************************************************************/ - -/** - * @brief start observer using package manager - * - * @return void. - */ -/* -service_adaptor_error_e sal_observer_start() -{ - SAL_FN_CALL; - - int ret = 0; - package_manager_h package = NULL; - - package_manager_create(&package); - - ret = package_manager_set_event_cb(package, _sal_package_event_cb, NULL); - RETVM_IF(PACKAGE_MANAGER_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_SYSTEM, "package_manager_set_event_cb() Fail(%d)", ret); - - 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; - - int ret = PACKAGE_MANAGER_ERROR_NONE; - - ret = package_manager_foreach_package_info(_sal_package_info_cb, NULL); - RETVM_IF(PACKAGE_MANAGER_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_SYSTEM, "package_manager_foreach_package_info() Fail(%d)", ret); - - return SERVICE_ADAPTOR_ERROR_NONE; -} -*/ diff --git a/server/sal_observer.h b/server/sal_observer.h deleted file mode 100644 index ad11160..0000000 --- a/server/sal_observer.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Service Adaptor - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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_OBSERVER_H__ -#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__ */ diff --git a/server/sal_resource.c b/server/sal_resource.c deleted file mode 100644 index f1bc74c..0000000 --- a/server/sal_resource.c +++ /dev/null @@ -1,56 +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 - -#include "sal_resource.h" -#include "service_adaptor_internal.h" - -/****************************************************************************** - * Global variables and defines - ******************************************************************************/ - -/****************************************************************************** - * Private interface - ******************************************************************************/ - -/****************************************************************************** - * Private interface definition - ******************************************************************************/ - -/****************************************************************************** - * Public interface definition - ******************************************************************************/ -/* -resource_adaptor_listener_h sal_resource_register_listener(resource_adaptor_h resource) -{ - int ret = SERVICE_ADAPTOR_ERROR_NONE; - - resource_adaptor_listener_h listener = - (resource_adaptor_listener_h) g_malloc0(sizeof(resource_adaptor_listener_s)); - - ret = resource_adaptor_register_listener(resource, listener); - - if (SERVICE_ADAPTOR_ERROR_NONE != ret) { - SAL_FREE(listener); - } - - return listener; -} -*/ diff --git a/server/sal_resource.h b/server/sal_resource.h deleted file mode 100644 index ef90567..0000000 --- a/server/sal_resource.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Service Adaptor - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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_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__ */ diff --git a/server/sal_storage.c b/server/sal_storage.c deleted file mode 100644 index 4b4d133..0000000 --- a/server/sal_storage.c +++ /dev/null @@ -1,56 +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 - -#include "sal_storage.h" -#include "service_adaptor_internal.h" - -/****************************************************************************** - * Global variables and defines - ******************************************************************************/ - -/****************************************************************************** - * Private interface - ******************************************************************************/ - -/****************************************************************************** - * Private interface definition - ******************************************************************************/ - -/****************************************************************************** - * Public interface definition - ******************************************************************************/ -/* -storage_adaptor_listener_h sal_storage_register_listener(storage_adaptor_h storage) -{ - int ret = SERVICE_ADAPTOR_ERROR_NONE; - - storage_adaptor_listener_h listener = - (storage_adaptor_listener_h) g_malloc0(sizeof(storage_adaptor_listener_s)); - - ret = storage_adaptor_register_listener(storage, listener); - - if (SERVICE_ADAPTOR_ERROR_NONE != ret) { - SAL_FREE(listener); - } - - return listener; -} -*/ diff --git a/server/sal_storage.h b/server/sal_storage.h deleted file mode 100644 index 7b12f50..0000000 --- a/server/sal_storage.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Service Adaptor - * - * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Yongjin Kim - * Jinhyeong Ahn - * Jiwon Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT 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_STORAGE_H__ -#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__ */ -- 2.7.4