2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <sys/types.h>
26 #include <sys/smack.h>
30 #include <plugin_message.h>
32 #include "storage-adaptor.h"
33 #include "storage-adaptor-log.h"
35 #define PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE 40960
36 #define PLUGIN_MESSAGE_LISTENER_CMD_APPEND_FD "append;"
37 #define PLUGIN_MESSAGE_LISTENER_CMD_STOP "stop;"
39 #define STORAGE_PLUGIN_INTERFACE_CREATE_CONTEXT "create_context"
40 #define STORAGE_PLUGIN_INTERFACE_DESTROY_CONTEXT "destroy_context"
41 #define STORAGE_PLUGIN_INTERFACE_MAKE_DIRECTORY "make_directory"
42 #define STORAGE_PLUGIN_INTERFACE_GET_LIST "get_list"
43 #define STORAGE_PLUGIN_INTERFACE_REMOVE_DIRECTORY "remove_directory"
44 #define STORAGE_PLUGIN_INTERFACE_UPLOAD_FILE_SYNC "upload_file_sync"
45 #define STORAGE_PLUGIN_INTERFACE_DOWNLOAD_FILE_SYNC "download_file_sync"
46 #define STORAGE_PLUGIN_INTERFACE_DELETE_FILE "delete_file"
47 #define STORAGE_PLUGIN_INTERFACE_MOVE_DIRECTORY "move_directory"
48 #define STORAGE_PLUGIN_INTERFACE_MOVE_FILE "move_file"
49 #define STORAGE_PLUGIN_INTERFACE_SET_TRANSFER_STATE "set_transfer_state"
50 #define STORAGE_PLUGIN_INTERFACE_GET_TRANSFER_STATE "get_transfer_state"
51 #define STORAGE_PLUGIN_INTERFACE_GET_ROOT_FOLDER_PATH "get_root_folder_path"
53 /* for 2.4 public functions */
54 #define STORAGE_PLUGIN_INTERFACE_START_UPLOAD_TASK "start_upload_task"
55 #define STORAGE_PLUGIN_INTERFACE_START_DOWNLOAD_TASK "start_download_task"
56 #define STORAGE_PLUGIN_INTERFACE_START_DOWNLOAD_THUMB_TASK "start_download_thumb_task"
57 #define STORAGE_PLUGIN_INTERFACE_CANCEL_UPLOAD_TASK "cancel_upload_task"
58 #define STORAGE_PLUGIN_INTERFACE_CANCEL_DOWNLOAD_TASK "cancel_download_task"
59 #define STORAGE_PLUGIN_INTERFACE_CANCEL_DOWNLOAD_THUMB_TASK "cancel_download_thumb_task"
61 #define STORAGE_PLUGIN_CALLBACK_DOWNLOAD_FILE_ASYNC_CB "download_async_cb"
62 #define STORAGE_PLUGIN_CALLBACK_UPLOAD_FILE_ASYNC_CB "upload_async_cb"
63 #define STORAGE_PLUGIN_CALLBACK_PROGRESS_CB "progress_cb"
65 #define IF_IS_PLUGIN_THAN_RETURN_NULL() do {if (!g_process_identity) return NULL; } while (0)
66 #define SAFE_ADD_STRING(x) (x) ? (x) : ("")
69 PLUGIN_TYPE_INHOUSE = 0,
70 PLUGIN_TYPE_3RD_PARTY = 1,
71 } storage_plugin_type_e;
74 #ifndef FORK_PLUGIN_ARCHITECTURE
75 GHashTable *g_file_uid_list = NULL;
79 * Storage adaptor plugin
81 typedef struct storage_adaptor_plugin_s {
82 storage_adaptor_h adaptor; /* Adaptor */
83 char *path; /* Plugin library path */
84 storage_adaptor_plugin_handle_h handle; /* Plugin handle */
85 void *dl_handle; /* Plugin library handle */
86 int ref_counter; /* Plugin reference counter */
87 GMutex ref_counter_mutex; /* Plugin reference counter mutex */
88 storage_adaptor_plugin_listener_h plugin_listener; /* Plugin callback listener */
89 GMutex plugin_listener_mutex; /* Plugin callback listener mutex */
92 storage_plugin_type_e type;
97 GMutex contexts_mutex;
98 } storage_adaptor_plugin_t;
103 typedef struct storage_adaptor_s {
104 GMutex storage_adaptor_mutex; /* Adaptor mutex */
105 int started; /* Started flag */
106 char *plugins_dir; /* Plugins directory path */
107 GList *plugins; /* List of loaded plugins */
108 GMutex plugins_mutex; /* Plugin list mutex */
109 GList *adaptor_listeners; /* List of vservice channel listener (for now not effective) */
110 GMutex adaptor_listeners_mutex; /* Listener list mutex */
115 pthread_t plugin_listener;
118 static int g_process_identity = -1;
120 static storage_adaptor_plugin_h g_child_plugin = NULL;
125 static storage_adaptor_plugin_h storage_adaptor_create_plugin(const char *plugin_path);
128 * Destroys plugin and deletes all resources associated with it
130 static void storage_adaptor_destroy_plugin(storage_adaptor_plugin_h plugin);
133 * Loads plugins from selected directory
135 static int storage_adaptor_load_plugins_from_directory(storage_adaptor_h adaptor,
136 const char *dir_path);
139 * Checks if plugin is loaded by selected plugin adaptor
141 static int storage_adaptor_has_plugin(storage_adaptor_h adaptor,
142 storage_adaptor_plugin_h plugin);
146 #define GET_PLUGIN_PID() getpid()
148 int _get_plugin_fd_from_file_uid(long long int file_uid)
150 return ((int) (0xffff & file_uid));
153 long long int _get_file_uid_from_plugin_fd(int plugin_fd)
155 long long int plugin_section = 0LL;
156 #ifdef FORK_PLUGIN_ARCHITECTURE
157 /* TODO it must be changed to another index (not support 64bit) */
158 plugin_section = ((long long int) GET_PLUGIN_PID()) << (sizeof(int)*8);
161 return (plugin_section | (long long int)plugin_fd);
165 * Increases adaptor's plugin references counter
167 void storage_adaptor_plugin_ref(storage_adaptor_plugin_h);
170 * Decreases adaptor's plugin references counter
172 void storage_adaptor_plugin_unref(storage_adaptor_plugin_h);
175 /* ///////////////////////////////////////////////////////////////////////////////
176 ///////////// Internal function prototype (for forked plugin) ///////////////
177 /////////////////////////////////////////////////////////////////////////////// */
180 /* To be used by adaptor */
181 void *_storage_adaptor_plugin_message_collector(void *data);
182 void __storage_adaptor_transfer_message(const char *msg);
183 int __storage_adaptor_parse_message_cmd(storage_adaptor_h adaptor, char *msg);
184 void _storage_adaptor_send_cmd_add_fd(storage_adaptor_h adaptor, int fd);
185 void _storage_adaptor_send_cmd_stop_listen(storage_adaptor_h adaptor);
187 static int storage_adaptor_send_message_to_plugin_sync(storage_adaptor_plugin_h plugin,
188 plugin_message_h send_message,
189 plugin_message_h *receive_message);
191 /* To be used by adaptor (virtual plugin handle) */
192 storage_adaptor_plugin_handle_h __storage_adaptor_create_3rd_party_plugin_handle(const char *plugin_uri);
194 storage_error_code_t storage_plugin_send_create_context(storage_adaptor_plugin_context_h *context,
196 const char *app_secret,
197 const char *access_token,
201 storage_error_code_t storage_plugin_send_destroy_context(storage_adaptor_plugin_context_h context);
203 storage_error_code_t storage_plugin_send_set_server_info(storage_adaptor_plugin_context_h context,
204 GHashTable *server_info,
206 storage_adaptor_error_code_h *error,
209 storage_error_code_t storage_plugin_send_make_directory(storage_adaptor_plugin_context_h context,
210 const char *parent_folder_storage_path,
211 const char *folder_name,
213 storage_adaptor_file_info_h *file_info,
214 storage_adaptor_error_code_h *error,
217 storage_error_code_t storage_plugin_send_remove_directory(storage_adaptor_plugin_context_h context,
218 const char *parent_folder_storage_path,
219 const char *folder_name,
221 storage_adaptor_file_info_h *file_info,
222 storage_adaptor_error_code_h *error,
225 storage_error_code_t storage_plugin_send_get_list(storage_adaptor_plugin_context_h context,
226 const char *parent_folder_storage_path,
227 const char *folder_name,
229 storage_adaptor_file_info_h **file_info_list,
230 int *file_info_list_len,
231 storage_adaptor_error_code_h *error,
234 storage_error_code_t storage_plugin_send_upload_file_sync(storage_adaptor_plugin_context_h context,
235 const char *parent_folder_storage_path,
236 const char *file_name,
237 const char *upload_file_local_path,
240 storage_adaptor_file_info_h *file_info,
241 storage_adaptor_error_code_h *error,
244 storage_error_code_t storage_plugin_send_download_file_sync(storage_adaptor_plugin_context_h context,
245 const char *parent_folder_storage_path,
246 const char *file_name,
247 const char *download_file_local_path,
249 storage_adaptor_error_code_h *error,
252 storage_error_code_t storage_plugin_send_delete_file(storage_adaptor_plugin_context_h context,
253 const char *parent_folder_storage_path,
254 const char *file_name,
256 storage_adaptor_file_info_h *file_info,
257 storage_adaptor_error_code_h *error,
260 storage_error_code_t storage_plugin_send_move_directory(storage_adaptor_plugin_context_h context,
261 const char *parent_folder_storage_path,
262 const char *folder_name,
263 const char *dest_parent_folder_storage_path,
264 const char *new_folder_name,
266 storage_adaptor_file_info_h *file_info,
267 storage_adaptor_error_code_h *error,
270 storage_error_code_t storage_plugin_send_move_file(storage_adaptor_plugin_context_h context,
271 const char *parent_folder_storage_path,
272 const char *file_name,
273 const char *dest_parent_folder_storage_path,
274 const char *new_file_name,
276 storage_adaptor_file_info_h *file_info,
277 storage_adaptor_error_code_h *error,
280 storage_error_code_t storage_plugin_send_set_transfer_state(storage_adaptor_plugin_context_h context,
281 void *transfer_request_id,
282 storage_adaptor_transfer_state_e state,
284 storage_adaptor_error_code_h *error,
287 storage_error_code_t storage_plugin_send_get_transfer_state(storage_adaptor_plugin_context_h context,
288 void *transfer_request_id,
290 storage_adaptor_transfer_state_e *state,
291 storage_adaptor_error_code_h *error,
294 storage_error_code_t storage_plugin_send_get_root_folder_path(storage_adaptor_plugin_context_h context,
296 char **root_folder_path,
297 storage_adaptor_error_code_h *error,
300 storage_error_code_t storage_plugin_send_start_upload_task(storage_adaptor_plugin_context_h context,
302 const char *upload_dir,
303 const char *file_path,
305 storage_adaptor_error_code_h *error,
308 storage_error_code_t storage_plugin_send_start_download_task(storage_adaptor_plugin_context_h context,
309 const char *storage_dir,
310 const char *file_path,
313 storage_adaptor_error_code_h *error,
316 storage_error_code_t storage_plugin_send_start_download_thumb_task(storage_adaptor_plugin_context_h context,
317 const char *storage_dir,
318 const char *file_path,
322 storage_adaptor_error_code_h *error,
325 storage_error_code_t storage_plugin_send_cancel_upload_task(storage_adaptor_plugin_context_h context,
327 storage_adaptor_error_code_h *error);
329 storage_error_code_t storage_plugin_send_cancel_download_task(storage_adaptor_plugin_context_h context,
331 storage_adaptor_error_code_h *error);
333 storage_error_code_t storage_plugin_send_cancel_download_thumb_task(storage_adaptor_plugin_context_h context,
335 storage_adaptor_error_code_h *error);
337 /* To be used by forked plugin */
338 void *_storage_plugin_request_collector(void *data);
339 storage_adaptor_plugin_context_h __storage_plugin_get_context_by_context_id(storage_adaptor_plugin_h plugin, int context_id);
340 void __storage_plugin_progress_command(storage_adaptor_plugin_h plugin, char *order, char **result);
343 storage_adaptor_file_info_h _get_file_info_from_message_array(plugin_message_array_h message_array, int index);
345 int _message_array_set_file_info(plugin_message_array_h message_array, int index, storage_adaptor_file_info_h file_info);
348 * Definition of callback function variables for vservice channel (= infra adaptor) (example)
350 /* private feature */
351 storage_adaptor_service_download_file_async_reply_cb _service_adaptor_download_file_async_reply = NULL;
352 storage_adaptor_service_upload_file_async_reply_cb _service_adaptor_upload_file_async_reply = NULL;
353 storage_adaptor_service_file_transfer_progress_reply_cb _service_adaptor_file_transfer_progress_reply = NULL;
356 storage_adaptor_service_download_state_changed_reply_cb _service_adaptor_download_state_changed_reply = NULL;
357 storage_adaptor_service_upload_state_changed_reply_cb _service_adaptor_upload_state_changed_reply = NULL;
358 storage_adaptor_service_task_progress_reply_cb _service_adaptor_task_progress_reply = NULL;
361 * Gets a message from plugin (callback) when a sms message is received (sample)
363 /* private feature */
364 void storage_adaptor_download_file_async_reply_cb(void *request_id,
365 char *download_file_local_path,
366 storage_adaptor_error_code_h error,
369 if (NULL != _service_adaptor_download_file_async_reply) {
370 _service_adaptor_download_file_async_reply(request_id,
371 download_file_local_path, error, response);
375 void storage_adaptor_upload_file_async_reply_cb(void *request_id,
376 storage_adaptor_file_info_h file_info,
377 storage_adaptor_error_code_h error,
380 if (NULL != _service_adaptor_upload_file_async_reply) {
381 _service_adaptor_upload_file_async_reply(request_id,
382 file_info, error, response);
386 void storage_adaptor_file_transfer_progress_reply_cb(void *request_id,
387 unsigned long long progress_size_byte,
388 unsigned long long total_size_byte,
389 storage_adaptor_error_code_h error,
392 if (NULL != _service_adaptor_file_transfer_progress_reply) {
393 _service_adaptor_file_transfer_progress_reply(request_id,
394 progress_size_byte, total_size_byte, error, response);
399 void storage_adaptor_download_state_changed_reply_cb(int file_descriptor,
400 storage_adaptor_transfer_state_e state,
401 storage_adaptor_error_code_h error,
404 if ((state == STORAGE_ADAPTOR_TRANSFER_STATE_FINISHED)
405 || (state == STORAGE_ADAPTOR_TRANSFER_STATE_CANCELED)
406 || (state == STORAGE_ADAPTOR_TRANSFER_STATE_FAILED)) {
407 close(file_descriptor);
410 if (NULL != _service_adaptor_download_state_changed_reply) {
411 long long int file_uid = _get_file_uid_from_plugin_fd(file_descriptor);
412 _service_adaptor_download_state_changed_reply(file_uid,
413 state, error, user_data);
417 void storage_adaptor_upload_state_changed_reply_cb(int file_descriptor,
418 storage_adaptor_transfer_state_e state,
419 storage_adaptor_file_info_h file_info,
420 storage_adaptor_error_code_h error,
423 if ((state == STORAGE_ADAPTOR_TRANSFER_STATE_FINISHED)
424 || (state == STORAGE_ADAPTOR_TRANSFER_STATE_CANCELED)
425 || (state == STORAGE_ADAPTOR_TRANSFER_STATE_FAILED)) {
426 close(file_descriptor);
429 if (NULL != _service_adaptor_upload_state_changed_reply) {
430 long long int file_uid = _get_file_uid_from_plugin_fd(file_descriptor);
431 _service_adaptor_upload_state_changed_reply(file_uid,
432 state, file_info, error, user_data);
436 void storage_adaptor_task_progress_reply_cb(int file_descriptor,
437 unsigned long long progress_size_byte,
438 unsigned long long total_size_byte,
439 storage_adaptor_error_code_h error,
442 if (NULL != _service_adaptor_task_progress_reply) {
443 long long int file_uid = _get_file_uid_from_plugin_fd(file_descriptor);
444 _service_adaptor_task_progress_reply(file_uid,
445 progress_size_byte, total_size_byte);
449 /* //------------------------------------------------------------------------
450 // Functions implementations
451 //------------------------------------------------------------------------ */
453 /* //////////////////////////////////////////////////////////
454 // Adaptor Defined Plugin Function
455 ////////////////////////////////////////////////////////// */
457 storage_error_code_t storage_plugin_open_file(storage_adaptor_plugin_context_h context,
458 const char *file_path,
459 storage_adaptor_file_access_mode_e mode,
460 int *file_descriptor,
461 storage_adaptor_error_code_h *error)
463 storage_error_code_t ret = STORAGE_ADAPTOR_ERROR_NONE;
465 if ((NULL == file_descriptor) || (NULL == file_path)) {
467 *error = storage_adaptor_create_error_code((int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
468 "Invalid parameter");
470 ret = STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
473 if (STORAGE_ADAPTOR_FILE_ACCESS_READ == mode) {
474 fd = open(file_path, mode);
475 } else if (STORAGE_ADAPTOR_FILE_ACCESS_WRITE == mode) {
476 fd = open(file_path, mode, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
479 *error = storage_adaptor_create_error_code((int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
480 "Invalid parameter (file mode)");
482 ret = STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
487 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
489 if (EEXIST == errno) {
490 error_code = (int64_t) STORAGE_PLUGIN_ERROR_FILE_AREADY_EXIST;
491 } else if (EACCES == errno) {
492 error_code = (int64_t) STORAGE_PLUGIN_ERROR_FILE_ACCESS_DENIED;
494 error_code = (int64_t) STORAGE_PLUGIN_ERROR_FILE_OPEN_FAILED;
497 *error = storage_adaptor_create_error_code(error_code,
501 *file_descriptor = fd;
507 storage_error_code_t storage_plugin_close_file(storage_adaptor_plugin_context_h context,
509 storage_adaptor_error_code_h *error)
511 storage_error_code_t ret = STORAGE_ADAPTOR_ERROR_NONE;
513 int r = close(file_descriptor);
515 storage_adaptor_debug("close ret : %d", r);
522 /* //////////////////////////////////////////////////////
523 // Mandatory: External adaptor management function
524 ////////////////////////////////////////////////////// */
525 storage_adaptor_h storage_adaptor_create(const char *plugins_dir)
527 if (NULL == plugins_dir) {
528 storage_adaptor_error("Invalid argument""(plugins_dir: %p", plugins_dir);
532 storage_adaptor_h storage_adaptor = (storage_adaptor_h) malloc(sizeof(storage_adaptor_t));
534 if (NULL == storage_adaptor) {
535 storage_adaptor_error("Critical : Memory allocation failed");
539 /* for forked plugin */
540 if (pipe(storage_adaptor->rd_cmd) == -1) {
541 free(storage_adaptor);
544 g_mutex_init(&storage_adaptor->rd_mutex);
545 storage_adaptor->rd_list = NULL;
547 storage_adaptor->started = 0;
548 storage_adaptor->plugins_dir = strdup(plugins_dir);
550 g_mutex_init(&storage_adaptor->storage_adaptor_mutex);
551 g_mutex_init(&storage_adaptor->plugins_mutex);
552 g_mutex_init(&storage_adaptor->adaptor_listeners_mutex);
554 g_mutex_lock(&storage_adaptor->adaptor_listeners_mutex);
555 storage_adaptor->adaptor_listeners = NULL;
556 g_mutex_unlock(&storage_adaptor->adaptor_listeners_mutex);
558 g_mutex_lock(&storage_adaptor->plugins_mutex);
559 storage_adaptor->plugins = NULL;
560 g_mutex_unlock(&storage_adaptor->plugins_mutex);
562 #ifndef FORK_PLUGIN_ARCHITECTURE
563 g_file_uid_list = g_hash_table_new_full(g_int_hash, g_int_equal, NULL, free);
566 return storage_adaptor;
569 void storage_adaptor_destroy(storage_adaptor_h adaptor)
571 if (NULL == adaptor) {
572 storage_adaptor_error("Invalid argument""(adaptor: %p)", adaptor);
576 g_mutex_lock(&adaptor->storage_adaptor_mutex);
577 if (0 != adaptor->started) {
578 storage_adaptor_error("Storage adaptor is running. Forcing stop before destroy");
579 storage_adaptor_stop(adaptor);
582 g_mutex_lock(&adaptor->plugins_mutex);
583 if (NULL != adaptor->plugins) {
584 g_list_free_full(adaptor->plugins, (GDestroyNotify) storage_adaptor_plugin_unref);
585 adaptor->plugins = NULL;
587 g_mutex_unlock(&adaptor->plugins_mutex);
589 g_mutex_lock(&adaptor->adaptor_listeners_mutex);
590 if (NULL != adaptor->adaptor_listeners) {
591 g_list_free(adaptor->adaptor_listeners);
592 adaptor->adaptor_listeners = NULL;
594 g_mutex_unlock(&adaptor->adaptor_listeners_mutex);
596 _service_adaptor_download_file_async_reply = NULL;
597 _service_adaptor_upload_file_async_reply = NULL;
598 _service_adaptor_file_transfer_progress_reply = NULL;
599 _service_adaptor_download_state_changed_reply = NULL;
600 _service_adaptor_upload_state_changed_reply = NULL;
601 _service_adaptor_task_progress_reply = NULL;
603 free(adaptor->plugins_dir);
604 adaptor->plugins_dir = NULL;
606 g_mutex_unlock(&adaptor->storage_adaptor_mutex);
608 #ifndef FORK_PLUGIN_ARCHITECTURE
609 g_hash_table_destroy(g_file_uid_list);
612 /* For forked plugin */
613 g_list_free(adaptor->rd_list);
614 close(adaptor->rd_cmd[0]);
615 close(adaptor->rd_cmd[1]);
620 int storage_adaptor_start(storage_adaptor_h adaptor)
622 storage_adaptor_debug("Starting storage adaptor");
623 if (NULL == adaptor) {
624 storage_adaptor_error("Invalid argument""(adaptor: %p)", adaptor);
625 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
628 g_mutex_lock(&adaptor->storage_adaptor_mutex);
629 int result = STORAGE_ADAPTOR_ERROR_NONE;
630 if (0 != adaptor->started) {
631 storage_adaptor_error("Storage adaptor is already started");
632 result = STORAGE_ADAPTOR_ERROR_START;
634 adaptor->started = 1;
637 if (pthread_create(&pid, NULL, _storage_adaptor_plugin_message_collector, (void *)adaptor)) {
638 adaptor->started = 0;
639 storage_adaptor_error("Could not create 3rd party plugin listener");
640 result = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
641 } else if (STORAGE_ADAPTOR_ERROR_NONE != (result = storage_adaptor_load_plugins_from_directory(adaptor, adaptor->plugins_dir))) {
642 _storage_adaptor_send_cmd_stop_listen(adaptor);
643 adaptor->started = 0;
644 storage_adaptor_error("Could not load plugins from directory");
645 result = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
647 adaptor->plugin_listener = pid;
648 storage_adaptor_info("Storage adaptor started successfully");
651 g_mutex_unlock(&adaptor->storage_adaptor_mutex);
656 int storage_adaptor_stop(storage_adaptor_h adaptor)
658 if (NULL == adaptor) {
659 storage_adaptor_error("Invalid argument""(adaptor: %p)", adaptor);
660 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
663 g_mutex_lock(&adaptor->storage_adaptor_mutex);
665 /* For forked plugin */
666 storage_adaptor_debug("stop plugin listener");
667 _storage_adaptor_send_cmd_stop_listen(adaptor);
668 pthread_join(adaptor->plugin_listener, NULL);
670 int result = STORAGE_ADAPTOR_ERROR_NONE;
671 if (0 == adaptor->started) {
672 result = STORAGE_ADAPTOR_ERROR_START;
674 if (NULL != adaptor->plugins) {
675 g_mutex_lock(&adaptor->plugins_mutex);
676 g_list_free_full(adaptor->plugins, (GDestroyNotify) storage_adaptor_plugin_unref);
677 adaptor->plugins = NULL;
678 g_mutex_unlock(&adaptor->plugins_mutex);
680 adaptor->started = 0;
681 storage_adaptor_debug("Storage adaptor stopped");
684 g_mutex_unlock(&adaptor->storage_adaptor_mutex);
688 int storage_adaptor_register_listener(storage_adaptor_h adaptor,
689 storage_adaptor_listener_h listener)
691 if ((NULL == adaptor) || (NULL == listener)) {
692 storage_adaptor_error("Invalid argument""(adaptor: %p, listener: %p)", adaptor, listener);
693 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
696 g_mutex_lock(&adaptor->adaptor_listeners_mutex);
698 adaptor->adaptor_listeners = g_list_append(adaptor->adaptor_listeners, listener);
700 g_mutex_unlock(&adaptor->adaptor_listeners_mutex);
702 _service_adaptor_download_file_async_reply =
703 (storage_adaptor_service_download_file_async_reply_cb) listener->download_file_async_reply;
704 _service_adaptor_upload_file_async_reply =
705 (storage_adaptor_service_upload_file_async_reply_cb) listener->upload_file_async_reply;
706 _service_adaptor_file_transfer_progress_reply =
707 (storage_adaptor_service_file_transfer_progress_reply_cb) listener->file_transfer_progress_reply;
708 _service_adaptor_download_state_changed_reply =
709 (storage_adaptor_service_download_state_changed_reply_cb) listener->download_state_changed_reply;
710 _service_adaptor_upload_state_changed_reply =
711 (storage_adaptor_service_upload_state_changed_reply_cb) listener->upload_state_changed_reply;
712 _service_adaptor_task_progress_reply =
713 (storage_adaptor_service_task_progress_reply_cb) listener->task_progress_reply;
715 return STORAGE_ADAPTOR_ERROR_NONE;
718 int storage_adaptor_unregister_listener(storage_adaptor_h adaptor,
719 storage_adaptor_listener_h listener)
721 if ((NULL == adaptor) || (NULL == listener)) {
722 storage_adaptor_error("Invalid argument""(adaptor: %p, listener: %p)", adaptor, listener);
723 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
726 g_mutex_lock(&adaptor->adaptor_listeners_mutex);
728 if (NULL == g_list_find(adaptor->adaptor_listeners, listener)) {
729 g_mutex_unlock(&adaptor->adaptor_listeners_mutex);
730 storage_adaptor_error("Could not find listener");
731 return STORAGE_ADAPTOR_ERROR_NOT_FOUND;
734 adaptor->adaptor_listeners = g_list_remove(adaptor->adaptor_listeners, listener);
736 g_mutex_unlock(&adaptor->adaptor_listeners_mutex);
738 _service_adaptor_download_file_async_reply = NULL;
739 _service_adaptor_upload_file_async_reply = NULL;
740 _service_adaptor_file_transfer_progress_reply = NULL;
741 _service_adaptor_download_state_changed_reply = NULL;
742 _service_adaptor_upload_state_changed_reply = NULL;
743 _service_adaptor_task_progress_reply = NULL;
745 return STORAGE_ADAPTOR_ERROR_NONE;
748 /* /////////////////////////////////////////////////////////////
749 // Plugin create / destroy / ref. count / get plugin name
750 ///////////////////////////////////////////////////////////// */
751 static storage_adaptor_plugin_h storage_adaptor_create_plugin(const char *plugin_path)
753 if (NULL == plugin_path) {
754 storage_adaptor_error("Invalid argument (plugin_path is null)");
758 void *dl_handle = dlopen(plugin_path, RTLD_LAZY);
759 if (NULL == dl_handle) {
760 storage_adaptor_error("Could not load plugin %s: %s", plugin_path, dlerror());
764 storage_adaptor_plugin_handle_h (*get_adaptee_handle)(void) = NULL;
766 get_adaptee_handle = (storage_adaptor_plugin_handle_h (*)(void)) (dlsym(dl_handle, "create_plugin_handle"));
767 if (NULL == get_adaptee_handle) {
769 storage_adaptor_error("Could not get function pointer to create_plugin_handle");
774 storage_adaptor_plugin_handle_h handle = get_adaptee_handle();
775 plugin_req_exit_void();
777 if (NULL == handle) {
779 storage_adaptor_error("Could not get adaptee handle");
783 handle->open_file = storage_plugin_open_file;
784 handle->close_file = storage_plugin_close_file;
786 storage_adaptor_plugin_h plugin = (storage_adaptor_plugin_h) calloc(1, sizeof(storage_adaptor_plugin_t));
787 if (NULL == plugin) {
789 storage_adaptor_error("Could not create plugin object");
793 storage_adaptor_plugin_listener_h listener =
794 (storage_adaptor_plugin_listener_h) calloc(1, sizeof(storage_adaptor_plugin_listener_t));
796 if (NULL == listener) {
799 storage_adaptor_error("Could not create listener object");
803 plugin->path = g_strdup(plugin_path);
804 plugin->handle = handle;
805 plugin->dl_handle = dl_handle;
806 plugin->ref_counter = 0;
808 plugin->type = PLUGIN_TYPE_INHOUSE;
810 g_mutex_init(&plugin->ref_counter_mutex);
811 g_mutex_init(&plugin->plugin_listener_mutex);
812 g_mutex_init(&plugin->contexts_mutex);
813 plugin->contexts = NULL;
815 listener->storage_adaptor_download_file_async_reply = storage_adaptor_download_file_async_reply_cb;
816 listener->storage_adaptor_upload_file_async_reply = storage_adaptor_upload_file_async_reply_cb;
817 listener->storage_adaptor_file_transfer_progress_reply = storage_adaptor_file_transfer_progress_reply_cb;
818 listener->storage_adaptor_download_state_changed_reply = storage_adaptor_download_state_changed_reply_cb;
819 listener->storage_adaptor_upload_state_changed_reply = storage_adaptor_upload_state_changed_reply_cb;
820 listener->storage_adaptor_task_progress_reply = storage_adaptor_task_progress_reply_cb;
824 plugin->handle->set_listener(listener);
825 plugin_req_exit_void();
827 g_mutex_lock(&plugin->plugin_listener_mutex);
828 plugin->plugin_listener = listener;
829 g_mutex_unlock(&plugin->plugin_listener_mutex);
834 static void storage_adaptor_destroy_plugin(storage_adaptor_plugin_h plugin)
836 if (NULL == plugin) {
837 storage_adaptor_error("Invalid argument""(plugin: %p)", plugin);
841 if (NULL != plugin->handle) {
842 plugin->handle->destroy_handle(plugin->handle);
844 g_mutex_lock(&plugin->plugin_listener_mutex);
847 plugin->handle->unset_listener();
848 plugin_req_exit_void();
850 g_mutex_unlock(&plugin->plugin_listener_mutex);
852 plugin->handle = NULL;
855 if (NULL != plugin->dl_handle) {
856 dlclose(plugin->dl_handle);
857 plugin->dl_handle = NULL;
866 static int storage_adaptor_load_plugins_from_directory(storage_adaptor_h adaptor,
867 const char *dir_path)
869 char *plugin_path = NULL;
871 struct dirent dir_entry, *result = NULL;
873 storage_adaptor_debug("Starting load plugins from directory");
875 if ((NULL == adaptor) || (NULL == dir_path)) {
876 storage_adaptor_error("Invalid argument""(adaptor: %p, dir_path: %p)", adaptor, dir_path);
877 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
880 dir = opendir(dir_path);
882 storage_adaptor_error("Could not open dir path (%s)", dir_path);
883 return STORAGE_ADAPTOR_ERROR_NOT_FOUND;
886 int ret = STORAGE_ADAPTOR_ERROR_NONE;
887 while (0 == (readdir_r(dir, &dir_entry, &result))) {
889 if (NULL == result) {
890 storage_adaptor_error("Could not open directory %s", plugin_path);
894 if (dir_entry.d_type & DT_DIR) {
898 plugin_path = g_strconcat(dir_path, "/", dir_entry.d_name, NULL);
899 storage_adaptor_plugin_h plugin = storage_adaptor_create_plugin(plugin_path);
901 if (NULL != plugin) {
902 storage_adaptor_debug("Loaded plugin: %s", plugin_path);
903 plugin->adaptor = adaptor;
904 storage_adaptor_plugin_ref(plugin);
905 g_mutex_lock(&adaptor->plugins_mutex);
906 adaptor->plugins = g_list_append(adaptor->plugins, plugin);
907 g_mutex_unlock(&adaptor->plugins_mutex);
909 storage_adaptor_error("Could not load plugin %s", plugin_path);
916 storage_adaptor_debug("End load plugins from directory");
921 static int storage_adaptor_has_plugin(storage_adaptor_h adaptor,
922 storage_adaptor_plugin_h plugin)
924 if ((NULL == adaptor) || (NULL == plugin)) {
925 storage_adaptor_error("Invalid argument""(adaptor: %p, plugin: %p)", adaptor, plugin);
931 g_mutex_lock(&adaptor->plugins_mutex);
932 if (NULL != g_list_find(adaptor->plugins, plugin)) {
935 g_mutex_unlock(&adaptor->plugins_mutex);
940 void storage_adaptor_plugin_ref(storage_adaptor_plugin_h plugin)
942 if (NULL == plugin) {
943 storage_adaptor_error("Invalid argument""(plugin: %p)", plugin);
947 g_mutex_lock(&plugin->ref_counter_mutex);
948 plugin->ref_counter = plugin->ref_counter + 1;
949 if (NULL != plugin->handle) {
950 storage_adaptor_info("plugin name : %s, ref_counter: %d",
951 plugin->handle->plugin_uri, plugin->ref_counter);
953 storage_adaptor_info("ref_counter: %d", plugin->ref_counter);
955 g_mutex_unlock(&plugin->ref_counter_mutex);
958 void storage_adaptor_plugin_unref(storage_adaptor_plugin_h plugin)
960 if (NULL == plugin) {
961 storage_adaptor_error("Invalid argument""(plugin: %p)", plugin);
965 int should_destroy = 0;
967 g_mutex_lock(&plugin->ref_counter_mutex);
968 plugin->ref_counter = plugin->ref_counter - 1;
969 if (NULL != plugin->handle) {
970 storage_adaptor_info("plugin name : %s, ref_counter: %d",
971 plugin->handle->plugin_uri, plugin->ref_counter);
973 storage_adaptor_info("ref_counter: %d", plugin->ref_counter);
975 if (0 >= plugin->ref_counter) {
978 g_mutex_unlock(&plugin->ref_counter_mutex);
980 if (should_destroy) {
981 storage_adaptor_debug("Plugin is being destroyed");
982 storage_adaptor_destroy_plugin(plugin);
986 /* For 3rd party plugin packages */
987 int storage_adaptor_load_plugin_from_package(storage_adaptor_h adaptor,
988 const char *package_id,
989 const char *plugin_path)
994 if (pipe(adaptor_fd) == -1) {
995 storage_adaptor_debug("pipe creation error, can not load plugin package");
996 } else if (pipe(plugin_fd) == -1) {
997 close(adaptor_fd[0]);
998 close(adaptor_fd[1]);
999 storage_adaptor_debug("pipe creation error[2], can not load plugin package");
1001 g_process_identity = fork();
1002 if (0 == g_process_identity) { /* child */
1003 storage_adaptor_debug_func("[CHILD PROCESS] forked success (PID : %d, id : %d)", (int)getpid());
1004 /* storage_adaptor_info("set uid : %d", setuid(5000)); */
1005 /* TODO remove temp code */
1006 /* change_smack_rule("org.tizen.tui4"); */
1007 /* smack_set_label_for_self(package_id); */
1009 storage_adaptor_plugin_h plugin = NULL;
1010 plugin = storage_adaptor_create_plugin(plugin_path);
1011 if (NULL == plugin) {
1012 storage_adaptor_error("[CHILD PROCESS] Load plugin failed");
1015 g_child_plugin = plugin;
1016 plugin->rd = plugin_fd[0];
1017 close(plugin_fd[1]);
1018 plugin->wd = adaptor_fd[1];
1019 close(adaptor_fd[0]);
1020 void *temp = _storage_plugin_request_collector((void *)plugin);
1021 storage_adaptor_debug_func("[CHILD PROCESS] exit %p", temp);
1023 } else if (0 < g_process_identity) { /* parent */
1024 storage_adaptor_debug_func("[PARENT PROCESS] forked success (PID : %d)", (int)getpid());
1025 storage_adaptor_plugin_h _plugin = (storage_adaptor_plugin_h) calloc(1, sizeof(storage_adaptor_plugin_t));
1026 if (NULL == _plugin) {
1027 storage_adaptor_error("[PARENT PROCESS] memory allocation failed");
1031 _plugin->ref_counter = 0;
1032 g_mutex_init(&_plugin->ref_counter_mutex);
1033 g_mutex_init(&_plugin->message_mutex);
1035 _plugin->handle = __storage_adaptor_create_3rd_party_plugin_handle(package_id);
1037 _plugin->type = PLUGIN_TYPE_3RD_PARTY;
1038 _plugin->pid = g_process_identity;
1039 _plugin->rd = adaptor_fd[0];
1040 close(adaptor_fd[1]);
1041 _plugin->wd = plugin_fd[1];
1042 close(plugin_fd[0]);
1044 _storage_adaptor_send_cmd_add_fd(adaptor, _plugin->rd);
1046 _plugin->adaptor = adaptor;
1047 storage_adaptor_plugin_ref(_plugin);
1048 g_mutex_lock(&adaptor->plugins_mutex);
1049 adaptor->plugins = g_list_append(adaptor->plugins, _plugin);
1050 g_mutex_unlock(&adaptor->plugins_mutex);
1052 close(adaptor_fd[0]);
1053 close(adaptor_fd[1]);
1054 close(plugin_fd[0]);
1055 close(plugin_fd[1]);
1056 storage_adaptor_debug("fork error, can not load plugin package");
1063 /* //////////////////////////////////////////////////////
1064 // Plugin context create / destroy
1065 ////////////////////////////////////////////////////// */
1066 storage_adaptor_plugin_context_h storage_adaptor_create_plugin_context(storage_adaptor_plugin_h plugin,
1068 const char *app_secret,
1069 const char *access_token,
1072 const char *service_name)
1074 storage_adaptor_debug("Starting storage_adaptor_create_plugin_context");
1076 if (NULL == plugin) {
1077 storage_adaptor_error("Invalid argument""(plugin: %p)", plugin);
1081 if (NULL != plugin->handle) {
1082 storage_adaptor_plugin_context_h plugin_context = NULL;
1084 if (plugin->type == PLUGIN_TYPE_3RD_PARTY) {
1085 plugin_context = (storage_adaptor_plugin_context_h) calloc(1, sizeof(storage_adaptor_plugin_context_t));
1086 if (NULL == plugin_context) {
1089 plugin_context->plugin_handle = plugin;
1093 plugin->handle->create_context(&plugin_context, SAFE_ADD_STRING(app_id), SAFE_ADD_STRING(app_secret),
1094 SAFE_ADD_STRING(access_token), SAFE_ADD_STRING(cid), SAFE_ADD_STRING(uid));
1095 plugin_req_exit_void();
1097 if (NULL == plugin_context) {
1098 storage_adaptor_error("Create context failed");
1102 /* For forked plugin */
1103 g_mutex_lock(&plugin->contexts_mutex);
1104 plugin->contexts = g_list_append(plugin->contexts, (gpointer)plugin_context);
1105 g_mutex_unlock(&plugin->contexts_mutex);
1107 plugin_context->plugin_uri = strdup(plugin->handle->plugin_uri);
1108 plugin_context->service_name = strdup(service_name ? service_name : "");
1109 return plugin_context;
1111 storage_adaptor_error("Plugin handle is null");
1114 storage_adaptor_debug("End storage_adaptor_create_plugin_context");
1118 void storage_adaptor_destroy_plugin_context(storage_adaptor_plugin_h plugin,
1119 storage_adaptor_plugin_context_h plugin_context)
1121 if ((NULL == plugin) || (NULL == plugin_context)) {
1122 storage_adaptor_error("Invalid argument""(plugin: %p, plugin_context: %p)", plugin, plugin_context);
1126 free(plugin_context->plugin_uri);
1127 plugin_context->plugin_uri = NULL;
1128 /* free(plugin_context->service_name); */
1129 /* plugin_context->service_name = NULL; */
1131 if (NULL != plugin->handle) {
1133 plugin->handle->destroy_context(plugin_context);
1134 plugin_req_exit_void();
1136 storage_adaptor_error("Plugin handle is null");
1140 /* //////////////////////////////////////////////////////
1141 // Get plugin by plugin name
1142 ////////////////////////////////////////////////////// */
1143 storage_adaptor_plugin_h storage_adaptor_get_plugin_by_name(storage_adaptor_h adaptor,
1144 const char *plugin_uri)
1146 storage_adaptor_debug("Starting storage_adaptor_get_plugin_by_name");
1148 if ((NULL == adaptor) || (NULL == plugin_uri)) {
1149 storage_adaptor_error("Invalid argument""(adaptor: %p, plugin_uri: %p)", adaptor, plugin_uri);
1153 storage_adaptor_plugin_h plugin = NULL;
1154 g_mutex_lock(&adaptor->plugins_mutex);
1155 int count = g_list_length(adaptor->plugins);
1157 for (i = 0; i < count; i++) {
1158 storage_adaptor_plugin_h temp_plugin = g_list_nth_data(adaptor->plugins, i);
1159 if (NULL != temp_plugin) {
1160 if (0 == strcmp(temp_plugin->handle->plugin_uri, plugin_uri)) {
1161 storage_adaptor_plugin_ref(temp_plugin);
1162 plugin = temp_plugin;
1163 g_mutex_unlock(&adaptor->plugins_mutex);
1168 g_mutex_unlock(&adaptor->plugins_mutex);
1173 /* //////////////////////////////////////////////////////
1174 // Plugin load / unload / get plugin list
1175 ////////////////////////////////////////////////////// */
1176 int storage_adaptor_load_plugin(storage_adaptor_h adaptor,
1177 const char *plugin_path)
1179 if ((NULL == adaptor) || (NULL == plugin_path)) {
1180 storage_adaptor_error("Invalid argument""(adaptor: %p, plugin_path: %p)", adaptor, plugin_path);
1181 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
1184 if (0 == adaptor->started) {
1185 storage_adaptor_error("Storage adaptor is not started");
1186 return STORAGE_ADAPTOR_ERROR_START;
1189 storage_adaptor_plugin_h plugin = storage_adaptor_create_plugin(plugin_path);
1190 if (NULL == plugin) {
1191 storage_adaptor_error("Could not load plugin %s", plugin_path);
1192 return STORAGE_ADAPTOR_ERROR_CREATE;
1195 plugin->adaptor = adaptor;
1196 storage_adaptor_plugin_ref(plugin);
1198 g_mutex_lock(&adaptor->plugins_mutex);
1199 adaptor->plugins = g_list_append(adaptor->plugins, plugin);
1200 g_mutex_unlock(&adaptor->plugins_mutex);
1202 return STORAGE_ADAPTOR_ERROR_NONE;
1205 int storage_adaptor_unload_plugin(storage_adaptor_h adaptor,
1206 storage_adaptor_plugin_h plugin)
1208 if ((NULL == adaptor) || (NULL == plugin)) {
1209 storage_adaptor_error("Invalid argument""(adaptor: %p, plugin: %p)", adaptor, plugin);
1210 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
1213 if (0 == adaptor->started) {
1214 storage_adaptor_error("Storage adaptor is not started");
1215 return STORAGE_ADAPTOR_ERROR_START;
1218 if (!storage_adaptor_has_plugin(adaptor, plugin)) {
1219 storage_adaptor_error("Storage adaptor has no plugin");
1220 return STORAGE_ADAPTOR_ERROR_NOT_FOUND;
1223 plugin->adaptor = NULL;
1225 g_mutex_lock(&adaptor->plugins_mutex);
1226 adaptor->plugins = g_list_remove(adaptor->plugins, plugin);
1227 g_mutex_unlock(&adaptor->plugins_mutex);
1229 storage_adaptor_plugin_unref(plugin);
1231 return STORAGE_ADAPTOR_ERROR_NONE;
1234 GList *storage_adaptor_get_plugins(storage_adaptor_h adaptor)
1236 if (NULL == adaptor) {
1237 storage_adaptor_error("Invalid argument""(adaptor: %p)", adaptor);
1241 GList *plugins = NULL;
1243 g_mutex_lock(&adaptor->plugins_mutex);
1244 int plugins_count = g_list_length(adaptor->plugins);
1246 for (i = 0; i < plugins_count; i++) {
1247 storage_adaptor_plugin_h plugin = g_list_nth_data(adaptor->plugins, i);
1248 if (NULL != plugin) {
1249 storage_adaptor_plugin_ref(plugin);
1250 plugins = g_list_append(plugins, plugin);
1253 g_mutex_unlock(&adaptor->plugins_mutex);
1258 /* ////////////////////////////////////////////////////////////
1259 // Adaptor Etc Functions
1260 //////////////////////////////////////////////////////////// */
1262 /* Get plugin name by plugin */
1263 void storage_adaptor_get_plugin_uri(storage_adaptor_plugin_h plugin,
1266 if ((NULL == plugin) || (NULL == plugin_uri)) {
1267 storage_adaptor_error("Invalid argument""(plugin: %p)", plugin);
1270 if ((NULL != plugin->handle) && (NULL != plugin->handle->plugin_uri)) {
1271 *plugin_uri = strdup(plugin->handle->plugin_uri);
1276 * Refresh access token
1279 storage_error_code_t storage_adaptor_refresh_access_token(storage_adaptor_plugin_context_h context,
1280 const char *new_access_token)
1282 if ((NULL == context) || (NULL == new_access_token) || (0 >= strlen(new_access_token))) {
1283 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
1285 storage_adaptor_debug_secure("New access token : %s", new_access_token);
1287 free(context->access_token);
1288 context->access_token = NULL;
1289 context->access_token = strdup(new_access_token);
1291 return STORAGE_ADAPTOR_ERROR_NONE;
1296 storage_error_code_t storage_adaptor_refresh_uid(storage_adaptor_plugin_context_h context,
1297 const char *new_uid)
1299 if ((NULL == context) || (NULL == new_uid) || (0 >= strlen(new_uid))) {
1300 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
1302 storage_adaptor_debug_secure("New uid : %s", new_uid);
1305 context->uid = NULL;
1306 context->uid = strdup(new_uid);
1308 return STORAGE_ADAPTOR_ERROR_NONE;
1313 storage_adaptor_error_code_h storage_adaptor_create_error_code(const int64_t code,
1319 storage_adaptor_error_code_h error_code =
1320 (storage_adaptor_error_code_h) calloc(1, sizeof(storage_adaptor_error_code_t));
1321 if (NULL != error_code) {
1322 error_code->code = code;
1323 error_code->msg = strdup(msg);
1329 void storage_adaptor_destroy_error_code(storage_adaptor_error_code_h *error_code)
1331 if ((NULL != error_code) && (NULL != (*error_code))) {
1332 free((*error_code)->msg);
1333 (*error_code)->msg = NULL;
1340 storage_adaptor_file_info_h storage_adaptor_create_file_info(void)
1342 storage_adaptor_file_info_h _file_info = NULL;
1343 _file_info = (storage_adaptor_file_info_h) calloc(1, sizeof(storage_adaptor_file_info_t));
1345 storage_adaptor_media_meta_s *_media_meta = NULL;
1346 _media_meta = (storage_adaptor_media_meta_s *) calloc(1, sizeof(storage_adaptor_media_meta_s));
1348 storage_adaptor_cloud_meta_s *_cloud_meta = NULL;
1349 _cloud_meta = (storage_adaptor_cloud_meta_s *) calloc(1, sizeof(storage_adaptor_cloud_meta_s));
1351 if ((NULL == _file_info) || (NULL == _media_meta) || (NULL == _cloud_meta)) {
1359 _media_meta->mime_type = NULL;
1360 _media_meta->title = NULL;
1361 _media_meta->album = NULL;
1362 _media_meta->artist = NULL;
1363 _media_meta->genere = NULL;
1364 _media_meta->recorded_date = NULL;
1365 _media_meta->width = -1;
1366 _media_meta->height = -1;
1367 _media_meta->duration = -1;
1368 _media_meta->copyright = NULL;
1369 _media_meta->track_num = NULL;
1370 _media_meta->description = NULL;
1371 _media_meta->composer = NULL;
1372 _media_meta->year = NULL;
1373 _media_meta->bitrate = -1;
1374 _media_meta->samplerate = -1;
1375 _media_meta->channel = -1;
1376 _media_meta->extra_media_meta = NULL;
1378 _cloud_meta->service_name = NULL;
1379 _cloud_meta->usage_byte = 0ULL;
1380 _cloud_meta->quota_byte = 0ULL;
1381 _cloud_meta->extra_cloud_meta = NULL;
1383 _file_info->plugin_uri = NULL;
1384 _file_info->object_id = NULL;
1385 _file_info->storage_path = NULL;
1386 _file_info->file_size = 0ULL;
1388 /* private only!! */
1389 _file_info->revision = -1;
1390 _file_info->timestamp = 0ULL;
1391 _file_info->type = NULL;
1392 _file_info->deleted = -1;
1393 _file_info->expired_time = 0ULL;
1394 _file_info->download_count = -0U;
1395 _file_info->max_download_count = -0U;
1396 _file_info->file_info_index = -1;
1397 _file_info->tag = NULL;
1398 _file_info->file_share_token = NULL;
1401 _file_info->created_time = 0ULL;
1402 _file_info->modified_time = 0ULL;
1403 _file_info->file_info_index = -1;
1404 _file_info->content_type = STORAGE_ADAPTOR_CONTENT_TYPE_DEFAULT;
1405 _file_info->media_meta = _media_meta;
1406 _file_info->cloud_meta = _cloud_meta;
1407 _file_info->extra_file_info = NULL;
1412 int storage_adaptor_destroy_file_info(storage_adaptor_file_info_h *file_info)
1414 if (NULL == file_info) {
1418 if (NULL == *file_info) {
1421 storage_adaptor_file_info_h _file_info = *file_info;
1423 free(_file_info->plugin_uri);
1424 free(_file_info->object_id);
1425 free(_file_info->storage_path);
1426 free(_file_info->extra_file_info);
1427 free(_file_info->type);
1428 free(_file_info->tag);
1430 storage_adaptor_media_meta_s *_media_meta = _file_info->media_meta;
1432 if (NULL != _media_meta) {
1433 free(_media_meta->mime_type);
1434 free(_media_meta->title);
1435 free(_media_meta->album);
1436 free(_media_meta->artist);
1437 free(_media_meta->genere);
1438 free(_media_meta->recorded_date);
1439 free(_media_meta->copyright);
1440 free(_media_meta->track_num);
1441 free(_media_meta->description);
1442 free(_media_meta->composer);
1443 free(_media_meta->year);
1444 free(_media_meta->extra_media_meta);
1447 storage_adaptor_cloud_meta_s *_cloud_meta = _file_info->cloud_meta;
1449 if (NULL != _cloud_meta) {
1450 free(_cloud_meta->service_name);
1451 free(_cloud_meta->extra_cloud_meta);
1455 if (NULL != _file_info->file_share_token) {
1456 free(_file_info->file_share_token->public_token);
1457 _file_info->file_share_token->public_token = NULL;
1459 free(_file_info->file_share_token->auth_code);
1460 _file_info->file_share_token->auth_code = NULL;
1462 free(_file_info->file_share_token);
1465 _file_info->plugin_uri = NULL;
1466 _file_info->object_id = NULL;
1467 _file_info->storage_path = NULL;
1468 _file_info->revision = -1;
1469 _file_info->timestamp = 0ULL;
1470 _file_info->type = NULL;
1471 _file_info->file_size = 0ULL;
1472 _file_info->deleted = -1;
1473 _file_info->expired_time = 0ULL;
1474 _file_info->download_count = 0U;
1475 _file_info->max_download_count = 0U;
1476 _file_info->file_info_index = -1;
1477 _file_info->tag = NULL;
1478 _file_info->file_share_token = NULL;
1481 free((*file_info)->media_meta);
1482 free((*file_info)->cloud_meta);
1486 return STORAGE_ADAPTOR_ERROR_NONE;
1489 void __assign_error_code(storage_adaptor_error_code_h *error, const int64_t code, const char *msg)
1491 if (NULL != error) {
1492 *error = storage_adaptor_create_error_code(code, msg);
1496 /* ////////////////////////////////////////////////////////////
1497 // Adaptor Plugin call Functions
1498 //////////////////////////////////////////////////////////// */
1502 /* ////////////////////// Public feature //////////////////////////// */
1505 storage_error_code_t storage_adaptor_open_file(storage_adaptor_plugin_h plugin,
1506 storage_adaptor_plugin_context_h context,
1507 const char *file_path,
1508 storage_adaptor_file_access_mode_e mode,
1509 long long int *file_uid,
1510 storage_adaptor_error_code_h *error)
1512 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1513 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1515 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1516 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1518 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1519 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1522 storage_adaptor_check_param_equal(NULL, file_uid, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1523 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (file_uid)"));
1526 storage_adaptor_check_param_equal(NULL, plugin->handle->open_file, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1527 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (open file)"));
1530 storage_error_code_t ret = plugin->handle->open_file(context, file_path, mode, &plugin_fd, error);
1531 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
1532 *file_uid = _get_file_uid_from_plugin_fd(plugin_fd);
1534 #ifndef FORK_PLUGIN_ARCHITECTURE
1535 long long int *buf = (long long int *) calloc(1, sizeof(long long int));
1538 g_hash_table_insert(g_file_uid_list, (void *)&plugin_fd, (void *)buf);
1542 #ifdef DEBUG_ADAPTOR_PARAMS
1543 storage_adaptor_debug_func("plugin fd (%d), file uid(%lld)", plugin_fd, *file_uid);
1551 storage_error_code_t storage_adaptor_close_file(storage_adaptor_plugin_h plugin,
1552 storage_adaptor_plugin_context_h context,
1553 long long int file_uid,
1554 storage_adaptor_error_code_h *error)
1556 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1557 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1559 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1560 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1562 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1563 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1566 storage_adaptor_check_param_equal(NULL, plugin->handle->close_file, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1567 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (close file)"));
1569 int plugin_fd = _get_plugin_fd_from_file_uid(file_uid);
1570 storage_error_code_t ret = plugin->handle->close_file(context, plugin_fd, error);
1572 #ifndef FORK_PLUGIN_ARCHITECTURE
1573 g_hash_table_remove(g_file_uid_list, (void *)&plugin_fd);
1576 #ifdef DEBUG_ADAPTOR_PARAMS
1577 storage_adaptor_debug_func("plugin fd (%d), file uid(%lld)", plugin_fd, file_uid);
1584 storage_error_code_t storage_adaptor_start_upload_task(storage_adaptor_plugin_h plugin,
1585 storage_adaptor_plugin_context_h context,
1586 long long int src_file_descriptor, /* read only opened */
1587 const char *upload_dir_path,
1588 const char *file_name,
1590 storage_adaptor_error_code_h *error,
1593 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1594 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1596 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1597 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1599 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1600 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1603 storage_adaptor_check_param_equal(NULL, plugin->handle->start_upload_task, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1604 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (start_upload_task)"));
1606 storage_error_code_t ret = STORAGE_ADAPTOR_ERROR_NONE;
1608 #ifdef DEBUG_ADAPTOR_PARAMS
1609 storage_adaptor_debug_func("========== %s START ==========", __FUNCTION__);
1610 storage_adaptor_debug_func("[in] file_uid (%lld)", src_file_descriptor);
1611 storage_adaptor_debug_func("[in] path (%s / %s)", upload_dir_path, file_name);
1612 storage_adaptor_debug_func("[in] need progress (%d)", need_progress ? 1 : 0);
1615 int plugin_fd = _get_plugin_fd_from_file_uid(src_file_descriptor);
1617 ret = plugin->handle->start_upload_task(context, plugin_fd,
1618 upload_dir_path, file_name, need_progress, error, user_data);
1619 plugin_req_exit(ret, plugin, error);
1625 storage_error_code_t storage_adaptor_start_download_task(storage_adaptor_plugin_h plugin,
1626 storage_adaptor_plugin_context_h context,
1627 const char *storage_dir_path,
1628 const char *file_name,
1629 long long int dst_file_descriptor, /* write only opened */
1631 storage_adaptor_error_code_h *error,
1634 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1635 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1637 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1638 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1640 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1641 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1644 storage_adaptor_check_param_equal(NULL, plugin->handle->start_download_task, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1645 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (start_download_task)"));
1647 storage_error_code_t ret = STORAGE_ADAPTOR_ERROR_NONE;
1649 #ifdef DEBUG_ADAPTOR_PARAMS
1650 storage_adaptor_debug_func("========== %s START ==========", __FUNCTION__);
1651 storage_adaptor_debug_func("[in] file_uid (%lld)", dst_file_descriptor);
1652 storage_adaptor_debug_func("[in] path (%s / %s)", storage_dir_path, file_name);
1653 storage_adaptor_debug_func("[in] need progress (%d)", need_progress ? 1 : 0);
1656 int plugin_fd = _get_plugin_fd_from_file_uid(dst_file_descriptor);
1658 ret = plugin->handle->start_download_task(context, storage_dir_path, file_name,
1659 plugin_fd, need_progress, error, user_data);
1660 plugin_req_exit(ret, plugin, error);
1666 storage_error_code_t storage_adaptor_start_download_thumb_task(storage_adaptor_plugin_h plugin,
1667 storage_adaptor_plugin_context_h context,
1668 const char *storage_dir_path,
1669 const char *file_name,
1670 long long int dst_file_descriptor, /* write only opened */
1671 int thumbnail_size, /* level (defined plugin SPEC) */
1673 storage_adaptor_error_code_h *error,
1676 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1677 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1679 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1680 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1682 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1683 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1686 storage_adaptor_check_param_equal(NULL, plugin->handle->start_download_thumb_task, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1687 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (start_download_thumb_task)"));
1689 storage_error_code_t ret = STORAGE_ADAPTOR_ERROR_NONE;
1691 #ifdef DEBUG_ADAPTOR_PARAMS
1692 storage_adaptor_debug_func("========== %s START ==========", __FUNCTION__);
1693 storage_adaptor_debug_func("[in] file_uid (%lld)", dst_file_descriptor);
1694 storage_adaptor_debug_func("[in] path (%s / %s)", storage_dir_path, file_name);
1695 storage_adaptor_debug_func("[in] need progress (%d)", need_progress ? 1 : 0);
1698 int plugin_fd = _get_plugin_fd_from_file_uid(dst_file_descriptor);
1700 ret = plugin->handle->start_download_thumb_task(context, storage_dir_path, file_name,
1701 plugin_fd, thumbnail_size, need_progress, error, user_data);
1702 plugin_req_exit(ret, plugin, error);
1709 storage_error_code_t storage_adaptor_cancel_upload_task(storage_adaptor_plugin_h plugin,
1710 storage_adaptor_plugin_context_h context,
1711 long long int file_uid,
1712 storage_adaptor_error_code_h *error)
1714 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1715 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1717 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1718 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1720 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1721 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1724 storage_adaptor_check_param_equal(NULL, plugin->handle->cancel_upload_task, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1725 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (cancel_upload_task)"));
1727 storage_error_code_t ret = STORAGE_ADAPTOR_ERROR_NONE;
1729 int plugin_fd = _get_plugin_fd_from_file_uid(file_uid);
1731 ret = plugin->handle->cancel_upload_task(context, plugin_fd, error);
1732 plugin_req_exit(ret, plugin, error);
1738 storage_error_code_t storage_adaptor_cancel_download_task(storage_adaptor_plugin_h plugin,
1739 storage_adaptor_plugin_context_h context,
1740 long long int file_uid,
1741 storage_adaptor_error_code_h *error)
1743 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1744 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1746 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1747 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1749 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1750 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1753 storage_adaptor_check_param_equal(NULL, plugin->handle->cancel_download_task, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1754 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (cancel_download_task)"));
1756 storage_error_code_t ret = STORAGE_ADAPTOR_ERROR_NONE;
1758 int plugin_fd = _get_plugin_fd_from_file_uid(file_uid);
1760 ret = plugin->handle->cancel_download_task(context, plugin_fd, error);
1761 plugin_req_exit(ret, plugin, error);
1768 storage_error_code_t storage_adaptor_cancel_download_thumb_task(storage_adaptor_plugin_h plugin,
1769 storage_adaptor_plugin_context_h context,
1770 long long int file_uid,
1771 storage_adaptor_error_code_h *error)
1773 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1774 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1776 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1777 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1779 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1780 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1783 storage_adaptor_check_param_equal(NULL, plugin->handle->cancel_download_thumb_task, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1784 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (cancel_download_thumb_task)"));
1786 storage_error_code_t ret = STORAGE_ADAPTOR_ERROR_NONE;
1788 int plugin_fd = _get_plugin_fd_from_file_uid(file_uid);
1790 ret = plugin->handle->cancel_download_thumb_task(context, plugin_fd, error);
1791 plugin_req_exit(ret, plugin, error);
1797 /* ////////////////////// Common feature //////////////////////////// */
1800 * @brief Set server information for Storage Plugin
1802 * @param[in] plugin specifies Storage Adaptor Plugin handle
1803 * @param[in] context specifies Storage Adaptor Plugin Context handle
1804 * @param[in] server_info specifies server information for Storage Plugin
1805 * @param[in] request specifies optional parameter
1806 * @param[out] error specifies error code
1807 * @param[out] response specifies optional parameter
1808 * @return 0 on success, otherwise a positive error value
1809 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
1812 storage_error_code_t storage_adaptor_set_server_info(storage_adaptor_plugin_h plugin,
1813 storage_adaptor_plugin_context_h context,
1814 GHashTable *server_info,
1816 storage_adaptor_error_code_h *error,
1819 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1820 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1822 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1823 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1825 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1826 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1829 storage_adaptor_check_param_equal(NULL, plugin->handle->set_server_info, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1830 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (set_server_info)"));
1832 #ifdef DEBUG_ADAPTOR_PARAMS
1833 storage_adaptor_debug_func("========== %s START ==========", __FUNCTION__);
1834 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
1835 context->app_id, context->access_token, context->uid);
1836 storage_adaptor_debug_func("[in] server_info [addr(%p)]", server_info);
1837 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
1841 storage_error_code_t ret = plugin->handle->set_server_info(
1842 context, server_info, request, error, response);
1843 plugin_req_exit(ret, plugin, error);
1845 #ifdef DEBUG_ADAPTOR_PARAMS
1846 storage_adaptor_debug_func("[out] return code (%d)", ret);
1847 if ((NULL != error) && (NULL != *error)) {
1848 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
1849 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
1851 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
1852 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
1859 * @brief Makes a directory at cloud
1860 * @param[in] upload_file_local_path specifies local path of the file to be uploaded
1862 * @param[in] plugin specifies Storage Adaptor Plugin handle
1863 * @param[in] context specifies Storage Adaptor Plugin Context handle
1864 * @param[in] parent_folder_storage_path specifies path to locate the folder you want to create
1865 * @param[in] folder_name specifies folder name to be created at cloud
1866 * @param[in] request specifies optional parameter
1867 * @param[out] file_info specifies Storage Adaptor File Info handle
1868 * @param[out] error specifies error code
1869 * @param[out] response specifies optional parameter
1870 * @return 0 on success, otherwise a negative error value
1871 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
1873 storage_error_code_t storage_adaptor_make_directory(storage_adaptor_plugin_h plugin,
1874 storage_adaptor_plugin_context_h context,
1875 const char *parent_folder_storage_path,
1876 const char *folder_name,
1878 storage_adaptor_file_info_h *file_info,
1879 storage_adaptor_error_code_h *error,
1882 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1883 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1885 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1886 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1888 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1889 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1892 storage_adaptor_check_param_equal(NULL, plugin->handle->make_directory, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1893 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (make_directory)"));
1895 #ifdef DEBUG_ADAPTOR_PARAMS
1896 storage_adaptor_debug_func("========== %s START ==========", __FUNCTION__);
1897 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
1898 context->app_id, context->access_token, context->uid);
1899 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
1900 storage_adaptor_debug_func("[in] folder_name (%s)", folder_name);
1901 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
1905 storage_error_code_t ret = plugin->handle->make_directory(
1906 context, parent_folder_storage_path, folder_name, request, file_info, error, response);
1907 plugin_req_exit(ret, plugin, error);
1909 #ifdef DEBUG_ADAPTOR_PARAMS
1910 storage_adaptor_debug_func("[out] return code (%d)", ret);
1911 if ((NULL != file_info) && (NULL != (*file_info))) {
1912 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
1914 if ((NULL != error) && (NULL != *error)) {
1915 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
1916 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
1918 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
1919 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
1926 * @brief Removes a directory at cloud
1928 * @param[in] plugin specifies Storage Adaptor Plugin handle
1929 * @param[in] context specifies Storage Adaptor Plugin Context handle
1930 * @param[in] parent_folder_storage_path specifies parent folder path of folder you want to delete
1931 * @param[in] folder_name specifies folder name to be deleted from cloud
1932 * @param[in] request specifies optional parameter
1933 * @param[out] file_info specifies Storage Adaptor File Info handle
1934 * @param[out] error specifies error code
1935 * @param[out] response specifies optional parameter
1936 * @return 0 on success, otherwise a negative error value
1937 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
1939 storage_error_code_t storage_adaptor_remove_directory(storage_adaptor_plugin_h plugin,
1940 storage_adaptor_plugin_context_h context,
1941 const char *parent_folder_storage_path,
1942 const char *folder_name,
1944 storage_adaptor_file_info_h *file_info,
1945 storage_adaptor_error_code_h *error,
1948 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1949 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1951 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1952 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1954 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1955 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1958 storage_adaptor_check_param_equal(NULL, plugin->handle->remove_directory, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1959 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (remove_directory)"));
1961 #ifdef DEBUG_ADAPTOR_PARAMS
1962 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
1963 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
1964 context->app_id, context->access_token, context->uid);
1965 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
1966 storage_adaptor_debug_func("[in] folder_name (%s)", folder_name);
1967 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
1971 storage_error_code_t ret = plugin->handle->remove_directory(context, parent_folder_storage_path,
1972 folder_name, request, file_info, error, response);
1973 plugin_req_exit(ret, plugin, error);
1975 #ifdef DEBUG_ADAPTOR_PARAMS
1976 storage_adaptor_debug_func("[out] return code (%d)", ret);
1977 if ((NULL != file_info) && (NULL != (*file_info))) {
1978 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
1980 if ((NULL != error) && (NULL != *error)) {
1981 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
1982 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
1984 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
1985 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
1992 * @brief Requests folder and file list in a folder
1994 * @param[in] plugin specifies Storage Adaptor Plugin handle
1995 * @param[in] context specifies Storage Adaptor Plugin Context handle
1996 * @param[in] parent_folder_storage_path specifies parent folder path of folder you want to get list
1997 * @param[in] folder_name specifies folder name you want to get list
1998 * @param[in] request specifies optional parameter
1999 * @param[out] file_info_list specifies Storage Adaptor File Info handle
2000 * @param[out] file_info_list_len specifies length of the file_info_list
2001 * @param[out] error specifies error code
2002 * @param[out] response specifies optional parameter
2003 * @return 0 on success, otherwise a negative error value
2004 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2006 storage_error_code_t storage_adaptor_list(storage_adaptor_plugin_h plugin,
2007 storage_adaptor_plugin_context_h context,
2008 const char *parent_folder_storage_path,
2009 const char *folder_name,
2011 storage_adaptor_file_info_h **file_info_list,
2012 int *file_info_list_len,
2013 storage_adaptor_error_code_h *error,
2016 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2017 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2019 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2020 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2022 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2023 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2026 storage_adaptor_check_param_equal(NULL, plugin->handle->list, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2027 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (list)"));
2029 #ifdef DEBUG_ADAPTOR_PARAMS
2030 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2031 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2032 context->app_id, context->access_token, context->uid);
2033 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2034 storage_adaptor_debug_func("[in] folder_name (%s)", folder_name);
2035 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2039 storage_error_code_t ret = plugin->handle->list(context, parent_folder_storage_path,
2040 folder_name, request, file_info_list, file_info_list_len, error, response);
2041 plugin_req_exit(ret, plugin, error);
2043 #ifdef DEBUG_ADAPTOR_PARAMS
2044 storage_adaptor_debug_func("[out] return code (%d)", ret);
2045 storage_adaptor_debug_func("[out] file_info_list_len (%d)", *file_info_list_len);
2046 if ((NULL != error) && (NULL != *error)) {
2047 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2048 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2050 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2051 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2058 * @brief Uploads a file to cloud (Sync)
2060 * @param[in] plugin specifies Storage Adaptor Plugin handle
2061 * @param[in] context specifies Storage Adaptor Plugin Context handle
2062 * @param[in] parent_folder_storage_path specifies folder path of file you want to upload
2063 * @param[in] file_name specifies file name to be uploaded to cloud
2064 * @param[in] upload_file_local_path specifies local path of the file to be uploaded
2065 * @param[in] publish specifies Allow to share file with no authentication
2066 * @param[in] request specifies optional parameter
2067 * @param[out] file_info specifies Storage Adaptor File Info handle
2068 * @param[out] error specifies error code
2069 * @param[out] response specifies optional parameter
2070 * @return 0 on success, otherwise a negative error value
2071 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2073 storage_error_code_t storage_adaptor_upload_file_sync(storage_adaptor_plugin_h plugin,
2074 storage_adaptor_plugin_context_h context,
2075 const char *parent_folder_storage_path,
2076 const char *file_name,
2077 const char *upload_file_local_path,
2080 storage_adaptor_file_info_h *file_info,
2081 storage_adaptor_error_code_h *error,
2084 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2085 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2087 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2088 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2090 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2091 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2094 storage_adaptor_check_param_equal(NULL, plugin->handle->upload_file_sync, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2095 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (upload_file_sync)"));
2097 #ifdef DEBUG_ADAPTOR_PARAMS
2098 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2099 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2100 context->app_id, context->access_token, context->uid);
2101 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2102 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2103 storage_adaptor_debug_func("[in] upload_file_local_path (%s)", upload_file_local_path);
2104 storage_adaptor_debug_func("[in] publish (%d)", publish);
2105 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2109 storage_error_code_t ret = plugin->handle->upload_file_sync(context, parent_folder_storage_path,
2110 file_name, upload_file_local_path, publish, request, file_info, error, response);
2111 plugin_req_exit(ret, plugin, error);
2113 #ifdef DEBUG_ADAPTOR_PARAMS
2114 storage_adaptor_debug_func("[out] return code (%d)", ret);
2115 if ((NULL != file_info) && (NULL != (*file_info))) {
2116 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
2117 if ((1 == publish) && (NULL != (*file_info)->file_share_token)) {
2118 storage_adaptor_debug_func("[out] file_info->file_share_token->public_token (%s)",
2119 (*file_info)->file_share_token->public_token);
2120 storage_adaptor_debug_func("[out] file_info->file_share_token->auth_code (%s)",
2121 (*file_info)->file_share_token->auth_code);
2124 if ((NULL != error) && (NULL != *error)) {
2125 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2126 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2128 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2129 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2136 * @brief Downloads a file to local (Sync)
2138 * @param[in] plugin specifies Storage Adaptor Plugin handle
2139 * @param[in] context specifies Storage Adaptor Plugin Context handle
2140 * @param[in] parent_folder_storage_path specifies folder path of file you want to download
2141 * @param[in] file_name specifies file name to be downloaded to local
2142 * @param[in] download_file_local_path specifies local path to download
2143 * @param[in] request specifies optional parameter
2144 * @param[out] error specifies error code
2145 * @param[out] response specifies optional parameter
2146 * @return 0 on success, otherwise a negative error value
2147 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2149 storage_error_code_t storage_adaptor_download_file_sync(storage_adaptor_plugin_h plugin,
2150 storage_adaptor_plugin_context_h context,
2151 const char *parent_folder_storage_path,
2152 const char *file_name,
2153 const char *download_file_local_path,
2155 storage_adaptor_error_code_h *error,
2158 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2159 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2161 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2162 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2164 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2165 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2168 storage_adaptor_check_param_equal(NULL, plugin->handle->download_file_sync, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2169 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (download_file_sync)"));
2171 #ifdef DEBUG_ADAPTOR_PARAMS
2172 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2173 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2174 context->app_id, context->access_token, context->uid);
2175 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2176 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2177 storage_adaptor_debug_func("[in] download_file_local_path (%s)", download_file_local_path);
2178 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2182 storage_error_code_t ret = plugin->handle->download_file_sync(context, parent_folder_storage_path,
2183 file_name, download_file_local_path, request, error, response);
2184 plugin_req_exit(ret, plugin, error);
2186 #ifdef DEBUG_ADAPTOR_PARAMS
2187 storage_adaptor_debug_func("[out] return code (%d)", ret);
2188 if ((NULL != error) && (NULL != *error)) {
2189 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2190 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2192 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2193 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2199 storage_error_code_t storage_adaptor_download_thumbnail(storage_adaptor_plugin_h plugin,
2200 storage_adaptor_plugin_context_h context,
2201 const char *folder_path,
2202 const char *file_name,
2203 const char *download_path,
2206 storage_adaptor_error_code_h *error,
2209 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2210 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2212 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2213 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2215 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2216 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2219 storage_adaptor_check_param_equal(NULL, plugin->handle->download_thumbnail, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2220 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (download_thumbnail)"));
2222 #ifdef DEBUG_ADAPTOR_PARAMS
2223 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2224 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2225 context->app_id, context->access_token, context->uid);
2226 storage_adaptor_debug_func("[in] folder_path (%s)", folder_path);
2227 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2228 storage_adaptor_debug_func("[in] download_path (%s)", download_path);
2229 storage_adaptor_debug_func("[in] thumbnail_size (%d)", thumbnail_size);
2230 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2234 storage_error_code_t ret = plugin->handle->download_thumbnail(context, folder_path,
2235 file_name, download_path, thumbnail_size, request, error, response);
2236 plugin_req_exit(ret, plugin, error);
2238 #ifdef DEBUG_ADAPTOR_PARAMS
2239 storage_adaptor_debug_func("[out] return code (%d)", ret);
2240 if ((NULL != error) && (NULL != *error)) {
2241 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2242 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2244 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2245 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2254 * @brief Removes a file at cloud
2256 * @param[in] plugin specifies Storage Adaptor Plugin handle
2257 * @param[in] context specifies Storage Adaptor Plugin Context handle
2258 * @param[in] parent_folder_storage_path specifies folder path of file you want to delete
2259 * @param[in] file_name specifies file name to be deleted from cloud
2260 * @param[in] request specifies optional parameter
2261 * @param[out] file_info specifies Storage Adaptor File Info handle
2262 * @param[out] error specifies error code
2263 * @param[out] response specifies optional parameter
2264 * @return 0 on success, otherwise a negative error value
2265 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2267 storage_error_code_t storage_adaptor_delete_file(storage_adaptor_plugin_h plugin,
2268 storage_adaptor_plugin_context_h context,
2269 const char *parent_folder_storage_path,
2270 const char *file_name,
2272 storage_adaptor_file_info_h *file_info,
2273 storage_adaptor_error_code_h *error,
2276 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2277 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2279 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2280 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2282 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2283 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2286 storage_adaptor_check_param_equal(NULL, plugin->handle->delete_file, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2287 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (delete_file)"));
2289 #ifdef DEBUG_ADAPTOR_PARAMS
2290 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2291 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2292 context->app_id, context->access_token, context->uid);
2293 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2294 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2295 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2299 storage_error_code_t ret = plugin->handle->delete_file(context, parent_folder_storage_path,
2300 file_name, request, file_info, error, response);
2301 plugin_req_exit(ret, plugin, error);
2303 #ifdef DEBUG_ADAPTOR_PARAMS
2304 storage_adaptor_debug_func("[out] return code (%d)", ret);
2305 if ((NULL != file_info) && (NULL != (*file_info))) {
2306 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
2308 if ((NULL != error) && (NULL != *error)) {
2309 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2310 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2312 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2313 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2320 * @brief Move a folder into destination folder
2322 * @param[in] plugin specifies Storage Adaptor Plugin handle
2323 * @param[in] context specifies Storage Adaptor Plugin Context handle
2324 * @param[in] parent_folder_storage_path specifies parent folder path of folder you want to move
2325 * @param[in] folder_name specifies folder name to be moved
2326 * @param[in] dest_parent_folder_storage_path specifies new parent folder path
2327 * @param[in] new_folder_name specifies new folder name
2328 * @param[in] request specifies optional parameter
2329 * @param[out] file_info specifies Storage Adaptor File Info handle
2330 * @param[out] error specifies error code
2331 * @param[out] response specifies optional parameter
2332 * @return 0 on success, otherwise a positive error value
2333 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2335 storage_error_code_t storage_adaptor_move_directory(storage_adaptor_plugin_h plugin,
2336 storage_adaptor_plugin_context_h context,
2337 const char *parent_folder_storage_path,
2338 const char *folder_name,
2339 const char *dest_parent_folder_storage_path,
2340 const char *new_folder_name,
2342 storage_adaptor_file_info_h *file_info,
2343 storage_adaptor_error_code_h *error,
2346 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2347 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2349 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2350 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2352 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2353 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2356 storage_adaptor_check_param_equal(NULL, plugin->handle->move_directory, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2357 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (move_directory)"));
2359 #ifdef DEBUG_ADAPTOR_PARAMS
2360 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2361 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2362 context->app_id, context->access_token, context->uid);
2363 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2364 storage_adaptor_debug_func("[in] folder_name (%s)", folder_name);
2365 storage_adaptor_debug_func("[in] dest_parent_folder_storage_path (%s)", dest_parent_folder_storage_path);
2366 storage_adaptor_debug_func("[in] new_folder_name (%s)", new_folder_name);
2367 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2371 storage_error_code_t ret = plugin->handle->move_directory(context, parent_folder_storage_path,
2372 folder_name, dest_parent_folder_storage_path, new_folder_name, request, file_info, error, response);
2373 plugin_req_exit(ret, plugin, error);
2375 #ifdef DEBUG_ADAPTOR_PARAMS
2376 storage_adaptor_debug_func("[out] return code (%d)", ret);
2377 if ((NULL != file_info) && (NULL != (*file_info))) {
2378 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
2380 if ((NULL != error) && (NULL != *error)) {
2381 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2382 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2384 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2385 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2392 * @brief Move a file into destination folder
2394 * @param[in] plugin specifies Storage Adaptor Plugin handle
2395 * @param[in] context specifies Storage Adaptor Plugin Context handle
2396 * @param[in] parent_folder_storage_path specifies folder path of file you want to move
2397 * @param[in] file_name specifies file name to be moved
2398 * @param[in] dest_parent_folder_storage_path specifies new folder path
2399 * @param[in] new_file_name specifies new file name
2400 * @param[in] request specifies optional parameter
2401 * @param[out] file_info specifies Storage Adaptor File Info handle
2402 * @param[out] error specifies error code
2403 * @param[out] response specifies optional parameter
2404 * @return 0 on success, otherwise a positive error value
2405 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2407 storage_error_code_t storage_adaptor_move_file(storage_adaptor_plugin_h plugin,
2408 storage_adaptor_plugin_context_h context,
2409 const char *parent_folder_storage_path,
2410 const char *file_name,
2411 const char *dest_parent_folder_storage_path,
2412 const char *new_file_name,
2414 storage_adaptor_file_info_h *file_info,
2415 storage_adaptor_error_code_h *error,
2418 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2419 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2421 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2422 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2424 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2425 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2428 storage_adaptor_check_param_equal(NULL, plugin->handle->move_file, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2429 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (move_file)"));
2431 #ifdef DEBUG_ADAPTOR_PARAMS
2432 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2433 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2434 context->app_id, context->access_token, context->uid);
2435 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2436 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2437 storage_adaptor_debug_func("[in] dest_parent_folder_storage_path (%s)", dest_parent_folder_storage_path);
2438 storage_adaptor_debug_func("[in] new_file_name (%s)", new_file_name);
2439 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2443 storage_error_code_t ret = plugin->handle->move_file(context, parent_folder_storage_path,
2444 file_name, dest_parent_folder_storage_path, new_file_name, request, file_info, error, response);
2445 plugin_req_exit(ret, plugin, error);
2447 #ifdef DEBUG_ADAPTOR_PARAMS
2448 storage_adaptor_debug_func("[out] return code (%d)", ret);
2449 if ((NULL != file_info) && (NULL != (*file_info))) {
2450 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
2452 if ((NULL != error) && (NULL != *error)) {
2453 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2454 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2456 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2457 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2464 * @brief Get state of file transfer request
2466 * @param[in] plugin specifies Storage Adaptor Plugin handle
2467 * @param[in] context specifies Storage Adaptor Plugin Context handle
2468 * @param[in] transfer_request_id specifies unique id for file transfer request
2469 * @param[in] request specifies optional parameter
2470 * @param[out] state specifies current state of transfer request
2471 * @param[out] error specifies error code
2472 * @param[out] response specifies optional parameter
2473 * @return 0 on success, otherwise a positive error value
2474 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2476 storage_error_code_t storage_adaptor_get_transfer_state(storage_adaptor_plugin_h plugin,
2477 storage_adaptor_plugin_context_h context,
2478 void *transfer_request_id,
2480 storage_adaptor_transfer_state_e *state,
2481 storage_adaptor_error_code_h *error,
2484 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2485 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2487 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2488 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2490 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2491 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2494 storage_adaptor_check_param_equal(NULL, plugin->handle->get_transfer_state, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2495 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (get_transfer_state)"));
2497 #ifdef DEBUG_ADAPTOR_PARAMS
2498 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2499 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
2500 context->app_id, context->access_token, context->cid, context->uid);
2501 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2505 storage_error_code_t ret = plugin->handle->get_transfer_state(context, transfer_request_id,
2506 request, state, error, response);
2507 plugin_req_exit(ret, plugin, error);
2509 #ifdef DEBUG_ADAPTOR_PARAMS
2510 storage_adaptor_debug_func("[out] return code (%d)", ret);
2511 if (NULL != state) {
2512 storage_adaptor_debug_func("[out] state (%d)", *state);
2514 if ((NULL != error) && (NULL != *error)) {
2515 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2516 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2518 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2519 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2526 * @brief Set state of file transfer request
2528 * @param[in] plugin specifies Storage Adaptor Plugin handle
2529 * @param[in] context specifies Storage Adaptor Plugin Context handle
2530 * @param[in] transfer_request_id specifies unique id for file transfer request
2531 * @param[in] state specifies state to set
2532 * @param[in] request specifies optional parameter
2533 * @param[out] error specifies error code
2534 * @param[out] response specifies optional parameter
2535 * @return 0 on success, otherwise a positive error value
2536 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2538 storage_error_code_t storage_adaptor_set_transfer_state(storage_adaptor_plugin_h plugin,
2539 storage_adaptor_plugin_context_h context,
2540 void *transfer_request_id,
2541 storage_adaptor_transfer_state_e state,
2543 storage_adaptor_error_code_h *error,
2546 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2547 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2549 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2550 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2552 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2553 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2556 storage_adaptor_check_param_equal(NULL, plugin->handle->set_transfer_state, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2557 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (set_transfer_state)"));
2559 #ifdef DEBUG_ADAPTOR_PARAMS
2560 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2561 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2562 context->app_id, context->access_token, context->uid);
2563 storage_adaptor_debug_func("[in] state(%d)", state);
2564 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2568 storage_error_code_t ret = plugin->handle->set_transfer_state(context, transfer_request_id,
2569 state, request, error, response);
2570 plugin_req_exit(ret, plugin, error);
2572 #ifdef DEBUG_ADAPTOR_PARAMS
2573 storage_adaptor_debug_func("[out] return code (%d)", ret);
2574 if ((NULL != error) && (NULL != *error)) {
2575 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2576 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2578 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2579 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2585 storage_error_code_t storage_adaptor_get_root_folder_path(storage_adaptor_plugin_h plugin,
2586 storage_adaptor_plugin_context_h context,
2588 char **root_folder_path,
2589 storage_adaptor_error_code_h *error,
2592 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2593 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2595 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2596 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2598 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2599 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2602 storage_adaptor_check_param_equal(NULL, root_folder_path, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2603 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (root_folder_path)"));
2606 storage_adaptor_check_param_equal(NULL, plugin->handle->get_root_folder_path, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2607 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (get_root_folder_path)"));
2609 #ifdef DEBUG_ADAPTOR_PARAMS
2610 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2611 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2612 context->app_id, context->access_token, context->uid);
2613 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2617 storage_error_code_t ret = plugin->handle->get_root_folder_path(context, request, root_folder_path, error, response);
2618 plugin_req_exit(ret, plugin, error);
2620 #ifdef DEBUG_ADAPTOR_PARAMS
2621 storage_adaptor_debug_func("[out] return code (%d)", ret);
2622 if (NULL != *root_folder_path) {
2623 storage_adaptor_debug_func("[out] root_folder_path (%s)", *root_folder_path);
2625 if ((NULL != error) && (NULL != *error)) {
2626 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2627 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2629 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2630 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2636 /* ////////////////////// Private feature //////////////////////////// */
2639 * @brief Uploads a file to cloud (Async)
2641 * @param[in] plugin specifies Storage Adaptor Plugin handle
2642 * @param[in] context specifies Storage Adaptor Plugin Context handle
2643 * @param[in] parent_folder_storage_path specifies folder path of file you want to upload
2644 * @param[in] file_name specifies file name to be uploaded to cloud
2645 * @param[in] upload_file_local_path specifies local path of the file to be uploaded
2646 * @param[in] publish specifies Allow to share file with no authentication
2647 * @param[in] request specifies optional parameter
2648 * @param[out] transfer_request_id specifies
2649 * @param[out] error specifies error code
2650 * @return 0 on success, otherwise a negative error value
2651 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2653 storage_error_code_t storage_adaptor_upload_file_async(storage_adaptor_plugin_h plugin,
2654 storage_adaptor_plugin_context_h context,
2655 const char *parent_folder_storage_path,
2656 const char *file_name,
2657 const char *upload_file_local_path,
2660 void *transfer_request_id,
2661 storage_adaptor_error_code_h *error)
2663 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2664 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2666 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2667 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2669 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2670 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2673 storage_adaptor_check_param_equal(NULL, plugin->handle->upload_file_async, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2674 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (upload_file_async)"));
2676 #ifdef DEBUG_ADAPTOR_PARAMS
2677 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2678 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
2679 context->app_id, context->access_token, context->cid, context->uid);
2680 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2681 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2682 storage_adaptor_debug_func("[in] upload_file_local_path (%s)", upload_file_local_path);
2683 storage_adaptor_debug_func("[in] publish (%d)", publish);
2684 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2688 storage_error_code_t ret = plugin->handle->upload_file_async(context, parent_folder_storage_path,
2689 file_name, upload_file_local_path, publish, request, transfer_request_id);
2690 plugin_req_exit(ret, plugin, error);
2692 #ifdef DEBUG_ADAPTOR_PARAMS
2693 storage_adaptor_debug_func("[out] return code (%d)", ret);
2694 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2701 * @brief Downloads a file to local (Async)
2703 * @param[in] plugin specifies Storage Adaptor Plugin handle
2704 * @param[in] context specifies Storage Adaptor Plugin Context handle
2705 * @param[in] parent_folder_storage_path specifies folder path of file you want to download
2706 * @param[in] file_name specifies file name to be downloaded to local
2707 * @param[in] download_file_local_path specifies local path to download
2708 * @param[in] request specifies optional parameter
2709 * @param[out] transfer_request_id specifies
2710 * @param[out] error specifies error code
2711 * @return 0 on success, otherwise a negative error value
2712 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2714 storage_error_code_t storage_adaptor_download_file_async(storage_adaptor_plugin_h plugin,
2715 storage_adaptor_plugin_context_h context,
2716 const char *parent_folder_storage_path,
2717 const char *file_name,
2718 const char *download_file_local_path,
2720 void *transfer_request_id,
2721 storage_adaptor_error_code_h *error)
2723 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2724 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2726 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2727 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2729 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2730 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2733 storage_adaptor_check_param_equal(NULL, plugin->handle->download_file_async, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2734 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (download_file_async)"));
2736 #ifdef DEBUG_ADAPTOR_PARAMS
2737 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2738 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
2739 context->app_id, context->access_token, context->cid, context->uid);
2740 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2741 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2742 storage_adaptor_debug_func("[in] download_file_local_path (%s)", download_file_local_path);
2743 storage_adaptor_debug_func("[in] request (addr : %p)", request);
2744 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2748 storage_error_code_t ret = plugin->handle->download_file_async(context, parent_folder_storage_path,
2749 file_name, download_file_local_path, request, transfer_request_id);
2750 plugin_req_exit(ret, plugin, error);
2752 #ifdef DEBUG_ADAPTOR_PARAMS
2753 storage_adaptor_debug_func("[out] return code (%d)", ret);
2754 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2762 * @brief Sets metadata of file at cloud
2764 * @param[in] plugin specifies Storage Adaptor Plugin handle
2765 * @param[in] context specifies Storage Adaptor Plugin Context handle
2766 * @param[in] parent_folder_storage_path specifies folder path of file you want to set meta data
2767 * @param[in] file_name specifies file name to be updated meta data
2768 * @param[in] meta_data specifies meta data (A pair of Key, Value)
2769 * @param[in] request specifies optional parameter
2770 * @param[out] file_info specifies Storage Adaptor File Info handle
2771 * @param[out] error specifies error code
2772 * @param[out] response specifies optional parameter
2773 * @return 0 on success, otherwise a negative error value
2774 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2776 storage_error_code_t storage_adaptor_set_meta(storage_adaptor_plugin_h plugin,
2777 storage_adaptor_plugin_context_h context,
2778 const char *parent_folder_storage_path,
2779 const char *file_name,
2780 const void *meta_data,
2782 storage_adaptor_file_info_h *file_info,
2783 storage_adaptor_error_code_h *error,
2786 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2787 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2789 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2790 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2792 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2793 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2796 storage_adaptor_check_param_equal(NULL, plugin->handle->set_meta, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2797 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (set_meta)"));
2799 #ifdef DEBUG_ADAPTOR_PARAMS
2800 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2801 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
2802 context->app_id, context->access_token, context->cid, context->uid);
2803 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2804 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2805 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2809 storage_error_code_t ret = plugin->handle->set_meta(context, parent_folder_storage_path,
2810 file_name, meta_data, request, file_info, error, response);
2811 plugin_req_exit(ret, plugin, error);
2813 #ifdef DEBUG_ADAPTOR_PARAMS
2814 storage_adaptor_debug_func("[out] return code (%d)", ret);
2815 if ((NULL != file_info) && (NULL != (*file_info))) {
2816 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
2818 if ((NULL != error) && (NULL != *error)) {
2819 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2820 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2822 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2823 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2830 * @brief Gets metatdata of file at cloud
2832 * @param[in] plugin specifies Storage Adaptor Plugin handle
2833 * @param[in] context specifies Storage Adaptor Plugin Context handle
2834 * @param[in] parent_folder_storage_path specifies folder path of file you want to get meta data
2835 * @param[in] file_name specifies file name
2836 * @param[in] request specifies optional parameter
2837 * @param[out] file_info specifies Storage Adaptor File Info handle
2838 * @param[out] meta_data specifies meta data (A pair of Key, Value)
2839 * @param[out] error specifies error code
2840 * @param[out] response specifies optional parameter
2841 * @return 0 on success, otherwise a negative error value
2842 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2844 storage_error_code_t storage_adaptor_get_meta(storage_adaptor_plugin_h plugin,
2845 storage_adaptor_plugin_context_h context,
2846 const char *parent_folder_storage_path,
2847 const char *file_name,
2849 storage_adaptor_file_info_h *file_info,
2851 storage_adaptor_error_code_h *error,
2854 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2855 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2857 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2858 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2860 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2861 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2864 storage_adaptor_check_param_equal(NULL, plugin->handle->get_meta, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2865 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (get_meta)"));
2867 #ifdef DEBUG_ADAPTOR_PARAMS
2868 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2869 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
2870 context->app_id, context->access_token, context->cid, context->uid);
2871 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2872 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2873 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2877 storage_error_code_t ret = plugin->handle->get_meta(context, parent_folder_storage_path,
2878 file_name, request, file_info, meta_data, error, response);
2879 plugin_req_exit(ret, plugin, error);
2881 #ifdef DEBUG_ADAPTOR_PARAMS
2882 storage_adaptor_debug_func("[out] return code (%d)", ret);
2883 if ((NULL != file_info) && (NULL != (*file_info))) {
2884 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
2886 if ((NULL != error) && (NULL != *error)) {
2887 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2888 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2890 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2891 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2898 * @brief Set up Multi Channel Upload
2900 * @param[in] plugin specifies Storage Adaptor Plugin handle
2901 * @param[in] context specifies Storage Adaptor Plugin Context handle
2902 * @param[in] parent_folder_storage_path specifies folder path of file you want to upload
2903 * @param[in] file_name specifies file name to be uploaded to cloud
2904 * @param[in] upload_file_local_path specifies local path of the file to be uploaded
2905 * @param[in] chunk_size_byte specifies size of chunk
2906 * @param[in] request specifies optional parameter
2907 * @param[out] mupload_key specifies Multi Channel Upload key
2908 * @param[out] chunk_count specifies total number of chunks
2909 * @param[out] file_info specifies Storage Adaptor File Info handle
2910 * @param[out] error specifies error code
2911 * @param[out] response specifies optional parameter
2912 * @return 0 on success, otherwise a negative error value
2913 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2915 storage_error_code_t storage_adaptor_start_mupload(storage_adaptor_plugin_h plugin,
2916 storage_adaptor_plugin_context_h context,
2917 const char *parent_folder_storage_path,
2918 const char *file_name,
2919 const char *upload_file_local_path,
2920 const unsigned long long chunk_size,
2924 storage_adaptor_file_info_h *file_info,
2925 storage_adaptor_error_code_h *error,
2928 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2929 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2931 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2932 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2934 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2935 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2937 storage_adaptor_check_param_equal(NULL, plugin->handle->start_mupload, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2938 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (start_mupload)"));
2941 #ifdef DEBUG_ADAPTOR_PARAMS
2942 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2943 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
2944 context->app_id, context->access_token, context->cid, context->uid);
2945 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2946 storage_adaptor_debug_func("[in] chunk_size (%llu)", chunk_size);
2947 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2951 storage_error_code_t ret = plugin->handle->start_mupload(context, parent_folder_storage_path,
2952 file_name, upload_file_local_path, chunk_size, request, mupload_key, chunk_count,
2953 file_info, error, response);
2954 plugin_req_exit(ret, plugin, error);
2956 #ifdef DEBUG_ADAPTOR_PARAMS
2957 storage_adaptor_debug_func("[out] return code (%d)", ret);
2958 if ((NULL != file_info) && (NULL != (*file_info))) {
2959 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
2961 if ((NULL != error) && (NULL != *error)) {
2962 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2963 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2965 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2966 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2973 * @brief Uploads a chunk to cloud
2975 * @param[in] plugin specifies Storage Adaptor Plugin handle
2976 * @param[in] context specifies Storage Adaptor Plugin Context handle
2977 * @param[in] mupload_key specifies Multi Channel Upload key
2978 * @param[in] chunk_number specifies number of chunk (Starting at 1)
2979 * @param[in] request specifies optional parameter
2980 * @param[out] file_info specifies Storage Adaptor File Info handle
2981 * @param[out] error specifies error code
2982 * @param[out] response specifies optional parameter
2983 * @return 0 on success, otherwise a negative error value
2984 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2986 storage_error_code_t storage_adaptor_upload_mupload(storage_adaptor_plugin_h plugin,
2987 storage_adaptor_plugin_context_h context,
2988 const char *mupload_key,
2989 const int chunk_number,
2991 storage_adaptor_file_info_h *file_info,
2992 storage_adaptor_error_code_h *error,
2995 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2996 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2998 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2999 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3001 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3002 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3005 storage_adaptor_check_param_equal(NULL, plugin->handle->upload_mupload, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3006 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (upload_mupload)"));
3008 #ifdef DEBUG_ADAPTOR_PARAMS
3009 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3010 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3011 context->app_id, context->access_token, context->cid, context->uid);
3012 storage_adaptor_debug_func("[in] mupload_key (%s)", mupload_key);
3013 storage_adaptor_debug_func("[in] chunk_number (%d)", chunk_number);
3014 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3018 storage_error_code_t ret = plugin->handle->upload_mupload(context, mupload_key,
3019 chunk_number, request, file_info, error, response);
3020 plugin_req_exit(ret, plugin, error);
3022 #ifdef DEBUG_ADAPTOR_PARAMS
3023 storage_adaptor_debug_func("[out] return code (%d)", ret);
3024 if ((NULL != file_info) && (NULL != (*file_info))) {
3025 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
3027 if ((NULL != error) && (NULL != *error)) {
3028 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3029 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3031 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3032 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3039 * @brief Ends Multi channel Upload
3041 * @param[in] plugin specifies Storage Adaptor Plugin handle
3042 * @param[in] context specifies Storage Adaptor Plugin Context handle
3043 * @param[in] mupload_key specifies Multi Channel Upload key
3044 * @param[in] publish specifies Allow to share file with no authentication
3045 * @param[in] request specifies optional parameter
3046 * @param[out] file_info specifies Storage Adaptor File Info handle
3047 * @param[out] error specifies error code
3048 * @param[out] response specifies optional parameter
3049 * @return 0 on success, otherwise a negative error value
3050 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3052 storage_error_code_t storage_adaptor_end_mupload(storage_adaptor_plugin_h plugin,
3053 storage_adaptor_plugin_context_h context,
3054 const char *mupload_key,
3057 storage_adaptor_file_info_h *file_info,
3058 storage_adaptor_error_code_h *error,
3061 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3062 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3064 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3065 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3067 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3068 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3071 storage_adaptor_check_param_equal(NULL, plugin->handle->end_mupload, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3072 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (end_mupoad)"));
3074 #ifdef DEBUG_ADAPTOR_PARAMS
3075 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3076 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3077 context->app_id, context->access_token, context->cid, context->uid);
3078 storage_adaptor_debug_func("[in] mupload_key (%s)", mupload_key);
3079 storage_adaptor_debug_func("[in] publish (%d)", publish);
3080 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3084 storage_error_code_t ret = plugin->handle->end_mupload(context, mupload_key,
3085 publish, request, file_info, error, response);
3086 plugin_req_exit(ret, plugin, error);
3088 #ifdef DEBUG_ADAPTOR_PARAMS
3089 storage_adaptor_debug_func("[out] return code (%d)", ret);
3090 if ((NULL != file_info) && (NULL != (*file_info))) {
3091 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
3093 if ((NULL != error) && (NULL != *error)) {
3094 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3095 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3097 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3098 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3105 * @brief Requests list of chunks uploaded
3107 * @param[in] plugin specifies Storage Adaptor Plugin handle
3108 * @param[in] context specifies Storage Adaptor Plugin Context handle
3109 * @param[in] mupload_key specifies Multi Channel Upload key
3110 * @param[in] request specifies optional parameter
3111 * @param[out] file_info_list specifies Storage Adaptor File Info handle
3112 * @param[out] file_info_list_len specifies length of the file_info_list
3113 * @param[out] error specifies error code
3114 * @param[out] response specifies optional parameter
3115 * @return 0 on success, otherwise a negative error value
3116 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3118 storage_error_code_t storage_adaptor_list_mupload(storage_adaptor_plugin_h plugin,
3119 storage_adaptor_plugin_context_h context,
3120 const char *mupload_key,
3122 storage_adaptor_file_info_h **file_info_list,
3123 int *file_info_list_len,
3124 storage_adaptor_error_code_h *error,
3127 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3128 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3130 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3131 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3133 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3134 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3137 storage_adaptor_check_param_equal(NULL, plugin->handle->list_mupload, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3138 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (list_mupload)"));
3140 #ifdef DEBUG_ADAPTOR_PARAMS
3141 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3142 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3143 context->app_id, context->access_token, context->cid, context->uid);
3144 storage_adaptor_debug_func("[in] mupload_key (%s)", mupload_key);
3145 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3149 storage_error_code_t ret = plugin->handle->list_mupload(context, mupload_key,
3150 request, file_info_list, file_info_list_len, error, response);
3151 plugin_req_exit(ret, plugin, error);
3153 #ifdef DEBUG_ADAPTOR_PARAMS
3154 storage_adaptor_debug_func("[out] return code (%d)", ret);
3155 if (NULL != file_info_list_len) {
3156 storage_adaptor_debug_func("[out] file_info_list_len (%d)", *file_info_list_len);
3158 if ((NULL != error) && (NULL != *error)) {
3159 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3160 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3162 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3163 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3170 * @brief Cancels all operations
3172 * @param[in] plugin specifies Storage Adaptor Plugin handle
3173 * @param[in] context specifies Storage Adaptor Plugin Context handle
3174 * @param[in] mupload_key specifies Multi Channel Upload key
3175 * @param[in] request specifies optional parameter
3176 * @param[out] file_info specifies Storage Adaptor File Info handle
3177 * @param[out] error specifies error code
3178 * @param[out] response specifies optional parameter
3179 * @return 0 on success, otherwise a negative error value
3180 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3182 storage_error_code_t storage_adaptor_cancel_mupload(storage_adaptor_plugin_h plugin,
3183 storage_adaptor_plugin_context_h context,
3184 const char *mupload_key,
3186 storage_adaptor_file_info_h *file_info,
3187 storage_adaptor_error_code_h *error,
3190 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3191 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3193 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3194 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3196 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3197 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3200 storage_adaptor_check_param_equal(NULL, plugin->handle->cancel_mupload, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3201 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (cancel_mupload)"));
3203 #ifdef DEBUG_ADAPTOR_PARAMS
3204 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3205 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3206 context->app_id, context->access_token, context->cid, context->uid);
3207 storage_adaptor_debug_func("[in] mupload_key (%s)", mupload_key);
3208 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3212 storage_error_code_t ret = plugin->handle->cancel_mupload(context, mupload_key,
3213 request, file_info, error, response);
3214 plugin_req_exit(ret, plugin, error);
3216 #ifdef DEBUG_ADAPTOR_PARAMS
3217 storage_adaptor_debug_func("[out] return code (%d)", ret);
3218 if ((NULL != file_info) && (NULL != (*file_info))) {
3219 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
3221 if ((NULL != error) && (NULL != *error)) {
3222 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3223 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3225 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3226 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3233 * @brief Starts Transaction
3235 * @param[in] plugin specifies Storage Adaptor Plugin handle
3236 * @param[in] context specifies Storage Adaptor Plugin Context handle
3237 * @param[in] request specifies optional parameter
3238 * @param[out] tx_key specifies Transaction key
3239 * @param[out] error specifies error code
3240 * @param[out] response specifies optional parameter
3241 * @return 0 on success, otherwise a negative error value
3242 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3244 storage_error_code_t storage_adaptor_start_transaction(storage_adaptor_plugin_h plugin,
3245 storage_adaptor_plugin_context_h context,
3248 storage_adaptor_error_code_h *error,
3251 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3252 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3254 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3255 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3257 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3258 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3261 storage_adaptor_check_param_equal(NULL, plugin->handle->start_transaction, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3262 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (start_transacion)"));
3264 #ifdef DEBUG_ADAPTOR_PARAMS
3265 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3266 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3267 context->app_id, context->access_token, context->cid, context->uid);
3268 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3272 storage_error_code_t ret = plugin->handle->start_transaction(context, request,
3273 tx_key, error, response);
3274 plugin_req_exit(ret, plugin, error);
3276 #ifdef DEBUG_ADAPTOR_PARAMS
3277 storage_adaptor_debug_func("[out] return code (%d)", ret);
3278 if (NULL != tx_key) {
3279 storage_adaptor_debug_func("[out] tx_key (%s)", *tx_key);
3281 if ((NULL != error) && (NULL != *error)) {
3282 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3283 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3285 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3286 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3293 * @brief Uploads a file
3295 * @param[in] plugin specifies Storage Adaptor Plugin handle
3296 * @param[in] context specifies Storage Adaptor Plugin Context handle
3297 * @param[in] tx_key specifies Transaction key
3298 * @param[in] tx_seq specifies Transaction sequesnce (Starting at 1)
3299 * @param[in] parent_folder_storage_path specifies folder path of file you want to upload
3300 * @param[in] file_name specifies file name to be uploaded to cloud
3301 * @param[in] upload_file_local_path specifies local path of the file to be uploaded
3302 * @param[in] request specifies optional parameter
3303 * @param[out] file_info specifies Storage Adaptor File Info handle
3304 * @param[out] error specifies error code
3305 * @param[out] response specifies optional parameter
3306 * @return 0 on success, otherwise a negative error value
3307 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3309 storage_error_code_t storage_adaptor_upload_file_transaction(storage_adaptor_plugin_h plugin,
3310 storage_adaptor_plugin_context_h context,
3313 const char *parent_folder_storage_path,
3314 const char *file_name,
3315 const char *upload_file_local_path,
3317 storage_adaptor_file_info_h *file_info,
3318 storage_adaptor_error_code_h *error,
3321 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3322 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3324 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3325 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3327 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3328 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3331 storage_adaptor_check_param_equal(NULL, plugin->handle->upload_file_transaction, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3332 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (upload_file_transaction)"));
3334 #ifdef DEBUG_ADAPTOR_PARAMS
3335 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3336 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3337 context->app_id, context->access_token, context->cid, context->uid);
3338 storage_adaptor_debug_func("[in] tx_key (%s)", tx_key);
3339 storage_adaptor_debug_func("[in] tx_seq (%d)", tx_seq);
3340 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
3341 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
3342 storage_adaptor_debug_func("[in] upload_file_local_path (%s)", upload_file_local_path);
3343 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3347 storage_error_code_t ret = plugin->handle->upload_file_transaction(context, tx_key,
3348 tx_seq, parent_folder_storage_path, file_name, upload_file_local_path, request, file_info, error, response);
3349 plugin_req_exit(ret, plugin, error);
3351 #ifdef DEBUG_ADAPTOR_PARAMS
3352 storage_adaptor_debug_func("[out] return code (%d)", ret);
3353 if ((NULL != file_info) && (NULL != (*file_info))) {
3354 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
3357 if ((NULL != error) && (NULL != *error)) {
3358 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3359 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3361 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3362 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3369 * @brief Updates a folder
3371 * @param[in] plugin specifies Storage Adaptor Plugin handle
3372 * @param[in] context specifies Storage Adaptor Plugin Context handle
3373 * @param[in] tx_key specifies Transaction key
3374 * @param[in] tx_seq specifies Transaction sequesnce (Starting at 1)
3375 * @param[in] parent_folder_storage_path specifies folder path of folder you want to update
3376 * @param[in] folder_name specifies folder name to be updated
3377 * @param[in] request specifies optional parameter
3378 * @param[out] file_info specifies Storage Adaptor File Info handle
3379 * @param[out] error specifies error code
3380 * @param[out] response specifies optional parameter
3381 * @return 0 on success, otherwise a negative error value
3382 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3384 storage_error_code_t storage_adaptor_set_dir_transaction(storage_adaptor_plugin_h plugin,
3385 storage_adaptor_plugin_context_h context,
3388 const char *parent_folder_storage_path,
3389 const char *folder_name,
3391 storage_adaptor_file_info_h *file_info,
3392 storage_adaptor_error_code_h *error,
3395 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3396 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3398 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3399 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3401 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3402 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3405 storage_adaptor_check_param_equal(NULL, plugin->handle->set_dir_transaction, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3406 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (set_dir_transaction)"));
3408 #ifdef DEBUG_ADAPTOR_PARAMS
3409 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3410 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3411 context->app_id, context->access_token, context->cid, context->uid);
3412 storage_adaptor_debug_func("[in] tx_key (%s)", tx_key);
3413 storage_adaptor_debug_func("[in] tx_seq (%d)", tx_seq);
3414 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
3415 storage_adaptor_debug_func("[in] folder_name (%s)", folder_name);
3416 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3420 storage_error_code_t ret = plugin->handle->set_dir_transaction(context, tx_key,
3421 tx_seq, parent_folder_storage_path, folder_name, request, file_info, error, response);
3422 plugin_req_exit(ret, plugin, error);
3424 #ifdef DEBUG_ADAPTOR_PARAMS
3425 storage_adaptor_debug_func("[out] return code (%d)", ret);
3426 if ((NULL != file_info) && (NULL != (*file_info))) {
3427 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
3429 if ((NULL != error) && (NULL != *error)) {
3430 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3431 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3433 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3434 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3441 * @brief Removes a file
3443 * @param[in] plugin specifies Storage Adaptor Plugin handle
3444 * @param[in] context specifies Storage Adaptor Plugin Context handle
3445 * @param[in] tx_key specifies Transaction key
3446 * @param[in] tx_seq specifies Transaction sequesnce (Starting at 1)
3447 * @param[in] parent_folder_storage_path specifies folder path of file you want to delete
3448 * @param[in] file_name specifies file name to be deleted from cloud
3449 * @param[in] request specifies optional parameter
3450 * @param[in] upload_file_local_path specifies local path of the file to be uploaded
3451 * @param[out] file_info specifies Storage Adaptor File Info handle
3452 * @param[out] error specifies error code
3453 * @param[out] response specifies optional parameter
3454 * @return 0 on success, otherwise a negative error value
3455 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3457 storage_error_code_t storage_adaptor_delete_file_transaction(storage_adaptor_plugin_h plugin,
3458 storage_adaptor_plugin_context_h context,
3461 const char *parent_folder_storage_path,
3462 const char *file_name,
3464 storage_adaptor_file_info_h *file_info,
3465 storage_adaptor_error_code_h *error,
3468 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3469 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3471 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3472 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3474 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3475 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3478 storage_adaptor_check_param_equal(NULL, plugin->handle->delete_file_transaction, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3479 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (delete_file_transaction)"));
3481 #ifdef DEBUG_ADAPTOR_PARAMS
3482 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3483 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3484 context->app_id, context->access_token, context->cid, context->uid);
3485 storage_adaptor_debug_func("[in] tx_key (%s)", tx_key);
3486 storage_adaptor_debug_func("[in] tx_seq (%d)", tx_seq);
3487 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
3488 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
3489 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3493 storage_error_code_t ret = plugin->handle->delete_file_transaction(context, tx_key,
3494 tx_seq, parent_folder_storage_path, file_name, request, file_info, error, response);
3495 plugin_req_exit(ret, plugin, error);
3497 #ifdef DEBUG_ADAPTOR_PARAMS
3498 storage_adaptor_debug_func("[out] return code (%d)", ret);
3499 if ((NULL != file_info) && (NULL != (*file_info))) {
3500 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
3502 if ((NULL != error) && (NULL != *error)) {
3503 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3504 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3506 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3507 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3514 * @brief Removes a folder
3516 * @param[in] plugin specifies Storage Adaptor Plugin handle
3517 * @param[in] context specifies Storage Adaptor Plugin Context handle
3518 * @param[in] tx_key specifies Transaction key
3519 * @param[in] tx_seq specifies Transaction sequesnce (Starting at 1)
3520 * @param[in] parent_folder_storage_path specifies folder path of folder you want to delete
3521 * @param[in] folder_name specifies folder name to be deleted
3522 * @param[in] request specifies optional parameter
3523 * @param[out] file_info specifies Storage Adaptor File Info handle
3524 * @param[out] error specifies error code
3525 * @param[out] response specifies optional parameter
3526 * @return 0 on success, otherwise a negative error value
3527 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3529 storage_error_code_t storage_adaptor_delete_dir_transaction(storage_adaptor_plugin_h plugin,
3530 storage_adaptor_plugin_context_h context,
3533 const char *parent_folder_storage_path,
3534 const char *folder_name,
3536 storage_adaptor_file_info_h *file_info,
3537 storage_adaptor_error_code_h *error,
3540 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3541 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3543 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3544 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3546 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3547 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3550 storage_adaptor_check_param_equal(NULL, plugin->handle->delete_dir_transaction, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3551 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (delete_dir_transaction)"));
3553 #ifdef DEBUG_ADAPTOR_PARAMS
3554 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3555 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3556 context->app_id, context->access_token, context->cid, context->uid);
3557 storage_adaptor_debug_func("[in] tx_key (%s)", tx_key);
3558 storage_adaptor_debug_func("[in] tx_seq (%d)", tx_seq);
3559 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
3560 storage_adaptor_debug_func("[in] folder_name (%s)", folder_name);
3561 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3565 storage_error_code_t ret = plugin->handle->delete_dir_transaction(context, tx_key,
3566 tx_seq, parent_folder_storage_path, folder_name, request, file_info, error, response);
3567 plugin_req_exit(ret, plugin, error);
3569 #ifdef DEBUG_ADAPTOR_PARAMS
3570 storage_adaptor_debug_func("[out] return code (%d)", ret);
3571 if ((NULL != file_info) && (NULL != (*file_info))) {
3572 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
3574 if ((NULL != error) && (NULL != *error)) {
3575 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3576 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3578 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3579 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3586 * @brief Ends Transaction
3588 * @param[in] plugin specifies Storage Adaptor Plugin handle
3589 * @param[in] context specifies Storage Adaptor Plugin Context handle
3590 * @param[in] tx_key specifies Transaction key
3591 * @param[in] tx_count specifies Transaction order count
3592 * @param[in] request specifies optional parameter
3593 * @param[out] file_info_list specifies Storage Adaptor File Info handle
3594 * @param[out] file_info_list_len specifies length of the file_info_list
3595 * @param[out] error specifies error code
3596 * @param[out] response specifies optional parameter
3597 * @return 0 on success, otherwise a negative error value
3598 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3600 storage_error_code_t storage_adaptor_end_transaction(storage_adaptor_plugin_h plugin,
3601 storage_adaptor_plugin_context_h context,
3605 storage_adaptor_file_info_h **file_info_list,
3606 int *file_info_list_len,
3607 storage_adaptor_error_code_h *error,
3610 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3611 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3613 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3614 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3616 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3617 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3620 storage_adaptor_check_param_equal(NULL, plugin->handle->end_transaction, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3621 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (end_transaction)"));
3623 #ifdef DEBUG_ADAPTOR_PARAMS
3624 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3625 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3626 context->app_id, context->access_token, context->cid, context->uid);
3627 storage_adaptor_debug_func("[in] tx_key (%s)", tx_key);
3628 storage_adaptor_debug_func("[in] tx_count (%d)", tx_count);
3629 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3633 storage_error_code_t ret = plugin->handle->end_transaction(context, tx_key,
3634 tx_count, request, file_info_list, file_info_list_len, error, response);
3635 plugin_req_exit(ret, plugin, error);
3637 #ifdef DEBUG_ADAPTOR_PARAMS
3638 storage_adaptor_debug_func("[out] return code (%d)", ret);
3639 if (NULL != file_info_list_len) {
3640 storage_adaptor_debug_func("[out] file_info_list_len (%d)", *file_info_list_len);
3642 if ((NULL != error) && (NULL != *error)) {
3643 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3644 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3646 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3647 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3654 * @brief Requests Transaction list
3656 * @param[in] plugin specifies Storage Adaptor Plugin handle
3657 * @param[in] context specifies Storage Adaptor Plugin Context handle
3658 * @param[in] tx_key specifies Transaction key
3659 * @param[in] request specifies optional parameter
3660 * @param[out] file_info_list specifies Storage Adaptor File Info handle
3661 * @param[out] file_info_list_len specifies length of the file_info_list
3662 * @param[out] error specifies error code
3663 * @param[out] response specifies optional parameter
3664 * @return 0 on success, otherwise a negative error value
3665 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3667 storage_error_code_t storage_adaptor_list_transaction(storage_adaptor_plugin_h plugin,
3668 storage_adaptor_plugin_context_h context,
3671 storage_adaptor_file_info_h **file_info_list,
3672 int *file_info_list_len,
3673 storage_adaptor_error_code_h *error,
3676 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3677 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3679 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3680 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3682 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3683 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3686 storage_adaptor_check_param_equal(NULL, plugin->handle->list_transaction, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3687 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (list_transaction)"));
3689 #ifdef DEBUG_ADAPTOR_PARAMS
3690 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3691 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3692 context->app_id, context->access_token, context->cid, context->uid);
3693 storage_adaptor_debug_func("[in] tx_key (%s)", tx_key);
3694 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3698 storage_error_code_t ret = plugin->handle->list_transaction(context, tx_key,
3699 request, file_info_list, file_info_list_len, error, response);
3700 plugin_req_exit(ret, plugin, error);
3702 #ifdef DEBUG_ADAPTOR_PARAMS
3703 storage_adaptor_debug_func("[out] return code (%d)", ret);
3704 if (NULL != file_info_list_len) {
3705 storage_adaptor_debug_func("[out] file_info_list_len (%d)", *file_info_list_len);
3707 if ((NULL != error) && (NULL != *error)) {
3708 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3709 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3711 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3712 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3719 * @brief Cancels all transactions
3721 * @param[in] plugin specifies Storage Adaptor Plugin handle
3722 * @param[in] context specifies Storage Adaptor Plugin Context handle
3723 * @param[in] tx_key specifies Transaction key
3724 * @param[in] request specifies optional parameter
3725 * @param[out] file_info_list specifies Storage Adaptor File Info handle
3726 * @param[out] file_info_list_len specifies length of the file_info_list
3727 * @param[out] error specifies error code
3728 * @param[out] response specifies optional parameter
3729 * @return 0 on success, otherwise a negative error value
3730 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3732 storage_error_code_t storage_adaptor_cancel_transaction(storage_adaptor_plugin_h plugin,
3733 storage_adaptor_plugin_context_h context,
3736 storage_adaptor_file_info_h **file_info_list,
3737 int *file_info_list_len,
3738 storage_adaptor_error_code_h *error,
3741 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3742 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3744 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3745 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3747 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3748 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3751 storage_adaptor_check_param_equal(NULL, plugin->handle->cancel_transaction, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3752 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (cancel_transaction)"));
3754 #ifdef DEBUG_ADAPTOR_PARAMS
3755 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3756 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3757 context->app_id, context->access_token, context->cid, context->uid);
3758 storage_adaptor_debug_func("[in] tx_key (%s)", tx_key);
3759 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3763 storage_error_code_t ret = plugin->handle->cancel_transaction(context, tx_key,
3764 request, file_info_list, file_info_list_len, error, response);
3765 plugin_req_exit(ret, plugin, error);
3767 #ifdef DEBUG_ADAPTOR_PARAMS
3768 storage_adaptor_debug_func("[out] return code (%d)", ret);
3769 if (NULL != file_info_list_len) {
3770 storage_adaptor_debug_func("[out] file_info_list_len (%d)", *file_info_list_len);
3772 if ((NULL != error) && (NULL != *error)) {
3773 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3774 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3776 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3777 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3784 * @brief Uploads multiple files to cloud
3786 * @param[in] plugin specifies Storage Adaptor Plugin handle
3787 * @param[in] context specifies Storage Adaptor Plugin Context handle
3788 * @param[in] parent_folder_storage_path specifies folder path of files you want to upload
3789 * @param[in] upload_file_local_path_list specifies local path list of the files to be uploaded
3790 * @param[in] upload_list_len specifies total number of files to be uploaded
3791 * @param[in] request specifies optional parameter
3792 * @param[out] error specifies error code
3793 * @param[out] response specifies optional parameter
3794 * @return 0 on success, otherwise a positive error value
3795 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3797 storage_error_code_t storage_adaptor_multi_file_upload(storage_adaptor_plugin_h plugin,
3798 storage_adaptor_plugin_context_h context,
3799 const char *parent_folder_storage_path,
3800 const char **upload_file_local_path_list,
3801 const int upload_list_len,
3803 storage_adaptor_error_code_h *error,
3806 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3807 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3809 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3810 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3812 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3813 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3816 storage_adaptor_check_param_equal(NULL, plugin->handle->multi_file_upload, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3817 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (multi_file_upload)"));
3819 #ifdef DEBUG_ADAPTOR_PARAMS
3820 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3821 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3822 context->app_id, context->access_token, context->cid, context->uid);
3823 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
3824 storage_adaptor_debug_func("[in] upload_list_len (%d)", upload_list_len);
3825 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3829 storage_error_code_t ret = plugin->handle->multi_file_upload(context, parent_folder_storage_path,
3830 upload_file_local_path_list, upload_list_len, request, error, response);
3831 plugin_req_exit(ret, plugin, error);
3833 #ifdef DEBUG_ADAPTOR_PARAMS
3834 storage_adaptor_debug_func("[out] return code (%d)", ret);
3835 if ((NULL != error) && (NULL != *error)) {
3836 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3837 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3839 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3840 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3847 * @brief Downloads multiple files in a folder
3849 * @param[in] plugin specifies Storage Adaptor Plugin handle
3850 * @param[in] context specifies Storage Adaptor Plugin Context handle
3851 * @param[in] parent_folder_storage_path specifies folder path of files you want to download
3852 * @param[in] file_name_list specifies file name list to be downloaded
3853 * @param[in] file_name_list_len specifies total number of files to be downloaded
3854 * @param[in] download_folder_local_path specifies local folder path to download files
3855 * @param[in] request specifies optional parameter
3856 * @param[out] file_info_list specifies Storage Adaptor File Info handle
3857 * @param[out] file_info_list_len specifies length of the file_info_list
3858 * @param[out] error specifies error code
3859 * @param[out] response specifies optional parameter
3860 * @return 0 on success, otherwise a positive error value
3861 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3863 storage_error_code_t storage_adaptor_multi_file_download(storage_adaptor_plugin_h plugin,
3864 storage_adaptor_plugin_context_h context,
3865 const char *parent_folder_storage_path,
3866 const char *file_name_list,
3867 const int file_name_list_len,
3868 const char *download_folder_local_path,
3870 storage_adaptor_file_info_h **file_info_list,
3871 int *file_info_list_len,
3872 storage_adaptor_error_code_h *error,
3875 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3876 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3878 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3879 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3881 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3882 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3885 storage_adaptor_check_param_equal(NULL, plugin->handle->multi_file_download, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3886 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (multi_file_download)"));
3888 #ifdef DEBUG_ADAPTOR_PARAMS
3889 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3890 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3891 context->app_id, context->access_token, context->cid, context->uid);
3892 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
3893 storage_adaptor_debug_func("[in] download_list_len (%d)", file_name_list_len);
3894 storage_adaptor_debug_func("[in] download_folder_local_path (%s)", download_folder_local_path);
3895 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3899 storage_error_code_t ret = plugin->handle->multi_file_download(context, parent_folder_storage_path,
3900 file_name_list, file_name_list_len, download_folder_local_path, request, file_info_list,
3901 file_info_list_len, error, response);
3902 plugin_req_exit(ret, plugin, error);
3904 #ifdef DEBUG_ADAPTOR_PARAMS
3905 storage_adaptor_debug_func("[out] return code (%d)", ret);
3906 if (NULL != file_info_list_len) {
3907 storage_adaptor_debug_func("[out] file_info_list_len (%d)", *file_info_list_len);
3909 if ((NULL != error) && (NULL != *error)) {
3910 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3911 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3913 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3914 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3921 * @brief Requests current server timestamp
3923 * @param[in] plugin specifies Storage Adaptor Plugin handle
3924 * @param[in] context specifies Storage Adaptor Plugin Context handle
3925 * @param[in] request specifies optional parameter
3926 * @param[out] timestamp specifies server timestamp
3927 * @param[out] error specifies error code
3928 * @param[out] response specifies optional parameter
3929 * @return 0 on success, otherwise a positive error value
3930 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3932 storage_error_code_t storage_adaptor_get_timestamp(storage_adaptor_plugin_h plugin,
3933 storage_adaptor_plugin_context_h context,
3935 unsigned long long *timestamp,
3936 storage_adaptor_error_code_h *error,
3939 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3940 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3942 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3943 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3945 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3946 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3949 storage_adaptor_check_param_equal(NULL, plugin->handle->get_timestamp, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3950 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (get_timestamp)"));
3952 #ifdef DEBUG_ADAPTOR_PARAMS
3953 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3954 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3955 context->app_id, context->access_token, context->cid, context->uid);
3956 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3960 storage_error_code_t ret = plugin->handle->get_timestamp(context, request,
3961 timestamp, error, response);
3962 plugin_req_exit(ret, plugin, error);
3964 #ifdef DEBUG_ADAPTOR_PARAMS
3965 storage_adaptor_debug_func("[out] return code (%d)", ret);
3966 if (NULL != timestamp) {
3967 storage_adaptor_debug_func("[out] timestamp (%llu)", *timestamp);
3969 if ((NULL != error) && (NULL != *error)) {
3970 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3971 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3973 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3974 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3981 * @brief Requests a file info by public token
3983 * @param[in] plugin specifies Storage Adaptor Plugin handle
3984 * @param[in] context specifies Storage Adaptor Plugin Context handle
3985 * @param[in] public_token specifies token for Download, Get API
3986 (when terminal upload file and add publish=true parameter, or
3987 * @param[in] auth_code specifies Authentication code for public APIs
3988 * @param[in] request specifies optional parameter
3989 * @param[out] file_info specifies Storage Adaptor File Info handle
3990 * @param[out] error specifies error code
3991 * @param[out] response specifies optional parameter
3992 * @return 0 on success, otherwise a positive error value
3993 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3995 storage_error_code_t storage_adaptor_get_file_info_by_public_token(storage_adaptor_plugin_h plugin,
3996 storage_adaptor_plugin_context_h context,
3997 const char *public_token,
3998 const char *auth_code,
4000 storage_adaptor_file_info_h *file_info,
4001 storage_adaptor_error_code_h *error,
4004 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4005 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4007 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4008 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4010 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4011 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4014 storage_adaptor_check_param_equal(NULL, plugin->handle->get_file_info_by_public_token, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4015 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (get_file_info_by_public_token)"));
4017 #ifdef DEBUG_ADAPTOR_PARAMS
4018 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4019 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4020 context->app_id, context->access_token, context->cid, context->uid);
4021 storage_adaptor_debug_func("[in] public_token (%s)", public_token);
4022 storage_adaptor_debug_func("[in] auth_code (%s)", auth_code);
4023 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4027 storage_error_code_t ret = plugin->handle->get_file_info_by_public_token(context, public_token,
4028 auth_code, request, file_info, error, response);
4029 plugin_req_exit(ret, plugin, error);
4031 #ifdef DEBUG_ADAPTOR_PARAMS
4032 storage_adaptor_debug_func("[out] return code (%d)", ret);
4033 if ((NULL != file_info) && (NULL != (*file_info))) {
4034 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
4036 if ((NULL != error) && (NULL != *error)) {
4037 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4038 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4040 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4041 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4048 * @brief Downloads a file by public token (Sync)
4050 * @param[in] plugin specifies Storage Adaptor Plugin handle
4051 * @param[in] context specifies Storage Adaptor Plugin Context handle
4052 * @param[in] public_token specifies token for Download, Get API
4053 (when terminal upload file and add publish=true parameter, or
4054 * @param[in] auth_code specifies Authentication code for public APIs
4055 * @param[in] download_file_local_path specifies local path to download
4056 * @param[in] request specifies optional parameter
4057 * @param[out] error specifies error code
4058 * @param[out] response specifies optional parameter
4059 * @return 0 on success, otherwise a positive error value
4060 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4062 storage_error_code_t storage_adaptor_download_file_sync_by_public_token(storage_adaptor_plugin_h plugin,
4063 storage_adaptor_plugin_context_h context,
4064 const char *public_token,
4065 const char *auth_code,
4066 const char *download_file_local_path,
4068 storage_adaptor_error_code_h *error,
4071 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4072 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4074 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4075 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4077 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4078 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4081 storage_adaptor_check_param_equal(NULL, plugin->handle->download_file_sync_by_public_token, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4082 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (download_file_sync_by_public_token)"));
4084 #ifdef DEBUG_ADAPTOR_PARAMS
4085 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4086 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4087 context->app_id, context->access_token, context->cid, context->uid);
4088 storage_adaptor_debug_func("[in] public_token (%s)", public_token);
4089 storage_adaptor_debug_func("[in] auth_code (%s)", auth_code);
4090 storage_adaptor_debug_func("[in] download_file_local_path (%s)", download_file_local_path);
4091 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4095 storage_error_code_t ret = plugin->handle->download_file_sync_by_public_token(context, public_token,
4096 auth_code, download_file_local_path, request, error, response);
4097 plugin_req_exit(ret, plugin, error);
4099 #ifdef DEBUG_ADAPTOR_PARAMS
4100 storage_adaptor_debug_func("[out] return code (%d)", ret);
4101 if ((NULL != error) && (NULL != *error)) {
4102 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4103 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4105 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4106 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4113 * @brief Downloads a file by public token (Async)
4115 * @param[in] plugin specifies Storage Adaptor Plugin handle
4116 * @param[in] context specifies Storage Adaptor Plugin Context handle
4117 * @param[in] public_token specifies token for Download, Get API
4118 (when terminal upload file and add publish=true parameter, or
4119 * @param[in] auth_code specifies Authentication code for public APIs
4120 * @param[in] download_file_local_path specifies local path to download
4121 * @param[in] request specifies optional parameter
4122 * @param[out] transfer_request_id specifies
4123 * @param[out] error specifies error code
4124 * @return 0 on success, otherwise a positive error value
4125 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4127 storage_error_code_t storage_adaptor_download_file_async_by_public_token(storage_adaptor_plugin_h plugin,
4128 storage_adaptor_plugin_context_h context,
4129 const char *public_token,
4130 const char *auth_code,
4131 const char *download_file_local_path,
4133 void *transfer_request_id,
4134 storage_adaptor_error_code_h *error)
4136 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4137 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4139 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4140 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4142 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4143 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4146 storage_adaptor_check_param_equal(NULL, plugin->handle->download_file_async_by_public_token, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4147 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (download_file_async_by_public_token)"));
4149 #ifdef DEBUG_ADAPTOR_PARAMS
4150 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4151 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4152 context->app_id, context->access_token, context->cid, context->uid);
4153 storage_adaptor_debug_func("[in] public_token (%s)", public_token);
4154 storage_adaptor_debug_func("[in] auth_code (%s)", auth_code);
4155 storage_adaptor_debug_func("[in] download_file_local_path (%s)", download_file_local_path);
4156 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4160 storage_error_code_t ret = plugin->handle->download_file_async_by_public_token(context, public_token,
4161 auth_code, download_file_local_path, request, transfer_request_id);
4162 plugin_req_exit(ret, plugin, error);
4164 #ifdef DEBUG_ADAPTOR_PARAMS
4165 storage_adaptor_debug_func("[out] return code (%d)", ret);
4166 storage_adaptor_debug_func("[out] request_id [addr(%p)]", transfer_request_id);
4167 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4174 * @brief Authenticates public auth code
4176 * @param[in] plugin specifies Storage Adaptor Plugin handle
4177 * @param[in] context specifies Storage Adaptor Plugin Context handle
4178 * @param[in] public_token specifies token for Download, Get API
4179 (when terminal upload file and add publish=true parameter, or
4180 * @param[in] auth_code specifies Authentication code for public APIs
4181 * @param[in] request specifies optional parameter
4182 * @param[out] error specifies error code
4183 * @param[out] response specifies optional parameter
4184 * @return 0 on success, otherwise a positive error value
4185 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4187 storage_error_code_t storage_adaptor_auth_public_authcode_by_public_token(storage_adaptor_plugin_h plugin,
4188 storage_adaptor_plugin_context_h context,
4189 const char *public_token,
4190 const char *auth_code,
4192 storage_adaptor_error_code_h *error,
4195 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4196 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4198 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4199 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4201 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4202 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4205 storage_adaptor_check_param_equal(NULL, plugin->handle->auth_public_authcode_by_public_token, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4206 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (auth_public_authcode_by_public_token)"));
4208 #ifdef DEBUG_ADAPTOR_PARAMS
4209 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4210 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4211 context->app_id, context->access_token, context->cid, context->uid);
4212 storage_adaptor_debug_func("[in] public_token (%s)", public_token);
4213 storage_adaptor_debug_func("[in] auth_code (%s)", auth_code);
4214 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4218 storage_error_code_t ret = plugin->handle->auth_public_authcode_by_public_token(context, public_token,
4219 auth_code, request, error, response);
4220 plugin_req_exit(ret, plugin, error);
4222 #ifdef DEBUG_ADAPTOR_PARAMS
4223 storage_adaptor_debug_func("[out] return code (%d)", ret);
4224 if ((NULL != error) && (NULL != *error)) {
4225 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4226 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4228 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4229 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4236 * @brief Removes multiple files in a folder
4238 * @param[in] plugin specifies Storage Adaptor Plugin handle
4239 * @param[in] context specifies Storage Adaptor Plugin Context handle
4240 * @param[in] parent_folder_storage_path specifies folder path of files you want to delete
4241 * @param[in] file_name_list specifies file name list to be deleted
4242 * @param[in] file_name_list_len specifies total number of files to be deleted
4243 * @param[in] request specifies optional parameter
4244 * @param[out] file_info_list specifies Storage Adaptor File Info handle
4245 * @param[out] file_info_list_len specifies length of the file_info_list
4246 * @param[out] error specifies error code
4247 * @param[out] response specifies optional parameter
4248 * @return 0 on success, otherwise a positive error value
4249 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4251 storage_error_code_t storage_adaptor_delete_multi_file_in_folder(storage_adaptor_plugin_h plugin,
4252 storage_adaptor_plugin_context_h context,
4253 const char *parent_folder_storage_path,
4254 const char **file_name_list,
4255 const int file_name_list_len,
4257 storage_adaptor_file_info_h **file_info_list,
4258 int *file_info_list_len,
4259 storage_adaptor_error_code_h *error,
4262 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4263 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4265 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4266 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4268 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4269 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4272 storage_adaptor_check_param_equal(NULL, plugin->handle->delete_multi_file_in_folder, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4273 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (delete_multi_file_in_folder)"));
4275 #ifdef DEBUG_ADAPTOR_PARAMS
4276 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4277 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4278 context->app_id, context->access_token, context->cid, context->uid);
4279 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
4280 storage_adaptor_debug_func("[in] file_name_list_len (%d)", file_name_list_len);
4281 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4285 storage_error_code_t ret = plugin->handle->delete_multi_file_in_folder(context, parent_folder_storage_path,
4286 file_name_list, file_name_list_len, request, file_info_list, file_info_list_len, error, response);
4287 plugin_req_exit(ret, plugin, error);
4289 #ifdef DEBUG_ADAPTOR_PARAMS
4290 storage_adaptor_debug_func("[out] return code (%d)", ret);
4291 if (NULL != file_info_list_len) {
4292 storage_adaptor_debug_func("[out] file_info_list_len (%d)", *file_info_list_len);
4294 if ((NULL != error) && (NULL != *error)) {
4295 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4296 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4298 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4299 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4306 * @brief Requests policy for upload
4308 * @param[in] plugin specifies Storage Adaptor Plugin handle
4309 * @param[in] context specifies Storage Adaptor Plugin Context handle
4310 * @param[in] request specifies optional parameter
4311 * @param[out] allowed_extension specifies
4312 * @param[out] allowed_extension_len specifies length of allowed_extension
4313 * @param[out] error specifies error code
4314 * @param[out] response specifies optional parameter
4315 * @return 0 on success, otherwise a positive error value
4316 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4318 storage_error_code_t storage_adaptor_get_policy(storage_adaptor_plugin_h plugin,
4319 storage_adaptor_plugin_context_h context,
4321 char ***allowed_extension,
4322 int *allowed_extension_len,
4323 storage_adaptor_error_code_h *error,
4326 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4327 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4329 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4330 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4332 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4333 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4336 storage_adaptor_check_param_equal(NULL, plugin->handle->get_policy, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4337 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (get_policy)"));
4339 #ifdef DEBUG_ADAPTOR_PARAMS
4340 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4341 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4342 context->app_id, context->access_token, context->cid, context->uid);
4343 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4347 storage_error_code_t ret = plugin->handle->get_policy(context, request,
4348 allowed_extension, allowed_extension_len, error, response);
4349 plugin_req_exit(ret, plugin, error);
4351 #ifdef DEBUG_ADAPTOR_PARAMS
4352 storage_adaptor_debug_func("[out] return code (%d)", ret);
4353 if (NULL != allowed_extension_len) {
4354 storage_adaptor_debug_func("[out] allowed_extension_len (%d)", *allowed_extension_len);
4356 if ((NULL != error) && (NULL != *error)) {
4357 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4358 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4360 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4361 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4368 * @brief Requests quota of user
4370 * @param[in] plugin specifies Storage Adaptor Plugin handle
4371 * @param[in] context specifies Storage Adaptor Plugin Context handle
4372 * @param[in] request specifies optional parameter
4373 * @param[out] total_usage specifies total usage of user
4374 * @param[out] total_quota specifies total quota of user
4375 * @param[out] error specifies error code
4376 * @param[out] response specifies optional parameter
4377 * @return 0 on success, otherwise a positive error value
4378 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4380 storage_error_code_t storage_adaptor_get_quota(storage_adaptor_plugin_h plugin,
4381 storage_adaptor_plugin_context_h context,
4383 unsigned long long *total_usage,
4384 unsigned long long *total_quota,
4385 storage_adaptor_error_code_h *error,
4388 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4389 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4391 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4392 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4394 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4395 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4398 storage_adaptor_check_param_equal(NULL, plugin->handle->get_quota, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4399 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (get_quota)"));
4401 #ifdef DEBUG_ADAPTOR_PARAMS
4402 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4403 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4404 context->app_id, context->access_token, context->cid, context->uid);
4405 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4409 storage_error_code_t ret = plugin->handle->get_quota(context, request,
4410 total_usage, total_quota, error, response);
4411 plugin_req_exit(ret, plugin, error);
4413 #ifdef DEBUG_ADAPTOR_PARAMS
4414 storage_adaptor_debug_func("[out] return code (%d)", ret);
4415 if (NULL != total_usage) {
4416 storage_adaptor_debug_func("[out] total_usage (%llu)", *total_usage);
4418 if (NULL != total_quota) {
4419 storage_adaptor_debug_func("[out] total_quota (%llu)", *total_quota);
4421 if ((NULL != error) && (NULL != *error)) {
4422 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4423 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4425 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4426 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4433 * @brief Requests Redirect URL mapped with public token (Not yet supported)
4435 * @param[in] plugin specifies Storage Adaptor Plugin handle
4436 * @param[in] context specifies Storage Adaptor Plugin Context handle
4437 * @param[in] public_token specifies token for Download, Get API
4438 (when terminal upload file and add publish=true parameter, or
4439 * @param[in] request specifies optional parameter
4440 * @param[out] error specifies error code
4441 * @param[out] response specifies optional parameter
4442 * @return 0 on success, otherwise a positive error value
4443 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4445 storage_error_code_t storage_adaptor_redirect_url_by_public_token(storage_adaptor_plugin_h plugin,
4446 storage_adaptor_plugin_context_h context,
4447 const char *public_token,
4449 storage_adaptor_error_code_h *error,
4452 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4453 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4455 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4456 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4458 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4459 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4462 storage_adaptor_check_param_equal(NULL, plugin->handle->redirect_url_by_public_token, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4463 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (redirect_url_by_public_token)"));
4465 #ifdef DEBUG_ADAPTOR_PARAMS
4466 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4467 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4468 context->app_id, context->access_token, context->cid, context->uid);
4469 storage_adaptor_debug_func("[in] public_token (%s)", public_token);
4470 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4474 storage_error_code_t ret = plugin->handle->redirect_url_by_public_token(context, public_token,
4475 request, error, response);
4476 plugin_req_exit(ret, plugin, error);
4478 #ifdef DEBUG_ADAPTOR_PARAMS
4479 storage_adaptor_debug_func("[out] return code (%d)", ret);
4480 if ((NULL != error) && (NULL != *error)) {
4481 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4482 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4484 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4485 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4492 * @brief Creates Upload URL (Not yet supported)
4494 * @param[in] plugin specifies Storage Adaptor Plugin handle
4495 * @param[in] context specifies Storage Adaptor Plugin Context handle
4496 * @param[in] parent_folder_storage_path specifies folder path of files you want to upload
4497 * @param[in] file_name specifies file name to be uploaded
4498 * @param[in] x_upload_content_length specifies length of content
4499 * @param[in] request specifies optional parameter
4500 * @param[out] error specifies error code
4501 * @param[out] response specifies optional parameter
4502 * @return 0 on success, otherwise a positive error value
4503 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4505 storage_error_code_t storage_adaptor_create_resuming_upload_url(storage_adaptor_plugin_h plugin,
4506 storage_adaptor_plugin_context_h context,
4507 const char *parent_folder_storage_path,
4508 const char *file_name,
4509 const unsigned long long x_upload_content_length,
4511 storage_adaptor_error_code_h *error,
4514 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4515 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4517 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4518 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4520 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4521 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4524 storage_adaptor_check_param_equal(NULL, plugin->handle->create_resuming_upload_url, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4525 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (create_resuming_upload_url)"));
4527 #ifdef DEBUG_ADAPTOR_PARAMS
4528 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4529 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4530 context->app_id, context->access_token, context->cid, context->uid);
4531 storage_adaptor_debug_func("[in] parent_folder_storage_path(%s)", parent_folder_storage_path);
4532 storage_adaptor_debug_func("[in] file_name(%s)", file_name);
4533 storage_adaptor_debug_func("[in] x_upload_content_length(%llu)", x_upload_content_length);
4534 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4538 storage_error_code_t ret = plugin->handle->create_resuming_upload_url(context, parent_folder_storage_path,
4539 file_name, x_upload_content_length, request, error, response);
4540 plugin_req_exit(ret, plugin, error);
4542 #ifdef DEBUG_ADAPTOR_PARAMS
4543 storage_adaptor_debug_func("[out] return code (%d)", ret);
4544 if ((NULL != error) && (NULL != *error)) {
4545 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4546 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4548 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4549 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4556 * @brief Creates chunk Upload URL (Not yet supported)
4558 * @param[in] plugin specifies Storage Adaptor Plugin handle
4559 * @param[in] context specifies Storage Adaptor Plugin Context handle
4560 * @param[in] mupload_key specifies Multi Channel Upload key
4561 * @param[in] chunk_number specifies number of chunk (Starting at 1)
4562 * @param[in] x_upload_content_length specifies length of content
4563 * @param[in] request specifies optional parameter
4564 * @param[out] rupload_key specifies Resuming Upload key
4565 * @param[out] error specifies error code
4566 * @param[out] response specifies optional parameter
4567 * @return 0 on success, otherwise a positive error value
4568 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4570 storage_error_code_t storage_adaptor_create_resuming_chunk_upload_url(storage_adaptor_plugin_h plugin,
4571 storage_adaptor_plugin_context_h context,
4572 const char *mupload_key,
4573 const int chunk_number,
4574 const unsigned long long x_upload_content_length,
4577 storage_adaptor_error_code_h *error,
4580 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4581 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4583 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4584 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4586 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4587 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4590 storage_adaptor_check_param_equal(NULL, plugin->handle->create_resuming_chunk_upload_url, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4591 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (create_resuming_chunk_upload_url)"));
4593 #ifdef DEBUG_ADAPTOR_PARAMS
4594 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4595 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4596 context->app_id, context->access_token, context->cid, context->uid);
4597 storage_adaptor_debug_func("[in] mupload_key(%s)", mupload_key);
4598 storage_adaptor_debug_func("[in] chunk_number(%d)", chunk_number);
4599 storage_adaptor_debug_func("[in] x_upload_content_length(%llu)", x_upload_content_length);
4600 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4604 storage_error_code_t ret = plugin->handle->create_resuming_chunk_upload_url(context, mupload_key,
4605 chunk_number, x_upload_content_length, request, rupload_key, error, response);
4606 plugin_req_exit(ret, plugin, error);
4608 #ifdef DEBUG_ADAPTOR_PARAMS
4609 storage_adaptor_debug_func("[out] return code (%d)", ret);
4610 if (NULL != rupload_key) {
4611 storage_adaptor_debug_func("[out] rupload_key (%s)", *rupload_key);
4613 if ((NULL != error) && (NULL != *error)) {
4614 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4615 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4617 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4618 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4625 * @brief Resumes Upload (Not yet supported)
4627 * @param[in] plugin specifies Storage Adaptor Plugin handle
4628 * @param[in] context specifies Storage Adaptor Plugin Context handle
4629 * @param[in] rupload_key specifies Resuming Upload key
4630 * @param[in] content_range specifies range of content
4631 * @param[in] content_length specifies length of content
4632 * @param[in] request specifies optional parameter
4633 * @param[out] error specifies error code
4634 * @param[out] response specifies optional parameter
4635 * @return 0 on success, otherwise a positive error value
4636 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4638 storage_error_code_t storage_adaptor_resuming_upload(storage_adaptor_plugin_h plugin,
4639 storage_adaptor_plugin_context_h context,
4640 const char *rupload_key,
4641 const char *change_range,
4642 const unsigned long long content_length,
4644 storage_adaptor_error_code_h *error,
4647 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4648 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4650 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4651 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4653 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4654 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4657 storage_adaptor_check_param_equal(NULL, plugin->handle->resuming_upload, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4658 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (resuming_upload)"));
4660 #ifdef DEBUG_ADAPTOR_PARAMS
4661 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4662 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4663 context->app_id, context->access_token, context->cid, context->uid);
4664 storage_adaptor_debug_func("[in] rupload_key(%s)", rupload_key);
4665 storage_adaptor_debug_func("[in] change_range(%d)", change_range);
4666 storage_adaptor_debug_func("[in] content_length(%llu)", content_length);
4667 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4671 storage_error_code_t ret = plugin->handle->resuming_upload(context, rupload_key,
4672 change_range, content_length, request, error, response);
4673 plugin_req_exit(ret, plugin, error);
4675 #ifdef DEBUG_ADAPTOR_PARAMS
4676 storage_adaptor_debug_func("[out] return code (%d)", ret);
4677 if ((NULL != error) && (NULL != *error)) {
4678 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4679 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4681 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4682 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4689 * @brief Get progress of file transfer request
4691 * @param[in] plugin specifies Storage Adaptor Plugin handle
4692 * @param[in] context specifies Storage Adaptor Plugin Context handle
4693 * @param[in] transfer_request_id specifies unique id for file transfer request
4694 * @param[in] request specifies optional parameter
4695 * @param[out] progress_size specifies current progress size
4696 * @param[out] total_size specifies total size to transfer
4697 * @param[out] error specifies error code
4698 * @param[out] response specifies optional parameter
4699 * @return 0 on success, otherwise a positive error value
4700 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4702 storage_error_code_t storage_adaptor_get_transfer_progress(storage_adaptor_plugin_h plugin,
4703 storage_adaptor_plugin_context_h context,
4704 void *transfer_request_id,
4706 unsigned long long *progress_size_byte,
4707 unsigned long long *total_size_byte,
4708 storage_adaptor_error_code_h *error,
4711 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4712 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4714 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4715 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4717 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4718 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4721 storage_adaptor_check_param_equal(NULL, plugin->handle->get_transfer_progress, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4722 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (get_transfer_progress)"));
4724 #ifdef DEBUG_ADAPTOR_PARAMS
4725 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4726 storage_adaptor_debug_secure("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4727 context->app_id, context->access_token, context->cid, context->uid);
4728 storage_adaptor_debug_func("[in] tansfer_request_id [addr(%p)]", transfer_request_id);
4729 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4733 storage_error_code_t ret = plugin->handle->get_transfer_progress(context, transfer_request_id,
4734 request, progress_size_byte, total_size_byte, error, response);
4735 plugin_req_exit(ret, plugin, error);
4737 #ifdef DEBUG_ADAPTOR_PARAMS
4738 storage_adaptor_debug_func("[out] return code (%d)", ret);
4739 if (NULL != progress_size_byte) {
4740 storage_adaptor_debug_func("[out] progress size : %10llubyte", *progress_size_byte);
4742 if (NULL != total_size_byte) {
4743 storage_adaptor_debug_func("[out] total size : %10llubyte", *total_size_byte);
4745 if ((NULL != error) && (NULL != *error)) {
4746 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4747 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4749 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4750 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4769 /* ///////////////////////////////////////////////////////////////////////////////
4770 ///////////////////////////////////////////////////////////////////////////////
4771 //////////// Internal function description (for forked plugin) //////////////
4772 ///////////////////////////////////////////////////////////////////////////////
4773 /////////////////////////////////////////////////////////////////////////////// */
4775 void *_storage_adaptor_plugin_message_collector(void *data)
4777 storage_adaptor_h adaptor = (storage_adaptor_h) data;
4779 storage_adaptor_info("3rd party plugin listener run");
4780 int i, lagest_fd = -1;
4783 tv.tv_sec = 10L; /* TODO change to define or meaningful value */
4784 char msg_buf[PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE] = {0, };
4785 int buf_size, rcv_len;
4786 GList *dead_list = NULL;
4789 /* Clears and sets fds for select */
4791 FD_SET(adaptor->rd_cmd[0], &read_set);
4792 lagest_fd = adaptor->rd_cmd[0];
4794 /* Sets plugin fds for select */
4795 for (i = 0; i < g_list_length(adaptor->rd_list); i++) {
4796 int fd = (int) g_list_nth_data(adaptor->rd_list, i);
4797 FD_SET(fd, &read_set);
4798 if (lagest_fd < fd) {
4803 /* Select with timeout (for avoid blocking issue) */
4804 int stmt = select((lagest_fd + 1), &read_set, NULL, NULL, &tv);
4805 IF_IS_PLUGIN_THAN_RETURN_NULL();
4807 /* storage_adaptor_debug("select refrech by timeout(%ld sec) [id : %d]", tv.tv_sec, g_process_identity); */
4808 if (0L >= tv.tv_sec) {
4809 /* storage_adaptor_debug("Resets selector timeout sec"); */
4812 IF_IS_PLUGIN_THAN_RETURN_NULL();
4813 } else if (stmt > 0) {
4814 /* Checking message queue with Plugin processes. */
4815 for (i = 0; i < g_list_length(adaptor->rd_list); i++) {
4816 IF_IS_PLUGIN_THAN_RETURN_NULL();
4817 int fd = (int) g_list_nth_data(adaptor->rd_list, i);
4818 if (FD_ISSET(fd, &read_set)) {
4819 IF_IS_PLUGIN_THAN_RETURN_NULL();
4820 /* pre-read buf size */
4821 rcv_len = read(fd, &buf_size, sizeof(int));
4823 storage_adaptor_debug("Child process dead (Remove from listening queue)");
4824 dead_list = g_list_append(dead_list, (gpointer)fd);
4827 /* allocates and read buf data */
4828 memset(msg_buf, 0, PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE);
4829 buf_size %= (PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE - 1);
4830 rcv_len = read(fd, msg_buf, buf_size);
4831 storage_adaptor_debug("read message [%s][%d]", msg_buf, rcv_len);
4834 /* transfer data to adaptor */
4835 __storage_adaptor_transfer_message(msg_buf);
4837 storage_adaptor_debug("Child process dead (Remove from listening queue)");
4838 dead_list = g_list_append(dead_list, (gpointer)fd);
4843 /* Checking message queue with Adaptor internal command. */
4844 IF_IS_PLUGIN_THAN_RETURN_NULL();
4845 if (FD_ISSET(adaptor->rd_cmd[0], &read_set)) {
4846 int fd = adaptor->rd_cmd[0];
4847 IF_IS_PLUGIN_THAN_RETURN_NULL();
4848 /* pre-read buf size */
4849 rcv_len = read(fd, &buf_size, sizeof(int));
4852 storage_adaptor_debug("Parent process dead : Listener break");
4856 /* allocates and read buf data */
4857 memset(msg_buf, 0, PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE);
4858 buf_size %= (PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE - 1);
4859 rcv_len = read(fd, msg_buf, buf_size);
4860 storage_adaptor_debug("read message [%s][%d]", msg_buf, rcv_len);
4863 storage_adaptor_debug("Parent process dead : Listener break");
4867 /* parse cmd message (e.g. append read_fd / change timeout sec / stop listener) */
4868 int cmd_ret = __storage_adaptor_parse_message_cmd(adaptor, msg_buf);
4870 storage_adaptor_info("3rd party plugin listener stopped by adaptor cmd");
4875 /* Remove fd with disconnected plugin. */
4876 for (i = 0; i < g_list_length(dead_list); i++) {
4877 adaptor->rd_list = g_list_remove(adaptor->rd_list, (gpointer) g_list_nth_data(dead_list, i));
4879 g_list_free(dead_list);
4882 storage_adaptor_error("plugin message listener error (errno : %d)", errno);
4885 storage_adaptor_info("3rd party plugin listener stopped");
4890 void __storage_adaptor_transfer_message(const char *msg)
4892 plugin_message_h t_msg = NULL;
4894 ret = plugin_message_deserialize(msg, &t_msg);
4896 pmnumber req_type, req_id;
4897 ret = plugin_message_get_value_number(t_msg, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE, &req_type);
4898 if (!ret && (PLUGIN_MESSAGE_TYPE_FUNCTION == req_type)) {
4899 storage_adaptor_debug("Message function type : function");
4900 ret = plugin_message_get_value_number(t_msg, PLUGIN_MESSAGE_ELEMENT_REQUEST_ID, &req_id);
4902 storage_adaptor_debug("Send plugin data to requester");
4903 int hooked_fd = (int) req_id;
4904 int len = strlen(msg);
4905 ret = write(hooked_fd, &len, sizeof(int));
4906 ret = write(hooked_fd, msg, sizeof(char) * len);
4908 storage_adaptor_debug("Couldn't get request id");
4910 } else if (!ret && (PLUGIN_MESSAGE_TYPE_CALLBACK == req_type)) {
4911 storage_adaptor_debug("Message function type : callback");
4912 /*TODO call callback function */
4913 char *callback_name = NULL;
4914 ret = plugin_message_get_value_string(t_msg, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME, &callback_name);
4915 storage_adaptor_error("Callback name : %s", callback_name);
4916 if (NULL == callback_name) {
4917 storage_adaptor_error("Function name parsing error");
4918 } else if (0 == strncmp(STORAGE_PLUGIN_CALLBACK_DOWNLOAD_FILE_ASYNC_CB,
4920 strlen(STORAGE_PLUGIN_CALLBACK_DOWNLOAD_FILE_ASYNC_CB))) {
4921 pmnumber fd, state, ret_code;
4922 char *ret_msg = NULL;
4924 storage_adaptor_error_code_h error = NULL;
4925 ret = plugin_message_get_value_number(t_msg, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
4926 ret = plugin_message_get_value_string(t_msg, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_msg);
4927 if (NULL != ret_msg) {
4928 error = storage_adaptor_create_error_code((int64_t) ret_code, ret_msg);
4930 ret = plugin_message_get_param_number(t_msg, param_idx++, &fd);
4931 ret = plugin_message_get_param_number(t_msg, param_idx++, &state);
4933 storage_adaptor_download_state_changed_reply_cb((int)fd, (storage_adaptor_transfer_state_e)state, error, NULL);
4934 storage_adaptor_destroy_error_code(&error);
4935 } else if (0 == strncmp(STORAGE_PLUGIN_CALLBACK_UPLOAD_FILE_ASYNC_CB,
4937 strlen(STORAGE_PLUGIN_CALLBACK_UPLOAD_FILE_ASYNC_CB))) {
4938 pmnumber fd, state, ret_code;
4939 char *ret_msg = NULL;
4941 storage_adaptor_error_code_h error = NULL;
4942 storage_adaptor_file_info_h file_info = NULL;
4943 ret = plugin_message_get_value_number(t_msg, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
4944 ret = plugin_message_get_value_string(t_msg, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_msg);
4945 if (NULL != ret_msg) {
4946 error = storage_adaptor_create_error_code((int64_t) ret_code, ret_msg);
4948 ret = plugin_message_get_param_number(t_msg, param_idx++, &fd);
4949 ret = plugin_message_get_param_number(t_msg, param_idx++, &state);
4951 plugin_message_array_h file_info_message = NULL;
4952 ret = plugin_message_get_param_array(t_msg, param_idx++, &file_info_message);
4953 if ((0 == ret) && (NULL != file_info_message)) {
4954 file_info = _get_file_info_from_message_array(file_info_message, param_idx++);
4957 storage_adaptor_upload_state_changed_reply_cb((int)fd,
4958 (storage_adaptor_transfer_state_e)state, file_info, error, NULL);
4960 storage_adaptor_destroy_file_info(&file_info);
4961 plugin_message_array_destroy(file_info_message);
4962 storage_adaptor_destroy_error_code(&error);
4963 } else if (0 == strncmp(STORAGE_PLUGIN_CALLBACK_PROGRESS_CB,
4965 strlen(STORAGE_PLUGIN_CALLBACK_PROGRESS_CB))) {
4966 pmnumber fd, progress, total, ret_code;
4967 char *ret_msg = NULL;
4969 storage_adaptor_error_code_h error = NULL;
4970 ret = plugin_message_get_value_number(t_msg, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
4971 ret = plugin_message_get_value_string(t_msg, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_msg);
4972 if (NULL != ret_msg) {
4973 error = storage_adaptor_create_error_code((int64_t) ret_code, ret_msg);
4975 ret = plugin_message_get_param_number(t_msg, param_idx++, &fd);
4976 ret = plugin_message_get_param_number(t_msg, param_idx++, &progress);
4977 ret = plugin_message_get_param_number(t_msg, param_idx++, &total);
4979 storage_adaptor_task_progress_reply_cb((int)fd,
4980 (unsigned long long)progress, (unsigned long long)total, error, NULL);
4981 storage_adaptor_destroy_error_code(&error);
4983 storage_adaptor_error("Invalid callback name : %s", callback_name);
4985 free(callback_name);
4987 storage_adaptor_warning("Received message parsing fail.");
4989 plugin_message_destroy(t_msg);
4993 int __storage_adaptor_parse_message_cmd(storage_adaptor_h adaptor, char *msg)
4995 char *cmd_data = NULL;
4996 if (0 == strncmp(PLUGIN_MESSAGE_LISTENER_CMD_APPEND_FD, msg, strlen(PLUGIN_MESSAGE_LISTENER_CMD_APPEND_FD))) {
4997 cmd_data = msg + strlen(PLUGIN_MESSAGE_LISTENER_CMD_APPEND_FD);
4998 int fd = atoi(cmd_data);
5000 adaptor->rd_list = g_list_append(adaptor->rd_list, (gpointer)fd);
5001 } else if (0 == strncmp(PLUGIN_MESSAGE_LISTENER_CMD_STOP, msg, strlen(PLUGIN_MESSAGE_LISTENER_CMD_STOP))) {
5009 void _storage_adaptor_send_cmd_add_fd(storage_adaptor_h adaptor, int fd)
5011 char cmd_buf[256] = {0, };
5012 snprintf(cmd_buf, 255, "%s%d", PLUGIN_MESSAGE_LISTENER_CMD_APPEND_FD, fd);
5013 int len = strlen(cmd_buf);
5016 g_mutex_lock(&adaptor->rd_mutex);
5017 wr_ret = write(adaptor->rd_cmd[1], &len, sizeof(int));
5018 wr_ret = write(adaptor->rd_cmd[1], cmd_buf, sizeof(char) * len);
5019 g_mutex_unlock(&adaptor->rd_mutex);
5020 storage_adaptor_debug("writed (%d)(%s)", wr_ret, cmd_buf);
5023 void _storage_adaptor_send_cmd_stop_listen(storage_adaptor_h adaptor)
5025 char cmd_buf[256] = {0, };
5026 snprintf(cmd_buf, 255, "%s", PLUGIN_MESSAGE_LISTENER_CMD_STOP);
5027 int len = strlen(cmd_buf);
5030 g_mutex_lock(&adaptor->rd_mutex);
5031 wr_ret = write(adaptor->rd_cmd[1], &len, sizeof(int));
5032 wr_ret = write(adaptor->rd_cmd[1], cmd_buf, sizeof(char) * len);
5033 g_mutex_unlock(&adaptor->rd_mutex);
5034 storage_adaptor_debug("writed (%d)(%s)", wr_ret, cmd_buf);
5037 static int storage_adaptor_send_message_to_plugin_sync(storage_adaptor_plugin_h plugin,
5038 plugin_message_h send_message,
5039 plugin_message_h *receive_message)
5042 int wfd = plugin->wd;
5045 if (pipe(sync_hook) != -1) {
5046 char read_buf[PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE] = {0, };
5048 plugin_message_set_value_number(send_message, PLUGIN_MESSAGE_ELEMENT_REQUEST_ID, (pmnumber) sync_hook[1]);
5049 char *stream = NULL;
5050 io_ret = plugin_message_serialize(send_message, &stream);
5051 int len = strlen(stream);
5053 g_mutex_lock(&plugin->message_mutex);
5054 io_ret = write(wfd, &len, sizeof(len));
5055 io_ret = write(wfd, stream, sizeof(char) * len);
5056 g_mutex_unlock(&plugin->message_mutex);
5061 io_ret = read(sync_hook[0], &len, sizeof(len));
5062 memset(read_buf, 0, PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE);
5063 len %= (PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE - 1);
5065 io_ret = read(sync_hook[0], read_buf, len);
5067 storage_adaptor_debug("io ret : %d", io_ret);
5068 close(sync_hook[0]);
5069 close(sync_hook[1]);
5071 plugin_message_h _rcv;
5072 if (0 < strlen(read_buf)) {
5073 io_ret = plugin_message_deserialize(read_buf, &_rcv);
5075 *receive_message = _rcv;
5085 storage_adaptor_plugin_handle_h __storage_adaptor_create_3rd_party_plugin_handle(const char *plugin_uri)
5087 storage_adaptor_plugin_handle_h handle = (storage_adaptor_plugin_handle_h) calloc(1, sizeof(storage_adaptor_plugin_handle_t));
5089 if (NULL == handle) {
5093 handle->create_context = storage_plugin_send_create_context;
5094 handle->destroy_context = storage_plugin_send_destroy_context;
5095 handle->set_server_info = storage_plugin_send_set_server_info;
5096 handle->make_directory = storage_plugin_send_make_directory;
5097 handle->remove_directory = storage_plugin_send_remove_directory;
5098 handle->list = storage_plugin_send_get_list;
5099 handle->upload_file_sync = storage_plugin_send_upload_file_sync;
5100 handle->download_file_sync = storage_plugin_send_download_file_sync;
5101 handle->delete_file = storage_plugin_send_delete_file;
5102 handle->move_directory = storage_plugin_send_move_directory;
5103 handle->move_file = storage_plugin_send_move_file;
5104 handle->set_transfer_state = storage_plugin_send_set_transfer_state;
5105 handle->get_transfer_state = storage_plugin_send_get_transfer_state;
5106 handle->get_root_folder_path = storage_plugin_send_get_root_folder_path;
5108 handle->start_upload_task = storage_plugin_send_start_upload_task;
5109 handle->start_download_task = storage_plugin_send_start_download_task;
5110 handle->start_download_thumb_task = storage_plugin_send_start_download_thumb_task;
5111 handle->cancel_upload_task = storage_plugin_send_cancel_upload_task;
5112 handle->cancel_download_task = storage_plugin_send_cancel_download_task;
5113 handle->cancel_download_thumb_task = storage_plugin_send_cancel_download_thumb_task;
5115 handle->plugin_uri = strdup(plugin_uri);
5120 storage_adaptor_file_info_h _get_file_info_from_message_array(plugin_message_array_h message_array, int index)
5122 storage_adaptor_file_info_h file_info = NULL;
5124 if (NULL == message_array) {
5130 _media_meta->mime_type = NULL;
5131 _media_meta->title = NULL;
5132 _media_meta->album = NULL;
5133 _media_meta->artist = NULL;
5134 _media_meta->genere = NULL;
5135 _media_meta->recorded_date = NULL;
5136 _media_meta->width = -1;
5137 _media_meta->height = -1;
5138 _media_meta->duration = -1;
5139 _media_meta->copyright = NULL;
5140 _media_meta->track_num = NULL;
5141 _media_meta->description = NULL;
5142 _media_meta->composer = NULL;
5143 _media_meta->year = NULL;
5144 _media_meta->bitrate = -1;
5145 _media_meta->samplerate = -1;
5146 _media_meta->channel = -1;
5147 _media_meta->extra_media_meta = NULL;
5149 _cloud_meta->service_name = NULL;
5150 _cloud_meta->usage_byte = 0ULL;
5151 _cloud_meta->quota_byte = 0ULL;
5152 _cloud_meta->extra_cloud_meta = NULL;
5155 char *plugin_uri = NULL;
5156 char *object_id = NULL;
5157 char *storage_path = NULL;
5158 pmnumber file_size = 0LL;
5159 pmnumber created_time = 0LL;
5160 pmnumber modified_time = 0LL;
5161 pmnumber file_info_index = -1LL;
5162 pmnumber content_type = (pmnumber)STORAGE_ADAPTOR_CONTENT_TYPE_DEFAULT;
5163 char *extra_file_info = NULL;
5166 ret = plugin_message_array_get_element(message_array, index, &plugin_uri, &object_id, &storage_path,
5167 &file_size, &created_time, &modified_time, &file_info_index, &content_type, &extra_file_info);
5170 file_info = storage_adaptor_create_file_info();
5172 if (NULL != file_info) {
5173 file_info->plugin_uri = plugin_uri;
5174 file_info->object_id = object_id;
5175 file_info->storage_path = storage_path;
5176 file_info->file_size = (unsigned long long) file_size;
5177 file_info->created_time = (unsigned long long) created_time;
5178 file_info->modified_time = (unsigned long long) modified_time;
5179 file_info->file_info_index = (long long int) file_info_index;
5180 file_info->content_type = (int) content_type;
5181 file_info->extra_file_info = extra_file_info;
5185 free(extra_file_info);
5192 int _message_array_set_file_info(plugin_message_array_h message_array, int index, storage_adaptor_file_info_h file_info)
5194 int ret = STORAGE_ADAPTOR_ERROR_NONE;
5195 if ((NULL == message_array) || (NULL == file_info)) {
5201 _media_meta->mime_type = NULL;
5202 _media_meta->title = NULL;
5203 _media_meta->album = NULL;
5204 _media_meta->artist = NULL;
5205 _media_meta->genere = NULL;
5206 _media_meta->recorded_date = NULL;
5207 _media_meta->width = -1;
5208 _media_meta->height = -1;
5209 _media_meta->duration = -1;
5210 _media_meta->copyright = NULL;
5211 _media_meta->track_num = NULL;
5212 _media_meta->description = NULL;
5213 _media_meta->composer = NULL;
5214 _media_meta->year = NULL;
5215 _media_meta->bitrate = -1;
5216 _media_meta->samplerate = -1;
5217 _media_meta->channel = -1;
5218 _media_meta->extra_media_meta = NULL;
5220 _cloud_meta->service_name = NULL;
5221 _cloud_meta->usage_byte = 0ULL;
5222 _cloud_meta->quota_byte = 0ULL;
5223 _cloud_meta->extra_cloud_meta = NULL;
5226 char *plugin_uri = SAFE_ADD_STRING(file_info->plugin_uri);
5227 char *object_id = SAFE_ADD_STRING(file_info->object_id);
5228 char *storage_path = SAFE_ADD_STRING(file_info->storage_path);
5229 pmnumber file_size = (pmnumber) file_info->file_size;
5230 pmnumber created_time = (pmnumber) file_info->created_time;
5231 pmnumber modified_time = (pmnumber) file_info->modified_time;
5232 pmnumber file_info_index = (pmnumber) file_info->file_info_index;
5233 pmnumber content_type = (pmnumber) file_info->content_type;
5234 char *extra_file_info = SAFE_ADD_STRING(file_info->extra_file_info);
5236 ret = plugin_message_array_add_element(message_array, plugin_uri, object_id, storage_path,
5237 file_size, created_time, modified_time, file_info_index, content_type, extra_file_info);
5245 void change_smack_rule(const char *smack_label)
5250 storage_adaptor_info("smack_label : %s\n", smack_label);
5252 /* Check self process smack */
5253 smack_new_label_from_self(&label);
5254 storage_adaptor_info("now label(%s)\n", label);
5258 /* Change smack label */
5259 ret = smack_set_label_for_self(smack_label);
5260 storage_adaptor_info("set label self(%d)\n", ret);
5262 /* Check self process smack */
5263 smack_new_label_from_self(&label);
5264 storage_adaptor_info("now label(%s)\n", label);
5270 storage_error_code_t storage_plugin_send_create_context(storage_adaptor_plugin_context_h *context,
5272 const char *app_secret,
5273 const char *access_token,
5277 storage_adaptor_plugin_h plugin = NULL;
5278 plugin = (*context)->plugin_handle;
5281 plugin_message_h message = NULL;
5282 ret = plugin_message_create(&message);
5285 (*context)->context_id = (int) (intptr_t)(*context);
5287 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5288 (pmnumber) (*context)->context_id);
5289 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5290 STORAGE_PLUGIN_INTERFACE_CREATE_CONTEXT);
5292 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5293 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5295 int param_index = 1;
5296 plugin_message_set_param_string(message, param_index++, app_id);
5297 plugin_message_set_param_string(message, param_index++, app_secret);
5298 plugin_message_set_param_string(message, param_index++, access_token);
5299 plugin_message_set_param_string(message, param_index++, cid);
5300 plugin_message_set_param_string(message, param_index++, uid);
5302 plugin_message_h result_message = NULL;
5303 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5307 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5309 ret = (int) ret_code;
5311 char *ret_msg = NULL;
5312 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5313 storage_adaptor_debug("Create context successed");
5315 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5316 storage_adaptor_debug("Create context failed (%d)(%s)", ret, ret_msg);
5323 plugin_message_destroy(result_message);
5326 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5328 plugin_message_destroy(message);
5333 storage_error_code_t storage_plugin_send_destroy_context(storage_adaptor_plugin_context_h context)
5335 storage_adaptor_plugin_h plugin = NULL;
5336 plugin = context->plugin_handle;
5339 plugin_message_h message = NULL;
5340 ret = plugin_message_create(&message);
5343 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5344 (pmnumber) context->context_id);
5345 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5346 STORAGE_PLUGIN_INTERFACE_DESTROY_CONTEXT);
5348 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5349 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5351 plugin_message_h result_message = NULL;
5352 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5356 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5358 ret = (int) ret_code;
5360 char *ret_msg = NULL;
5361 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5362 storage_adaptor_debug("Destroy context successed");
5364 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5365 storage_adaptor_debug("Destroy context failed (%d)(%s)", ret, ret_msg);
5369 storage_adaptor_debug("Force release memory by adaptor process");
5370 free(context->access_token);
5374 plugin_message_destroy(result_message);
5377 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5379 plugin_message_destroy(message);
5384 storage_error_code_t storage_plugin_send_set_server_info(storage_adaptor_plugin_context_h context,
5385 GHashTable *server_info,
5387 storage_adaptor_error_code_h *error,
5390 return STORAGE_ADAPTOR_ERROR_UNSUPPORTED;
5393 storage_error_code_t storage_plugin_send_make_directory(storage_adaptor_plugin_context_h context,
5394 const char *parent_folder_storage_path,
5395 const char *folder_name,
5397 storage_adaptor_file_info_h *file_info,
5398 storage_adaptor_error_code_h *error,
5401 storage_adaptor_plugin_h plugin = NULL;
5402 plugin = context->plugin_handle;
5405 plugin_message_h message = NULL;
5406 ret = plugin_message_create(&message);
5409 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5410 (pmnumber) context->context_id);
5411 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5412 STORAGE_PLUGIN_INTERFACE_MAKE_DIRECTORY);
5414 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5415 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5417 int param_index = 1;
5418 plugin_message_set_param_string(message, param_index++, parent_folder_storage_path);
5419 plugin_message_set_param_string(message, param_index++, folder_name);
5421 plugin_message_h result_message = NULL;
5422 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5426 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5428 ret = (int) ret_code;
5429 char *ret_msg = NULL;
5430 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5431 storage_adaptor_debug("Make directory successed");
5433 if (NULL != file_info) {
5434 storage_adaptor_debug("Get file info");
5437 plugin_message_array_h file_info_message = NULL;
5438 param_ret = plugin_message_get_param_array(result_message, param_idx++, &file_info_message);
5439 if ((0 == param_ret) && (NULL != file_info_message)) {
5440 *file_info = _get_file_info_from_message_array(file_info_message, param_idx++);
5442 plugin_message_array_destroy(file_info_message);
5445 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5446 storage_adaptor_debug("Make directory failed (%d)(%s)", ret, ret_msg);
5447 if (NULL != error) {
5448 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
5449 *error = error_code;
5454 plugin_message_destroy(result_message);
5457 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5459 plugin_message_destroy(message);
5465 storage_error_code_t storage_plugin_send_remove_directory(storage_adaptor_plugin_context_h context,
5466 const char *parent_folder_storage_path,
5467 const char *folder_name,
5469 storage_adaptor_file_info_h *file_info,
5470 storage_adaptor_error_code_h *error,
5473 storage_adaptor_plugin_h plugin = NULL;
5474 plugin = context->plugin_handle;
5477 plugin_message_h message = NULL;
5478 ret = plugin_message_create(&message);
5481 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5482 (pmnumber) context->context_id);
5483 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5484 STORAGE_PLUGIN_INTERFACE_REMOVE_DIRECTORY);
5486 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5487 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5489 int param_index = 1;
5490 plugin_message_set_param_string(message, param_index++, parent_folder_storage_path);
5491 plugin_message_set_param_string(message, param_index++, folder_name);
5493 plugin_message_h result_message = NULL;
5494 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5498 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5500 ret = (int) ret_code;
5501 char *ret_msg = NULL;
5502 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5503 storage_adaptor_debug("Remove directory successed");
5505 if (NULL != file_info) {
5506 storage_adaptor_debug("Get file info");
5509 plugin_message_array_h file_info_message = NULL;
5510 param_ret = plugin_message_get_param_array(result_message, param_idx++, &file_info_message);
5511 if ((0 == param_ret) && (NULL != file_info_message)) {
5512 *file_info = _get_file_info_from_message_array(file_info_message, param_idx++);
5514 plugin_message_array_destroy(file_info_message);
5517 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5518 storage_adaptor_debug("Remove directory failed (%d)(%s)", ret, ret_msg);
5519 if (NULL != error) {
5520 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
5521 *error = error_code;
5526 plugin_message_destroy(result_message);
5529 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5531 plugin_message_destroy(message);
5536 storage_error_code_t storage_plugin_send_get_list(storage_adaptor_plugin_context_h context,
5537 const char *parent_folder_storage_path,
5538 const char *folder_name,
5540 storage_adaptor_file_info_h **file_info_list,
5541 int *file_info_list_len,
5542 storage_adaptor_error_code_h *error,
5545 storage_adaptor_plugin_h plugin = NULL;
5546 plugin = context->plugin_handle;
5549 plugin_message_h message = NULL;
5550 ret = plugin_message_create(&message);
5553 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5554 (pmnumber) context->context_id);
5555 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5556 STORAGE_PLUGIN_INTERFACE_REMOVE_DIRECTORY);
5558 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5559 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5561 int param_index = 1;
5562 plugin_message_set_param_string(message, param_index++, parent_folder_storage_path);
5563 plugin_message_set_param_string(message, param_index++, folder_name);
5565 plugin_message_h result_message = NULL;
5566 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5570 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5572 ret = (int) ret_code;
5573 char *ret_msg = NULL;
5574 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5575 storage_adaptor_debug("Get list successed");
5579 param_ret = plugin_message_get_param_number(result_message, 2, &len);
5580 if ((0 == ret) && (NULL != file_info_list) && (len > 0LL)) {
5581 storage_adaptor_debug("Get file info");
5582 plugin_message_array_h file_info_message = NULL;
5583 param_ret = plugin_message_get_param_array(result_message, 1, &file_info_message);
5584 if ((0 == param_ret) && (NULL != file_info_message)) {
5585 int i, l = (int) len;
5586 *file_info_list = (storage_adaptor_file_info_h *) calloc(l, sizeof(storage_adaptor_file_info_h));
5587 if (NULL != *file_info_list) {
5588 for (i = 0; i < l; i++) {
5589 (*file_info_list)[i] = _get_file_info_from_message_array(file_info_message, (i+1));
5591 if (NULL != file_info_list_len) {
5592 *file_info_list_len = l;
5595 plugin_message_array_destroy(file_info_message);
5599 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5600 storage_adaptor_debug("Get list failed (%d)(%s)", ret, ret_msg);
5601 if (NULL != error) {
5602 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
5603 *error = error_code;
5608 plugin_message_destroy(result_message);
5611 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5613 plugin_message_destroy(message);
5619 storage_error_code_t storage_plugin_send_upload_file_sync(storage_adaptor_plugin_context_h context,
5620 const char *parent_folder_storage_path,
5621 const char *file_name,
5622 const char *upload_file_local_path,
5625 storage_adaptor_file_info_h *file_info,
5626 storage_adaptor_error_code_h *error,
5629 storage_adaptor_plugin_h plugin = NULL;
5630 plugin = context->plugin_handle;
5633 plugin_message_h message = NULL;
5634 ret = plugin_message_create(&message);
5637 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5638 (pmnumber) context->context_id);
5639 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5640 STORAGE_PLUGIN_INTERFACE_UPLOAD_FILE_SYNC);
5642 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5643 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5645 int param_index = 1;
5646 plugin_message_set_param_string(message, param_index++, parent_folder_storage_path);
5647 plugin_message_set_param_string(message, param_index++, file_name);
5648 plugin_message_set_param_string(message, param_index++, upload_file_local_path);
5649 plugin_message_set_param_number(message, param_index++, (pmnumber) publish);
5651 plugin_message_h result_message = NULL;
5652 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5656 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5658 ret = (int) ret_code;
5659 char *ret_msg = NULL;
5660 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5661 storage_adaptor_debug("Upload sync successed");
5663 if (NULL != file_info) {
5664 storage_adaptor_debug("Get file info");
5667 plugin_message_array_h file_info_message = NULL;
5668 param_ret = plugin_message_get_param_array(result_message, param_idx++, &file_info_message);
5669 if ((0 == param_ret) && (NULL != file_info_message)) {
5670 *file_info = _get_file_info_from_message_array(file_info_message, param_idx++);
5672 plugin_message_array_destroy(file_info_message);
5675 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5676 storage_adaptor_debug("Upload sync failed (%d)(%s)", ret, ret_msg);
5677 if (NULL != error) {
5678 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
5679 *error = error_code;
5684 plugin_message_destroy(result_message);
5687 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5689 plugin_message_destroy(message);
5695 storage_error_code_t storage_plugin_send_download_file_sync(storage_adaptor_plugin_context_h context,
5696 const char *parent_folder_storage_path,
5697 const char *file_name,
5698 const char *download_file_local_path,
5700 storage_adaptor_error_code_h *error,
5703 storage_adaptor_plugin_h plugin = NULL;
5704 plugin = context->plugin_handle;
5707 plugin_message_h message = NULL;
5708 ret = plugin_message_create(&message);
5711 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5712 (pmnumber) context->context_id);
5713 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5714 STORAGE_PLUGIN_INTERFACE_DOWNLOAD_FILE_SYNC);
5716 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5717 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5719 int param_index = 1;
5720 plugin_message_set_param_string(message, param_index++, parent_folder_storage_path);
5721 plugin_message_set_param_string(message, param_index++, file_name);
5722 plugin_message_set_param_string(message, param_index++, download_file_local_path);
5724 plugin_message_h result_message = NULL;
5725 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5729 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5731 ret = (int) ret_code;
5732 char *ret_msg = NULL;
5733 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5734 storage_adaptor_debug("Download sync successed");
5736 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5737 storage_adaptor_debug("Download sync failed (%d)(%s)", ret, ret_msg);
5738 if (NULL != error) {
5739 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
5740 *error = error_code;
5745 plugin_message_destroy(result_message);
5748 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5750 plugin_message_destroy(message);
5755 storage_error_code_t storage_plugin_send_delete_file(storage_adaptor_plugin_context_h context,
5756 const char *parent_folder_storage_path,
5757 const char *file_name,
5759 storage_adaptor_file_info_h *file_info,
5760 storage_adaptor_error_code_h *error,
5763 storage_adaptor_plugin_h plugin = NULL;
5764 plugin = context->plugin_handle;
5767 plugin_message_h message = NULL;
5768 ret = plugin_message_create(&message);
5771 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5772 (pmnumber) context->context_id);
5773 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5774 STORAGE_PLUGIN_INTERFACE_DELETE_FILE);
5776 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5777 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5779 int param_index = 1;
5780 plugin_message_set_param_string(message, param_index++, parent_folder_storage_path);
5781 plugin_message_set_param_string(message, param_index++, file_name);
5783 plugin_message_h result_message = NULL;
5784 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5788 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5790 ret = (int) ret_code;
5791 char *ret_msg = NULL;
5792 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5793 storage_adaptor_debug("Delete file successed");
5795 if (NULL != file_info) {
5796 storage_adaptor_debug("Get file info");
5799 plugin_message_array_h file_info_message = NULL;
5800 param_ret = plugin_message_get_param_array(result_message, param_idx++, &file_info_message);
5801 if ((0 == param_ret) && (NULL != file_info_message)) {
5802 *file_info = _get_file_info_from_message_array(file_info_message, param_idx++);
5804 plugin_message_array_destroy(file_info_message);
5807 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5808 storage_adaptor_debug("Delete file failed (%d)(%s)", ret, ret_msg);
5809 if (NULL != error) {
5810 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
5811 *error = error_code;
5816 plugin_message_destroy(result_message);
5819 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5821 plugin_message_destroy(message);
5826 storage_error_code_t storage_plugin_send_move_directory(storage_adaptor_plugin_context_h context,
5827 const char *parent_folder_storage_path,
5828 const char *folder_name,
5829 const char *dest_parent_folder_storage_path,
5830 const char *new_folder_name,
5832 storage_adaptor_file_info_h *file_info,
5833 storage_adaptor_error_code_h *error,
5836 storage_adaptor_plugin_h plugin = NULL;
5837 plugin = context->plugin_handle;
5840 plugin_message_h message = NULL;
5841 ret = plugin_message_create(&message);
5844 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5845 (pmnumber) context->context_id);
5846 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5847 STORAGE_PLUGIN_INTERFACE_MOVE_DIRECTORY);
5849 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5850 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5852 int param_index = 1;
5853 plugin_message_set_param_string(message, param_index++, parent_folder_storage_path);
5854 plugin_message_set_param_string(message, param_index++, folder_name);
5855 plugin_message_set_param_string(message, param_index++, dest_parent_folder_storage_path);
5856 plugin_message_set_param_string(message, param_index++, new_folder_name);
5858 plugin_message_h result_message = NULL;
5859 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5863 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5865 ret = (int) ret_code;
5866 char *ret_msg = NULL;
5867 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5868 storage_adaptor_debug("Move directory successed");
5870 if (NULL != file_info) {
5871 storage_adaptor_debug("Get file info");
5874 plugin_message_array_h file_info_message = NULL;
5875 param_ret = plugin_message_get_param_array(result_message, param_idx++, &file_info_message);
5876 if ((0 == param_ret) && (NULL != file_info_message)) {
5877 *file_info = _get_file_info_from_message_array(file_info_message, param_idx++);
5879 plugin_message_array_destroy(file_info_message);
5882 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5883 storage_adaptor_debug("Move directory failed (%d)(%s)", ret, ret_msg);
5884 if (NULL != error) {
5885 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
5886 *error = error_code;
5891 plugin_message_destroy(result_message);
5894 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5896 plugin_message_destroy(message);
5901 storage_error_code_t storage_plugin_send_move_file(storage_adaptor_plugin_context_h context,
5902 const char *parent_folder_storage_path,
5903 const char *file_name,
5904 const char *dest_parent_folder_storage_path,
5905 const char *new_file_name,
5907 storage_adaptor_file_info_h *file_info,
5908 storage_adaptor_error_code_h *error,
5911 storage_adaptor_plugin_h plugin = NULL;
5912 plugin = context->plugin_handle;
5915 plugin_message_h message = NULL;
5916 ret = plugin_message_create(&message);
5919 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5920 (pmnumber) context->context_id);
5921 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5922 STORAGE_PLUGIN_INTERFACE_MOVE_FILE);
5924 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5925 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5927 int param_index = 1;
5928 plugin_message_set_param_string(message, param_index++, parent_folder_storage_path);
5929 plugin_message_set_param_string(message, param_index++, file_name);
5930 plugin_message_set_param_string(message, param_index++, dest_parent_folder_storage_path);
5931 plugin_message_set_param_string(message, param_index++, new_file_name);
5933 plugin_message_h result_message = NULL;
5934 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5938 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5940 ret = (int) ret_code;
5941 char *ret_msg = NULL;
5942 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5943 storage_adaptor_debug("Move file successed");
5945 if (NULL != file_info) {
5946 storage_adaptor_debug("Get file info");
5949 plugin_message_array_h file_info_message = NULL;
5950 param_ret = plugin_message_get_param_array(result_message, param_idx++, &file_info_message);
5951 if ((0 == param_ret) && (NULL != file_info_message)) {
5952 *file_info = _get_file_info_from_message_array(file_info_message, param_idx++);
5954 plugin_message_array_destroy(file_info_message);
5957 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5958 storage_adaptor_debug("Move file failed (%d)(%s)", ret, ret_msg);
5959 if (NULL != error) {
5960 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
5961 *error = error_code;
5966 plugin_message_destroy(result_message);
5969 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5971 plugin_message_destroy(message);
5976 storage_error_code_t storage_plugin_send_set_transfer_state(storage_adaptor_plugin_context_h context,
5977 void *transfer_request_id,
5978 storage_adaptor_transfer_state_e state,
5980 storage_adaptor_error_code_h *error,
5983 storage_adaptor_plugin_h plugin = NULL;
5984 plugin = context->plugin_handle;
5987 plugin_message_h message = NULL;
5988 ret = plugin_message_create(&message);
5991 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5992 (pmnumber) context->context_id);
5993 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5994 STORAGE_PLUGIN_INTERFACE_SET_TRANSFER_STATE);
5995 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5996 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5998 int param_index = 1;
5999 plugin_message_set_param_number(message, param_index++, (pmnumber)(intptr_t)transfer_request_id);
6000 plugin_message_set_param_number(message, param_index++, (pmnumber)state);
6002 plugin_message_h result_message = NULL;
6003 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
6007 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
6009 ret = (int) ret_code;
6010 char *ret_msg = NULL;
6011 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6012 storage_adaptor_debug("Set transfer state successed");
6014 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
6015 storage_adaptor_debug("Set transfer state failed (%d)(%s)", ret, ret_msg);
6016 if (NULL != error) {
6017 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
6018 *error = error_code;
6023 plugin_message_destroy(result_message);
6026 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6028 plugin_message_destroy(message);
6033 storage_error_code_t storage_plugin_send_get_transfer_state(storage_adaptor_plugin_context_h context,
6034 void *transfer_request_id,
6036 storage_adaptor_transfer_state_e *state,
6037 storage_adaptor_error_code_h *error,
6040 storage_adaptor_plugin_h plugin = NULL;
6041 plugin = context->plugin_handle;
6044 plugin_message_h message = NULL;
6045 ret = plugin_message_create(&message);
6048 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
6049 (pmnumber) context->context_id);
6050 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
6051 STORAGE_PLUGIN_INTERFACE_GET_TRANSFER_STATE);
6052 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
6053 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
6055 int param_index = 1;
6056 plugin_message_set_param_number(message, param_index++, (pmnumber)(intptr_t)transfer_request_id);
6058 plugin_message_h result_message = NULL;
6059 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
6063 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
6065 ret = (int) ret_code;
6066 char *ret_msg = NULL;
6067 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6068 storage_adaptor_debug("Get transfer state successed");
6070 plugin_message_get_param_number(message, 1, &st);
6071 if (NULL != state) {
6072 *state = (storage_adaptor_transfer_state_e)st;
6075 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
6076 storage_adaptor_debug("Get transfer state failed (%d)(%s)", ret, ret_msg);
6077 if (NULL != error) {
6078 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
6079 *error = error_code;
6084 plugin_message_destroy(result_message);
6087 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6089 plugin_message_destroy(message);
6094 storage_error_code_t storage_plugin_send_get_root_folder_path(storage_adaptor_plugin_context_h context,
6096 char **root_folder_path,
6097 storage_adaptor_error_code_h *error,
6100 storage_adaptor_plugin_h plugin = NULL;
6101 plugin = context->plugin_handle;
6104 plugin_message_h message = NULL;
6105 ret = plugin_message_create(&message);
6108 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
6109 (pmnumber) context->context_id);
6110 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
6111 STORAGE_PLUGIN_INTERFACE_GET_ROOT_FOLDER_PATH);
6112 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
6113 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
6115 /* int param_index = 1; */
6117 plugin_message_h result_message = NULL;
6118 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
6122 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
6124 ret = (int) ret_code;
6125 char *ret_msg = NULL;
6126 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6127 storage_adaptor_debug("Get root folder path successed");
6129 plugin_message_get_param_string(message, 1, &path);
6130 if (NULL != root_folder_path) {
6131 *root_folder_path = path;
6134 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
6135 storage_adaptor_debug("Get root folder path failed (%d)(%s)", ret, ret_msg);
6136 if (NULL != error) {
6137 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
6138 *error = error_code;
6143 plugin_message_destroy(result_message);
6146 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6148 plugin_message_destroy(message);
6153 /* ///////////// for 2.4 public API */
6154 storage_error_code_t storage_plugin_send_start_upload_task(storage_adaptor_plugin_context_h context,
6156 const char *upload_dir,
6157 const char *file_path,
6159 storage_adaptor_error_code_h *error,
6162 storage_adaptor_plugin_h plugin = NULL;
6163 plugin = context->plugin_handle;
6166 plugin_message_h message = NULL;
6167 ret = plugin_message_create(&message);
6170 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
6171 (pmnumber) context->context_id);
6172 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
6173 STORAGE_PLUGIN_INTERFACE_START_UPLOAD_TASK);
6175 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
6176 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
6178 int param_index = 1;
6179 plugin_message_set_param_number(message, param_index++, (pmnumber)fd);
6180 plugin_message_set_param_string(message, param_index++, upload_dir);
6181 plugin_message_set_param_string(message, param_index++, file_path);
6182 plugin_message_set_param_bool(message, param_index++, need_progress);
6185 plugin_message_set_opt_param_number(message, param_index++, (pmnumber)(intptr_t)user_data);
6187 plugin_message_h result_message = NULL;
6188 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
6190 if ((0 == ret) && (NULL != result_message)) {
6192 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
6194 ret = (int) ret_code;
6195 char *ret_msg = NULL;
6196 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6197 storage_adaptor_debug("Upload file async successed");
6199 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
6200 storage_adaptor_debug("Upload file async failed (%d)(%s)", ret, ret_msg);
6201 if (NULL != error) {
6202 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
6203 *error = error_code;
6208 plugin_message_destroy(result_message);
6211 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6213 plugin_message_destroy(message);
6218 storage_error_code_t storage_plugin_send_start_download_task(storage_adaptor_plugin_context_h context,
6219 const char *storage_dir,
6220 const char *file_path,
6223 storage_adaptor_error_code_h *error,
6226 storage_adaptor_plugin_h plugin = NULL;
6227 plugin = context->plugin_handle;
6230 plugin_message_h message = NULL;
6231 ret = plugin_message_create(&message);
6234 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
6235 (pmnumber) context->context_id);
6236 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
6237 STORAGE_PLUGIN_INTERFACE_START_DOWNLOAD_TASK);
6239 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
6240 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
6242 int param_index = 1;
6243 plugin_message_set_param_string(message, param_index++, storage_dir);
6244 plugin_message_set_param_string(message, param_index++, file_path);
6245 plugin_message_set_param_number(message, param_index++, (pmnumber)fd);
6246 plugin_message_set_param_bool(message, param_index++, need_progress);
6249 plugin_message_set_opt_param_number(message, param_index++, (pmnumber)(intptr_t)user_data);
6251 plugin_message_h result_message = NULL;
6252 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
6254 if ((0 == ret) && (NULL != result_message)) {
6256 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
6258 ret = (int) ret_code;
6259 char *ret_msg = NULL;
6260 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6261 storage_adaptor_debug("Download file async successed");
6263 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
6264 storage_adaptor_debug("Download file async failed (%d)(%s)", ret, ret_msg);
6265 if (NULL != error) {
6266 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
6267 *error = error_code;
6272 plugin_message_destroy(result_message);
6275 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6277 plugin_message_destroy(message);
6282 storage_error_code_t storage_plugin_send_start_download_thumb_task(storage_adaptor_plugin_context_h context,
6283 const char *storage_dir,
6284 const char *file_path,
6288 storage_adaptor_error_code_h *error,
6291 storage_adaptor_plugin_h plugin = NULL;
6292 plugin = context->plugin_handle;
6295 plugin_message_h message = NULL;
6296 ret = plugin_message_create(&message);
6299 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
6300 (pmnumber) context->context_id);
6301 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
6302 STORAGE_PLUGIN_INTERFACE_START_DOWNLOAD_THUMB_TASK);
6304 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
6305 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
6307 int param_index = 1;
6308 plugin_message_set_param_string(message, param_index++, storage_dir);
6309 plugin_message_set_param_string(message, param_index++, file_path);
6310 plugin_message_set_param_number(message, param_index++, (pmnumber)fd);
6311 plugin_message_set_param_number(message, param_index++, (pmnumber)thumbnail_size);
6312 plugin_message_set_param_bool(message, param_index++, need_progress);
6315 plugin_message_set_opt_param_number(message, param_index++, (pmnumber)(intptr_t)user_data);
6317 plugin_message_h result_message = NULL;
6318 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
6320 if ((0 == ret) && (NULL != result_message)) {
6322 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
6324 ret = (int) ret_code;
6325 char *ret_msg = NULL;
6326 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6327 storage_adaptor_debug("Download thumbnail async successed");
6329 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
6330 storage_adaptor_debug("Download thumbnail async failed (%d)(%s)", ret, ret_msg);
6331 if (NULL != error) {
6332 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
6333 *error = error_code;
6338 plugin_message_destroy(result_message);
6341 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6343 plugin_message_destroy(message);
6348 storage_error_code_t storage_plugin_send_cancel_upload_task(storage_adaptor_plugin_context_h context,
6350 storage_adaptor_error_code_h *error)
6352 storage_adaptor_plugin_h plugin = NULL;
6353 plugin = context->plugin_handle;
6356 plugin_message_h message = NULL;
6357 ret = plugin_message_create(&message);
6360 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
6361 (pmnumber) context->context_id);
6362 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
6363 STORAGE_PLUGIN_INTERFACE_CANCEL_UPLOAD_TASK);
6365 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
6366 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
6368 int param_index = 1;
6369 plugin_message_set_param_number(message, param_index++, (pmnumber)fd);
6371 plugin_message_h result_message = NULL;
6372 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
6374 if ((0 == ret) && (NULL != result_message)) {
6376 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
6378 ret = (int) ret_code;
6379 char *ret_msg = NULL;
6380 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6381 storage_adaptor_debug("Upload file async successed");
6383 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
6384 storage_adaptor_debug("Upload file async failed (%d)(%s)", ret, ret_msg);
6385 if (NULL != error) {
6386 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
6387 *error = error_code;
6392 plugin_message_destroy(result_message);
6395 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6397 plugin_message_destroy(message);
6402 storage_error_code_t storage_plugin_send_cancel_download_task(storage_adaptor_plugin_context_h context,
6404 storage_adaptor_error_code_h *error)
6406 storage_adaptor_plugin_h plugin = NULL;
6407 plugin = context->plugin_handle;
6410 plugin_message_h message = NULL;
6411 ret = plugin_message_create(&message);
6414 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
6415 (pmnumber) context->context_id);
6416 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
6417 STORAGE_PLUGIN_INTERFACE_CANCEL_DOWNLOAD_TASK);
6419 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
6420 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
6422 int param_index = 1;
6423 plugin_message_set_param_number(message, param_index++, (pmnumber)fd);
6425 plugin_message_h result_message = NULL;
6426 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
6428 if ((0 == ret) && (NULL != result_message)) {
6430 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
6432 ret = (int) ret_code;
6433 char *ret_msg = NULL;
6434 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6435 storage_adaptor_debug("Cancel upload file successed");
6437 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
6438 storage_adaptor_debug("Cancel upload file failed (%d)(%s)", ret, ret_msg);
6439 if (NULL != error) {
6440 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
6441 *error = error_code;
6446 plugin_message_destroy(result_message);
6449 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6451 plugin_message_destroy(message);
6456 storage_error_code_t storage_plugin_send_cancel_download_thumb_task(storage_adaptor_plugin_context_h context,
6458 storage_adaptor_error_code_h *error)
6460 storage_adaptor_plugin_h plugin = NULL;
6461 plugin = context->plugin_handle;
6464 plugin_message_h message = NULL;
6465 ret = plugin_message_create(&message);
6468 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
6469 (pmnumber) context->context_id);
6470 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
6471 STORAGE_PLUGIN_INTERFACE_CANCEL_DOWNLOAD_THUMB_TASK);
6473 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
6474 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
6476 int param_index = 1;
6477 plugin_message_set_param_number(message, param_index++, (pmnumber)fd);
6479 plugin_message_h result_message = NULL;
6480 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
6482 if ((0 == ret) && (NULL != result_message)) {
6484 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
6486 ret = (int) ret_code;
6487 char *ret_msg = NULL;
6488 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6489 storage_adaptor_debug("Cancel download thumbnail successed");
6491 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
6492 storage_adaptor_debug("Cancel download thumbnail failed (%d)(%s)", ret, ret_msg);
6493 if (NULL != error) {
6494 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
6495 *error = error_code;
6500 plugin_message_destroy(result_message);
6503 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6505 plugin_message_destroy(message);
6510 void storage_plugin_receive_download_state_changed_cb(int file_descriptor,
6511 storage_adaptor_transfer_state_e state,
6512 storage_adaptor_error_code_h error,
6516 plugin_message_h m_callback = NULL;
6518 if ((0 != plugin_message_create(&m_callback)) || (NULL == m_callback)) {
6519 LOGE("[%s/%d] Callback message create failed", __FUNCTION__, __LINE__);
6523 const char *func_name = STORAGE_PLUGIN_CALLBACK_DOWNLOAD_FILE_ASYNC_CB;
6525 plugin_message_set_value_string(m_callback, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME, func_name);
6526 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE, PLUGIN_MESSAGE_TYPE_CALLBACK);
6528 if (NULL == error) {
6529 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)STORAGE_ADAPTOR_ERROR_NONE);
6531 LOGD("[%s/%d] Callback's error value (%lld, %s)", __FUNCTION__, __LINE__, (long long int)error->code, error->msg);
6532 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, (pmnumber)error->code);
6533 plugin_message_set_value_string(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, error->msg);
6537 plugin_message_set_param_number(m_callback, param_idx++, (pmnumber)file_descriptor);
6538 plugin_message_set_param_number(m_callback, param_idx++, (pmnumber)state);
6540 char *result = NULL;
6543 ret = plugin_message_serialize(m_callback, &result);
6545 if ((0 == ret) && (NULL != result)) {
6546 LOGD("[%s/%d] Send callback data message to adaptor", __FUNCTION__, __LINE__);
6547 int res_len = strlen(result);
6548 rcv_len = write(g_child_plugin->wd, &res_len, sizeof(int));
6549 rcv_len = write(g_child_plugin->wd, result, sizeof(char) * res_len);
6551 LOGE("[%s/%d] pipe socket writing error", __FUNCTION__, __LINE__);
6554 LOGE("[%s/%d] Callback data message serialization failed", __FUNCTION__, __LINE__);
6557 plugin_message_destroy(m_callback);
6560 void storage_plugin_receive_upload_state_changed_cb(int file_descriptor,
6561 storage_adaptor_transfer_state_e state,
6562 storage_adaptor_file_info_h file_info,
6563 storage_adaptor_error_code_h error,
6567 plugin_message_h m_callback = NULL;
6569 if ((0 != plugin_message_create(&m_callback)) || (NULL == m_callback)) {
6570 LOGE("[%s/%d] Callback message create failed", __FUNCTION__, __LINE__);
6574 const char *func_name = STORAGE_PLUGIN_CALLBACK_UPLOAD_FILE_ASYNC_CB;
6576 plugin_message_set_value_string(m_callback, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME, func_name);
6577 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE, PLUGIN_MESSAGE_TYPE_CALLBACK);
6579 if (NULL == error) {
6580 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)STORAGE_ADAPTOR_ERROR_NONE);
6582 LOGD("[%s/%d] Callback's error value (%lld, %s)", __FUNCTION__, __LINE__, (long long int)error->code, error->msg);
6583 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, (pmnumber)error->code);
6584 plugin_message_set_value_string(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, error->msg);
6588 plugin_message_set_param_number(m_callback, param_idx++, (pmnumber)file_descriptor);
6589 plugin_message_set_param_number(m_callback, param_idx++, (pmnumber)state);
6591 if (NULL != file_info) {
6592 LOGD("Insert file info to pipe message");
6594 plugin_message_array_h file_info_message = NULL;
6595 char message_array_type[20] = {0, };
6596 snprintf(message_array_type, 19, "%c%c%c%c%c%c%c%c%c", PLUGIN_DATA_TYPE_STRING,
6597 PLUGIN_DATA_TYPE_STRING,
6598 PLUGIN_DATA_TYPE_STRING,
6599 PLUGIN_DATA_TYPE_NUM,
6600 PLUGIN_DATA_TYPE_NUM,
6601 PLUGIN_DATA_TYPE_NUM,
6602 PLUGIN_DATA_TYPE_NUM,
6603 PLUGIN_DATA_TYPE_NUM,
6604 PLUGIN_DATA_TYPE_STRING);
6605 param_ret = plugin_message_array_create(message_array_type, &file_info_message);
6606 if (0 == param_ret) {
6607 _message_array_set_file_info(file_info_message, 1, file_info);
6608 param_ret = plugin_message_set_param_array(m_callback, param_idx++, file_info_message);
6609 plugin_message_array_destroy(file_info_message);
6613 char *result = NULL;
6615 ret = plugin_message_serialize(m_callback, &result);
6617 if ((0 == ret) && (NULL != result)) {
6618 LOGD("[%s/%d] Send callback data message to adaptor", __FUNCTION__, __LINE__);
6619 int res_len = strlen(result);
6620 int rcv_len = write(g_child_plugin->wd, &res_len, sizeof(int));
6621 rcv_len = write(g_child_plugin->wd, result, sizeof(char) * res_len);
6623 LOGE("[%s/%d] pipe socket writing error", __FUNCTION__, __LINE__);
6626 LOGE("[%s/%d] Callback data message serialization failed", __FUNCTION__, __LINE__);
6629 plugin_message_destroy(m_callback);
6633 void storage_plugin_receive_file_progress_cb(int file_descriptor,
6634 unsigned long long progress_size_byte,
6635 unsigned long long total_size_byte,
6636 storage_adaptor_error_code_h error,
6640 plugin_message_h m_callback = NULL;
6642 if ((0 != plugin_message_create(&m_callback)) || (NULL == m_callback)) {
6643 LOGE("[%s/%d] Callback message create failed", __FUNCTION__, __LINE__);
6647 const char *func_name = STORAGE_PLUGIN_CALLBACK_PROGRESS_CB;
6649 plugin_message_set_value_string(m_callback, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME, func_name);
6650 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE, PLUGIN_MESSAGE_TYPE_CALLBACK);
6652 if (NULL == error) {
6653 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)STORAGE_ADAPTOR_ERROR_NONE);
6655 LOGD("[%s/%d] Callback's error value (%lld, %s)", __FUNCTION__, __LINE__, (long long int)error->code, error->msg);
6656 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, (pmnumber)error->code);
6657 plugin_message_set_value_string(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, error->msg);
6661 plugin_message_set_param_number(m_callback, param_idx++, (pmnumber)file_descriptor);
6662 plugin_message_set_param_number(m_callback, param_idx++, (pmnumber)progress_size_byte);
6663 plugin_message_set_param_number(m_callback, param_idx++, (pmnumber)total_size_byte);
6665 char *result = NULL;
6667 ret = plugin_message_serialize(m_callback, &result);
6669 if ((0 == ret) && (NULL != result)) {
6670 LOGD("[%s/%d] Send callback data message to adaptor", __FUNCTION__, __LINE__);
6671 int res_len = strlen(result);
6672 int rcv_len = write(g_child_plugin->wd, &res_len, sizeof(int));
6673 rcv_len = write(g_child_plugin->wd, result, sizeof(char) * res_len);
6675 LOGE("[%s/%d] pipe socket writing error", __FUNCTION__, __LINE__);
6678 LOGE("[%s/%d] Callback data message serialization failed", __FUNCTION__, __LINE__);
6681 plugin_message_destroy(m_callback);
6686 /* For forked plugin */
6687 void *_storage_plugin_request_collector(void *data)
6689 storage_adaptor_plugin_h plugin = (storage_adaptor_plugin_h) data;
6691 int rcv_len, buf_size;
6692 char msg_buf[PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE] = {0, };
6695 /* pre-read buf size */
6696 rcv_len = read(plugin->rd, &buf_size, sizeof(int));
6699 LOGD("shutdown by adaptor disconnected");
6703 /* allocates and read buf data */
6704 memset(msg_buf, 0, PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE);
6705 buf_size %= (PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE - 1);
6706 rcv_len = read(plugin->rd, msg_buf, buf_size);
6707 LOGD("read message [%s][len: %d]", msg_buf, rcv_len);
6710 LOGD("shutdown by adaptor disconnected");
6714 char *result = NULL;
6715 __storage_plugin_progress_command(plugin, msg_buf, &result);
6717 if (NULL != result) {
6718 int res_len = strlen(result);
6719 rcv_len = write(plugin->wd, &res_len, sizeof(int));
6720 rcv_len = write(plugin->wd, result, sizeof(char) * res_len);
6722 /* transfer data to adaptor */
6727 storage_adaptor_plugin_context_h __storage_plugin_get_context_by_context_id(storage_adaptor_plugin_h plugin, int context_id)
6729 if (NULL == plugin) {
6733 /* For forked plugin */
6734 storage_adaptor_plugin_context_h ctx = NULL;
6736 len = g_list_length(plugin->contexts);
6738 for (i = 0; i < len; i++) {
6739 ctx = (storage_adaptor_plugin_context_h) g_list_nth_data(plugin->contexts, i);
6741 if (context_id == ctx->context_id) {
6748 void __storage_plugin_progress_command(storage_adaptor_plugin_h plugin, char *order, char **result)
6751 plugin_message_h m_order = NULL;
6752 plugin_message_h m_result = NULL;
6754 if ((NULL == order) || (plugin_message_deserialize(order, &m_order))) {
6755 LOGE("[%s/%d] Message parse error", __FUNCTION__, __LINE__);
6757 } else if (plugin_message_create(&m_result)) {
6758 plugin_message_destroy(m_order);
6761 LOGE("[%s/%d] Message parse error", __FUNCTION__, __LINE__);
6765 char *func_name = NULL;
6768 pmnumber ctx, req, type;
6770 plugin_message_get_value_number(m_order, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID, &ctx);
6771 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID, ctx);
6772 plugin_message_get_value_number(m_order, PLUGIN_MESSAGE_ELEMENT_REQUEST_ID, &req);
6773 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_REQUEST_ID, req);
6774 plugin_message_get_value_string(m_order, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME, &func_name);
6775 plugin_message_set_value_string(m_result, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME, func_name);
6776 plugin_message_get_value_number(m_order, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE, &type);
6777 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE, type);
6778 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)STORAGE_ADAPTOR_ERROR_NONE);
6779 context_id = (int) ctx;
6780 storage_adaptor_plugin_context_h context = __storage_plugin_get_context_by_context_id(plugin, context_id);
6782 storage_adaptor_error_code_h error_code = NULL;
6783 storage_adaptor_file_info_h file_info = NULL;
6785 if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_CREATE_CONTEXT,
6786 func_name, strlen(STORAGE_PLUGIN_INTERFACE_CREATE_CONTEXT))) {
6787 LOGD(">>>>>> %s func start", func_name);
6788 char *app_id = NULL;
6789 char *app_secret = NULL;
6790 char *access_token = NULL;
6793 char *service_name = NULL;
6796 plugin_message_get_param_string(m_order, param_idx++, &app_id);
6797 plugin_message_get_param_string(m_order, param_idx++, &app_secret);
6798 plugin_message_get_param_string(m_order, param_idx++, &access_token);
6799 plugin_message_get_param_string(m_order, param_idx++, &cid);
6800 plugin_message_get_param_string(m_order, param_idx++, &uid);
6802 LOGD("Call library function");
6803 context = storage_adaptor_create_plugin_context(plugin,
6804 app_id, app_secret, access_token, cid, uid, "");
6806 if (NULL == context) {
6807 LOGE("[%s<%s>/%d] Could not create context", __FUNCTION__, func_name, __LINE__);
6808 /* error_code = storage_adaptor_create_error_code((int64_t)STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL, */
6809 /* "Could not create context"); */
6810 plugin_message_set_value_number(m_result,
6811 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
6812 (pmnumber)STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL);
6813 plugin_message_set_value_string(m_result,
6814 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
6815 "Could not create context");
6817 LOGD("[%s<%s>/%d] Created context successfuly", __FUNCTION__, func_name, __LINE__);
6818 context->context_id = context_id;
6820 plugin_message_set_value_number(m_result,
6821 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
6822 (pmnumber)STORAGE_ADAPTOR_ERROR_NONE);
6831 LOGD("<<<<<< %s func end", func_name);
6832 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_DESTROY_CONTEXT,
6833 func_name, strlen(STORAGE_PLUGIN_INTERFACE_DESTROY_CONTEXT))) {
6834 LOGD(">>>>>> %s func start", func_name);
6835 if (NULL == context) {
6836 LOGE("[%s<%s>/%d] Could not found context", __FUNCTION__, func_name, __LINE__);
6838 LOGD("[%s<%s>/%d] function success", __FUNCTION__, func_name, __LINE__);
6839 storage_adaptor_destroy_plugin_context(plugin, context);
6841 plugin_message_set_value_number(m_result,
6842 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
6843 (pmnumber)STORAGE_ADAPTOR_ERROR_NONE);
6845 LOGD("<<<<<< %s func end", func_name);
6846 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_MAKE_DIRECTORY,
6847 func_name, strlen(STORAGE_PLUGIN_INTERFACE_MAKE_DIRECTORY))) {
6848 LOGD(">>>>>> %s func start", func_name);
6849 char *parent_path = NULL;
6850 char *folder_path = NULL;
6853 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
6854 plugin_message_get_param_string(m_order, param_idx++, &folder_path);
6856 LOGD("Call library function");
6857 ret = plugin->handle->make_directory(context, parent_path, folder_path,
6858 NULL, &file_info, &error_code, NULL);
6860 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6861 LOGD("API success");
6864 if (NULL != file_info) {
6865 LOGD("Insert file info to pipe message");
6867 plugin_message_array_h file_info_message = NULL;
6868 char message_array_type[20] = {0, };
6869 snprintf(message_array_type, 19, "%c%c%c%c%c%c%c%c%c", PLUGIN_DATA_TYPE_STRING,
6870 PLUGIN_DATA_TYPE_STRING,
6871 PLUGIN_DATA_TYPE_STRING,
6872 PLUGIN_DATA_TYPE_NUM,
6873 PLUGIN_DATA_TYPE_NUM,
6874 PLUGIN_DATA_TYPE_NUM,
6875 PLUGIN_DATA_TYPE_NUM,
6876 PLUGIN_DATA_TYPE_NUM,
6877 PLUGIN_DATA_TYPE_STRING);
6878 param_ret = plugin_message_array_create(message_array_type, &file_info_message);
6879 if (0 == param_ret) {
6880 _message_array_set_file_info(file_info_message, 1, file_info);
6881 param_ret = plugin_message_set_param_array(m_result, param_idx++, file_info_message);
6882 plugin_message_array_destroy(file_info_message);
6885 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
6886 } else if (NULL != error_code) {
6887 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
6888 plugin_message_set_value_number(m_result,
6889 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
6890 (pmnumber)error_code->code);
6891 plugin_message_set_value_string(m_result,
6892 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
6893 error_code->msg ? error_code->msg : "");
6894 free(error_code->msg);
6897 LOGD("API failed ret_code[%d]", ret);
6898 plugin_message_set_value_number(m_result,
6899 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
6904 LOGD("<<<<<< %s func end", func_name);
6905 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_REMOVE_DIRECTORY,
6906 func_name, strlen(STORAGE_PLUGIN_INTERFACE_REMOVE_DIRECTORY))) {
6907 LOGD(">>>>>> %s func start", func_name);
6908 char *parent_path = NULL;
6909 char *folder_path = NULL;
6912 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
6913 plugin_message_get_param_string(m_order, param_idx++, &folder_path);
6915 LOGD("Call library function");
6916 ret = plugin->handle->remove_directory(context, parent_path, folder_path,
6917 NULL, &file_info, &error_code, NULL);
6919 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6920 LOGD("API success");
6923 if (NULL != file_info) {
6924 LOGD("Insert file info to pipe message");
6926 plugin_message_array_h file_info_message = NULL;
6927 char message_array_type[20] = {0, };
6928 snprintf(message_array_type, 19, "%c%c%c%c%c%c%c%c%c", PLUGIN_DATA_TYPE_STRING,
6929 PLUGIN_DATA_TYPE_STRING,
6930 PLUGIN_DATA_TYPE_STRING,
6931 PLUGIN_DATA_TYPE_NUM,
6932 PLUGIN_DATA_TYPE_NUM,
6933 PLUGIN_DATA_TYPE_NUM,
6934 PLUGIN_DATA_TYPE_NUM,
6935 PLUGIN_DATA_TYPE_NUM,
6936 PLUGIN_DATA_TYPE_STRING);
6937 param_ret = plugin_message_array_create(message_array_type, &file_info_message);
6938 if (0 == param_ret) {
6939 _message_array_set_file_info(file_info_message, 1, file_info);
6940 param_ret = plugin_message_set_param_array(m_result, param_idx++, file_info_message);
6941 plugin_message_array_destroy(file_info_message);
6944 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
6945 } else if (NULL != error_code) {
6946 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
6947 plugin_message_set_value_number(m_result,
6948 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
6949 (pmnumber)error_code->code);
6950 plugin_message_set_value_string(m_result,
6951 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
6952 error_code->msg ? error_code->msg : "");
6953 free(error_code->msg);
6956 LOGD("API failed ret_code[%d]", ret);
6957 plugin_message_set_value_number(m_result,
6958 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
6963 LOGD("<<<<<< %s func end", func_name);
6964 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_GET_LIST,
6965 func_name, strlen(STORAGE_PLUGIN_INTERFACE_GET_LIST))) {
6966 LOGD(">>>>>> %s func start", func_name);
6967 char *parent_path = NULL;
6968 char *folder_path = NULL;
6971 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
6972 plugin_message_get_param_string(m_order, param_idx++, &folder_path);
6974 storage_adaptor_file_info_h *file_list = NULL;
6975 int file_list_len = 0;
6976 LOGD("Call library function");
6977 ret = plugin->handle->list(context, parent_path, folder_path,
6978 NULL, &file_list, &file_list_len, &error_code, NULL);
6980 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6983 if ((NULL != file_list) && (0 < file_list_len)) {
6984 LOGD("Insert file list to pipe message (length : %d)", file_list_len);
6986 plugin_message_array_h file_info_message = NULL;
6987 char message_array_type[20] = {0, };
6988 snprintf(message_array_type, 19, "%c%c%c%c%c%c%c%c%c", PLUGIN_DATA_TYPE_STRING,
6989 PLUGIN_DATA_TYPE_STRING,
6990 PLUGIN_DATA_TYPE_STRING,
6991 PLUGIN_DATA_TYPE_NUM,
6992 PLUGIN_DATA_TYPE_NUM,
6993 PLUGIN_DATA_TYPE_NUM,
6994 PLUGIN_DATA_TYPE_NUM,
6995 PLUGIN_DATA_TYPE_NUM,
6996 PLUGIN_DATA_TYPE_STRING);
6997 param_ret = plugin_message_array_create(message_array_type, &file_info_message);
6998 if (0 == param_ret) {
6999 for (i = 0; i < file_list_len; i++) {
7000 _message_array_set_file_info(file_info_message, (i + 1), file_list[i]);
7001 storage_adaptor_destroy_file_info(&(file_list[i]));
7005 param_ret = plugin_message_set_param_array(m_result, param_idx++, file_info_message);
7006 param_ret = plugin_message_set_param_number(m_result, param_idx++, (pmnumber)file_list_len);
7007 plugin_message_array_destroy(file_info_message);
7010 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7011 } else if (NULL != error_code) {
7012 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7013 plugin_message_set_value_number(m_result,
7014 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7015 (pmnumber)error_code->code);
7016 plugin_message_set_value_string(m_result,
7017 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7018 error_code->msg ? error_code->msg : "");
7019 free(error_code->msg);
7022 LOGD("API failed ret_code[%d]", ret);
7023 plugin_message_set_value_number(m_result,
7024 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7029 LOGD("<<<<<< %s func end", func_name);
7030 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_UPLOAD_FILE_SYNC,
7031 func_name, strlen(STORAGE_PLUGIN_INTERFACE_UPLOAD_FILE_SYNC))) {
7032 LOGD(">>>>>> %s func start", func_name);
7033 char *parent_path = NULL;
7034 char *folder_path = NULL;
7035 char *local_path = NULL;
7039 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
7040 plugin_message_get_param_string(m_order, param_idx++, &folder_path);
7041 plugin_message_get_param_string(m_order, param_idx++, &local_path);
7042 plugin_message_get_param_number(m_order, param_idx++, &publish);
7044 LOGD("Call library function");
7045 ret = plugin->handle->upload_file_sync(context, parent_path, folder_path, local_path, (int)publish,
7046 NULL, &file_info, &error_code, NULL);
7048 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7049 LOGD("API success");
7052 if (NULL != file_info) {
7053 LOGD("Insert file info to pipe message");
7055 plugin_message_array_h file_info_message = NULL;
7056 char message_array_type[20] = {0, };
7057 snprintf(message_array_type, 19, "%c%c%c%c%c%c%c%c%c", PLUGIN_DATA_TYPE_STRING,
7058 PLUGIN_DATA_TYPE_STRING,
7059 PLUGIN_DATA_TYPE_STRING,
7060 PLUGIN_DATA_TYPE_NUM,
7061 PLUGIN_DATA_TYPE_NUM,
7062 PLUGIN_DATA_TYPE_NUM,
7063 PLUGIN_DATA_TYPE_NUM,
7064 PLUGIN_DATA_TYPE_NUM,
7065 PLUGIN_DATA_TYPE_STRING);
7066 param_ret = plugin_message_array_create(message_array_type, &file_info_message);
7067 if (0 == param_ret) {
7068 _message_array_set_file_info(file_info_message, 1, file_info);
7069 param_ret = plugin_message_set_param_array(m_result, param_idx++, file_info_message);
7070 plugin_message_array_destroy(file_info_message);
7073 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7074 } else if (NULL != error_code) {
7075 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7076 plugin_message_set_value_number(m_result,
7077 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7078 (pmnumber)error_code->code);
7079 plugin_message_set_value_string(m_result,
7080 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7081 error_code->msg ? error_code->msg : "");
7082 free(error_code->msg);
7085 LOGD("API failed ret_code[%d]", ret);
7086 plugin_message_set_value_number(m_result,
7087 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7093 LOGD("<<<<<< %s func end", func_name);
7094 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_DOWNLOAD_FILE_SYNC,
7095 func_name, strlen(STORAGE_PLUGIN_INTERFACE_DOWNLOAD_FILE_SYNC))) {
7096 LOGD(">>>>>> %s func start", func_name);
7097 char *parent_path = NULL;
7098 char *folder_path = NULL;
7099 char *local_path = NULL;
7102 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
7103 plugin_message_get_param_string(m_order, param_idx++, &folder_path);
7104 plugin_message_get_param_string(m_order, param_idx++, &local_path);
7106 LOGD("Call library function");
7107 ret = plugin->handle->download_file_sync(context, parent_path, folder_path, local_path,
7108 NULL, &error_code, NULL);
7110 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7111 LOGD("API success");
7112 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7113 } else if (NULL != error_code) {
7114 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7115 plugin_message_set_value_number(m_result,
7116 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7117 (pmnumber)error_code->code);
7118 plugin_message_set_value_string(m_result,
7119 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7120 error_code->msg ? error_code->msg : "");
7121 free(error_code->msg);
7124 LOGD("API failed ret_code[%d]", ret);
7125 plugin_message_set_value_number(m_result,
7126 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7132 LOGD("<<<<<< %s func end", func_name);
7133 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_DELETE_FILE,
7134 func_name, strlen(STORAGE_PLUGIN_INTERFACE_DELETE_FILE))) {
7135 LOGD(">>>>>> %s func start", func_name);
7136 char *parent_path = NULL;
7137 char *folder_path = NULL;
7140 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
7141 plugin_message_get_param_string(m_order, param_idx++, &folder_path);
7143 LOGD("Call library function");
7144 ret = plugin->handle->delete_file(context, parent_path, folder_path,
7145 NULL, &file_info, &error_code, NULL);
7147 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7148 LOGD("API success");
7151 if (NULL != file_info) {
7152 LOGD("Insert file info to pipe message");
7154 plugin_message_array_h file_info_message = NULL;
7155 char message_array_type[20] = {0, };
7156 snprintf(message_array_type, 19, "%c%c%c%c%c%c%c%c%c", PLUGIN_DATA_TYPE_STRING,
7157 PLUGIN_DATA_TYPE_STRING,
7158 PLUGIN_DATA_TYPE_STRING,
7159 PLUGIN_DATA_TYPE_NUM,
7160 PLUGIN_DATA_TYPE_NUM,
7161 PLUGIN_DATA_TYPE_NUM,
7162 PLUGIN_DATA_TYPE_NUM,
7163 PLUGIN_DATA_TYPE_NUM,
7164 PLUGIN_DATA_TYPE_STRING);
7165 param_ret = plugin_message_array_create(message_array_type, &file_info_message);
7166 if (0 == param_ret) {
7167 _message_array_set_file_info(file_info_message, 1, file_info);
7168 param_ret = plugin_message_set_param_array(m_result, param_idx++, file_info_message);
7169 plugin_message_array_destroy(file_info_message);
7172 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7173 } else if (NULL != error_code) {
7174 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7175 plugin_message_set_value_number(m_result,
7176 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7177 (pmnumber)error_code->code);
7178 plugin_message_set_value_string(m_result,
7179 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7180 error_code->msg ? error_code->msg : "");
7181 free(error_code->msg);
7184 LOGD("API failed ret_code[%d]", ret);
7185 plugin_message_set_value_number(m_result,
7186 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7191 LOGD("<<<<<< %s func end", func_name);
7192 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_MOVE_DIRECTORY,
7193 func_name, strlen(STORAGE_PLUGIN_INTERFACE_MOVE_DIRECTORY))) {
7194 LOGD(">>>>>> %s func start", func_name);
7195 char *parent_path = NULL;
7196 char *folder_path = NULL;
7197 char *dst_parent_path = NULL;
7198 char *dst_folder_path = NULL;
7201 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
7202 plugin_message_get_param_string(m_order, param_idx++, &folder_path);
7203 plugin_message_get_param_string(m_order, param_idx++, &dst_parent_path);
7204 plugin_message_get_param_string(m_order, param_idx++, &dst_folder_path);
7206 LOGD("Call library function");
7207 ret = plugin->handle->move_directory(context, parent_path, folder_path, dst_parent_path, dst_folder_path,
7208 NULL, &file_info, &error_code, NULL);
7210 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7211 LOGD("API success");
7214 if (NULL != file_info) {
7215 LOGD("Insert file info to pipe message");
7217 plugin_message_array_h file_info_message = NULL;
7218 char message_array_type[20] = {0, };
7219 snprintf(message_array_type, 19, "%c%c%c%c%c%c%c%c%c", PLUGIN_DATA_TYPE_STRING,
7220 PLUGIN_DATA_TYPE_STRING,
7221 PLUGIN_DATA_TYPE_STRING,
7222 PLUGIN_DATA_TYPE_NUM,
7223 PLUGIN_DATA_TYPE_NUM,
7224 PLUGIN_DATA_TYPE_NUM,
7225 PLUGIN_DATA_TYPE_NUM,
7226 PLUGIN_DATA_TYPE_NUM,
7227 PLUGIN_DATA_TYPE_STRING);
7228 param_ret = plugin_message_array_create(message_array_type, &file_info_message);
7229 if (0 == param_ret) {
7230 _message_array_set_file_info(file_info_message, 1, file_info);
7231 param_ret = plugin_message_set_param_array(m_result, param_idx++, file_info_message);
7232 plugin_message_array_destroy(file_info_message);
7235 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7236 } else if (NULL != error_code) {
7237 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7238 plugin_message_set_value_number(m_result,
7239 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7240 (pmnumber)error_code->code);
7241 plugin_message_set_value_string(m_result,
7242 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7243 error_code->msg ? error_code->msg : "");
7244 free(error_code->msg);
7247 LOGD("API failed ret_code[%d]", ret);
7248 plugin_message_set_value_number(m_result,
7249 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7254 free(dst_parent_path);
7255 free(dst_folder_path);
7256 LOGD("<<<<<< %s func end", func_name);
7257 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_MOVE_FILE,
7258 func_name, strlen(STORAGE_PLUGIN_INTERFACE_MOVE_FILE))) {
7259 LOGD(">>>>>> %s func start", func_name);
7260 char *parent_path = NULL;
7261 char *file_path = NULL;
7262 char *dst_parent_path = NULL;
7263 char *dst_file_path = NULL;
7266 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
7267 plugin_message_get_param_string(m_order, param_idx++, &file_path);
7268 plugin_message_get_param_string(m_order, param_idx++, &dst_parent_path);
7269 plugin_message_get_param_string(m_order, param_idx++, &dst_file_path);
7271 LOGD("Call library function");
7272 ret = plugin->handle->move_file(context, parent_path, file_path, dst_parent_path, dst_file_path,
7273 NULL, &file_info, &error_code, NULL);
7275 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7276 LOGD("API success");
7279 if (NULL != file_info) {
7280 LOGD("Insert file info to pipe message");
7282 plugin_message_array_h file_info_message = NULL;
7283 char message_array_type[20] = {0, };
7284 snprintf(message_array_type, 19, "%c%c%c%c%c%c%c%c%c", PLUGIN_DATA_TYPE_STRING,
7285 PLUGIN_DATA_TYPE_STRING,
7286 PLUGIN_DATA_TYPE_STRING,
7287 PLUGIN_DATA_TYPE_NUM,
7288 PLUGIN_DATA_TYPE_NUM,
7289 PLUGIN_DATA_TYPE_NUM,
7290 PLUGIN_DATA_TYPE_NUM,
7291 PLUGIN_DATA_TYPE_NUM,
7292 PLUGIN_DATA_TYPE_STRING);
7293 param_ret = plugin_message_array_create(message_array_type, &file_info_message);
7294 if (0 == param_ret) {
7295 _message_array_set_file_info(file_info_message, 1, file_info);
7296 param_ret = plugin_message_set_param_array(m_result, param_idx++, file_info_message);
7297 plugin_message_array_destroy(file_info_message);
7300 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7301 } else if (NULL != error_code) {
7302 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7303 plugin_message_set_value_number(m_result,
7304 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7305 (pmnumber)error_code->code);
7306 plugin_message_set_value_string(m_result,
7307 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7308 error_code->msg ? error_code->msg : "");
7309 free(error_code->msg);
7312 LOGD("API failed ret_code[%d]", ret);
7313 plugin_message_set_value_number(m_result,
7314 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7319 free(dst_parent_path);
7320 free(dst_file_path);
7321 LOGD("<<<<<< %s func end", func_name);
7322 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_START_UPLOAD_TASK,
7323 func_name, strlen(STORAGE_PLUGIN_INTERFACE_START_UPLOAD_TASK))) {
7324 LOGD(">>>>>> %s func start", func_name);
7325 pmnumber fd, user_data;
7326 char *parent_path = NULL;
7327 char *file_name = NULL;
7328 bool need_progress = false;
7331 plugin_message_get_param_number(m_order, param_idx++, &fd);
7332 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
7333 plugin_message_get_param_string(m_order, param_idx++, &file_name);
7334 plugin_message_get_param_bool(m_order, param_idx++, &need_progress);
7337 plugin_message_get_param_number(m_order, param_idx++, &user_data);
7339 LOGD("Call library function");
7340 ret = plugin->handle->start_upload_task(context, (int)fd, parent_path, file_name, need_progress,
7341 &error_code, (void *)(intptr_t)user_data);
7343 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7344 LOGD("API success");
7346 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7347 } else if (NULL != error_code) {
7348 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7349 plugin_message_set_value_number(m_result,
7350 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7351 (pmnumber)error_code->code);
7352 plugin_message_set_value_string(m_result,
7353 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7354 error_code->msg ? error_code->msg : "");
7355 free(error_code->msg);
7358 LOGD("API failed ret_code[%d]", ret);
7359 plugin_message_set_value_number(m_result,
7360 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7365 LOGD("<<<<<< %s func end", func_name);
7366 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_START_DOWNLOAD_TASK,
7367 func_name, strlen(STORAGE_PLUGIN_INTERFACE_START_DOWNLOAD_TASK))) {
7368 LOGD(">>>>>> %s func start", func_name);
7369 pmnumber fd, user_data;
7370 char *parent_path = NULL;
7371 char *file_name = NULL;
7372 bool need_progress = false;
7375 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
7376 plugin_message_get_param_string(m_order, param_idx++, &file_name);
7377 plugin_message_get_param_number(m_order, param_idx++, &fd);
7378 plugin_message_get_param_bool(m_order, param_idx++, &need_progress);
7381 plugin_message_get_param_number(m_order, param_idx++, &user_data);
7383 LOGD("Call library function");
7384 ret = plugin->handle->start_download_task(context, parent_path, file_name, (int)fd, need_progress,
7385 &error_code, (void *)(intptr_t)user_data);
7387 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7388 LOGD("API success");
7390 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7391 } else if (NULL != error_code) {
7392 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7393 plugin_message_set_value_number(m_result,
7394 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7395 (pmnumber)error_code->code);
7396 plugin_message_set_value_string(m_result,
7397 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7398 error_code->msg ? error_code->msg : "");
7399 free(error_code->msg);
7402 LOGD("API failed ret_code[%d]", ret);
7403 plugin_message_set_value_number(m_result,
7404 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7409 LOGD("<<<<<< %s func end", func_name);
7410 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_START_DOWNLOAD_THUMB_TASK,
7411 func_name, strlen(STORAGE_PLUGIN_INTERFACE_START_DOWNLOAD_THUMB_TASK))) {
7412 LOGD(">>>>>> %s func start", func_name);
7413 pmnumber fd, thumb_size, user_data;
7414 char *parent_path = NULL;
7415 char *file_name = NULL;
7416 bool need_progress = false;
7419 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
7420 plugin_message_get_param_string(m_order, param_idx++, &file_name);
7421 plugin_message_get_param_number(m_order, param_idx++, &fd);
7422 plugin_message_get_param_number(m_order, param_idx++, &thumb_size);
7423 plugin_message_get_param_bool(m_order, param_idx++, &need_progress);
7426 plugin_message_get_param_number(m_order, param_idx++, &user_data);
7428 LOGD("Call library function");
7429 ret = plugin->handle->start_download_thumb_task(context, parent_path, file_name, (int)fd, (int)thumb_size, need_progress,
7430 &error_code, (void *)(intptr_t)user_data);
7432 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7433 LOGD("API success");
7435 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7436 } else if (NULL != error_code) {
7437 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7438 plugin_message_set_value_number(m_result,
7439 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7440 (pmnumber)error_code->code);
7441 plugin_message_set_value_string(m_result,
7442 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7443 error_code->msg ? error_code->msg : "");
7444 free(error_code->msg);
7447 LOGD("API failed ret_code[%d]", ret);
7448 plugin_message_set_value_number(m_result,
7449 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7454 LOGD("<<<<<< %s func end", func_name);
7455 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_CANCEL_UPLOAD_TASK,
7456 func_name, strlen(STORAGE_PLUGIN_INTERFACE_CANCEL_UPLOAD_TASK))) {
7457 LOGD(">>>>>> %s func start", func_name);
7461 plugin_message_get_param_number(m_order, param_idx++, &fd);
7463 LOGD("Call library function");
7464 ret = plugin->handle->cancel_upload_task(context, (int)fd, &error_code);
7466 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7467 LOGD("API success");
7469 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7470 } else if (NULL != error_code) {
7471 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7472 plugin_message_set_value_number(m_result,
7473 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7474 (pmnumber)error_code->code);
7475 plugin_message_set_value_string(m_result,
7476 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7477 error_code->msg ? error_code->msg : "");
7478 free(error_code->msg);
7481 LOGD("API failed ret_code[%d]", ret);
7482 plugin_message_set_value_number(m_result,
7483 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7486 LOGD("<<<<<< %s func end", func_name);
7487 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_CANCEL_DOWNLOAD_TASK,
7488 func_name, strlen(STORAGE_PLUGIN_INTERFACE_CANCEL_DOWNLOAD_TASK))) {
7489 LOGD(">>>>>> %s func start", func_name);
7493 plugin_message_get_param_number(m_order, param_idx++, &fd);
7495 LOGD("Call library function");
7496 ret = plugin->handle->cancel_download_task(context, (int)fd, &error_code);
7498 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7499 LOGD("API success");
7501 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7502 } else if (NULL != error_code) {
7503 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7504 plugin_message_set_value_number(m_result,
7505 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7506 (pmnumber)error_code->code);
7507 plugin_message_set_value_string(m_result,
7508 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7509 error_code->msg ? error_code->msg : "");
7510 free(error_code->msg);
7513 LOGD("API failed ret_code[%d]", ret);
7514 plugin_message_set_value_number(m_result,
7515 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7518 LOGD("<<<<<< %s func end", func_name);
7519 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_CANCEL_DOWNLOAD_THUMB_TASK,
7520 func_name, strlen(STORAGE_PLUGIN_INTERFACE_CANCEL_DOWNLOAD_THUMB_TASK))) {
7521 LOGD(">>>>>> %s func start", func_name);
7525 plugin_message_get_param_number(m_order, param_idx++, &fd);
7527 LOGD("Call library function");
7528 ret = plugin->handle->cancel_download_thumb_task(context, (int)fd, &error_code);
7530 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7531 LOGD("API success");
7533 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7534 } else if (NULL != error_code) {
7535 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7536 plugin_message_set_value_number(m_result,
7537 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7538 (pmnumber)error_code->code);
7539 plugin_message_set_value_string(m_result,
7540 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7541 error_code->msg ? error_code->msg : "");
7542 free(error_code->msg);
7545 LOGD("API failed ret_code[%d]", ret);
7546 plugin_message_set_value_number(m_result,
7547 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7550 LOGD("<<<<<< %s func end", func_name);
7551 } else { /* TODO Next */
7552 LOGD(">>>>>> %s func start", func_name);
7553 plugin_message_set_value_number(m_result,
7554 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7555 (pmnumber)STORAGE_ADAPTOR_ERROR_UNSUPPORTED);
7556 plugin_message_set_value_string(m_result,
7557 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7558 "Unsupported operation");
7559 LOGD("<<<<<< %s func end", func_name);
7562 storage_adaptor_destroy_file_info(&file_info);
7565 char *result_data = NULL;
7566 plugin_message_serialize(m_result, &result_data);
7567 plugin_message_destroy(m_result);
7568 plugin_message_destroy(m_order);
7570 *result = result_data;