2 * Storage Plugin Client
4 * Copyright (c) 2014 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
26 #include "service_adaptor_errors.h"
27 #include "service_adaptor_internal.h"
28 #include "cloud_service.h"
29 #include "sal_service_provider.h"
30 #include "sal_storage_provider.h"
32 API int storage_provider_create(storage_provider_h *provider)
36 storage_provider_h storage_provider = (storage_provider_h) g_malloc0(sizeof(storage_provider_s));
38 storage_provider->cloud_remove_file = NULL;
40 *provider = storage_provider;
42 return SERVICE_ADAPTOR_ERROR_NONE;
45 API app_control_h storage_provider_message(storage_provider_h provider, const char *operation, void *user_data)
49 app_control_h reply = NULL;
51 RETV_IF(NULL == provider, reply);
53 int ret = SERVICE_ADAPTOR_ERROR_NONE;
55 if (0 == strcmp(operation, CLOUD_REMOVE_FILE_URI))
57 app_control_create(&reply);
59 char *cloud_path = NULL;
60 app_control_get_extra_data((app_control_h) user_data, CLOUD_CLOUD_PATH_KEY, &cloud_path);
62 ret = provider->cloud_remove_file(cloud_path);
64 if (SERVICE_ADAPTOR_ERROR_NONE != ret)
66 SAL_ERR("cloud_remove_file() Fail (%d)", ret);
67 app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_FAILURE);
71 app_control_add_extra_data(reply, PLUGIN_RESULT_KEY, PLUGIN_RESULT_VALUE_SUCCESS);
77 API int storage_provider_add_extra_data(storage_provider_h provider, app_control_h reply)
81 RETV_IF(NULL == provider, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
82 RETV_IF(NULL == reply, SERVICE_ADAPTOR_ERROR_INVALID_PARAMETER);
84 app_control_add_extra_data(reply, PLUGIN_KEY_STORAGE, PLUGIN_VALUE_TRUE);
86 if (NULL != provider->cloud_remove_file)
88 app_control_add_extra_data(reply, CLOUD_REMOVE_FILE_URI, PLUGIN_VALUE_TRUE);
91 return SERVICE_ADAPTOR_ERROR_NONE;