#include "auth_adaptor.h"
#include "service_adaptor_internal.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
static void _auth_adaptor_free_plugin(auth_plugin_h plugin)
{
}
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
API auth_adaptor_h auth_adaptor_create()
{
g_mutex_lock(&auth->mutex);
- if (0 != auth->start)
- {
+ if (0 != auth->start) {
auth_adaptor_stop(auth);
}
RETV_IF(NULL == auth, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- // TODO: notify auth adaptor stop to each plugin
+ /* TODO: notify auth adaptor stop to each plugin */
g_mutex_lock(&auth->mutex);
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
+ /* TODO: register insert/ update/ delete callback for service-adaptor */
return SERVICE_ADAPTOR_ERROR_NONE;
}
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
+ /* TODO: unregister insert/ update/ delete callback for service-adaptor */
return 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)
- {
+ 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)
- {
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
SAL_INFO("could not find the function for oauth 2.0");
SAL_FREE(plugin->oauth2);
}
RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- if (NULL != plugin->oauth1)
- {
+ if (NULL != plugin->oauth1) {
oauth1_unregister_service(plugin->oauth1);
SAL_FREE(plugin->oauth1);
}
- if (NULL != plugin->oauth2)
- {
+ if (NULL != plugin->oauth2) {
oauth2_unregister_service(plugin->oauth2);
SAL_FREE(plugin->oauth2);
}
auth_plugin_h plugin = NULL;
- for (GList *list = g_list_first(auth->plugins); list != NULL; list = list->next)
- {
+ 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))
- {
+ if (0 == strcmp(this->uri, uri)) {
plugin = this;
break;
}
char *uri = NULL;
- for (GList *list = g_list_first(auth->plugins); list != NULL; list = list->next)
- {
+ 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))
- {
+ if (0 == strcmp(this->package, package)) {
uri = this->uri;
break;
}
int ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
- for (GList *list = g_list_first(auth->plugins); list != NULL; list = list->next)
- {
+ 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))
- {
+ if (0 == strcmp(this->uri, uri)) {
ret = SERVICE_ADAPTOR_ERROR_NONE;
- // TODO: increase ref count
+ /* TODO: increase ref count */
break;
}
}
int ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
- for (GList *list = g_list_first(auth->plugins); list != NULL; list = list->next)
- {
+ 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))
- {
+ if (0 == strcmp(this->uri, uri)) {
ret = SERVICE_ADAPTOR_ERROR_NONE;
- // TODO: decrease ref count
+ /* TODO: decrease ref count */
break;
}
}
#include "sal_service_provider.h"
#include "sal_auth_provider.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-typedef struct _app_control_user_data_s
-{
+typedef struct _app_control_user_data_s {
void *callback;
void *user_data;
} app_control_user_data_s;
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
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
/**
* @brief callback of service plugin
RET_IF(NULL == callback);
- // TODO: move this function for chaning result enum to general
+ /* 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))
- {
+ if (0 == strcmp(PLUGIN_RESULT_VALUE_FAILURE, ret_str)) {
ret = SERVICE_ADAPTOR_ERROR_INTERNAL;
}
int res = app_control_send_launch_request(request, _oauth1_get_access_token_cb, app_control_user_data);
- if (APP_CONTROL_ERROR_NONE != res)
- {
+ if (APP_CONTROL_ERROR_NONE != res) {
return SERVICE_ADAPTOR_ERROR_SYSTEM;
}
return SERVICE_ADAPTOR_ERROR_NONE;
}
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
API int oauth1_register_service(oauth1_service_h oauth1, GHashTable *service)
{
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))
- {
+ 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))
- {
+ } 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;
}
#include "sal_auth_provider.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-typedef struct _app_control_user_data_s
-{
+typedef struct _app_control_user_data_s {
void *callback;
void *user_data;
} app_control_user_data_s;
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
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
static int _oauth2_get_access_token(auth_plugin_h plugin, char **access_token, void *user_data)
{
return SERVICE_ADAPTOR_ERROR_NONE;
}
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
API int oauth2_register_service(oauth2_service_h oauth2, GHashTable *service)
{
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))
- {
+ 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))
- {
+ } 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;
}
#include "sal_service_provider.h"
#include "sal_storage_provider.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-typedef struct _app_control_user_data_s
-{
+typedef struct _app_control_user_data_s {
cloud_file_h file;
void *callback;
typedef int (*_remove_file)(void *plugin, const char *cloud_path, cloud_file_cb callback, void *user_data);
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
int _make_cloud_file_by_local(const char *local_path, cloud_file_h *file)
{
cloud_file->cloud_path = NULL;
cloud_file->size = file_info.st_size;
- if(S_ISDIR(file_info.st_mode))
- {
+ if (S_ISDIR(file_info.st_mode)) {
cloud_file->is_dir = true;
}
RET_IF(NULL == callback);
- // TODO: move this function for chaning result enum to general
+ /* 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))
- {
+ if (0 == strcmp(PLUGIN_RESULT_VALUE_FAILURE, ret_str)) {
ret = SERVICE_ADAPTOR_ERROR_INTERNAL;
}
int res = app_control_send_launch_request(request, _cloud_remove_file_cb, app_control_user_data);
- if (APP_CONTROL_ERROR_NONE != res)
- {
+ if (APP_CONTROL_ERROR_NONE != res) {
return SERVICE_ADAPTOR_ERROR_SYSTEM;
}
return SERVICE_ADAPTOR_ERROR_NONE;
}
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
API int cloud_register_service(cloud_service_h cloud, GHashTable *service)
{
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))
- {
+ 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;
}
#include "storage_adaptor.h"
#include "service_adaptor_internal.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
static void _storage_adaptor_free_plugin(storage_plugin_h plugin)
{
}
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * 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));
+ storage_adaptor_h storage = (storage_adaptor_h) g_malloc0(sizeof(storage_adaptor_s));
- g_mutex_init(&storage->mutex);
+ g_mutex_init(&storage->mutex);
return storage;
}
{
SAL_FN_CALL;
- RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- g_mutex_lock(&storage->mutex);
+ g_mutex_lock(&storage->mutex);
- if (0 != storage->start)
- {
- storage_adaptor_stop(storage);
- }
+ if (0 != storage->start) {
+ storage_adaptor_stop(storage);
+ }
- SAL_FREE(storage);
+ SAL_FREE(storage);
- g_mutex_unlock(&storage->mutex);
+ g_mutex_unlock(&storage->mutex);
return SERVICE_ADAPTOR_ERROR_NONE;
}
{
SAL_FN_CALL;
- RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- g_mutex_lock(&storage->mutex);
+ g_mutex_lock(&storage->mutex);
- storage->start = 1;
+ storage->start = 1;
- g_mutex_unlock(&storage->mutex);
+ g_mutex_unlock(&storage->mutex);
return SERVICE_ADAPTOR_ERROR_NONE;
}
{
SAL_FN_CALL;
- RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- // TODO: notify storage adaptor stop to each plugin
+ /* TODO: notify storage adaptor stop to each plugin */
- g_mutex_lock(&storage->mutex);
+ g_mutex_lock(&storage->mutex);
- storage->start = 0;
+ storage->start = 0;
- g_mutex_unlock(&storage->mutex);
+ g_mutex_unlock(&storage->mutex);
return SERVICE_ADAPTOR_ERROR_NONE;
}
{
SAL_FN_CALL;
- RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == listener, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+ 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
+ /* TODO: register insert/ update/ delete callback for service-adaptor */
return SERVICE_ADAPTOR_ERROR_NONE;
}
{
SAL_FN_CALL;
- RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == listener, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+ 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
+ /* 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;
+ 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);
+ 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);
+ 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);
+ g_mutex_init(&storage_plugin->mutex);
+ g_cond_init(&storage_plugin->cond);
- *plugin = storage_plugin;
+ *plugin = storage_plugin;
- return SERVICE_ADAPTOR_ERROR_NONE;
+ return SERVICE_ADAPTOR_ERROR_NONE;
}
API service_adaptor_error_e storage_adaptor_destroy_plugin(storage_plugin_h plugin)
{
- SAL_FN_CALL;
+ SAL_FN_CALL;
- RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- SAL_FREE(plugin->uri);
- SAL_FREE(plugin->name);
- SAL_FREE(plugin);
+ SAL_FREE(plugin->uri);
+ SAL_FREE(plugin->name);
+ SAL_FREE(plugin);
- return SERVICE_ADAPTOR_ERROR_NONE;
+ return SERVICE_ADAPTOR_ERROR_NONE;
}
API service_adaptor_error_e storage_adaptor_register_plugin_service(storage_plugin_h plugin, GHashTable *service)
{
- SAL_FN_CALL;
+ SAL_FN_CALL;
- RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == service, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == service, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- int ret = SERVICE_ADAPTOR_ERROR_NONE;
+ int ret = SERVICE_ADAPTOR_ERROR_NONE;
- plugin->cloud = (cloud_service_h) g_malloc0(sizeof(cloud_service_s));
- ret = cloud_register_service(plugin->cloud, service);
+ 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);
- }
+ 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;
+ 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);
+ SAL_FN_CALL;
- 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;
+ 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;
+ SAL_FN_CALL;
- RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- g_mutex_lock(&storage->mutex);
+ g_mutex_lock(&storage->mutex);
- storage->plugins = g_list_append(storage->plugins, plugin);
+ storage->plugins = g_list_append(storage->plugins, plugin);
- g_mutex_unlock(&storage->mutex);
+ g_mutex_unlock(&storage->mutex);
- return SERVICE_ADAPTOR_ERROR_NONE;
+ 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;
+ SAL_FN_CALL;
- RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- g_mutex_lock(&storage->mutex);
+ g_mutex_lock(&storage->mutex);
- RETV_IF(NULL == g_list_find(storage->plugins, plugin), SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == g_list_find(storage->plugins, plugin), SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- storage->plugins = g_list_remove(storage->plugins, plugin);
+ storage->plugins = g_list_remove(storage->plugins, plugin);
- _storage_adaptor_free_plugin(plugin);
+ _storage_adaptor_free_plugin(plugin);
- g_mutex_unlock(&storage->mutex);
+ g_mutex_unlock(&storage->mutex);
- return SERVICE_ADAPTOR_ERROR_NONE;
+ return SERVICE_ADAPTOR_ERROR_NONE;
}
API storage_plugin_h storage_adaptor_get_plugin(storage_adaptor_h storage, const char *uri)
{
- SAL_FN_CALL;
+ SAL_FN_CALL;
- RETV_IF(NULL == storage, NULL);
- RETV_IF(NULL == uri, NULL);
+ RETV_IF(NULL == storage, NULL);
+ RETV_IF(NULL == uri, NULL);
- g_mutex_lock(&storage->mutex);
+ g_mutex_lock(&storage->mutex);
- storage_plugin_h plugin = NULL;
+ 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;
+ 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;
- }
- }
+ if (0 == strcmp(this->uri, uri)) {
+ plugin = this;
+ break;
+ }
+ }
- g_mutex_unlock(&storage->mutex);
+ g_mutex_unlock(&storage->mutex);
- return plugin;
+ return plugin;
}
API char *storage_adaptor_get_uri(storage_adaptor_h storage, const char *package)
{
- SAL_FN_CALL;
+ SAL_FN_CALL;
- RETV_IF(NULL == storage, NULL);
- RETV_IF(NULL == package, NULL);
+ RETV_IF(NULL == storage, NULL);
+ RETV_IF(NULL == package, NULL);
- g_mutex_lock(&storage->mutex);
+ g_mutex_lock(&storage->mutex);
- char *uri = NULL;
+ 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;
+ 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;
- }
- }
+ if (0 == strcmp(this->package, package)) {
+ uri = this->uri;
+ break;
+ }
+ }
- g_mutex_unlock(&storage->mutex);
+ g_mutex_unlock(&storage->mutex);
- return uri;
+ return uri;
}
API service_adaptor_error_e storage_adaptor_ref_plugin(storage_adaptor_h storage, const char *uri)
{
- SAL_FN_CALL;
+ SAL_FN_CALL;
- RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- g_mutex_lock(&storage->mutex);
+ g_mutex_lock(&storage->mutex);
- int ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
+ 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;
+ 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;
- }
- }
+ if (0 == strcmp(this->uri, uri)) {
+ ret = SERVICE_ADAPTOR_ERROR_NONE;
+ /* TODO: increase ref count */
+ break;
+ }
+ }
- g_mutex_unlock(&storage->mutex);
+ g_mutex_unlock(&storage->mutex);
- return ret;
+ return ret;
}
API service_adaptor_error_e storage_adaptor_unref_plugin(storage_adaptor_h storage, const char *uri)
{
- SAL_FN_CALL;
+ SAL_FN_CALL;
- RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == storage, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
+ RETV_IF(NULL == uri, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- g_mutex_lock(&storage->mutex);
+ g_mutex_lock(&storage->mutex);
- int ret = SERVICE_ADAPTOR_ERROR_NO_DATA;
+ 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;
+ 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;
- }
- }
+ if (0 == strcmp(this->uri, uri)) {
+ ret = SERVICE_ADAPTOR_ERROR_NONE;
+ /* TODO: decrease ref count */
+ break;
+ }
+ }
- g_mutex_unlock(&storage->mutex);
+ g_mutex_unlock(&storage->mutex);
- return ret;
+ return ret;
}
int ret = SERVICE_ADAPTOR_ERROR_NONE;
- if (0 == strcmp(operation, OAUTH1_0_GET_ACCESS_TOKEN_URI))
- {
+ if (0 == strcmp(operation, OAUTH1_0_GET_ACCESS_TOKEN_URI)) {
app_control_create(&reply);
char *access_token = NULL;
ret = provider->oauth1_get_access_token(&access_token);
- if (SERVICE_ADAPTOR_ERROR_NONE != ret)
- {
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
SAL_ERR("oauth1_get_access_token() Fail (%d)", ret);
app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_FAILURE);
return reply;
app_control_add_extra_data(reply, PLUGIN_KEY_AUTH, PLUGIN_VALUE_TRUE);
- if (NULL != provider->oauth1_get_access_token)
- {
+ if (NULL != provider->oauth1_get_access_token) {
app_control_add_extra_data(reply, OAUTH1_0_GET_ACCESS_TOKEN_URI, PLUGIN_VALUE_TRUE);
}
- if (NULL != provider->oauth1_get_extra_data)
- {
+ if (NULL != provider->oauth1_get_extra_data) {
app_control_add_extra_data(reply, OAUTH1_0_GET_EXTRA_DATA_URI, PLUGIN_VALUE_TRUE);
}
- if (NULL != provider->oauth2_get_access_token)
- {
+ if (NULL != provider->oauth2_get_access_token) {
app_control_add_extra_data(reply, OAUTH2_0_GET_ACCESS_TOKEN_URI, PLUGIN_VALUE_TRUE);
}
- if (NULL != provider->oauth2_get_extra_data)
- {
+ if (NULL != provider->oauth2_get_extra_data) {
app_control_add_extra_data(reply, OAUTH2_0_GET_EXTRA_DATA_URI, PLUGIN_VALUE_TRUE);
}
#include "sal_ipc_client_core.h"
#include "sal_ipc_client_auth.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************
/**
* @brief Describes infromation about Adaptor Handle
*/
-typedef struct _service_adaptor_s
-{
+typedef struct _service_adaptor_s {
char *uri;
GList *plugins; /* char **plugins (uri) */
GList *started_plugins; /* service_plugin_h **started_plugins */
} service_adaptor_s;
-//typedef struct _service_adaptor_s *service_adaptor_h;
+/* typedef struct _service_adaptor_s *service_adaptor_h; */
/**
* @brief Describes infromation about Plugin Handle
*/
-typedef struct _service_plugin_s
-{
+typedef struct _service_plugin_s {
char *uri;
GHashTable *property;
} service_plugin_s;
service_adaptor_h service_adaptor = NULL;
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
API int service_adaptor_create(service_adaptor_h *service_adaptor)
{
app_get_id(&uri);
- if (NULL == uri)
- {
+ if (NULL == uri) {
char path[1024] = {0,};
int path_len = 0;
ret = sal_ipc_client_deinit();
RETV_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_INTERNAL);
- // TODO: free memory in adaptor
+ /* TODO: free memory in adaptor */
SAL_FREE(service_adaptor);
return SERVICE_ADAPTOR_ERROR_NONE;
RETV_IF(0 == g_list_length(service_adaptor->plugins), SERVICE_ADAPTOR_ERROR_NO_DATA);
- for (GList *list = g_list_first(service_adaptor->plugins); list != NULL; list = list->next)
- {
+ for (GList *list = g_list_first(service_adaptor->plugins); list != NULL; list = list->next) {
char * uri = (char *) list->data;
bool ret = callback(uri, 0, user_data);
int ret = ipc_service_plugin_destroy(plugin->uri);
RETV_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- // TODO: free memeory of plugin
+ /* TODO: free memeory of plugin */
SAL_FREE(plugin);
return SERVICE_ADAPTOR_ERROR_NONE;
RETV_IF(NULL == key, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == value, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- if (0 < g_hash_table_size(plugin->property))
- {
+ if (0 < g_hash_table_size(plugin->property)) {
GHashTableIter iter;
gpointer iter_key, iter_value;
g_hash_table_iter_init(&iter, plugin->property);
- while (g_hash_table_iter_next(&iter, &iter_key, &iter_value))
- {
- if (strcmp(key, (char *) iter_key) == 0)
- {
+ while (g_hash_table_iter_next(&iter, &iter_key, &iter_value)) {
+ if (strcmp(key, (char *) iter_key) == 0) {
*value = g_strdup(iter_value);
return SERVICE_ADAPTOR_ERROR_NONE;
}
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)
+ /* TODO: login this plugin via service adaptor (dbus) */
callback(SERVICE_ADAPTOR_ERROR_NONE, user_data);
RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- // TODO: check this plugin via service adaptor (dbus), use or not use?, must be logined.
+ /* TODO: check this plugin via service adaptor (dbus), use or not use?, must be logined. */
service_adaptor->started_plugins = g_list_append(service_adaptor->started_plugins, plugin);
RETV_IF(NULL == service_adaptor, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == plugin, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- // TODO: notify to stop this plugin to service adaptor (dbus)
+ /* TODO: notify to stop this plugin to service adaptor (dbus) */
- for (GList *list = g_list_first(service_adaptor->started_plugins); list != NULL; list = list->next)
- {
+ for (GList *list = g_list_first(service_adaptor->started_plugins); list != NULL; list = list->next) {
service_plugin_h service_plugin = (service_plugin_h) list->data;
- if (0 == strcmp(service_plugin->uri, plugin->uri))
- {
+ if (0 == strcmp(service_plugin->uri, plugin->uri)) {
service_adaptor->started_plugins = g_list_remove(service_adaptor->started_plugins, list);
return SERVICE_ADAPTOR_ERROR_NONE;
#include "sal_service_auth_internal.h"
#include "sal_ipc_client_auth.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
int service_auth_oauth1_start(service_auth_oauth1_h oauth1)
{
return SERVICE_ADAPTOR_ERROR_NONE;
}
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
API int service_auth_oauth1_create(service_plugin_h plugin, service_auth_oauth1_h *oauth1)
{
{
SAL_FN_CALL;
- // TODO: free internal value of provider
+ /* TODO: free internal value of provider */
SAL_FREE(provider);
return SERVICE_ADAPTOR_ERROR_NONE;
app_control_h reply = NULL;
- if (0 == strcmp(operation, PLUGIN_CONNECT_URI))
- {
+ if (0 == strcmp(operation, PLUGIN_CONNECT_URI)) {
app_control_create(&reply);
ret = provider->connect();
- if (SERVICE_ADAPTOR_ERROR_NONE != ret)
- {
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
SAL_ERR("connect() Fail (%d)", ret);
app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_FAILURE);
goto catch;
auth_provider_add_extra_data(provider->auth_provider, reply);
storage_provider_add_extra_data(provider->storage_provider, reply);
- // TODO: another adaptor
- }
- else if (0 == strcmp(operation, PLUGIN_DISCONNECT_URI))
- {
+ /* TODO: another adaptor */
+ } else if (0 == strcmp(operation, PLUGIN_DISCONNECT_URI)) {
app_control_create(&reply);
ret = provider->disconnect();
- if (SERVICE_ADAPTOR_ERROR_NONE != ret)
- {
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
SAL_ERR("connect() Fail (%d)", ret);
app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_FAILURE);
goto catch;
}
app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_SUCCESS);
- }
- else
- {
+ } else {
reply = auth_provider_message(provider->auth_provider, operation, app_control);
TRY_IF(NULL != reply, "auth_plugin_client_message() Finded");
#include "sal_service_storage_internal.h"
#include "sal_ipc_client_storage.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
int service_storage_cloud_start(service_storage_cloud_file_h file)
{
return SERVICE_ADAPTOR_ERROR_NONE;
}
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
API int service_storage_cloud_file_create(service_plugin_h plugin, service_storage_cloud_file_h *file)
{
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)
- {
+ /* TODO: g_list_copy_deep() */
+ if (NULL != src_file->files) {
cloud_file->files = g_list_copy(src_file->files);
- }
- else
- {
+ } else {
cloud_file->files = NULL;
}
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)
- {
+ 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);
return SERVICE_ADAPTOR_ERROR_NONE;
}
-//******************************************************************************
-//* 2.4 Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * 2.4 Public interface definition
+ ******************************************************************************/
API int service_storage_get_file_list(service_plugin_h plugin,
const char *dir_path,
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)
+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 == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
-// return service_task_stop((service_task_h) task);
+/* return service_task_stop((service_task_h) task); */
return SERVICE_ADAPTOR_ERROR_NONE;
}
#include "sal_service_auth_internal.h"
#include "sal_service_storage_internal.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
GList *service_tasks = NULL;
GThreadPool *thread_pool = NULL;
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * 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)
- {
+ if (NULL != task->oauth1) {
service_auth_oauth1_start(task->oauth1);
- }
- else if (NULL != task->cloud_file)
- {
+ } else if (NULL != task->cloud_file) {
service_storage_cloud_start(task->cloud_file);
- }
- else
- {
+ } else {
return;
}
- // TODO: in IPC
- if (NULL != task->storage_progress_callback)
- {
+ /* TODO: in IPC */
+ if (NULL != task->storage_progress_callback) {
task->storage_progress_callback(100, 100, task->user_data);
}
- if (NULL != task->storage_state_callback)
- {
+ if (NULL != task->storage_state_callback) {
task->storage_state_callback(SERVICE_STORAGE_TASK_COMPLETED, task->user_data);
}
- if (NULL != task->storage_result_callback)
- {
+ if (NULL != task->storage_result_callback) {
task->storage_result_callback(SERVICE_ADAPTOR_ERROR_NONE, task->user_data);
}
- if (NULL != task->storage_file_list_callback)
- {
+ 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";
}
}
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
API int service_task_connect()
{
{
SAL_FN_CALL;
- // TODO: stop current stated task
+ /* TODO: stop current stated task */
return SERVICE_ADAPTOR_ERROR_NONE;
}
RETV_IF(NULL == task, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
- if (NULL != task->cloud_file)
- {
+ if (NULL != task->cloud_file) {
service_storage_cloud_stop(task->cloud_file);
- }
- else
- {
+ } else {
return SERVICE_ADAPTOR_ERROR_NO_DATA;
}
int ret = SERVICE_ADAPTOR_ERROR_NONE;
- if (0 == strcmp(operation, CLOUD_REMOVE_FILE_URI))
- {
+ if (0 == strcmp(operation, CLOUD_REMOVE_FILE_URI)) {
app_control_create(&reply);
char *cloud_path = NULL;
ret = provider->cloud_remove_file(cloud_path);
- if (SERVICE_ADAPTOR_ERROR_NONE != ret)
- {
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
SAL_ERR("cloud_remove_file() Fail (%d)", ret);
app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_FAILURE);
return reply;
app_control_add_extra_data(reply, PLUGIN_KEY_STORAGE, PLUGIN_VALUE_TRUE);
- if (NULL != provider->cloud_remove_file)
- {
+ if (NULL != provider->cloud_remove_file) {
app_control_add_extra_data(reply, CLOUD_REMOVE_FILE_URI, PLUGIN_VALUE_TRUE);
}
#include "service_adaptor_internal.h"
#include "sal_ipc.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
/**
* 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
+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;
*/
static GDBusProxy *interface_proxy = NULL;
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
static gpointer _dbus_client_thread_func(gpointer data);
GVariant *parameters,
gpointer user_data);
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
/**
* @brief D-Bus client thread function.
ret = _dbus_client_start(data);
- if (SERVICE_ADAPTOR_ERROR_NONE == ret)
- {
+ if (SERVICE_ADAPTOR_ERROR_NONE == ret) {
g_main_loop_run(dbus_client_loop);
}
connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
- if (NULL == connection)
- {
+ if (NULL == connection) {
g_error_free(error);
return SERVICE_ADAPTOR_ERROR_INTERNAL;
NULL,
&error);
- if (NULL == interface_proxy)
- {
+ if (NULL == interface_proxy) {
g_error_free(error);
g_object_unref(connection);
thread_data,
NULL);
- if (0 == watcher_id)
- {
+ if (0 == watcher_id) {
g_object_unref(interface_proxy);
interface_proxy = NULL;
G_CALLBACK(_on_signal),
NULL);
- if (0 == res)
- {
+ if (0 == res) {
g_object_unref(interface_proxy);
interface_proxy = NULL;
{
SAL_FN_CALL;
- if (NULL != interface_proxy)
- {
+ if (NULL != interface_proxy) {
g_object_unref(interface_proxy);
interface_proxy = NULL;
}
- if (NULL != connection)
- {
+ if (NULL != connection) {
g_object_unref(connection);
connection = NULL;
}
- if (0 != watcher_id)
- {
+ if (0 != watcher_id) {
g_bus_unwatch_name(watcher_id);
watcher_id = 0;
}
dbus_client_thread_data_h thread_data = (dbus_client_thread_data_h) user_data;
- if (NULL != thread_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);
{
SAL_FN_CALL;
- if (NULL != interface_proxy)
- {
+ if (NULL != interface_proxy) {
g_object_unref(interface_proxy);
interface_proxy = NULL;
}
- if (NULL != connection)
- {
+ if (NULL != connection) {
g_object_unref(connection);
connection = NULL;
}
- if (0 != watcher_id)
- {
+ if (0 != watcher_id) {
g_bus_unwatch_name(watcher_id);
watcher_id = 0;
}
{
SAL_FN_CALL;
- if (0 == strncmp(signal_name, DBUS_SERVICE_ADAPTOR, DBUS_NAME_LENGTH))
- {
- // TODO:
+ if (0 == strncmp(signal_name, DBUS_SERVICE_ADAPTOR, DBUS_NAME_LENGTH)) {
+ /* TODO: */
/*
on_service_signal(proxy,
sender_name,
}
}
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
API service_adaptor_error_e sal_ipc_client_get_interface(GDBusProxy **interface)
{
{
SAL_FN_CALL;
-#if !GLIB_CHECK_VERSION(2,32,0)
+#if !GLIB_CHECK_VERSION(2, 32, 0)
g_thread_init(NULL);
#endif
-#if !GLIB_CHECK_VERSION(2,35,0)
+#if !GLIB_CHECK_VERSION(2, 35, 0)
g_type_init();
#endif
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_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 SERVICE_ADAPTOR_ERROR_INTERNAL;
}
{
SAL_FN_CALL;
- if (NULL != dbus_client_loop)
- {
- if (g_main_loop_is_running(dbus_client_loop))
- {
+ 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)
- {
+ if (NULL != dbus_client_thread) {
g_thread_join(dbus_client_thread);
dbus_client_thread = NULL;
}
- if (NULL != dbus_client_loop)
- {
+ if (NULL != dbus_client_loop) {
g_main_loop_unref(dbus_client_loop);
dbus_client_loop = NULL;
}
- if (NULL != dbus_client_context)
- {
+ 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;
#include "sal_service_auth.h"
#include "sal_service_auth_internal.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
int _get_oauth1(GVariant *reply_info, service_auth_oauth1_h *oauth1)
{
return SERVICE_ADAPTOR_ERROR_NONE;
}
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
API int ipc_service_auth_oauth1(const char *uri, service_auth_oauth1_h req_oauth1, service_auth_oauth1_h *res_oauth1)
{
#include "sal_ipc_client.h"
#include "sal_ipc_client_core.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
API int ipc_service_adaptor_connect(const char *uri, GList **plugins)
{
GList *plugin_list = NULL;
gsize uri_info_size = g_variant_n_children(info[idx2]);
- for (gsize i = 0; i < uri_info_size; i++)
- {
+ for (gsize i = 0; i < uri_info_size; i++) {
GVariant *uri_info_struct;
GVariant *uri_info_entry_v = g_variant_get_child_value(info[idx2], i);
uri_info_struct = g_variant_get_child_value(uri_info_entry_v, 0);
#include "sal_service_storage.h"
#include "sal_service_storage_internal.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
int _get_cloud_file(GVariant *reply_info, service_storage_cloud_file_h *file)
{
gsize files_size = g_variant_n_children(info[idx]);
- for (gsize i = 0; i < files_size; i++)
- {
+ 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);
ipc_destroy_variant_info(info, info_size);
- // TODO: reorder files because it is just serialized. it makes tree structure.
+ /* TODO: reorder files because it is just serialized. it makes tree structure. */
*file = cloud_file;
return SERVICE_ADAPTOR_ERROR_NONE;
}
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * 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)
{
#include "sal_ipc_server_auth.h"
#include "sal_ipc_server_storage.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
/**
* D-Bus server thread
/**
* information for method call
*/
-typedef struct _method_call_s
-{
+typedef struct _method_call_s {
GDBusConnection *connection;
gchar *sender;
gchar *object_path;
} method_call_s;
typedef struct _method_call_s *method_call_h;
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
static void _method_call_async_func(gpointer data, gpointer user_data)
{
SAL_INFO("Call %s", handle->method_name);
- if (0 == strncmp(handle->method_name, DBUS_SERVICE_ADAPTOR, DBUS_NAME_LENGTH))
- {
+ if (0 == strncmp(handle->method_name, DBUS_SERVICE_ADAPTOR, DBUS_NAME_LENGTH)) {
service_adaptor_method_call(handle->connection,
handle->sender,
handle->object_path,
handle->parameters,
handle->invocation,
handle->user_data);
- }
- else if (0 == strncmp(handle->method_name, DBUS_SERVICE_PLUGIN, DBUS_NAME_LENGTH))
- {
+ } else if (0 == strncmp(handle->method_name, DBUS_SERVICE_PLUGIN, DBUS_NAME_LENGTH)) {
service_plugin_method_call(handle->connection,
handle->sender,
handle->object_path,
handle->parameters,
handle->invocation,
handle->user_data);
- }
- else if (0 == strncmp(handle->method_name, DBUS_SERVICE_AUTH, DBUS_NAME_LENGTH))
- {
+ } else if (0 == strncmp(handle->method_name, DBUS_SERVICE_AUTH, DBUS_NAME_LENGTH)) {
service_auth_method_call(handle->connection,
handle->sender,
handle->object_path,
handle->parameters,
handle->invocation,
handle->user_data);
- }
- else if (0 == strncmp(handle->method_name, DBUS_SERVICE_STORAGE, DBUS_NAME_LENGTH))
- {
+ } else if (0 == strncmp(handle->method_name, DBUS_SERVICE_STORAGE, DBUS_NAME_LENGTH)) {
service_storage_method_call(handle->connection,
handle->sender,
handle->object_path,
gboolean ret = false;
- if (NULL == *error)
- {
+ if (NULL == *error) {
ret = true;
}
/**
* D-Bus handlers vtable.
*/
-static const GDBusInterfaceVTable interface_vtable =
-{
+static const GDBusInterfaceVTable interface_vtable = {
_handle_method_call,
_handle_get_property,
_handle_set_property
{
SAL_FN_CALL;
- if (NULL != dbus_connection)
- {
+ 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
+ /* Send SIGINT to main thread to stop File Manager process and cleanly close Service Adaptor */
kill(getpid(), SIGINT);
}
NULL,
NULL);
- if (0 == owner_id)
- {
+ if (0 == owner_id) {
g_dbus_node_info_unref(introspection_data);
introspection_data = NULL;
{
SAL_FN_CALL;
- if (NULL != thread_pool)
- {
+ if (NULL != thread_pool) {
g_thread_pool_free(thread_pool, TRUE, TRUE);
}
- if (0 != owner_id)
- {
+ if (0 != owner_id) {
g_bus_unown_name(owner_id);
owner_id = 0;
}
- if (NULL != introspection_data)
- {
+ if (NULL != introspection_data) {
g_dbus_node_info_unref(introspection_data);
introspection_data = NULL;
}
ret = _sal_ipc_server_start();
- if (SERVICE_ADAPTOR_ERROR_NONE == ret)
- {
+ if (SERVICE_ADAPTOR_ERROR_NONE == ret) {
g_main_loop_run(dbus_server_loop);
}
return NULL;
}
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
API service_adaptor_error_e sal_ipc_server_init()
{
{
SAL_FN_CALL;
- if (NULL != dbus_server_loop)
- {
- if (g_main_loop_is_running(dbus_server_loop))
- {
+ 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)
- {
+ if (NULL != dbus_server_thread) {
g_thread_join(dbus_server_thread);
dbus_server_thread = NULL;
}
- if (NULL != dbus_server_loop)
- {
+ if (NULL != dbus_server_loop) {
g_main_loop_unref(dbus_server_loop);
dbus_server_loop = NULL;
}
- if (NULL != dbus_server_context)
- {
+ 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;
#include "sal_service_auth.h"
#include "sal_service_auth_internal.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
void _oauth1_get_access_token_cb(int result, oauth1_h oauth1, void *user_data)
{
int ret = SERVICE_ADAPTOR_ERROR_NONE;
- if (0 == strcmp(oauth1->operation, SERVICE_AUTH_OAUTH1_0_GET_ACCESS_TOKEN_URI))
- {
+ if (0 == strcmp(oauth1->operation, SERVICE_AUTH_OAUTH1_0_GET_ACCESS_TOKEN_URI)) {
ret = plugin->oauth1->oauth1_get_access_token(plugin, _oauth1_get_access_token_cb, reply);
return ret;
- }
- else if (0 == strcmp(oauth1->operation, SERVICE_AUTH_OAUTH1_0_GET_EXTRA_DATA_URI))
- {
+ } else if (0 == strcmp(oauth1->operation, SERVICE_AUTH_OAUTH1_0_GET_EXTRA_DATA_URI)) {
return ret;
}
return SERVICE_ADAPTOR_ERROR_INTERNAL;
}
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
API void service_auth_method_call(GDBusConnection *connection,
const gchar *sender,
GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
- if (0 == g_strcmp0(method_name, DBUS_SERVICE_AUTH_OAUTH1_METHOD))
- {
+ 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];
#include "sal_ipc_server.h"
#include "sal_ipc_server_core.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
API void service_adaptor_method_call(GDBusConnection *connection,
const gchar *sender,
GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
- if (0 == g_strcmp0(method_name, DBUS_SERVICE_ADAPTOR_CONNECT_METHOD))
- {
+ 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_ret = sal_adaptor_get_plugins(&plugins, &plugins_size);
- for (gsize i = 0; i < plugins_size; i++)
- {
+ for (gsize i = 0; i < plugins_size; i++) {
ipc_insure_g_variant_builder_add_array_string(builder, plugins[i]);
}
g_variant_builder_unref(builder);
ipc_destroy_variant_info(req_info, size);
- }
- else if (0 == g_strcmp0(method_name, DBUS_SERVICE_ADAPTOR_DISCONNECT_METHOD))
- {
+ } 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];
GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
- if (0 == g_strcmp0(method_name, DBUS_SERVICE_PLUGIN_CREATE_METHOD))
- {
+ 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];
sal_h sal = sal_get_handle();
- if (NULL != sal)
- {
+ if (NULL != sal) {
ipc_ret = auth_adaptor_ref_plugin(sal->auth, uri);
}
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))
- {
+ } 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];
sal_h sal = sal_get_handle();
- if (NULL != sal)
- {
+ if (NULL != sal) {
ipc_ret = auth_adaptor_unref_plugin(sal->auth, uri);
}
GError* error = NULL;
GDBusConnection *dbus_connection = dbus_get_connection();
- if (NULL != dbus_connection)
- {
+ if (NULL != dbus_connection) {
GVariant *response = g_variant_new("(ts)", (uint64_t) signal_code, signal_msg);
g_dbus_connection_emit_signal(dbus_connection,
response,
&error );
- if (NULL != error)
- {
+ if (NULL != error) {
service_adaptor_debug("Unable to send msg: %s", error->message);
return SERVICE_ADAPTOR_INTERNAL_ERROR_DBUS;
}
#include "sal_service_storage.h"
#include "sal_service_storage_internal.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
void _cloud_remove_file_cb(int result, cloud_file_h file, void *user_data)
{
int ret = SERVICE_ADAPTOR_ERROR_NONE;
- if (0 == strcmp(file->operation, SERVICE_STORAGE_CLOUD_REMOVE_FILE_URI))
- {
+ if (0 == strcmp(file->operation, SERVICE_STORAGE_CLOUD_REMOVE_FILE_URI)) {
ret = plugin->cloud->cloud_remove_file(plugin, file->cloud_path, _cloud_remove_file_cb, reply);
return ret;
- }
- else if (0 == strcmp(file->operation, SERVICE_STORAGE_CLOUD_DOWNLOAD_FILE_URI))
- {
+ } else if (0 == strcmp(file->operation, SERVICE_STORAGE_CLOUD_DOWNLOAD_FILE_URI)) {
ret = plugin->cloud->cloud_remove_file(plugin, file->cloud_path, _cloud_remove_file_cb, reply);
return ret;
- }
- else if (0 == strcmp(file->operation, SERVICE_STORAGE_CLOUD_UPLOAD_FILE_URI))
- {
+ } else if (0 == strcmp(file->operation, SERVICE_STORAGE_CLOUD_UPLOAD_FILE_URI)) {
ret = plugin->cloud->cloud_remove_file(plugin, file->cloud_path, _cloud_remove_file_cb, reply);
return ret;
- }
- else if (0 == strcmp(file->operation, SERVICE_STORAGE_CLOUD_DOWNLOAD_FILE_THUMBNAIL_URI))
- {
+ } else if (0 == strcmp(file->operation, SERVICE_STORAGE_CLOUD_DOWNLOAD_FILE_THUMBNAIL_URI)) {
ret = plugin->cloud->cloud_remove_file(plugin, file->cloud_path, _cloud_remove_file_cb, reply);
return ret;
- }
- else if (0 == strcmp(file->operation, SERVICE_STORAGE_CLOUD_GET_FILE_LIST_URI))
- {
+ } else if (0 == strcmp(file->operation, SERVICE_STORAGE_CLOUD_GET_FILE_LIST_URI)) {
ret = plugin->cloud->cloud_remove_file(plugin, file->cloud_path, _cloud_remove_file_cb, reply);
return ret;
return SERVICE_ADAPTOR_ERROR_INTERNAL;
}
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
API void service_storage_method_call(GDBusConnection *connection,
const gchar *sender,
GVariant *in_parameters = g_variant_get_child_value(parameters, 0);
- if (0 == g_strcmp0(method_name, DBUS_SERVICE_STORAGE_CLOUD_FILE_METHOD))
- {
+ 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];
#include "service_adaptor_internal.h"
#include "sal_ipc.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
-//******************************************************************************
-//* Public 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, ""))
- {
+ if (0 == strcmp(ret, "")) {
SAL_FREE(ret);
}
API void ipc_insure_g_variant_builder_add_array_string(GVariantBuilder *builder, const char *str)
{
- if (NULL == str)
- {
+ if (NULL == str) {
g_variant_builder_add(builder, "(s)", "");
- }
- else
- {
+ } else {
g_variant_builder_add(builder, "(s)", str);
}
}
API void ipc_create_error_msg(int code, char **ipc_msg)
{
- switch (code)
- {
- case SERVICE_ADAPTOR_ERROR_NONE:
- {
- *ipc_msg = NULL;
- break;
- }
- case SERVICE_ADAPTOR_ERROR_INTERNAL:
- {
- *ipc_msg = strdup("SERVICE_ADAPTOR_ERROR_INTERNAL");
- break;
- }
- default:
- {
- *ipc_msg = strdup("SERVICE_ADAPTOR_ERROR_UNKNOWN");
- break;
- }
+ switch (code) {
+ case SERVICE_ADAPTOR_ERROR_NONE:
+ *ipc_msg = NULL;
+ break;
+ case SERVICE_ADAPTOR_ERROR_INTERNAL:
+ *ipc_msg = strdup("SERVICE_ADAPTOR_ERROR_INTERNAL");
+ break;
+ default:
+ *ipc_msg = strdup("SERVICE_ADAPTOR_ERROR_UNKNOWN");
+ break;
}
}
API void ipc_create_variant_info(GVariant *parameters, int size, GVariant ***var_info)
{
- for (size_t i = 0; i < size; i++)
- {
+ 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++)
- {
+ for (size_t i = 0; i < size; i++) {
g_variant_unref(var_info[i]);
}
}
#include "sal_auth.h"
#include "service_adaptor_internal.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
void _sal_auth_login_cb(const char *uri, void *user_data)
{
}
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
auth_adaptor_listener_h sal_auth_register_listener(auth_adaptor_h auth)
{
int ret = auth_adaptor_register_listener(auth, listener);
- if (SERVICE_ADAPTOR_ERROR_NONE != ret)
- {
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
SAL_FREE(listener);
}
#include "sal_contact.h"
#include "service_adaptor_internal.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
contact_adaptor_listener_h sal_contact_register_listener(contact_adaptor_h contact)
{
ret = contact_adaptor_register_listener(contact, listener);
- if (SERVICE_ADAPTOR_ERROR_NONE != ret)
- {
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
SAL_FREE(listener);
}
#include "service_discovery.h"
#include "service_federation.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
#define FILE_PATH_LEN 256
static sal_h g_service_adaptor = NULL;
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
/**
* @brief callback of app control
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))
- {
+ 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))
- {
+ } 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);
auth_adaptor_unregister_plugin_service(plugin);
auth_adaptor_destroy_plugin(plugin);
- // TODO: destroy plugin of other adaptor
+ /* TODO: destroy plugin of other adaptor */
SAL_FN_END;
}
sal_h sal = NULL;
- // 1) create auth adaptor handle
+ /* 1) create auth adaptor handle */
auth_adaptor_h auth = auth_adaptor_create();
TRYM_IF(NULL == auth, "sal_auth_create_handle() Fail");
- // 2) create contact adaptor handle
+ /* 2) create contact adaptor handle */
contact_adaptor_h contact = contact_adaptor_create();
TRYM_IF(NULL == contact, "sal_contact_create_handle() Fail");
- // 3) create storage adaptor handle
+ /* 3) create storage adaptor handle */
storage_adaptor_h storage = storage_adaptor_create();
TRYM_IF(NULL == storage, "sal_storage_create_handle() Fail");
- // 4) create resource adaptor handle
+ /* 4) create resource adaptor handle */
resource_adaptor_h resource = resource_adaptor_create();
TRYM_IF(NULL == resource, "sal_resource_create_handle() Fail");
- // 5) register auth adaptor listener
+ /* 5) register auth adaptor listener */
auth_adaptor_listener_h auth_listener = sal_auth_register_listener(auth);
TRYM_IF(NULL == auth_listener, "sal_auth_register_listener() Fail");
- // 6) register contact adaptor listener
+ /* 6) register contact adaptor listener */
contact_adaptor_listener_h contact_listener = sal_contact_register_listener(contact);
TRYM_IF(NULL == contact_listener, "sal_contact_register_listener() Fail");
- // 7) register storage adaptor listener
+ /* 7) register storage adaptor listener */
storage_adaptor_listener_h storage_listener = sal_storage_register_listener(storage);
TRYM_IF(NULL == storage_listener, "sal_storage_register_listener() Fail");
- // 8) register resource adaptor listener
+ /* 8) register resource adaptor listener */
resource_adaptor_listener_h resource_listener = sal_resource_register_listener(resource);
TRYM_IF(NULL == resource_listener, "sal_resource_register_listener() Fail");
- // 9) create service adaptor
+ /* 9) create service adaptor */
sal = (sal_h) g_malloc0(sizeof(sal_s));
TRYM_IF(NULL == sal, "could not create service adaptor");
g_cond_init(&sal->cond);
catch:
- // TODO: free
+ /* TODO: free */
return sal;
}
RET_IF(NULL == sal);
- // 1) destroy service list
- if (NULL != sal->svc_list)
- {
- g_list_free(sal->svc_list);
- sal->svc_list = NULL;
- }
+ /* 1) destroy service list */
+ if (NULL != sal->svc_list) {
+ g_list_free(sal->svc_list);
+ sal->svc_list = NULL;
+ }
- // 2) free service adaptor handle
+ /* 2) free service adaptor handle */
SAL_FREE(sal);
SAL_FN_END;
SAL_FN_CALL;
int ret = SERVICE_ADAPTOR_ERROR_NONE;
- // 1) create adaptor (memory allocation)
+ /* 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)
+ /* 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)
+ /* 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
+ /* 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
+ /* 5) assign to global service adaptor handle */
g_service_adaptor = sal;
- // 6) register callback for package event
+ /* 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
+ /* 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
+ /* 8) create service federation */
ret = service_federation_create();
RETVM_IF(SERVICE_ADAPTOR_ERROR_NONE != ret, ret, "service_federation_create() Fail(%d)", ret);
_sal_destroy_spec_file(sal);
- if (0 < sal->start)
- {
+ if (0 < sal->start) {
_sal_stop(sal);
}
int ret = SERVICE_ADAPTOR_ERROR_NONE;
GMainLoop *loop = NULL;
-#if !GLIB_CHECK_VERSION(2,32,0)
+#if !GLIB_CHECK_VERSION(2, 32, 0)
g_thread_init(NULL);
#endif
-#if !GLIB_CHECK_VERSION(2,35,0)
+#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
+ /* mainloop of main thread */
loop = g_main_loop_new(NULL, FALSE);
- // installing signal handlers
+ /* installing signal handlers */
g_unix_signal_add_full(G_PRIORITY_HIGH, SIGINT,
- _sigterm_callback, loop, NULL );
+ _sigterm_callback, loop, NULL);
g_unix_signal_add_full(G_PRIORITY_HIGH, SIGTERM,
- _sigterm_callback, loop, NULL );
+ _sigterm_callback, loop, NULL);
- // start application's main loop
+ /* start application's main loop */
g_main_loop_run(loop);
- // cleanup after mainloop
+ /* cleanup after mainloop */
g_main_loop_unref(loop);
sal_h sal = sal_get_handle();
return 0;
}
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
API sal_h sal_get_handle()
{
SAL_FN_CALL;
- return g_service_adaptor;
+ 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,};
+ 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);
+ /* 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;
+ return root_path;
}
API service_adaptor_error_e sal_adaptor_connect(const char *uri)
SAL_INFO("uri: %s", uri);
- return SERVICE_ADAPTOR_ERROR_NONE;
+ return SERVICE_ADAPTOR_ERROR_NONE;
}
API service_adaptor_error_e sal_adaptor_disconnect(const char *uri)
SAL_INFO("uri: %s", uri);
- return SERVICE_ADAPTOR_ERROR_NONE;
+ return SERVICE_ADAPTOR_ERROR_NONE;
}
API service_adaptor_error_e sal_adaptor_get_plugins(char ***plugins, int *plugins_size)
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)
- {
+ 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);
app_control_destroy(request);
- return SERVICE_ADAPTOR_ERROR_NONE;
+ return SERVICE_ADAPTOR_ERROR_NONE;
}
API service_adaptor_error_e sal_provider_disconnect(const char *uri)
app_control_destroy(request);
- return SERVICE_ADAPTOR_ERROR_NONE;
+ return SERVICE_ADAPTOR_ERROR_NONE;
}
API char *sal_provider_get_uri(const char *package)
char *uri = auth_adaptor_get_uri(sal->auth, package);
- return uri;
+ return uri;
}
#include "sal_observer.h"
#include "auth_adaptor.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
#define SAL_PLUGIN_METADATA_KEY_ADAPTOR "service-adaptor"
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
/**
* @brief callback of app info
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)))
- {
+ 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);
* @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)
+ 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))
- {
+ 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_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))
- {
+ } 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");
storage_adaptor_unregister_plugin_service(storage_plugin);
storage_adaptor_destroy_plugin(storage_plugin);
- // TODO: destroy plugin of other adaptor
+ /* TODO: destroy plugin of other adaptor */
}
}
return true;
}
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
/**
* @brief start observer using package manager
#include "sal_resource.h"
#include "service_adaptor_internal.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
resource_adaptor_listener_h sal_resource_register_listener(resource_adaptor_h resource)
{
ret = resource_adaptor_register_listener(resource, listener);
- if (SERVICE_ADAPTOR_ERROR_NONE != ret)
- {
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
SAL_FREE(listener);
}
#include "sal_storage.h"
#include "service_adaptor_internal.h"
-//******************************************************************************
-//* Global variables and defines
-//******************************************************************************
+/******************************************************************************
+ * Global variables and defines
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface
-//******************************************************************************
+/******************************************************************************
+ * Private interface
+ ******************************************************************************/
-//******************************************************************************
-//* Private interface definition
-//******************************************************************************
+/******************************************************************************
+ * Private interface definition
+ ******************************************************************************/
-//******************************************************************************
-//* Public interface definition
-//******************************************************************************
+/******************************************************************************
+ * Public interface definition
+ ******************************************************************************/
storage_adaptor_listener_h sal_storage_register_listener(storage_adaptor_h storage)
{
ret = storage_adaptor_register_listener(storage, listener);
- if (SERVICE_ADAPTOR_ERROR_NONE != ret)
- {
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
SAL_FREE(listener);
}
ret = service_plugin_start_all(service_plugin);
- if (SERVICE_ADAPTOR_ERROR_NONE != ret)
- {
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
printf("service_plugin_start Failed(%d)\n", ret);
return;
}
service_task_h auth_task = NULL;
ret = service_auth_oauth1_create_task(oauth1, &auth_task);
ret = service_task_start(auth_task);
- if (SERVICE_ADAPTOR_ERROR_NONE == ret)
- {
+ if (SERVICE_ADAPTOR_ERROR_NONE == ret) {
printf("service_auth_oauth1_get_access_token() Request Successed\n");
}
service_task_h task = NULL;
ret = service_storage_cloud_file_create_task(file, &task);
ret = service_task_start(task);
- if (SERVICE_ADAPTOR_ERROR_NONE == ret)
- {
+ if (SERVICE_ADAPTOR_ERROR_NONE == ret) {
printf("service_storage_cloud_remove_file() Request Successed: %s\n", cloud_path);
}
}
bool _service_adaptor_plugin_callback(const char *uri, int service_mask, void *user_data)
{
- if (0 != strcmp(uri, "org.tizen.service-plugin-sample"))
- {
+ if (0 != strcmp(uri, "org.tizen.service-plugin-sample")) {
return true;
}
ret = service_plugin_create(uri, &service_plugin);
- if (SERVICE_ADAPTOR_ERROR_NONE != ret)
- {
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
printf("service_plugin_create(%s) Failed(%d)\n", uri, ret);
return true;
}
ret = service_plugin_login(service_plugin, _service_plugin_login_callback, NULL);
- if (SERVICE_ADAPTOR_ERROR_NONE != ret)
- {
+ if (SERVICE_ADAPTOR_ERROR_NONE != ret) {
printf("service_plugin_login(%s) Failed(%d)\n", uri, ret);
return true;
}
{
GMainLoop *loop = NULL;
-#if !GLIB_CHECK_VERSION(2,32,0)
+#if !GLIB_CHECK_VERSION(2, 32, 0)
g_thread_init(NULL);
#endif
-#if !GLIB_CHECK_VERSION(2,35,0)
+#if !GLIB_CHECK_VERSION(2, 35, 0)
g_type_init();
#endif
loop = g_main_loop_new(NULL, FALSE);
g_unix_signal_add_full(G_PRIORITY_HIGH, SIGINT,
- _sigterm_callback, loop, NULL );
+ _sigterm_callback, loop, NULL);
g_unix_signal_add_full(G_PRIORITY_HIGH, SIGTERM,
- _sigterm_callback, loop, NULL );
+ _sigterm_callback, loop, NULL);
g_main_loop_run(loop);