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>
29 #include <plugin_message.h>
31 #include "storage-adaptor.h"
32 #include "storage-adaptor-log.h"
34 #define PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE 40960
35 #define PLUGIN_MESSAGE_LISTENER_CMD_APPEND_FD "append;"
36 #define PLUGIN_MESSAGE_LISTENER_CMD_STOP "stop;"
38 #define STORAGE_PLUGIN_INTERFACE_CREATE_CONTEXT "create_context"
39 #define STORAGE_PLUGIN_INTERFACE_DESTROY_CONTEXT "destroy_context"
40 #define STORAGE_PLUGIN_INTERFACE_MAKE_DIRECTORY "make_directory"
41 #define STORAGE_PLUGIN_INTERFACE_GET_LIST "get_list"
42 #define STORAGE_PLUGIN_INTERFACE_REMOVE_DIRECTORY "remove_directory"
43 #define STORAGE_PLUGIN_INTERFACE_UPLOAD_FILE_SYNC "upload_file_sync"
44 #define STORAGE_PLUGIN_INTERFACE_DOWNLOAD_FILE_SYNC "download_file_sync"
45 #define STORAGE_PLUGIN_INTERFACE_DELETE_FILE "delete_file"
46 #define STORAGE_PLUGIN_INTERFACE_MOVE_DIRECTORY "move_directory"
47 #define STORAGE_PLUGIN_INTERFACE_MOVE_FILE "move_file"
48 #define STORAGE_PLUGIN_INTERFACE_SET_TRANSFER_STATE "set_transfer_state"
49 #define STORAGE_PLUGIN_INTERFACE_GET_TRANSFER_STATE "get_transfer_state"
50 #define STORAGE_PLUGIN_INTERFACE_GET_ROOT_FOLDER_PATH "get_root_folder_path"
52 /* for 2.4 public functions */
53 #define STORAGE_PLUGIN_INTERFACE_START_UPLOAD_TASK "start_upload_task"
54 #define STORAGE_PLUGIN_INTERFACE_START_DOWNLOAD_TASK "start_download_task"
55 #define STORAGE_PLUGIN_INTERFACE_START_DOWNLOAD_THUMB_TASK "start_download_thumb_task"
56 #define STORAGE_PLUGIN_INTERFACE_CANCEL_UPLOAD_TASK "cancel_upload_task"
57 #define STORAGE_PLUGIN_INTERFACE_CANCEL_DOWNLOAD_TASK "cancel_download_task"
58 #define STORAGE_PLUGIN_INTERFACE_CANCEL_DOWNLOAD_THUMB_TASK "cancel_download_thumb_task"
60 #define STORAGE_PLUGIN_CALLBACK_DOWNLOAD_FILE_ASYNC_CB "download_async_cb"
61 #define STORAGE_PLUGIN_CALLBACK_UPLOAD_FILE_ASYNC_CB "upload_async_cb"
62 #define STORAGE_PLUGIN_CALLBACK_PROGRESS_CB "progress_cb"
64 #define IF_IS_PLUGIN_THAN_RETURN_NULL() do {if (!g_process_identity) return NULL; } while (0)
65 #define SAFE_ADD_STRING(x) (x) ? (x) : ("")
68 PLUGIN_TYPE_INHOUSE = 0,
69 PLUGIN_TYPE_3RD_PARTY = 1,
70 } storage_plugin_type_e;
73 #ifndef FORK_PLUGIN_ARCHITECTURE
74 GHashTable *g_file_uid_list = NULL;
78 * Storage adaptor plugin
80 typedef struct storage_adaptor_plugin_s {
81 storage_adaptor_h adaptor; /* Adaptor */
82 char *path; /* Plugin library path */
83 storage_adaptor_plugin_handle_h handle; /* Plugin handle */
84 void *dl_handle; /* Plugin library handle */
85 int ref_counter; /* Plugin reference counter */
86 GMutex ref_counter_mutex; /* Plugin reference counter mutex */
87 storage_adaptor_plugin_listener_h plugin_listener; /* Plugin callback listener */
88 GMutex plugin_listener_mutex; /* Plugin callback listener mutex */
91 storage_plugin_type_e type;
96 GMutex contexts_mutex;
97 } storage_adaptor_plugin_t;
102 typedef struct storage_adaptor_s {
103 GMutex storage_adaptor_mutex; /* Adaptor mutex */
104 int started; /* Started flag */
105 char *plugins_dir; /* Plugins directory path */
106 GList *plugins; /* List of loaded plugins */
107 GMutex plugins_mutex; /* Plugin list mutex */
108 GList *adaptor_listeners; /* List of vservice channel listener (for now not effective) */
109 GMutex adaptor_listeners_mutex; /* Listener list mutex */
114 pthread_t plugin_listener;
117 static int g_process_identity = -1;
119 static storage_adaptor_plugin_h g_child_plugin = NULL;
124 static storage_adaptor_plugin_h storage_adaptor_create_plugin(const char *plugin_path);
127 * Destroys plugin and deletes all resources associated with it
129 static void storage_adaptor_destroy_plugin(storage_adaptor_plugin_h plugin);
132 * Loads plugins from selected directory
134 static int storage_adaptor_load_plugins_from_directory(storage_adaptor_h adaptor,
135 const char *dir_path);
138 * Checks if plugin is loaded by selected plugin adaptor
140 static int storage_adaptor_has_plugin(storage_adaptor_h adaptor,
141 storage_adaptor_plugin_h plugin);
145 #define GET_PLUGIN_PID() getpid()
147 int _get_plugin_fd_from_file_uid(long long int file_uid)
149 return ((int) (0xffff & file_uid));
152 long long int _get_file_uid_from_plugin_fd(int plugin_fd)
154 long long int plugin_section = 0LL;
155 #ifdef FORK_PLUGIN_ARCHITECTURE
156 /* TODO it must be changed to another index (not support 64bit) */
157 plugin_section = ((long long int) GET_PLUGIN_PID()) << (sizeof(int)*8);
160 return (plugin_section | (long long int)plugin_fd);
164 * Increases adaptor's plugin references counter
166 void storage_adaptor_plugin_ref(storage_adaptor_plugin_h);
169 * Decreases adaptor's plugin references counter
171 void storage_adaptor_plugin_unref(storage_adaptor_plugin_h);
174 /* ///////////////////////////////////////////////////////////////////////////////
175 ///////////// Internal function prototype (for forked plugin) ///////////////
176 /////////////////////////////////////////////////////////////////////////////// */
179 /* To be used by adaptor */
180 void *_storage_adaptor_plugin_message_collector(void *data);
181 void __storage_adaptor_transfer_message(const char *msg);
182 int __storage_adaptor_parse_message_cmd(storage_adaptor_h adaptor, char *msg);
183 void _storage_adaptor_send_cmd_add_fd(storage_adaptor_h adaptor, int fd);
184 void _storage_adaptor_send_cmd_stop_listen(storage_adaptor_h adaptor);
186 static int storage_adaptor_send_message_to_plugin_sync(storage_adaptor_plugin_h plugin,
187 plugin_message_h send_message,
188 plugin_message_h *receive_message);
190 /* To be used by adaptor (virtual plugin handle) */
191 storage_adaptor_plugin_handle_h __storage_adaptor_create_3rd_party_plugin_handle(const char *plugin_uri);
193 storage_error_code_t storage_plugin_send_create_context(storage_adaptor_plugin_context_h *context,
195 const char *app_secret,
196 const char *access_token,
200 storage_error_code_t storage_plugin_send_destroy_context(storage_adaptor_plugin_context_h context);
202 storage_error_code_t storage_plugin_send_set_server_info(storage_adaptor_plugin_context_h context,
203 GHashTable *server_info,
205 storage_adaptor_error_code_h *error,
208 storage_error_code_t storage_plugin_send_make_directory(storage_adaptor_plugin_context_h context,
209 const char *parent_folder_storage_path,
210 const char *folder_name,
212 storage_adaptor_file_info_h *file_info,
213 storage_adaptor_error_code_h *error,
216 storage_error_code_t storage_plugin_send_remove_directory(storage_adaptor_plugin_context_h context,
217 const char *parent_folder_storage_path,
218 const char *folder_name,
220 storage_adaptor_file_info_h *file_info,
221 storage_adaptor_error_code_h *error,
224 storage_error_code_t storage_plugin_send_get_list(storage_adaptor_plugin_context_h context,
225 const char *parent_folder_storage_path,
226 const char *folder_name,
228 storage_adaptor_file_info_h **file_info_list,
229 int *file_info_list_len,
230 storage_adaptor_error_code_h *error,
233 storage_error_code_t storage_plugin_send_upload_file_sync(storage_adaptor_plugin_context_h context,
234 const char *parent_folder_storage_path,
235 const char *file_name,
236 const char *upload_file_local_path,
239 storage_adaptor_file_info_h *file_info,
240 storage_adaptor_error_code_h *error,
243 storage_error_code_t storage_plugin_send_download_file_sync(storage_adaptor_plugin_context_h context,
244 const char *parent_folder_storage_path,
245 const char *file_name,
246 const char *download_file_local_path,
248 storage_adaptor_error_code_h *error,
251 storage_error_code_t storage_plugin_send_delete_file(storage_adaptor_plugin_context_h context,
252 const char *parent_folder_storage_path,
253 const char *file_name,
255 storage_adaptor_file_info_h *file_info,
256 storage_adaptor_error_code_h *error,
259 storage_error_code_t storage_plugin_send_move_directory(storage_adaptor_plugin_context_h context,
260 const char *parent_folder_storage_path,
261 const char *folder_name,
262 const char *dest_parent_folder_storage_path,
263 const char *new_folder_name,
265 storage_adaptor_file_info_h *file_info,
266 storage_adaptor_error_code_h *error,
269 storage_error_code_t storage_plugin_send_move_file(storage_adaptor_plugin_context_h context,
270 const char *parent_folder_storage_path,
271 const char *file_name,
272 const char *dest_parent_folder_storage_path,
273 const char *new_file_name,
275 storage_adaptor_file_info_h *file_info,
276 storage_adaptor_error_code_h *error,
279 storage_error_code_t storage_plugin_send_set_transfer_state(storage_adaptor_plugin_context_h context,
280 void *transfer_request_id,
281 storage_adaptor_transfer_state_e state,
283 storage_adaptor_error_code_h *error,
286 storage_error_code_t storage_plugin_send_get_transfer_state(storage_adaptor_plugin_context_h context,
287 void *transfer_request_id,
289 storage_adaptor_transfer_state_e *state,
290 storage_adaptor_error_code_h *error,
293 storage_error_code_t storage_plugin_send_get_root_folder_path(storage_adaptor_plugin_context_h context,
295 char **root_folder_path,
296 storage_adaptor_error_code_h *error,
299 storage_error_code_t storage_plugin_send_start_upload_task(storage_adaptor_plugin_context_h context,
301 const char *upload_dir,
302 const char *file_path,
304 storage_adaptor_error_code_h *error,
307 storage_error_code_t storage_plugin_send_start_download_task(storage_adaptor_plugin_context_h context,
308 const char *storage_dir,
309 const char *file_path,
312 storage_adaptor_error_code_h *error,
315 storage_error_code_t storage_plugin_send_start_download_thumb_task(storage_adaptor_plugin_context_h context,
316 const char *storage_dir,
317 const char *file_path,
321 storage_adaptor_error_code_h *error,
324 storage_error_code_t storage_plugin_send_cancel_upload_task(storage_adaptor_plugin_context_h context,
326 storage_adaptor_error_code_h *error);
328 storage_error_code_t storage_plugin_send_cancel_download_task(storage_adaptor_plugin_context_h context,
330 storage_adaptor_error_code_h *error);
332 storage_error_code_t storage_plugin_send_cancel_download_thumb_task(storage_adaptor_plugin_context_h context,
334 storage_adaptor_error_code_h *error);
336 /* To be used by forked plugin */
337 void *_storage_plugin_request_collector(void *data);
338 storage_adaptor_plugin_context_h __storage_plugin_get_context_by_context_id(storage_adaptor_plugin_h plugin, int context_id);
339 void __storage_plugin_progress_command(storage_adaptor_plugin_h plugin, char *order, char **result);
342 storage_adaptor_file_info_h _get_file_info_from_message_array(plugin_message_array_h message_array, int index);
344 int _message_array_set_file_info(plugin_message_array_h message_array, int index, storage_adaptor_file_info_h file_info);
347 * Definition of callback function variables for vservice channel (= infra adaptor) (example)
349 /* private feature */
350 storage_adaptor_service_download_file_async_reply_cb _service_adaptor_download_file_async_reply = NULL;
351 storage_adaptor_service_upload_file_async_reply_cb _service_adaptor_upload_file_async_reply = NULL;
352 storage_adaptor_service_file_transfer_progress_reply_cb _service_adaptor_file_transfer_progress_reply = NULL;
355 storage_adaptor_service_download_state_changed_reply_cb _service_adaptor_download_state_changed_reply = NULL;
356 storage_adaptor_service_upload_state_changed_reply_cb _service_adaptor_upload_state_changed_reply = NULL;
357 storage_adaptor_service_task_progress_reply_cb _service_adaptor_task_progress_reply = NULL;
360 * Gets a message from plugin (callback) when a sms message is received (sample)
362 /* private feature */
363 void storage_adaptor_download_file_async_reply_cb(void *request_id,
364 char *download_file_local_path,
365 storage_adaptor_error_code_h error,
368 if (NULL != _service_adaptor_download_file_async_reply) {
369 _service_adaptor_download_file_async_reply(request_id,
370 download_file_local_path, error, response);
374 void storage_adaptor_upload_file_async_reply_cb(void *request_id,
375 storage_adaptor_file_info_h file_info,
376 storage_adaptor_error_code_h error,
379 if (NULL != _service_adaptor_upload_file_async_reply) {
380 _service_adaptor_upload_file_async_reply(request_id,
381 file_info, error, response);
385 void storage_adaptor_file_transfer_progress_reply_cb(void *request_id,
386 unsigned long long progress_size_byte,
387 unsigned long long total_size_byte,
388 storage_adaptor_error_code_h error,
391 if (NULL != _service_adaptor_file_transfer_progress_reply) {
392 _service_adaptor_file_transfer_progress_reply(request_id,
393 progress_size_byte, total_size_byte, error, response);
398 void storage_adaptor_download_state_changed_reply_cb(int file_descriptor,
399 storage_adaptor_transfer_state_e state,
400 storage_adaptor_error_code_h error,
403 if ((state == STORAGE_ADAPTOR_TRANSFER_STATE_FINISHED)
404 || (state == STORAGE_ADAPTOR_TRANSFER_STATE_CANCELED)
405 || (state == STORAGE_ADAPTOR_TRANSFER_STATE_FAILED)) {
406 close(file_descriptor);
409 if (NULL != _service_adaptor_download_state_changed_reply) {
410 long long int file_uid = _get_file_uid_from_plugin_fd(file_descriptor);
411 _service_adaptor_download_state_changed_reply(file_uid,
412 state, error, user_data);
416 void storage_adaptor_upload_state_changed_reply_cb(int file_descriptor,
417 storage_adaptor_transfer_state_e state,
418 storage_adaptor_file_info_h file_info,
419 storage_adaptor_error_code_h error,
422 if ((state == STORAGE_ADAPTOR_TRANSFER_STATE_FINISHED)
423 || (state == STORAGE_ADAPTOR_TRANSFER_STATE_CANCELED)
424 || (state == STORAGE_ADAPTOR_TRANSFER_STATE_FAILED)) {
425 close(file_descriptor);
428 if (NULL != _service_adaptor_upload_state_changed_reply) {
429 long long int file_uid = _get_file_uid_from_plugin_fd(file_descriptor);
430 _service_adaptor_upload_state_changed_reply(file_uid,
431 state, file_info, error, user_data);
435 void storage_adaptor_task_progress_reply_cb(int file_descriptor,
436 unsigned long long progress_size_byte,
437 unsigned long long total_size_byte,
438 storage_adaptor_error_code_h error,
441 if (NULL != _service_adaptor_task_progress_reply) {
442 long long int file_uid = _get_file_uid_from_plugin_fd(file_descriptor);
443 _service_adaptor_task_progress_reply(file_uid,
444 progress_size_byte, total_size_byte);
448 /* //------------------------------------------------------------------------
449 // Functions implementations
450 //------------------------------------------------------------------------ */
452 /* //////////////////////////////////////////////////////////
453 // Adaptor Defined Plugin Function
454 ////////////////////////////////////////////////////////// */
456 storage_error_code_t storage_plugin_open_file(storage_adaptor_plugin_context_h context,
457 const char *file_path,
458 storage_adaptor_file_access_mode_e mode,
459 int *file_descriptor,
460 storage_adaptor_error_code_h *error)
462 storage_error_code_t ret = STORAGE_ADAPTOR_ERROR_NONE;
464 if ((NULL == file_descriptor) || (NULL == file_path)) {
466 *error = storage_adaptor_create_error_code((int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
467 "Invalid parameter");
469 ret = STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
472 if (STORAGE_ADAPTOR_FILE_ACCESS_READ == mode) {
473 fd = open(file_path, mode);
474 } else if (STORAGE_ADAPTOR_FILE_ACCESS_WRITE == mode) {
475 fd = open(file_path, mode, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
478 *error = storage_adaptor_create_error_code((int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
479 "Invalid parameter (file mode)");
481 ret = STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
486 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
488 if (EEXIST == errno) {
489 error_code = (int64_t) STORAGE_PLUGIN_ERROR_FILE_AREADY_EXIST;
490 } else if (EACCES == errno) {
491 error_code = (int64_t) STORAGE_PLUGIN_ERROR_FILE_ACCESS_DENIED;
493 error_code = (int64_t) STORAGE_PLUGIN_ERROR_FILE_OPEN_FAILED;
496 *error = storage_adaptor_create_error_code(error_code,
500 *file_descriptor = fd;
506 storage_error_code_t storage_plugin_close_file(storage_adaptor_plugin_context_h context,
508 storage_adaptor_error_code_h *error)
510 storage_error_code_t ret = STORAGE_ADAPTOR_ERROR_NONE;
512 int r = close(file_descriptor);
514 storage_adaptor_debug("close ret : %d", r);
521 /* //////////////////////////////////////////////////////
522 // Mandatory: External adaptor management function
523 ////////////////////////////////////////////////////// */
524 storage_adaptor_h storage_adaptor_create(const char *plugins_dir)
526 if (NULL == plugins_dir) {
527 storage_adaptor_error("Invalid argument""(plugins_dir: %p", plugins_dir);
531 storage_adaptor_h storage_adaptor = (storage_adaptor_h) malloc(sizeof(storage_adaptor_t));
533 if (NULL == storage_adaptor) {
534 storage_adaptor_error("Critical : Memory allocation failed");
538 /* for forked plugin */
539 if (pipe(storage_adaptor->rd_cmd) == -1) {
540 free(storage_adaptor);
543 g_mutex_init(&storage_adaptor->rd_mutex);
544 storage_adaptor->rd_list = NULL;
546 storage_adaptor->started = 0;
547 storage_adaptor->plugins_dir = strdup(plugins_dir);
549 g_mutex_init(&storage_adaptor->storage_adaptor_mutex);
550 g_mutex_init(&storage_adaptor->plugins_mutex);
551 g_mutex_init(&storage_adaptor->adaptor_listeners_mutex);
553 g_mutex_lock(&storage_adaptor->adaptor_listeners_mutex);
554 storage_adaptor->adaptor_listeners = NULL;
555 g_mutex_unlock(&storage_adaptor->adaptor_listeners_mutex);
557 g_mutex_lock(&storage_adaptor->plugins_mutex);
558 storage_adaptor->plugins = NULL;
559 g_mutex_unlock(&storage_adaptor->plugins_mutex);
561 #ifndef FORK_PLUGIN_ARCHITECTURE
562 g_file_uid_list = g_hash_table_new_full(g_int_hash, g_int_equal, NULL, free);
565 return storage_adaptor;
568 void storage_adaptor_destroy(storage_adaptor_h adaptor)
570 if (NULL == adaptor) {
571 storage_adaptor_error("Invalid argument""(adaptor: %p)", adaptor);
575 g_mutex_lock(&adaptor->storage_adaptor_mutex);
576 if (0 != adaptor->started) {
577 storage_adaptor_error("Storage adaptor is running. Forcing stop before destroy");
578 storage_adaptor_stop(adaptor);
581 g_mutex_lock(&adaptor->plugins_mutex);
582 if (NULL != adaptor->plugins) {
583 g_list_free_full(adaptor->plugins, (GDestroyNotify) storage_adaptor_plugin_unref);
584 adaptor->plugins = NULL;
586 g_mutex_unlock(&adaptor->plugins_mutex);
588 g_mutex_lock(&adaptor->adaptor_listeners_mutex);
589 if (NULL != adaptor->adaptor_listeners) {
590 g_list_free(adaptor->adaptor_listeners);
591 adaptor->adaptor_listeners = NULL;
593 g_mutex_unlock(&adaptor->adaptor_listeners_mutex);
595 _service_adaptor_download_file_async_reply = NULL;
596 _service_adaptor_upload_file_async_reply = NULL;
597 _service_adaptor_file_transfer_progress_reply = NULL;
598 _service_adaptor_download_state_changed_reply = NULL;
599 _service_adaptor_upload_state_changed_reply = NULL;
600 _service_adaptor_task_progress_reply = NULL;
602 free(adaptor->plugins_dir);
603 adaptor->plugins_dir = NULL;
605 g_mutex_unlock(&adaptor->storage_adaptor_mutex);
607 #ifndef FORK_PLUGIN_ARCHITECTURE
608 g_hash_table_destroy(g_file_uid_list);
611 /* For forked plugin */
612 g_list_free(adaptor->rd_list);
613 close(adaptor->rd_cmd[0]);
614 close(adaptor->rd_cmd[1]);
619 int storage_adaptor_start(storage_adaptor_h adaptor)
621 storage_adaptor_debug("Starting storage adaptor");
622 if (NULL == adaptor) {
623 storage_adaptor_error("Invalid argument""(adaptor: %p)", adaptor);
624 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
627 g_mutex_lock(&adaptor->storage_adaptor_mutex);
628 int result = STORAGE_ADAPTOR_ERROR_NONE;
629 if (0 != adaptor->started) {
630 storage_adaptor_error("Storage adaptor is already started");
631 result = STORAGE_ADAPTOR_ERROR_START;
633 adaptor->started = 1;
636 if (pthread_create(&pid, NULL, _storage_adaptor_plugin_message_collector, (void *)adaptor)) {
637 adaptor->started = 0;
638 storage_adaptor_error("Could not create 3rd party plugin listener");
639 result = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
640 } else if (STORAGE_ADAPTOR_ERROR_NONE != (result = storage_adaptor_load_plugins_from_directory(adaptor, adaptor->plugins_dir))) {
641 _storage_adaptor_send_cmd_stop_listen(adaptor);
642 adaptor->started = 0;
643 storage_adaptor_error("Could not load plugins from directory");
644 result = STORAGE_ADAPTOR_ERROR_NOT_FOUND;
646 adaptor->plugin_listener = pid;
647 storage_adaptor_info("Storage adaptor started successfully");
650 g_mutex_unlock(&adaptor->storage_adaptor_mutex);
655 int storage_adaptor_stop(storage_adaptor_h adaptor)
657 if (NULL == adaptor) {
658 storage_adaptor_error("Invalid argument""(adaptor: %p)", adaptor);
659 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
662 g_mutex_lock(&adaptor->storage_adaptor_mutex);
664 /* For forked plugin */
665 storage_adaptor_debug("stop plugin listener");
666 _storage_adaptor_send_cmd_stop_listen(adaptor);
667 pthread_join(adaptor->plugin_listener, NULL);
669 int result = STORAGE_ADAPTOR_ERROR_NONE;
670 if (0 == adaptor->started) {
671 result = STORAGE_ADAPTOR_ERROR_START;
673 if (NULL != adaptor->plugins) {
674 g_mutex_lock(&adaptor->plugins_mutex);
675 g_list_free_full(adaptor->plugins, (GDestroyNotify) storage_adaptor_plugin_unref);
676 adaptor->plugins = NULL;
677 g_mutex_unlock(&adaptor->plugins_mutex);
679 adaptor->started = 0;
680 storage_adaptor_debug("Storage adaptor stopped");
683 g_mutex_unlock(&adaptor->storage_adaptor_mutex);
687 int storage_adaptor_register_listener(storage_adaptor_h adaptor,
688 storage_adaptor_listener_h listener)
690 if ((NULL == adaptor) || (NULL == listener)) {
691 storage_adaptor_error("Invalid argument""(adaptor: %p, listener: %p)", adaptor, listener);
692 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
695 g_mutex_lock(&adaptor->adaptor_listeners_mutex);
697 adaptor->adaptor_listeners = g_list_append(adaptor->adaptor_listeners, listener);
699 g_mutex_unlock(&adaptor->adaptor_listeners_mutex);
701 _service_adaptor_download_file_async_reply =
702 (storage_adaptor_service_download_file_async_reply_cb) listener->download_file_async_reply;
703 _service_adaptor_upload_file_async_reply =
704 (storage_adaptor_service_upload_file_async_reply_cb) listener->upload_file_async_reply;
705 _service_adaptor_file_transfer_progress_reply =
706 (storage_adaptor_service_file_transfer_progress_reply_cb) listener->file_transfer_progress_reply;
707 _service_adaptor_download_state_changed_reply =
708 (storage_adaptor_service_download_state_changed_reply_cb) listener->download_state_changed_reply;
709 _service_adaptor_upload_state_changed_reply =
710 (storage_adaptor_service_upload_state_changed_reply_cb) listener->upload_state_changed_reply;
711 _service_adaptor_task_progress_reply =
712 (storage_adaptor_service_task_progress_reply_cb) listener->task_progress_reply;
714 return STORAGE_ADAPTOR_ERROR_NONE;
717 int storage_adaptor_unregister_listener(storage_adaptor_h adaptor,
718 storage_adaptor_listener_h listener)
720 if (NULL == adaptor) {
721 storage_adaptor_error("Invalid argument (adaptor)");
722 if (NULL != listener) {
726 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
728 if (NULL == listener) {
729 storage_adaptor_error("Invalid argument (listener)");
730 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
733 g_mutex_lock(&adaptor->adaptor_listeners_mutex);
735 if (NULL == g_list_find(adaptor->adaptor_listeners, listener)) {
736 g_mutex_unlock(&adaptor->adaptor_listeners_mutex);
737 storage_adaptor_error("Could not find listener");
739 return STORAGE_ADAPTOR_ERROR_NOT_FOUND;
742 adaptor->adaptor_listeners = g_list_remove(adaptor->adaptor_listeners, listener);
745 g_mutex_unlock(&adaptor->adaptor_listeners_mutex);
747 _service_adaptor_download_file_async_reply = NULL;
748 _service_adaptor_upload_file_async_reply = NULL;
749 _service_adaptor_file_transfer_progress_reply = NULL;
750 _service_adaptor_download_state_changed_reply = NULL;
751 _service_adaptor_upload_state_changed_reply = NULL;
752 _service_adaptor_task_progress_reply = NULL;
754 return STORAGE_ADAPTOR_ERROR_NONE;
757 /* /////////////////////////////////////////////////////////////
758 // Plugin create / destroy / ref. count / get plugin name
759 ///////////////////////////////////////////////////////////// */
760 static storage_adaptor_plugin_h storage_adaptor_create_plugin(const char *plugin_path)
762 if (NULL == plugin_path) {
763 storage_adaptor_error("Invalid argument (plugin_path is null)");
767 void *dl_handle = dlopen(plugin_path, RTLD_LAZY);
768 if (NULL == dl_handle) {
769 storage_adaptor_error("Could not load plugin %s: %s", plugin_path, dlerror());
773 storage_adaptor_plugin_handle_h (*get_adaptee_handle)(void) = NULL;
775 get_adaptee_handle = (storage_adaptor_plugin_handle_h (*)(void)) (dlsym(dl_handle, "create_plugin_handle"));
776 if (NULL == get_adaptee_handle) {
778 storage_adaptor_error("Could not get function pointer to create_plugin_handle");
783 storage_adaptor_plugin_handle_h handle = get_adaptee_handle();
784 plugin_req_exit_void();
786 if (NULL == handle) {
788 storage_adaptor_error("Could not get adaptee handle");
792 handle->open_file = storage_plugin_open_file;
793 handle->close_file = storage_plugin_close_file;
795 storage_adaptor_plugin_h plugin = (storage_adaptor_plugin_h) calloc(1, sizeof(storage_adaptor_plugin_t));
796 if (NULL == plugin) {
798 storage_adaptor_error("Could not create plugin object");
802 storage_adaptor_plugin_listener_h listener =
803 (storage_adaptor_plugin_listener_h) calloc(1, sizeof(storage_adaptor_plugin_listener_t));
805 if (NULL == listener) {
808 storage_adaptor_error("Could not create listener object");
812 plugin->path = g_strdup(plugin_path);
813 plugin->handle = handle;
814 plugin->dl_handle = dl_handle;
815 plugin->ref_counter = 0;
817 plugin->type = PLUGIN_TYPE_INHOUSE;
819 g_mutex_init(&plugin->ref_counter_mutex);
820 g_mutex_init(&plugin->plugin_listener_mutex);
821 g_mutex_init(&plugin->contexts_mutex);
822 plugin->contexts = NULL;
824 listener->storage_adaptor_download_file_async_reply = storage_adaptor_download_file_async_reply_cb;
825 listener->storage_adaptor_upload_file_async_reply = storage_adaptor_upload_file_async_reply_cb;
826 listener->storage_adaptor_file_transfer_progress_reply = storage_adaptor_file_transfer_progress_reply_cb;
827 listener->storage_adaptor_download_state_changed_reply = storage_adaptor_download_state_changed_reply_cb;
828 listener->storage_adaptor_upload_state_changed_reply = storage_adaptor_upload_state_changed_reply_cb;
829 listener->storage_adaptor_task_progress_reply = storage_adaptor_task_progress_reply_cb;
833 plugin->handle->set_listener(listener);
834 plugin_req_exit_void();
836 g_mutex_lock(&plugin->plugin_listener_mutex);
837 plugin->plugin_listener = listener;
838 g_mutex_unlock(&plugin->plugin_listener_mutex);
843 static void storage_adaptor_destroy_plugin(storage_adaptor_plugin_h plugin)
845 if (NULL == plugin) {
846 storage_adaptor_error("Invalid argument""(plugin: %p)", plugin);
850 if (NULL != plugin->handle) {
851 plugin->handle->destroy_handle(plugin->handle);
853 g_mutex_lock(&plugin->plugin_listener_mutex);
856 plugin->handle->unset_listener();
857 plugin_req_exit_void();
859 g_mutex_unlock(&plugin->plugin_listener_mutex);
861 plugin->handle = NULL;
864 if (NULL != plugin->dl_handle) {
865 dlclose(plugin->dl_handle);
866 plugin->dl_handle = NULL;
875 static int storage_adaptor_load_plugins_from_directory(storage_adaptor_h adaptor,
876 const char *dir_path)
878 char *plugin_path = NULL;
880 struct dirent dir_entry, *result = NULL;
882 storage_adaptor_debug("Starting load plugins from directory");
884 if ((NULL == adaptor) || (NULL == dir_path)) {
885 storage_adaptor_error("Invalid argument""(adaptor: %p, dir_path: %p)", adaptor, dir_path);
886 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
889 dir = opendir(dir_path);
891 storage_adaptor_error("Could not open dir path (%s)", dir_path);
892 return STORAGE_ADAPTOR_ERROR_NOT_FOUND;
895 int ret = STORAGE_ADAPTOR_ERROR_NONE;
896 while (0 == (readdir_r(dir, &dir_entry, &result))) {
898 if (NULL == result) {
899 storage_adaptor_error("Could not open directory %s", plugin_path);
903 if (dir_entry.d_type & DT_DIR) {
907 plugin_path = g_strconcat(dir_path, "/", dir_entry.d_name, NULL);
908 storage_adaptor_plugin_h plugin = storage_adaptor_create_plugin(plugin_path);
910 if (NULL != plugin) {
911 storage_adaptor_debug("Loaded plugin: %s", plugin_path);
912 plugin->adaptor = adaptor;
913 storage_adaptor_plugin_ref(plugin);
914 g_mutex_lock(&adaptor->plugins_mutex);
915 adaptor->plugins = g_list_append(adaptor->plugins, plugin);
916 g_mutex_unlock(&adaptor->plugins_mutex);
918 storage_adaptor_error("Could not load plugin %s", plugin_path);
925 storage_adaptor_debug("End load plugins from directory");
930 static int storage_adaptor_has_plugin(storage_adaptor_h adaptor,
931 storage_adaptor_plugin_h plugin)
933 if ((NULL == adaptor) || (NULL == plugin)) {
934 storage_adaptor_error("Invalid argument""(adaptor: %p, plugin: %p)", adaptor, plugin);
940 g_mutex_lock(&adaptor->plugins_mutex);
941 if (NULL != g_list_find(adaptor->plugins, plugin)) {
944 g_mutex_unlock(&adaptor->plugins_mutex);
949 void storage_adaptor_plugin_ref(storage_adaptor_plugin_h plugin)
951 if (NULL == plugin) {
952 storage_adaptor_error("Invalid argument""(plugin: %p)", plugin);
956 g_mutex_lock(&plugin->ref_counter_mutex);
957 plugin->ref_counter = plugin->ref_counter + 1;
958 if (NULL != plugin->handle) {
959 storage_adaptor_info("plugin name : %s, ref_counter: %d",
960 plugin->handle->plugin_uri, plugin->ref_counter);
962 storage_adaptor_info("ref_counter: %d", plugin->ref_counter);
964 g_mutex_unlock(&plugin->ref_counter_mutex);
967 void storage_adaptor_plugin_unref(storage_adaptor_plugin_h plugin)
969 if (NULL == plugin) {
970 storage_adaptor_error("Invalid argument""(plugin: %p)", plugin);
974 int should_destroy = 0;
976 g_mutex_lock(&plugin->ref_counter_mutex);
977 plugin->ref_counter = plugin->ref_counter - 1;
978 if (NULL != plugin->handle) {
979 storage_adaptor_info("plugin name : %s, ref_counter: %d",
980 plugin->handle->plugin_uri, plugin->ref_counter);
982 storage_adaptor_info("ref_counter: %d", plugin->ref_counter);
984 if (0 >= plugin->ref_counter) {
987 g_mutex_unlock(&plugin->ref_counter_mutex);
989 if (should_destroy) {
990 storage_adaptor_debug("Plugin is being destroyed");
991 storage_adaptor_destroy_plugin(plugin);
995 /* For 3rd party plugin packages */
996 int storage_adaptor_load_plugin_from_package(storage_adaptor_h adaptor,
997 const char *package_id,
998 const char *plugin_path)
1003 if (pipe(adaptor_fd) == -1) {
1004 storage_adaptor_debug("pipe creation error, can not load plugin package");
1005 } else if (pipe(plugin_fd) == -1) {
1006 close(adaptor_fd[0]);
1007 close(adaptor_fd[1]);
1008 storage_adaptor_debug("pipe creation error[2], can not load plugin package");
1010 g_process_identity = fork();
1011 if (0 == g_process_identity) { /* child */
1012 storage_adaptor_debug_func("[CHILD PROCESS] forked success (PID : %d, id : %d)", (int)getpid());
1014 storage_adaptor_plugin_h plugin = NULL;
1015 plugin = storage_adaptor_create_plugin(plugin_path);
1016 if (NULL == plugin) {
1017 storage_adaptor_error("[CHILD PROCESS] Load plugin failed");
1020 g_child_plugin = plugin;
1021 plugin->rd = plugin_fd[0];
1022 close(plugin_fd[1]);
1023 plugin->wd = adaptor_fd[1];
1024 close(adaptor_fd[0]);
1025 void *temp = _storage_plugin_request_collector((void *)plugin);
1026 storage_adaptor_debug_func("[CHILD PROCESS] exit %p", temp);
1028 } else if (0 < g_process_identity) { /* parent */
1029 storage_adaptor_debug_func("[PARENT PROCESS] forked success (PID : %d)", (int)getpid());
1030 storage_adaptor_plugin_h _plugin = (storage_adaptor_plugin_h) calloc(1, sizeof(storage_adaptor_plugin_t));
1031 if (NULL == _plugin) {
1032 storage_adaptor_error("[PARENT PROCESS] memory allocation failed");
1036 _plugin->ref_counter = 0;
1037 g_mutex_init(&_plugin->ref_counter_mutex);
1038 g_mutex_init(&_plugin->message_mutex);
1040 _plugin->handle = __storage_adaptor_create_3rd_party_plugin_handle(package_id);
1042 _plugin->type = PLUGIN_TYPE_3RD_PARTY;
1043 _plugin->pid = g_process_identity;
1044 _plugin->rd = adaptor_fd[0];
1045 close(adaptor_fd[1]);
1046 _plugin->wd = plugin_fd[1];
1047 close(plugin_fd[0]);
1049 _storage_adaptor_send_cmd_add_fd(adaptor, _plugin->rd);
1051 _plugin->adaptor = adaptor;
1052 storage_adaptor_plugin_ref(_plugin);
1053 g_mutex_lock(&adaptor->plugins_mutex);
1054 adaptor->plugins = g_list_append(adaptor->plugins, _plugin);
1055 g_mutex_unlock(&adaptor->plugins_mutex);
1057 close(adaptor_fd[0]);
1058 close(adaptor_fd[1]);
1059 close(plugin_fd[0]);
1060 close(plugin_fd[1]);
1061 storage_adaptor_debug("fork error, can not load plugin package");
1068 /* //////////////////////////////////////////////////////
1069 // Plugin context create / destroy
1070 ////////////////////////////////////////////////////// */
1071 storage_adaptor_plugin_context_h storage_adaptor_create_plugin_context(storage_adaptor_plugin_h plugin,
1073 const char *app_secret,
1074 const char *access_token,
1077 const char *service_name)
1079 storage_adaptor_debug("Starting storage_adaptor_create_plugin_context");
1081 if (NULL == plugin) {
1082 storage_adaptor_error("Invalid argument""(plugin: %p)", plugin);
1086 if (NULL != plugin->handle) {
1087 storage_adaptor_plugin_context_h plugin_context = NULL;
1089 if (plugin->type == PLUGIN_TYPE_3RD_PARTY) {
1090 plugin_context = (storage_adaptor_plugin_context_h) calloc(1, sizeof(storage_adaptor_plugin_context_t));
1091 if (NULL == plugin_context) {
1094 plugin_context->plugin_handle = plugin;
1098 plugin->handle->create_context(&plugin_context, SAFE_ADD_STRING(app_id), SAFE_ADD_STRING(app_secret),
1099 SAFE_ADD_STRING(access_token), SAFE_ADD_STRING(cid), SAFE_ADD_STRING(uid));
1100 plugin_req_exit_void();
1102 if (NULL == plugin_context) {
1103 storage_adaptor_error("Create context failed");
1107 /* For forked plugin */
1108 g_mutex_lock(&plugin->contexts_mutex);
1109 plugin->contexts = g_list_append(plugin->contexts, (gpointer)plugin_context);
1110 g_mutex_unlock(&plugin->contexts_mutex);
1112 plugin_context->plugin_uri = strdup(plugin->handle->plugin_uri);
1113 plugin_context->service_name = strdup(service_name ? service_name : "");
1114 return plugin_context;
1116 storage_adaptor_error("Plugin handle is null");
1119 storage_adaptor_debug("End storage_adaptor_create_plugin_context");
1123 void storage_adaptor_destroy_plugin_context(storage_adaptor_plugin_h plugin,
1124 storage_adaptor_plugin_context_h plugin_context)
1126 if ((NULL == plugin) || (NULL == plugin_context)) {
1127 storage_adaptor_error("Invalid argument""(plugin: %p, plugin_context: %p)", plugin, plugin_context);
1131 free(plugin_context->plugin_uri);
1132 plugin_context->plugin_uri = NULL;
1133 /* free(plugin_context->service_name); */
1134 /* plugin_context->service_name = NULL; */
1136 if (NULL != plugin->handle) {
1138 plugin->handle->destroy_context(plugin_context);
1139 plugin_req_exit_void();
1141 storage_adaptor_error("Plugin handle is null");
1145 /* //////////////////////////////////////////////////////
1146 // Get plugin by plugin name
1147 ////////////////////////////////////////////////////// */
1148 storage_adaptor_plugin_h storage_adaptor_get_plugin_by_name(storage_adaptor_h adaptor,
1149 const char *plugin_uri)
1151 storage_adaptor_debug("Starting storage_adaptor_get_plugin_by_name");
1153 if ((NULL == adaptor) || (NULL == plugin_uri)) {
1154 storage_adaptor_error("Invalid argument""(adaptor: %p, plugin_uri: %p)", adaptor, plugin_uri);
1158 storage_adaptor_plugin_h plugin = NULL;
1159 g_mutex_lock(&adaptor->plugins_mutex);
1160 int count = g_list_length(adaptor->plugins);
1162 for (i = 0; i < count; i++) {
1163 storage_adaptor_plugin_h temp_plugin = g_list_nth_data(adaptor->plugins, i);
1164 if (NULL != temp_plugin) {
1165 if (0 == strcmp(temp_plugin->handle->plugin_uri, plugin_uri)) {
1166 storage_adaptor_plugin_ref(temp_plugin);
1167 plugin = temp_plugin;
1168 g_mutex_unlock(&adaptor->plugins_mutex);
1173 g_mutex_unlock(&adaptor->plugins_mutex);
1178 /* //////////////////////////////////////////////////////
1179 // Plugin load / unload / get plugin list
1180 ////////////////////////////////////////////////////// */
1181 int storage_adaptor_load_plugin(storage_adaptor_h adaptor,
1182 const char *plugin_path)
1184 if ((NULL == adaptor) || (NULL == plugin_path)) {
1185 storage_adaptor_error("Invalid argument""(adaptor: %p, plugin_path: %p)", adaptor, plugin_path);
1186 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
1189 if (0 == adaptor->started) {
1190 storage_adaptor_error("Storage adaptor is not started");
1191 return STORAGE_ADAPTOR_ERROR_START;
1194 storage_adaptor_plugin_h plugin = storage_adaptor_create_plugin(plugin_path);
1195 if (NULL == plugin) {
1196 storage_adaptor_error("Could not load plugin %s", plugin_path);
1197 return STORAGE_ADAPTOR_ERROR_CREATE;
1200 plugin->adaptor = adaptor;
1201 storage_adaptor_plugin_ref(plugin);
1203 g_mutex_lock(&adaptor->plugins_mutex);
1204 adaptor->plugins = g_list_append(adaptor->plugins, plugin);
1205 g_mutex_unlock(&adaptor->plugins_mutex);
1207 return STORAGE_ADAPTOR_ERROR_NONE;
1210 int storage_adaptor_unload_plugin(storage_adaptor_h adaptor,
1211 storage_adaptor_plugin_h plugin)
1213 if ((NULL == adaptor) || (NULL == plugin)) {
1214 storage_adaptor_error("Invalid argument""(adaptor: %p, plugin: %p)", adaptor, plugin);
1215 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
1218 if (0 == adaptor->started) {
1219 storage_adaptor_error("Storage adaptor is not started");
1220 return STORAGE_ADAPTOR_ERROR_START;
1223 if (!storage_adaptor_has_plugin(adaptor, plugin)) {
1224 storage_adaptor_error("Storage adaptor has no plugin");
1225 return STORAGE_ADAPTOR_ERROR_NOT_FOUND;
1228 plugin->adaptor = NULL;
1230 g_mutex_lock(&adaptor->plugins_mutex);
1231 adaptor->plugins = g_list_remove(adaptor->plugins, plugin);
1232 g_mutex_unlock(&adaptor->plugins_mutex);
1234 storage_adaptor_plugin_unref(plugin);
1236 return STORAGE_ADAPTOR_ERROR_NONE;
1239 GList *storage_adaptor_get_plugins(storage_adaptor_h adaptor)
1241 if (NULL == adaptor) {
1242 storage_adaptor_error("Invalid argument""(adaptor: %p)", adaptor);
1246 GList *plugins = NULL;
1248 g_mutex_lock(&adaptor->plugins_mutex);
1249 int plugins_count = g_list_length(adaptor->plugins);
1251 for (i = 0; i < plugins_count; i++) {
1252 storage_adaptor_plugin_h plugin = g_list_nth_data(adaptor->plugins, i);
1253 if (NULL != plugin) {
1254 storage_adaptor_plugin_ref(plugin);
1255 plugins = g_list_append(plugins, plugin);
1258 g_mutex_unlock(&adaptor->plugins_mutex);
1263 /* ////////////////////////////////////////////////////////////
1264 // Adaptor Etc Functions
1265 //////////////////////////////////////////////////////////// */
1267 /* Get plugin name by plugin */
1268 void storage_adaptor_get_plugin_uri(storage_adaptor_plugin_h plugin,
1271 if ((NULL == plugin) || (NULL == plugin_uri)) {
1272 storage_adaptor_error("Invalid argument""(plugin: %p)", plugin);
1275 if ((NULL != plugin->handle) && (NULL != plugin->handle->plugin_uri)) {
1276 *plugin_uri = strdup(plugin->handle->plugin_uri);
1281 * Refresh access token
1284 storage_error_code_t storage_adaptor_refresh_access_token(storage_adaptor_plugin_context_h context,
1285 const char *new_access_token)
1287 if ((NULL == context) || (NULL == new_access_token) || (0 >= strlen(new_access_token))) {
1288 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
1290 storage_adaptor_debug("New access token : %s", new_access_token);
1292 free(context->access_token);
1293 context->access_token = NULL;
1294 context->access_token = strdup(new_access_token);
1296 return STORAGE_ADAPTOR_ERROR_NONE;
1301 storage_error_code_t storage_adaptor_refresh_uid(storage_adaptor_plugin_context_h context,
1302 const char *new_uid)
1304 if ((NULL == context) || (NULL == new_uid) || (0 >= strlen(new_uid))) {
1305 return STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT;
1307 storage_adaptor_debug("New uid : %s", new_uid);
1310 context->uid = NULL;
1311 context->uid = strdup(new_uid);
1313 return STORAGE_ADAPTOR_ERROR_NONE;
1318 storage_adaptor_error_code_h storage_adaptor_create_error_code(const int64_t code,
1324 storage_adaptor_error_code_h error_code =
1325 (storage_adaptor_error_code_h) calloc(1, sizeof(storage_adaptor_error_code_t));
1326 if (NULL != error_code) {
1327 error_code->code = code;
1328 error_code->msg = strdup(msg);
1334 void storage_adaptor_destroy_error_code(storage_adaptor_error_code_h *error_code)
1336 if ((NULL != error_code) && (NULL != (*error_code))) {
1337 free((*error_code)->msg);
1338 (*error_code)->msg = NULL;
1345 storage_adaptor_file_info_h storage_adaptor_create_file_info(void)
1347 storage_adaptor_file_info_h _file_info = NULL;
1348 _file_info = (storage_adaptor_file_info_h) calloc(1, sizeof(storage_adaptor_file_info_t));
1350 storage_adaptor_media_meta_s *_media_meta = NULL;
1351 _media_meta = (storage_adaptor_media_meta_s *) calloc(1, sizeof(storage_adaptor_media_meta_s));
1353 storage_adaptor_cloud_meta_s *_cloud_meta = NULL;
1354 _cloud_meta = (storage_adaptor_cloud_meta_s *) calloc(1, sizeof(storage_adaptor_cloud_meta_s));
1356 if ((NULL == _file_info) || (NULL == _media_meta) || (NULL == _cloud_meta)) {
1364 _media_meta->mime_type = NULL;
1365 _media_meta->title = NULL;
1366 _media_meta->album = NULL;
1367 _media_meta->artist = NULL;
1368 _media_meta->genere = NULL;
1369 _media_meta->recorded_date = NULL;
1370 _media_meta->width = -1;
1371 _media_meta->height = -1;
1372 _media_meta->duration = -1;
1373 _media_meta->copyright = NULL;
1374 _media_meta->track_num = NULL;
1375 _media_meta->description = NULL;
1376 _media_meta->composer = NULL;
1377 _media_meta->year = NULL;
1378 _media_meta->bitrate = -1;
1379 _media_meta->samplerate = -1;
1380 _media_meta->channel = -1;
1381 _media_meta->extra_media_meta = NULL;
1383 _cloud_meta->service_name = NULL;
1384 _cloud_meta->usage_byte = 0ULL;
1385 _cloud_meta->quota_byte = 0ULL;
1386 _cloud_meta->extra_cloud_meta = NULL;
1388 _file_info->plugin_uri = NULL;
1389 _file_info->object_id = NULL;
1390 _file_info->storage_path = NULL;
1391 _file_info->file_size = 0ULL;
1393 /* private only!! */
1394 _file_info->revision = -1;
1395 _file_info->timestamp = 0ULL;
1396 _file_info->type = NULL;
1397 _file_info->deleted = -1;
1398 _file_info->expired_time = 0ULL;
1399 _file_info->download_count = -0U;
1400 _file_info->max_download_count = -0U;
1401 _file_info->file_info_index = -1;
1402 _file_info->tag = NULL;
1403 _file_info->file_share_token = NULL;
1406 _file_info->created_time = 0ULL;
1407 _file_info->modified_time = 0ULL;
1408 _file_info->file_info_index = -1;
1409 _file_info->content_type = STORAGE_ADAPTOR_CONTENT_TYPE_DEFAULT;
1410 _file_info->media_meta = _media_meta;
1411 _file_info->cloud_meta = _cloud_meta;
1412 _file_info->extra_file_info = NULL;
1417 int storage_adaptor_destroy_file_info(storage_adaptor_file_info_h *file_info)
1419 if (NULL == file_info) {
1423 if (NULL == *file_info) {
1426 storage_adaptor_file_info_h _file_info = *file_info;
1428 free(_file_info->plugin_uri);
1429 free(_file_info->object_id);
1430 free(_file_info->storage_path);
1431 free(_file_info->extra_file_info);
1432 free(_file_info->type);
1433 free(_file_info->tag);
1435 storage_adaptor_media_meta_s *_media_meta = _file_info->media_meta;
1437 if (NULL != _media_meta) {
1438 free(_media_meta->mime_type);
1439 free(_media_meta->title);
1440 free(_media_meta->album);
1441 free(_media_meta->artist);
1442 free(_media_meta->genere);
1443 free(_media_meta->recorded_date);
1444 free(_media_meta->copyright);
1445 free(_media_meta->track_num);
1446 free(_media_meta->description);
1447 free(_media_meta->composer);
1448 free(_media_meta->year);
1449 free(_media_meta->extra_media_meta);
1452 storage_adaptor_cloud_meta_s *_cloud_meta = _file_info->cloud_meta;
1454 if (NULL != _cloud_meta) {
1455 free(_cloud_meta->service_name);
1456 free(_cloud_meta->extra_cloud_meta);
1460 if (NULL != _file_info->file_share_token) {
1461 free(_file_info->file_share_token->public_token);
1462 _file_info->file_share_token->public_token = NULL;
1464 free(_file_info->file_share_token->auth_code);
1465 _file_info->file_share_token->auth_code = NULL;
1467 free(_file_info->file_share_token);
1470 _file_info->plugin_uri = NULL;
1471 _file_info->object_id = NULL;
1472 _file_info->storage_path = NULL;
1473 _file_info->revision = -1;
1474 _file_info->timestamp = 0ULL;
1475 _file_info->type = NULL;
1476 _file_info->file_size = 0ULL;
1477 _file_info->deleted = -1;
1478 _file_info->expired_time = 0ULL;
1479 _file_info->download_count = 0U;
1480 _file_info->max_download_count = 0U;
1481 _file_info->file_info_index = -1;
1482 _file_info->tag = NULL;
1483 _file_info->file_share_token = NULL;
1486 free((*file_info)->media_meta);
1487 free((*file_info)->cloud_meta);
1491 return STORAGE_ADAPTOR_ERROR_NONE;
1494 void __assign_error_code(storage_adaptor_error_code_h *error, const int64_t code, const char *msg)
1496 if (NULL != error) {
1497 *error = storage_adaptor_create_error_code(code, msg);
1501 /* ////////////////////////////////////////////////////////////
1502 // Adaptor Plugin call Functions
1503 //////////////////////////////////////////////////////////// */
1507 /* ////////////////////// Public feature //////////////////////////// */
1510 storage_error_code_t storage_adaptor_open_file(storage_adaptor_plugin_h plugin,
1511 storage_adaptor_plugin_context_h context,
1512 const char *file_path,
1513 storage_adaptor_file_access_mode_e mode,
1514 long long int *file_uid,
1515 storage_adaptor_error_code_h *error)
1517 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1518 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1520 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1521 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1523 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1524 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1527 storage_adaptor_check_param_equal(NULL, file_uid, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1528 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (file_uid)"));
1531 storage_adaptor_check_param_equal(NULL, plugin->handle->open_file, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1532 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (open file)"));
1535 storage_error_code_t ret = plugin->handle->open_file(context, file_path, mode, &plugin_fd, error);
1536 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
1537 *file_uid = _get_file_uid_from_plugin_fd(plugin_fd);
1539 #ifndef FORK_PLUGIN_ARCHITECTURE
1540 long long int *buf = (long long int *) calloc(1, sizeof(long long int));
1543 g_hash_table_insert(g_file_uid_list, (void *)&plugin_fd, (void *)buf);
1547 #ifdef DEBUG_ADAPTOR_PARAMS
1548 storage_adaptor_debug_func("plugin fd (%d), file uid(%lld)", plugin_fd, *file_uid);
1556 storage_error_code_t storage_adaptor_close_file(storage_adaptor_plugin_h plugin,
1557 storage_adaptor_plugin_context_h context,
1558 long long int file_uid,
1559 storage_adaptor_error_code_h *error)
1561 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1562 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1564 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1565 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1567 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1568 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1571 storage_adaptor_check_param_equal(NULL, plugin->handle->close_file, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1572 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (close file)"));
1574 int plugin_fd = _get_plugin_fd_from_file_uid(file_uid);
1575 storage_error_code_t ret = plugin->handle->close_file(context, plugin_fd, error);
1577 #ifndef FORK_PLUGIN_ARCHITECTURE
1578 g_hash_table_remove(g_file_uid_list, (void *)&plugin_fd);
1581 #ifdef DEBUG_ADAPTOR_PARAMS
1582 storage_adaptor_debug_func("plugin fd (%d), file uid(%lld)", plugin_fd, file_uid);
1589 storage_error_code_t storage_adaptor_start_upload_task(storage_adaptor_plugin_h plugin,
1590 storage_adaptor_plugin_context_h context,
1591 long long int src_file_descriptor, /* read only opened */
1592 const char *upload_dir_path,
1593 const char *file_name,
1595 storage_adaptor_error_code_h *error,
1598 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1599 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1601 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1602 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1604 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1605 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1608 storage_adaptor_check_param_equal(NULL, plugin->handle->start_upload_task, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1609 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (start_upload_task)"));
1611 storage_error_code_t ret = STORAGE_ADAPTOR_ERROR_NONE;
1613 #ifdef DEBUG_ADAPTOR_PARAMS
1614 storage_adaptor_debug_func("========== %s START ==========", __FUNCTION__);
1615 storage_adaptor_debug_func("[in] file_uid (%lld)", src_file_descriptor);
1616 storage_adaptor_debug_func("[in] path (%s / %s)", upload_dir_path, file_name);
1617 storage_adaptor_debug_func("[in] need progress (%d)", need_progress ? 1 : 0);
1620 int plugin_fd = _get_plugin_fd_from_file_uid(src_file_descriptor);
1622 ret = plugin->handle->start_upload_task(context, plugin_fd,
1623 upload_dir_path, file_name, need_progress, error, user_data);
1624 plugin_req_exit(ret, plugin, error);
1630 storage_error_code_t storage_adaptor_start_download_task(storage_adaptor_plugin_h plugin,
1631 storage_adaptor_plugin_context_h context,
1632 const char *storage_dir_path,
1633 const char *file_name,
1634 long long int dst_file_descriptor, /* write only opened */
1636 storage_adaptor_error_code_h *error,
1639 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1640 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1642 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1643 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1645 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1646 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1649 storage_adaptor_check_param_equal(NULL, plugin->handle->start_download_task, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1650 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (start_download_task)"));
1652 storage_error_code_t ret = STORAGE_ADAPTOR_ERROR_NONE;
1654 #ifdef DEBUG_ADAPTOR_PARAMS
1655 storage_adaptor_debug_func("========== %s START ==========", __FUNCTION__);
1656 storage_adaptor_debug_func("[in] file_uid (%lld)", dst_file_descriptor);
1657 storage_adaptor_debug_func("[in] path (%s / %s)", storage_dir_path, file_name);
1658 storage_adaptor_debug_func("[in] need progress (%d)", need_progress ? 1 : 0);
1661 int plugin_fd = _get_plugin_fd_from_file_uid(dst_file_descriptor);
1663 ret = plugin->handle->start_download_task(context, storage_dir_path, file_name,
1664 plugin_fd, need_progress, error, user_data);
1665 plugin_req_exit(ret, plugin, error);
1671 storage_error_code_t storage_adaptor_start_download_thumb_task(storage_adaptor_plugin_h plugin,
1672 storage_adaptor_plugin_context_h context,
1673 const char *storage_dir_path,
1674 const char *file_name,
1675 long long int dst_file_descriptor, /* write only opened */
1676 int thumbnail_size, /* level (defined plugin SPEC) */
1678 storage_adaptor_error_code_h *error,
1681 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1682 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1684 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1685 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1687 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1688 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1691 storage_adaptor_check_param_equal(NULL, plugin->handle->start_download_thumb_task, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1692 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (start_download_thumb_task)"));
1694 storage_error_code_t ret = STORAGE_ADAPTOR_ERROR_NONE;
1696 #ifdef DEBUG_ADAPTOR_PARAMS
1697 storage_adaptor_debug_func("========== %s START ==========", __FUNCTION__);
1698 storage_adaptor_debug_func("[in] file_uid (%lld)", dst_file_descriptor);
1699 storage_adaptor_debug_func("[in] path (%s / %s)", storage_dir_path, file_name);
1700 storage_adaptor_debug_func("[in] need progress (%d)", need_progress ? 1 : 0);
1703 int plugin_fd = _get_plugin_fd_from_file_uid(dst_file_descriptor);
1705 ret = plugin->handle->start_download_thumb_task(context, storage_dir_path, file_name,
1706 plugin_fd, thumbnail_size, need_progress, error, user_data);
1707 plugin_req_exit(ret, plugin, error);
1714 storage_error_code_t storage_adaptor_cancel_upload_task(storage_adaptor_plugin_h plugin,
1715 storage_adaptor_plugin_context_h context,
1716 long long int file_uid,
1717 storage_adaptor_error_code_h *error)
1719 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1720 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1722 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1723 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1725 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1726 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1729 storage_adaptor_check_param_equal(NULL, plugin->handle->cancel_upload_task, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1730 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (cancel_upload_task)"));
1732 storage_error_code_t ret = STORAGE_ADAPTOR_ERROR_NONE;
1734 int plugin_fd = _get_plugin_fd_from_file_uid(file_uid);
1736 ret = plugin->handle->cancel_upload_task(context, plugin_fd, error);
1737 plugin_req_exit(ret, plugin, error);
1743 storage_error_code_t storage_adaptor_cancel_download_task(storage_adaptor_plugin_h plugin,
1744 storage_adaptor_plugin_context_h context,
1745 long long int file_uid,
1746 storage_adaptor_error_code_h *error)
1748 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1749 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1751 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1752 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1754 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1755 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1758 storage_adaptor_check_param_equal(NULL, plugin->handle->cancel_download_task, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1759 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (cancel_download_task)"));
1761 storage_error_code_t ret = STORAGE_ADAPTOR_ERROR_NONE;
1763 int plugin_fd = _get_plugin_fd_from_file_uid(file_uid);
1765 ret = plugin->handle->cancel_download_task(context, plugin_fd, error);
1766 plugin_req_exit(ret, plugin, error);
1773 storage_error_code_t storage_adaptor_cancel_download_thumb_task(storage_adaptor_plugin_h plugin,
1774 storage_adaptor_plugin_context_h context,
1775 long long int file_uid,
1776 storage_adaptor_error_code_h *error)
1778 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1779 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1781 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1782 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1784 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1785 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1788 storage_adaptor_check_param_equal(NULL, plugin->handle->cancel_download_thumb_task, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1789 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (cancel_download_thumb_task)"));
1791 storage_error_code_t ret = STORAGE_ADAPTOR_ERROR_NONE;
1793 int plugin_fd = _get_plugin_fd_from_file_uid(file_uid);
1795 ret = plugin->handle->cancel_download_thumb_task(context, plugin_fd, error);
1796 plugin_req_exit(ret, plugin, error);
1802 /* ////////////////////// Common feature //////////////////////////// */
1805 * @brief Set server information for Storage Plugin
1807 * @param[in] plugin specifies Storage Adaptor Plugin handle
1808 * @param[in] context specifies Storage Adaptor Plugin Context handle
1809 * @param[in] server_info specifies server information for Storage Plugin
1810 * @param[in] request specifies optional parameter
1811 * @param[out] error specifies error code
1812 * @param[out] response specifies optional parameter
1813 * @return 0 on success, otherwise a positive error value
1814 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
1817 storage_error_code_t storage_adaptor_set_server_info(storage_adaptor_plugin_h plugin,
1818 storage_adaptor_plugin_context_h context,
1819 GHashTable *server_info,
1821 storage_adaptor_error_code_h *error,
1824 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1825 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1827 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1828 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1830 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1831 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1834 storage_adaptor_check_param_equal(NULL, plugin->handle->set_server_info, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1835 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (set_server_info)"));
1837 #ifdef DEBUG_ADAPTOR_PARAMS
1838 storage_adaptor_debug_func("========== %s START ==========", __FUNCTION__);
1839 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
1840 context->app_id, context->access_token, context->uid);
1841 storage_adaptor_debug_func("[in] server_info [addr(%p)]", server_info);
1842 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
1846 storage_error_code_t ret = plugin->handle->set_server_info(
1847 context, server_info, request, error, response);
1848 plugin_req_exit(ret, plugin, error);
1850 #ifdef DEBUG_ADAPTOR_PARAMS
1851 storage_adaptor_debug_func("[out] return code (%d)", ret);
1852 if ((NULL != error) && (NULL != *error)) {
1853 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
1854 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
1856 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
1857 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
1864 * @brief Makes a directory at cloud
1865 * @param[in] upload_file_local_path specifies local path of the file to be uploaded
1867 * @param[in] plugin specifies Storage Adaptor Plugin handle
1868 * @param[in] context specifies Storage Adaptor Plugin Context handle
1869 * @param[in] parent_folder_storage_path specifies path to locate the folder you want to create
1870 * @param[in] folder_name specifies folder name to be created at cloud
1871 * @param[in] request specifies optional parameter
1872 * @param[out] file_info specifies Storage Adaptor File Info handle
1873 * @param[out] error specifies error code
1874 * @param[out] response specifies optional parameter
1875 * @return 0 on success, otherwise a negative error value
1876 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
1878 storage_error_code_t storage_adaptor_make_directory(storage_adaptor_plugin_h plugin,
1879 storage_adaptor_plugin_context_h context,
1880 const char *parent_folder_storage_path,
1881 const char *folder_name,
1883 storage_adaptor_file_info_h *file_info,
1884 storage_adaptor_error_code_h *error,
1887 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1888 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1890 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1891 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1893 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1894 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1897 storage_adaptor_check_param_equal(NULL, plugin->handle->make_directory, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1898 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (make_directory)"));
1900 #ifdef DEBUG_ADAPTOR_PARAMS
1901 storage_adaptor_debug_func("========== %s START ==========", __FUNCTION__);
1902 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
1903 context->app_id, context->access_token, context->uid);
1904 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
1905 storage_adaptor_debug_func("[in] folder_name (%s)", folder_name);
1906 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
1910 storage_error_code_t ret = plugin->handle->make_directory(
1911 context, parent_folder_storage_path, folder_name, request, file_info, error, response);
1912 plugin_req_exit(ret, plugin, error);
1914 #ifdef DEBUG_ADAPTOR_PARAMS
1915 storage_adaptor_debug_func("[out] return code (%d)", ret);
1916 if ((NULL != file_info) && (NULL != (*file_info))) {
1917 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
1919 if ((NULL != error) && (NULL != *error)) {
1920 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
1921 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
1923 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
1924 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
1931 * @brief Removes a directory at cloud
1933 * @param[in] plugin specifies Storage Adaptor Plugin handle
1934 * @param[in] context specifies Storage Adaptor Plugin Context handle
1935 * @param[in] parent_folder_storage_path specifies parent folder path of folder you want to delete
1936 * @param[in] folder_name specifies folder name to be deleted from cloud
1937 * @param[in] request specifies optional parameter
1938 * @param[out] file_info specifies Storage Adaptor File Info handle
1939 * @param[out] error specifies error code
1940 * @param[out] response specifies optional parameter
1941 * @return 0 on success, otherwise a negative error value
1942 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
1944 storage_error_code_t storage_adaptor_remove_directory(storage_adaptor_plugin_h plugin,
1945 storage_adaptor_plugin_context_h context,
1946 const char *parent_folder_storage_path,
1947 const char *folder_name,
1949 storage_adaptor_file_info_h *file_info,
1950 storage_adaptor_error_code_h *error,
1953 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1954 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
1956 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
1957 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
1959 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
1960 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
1963 storage_adaptor_check_param_equal(NULL, plugin->handle->remove_directory, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
1964 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (remove_directory)"));
1966 #ifdef DEBUG_ADAPTOR_PARAMS
1967 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
1968 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
1969 context->app_id, context->access_token, context->uid);
1970 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
1971 storage_adaptor_debug_func("[in] folder_name (%s)", folder_name);
1972 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
1976 storage_error_code_t ret = plugin->handle->remove_directory(context, parent_folder_storage_path,
1977 folder_name, request, file_info, error, response);
1978 plugin_req_exit(ret, plugin, error);
1980 #ifdef DEBUG_ADAPTOR_PARAMS
1981 storage_adaptor_debug_func("[out] return code (%d)", ret);
1982 if ((NULL != file_info) && (NULL != (*file_info))) {
1983 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
1985 if ((NULL != error) && (NULL != *error)) {
1986 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
1987 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
1989 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
1990 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
1997 * @brief Requests folder and file list in a folder
1999 * @param[in] plugin specifies Storage Adaptor Plugin handle
2000 * @param[in] context specifies Storage Adaptor Plugin Context handle
2001 * @param[in] parent_folder_storage_path specifies parent folder path of folder you want to get list
2002 * @param[in] folder_name specifies folder name you want to get list
2003 * @param[in] request specifies optional parameter
2004 * @param[out] file_info_list specifies Storage Adaptor File Info handle
2005 * @param[out] file_info_list_len specifies length of the file_info_list
2006 * @param[out] error specifies error code
2007 * @param[out] response specifies optional parameter
2008 * @return 0 on success, otherwise a negative error value
2009 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2011 storage_error_code_t storage_adaptor_list(storage_adaptor_plugin_h plugin,
2012 storage_adaptor_plugin_context_h context,
2013 const char *parent_folder_storage_path,
2014 const char *folder_name,
2016 storage_adaptor_file_info_h **file_info_list,
2017 int *file_info_list_len,
2018 storage_adaptor_error_code_h *error,
2021 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2022 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2024 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2025 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2027 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2028 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2031 storage_adaptor_check_param_equal(NULL, plugin->handle->list, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2032 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (list)"));
2034 #ifdef DEBUG_ADAPTOR_PARAMS
2035 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2036 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2037 context->app_id, context->access_token, context->uid);
2038 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2039 storage_adaptor_debug_func("[in] folder_name (%s)", folder_name);
2040 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2044 storage_error_code_t ret = plugin->handle->list(context, parent_folder_storage_path,
2045 folder_name, request, file_info_list, file_info_list_len, error, response);
2046 plugin_req_exit(ret, plugin, error);
2048 #ifdef DEBUG_ADAPTOR_PARAMS
2049 storage_adaptor_debug_func("[out] return code (%d)", ret);
2050 storage_adaptor_debug_func("[out] file_info_list_len (%d)", *file_info_list_len);
2051 if ((NULL != error) && (NULL != *error)) {
2052 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2053 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2055 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2056 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2063 * @brief Uploads a file to cloud (Sync)
2065 * @param[in] plugin specifies Storage Adaptor Plugin handle
2066 * @param[in] context specifies Storage Adaptor Plugin Context handle
2067 * @param[in] parent_folder_storage_path specifies folder path of file you want to upload
2068 * @param[in] file_name specifies file name to be uploaded to cloud
2069 * @param[in] upload_file_local_path specifies local path of the file to be uploaded
2070 * @param[in] publish specifies Allow to share file with no authentication
2071 * @param[in] request specifies optional parameter
2072 * @param[out] file_info specifies Storage Adaptor File Info handle
2073 * @param[out] error specifies error code
2074 * @param[out] response specifies optional parameter
2075 * @return 0 on success, otherwise a negative error value
2076 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2078 storage_error_code_t storage_adaptor_upload_file_sync(storage_adaptor_plugin_h plugin,
2079 storage_adaptor_plugin_context_h context,
2080 const char *parent_folder_storage_path,
2081 const char *file_name,
2082 const char *upload_file_local_path,
2085 storage_adaptor_file_info_h *file_info,
2086 storage_adaptor_error_code_h *error,
2089 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2090 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2092 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2093 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2095 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2096 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2099 storage_adaptor_check_param_equal(NULL, plugin->handle->upload_file_sync, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2100 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (upload_file_sync)"));
2102 #ifdef DEBUG_ADAPTOR_PARAMS
2103 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2104 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2105 context->app_id, context->access_token, context->uid);
2106 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2107 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2108 storage_adaptor_debug_func("[in] upload_file_local_path (%s)", upload_file_local_path);
2109 storage_adaptor_debug_func("[in] publish (%d)", publish);
2110 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2114 storage_error_code_t ret = plugin->handle->upload_file_sync(context, parent_folder_storage_path,
2115 file_name, upload_file_local_path, publish, request, file_info, error, response);
2116 plugin_req_exit(ret, plugin, error);
2118 #ifdef DEBUG_ADAPTOR_PARAMS
2119 storage_adaptor_debug_func("[out] return code (%d)", ret);
2120 if ((NULL != file_info) && (NULL != (*file_info))) {
2121 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
2122 if ((1 == publish) && (NULL != (*file_info)->file_share_token)) {
2123 storage_adaptor_debug_func("[out] file_info->file_share_token->public_token (%s)",
2124 (*file_info)->file_share_token->public_token);
2125 storage_adaptor_debug_func("[out] file_info->file_share_token->auth_code (%s)",
2126 (*file_info)->file_share_token->auth_code);
2129 if ((NULL != error) && (NULL != *error)) {
2130 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2131 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2133 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2134 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2141 * @brief Downloads a file to local (Sync)
2143 * @param[in] plugin specifies Storage Adaptor Plugin handle
2144 * @param[in] context specifies Storage Adaptor Plugin Context handle
2145 * @param[in] parent_folder_storage_path specifies folder path of file you want to download
2146 * @param[in] file_name specifies file name to be downloaded to local
2147 * @param[in] download_file_local_path specifies local path to download
2148 * @param[in] request specifies optional parameter
2149 * @param[out] error specifies error code
2150 * @param[out] response specifies optional parameter
2151 * @return 0 on success, otherwise a negative error value
2152 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2154 storage_error_code_t storage_adaptor_download_file_sync(storage_adaptor_plugin_h plugin,
2155 storage_adaptor_plugin_context_h context,
2156 const char *parent_folder_storage_path,
2157 const char *file_name,
2158 const char *download_file_local_path,
2160 storage_adaptor_error_code_h *error,
2163 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2164 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2166 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2167 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2169 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2170 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2173 storage_adaptor_check_param_equal(NULL, plugin->handle->download_file_sync, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2174 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (download_file_sync)"));
2176 #ifdef DEBUG_ADAPTOR_PARAMS
2177 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2178 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2179 context->app_id, context->access_token, context->uid);
2180 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2181 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2182 storage_adaptor_debug_func("[in] download_file_local_path (%s)", download_file_local_path);
2183 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2187 storage_error_code_t ret = plugin->handle->download_file_sync(context, parent_folder_storage_path,
2188 file_name, download_file_local_path, request, error, response);
2189 plugin_req_exit(ret, plugin, error);
2191 #ifdef DEBUG_ADAPTOR_PARAMS
2192 storage_adaptor_debug_func("[out] return code (%d)", ret);
2193 if ((NULL != error) && (NULL != *error)) {
2194 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2195 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2197 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2198 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2204 storage_error_code_t storage_adaptor_download_thumbnail(storage_adaptor_plugin_h plugin,
2205 storage_adaptor_plugin_context_h context,
2206 const char *folder_path,
2207 const char *file_name,
2208 const char *download_path,
2211 storage_adaptor_error_code_h *error,
2214 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2215 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2217 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2218 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2220 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2221 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2224 storage_adaptor_check_param_equal(NULL, plugin->handle->download_thumbnail, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2225 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (download_thumbnail)"));
2227 #ifdef DEBUG_ADAPTOR_PARAMS
2228 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2229 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2230 context->app_id, context->access_token, context->uid);
2231 storage_adaptor_debug_func("[in] folder_path (%s)", folder_path);
2232 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2233 storage_adaptor_debug_func("[in] download_path (%s)", download_path);
2234 storage_adaptor_debug_func("[in] thumbnail_size (%d)", thumbnail_size);
2235 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2239 storage_error_code_t ret = plugin->handle->download_thumbnail(context, folder_path,
2240 file_name, download_path, thumbnail_size, request, error, response);
2241 plugin_req_exit(ret, plugin, error);
2243 #ifdef DEBUG_ADAPTOR_PARAMS
2244 storage_adaptor_debug_func("[out] return code (%d)", ret);
2245 if ((NULL != error) && (NULL != *error)) {
2246 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2247 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2249 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2250 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2259 * @brief Removes a file at cloud
2261 * @param[in] plugin specifies Storage Adaptor Plugin handle
2262 * @param[in] context specifies Storage Adaptor Plugin Context handle
2263 * @param[in] parent_folder_storage_path specifies folder path of file you want to delete
2264 * @param[in] file_name specifies file name to be deleted from cloud
2265 * @param[in] request specifies optional parameter
2266 * @param[out] file_info specifies Storage Adaptor File Info handle
2267 * @param[out] error specifies error code
2268 * @param[out] response specifies optional parameter
2269 * @return 0 on success, otherwise a negative error value
2270 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2272 storage_error_code_t storage_adaptor_delete_file(storage_adaptor_plugin_h plugin,
2273 storage_adaptor_plugin_context_h context,
2274 const char *parent_folder_storage_path,
2275 const char *file_name,
2277 storage_adaptor_file_info_h *file_info,
2278 storage_adaptor_error_code_h *error,
2281 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2282 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2284 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2285 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2287 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2288 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2291 storage_adaptor_check_param_equal(NULL, plugin->handle->delete_file, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2292 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (delete_file)"));
2294 #ifdef DEBUG_ADAPTOR_PARAMS
2295 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2296 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2297 context->app_id, context->access_token, context->uid);
2298 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2299 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2300 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2304 storage_error_code_t ret = plugin->handle->delete_file(context, parent_folder_storage_path,
2305 file_name, request, file_info, error, response);
2306 plugin_req_exit(ret, plugin, error);
2308 #ifdef DEBUG_ADAPTOR_PARAMS
2309 storage_adaptor_debug_func("[out] return code (%d)", ret);
2310 if ((NULL != file_info) && (NULL != (*file_info))) {
2311 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
2313 if ((NULL != error) && (NULL != *error)) {
2314 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2315 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2317 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2318 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2325 * @brief Move a folder into destination folder
2327 * @param[in] plugin specifies Storage Adaptor Plugin handle
2328 * @param[in] context specifies Storage Adaptor Plugin Context handle
2329 * @param[in] parent_folder_storage_path specifies parent folder path of folder you want to move
2330 * @param[in] folder_name specifies folder name to be moved
2331 * @param[in] dest_parent_folder_storage_path specifies new parent folder path
2332 * @param[in] new_folder_name specifies new folder name
2333 * @param[in] request specifies optional parameter
2334 * @param[out] file_info specifies Storage Adaptor File Info handle
2335 * @param[out] error specifies error code
2336 * @param[out] response specifies optional parameter
2337 * @return 0 on success, otherwise a positive error value
2338 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2340 storage_error_code_t storage_adaptor_move_directory(storage_adaptor_plugin_h plugin,
2341 storage_adaptor_plugin_context_h context,
2342 const char *parent_folder_storage_path,
2343 const char *folder_name,
2344 const char *dest_parent_folder_storage_path,
2345 const char *new_folder_name,
2347 storage_adaptor_file_info_h *file_info,
2348 storage_adaptor_error_code_h *error,
2351 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2352 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2354 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2355 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2357 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2358 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2361 storage_adaptor_check_param_equal(NULL, plugin->handle->move_directory, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2362 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (move_directory)"));
2364 #ifdef DEBUG_ADAPTOR_PARAMS
2365 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2366 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2367 context->app_id, context->access_token, context->uid);
2368 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2369 storage_adaptor_debug_func("[in] folder_name (%s)", folder_name);
2370 storage_adaptor_debug_func("[in] dest_parent_folder_storage_path (%s)", dest_parent_folder_storage_path);
2371 storage_adaptor_debug_func("[in] new_folder_name (%s)", new_folder_name);
2372 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2376 storage_error_code_t ret = plugin->handle->move_directory(context, parent_folder_storage_path,
2377 folder_name, dest_parent_folder_storage_path, new_folder_name, request, file_info, error, response);
2378 plugin_req_exit(ret, plugin, error);
2380 #ifdef DEBUG_ADAPTOR_PARAMS
2381 storage_adaptor_debug_func("[out] return code (%d)", ret);
2382 if ((NULL != file_info) && (NULL != (*file_info))) {
2383 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
2385 if ((NULL != error) && (NULL != *error)) {
2386 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2387 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2389 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2390 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2397 * @brief Move a file into destination folder
2399 * @param[in] plugin specifies Storage Adaptor Plugin handle
2400 * @param[in] context specifies Storage Adaptor Plugin Context handle
2401 * @param[in] parent_folder_storage_path specifies folder path of file you want to move
2402 * @param[in] file_name specifies file name to be moved
2403 * @param[in] dest_parent_folder_storage_path specifies new folder path
2404 * @param[in] new_file_name specifies new file name
2405 * @param[in] request specifies optional parameter
2406 * @param[out] file_info specifies Storage Adaptor File Info handle
2407 * @param[out] error specifies error code
2408 * @param[out] response specifies optional parameter
2409 * @return 0 on success, otherwise a positive error value
2410 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2412 storage_error_code_t storage_adaptor_move_file(storage_adaptor_plugin_h plugin,
2413 storage_adaptor_plugin_context_h context,
2414 const char *parent_folder_storage_path,
2415 const char *file_name,
2416 const char *dest_parent_folder_storage_path,
2417 const char *new_file_name,
2419 storage_adaptor_file_info_h *file_info,
2420 storage_adaptor_error_code_h *error,
2423 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2424 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2426 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2427 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2429 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2430 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2433 storage_adaptor_check_param_equal(NULL, plugin->handle->move_file, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2434 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (move_file)"));
2436 #ifdef DEBUG_ADAPTOR_PARAMS
2437 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2438 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2439 context->app_id, context->access_token, context->uid);
2440 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2441 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2442 storage_adaptor_debug_func("[in] dest_parent_folder_storage_path (%s)", dest_parent_folder_storage_path);
2443 storage_adaptor_debug_func("[in] new_file_name (%s)", new_file_name);
2444 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2448 storage_error_code_t ret = plugin->handle->move_file(context, parent_folder_storage_path,
2449 file_name, dest_parent_folder_storage_path, new_file_name, request, file_info, error, response);
2450 plugin_req_exit(ret, plugin, error);
2452 #ifdef DEBUG_ADAPTOR_PARAMS
2453 storage_adaptor_debug_func("[out] return code (%d)", ret);
2454 if ((NULL != file_info) && (NULL != (*file_info))) {
2455 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
2457 if ((NULL != error) && (NULL != *error)) {
2458 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2459 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2461 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2462 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2469 * @brief Get state of file transfer request
2471 * @param[in] plugin specifies Storage Adaptor Plugin handle
2472 * @param[in] context specifies Storage Adaptor Plugin Context handle
2473 * @param[in] transfer_request_id specifies unique id for file transfer request
2474 * @param[in] request specifies optional parameter
2475 * @param[out] state specifies current state of transfer request
2476 * @param[out] error specifies error code
2477 * @param[out] response specifies optional parameter
2478 * @return 0 on success, otherwise a positive error value
2479 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2481 storage_error_code_t storage_adaptor_get_transfer_state(storage_adaptor_plugin_h plugin,
2482 storage_adaptor_plugin_context_h context,
2483 void *transfer_request_id,
2485 storage_adaptor_transfer_state_e *state,
2486 storage_adaptor_error_code_h *error,
2489 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2490 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2492 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2493 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2495 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2496 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2499 storage_adaptor_check_param_equal(NULL, plugin->handle->get_transfer_state, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2500 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (get_transfer_state)"));
2502 #ifdef DEBUG_ADAPTOR_PARAMS
2503 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2504 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
2505 context->app_id, context->access_token, context->cid, context->uid);
2506 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2510 storage_error_code_t ret = plugin->handle->get_transfer_state(context, transfer_request_id,
2511 request, state, error, response);
2512 plugin_req_exit(ret, plugin, error);
2514 #ifdef DEBUG_ADAPTOR_PARAMS
2515 storage_adaptor_debug_func("[out] return code (%d)", ret);
2516 if (NULL != state) {
2517 storage_adaptor_debug_func("[out] state (%d)", *state);
2519 if ((NULL != error) && (NULL != *error)) {
2520 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2521 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2523 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2524 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2531 * @brief Set state of file transfer request
2533 * @param[in] plugin specifies Storage Adaptor Plugin handle
2534 * @param[in] context specifies Storage Adaptor Plugin Context handle
2535 * @param[in] transfer_request_id specifies unique id for file transfer request
2536 * @param[in] state specifies state to set
2537 * @param[in] request specifies optional parameter
2538 * @param[out] error specifies error code
2539 * @param[out] response specifies optional parameter
2540 * @return 0 on success, otherwise a positive error value
2541 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2543 storage_error_code_t storage_adaptor_set_transfer_state(storage_adaptor_plugin_h plugin,
2544 storage_adaptor_plugin_context_h context,
2545 void *transfer_request_id,
2546 storage_adaptor_transfer_state_e state,
2548 storage_adaptor_error_code_h *error,
2551 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2552 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2554 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2555 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2557 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2558 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2561 storage_adaptor_check_param_equal(NULL, plugin->handle->set_transfer_state, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2562 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (set_transfer_state)"));
2564 #ifdef DEBUG_ADAPTOR_PARAMS
2565 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2566 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2567 context->app_id, context->access_token, context->uid);
2568 storage_adaptor_debug_func("[in] state(%d)", state);
2569 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2573 storage_error_code_t ret = plugin->handle->set_transfer_state(context, transfer_request_id,
2574 state, request, error, response);
2575 plugin_req_exit(ret, plugin, error);
2577 #ifdef DEBUG_ADAPTOR_PARAMS
2578 storage_adaptor_debug_func("[out] return code (%d)", ret);
2579 if ((NULL != error) && (NULL != *error)) {
2580 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2581 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2583 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2584 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2590 storage_error_code_t storage_adaptor_get_root_folder_path(storage_adaptor_plugin_h plugin,
2591 storage_adaptor_plugin_context_h context,
2593 char **root_folder_path,
2594 storage_adaptor_error_code_h *error,
2597 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2598 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2600 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2601 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2603 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2604 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2607 storage_adaptor_check_param_equal(NULL, root_folder_path, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2608 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (root_folder_path)"));
2611 storage_adaptor_check_param_equal(NULL, plugin->handle->get_root_folder_path, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2612 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (get_root_folder_path)"));
2614 #ifdef DEBUG_ADAPTOR_PARAMS
2615 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2616 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) uid(%s)]",
2617 context->app_id, context->access_token, context->uid);
2618 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2622 storage_error_code_t ret = plugin->handle->get_root_folder_path(context, request, root_folder_path, error, response);
2623 plugin_req_exit(ret, plugin, error);
2625 #ifdef DEBUG_ADAPTOR_PARAMS
2626 storage_adaptor_debug_func("[out] return code (%d)", ret);
2627 if (NULL != *root_folder_path) {
2628 storage_adaptor_debug_func("[out] root_folder_path (%s)", *root_folder_path);
2630 if ((NULL != error) && (NULL != *error)) {
2631 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2632 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2634 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2635 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2641 /* ////////////////////// Private feature //////////////////////////// */
2644 * @brief Uploads a file to cloud (Async)
2646 * @param[in] plugin specifies Storage Adaptor Plugin handle
2647 * @param[in] context specifies Storage Adaptor Plugin Context handle
2648 * @param[in] parent_folder_storage_path specifies folder path of file you want to upload
2649 * @param[in] file_name specifies file name to be uploaded to cloud
2650 * @param[in] upload_file_local_path specifies local path of the file to be uploaded
2651 * @param[in] publish specifies Allow to share file with no authentication
2652 * @param[in] request specifies optional parameter
2653 * @param[out] transfer_request_id specifies
2654 * @param[out] error specifies error code
2655 * @return 0 on success, otherwise a negative error value
2656 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2658 storage_error_code_t storage_adaptor_upload_file_async(storage_adaptor_plugin_h plugin,
2659 storage_adaptor_plugin_context_h context,
2660 const char *parent_folder_storage_path,
2661 const char *file_name,
2662 const char *upload_file_local_path,
2665 void *transfer_request_id,
2666 storage_adaptor_error_code_h *error)
2668 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2669 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2671 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2672 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2674 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2675 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2678 storage_adaptor_check_param_equal(NULL, plugin->handle->upload_file_async, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2679 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (upload_file_async)"));
2681 #ifdef DEBUG_ADAPTOR_PARAMS
2682 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2683 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
2684 context->app_id, context->access_token, context->cid, context->uid);
2685 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2686 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2687 storage_adaptor_debug_func("[in] upload_file_local_path (%s)", upload_file_local_path);
2688 storage_adaptor_debug_func("[in] publish (%d)", publish);
2689 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2693 storage_error_code_t ret = plugin->handle->upload_file_async(context, parent_folder_storage_path,
2694 file_name, upload_file_local_path, publish, request, transfer_request_id);
2695 plugin_req_exit(ret, plugin, error);
2697 #ifdef DEBUG_ADAPTOR_PARAMS
2698 storage_adaptor_debug_func("[out] return code (%d)", ret);
2699 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2706 * @brief Downloads a file to local (Async)
2708 * @param[in] plugin specifies Storage Adaptor Plugin handle
2709 * @param[in] context specifies Storage Adaptor Plugin Context handle
2710 * @param[in] parent_folder_storage_path specifies folder path of file you want to download
2711 * @param[in] file_name specifies file name to be downloaded to local
2712 * @param[in] download_file_local_path specifies local path to download
2713 * @param[in] request specifies optional parameter
2714 * @param[out] transfer_request_id specifies
2715 * @param[out] error specifies error code
2716 * @return 0 on success, otherwise a negative error value
2717 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2719 storage_error_code_t storage_adaptor_download_file_async(storage_adaptor_plugin_h plugin,
2720 storage_adaptor_plugin_context_h context,
2721 const char *parent_folder_storage_path,
2722 const char *file_name,
2723 const char *download_file_local_path,
2725 void *transfer_request_id,
2726 storage_adaptor_error_code_h *error)
2728 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2729 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2731 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2732 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2734 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2735 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2738 storage_adaptor_check_param_equal(NULL, plugin->handle->download_file_async, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2739 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (download_file_async)"));
2741 #ifdef DEBUG_ADAPTOR_PARAMS
2742 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2743 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
2744 context->app_id, context->access_token, context->cid, context->uid);
2745 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2746 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2747 storage_adaptor_debug_func("[in] download_file_local_path (%s)", download_file_local_path);
2748 storage_adaptor_debug_func("[in] request (addr : %p)", request);
2749 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2753 storage_error_code_t ret = plugin->handle->download_file_async(context, parent_folder_storage_path,
2754 file_name, download_file_local_path, request, transfer_request_id);
2755 plugin_req_exit(ret, plugin, error);
2757 #ifdef DEBUG_ADAPTOR_PARAMS
2758 storage_adaptor_debug_func("[out] return code (%d)", ret);
2759 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2767 * @brief Sets metadata of file at cloud
2769 * @param[in] plugin specifies Storage Adaptor Plugin handle
2770 * @param[in] context specifies Storage Adaptor Plugin Context handle
2771 * @param[in] parent_folder_storage_path specifies folder path of file you want to set meta data
2772 * @param[in] file_name specifies file name to be updated meta data
2773 * @param[in] meta_data specifies meta data (A pair of Key, Value)
2774 * @param[in] request specifies optional parameter
2775 * @param[out] file_info specifies Storage Adaptor File Info handle
2776 * @param[out] error specifies error code
2777 * @param[out] response specifies optional parameter
2778 * @return 0 on success, otherwise a negative error value
2779 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2781 storage_error_code_t storage_adaptor_set_meta(storage_adaptor_plugin_h plugin,
2782 storage_adaptor_plugin_context_h context,
2783 const char *parent_folder_storage_path,
2784 const char *file_name,
2785 const void *meta_data,
2787 storage_adaptor_file_info_h *file_info,
2788 storage_adaptor_error_code_h *error,
2791 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2792 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2794 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2795 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2797 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2798 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2801 storage_adaptor_check_param_equal(NULL, plugin->handle->set_meta, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2802 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (set_meta)"));
2804 #ifdef DEBUG_ADAPTOR_PARAMS
2805 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2806 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
2807 context->app_id, context->access_token, context->cid, context->uid);
2808 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2809 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2810 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2814 storage_error_code_t ret = plugin->handle->set_meta(context, parent_folder_storage_path,
2815 file_name, meta_data, request, file_info, error, response);
2816 plugin_req_exit(ret, plugin, error);
2818 #ifdef DEBUG_ADAPTOR_PARAMS
2819 storage_adaptor_debug_func("[out] return code (%d)", ret);
2820 if ((NULL != file_info) && (NULL != (*file_info))) {
2821 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
2823 if ((NULL != error) && (NULL != *error)) {
2824 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2825 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2827 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2828 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2835 * @brief Gets metatdata of file at cloud
2837 * @param[in] plugin specifies Storage Adaptor Plugin handle
2838 * @param[in] context specifies Storage Adaptor Plugin Context handle
2839 * @param[in] parent_folder_storage_path specifies folder path of file you want to get meta data
2840 * @param[in] file_name specifies file name
2841 * @param[in] request specifies optional parameter
2842 * @param[out] file_info specifies Storage Adaptor File Info handle
2843 * @param[out] meta_data specifies meta data (A pair of Key, Value)
2844 * @param[out] error specifies error code
2845 * @param[out] response specifies optional parameter
2846 * @return 0 on success, otherwise a negative error value
2847 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2849 storage_error_code_t storage_adaptor_get_meta(storage_adaptor_plugin_h plugin,
2850 storage_adaptor_plugin_context_h context,
2851 const char *parent_folder_storage_path,
2852 const char *file_name,
2854 storage_adaptor_file_info_h *file_info,
2856 storage_adaptor_error_code_h *error,
2859 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2860 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2862 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2863 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2865 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2866 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2869 storage_adaptor_check_param_equal(NULL, plugin->handle->get_meta, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2870 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (get_meta)"));
2872 #ifdef DEBUG_ADAPTOR_PARAMS
2873 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2874 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
2875 context->app_id, context->access_token, context->cid, context->uid);
2876 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
2877 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2878 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2882 storage_error_code_t ret = plugin->handle->get_meta(context, parent_folder_storage_path,
2883 file_name, request, file_info, meta_data, error, response);
2884 plugin_req_exit(ret, plugin, error);
2886 #ifdef DEBUG_ADAPTOR_PARAMS
2887 storage_adaptor_debug_func("[out] return code (%d)", ret);
2888 if ((NULL != file_info) && (NULL != (*file_info))) {
2889 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
2891 if ((NULL != error) && (NULL != *error)) {
2892 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2893 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2895 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2896 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2903 * @brief Set up Multi Channel Upload
2905 * @param[in] plugin specifies Storage Adaptor Plugin handle
2906 * @param[in] context specifies Storage Adaptor Plugin Context handle
2907 * @param[in] parent_folder_storage_path specifies folder path of file you want to upload
2908 * @param[in] file_name specifies file name to be uploaded to cloud
2909 * @param[in] upload_file_local_path specifies local path of the file to be uploaded
2910 * @param[in] chunk_size_byte specifies size of chunk
2911 * @param[in] request specifies optional parameter
2912 * @param[out] mupload_key specifies Multi Channel Upload key
2913 * @param[out] chunk_count specifies total number of chunks
2914 * @param[out] file_info specifies Storage Adaptor File Info handle
2915 * @param[out] error specifies error code
2916 * @param[out] response specifies optional parameter
2917 * @return 0 on success, otherwise a negative error value
2918 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2920 storage_error_code_t storage_adaptor_start_mupload(storage_adaptor_plugin_h plugin,
2921 storage_adaptor_plugin_context_h context,
2922 const char *parent_folder_storage_path,
2923 const char *file_name,
2924 const char *upload_file_local_path,
2925 const unsigned long long chunk_size,
2929 storage_adaptor_file_info_h *file_info,
2930 storage_adaptor_error_code_h *error,
2933 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2934 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
2936 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
2937 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
2939 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
2940 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
2942 storage_adaptor_check_param_equal(NULL, plugin->handle->start_mupload, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
2943 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (start_mupload)"));
2946 #ifdef DEBUG_ADAPTOR_PARAMS
2947 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
2948 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
2949 context->app_id, context->access_token, context->cid, context->uid);
2950 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
2951 storage_adaptor_debug_func("[in] chunk_size (%llu)", chunk_size);
2952 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
2956 storage_error_code_t ret = plugin->handle->start_mupload(context, parent_folder_storage_path,
2957 file_name, upload_file_local_path, chunk_size, request, mupload_key, chunk_count,
2958 file_info, error, response);
2959 plugin_req_exit(ret, plugin, error);
2961 #ifdef DEBUG_ADAPTOR_PARAMS
2962 storage_adaptor_debug_func("[out] return code (%d)", ret);
2963 if ((NULL != file_info) && (NULL != (*file_info))) {
2964 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
2966 if ((NULL != error) && (NULL != *error)) {
2967 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
2968 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
2970 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
2971 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
2978 * @brief Uploads a chunk to cloud
2980 * @param[in] plugin specifies Storage Adaptor Plugin handle
2981 * @param[in] context specifies Storage Adaptor Plugin Context handle
2982 * @param[in] mupload_key specifies Multi Channel Upload key
2983 * @param[in] chunk_number specifies number of chunk (Starting at 1)
2984 * @param[in] request specifies optional parameter
2985 * @param[out] file_info specifies Storage Adaptor File Info handle
2986 * @param[out] error specifies error code
2987 * @param[out] response specifies optional parameter
2988 * @return 0 on success, otherwise a negative error value
2989 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
2991 storage_error_code_t storage_adaptor_upload_mupload(storage_adaptor_plugin_h plugin,
2992 storage_adaptor_plugin_context_h context,
2993 const char *mupload_key,
2994 const int chunk_number,
2996 storage_adaptor_file_info_h *file_info,
2997 storage_adaptor_error_code_h *error,
3000 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3001 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3003 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3004 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3006 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3007 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3010 storage_adaptor_check_param_equal(NULL, plugin->handle->upload_mupload, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3011 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (upload_mupload)"));
3013 #ifdef DEBUG_ADAPTOR_PARAMS
3014 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3015 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3016 context->app_id, context->access_token, context->cid, context->uid);
3017 storage_adaptor_debug_func("[in] mupload_key (%s)", mupload_key);
3018 storage_adaptor_debug_func("[in] chunk_number (%d)", chunk_number);
3019 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3023 storage_error_code_t ret = plugin->handle->upload_mupload(context, mupload_key,
3024 chunk_number, request, file_info, error, response);
3025 plugin_req_exit(ret, plugin, error);
3027 #ifdef DEBUG_ADAPTOR_PARAMS
3028 storage_adaptor_debug_func("[out] return code (%d)", ret);
3029 if ((NULL != file_info) && (NULL != (*file_info))) {
3030 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
3032 if ((NULL != error) && (NULL != *error)) {
3033 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3034 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3036 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3037 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3044 * @brief Ends Multi channel Upload
3046 * @param[in] plugin specifies Storage Adaptor Plugin handle
3047 * @param[in] context specifies Storage Adaptor Plugin Context handle
3048 * @param[in] mupload_key specifies Multi Channel Upload key
3049 * @param[in] publish specifies Allow to share file with no authentication
3050 * @param[in] request specifies optional parameter
3051 * @param[out] file_info specifies Storage Adaptor File Info handle
3052 * @param[out] error specifies error code
3053 * @param[out] response specifies optional parameter
3054 * @return 0 on success, otherwise a negative error value
3055 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3057 storage_error_code_t storage_adaptor_end_mupload(storage_adaptor_plugin_h plugin,
3058 storage_adaptor_plugin_context_h context,
3059 const char *mupload_key,
3062 storage_adaptor_file_info_h *file_info,
3063 storage_adaptor_error_code_h *error,
3066 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3067 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3069 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3070 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3072 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3073 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3076 storage_adaptor_check_param_equal(NULL, plugin->handle->end_mupload, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3077 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (end_mupoad)"));
3079 #ifdef DEBUG_ADAPTOR_PARAMS
3080 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3081 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3082 context->app_id, context->access_token, context->cid, context->uid);
3083 storage_adaptor_debug_func("[in] mupload_key (%s)", mupload_key);
3084 storage_adaptor_debug_func("[in] publish (%d)", publish);
3085 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3089 storage_error_code_t ret = plugin->handle->end_mupload(context, mupload_key,
3090 publish, request, file_info, error, response);
3091 plugin_req_exit(ret, plugin, error);
3093 #ifdef DEBUG_ADAPTOR_PARAMS
3094 storage_adaptor_debug_func("[out] return code (%d)", ret);
3095 if ((NULL != file_info) && (NULL != (*file_info))) {
3096 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
3098 if ((NULL != error) && (NULL != *error)) {
3099 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3100 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3102 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3103 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3110 * @brief Requests list of chunks uploaded
3112 * @param[in] plugin specifies Storage Adaptor Plugin handle
3113 * @param[in] context specifies Storage Adaptor Plugin Context handle
3114 * @param[in] mupload_key specifies Multi Channel Upload key
3115 * @param[in] request specifies optional parameter
3116 * @param[out] file_info_list specifies Storage Adaptor File Info handle
3117 * @param[out] file_info_list_len specifies length of the file_info_list
3118 * @param[out] error specifies error code
3119 * @param[out] response specifies optional parameter
3120 * @return 0 on success, otherwise a negative error value
3121 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3123 storage_error_code_t storage_adaptor_list_mupload(storage_adaptor_plugin_h plugin,
3124 storage_adaptor_plugin_context_h context,
3125 const char *mupload_key,
3127 storage_adaptor_file_info_h **file_info_list,
3128 int *file_info_list_len,
3129 storage_adaptor_error_code_h *error,
3132 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3133 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3135 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3136 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3138 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3139 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3142 storage_adaptor_check_param_equal(NULL, plugin->handle->list_mupload, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3143 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (list_mupload)"));
3145 #ifdef DEBUG_ADAPTOR_PARAMS
3146 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3147 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3148 context->app_id, context->access_token, context->cid, context->uid);
3149 storage_adaptor_debug_func("[in] mupload_key (%s)", mupload_key);
3150 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3154 storage_error_code_t ret = plugin->handle->list_mupload(context, mupload_key,
3155 request, file_info_list, file_info_list_len, error, response);
3156 plugin_req_exit(ret, plugin, error);
3158 #ifdef DEBUG_ADAPTOR_PARAMS
3159 storage_adaptor_debug_func("[out] return code (%d)", ret);
3160 if (NULL != file_info_list_len) {
3161 storage_adaptor_debug_func("[out] file_info_list_len (%d)", *file_info_list_len);
3163 if ((NULL != error) && (NULL != *error)) {
3164 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3165 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3167 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3168 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3175 * @brief Cancels all operations
3177 * @param[in] plugin specifies Storage Adaptor Plugin handle
3178 * @param[in] context specifies Storage Adaptor Plugin Context handle
3179 * @param[in] mupload_key specifies Multi Channel Upload key
3180 * @param[in] request specifies optional parameter
3181 * @param[out] file_info specifies Storage Adaptor File Info handle
3182 * @param[out] error specifies error code
3183 * @param[out] response specifies optional parameter
3184 * @return 0 on success, otherwise a negative error value
3185 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3187 storage_error_code_t storage_adaptor_cancel_mupload(storage_adaptor_plugin_h plugin,
3188 storage_adaptor_plugin_context_h context,
3189 const char *mupload_key,
3191 storage_adaptor_file_info_h *file_info,
3192 storage_adaptor_error_code_h *error,
3195 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3196 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3198 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3199 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3201 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3202 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3205 storage_adaptor_check_param_equal(NULL, plugin->handle->cancel_mupload, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3206 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (cancel_mupload)"));
3208 #ifdef DEBUG_ADAPTOR_PARAMS
3209 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3210 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3211 context->app_id, context->access_token, context->cid, context->uid);
3212 storage_adaptor_debug_func("[in] mupload_key (%s)", mupload_key);
3213 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3217 storage_error_code_t ret = plugin->handle->cancel_mupload(context, mupload_key,
3218 request, file_info, error, response);
3219 plugin_req_exit(ret, plugin, error);
3221 #ifdef DEBUG_ADAPTOR_PARAMS
3222 storage_adaptor_debug_func("[out] return code (%d)", ret);
3223 if ((NULL != file_info) && (NULL != (*file_info))) {
3224 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
3226 if ((NULL != error) && (NULL != *error)) {
3227 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3228 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3230 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3231 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3238 * @brief Starts Transaction
3240 * @param[in] plugin specifies Storage Adaptor Plugin handle
3241 * @param[in] context specifies Storage Adaptor Plugin Context handle
3242 * @param[in] request specifies optional parameter
3243 * @param[out] tx_key specifies Transaction key
3244 * @param[out] error specifies error code
3245 * @param[out] response specifies optional parameter
3246 * @return 0 on success, otherwise a negative error value
3247 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3249 storage_error_code_t storage_adaptor_start_transaction(storage_adaptor_plugin_h plugin,
3250 storage_adaptor_plugin_context_h context,
3253 storage_adaptor_error_code_h *error,
3256 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3257 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3259 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3260 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3262 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3263 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3266 storage_adaptor_check_param_equal(NULL, plugin->handle->start_transaction, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3267 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (start_transacion)"));
3269 #ifdef DEBUG_ADAPTOR_PARAMS
3270 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3271 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3272 context->app_id, context->access_token, context->cid, context->uid);
3273 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3277 storage_error_code_t ret = plugin->handle->start_transaction(context, request,
3278 tx_key, error, response);
3279 plugin_req_exit(ret, plugin, error);
3281 #ifdef DEBUG_ADAPTOR_PARAMS
3282 storage_adaptor_debug_func("[out] return code (%d)", ret);
3283 if (NULL != tx_key) {
3284 storage_adaptor_debug_func("[out] tx_key (%s)", *tx_key);
3286 if ((NULL != error) && (NULL != *error)) {
3287 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3288 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3290 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3291 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3298 * @brief Uploads a file
3300 * @param[in] plugin specifies Storage Adaptor Plugin handle
3301 * @param[in] context specifies Storage Adaptor Plugin Context handle
3302 * @param[in] tx_key specifies Transaction key
3303 * @param[in] tx_seq specifies Transaction sequesnce (Starting at 1)
3304 * @param[in] parent_folder_storage_path specifies folder path of file you want to upload
3305 * @param[in] file_name specifies file name to be uploaded to cloud
3306 * @param[in] upload_file_local_path specifies local path of the file to be uploaded
3307 * @param[in] request specifies optional parameter
3308 * @param[out] file_info specifies Storage Adaptor File Info handle
3309 * @param[out] error specifies error code
3310 * @param[out] response specifies optional parameter
3311 * @return 0 on success, otherwise a negative error value
3312 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3314 storage_error_code_t storage_adaptor_upload_file_transaction(storage_adaptor_plugin_h plugin,
3315 storage_adaptor_plugin_context_h context,
3318 const char *parent_folder_storage_path,
3319 const char *file_name,
3320 const char *upload_file_local_path,
3322 storage_adaptor_file_info_h *file_info,
3323 storage_adaptor_error_code_h *error,
3326 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3327 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3329 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3330 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3332 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3333 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3336 storage_adaptor_check_param_equal(NULL, plugin->handle->upload_file_transaction, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3337 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (upload_file_transaction)"));
3339 #ifdef DEBUG_ADAPTOR_PARAMS
3340 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3341 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3342 context->app_id, context->access_token, context->cid, context->uid);
3343 storage_adaptor_debug_func("[in] tx_key (%s)", tx_key);
3344 storage_adaptor_debug_func("[in] tx_seq (%d)", tx_seq);
3345 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
3346 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
3347 storage_adaptor_debug_func("[in] upload_file_local_path (%s)", upload_file_local_path);
3348 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3352 storage_error_code_t ret = plugin->handle->upload_file_transaction(context, tx_key,
3353 tx_seq, parent_folder_storage_path, file_name, upload_file_local_path, request, file_info, error, response);
3354 plugin_req_exit(ret, plugin, error);
3356 #ifdef DEBUG_ADAPTOR_PARAMS
3357 storage_adaptor_debug_func("[out] return code (%d)", ret);
3358 if ((NULL != file_info) && (NULL != (*file_info))) {
3359 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
3362 if ((NULL != error) && (NULL != *error)) {
3363 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3364 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3366 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3367 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3374 * @brief Updates a folder
3376 * @param[in] plugin specifies Storage Adaptor Plugin handle
3377 * @param[in] context specifies Storage Adaptor Plugin Context handle
3378 * @param[in] tx_key specifies Transaction key
3379 * @param[in] tx_seq specifies Transaction sequesnce (Starting at 1)
3380 * @param[in] parent_folder_storage_path specifies folder path of folder you want to update
3381 * @param[in] folder_name specifies folder name to be updated
3382 * @param[in] request specifies optional parameter
3383 * @param[out] file_info specifies Storage Adaptor File Info handle
3384 * @param[out] error specifies error code
3385 * @param[out] response specifies optional parameter
3386 * @return 0 on success, otherwise a negative error value
3387 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3389 storage_error_code_t storage_adaptor_set_dir_transaction(storage_adaptor_plugin_h plugin,
3390 storage_adaptor_plugin_context_h context,
3393 const char *parent_folder_storage_path,
3394 const char *folder_name,
3396 storage_adaptor_file_info_h *file_info,
3397 storage_adaptor_error_code_h *error,
3400 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3401 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3403 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3404 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3406 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3407 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3410 storage_adaptor_check_param_equal(NULL, plugin->handle->set_dir_transaction, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3411 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (set_dir_transaction)"));
3413 #ifdef DEBUG_ADAPTOR_PARAMS
3414 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3415 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3416 context->app_id, context->access_token, context->cid, context->uid);
3417 storage_adaptor_debug_func("[in] tx_key (%s)", tx_key);
3418 storage_adaptor_debug_func("[in] tx_seq (%d)", tx_seq);
3419 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
3420 storage_adaptor_debug_func("[in] folder_name (%s)", folder_name);
3421 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3425 storage_error_code_t ret = plugin->handle->set_dir_transaction(context, tx_key,
3426 tx_seq, parent_folder_storage_path, folder_name, request, file_info, error, response);
3427 plugin_req_exit(ret, plugin, error);
3429 #ifdef DEBUG_ADAPTOR_PARAMS
3430 storage_adaptor_debug_func("[out] return code (%d)", ret);
3431 if ((NULL != file_info) && (NULL != (*file_info))) {
3432 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
3434 if ((NULL != error) && (NULL != *error)) {
3435 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3436 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3438 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3439 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3446 * @brief Removes a file
3448 * @param[in] plugin specifies Storage Adaptor Plugin handle
3449 * @param[in] context specifies Storage Adaptor Plugin Context handle
3450 * @param[in] tx_key specifies Transaction key
3451 * @param[in] tx_seq specifies Transaction sequesnce (Starting at 1)
3452 * @param[in] parent_folder_storage_path specifies folder path of file you want to delete
3453 * @param[in] file_name specifies file name to be deleted from cloud
3454 * @param[in] request specifies optional parameter
3455 * @param[in] upload_file_local_path specifies local path of the file to be uploaded
3456 * @param[out] file_info specifies Storage Adaptor File Info handle
3457 * @param[out] error specifies error code
3458 * @param[out] response specifies optional parameter
3459 * @return 0 on success, otherwise a negative error value
3460 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3462 storage_error_code_t storage_adaptor_delete_file_transaction(storage_adaptor_plugin_h plugin,
3463 storage_adaptor_plugin_context_h context,
3466 const char *parent_folder_storage_path,
3467 const char *file_name,
3469 storage_adaptor_file_info_h *file_info,
3470 storage_adaptor_error_code_h *error,
3473 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3474 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3476 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3477 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3479 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3480 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3483 storage_adaptor_check_param_equal(NULL, plugin->handle->delete_file_transaction, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3484 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (delete_file_transaction)"));
3486 #ifdef DEBUG_ADAPTOR_PARAMS
3487 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3488 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3489 context->app_id, context->access_token, context->cid, context->uid);
3490 storage_adaptor_debug_func("[in] tx_key (%s)", tx_key);
3491 storage_adaptor_debug_func("[in] tx_seq (%d)", tx_seq);
3492 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
3493 storage_adaptor_debug_func("[in] file_name (%s)", file_name);
3494 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3498 storage_error_code_t ret = plugin->handle->delete_file_transaction(context, tx_key,
3499 tx_seq, parent_folder_storage_path, file_name, request, file_info, error, response);
3500 plugin_req_exit(ret, plugin, error);
3502 #ifdef DEBUG_ADAPTOR_PARAMS
3503 storage_adaptor_debug_func("[out] return code (%d)", ret);
3504 if ((NULL != file_info) && (NULL != (*file_info))) {
3505 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
3507 if ((NULL != error) && (NULL != *error)) {
3508 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3509 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3511 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3512 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3519 * @brief Removes a folder
3521 * @param[in] plugin specifies Storage Adaptor Plugin handle
3522 * @param[in] context specifies Storage Adaptor Plugin Context handle
3523 * @param[in] tx_key specifies Transaction key
3524 * @param[in] tx_seq specifies Transaction sequesnce (Starting at 1)
3525 * @param[in] parent_folder_storage_path specifies folder path of folder you want to delete
3526 * @param[in] folder_name specifies folder name to be deleted
3527 * @param[in] request specifies optional parameter
3528 * @param[out] file_info specifies Storage Adaptor File Info handle
3529 * @param[out] error specifies error code
3530 * @param[out] response specifies optional parameter
3531 * @return 0 on success, otherwise a negative error value
3532 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3534 storage_error_code_t storage_adaptor_delete_dir_transaction(storage_adaptor_plugin_h plugin,
3535 storage_adaptor_plugin_context_h context,
3538 const char *parent_folder_storage_path,
3539 const char *folder_name,
3541 storage_adaptor_file_info_h *file_info,
3542 storage_adaptor_error_code_h *error,
3545 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3546 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3548 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3549 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3551 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3552 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3555 storage_adaptor_check_param_equal(NULL, plugin->handle->delete_dir_transaction, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3556 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (delete_dir_transaction)"));
3558 #ifdef DEBUG_ADAPTOR_PARAMS
3559 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3560 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3561 context->app_id, context->access_token, context->cid, context->uid);
3562 storage_adaptor_debug_func("[in] tx_key (%s)", tx_key);
3563 storage_adaptor_debug_func("[in] tx_seq (%d)", tx_seq);
3564 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
3565 storage_adaptor_debug_func("[in] folder_name (%s)", folder_name);
3566 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3570 storage_error_code_t ret = plugin->handle->delete_dir_transaction(context, tx_key,
3571 tx_seq, parent_folder_storage_path, folder_name, request, file_info, error, response);
3572 plugin_req_exit(ret, plugin, error);
3574 #ifdef DEBUG_ADAPTOR_PARAMS
3575 storage_adaptor_debug_func("[out] return code (%d)", ret);
3576 if ((NULL != file_info) && (NULL != (*file_info))) {
3577 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
3579 if ((NULL != error) && (NULL != *error)) {
3580 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3581 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3583 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3584 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3591 * @brief Ends Transaction
3593 * @param[in] plugin specifies Storage Adaptor Plugin handle
3594 * @param[in] context specifies Storage Adaptor Plugin Context handle
3595 * @param[in] tx_key specifies Transaction key
3596 * @param[in] tx_count specifies Transaction order count
3597 * @param[in] request specifies optional parameter
3598 * @param[out] file_info_list specifies Storage Adaptor File Info handle
3599 * @param[out] file_info_list_len specifies length of the file_info_list
3600 * @param[out] error specifies error code
3601 * @param[out] response specifies optional parameter
3602 * @return 0 on success, otherwise a negative error value
3603 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3605 storage_error_code_t storage_adaptor_end_transaction(storage_adaptor_plugin_h plugin,
3606 storage_adaptor_plugin_context_h context,
3610 storage_adaptor_file_info_h **file_info_list,
3611 int *file_info_list_len,
3612 storage_adaptor_error_code_h *error,
3615 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3616 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3618 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3619 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3621 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3622 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3625 storage_adaptor_check_param_equal(NULL, plugin->handle->end_transaction, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3626 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (end_transaction)"));
3628 #ifdef DEBUG_ADAPTOR_PARAMS
3629 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3630 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3631 context->app_id, context->access_token, context->cid, context->uid);
3632 storage_adaptor_debug_func("[in] tx_key (%s)", tx_key);
3633 storage_adaptor_debug_func("[in] tx_count (%d)", tx_count);
3634 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3638 storage_error_code_t ret = plugin->handle->end_transaction(context, tx_key,
3639 tx_count, request, file_info_list, file_info_list_len, error, response);
3640 plugin_req_exit(ret, plugin, error);
3642 #ifdef DEBUG_ADAPTOR_PARAMS
3643 storage_adaptor_debug_func("[out] return code (%d)", ret);
3644 if (NULL != file_info_list_len) {
3645 storage_adaptor_debug_func("[out] file_info_list_len (%d)", *file_info_list_len);
3647 if ((NULL != error) && (NULL != *error)) {
3648 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3649 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3651 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3652 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3659 * @brief Requests Transaction list
3661 * @param[in] plugin specifies Storage Adaptor Plugin handle
3662 * @param[in] context specifies Storage Adaptor Plugin Context handle
3663 * @param[in] tx_key specifies Transaction key
3664 * @param[in] request specifies optional parameter
3665 * @param[out] file_info_list specifies Storage Adaptor File Info handle
3666 * @param[out] file_info_list_len specifies length of the file_info_list
3667 * @param[out] error specifies error code
3668 * @param[out] response specifies optional parameter
3669 * @return 0 on success, otherwise a negative error value
3670 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3672 storage_error_code_t storage_adaptor_list_transaction(storage_adaptor_plugin_h plugin,
3673 storage_adaptor_plugin_context_h context,
3676 storage_adaptor_file_info_h **file_info_list,
3677 int *file_info_list_len,
3678 storage_adaptor_error_code_h *error,
3681 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3682 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3684 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3685 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3687 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3688 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3691 storage_adaptor_check_param_equal(NULL, plugin->handle->list_transaction, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3692 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (list_transaction)"));
3694 #ifdef DEBUG_ADAPTOR_PARAMS
3695 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3696 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3697 context->app_id, context->access_token, context->cid, context->uid);
3698 storage_adaptor_debug_func("[in] tx_key (%s)", tx_key);
3699 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3703 storage_error_code_t ret = plugin->handle->list_transaction(context, tx_key,
3704 request, file_info_list, file_info_list_len, error, response);
3705 plugin_req_exit(ret, plugin, error);
3707 #ifdef DEBUG_ADAPTOR_PARAMS
3708 storage_adaptor_debug_func("[out] return code (%d)", ret);
3709 if (NULL != file_info_list_len) {
3710 storage_adaptor_debug_func("[out] file_info_list_len (%d)", *file_info_list_len);
3712 if ((NULL != error) && (NULL != *error)) {
3713 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3714 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3716 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3717 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3724 * @brief Cancels all transactions
3726 * @param[in] plugin specifies Storage Adaptor Plugin handle
3727 * @param[in] context specifies Storage Adaptor Plugin Context handle
3728 * @param[in] tx_key specifies Transaction key
3729 * @param[in] request specifies optional parameter
3730 * @param[out] file_info_list specifies Storage Adaptor File Info handle
3731 * @param[out] file_info_list_len specifies length of the file_info_list
3732 * @param[out] error specifies error code
3733 * @param[out] response specifies optional parameter
3734 * @return 0 on success, otherwise a negative error value
3735 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3737 storage_error_code_t storage_adaptor_cancel_transaction(storage_adaptor_plugin_h plugin,
3738 storage_adaptor_plugin_context_h context,
3741 storage_adaptor_file_info_h **file_info_list,
3742 int *file_info_list_len,
3743 storage_adaptor_error_code_h *error,
3746 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3747 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3749 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3750 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3752 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3753 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3756 storage_adaptor_check_param_equal(NULL, plugin->handle->cancel_transaction, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3757 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (cancel_transaction)"));
3759 #ifdef DEBUG_ADAPTOR_PARAMS
3760 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3761 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3762 context->app_id, context->access_token, context->cid, context->uid);
3763 storage_adaptor_debug_func("[in] tx_key (%s)", tx_key);
3764 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3768 storage_error_code_t ret = plugin->handle->cancel_transaction(context, tx_key,
3769 request, file_info_list, file_info_list_len, error, response);
3770 plugin_req_exit(ret, plugin, error);
3772 #ifdef DEBUG_ADAPTOR_PARAMS
3773 storage_adaptor_debug_func("[out] return code (%d)", ret);
3774 if (NULL != file_info_list_len) {
3775 storage_adaptor_debug_func("[out] file_info_list_len (%d)", *file_info_list_len);
3777 if ((NULL != error) && (NULL != *error)) {
3778 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3779 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3781 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3782 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3789 * @brief Uploads multiple files to cloud
3791 * @param[in] plugin specifies Storage Adaptor Plugin handle
3792 * @param[in] context specifies Storage Adaptor Plugin Context handle
3793 * @param[in] parent_folder_storage_path specifies folder path of files you want to upload
3794 * @param[in] upload_file_local_path_list specifies local path list of the files to be uploaded
3795 * @param[in] upload_list_len specifies total number of files to be uploaded
3796 * @param[in] request specifies optional parameter
3797 * @param[out] error specifies error code
3798 * @param[out] response specifies optional parameter
3799 * @return 0 on success, otherwise a positive error value
3800 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3802 storage_error_code_t storage_adaptor_multi_file_upload(storage_adaptor_plugin_h plugin,
3803 storage_adaptor_plugin_context_h context,
3804 const char *parent_folder_storage_path,
3805 const char **upload_file_local_path_list,
3806 const int upload_list_len,
3808 storage_adaptor_error_code_h *error,
3811 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3812 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3814 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3815 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3817 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3818 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3821 storage_adaptor_check_param_equal(NULL, plugin->handle->multi_file_upload, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3822 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (multi_file_upload)"));
3824 #ifdef DEBUG_ADAPTOR_PARAMS
3825 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3826 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3827 context->app_id, context->access_token, context->cid, context->uid);
3828 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
3829 storage_adaptor_debug_func("[in] upload_list_len (%d)", upload_list_len);
3830 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3834 storage_error_code_t ret = plugin->handle->multi_file_upload(context, parent_folder_storage_path,
3835 upload_file_local_path_list, upload_list_len, request, error, response);
3836 plugin_req_exit(ret, plugin, error);
3838 #ifdef DEBUG_ADAPTOR_PARAMS
3839 storage_adaptor_debug_func("[out] return code (%d)", ret);
3840 if ((NULL != error) && (NULL != *error)) {
3841 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3842 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3844 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3845 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3852 * @brief Downloads multiple files in a folder
3854 * @param[in] plugin specifies Storage Adaptor Plugin handle
3855 * @param[in] context specifies Storage Adaptor Plugin Context handle
3856 * @param[in] parent_folder_storage_path specifies folder path of files you want to download
3857 * @param[in] file_name_list specifies file name list to be downloaded
3858 * @param[in] file_name_list_len specifies total number of files to be downloaded
3859 * @param[in] download_folder_local_path specifies local folder path to download files
3860 * @param[in] request specifies optional parameter
3861 * @param[out] file_info_list specifies Storage Adaptor File Info handle
3862 * @param[out] file_info_list_len specifies length of the file_info_list
3863 * @param[out] error specifies error code
3864 * @param[out] response specifies optional parameter
3865 * @return 0 on success, otherwise a positive error value
3866 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3868 storage_error_code_t storage_adaptor_multi_file_download(storage_adaptor_plugin_h plugin,
3869 storage_adaptor_plugin_context_h context,
3870 const char *parent_folder_storage_path,
3871 const char *file_name_list,
3872 const int file_name_list_len,
3873 const char *download_folder_local_path,
3875 storage_adaptor_file_info_h **file_info_list,
3876 int *file_info_list_len,
3877 storage_adaptor_error_code_h *error,
3880 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3881 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3883 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3884 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3886 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3887 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3890 storage_adaptor_check_param_equal(NULL, plugin->handle->multi_file_download, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3891 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (multi_file_download)"));
3893 #ifdef DEBUG_ADAPTOR_PARAMS
3894 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3895 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3896 context->app_id, context->access_token, context->cid, context->uid);
3897 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
3898 storage_adaptor_debug_func("[in] download_list_len (%d)", file_name_list_len);
3899 storage_adaptor_debug_func("[in] download_folder_local_path (%s)", download_folder_local_path);
3900 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3904 storage_error_code_t ret = plugin->handle->multi_file_download(context, parent_folder_storage_path,
3905 file_name_list, file_name_list_len, download_folder_local_path, request, file_info_list,
3906 file_info_list_len, error, response);
3907 plugin_req_exit(ret, plugin, error);
3909 #ifdef DEBUG_ADAPTOR_PARAMS
3910 storage_adaptor_debug_func("[out] return code (%d)", ret);
3911 if (NULL != file_info_list_len) {
3912 storage_adaptor_debug_func("[out] file_info_list_len (%d)", *file_info_list_len);
3914 if ((NULL != error) && (NULL != *error)) {
3915 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3916 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3918 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3919 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3926 * @brief Requests current server timestamp
3928 * @param[in] plugin specifies Storage Adaptor Plugin handle
3929 * @param[in] context specifies Storage Adaptor Plugin Context handle
3930 * @param[in] request specifies optional parameter
3931 * @param[out] timestamp specifies server timestamp
3932 * @param[out] error specifies error code
3933 * @param[out] response specifies optional parameter
3934 * @return 0 on success, otherwise a positive error value
3935 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
3937 storage_error_code_t storage_adaptor_get_timestamp(storage_adaptor_plugin_h plugin,
3938 storage_adaptor_plugin_context_h context,
3940 unsigned long long *timestamp,
3941 storage_adaptor_error_code_h *error,
3944 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3945 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
3947 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
3948 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
3950 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
3951 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
3954 storage_adaptor_check_param_equal(NULL, plugin->handle->get_timestamp, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
3955 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (get_timestamp)"));
3957 #ifdef DEBUG_ADAPTOR_PARAMS
3958 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
3959 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
3960 context->app_id, context->access_token, context->cid, context->uid);
3961 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
3965 storage_error_code_t ret = plugin->handle->get_timestamp(context, request,
3966 timestamp, error, response);
3967 plugin_req_exit(ret, plugin, error);
3969 #ifdef DEBUG_ADAPTOR_PARAMS
3970 storage_adaptor_debug_func("[out] return code (%d)", ret);
3971 if (NULL != timestamp) {
3972 storage_adaptor_debug_func("[out] timestamp (%llu)", *timestamp);
3974 if ((NULL != error) && (NULL != *error)) {
3975 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
3976 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
3978 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
3979 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
3986 * @brief Requests a file info by public token
3988 * @param[in] plugin specifies Storage Adaptor Plugin handle
3989 * @param[in] context specifies Storage Adaptor Plugin Context handle
3990 * @param[in] public_token specifies token for Download, Get API
3991 (when terminal upload file and add publish=true parameter, or
3992 * @param[in] auth_code specifies Authentication code for public APIs
3993 * @param[in] request specifies optional parameter
3994 * @param[out] file_info specifies Storage Adaptor File Info handle
3995 * @param[out] error specifies error code
3996 * @param[out] response specifies optional parameter
3997 * @return 0 on success, otherwise a positive error value
3998 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4000 storage_error_code_t storage_adaptor_get_file_info_by_public_token(storage_adaptor_plugin_h plugin,
4001 storage_adaptor_plugin_context_h context,
4002 const char *public_token,
4003 const char *auth_code,
4005 storage_adaptor_file_info_h *file_info,
4006 storage_adaptor_error_code_h *error,
4009 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4010 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4012 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4013 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4015 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4016 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4019 storage_adaptor_check_param_equal(NULL, plugin->handle->get_file_info_by_public_token, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4020 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (get_file_info_by_public_token)"));
4022 #ifdef DEBUG_ADAPTOR_PARAMS
4023 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4024 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4025 context->app_id, context->access_token, context->cid, context->uid);
4026 storage_adaptor_debug_func("[in] public_token (%s)", public_token);
4027 storage_adaptor_debug_func("[in] auth_code (%s)", auth_code);
4028 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4032 storage_error_code_t ret = plugin->handle->get_file_info_by_public_token(context, public_token,
4033 auth_code, request, file_info, error, response);
4034 plugin_req_exit(ret, plugin, error);
4036 #ifdef DEBUG_ADAPTOR_PARAMS
4037 storage_adaptor_debug_func("[out] return code (%d)", ret);
4038 if ((NULL != file_info) && (NULL != (*file_info))) {
4039 storage_adaptor_debug_func("[out] file_info->storage_path (%s)", (*file_info)->storage_path);
4041 if ((NULL != error) && (NULL != *error)) {
4042 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4043 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4045 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4046 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4053 * @brief Downloads a file by public token (Sync)
4055 * @param[in] plugin specifies Storage Adaptor Plugin handle
4056 * @param[in] context specifies Storage Adaptor Plugin Context handle
4057 * @param[in] public_token specifies token for Download, Get API
4058 (when terminal upload file and add publish=true parameter, or
4059 * @param[in] auth_code specifies Authentication code for public APIs
4060 * @param[in] download_file_local_path specifies local path to download
4061 * @param[in] request specifies optional parameter
4062 * @param[out] error specifies error code
4063 * @param[out] response specifies optional parameter
4064 * @return 0 on success, otherwise a positive error value
4065 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4067 storage_error_code_t storage_adaptor_download_file_sync_by_public_token(storage_adaptor_plugin_h plugin,
4068 storage_adaptor_plugin_context_h context,
4069 const char *public_token,
4070 const char *auth_code,
4071 const char *download_file_local_path,
4073 storage_adaptor_error_code_h *error,
4076 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4077 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4079 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4080 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4082 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4083 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4086 storage_adaptor_check_param_equal(NULL, plugin->handle->download_file_sync_by_public_token, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4087 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (download_file_sync_by_public_token)"));
4089 #ifdef DEBUG_ADAPTOR_PARAMS
4090 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4091 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4092 context->app_id, context->access_token, context->cid, context->uid);
4093 storage_adaptor_debug_func("[in] public_token (%s)", public_token);
4094 storage_adaptor_debug_func("[in] auth_code (%s)", auth_code);
4095 storage_adaptor_debug_func("[in] download_file_local_path (%s)", download_file_local_path);
4096 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4100 storage_error_code_t ret = plugin->handle->download_file_sync_by_public_token(context, public_token,
4101 auth_code, download_file_local_path, request, error, response);
4102 plugin_req_exit(ret, plugin, error);
4104 #ifdef DEBUG_ADAPTOR_PARAMS
4105 storage_adaptor_debug_func("[out] return code (%d)", ret);
4106 if ((NULL != error) && (NULL != *error)) {
4107 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4108 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4110 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4111 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4118 * @brief Downloads a file by public token (Async)
4120 * @param[in] plugin specifies Storage Adaptor Plugin handle
4121 * @param[in] context specifies Storage Adaptor Plugin Context handle
4122 * @param[in] public_token specifies token for Download, Get API
4123 (when terminal upload file and add publish=true parameter, or
4124 * @param[in] auth_code specifies Authentication code for public APIs
4125 * @param[in] download_file_local_path specifies local path to download
4126 * @param[in] request specifies optional parameter
4127 * @param[out] transfer_request_id specifies
4128 * @param[out] error specifies error code
4129 * @return 0 on success, otherwise a positive error value
4130 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4132 storage_error_code_t storage_adaptor_download_file_async_by_public_token(storage_adaptor_plugin_h plugin,
4133 storage_adaptor_plugin_context_h context,
4134 const char *public_token,
4135 const char *auth_code,
4136 const char *download_file_local_path,
4138 void *transfer_request_id,
4139 storage_adaptor_error_code_h *error)
4141 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4142 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4144 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4145 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4147 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4148 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4151 storage_adaptor_check_param_equal(NULL, plugin->handle->download_file_async_by_public_token, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4152 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (download_file_async_by_public_token)"));
4154 #ifdef DEBUG_ADAPTOR_PARAMS
4155 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4156 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4157 context->app_id, context->access_token, context->cid, context->uid);
4158 storage_adaptor_debug_func("[in] public_token (%s)", public_token);
4159 storage_adaptor_debug_func("[in] auth_code (%s)", auth_code);
4160 storage_adaptor_debug_func("[in] download_file_local_path (%s)", download_file_local_path);
4161 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4165 storage_error_code_t ret = plugin->handle->download_file_async_by_public_token(context, public_token,
4166 auth_code, download_file_local_path, request, transfer_request_id);
4167 plugin_req_exit(ret, plugin, error);
4169 #ifdef DEBUG_ADAPTOR_PARAMS
4170 storage_adaptor_debug_func("[out] return code (%d)", ret);
4171 storage_adaptor_debug_func("[out] request_id [addr(%p)]", transfer_request_id);
4172 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4179 * @brief Authenticates public auth code
4181 * @param[in] plugin specifies Storage Adaptor Plugin handle
4182 * @param[in] context specifies Storage Adaptor Plugin Context handle
4183 * @param[in] public_token specifies token for Download, Get API
4184 (when terminal upload file and add publish=true parameter, or
4185 * @param[in] auth_code specifies Authentication code for public APIs
4186 * @param[in] request specifies optional parameter
4187 * @param[out] error specifies error code
4188 * @param[out] response specifies optional parameter
4189 * @return 0 on success, otherwise a positive error value
4190 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4192 storage_error_code_t storage_adaptor_auth_public_authcode_by_public_token(storage_adaptor_plugin_h plugin,
4193 storage_adaptor_plugin_context_h context,
4194 const char *public_token,
4195 const char *auth_code,
4197 storage_adaptor_error_code_h *error,
4200 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4201 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4203 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4204 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4206 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4207 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4210 storage_adaptor_check_param_equal(NULL, plugin->handle->auth_public_authcode_by_public_token, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4211 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (auth_public_authcode_by_public_token)"));
4213 #ifdef DEBUG_ADAPTOR_PARAMS
4214 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4215 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4216 context->app_id, context->access_token, context->cid, context->uid);
4217 storage_adaptor_debug_func("[in] public_token (%s)", public_token);
4218 storage_adaptor_debug_func("[in] auth_code (%s)", auth_code);
4219 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4223 storage_error_code_t ret = plugin->handle->auth_public_authcode_by_public_token(context, public_token,
4224 auth_code, request, error, response);
4225 plugin_req_exit(ret, plugin, error);
4227 #ifdef DEBUG_ADAPTOR_PARAMS
4228 storage_adaptor_debug_func("[out] return code (%d)", ret);
4229 if ((NULL != error) && (NULL != *error)) {
4230 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4231 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4233 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4234 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4241 * @brief Removes multiple files in a folder
4243 * @param[in] plugin specifies Storage Adaptor Plugin handle
4244 * @param[in] context specifies Storage Adaptor Plugin Context handle
4245 * @param[in] parent_folder_storage_path specifies folder path of files you want to delete
4246 * @param[in] file_name_list specifies file name list to be deleted
4247 * @param[in] file_name_list_len specifies total number of files to be deleted
4248 * @param[in] request specifies optional parameter
4249 * @param[out] file_info_list specifies Storage Adaptor File Info handle
4250 * @param[out] file_info_list_len specifies length of the file_info_list
4251 * @param[out] error specifies error code
4252 * @param[out] response specifies optional parameter
4253 * @return 0 on success, otherwise a positive error value
4254 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4256 storage_error_code_t storage_adaptor_delete_multi_file_in_folder(storage_adaptor_plugin_h plugin,
4257 storage_adaptor_plugin_context_h context,
4258 const char *parent_folder_storage_path,
4259 const char **file_name_list,
4260 const int file_name_list_len,
4262 storage_adaptor_file_info_h **file_info_list,
4263 int *file_info_list_len,
4264 storage_adaptor_error_code_h *error,
4267 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4268 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4270 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4271 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4273 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4274 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4277 storage_adaptor_check_param_equal(NULL, plugin->handle->delete_multi_file_in_folder, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4278 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (delete_multi_file_in_folder)"));
4280 #ifdef DEBUG_ADAPTOR_PARAMS
4281 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4282 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4283 context->app_id, context->access_token, context->cid, context->uid);
4284 storage_adaptor_debug_func("[in] parent_folder_storage_path (%s)", parent_folder_storage_path);
4285 storage_adaptor_debug_func("[in] file_name_list_len (%d)", file_name_list_len);
4286 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4290 storage_error_code_t ret = plugin->handle->delete_multi_file_in_folder(context, parent_folder_storage_path,
4291 file_name_list, file_name_list_len, request, file_info_list, file_info_list_len, error, response);
4292 plugin_req_exit(ret, plugin, error);
4294 #ifdef DEBUG_ADAPTOR_PARAMS
4295 storage_adaptor_debug_func("[out] return code (%d)", ret);
4296 if (NULL != file_info_list_len) {
4297 storage_adaptor_debug_func("[out] file_info_list_len (%d)", *file_info_list_len);
4299 if ((NULL != error) && (NULL != *error)) {
4300 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4301 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4303 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4304 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4311 * @brief Requests policy for upload
4313 * @param[in] plugin specifies Storage Adaptor Plugin handle
4314 * @param[in] context specifies Storage Adaptor Plugin Context handle
4315 * @param[in] request specifies optional parameter
4316 * @param[out] allowed_extension specifies
4317 * @param[out] allowed_extension_len specifies length of allowed_extension
4318 * @param[out] error specifies error code
4319 * @param[out] response specifies optional parameter
4320 * @return 0 on success, otherwise a positive error value
4321 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4323 storage_error_code_t storage_adaptor_get_policy(storage_adaptor_plugin_h plugin,
4324 storage_adaptor_plugin_context_h context,
4326 char ***allowed_extension,
4327 int *allowed_extension_len,
4328 storage_adaptor_error_code_h *error,
4331 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4332 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4334 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4335 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4337 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4338 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4341 storage_adaptor_check_param_equal(NULL, plugin->handle->get_policy, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4342 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (get_policy)"));
4344 #ifdef DEBUG_ADAPTOR_PARAMS
4345 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4346 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4347 context->app_id, context->access_token, context->cid, context->uid);
4348 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4352 storage_error_code_t ret = plugin->handle->get_policy(context, request,
4353 allowed_extension, allowed_extension_len, error, response);
4354 plugin_req_exit(ret, plugin, error);
4356 #ifdef DEBUG_ADAPTOR_PARAMS
4357 storage_adaptor_debug_func("[out] return code (%d)", ret);
4358 if (NULL != allowed_extension_len) {
4359 storage_adaptor_debug_func("[out] allowed_extension_len (%d)", *allowed_extension_len);
4361 if ((NULL != error) && (NULL != *error)) {
4362 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4363 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4365 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4366 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4373 * @brief Requests quota of user
4375 * @param[in] plugin specifies Storage Adaptor Plugin handle
4376 * @param[in] context specifies Storage Adaptor Plugin Context handle
4377 * @param[in] request specifies optional parameter
4378 * @param[out] total_usage specifies total usage of user
4379 * @param[out] total_quota specifies total quota of user
4380 * @param[out] error specifies error code
4381 * @param[out] response specifies optional parameter
4382 * @return 0 on success, otherwise a positive error value
4383 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4385 storage_error_code_t storage_adaptor_get_quota(storage_adaptor_plugin_h plugin,
4386 storage_adaptor_plugin_context_h context,
4388 unsigned long long *total_usage,
4389 unsigned long long *total_quota,
4390 storage_adaptor_error_code_h *error,
4393 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4394 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4396 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4397 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4399 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4400 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4403 storage_adaptor_check_param_equal(NULL, plugin->handle->get_quota, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4404 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (get_quota)"));
4406 #ifdef DEBUG_ADAPTOR_PARAMS
4407 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4408 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4409 context->app_id, context->access_token, context->cid, context->uid);
4410 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4414 storage_error_code_t ret = plugin->handle->get_quota(context, request,
4415 total_usage, total_quota, error, response);
4416 plugin_req_exit(ret, plugin, error);
4418 #ifdef DEBUG_ADAPTOR_PARAMS
4419 storage_adaptor_debug_func("[out] return code (%d)", ret);
4420 if (NULL != total_usage) {
4421 storage_adaptor_debug_func("[out] total_usage (%llu)", *total_usage);
4423 if (NULL != total_quota) {
4424 storage_adaptor_debug_func("[out] total_quota (%llu)", *total_quota);
4426 if ((NULL != error) && (NULL != *error)) {
4427 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4428 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4430 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4431 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4438 * @brief Requests Redirect URL mapped with public token (Not yet supported)
4440 * @param[in] plugin specifies Storage Adaptor Plugin handle
4441 * @param[in] context specifies Storage Adaptor Plugin Context handle
4442 * @param[in] public_token specifies token for Download, Get API
4443 (when terminal upload file and add publish=true parameter, or
4444 * @param[in] request specifies optional parameter
4445 * @param[out] error specifies error code
4446 * @param[out] response specifies optional parameter
4447 * @return 0 on success, otherwise a positive error value
4448 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4450 storage_error_code_t storage_adaptor_redirect_url_by_public_token(storage_adaptor_plugin_h plugin,
4451 storage_adaptor_plugin_context_h context,
4452 const char *public_token,
4454 storage_adaptor_error_code_h *error,
4457 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4458 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4460 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4461 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4463 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4464 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4467 storage_adaptor_check_param_equal(NULL, plugin->handle->redirect_url_by_public_token, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4468 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (redirect_url_by_public_token)"));
4470 #ifdef DEBUG_ADAPTOR_PARAMS
4471 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4472 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4473 context->app_id, context->access_token, context->cid, context->uid);
4474 storage_adaptor_debug_func("[in] public_token (%s)", public_token);
4475 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4479 storage_error_code_t ret = plugin->handle->redirect_url_by_public_token(context, public_token,
4480 request, error, response);
4481 plugin_req_exit(ret, plugin, error);
4483 #ifdef DEBUG_ADAPTOR_PARAMS
4484 storage_adaptor_debug_func("[out] return code (%d)", ret);
4485 if ((NULL != error) && (NULL != *error)) {
4486 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4487 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4489 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4490 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4497 * @brief Creates Upload URL (Not yet supported)
4499 * @param[in] plugin specifies Storage Adaptor Plugin handle
4500 * @param[in] context specifies Storage Adaptor Plugin Context handle
4501 * @param[in] parent_folder_storage_path specifies folder path of files you want to upload
4502 * @param[in] file_name specifies file name to be uploaded
4503 * @param[in] x_upload_content_length specifies length of content
4504 * @param[in] request specifies optional parameter
4505 * @param[out] error specifies error code
4506 * @param[out] response specifies optional parameter
4507 * @return 0 on success, otherwise a positive error value
4508 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4510 storage_error_code_t storage_adaptor_create_resuming_upload_url(storage_adaptor_plugin_h plugin,
4511 storage_adaptor_plugin_context_h context,
4512 const char *parent_folder_storage_path,
4513 const char *file_name,
4514 const unsigned long long x_upload_content_length,
4516 storage_adaptor_error_code_h *error,
4519 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4520 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4522 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4523 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4525 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4526 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4529 storage_adaptor_check_param_equal(NULL, plugin->handle->create_resuming_upload_url, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4530 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (create_resuming_upload_url)"));
4532 #ifdef DEBUG_ADAPTOR_PARAMS
4533 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4534 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4535 context->app_id, context->access_token, context->cid, context->uid);
4536 storage_adaptor_debug_func("[in] parent_folder_storage_path(%s)", parent_folder_storage_path);
4537 storage_adaptor_debug_func("[in] file_name(%s)", file_name);
4538 storage_adaptor_debug_func("[in] x_upload_content_length(%llu)", x_upload_content_length);
4539 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4543 storage_error_code_t ret = plugin->handle->create_resuming_upload_url(context, parent_folder_storage_path,
4544 file_name, x_upload_content_length, request, error, response);
4545 plugin_req_exit(ret, plugin, error);
4547 #ifdef DEBUG_ADAPTOR_PARAMS
4548 storage_adaptor_debug_func("[out] return code (%d)", ret);
4549 if ((NULL != error) && (NULL != *error)) {
4550 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4551 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4553 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4554 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4561 * @brief Creates chunk Upload URL (Not yet supported)
4563 * @param[in] plugin specifies Storage Adaptor Plugin handle
4564 * @param[in] context specifies Storage Adaptor Plugin Context handle
4565 * @param[in] mupload_key specifies Multi Channel Upload key
4566 * @param[in] chunk_number specifies number of chunk (Starting at 1)
4567 * @param[in] x_upload_content_length specifies length of content
4568 * @param[in] request specifies optional parameter
4569 * @param[out] rupload_key specifies Resuming Upload key
4570 * @param[out] error specifies error code
4571 * @param[out] response specifies optional parameter
4572 * @return 0 on success, otherwise a positive error value
4573 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4575 storage_error_code_t storage_adaptor_create_resuming_chunk_upload_url(storage_adaptor_plugin_h plugin,
4576 storage_adaptor_plugin_context_h context,
4577 const char *mupload_key,
4578 const int chunk_number,
4579 const unsigned long long x_upload_content_length,
4582 storage_adaptor_error_code_h *error,
4585 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4586 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4588 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4589 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4591 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4592 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4595 storage_adaptor_check_param_equal(NULL, plugin->handle->create_resuming_chunk_upload_url, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4596 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (create_resuming_chunk_upload_url)"));
4598 #ifdef DEBUG_ADAPTOR_PARAMS
4599 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4600 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4601 context->app_id, context->access_token, context->cid, context->uid);
4602 storage_adaptor_debug_func("[in] mupload_key(%s)", mupload_key);
4603 storage_adaptor_debug_func("[in] chunk_number(%d)", chunk_number);
4604 storage_adaptor_debug_func("[in] x_upload_content_length(%llu)", x_upload_content_length);
4605 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4609 storage_error_code_t ret = plugin->handle->create_resuming_chunk_upload_url(context, mupload_key,
4610 chunk_number, x_upload_content_length, request, rupload_key, error, response);
4611 plugin_req_exit(ret, plugin, error);
4613 #ifdef DEBUG_ADAPTOR_PARAMS
4614 storage_adaptor_debug_func("[out] return code (%d)", ret);
4615 if (NULL != rupload_key) {
4616 storage_adaptor_debug_func("[out] rupload_key (%s)", *rupload_key);
4618 if ((NULL != error) && (NULL != *error)) {
4619 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4620 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4622 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4623 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4630 * @brief Resumes Upload (Not yet supported)
4632 * @param[in] plugin specifies Storage Adaptor Plugin handle
4633 * @param[in] context specifies Storage Adaptor Plugin Context handle
4634 * @param[in] rupload_key specifies Resuming Upload key
4635 * @param[in] content_range specifies range of content
4636 * @param[in] content_length specifies length of content
4637 * @param[in] request specifies optional parameter
4638 * @param[out] error specifies error code
4639 * @param[out] response specifies optional parameter
4640 * @return 0 on success, otherwise a positive error value
4641 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4643 storage_error_code_t storage_adaptor_resuming_upload(storage_adaptor_plugin_h plugin,
4644 storage_adaptor_plugin_context_h context,
4645 const char *rupload_key,
4646 const char *change_range,
4647 const unsigned long long content_length,
4649 storage_adaptor_error_code_h *error,
4652 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4653 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4655 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4656 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4658 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4659 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4662 storage_adaptor_check_param_equal(NULL, plugin->handle->resuming_upload, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4663 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (resuming_upload)"));
4665 #ifdef DEBUG_ADAPTOR_PARAMS
4666 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4667 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4668 context->app_id, context->access_token, context->cid, context->uid);
4669 storage_adaptor_debug_func("[in] rupload_key(%s)", rupload_key);
4670 storage_adaptor_debug_func("[in] change_range(%d)", change_range);
4671 storage_adaptor_debug_func("[in] content_length(%llu)", content_length);
4672 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4676 storage_error_code_t ret = plugin->handle->resuming_upload(context, rupload_key,
4677 change_range, content_length, request, error, response);
4678 plugin_req_exit(ret, plugin, error);
4680 #ifdef DEBUG_ADAPTOR_PARAMS
4681 storage_adaptor_debug_func("[out] return code (%d)", ret);
4682 if ((NULL != error) && (NULL != *error)) {
4683 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4684 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4686 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4687 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4694 * @brief Get progress of file transfer request
4696 * @param[in] plugin specifies Storage Adaptor Plugin handle
4697 * @param[in] context specifies Storage Adaptor Plugin Context handle
4698 * @param[in] transfer_request_id specifies unique id for file transfer request
4699 * @param[in] request specifies optional parameter
4700 * @param[out] progress_size specifies current progress size
4701 * @param[out] total_size specifies total size to transfer
4702 * @param[out] error specifies error code
4703 * @param[out] response specifies optional parameter
4704 * @return 0 on success, otherwise a positive error value
4705 * @retval error code defined in storage_error_code_t - STORAGE_ADAPTOR_ERROR_NONE if Successful
4707 storage_error_code_t storage_adaptor_get_transfer_progress(storage_adaptor_plugin_h plugin,
4708 storage_adaptor_plugin_context_h context,
4709 void *transfer_request_id,
4711 unsigned long long *progress_size_byte,
4712 unsigned long long *total_size_byte,
4713 storage_adaptor_error_code_h *error,
4716 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4717 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (plugin)"));
4719 storage_adaptor_check_param_equal(NULL, plugin, STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT,
4720 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_ARGUMENT, "Invalid argument (context)"));
4722 storage_adaptor_check_param_equal(NULL, plugin->handle, STORAGE_ADAPTOR_ERROR_INVALID_HANDLE,
4723 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_INVALID_HANDLE, "Invalid plugin handle"));
4726 storage_adaptor_check_param_equal(NULL, plugin->handle->get_transfer_progress, STORAGE_ADAPTOR_ERROR_UNSUPPORTED,
4727 __assign_error_code(error, (int64_t) STORAGE_ADAPTOR_ERROR_UNSUPPORTED, "Plugin does not support this API (get_transfer_progress)"));
4729 #ifdef DEBUG_ADAPTOR_PARAMS
4730 storage_adaptor_debug_func("========== %s ==========", __FUNCTION__);
4731 storage_adaptor_debug_func("[in] Context [app_id(%s) access_token(%s) cid(%s) uid(%s)]",
4732 context->app_id, context->access_token, context->cid, context->uid);
4733 storage_adaptor_debug_func("[in] tansfer_request_id [addr(%p)]", transfer_request_id);
4734 storage_adaptor_debug_func("[in] request [addr(%p)]", request);
4738 storage_error_code_t ret = plugin->handle->get_transfer_progress(context, transfer_request_id,
4739 request, progress_size_byte, total_size_byte, error, response);
4740 plugin_req_exit(ret, plugin, error);
4742 #ifdef DEBUG_ADAPTOR_PARAMS
4743 storage_adaptor_debug_func("[out] return code (%d)", ret);
4744 if (NULL != progress_size_byte) {
4745 storage_adaptor_debug_func("[out] progress size : %10llubyte", *progress_size_byte);
4747 if (NULL != total_size_byte) {
4748 storage_adaptor_debug_func("[out] total size : %10llubyte", *total_size_byte);
4750 if ((NULL != error) && (NULL != *error)) {
4751 storage_adaptor_debug_func("[out] error->code (%llu)", (*error)->code);
4752 storage_adaptor_debug_func("[out] error->msg (%s)", (*error)->msg);
4754 storage_adaptor_debug_func("[out] response [addr(%p)]", response);
4755 storage_adaptor_debug_func("========== %s END ==========", __FUNCTION__);
4774 /* ///////////////////////////////////////////////////////////////////////////////
4775 ///////////////////////////////////////////////////////////////////////////////
4776 //////////// Internal function description (for forked plugin) //////////////
4777 ///////////////////////////////////////////////////////////////////////////////
4778 /////////////////////////////////////////////////////////////////////////////// */
4780 void *_storage_adaptor_plugin_message_collector(void *data)
4782 storage_adaptor_h adaptor = (storage_adaptor_h) data;
4784 storage_adaptor_info("3rd party plugin listener run");
4785 int i, lagest_fd = -1;
4788 tv.tv_sec = 10L; /* TODO change to define or meaningful value */
4789 char msg_buf[PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE] = {0, };
4790 int buf_size, rcv_len;
4791 GList *dead_list = NULL;
4794 /* Clears and sets fds for select */
4796 FD_SET(adaptor->rd_cmd[0], &read_set);
4797 lagest_fd = adaptor->rd_cmd[0];
4799 /* Sets plugin fds for select */
4800 for (i = 0; i < g_list_length(adaptor->rd_list); i++) {
4801 int fd = (int) g_list_nth_data(adaptor->rd_list, i);
4802 FD_SET(fd, &read_set);
4803 if (lagest_fd < fd) {
4808 /* Select with timeout (for avoid blocking issue) */
4809 int stmt = select((lagest_fd + 1), &read_set, NULL, NULL, &tv);
4810 IF_IS_PLUGIN_THAN_RETURN_NULL();
4812 /* storage_adaptor_debug("select refrech by timeout(%ld sec) [id : %d]", tv.tv_sec, g_process_identity); */
4813 if (0L >= tv.tv_sec) {
4814 /* storage_adaptor_debug("Resets selector timeout sec"); */
4817 IF_IS_PLUGIN_THAN_RETURN_NULL();
4818 } else if (stmt > 0) {
4819 /* Checking message queue with Plugin processes. */
4820 for (i = 0; i < g_list_length(adaptor->rd_list); i++) {
4821 IF_IS_PLUGIN_THAN_RETURN_NULL();
4822 int fd = (int) g_list_nth_data(adaptor->rd_list, i);
4823 if (FD_ISSET(fd, &read_set)) {
4824 IF_IS_PLUGIN_THAN_RETURN_NULL();
4825 /* pre-read buf size */
4826 rcv_len = read(fd, &buf_size, sizeof(int));
4828 storage_adaptor_debug("Child process dead (Remove from listening queue)");
4829 dead_list = g_list_append(dead_list, (gpointer)fd);
4832 /* allocates and read buf data */
4833 memset(msg_buf, 0, PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE);
4834 buf_size %= (PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE - 1);
4835 rcv_len = read(fd, msg_buf, buf_size);
4836 storage_adaptor_debug("read message [%s][%d]", msg_buf, rcv_len);
4839 /* transfer data to adaptor */
4840 __storage_adaptor_transfer_message(msg_buf);
4842 storage_adaptor_debug("Child process dead (Remove from listening queue)");
4843 dead_list = g_list_append(dead_list, (gpointer)fd);
4848 /* Checking message queue with Adaptor internal command. */
4849 IF_IS_PLUGIN_THAN_RETURN_NULL();
4850 if (FD_ISSET(adaptor->rd_cmd[0], &read_set)) {
4851 int fd = adaptor->rd_cmd[0];
4852 IF_IS_PLUGIN_THAN_RETURN_NULL();
4853 /* pre-read buf size */
4854 rcv_len = read(fd, &buf_size, sizeof(int));
4857 storage_adaptor_debug("Parent process dead : Listener break");
4861 /* allocates and read buf data */
4862 memset(msg_buf, 0, PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE);
4863 buf_size %= (PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE - 1);
4864 rcv_len = read(fd, msg_buf, buf_size);
4865 storage_adaptor_debug("read message [%s][%d]", msg_buf, rcv_len);
4868 storage_adaptor_debug("Parent process dead : Listener break");
4872 /* parse cmd message (e.g. append read_fd / change timeout sec / stop listener) */
4873 int cmd_ret = __storage_adaptor_parse_message_cmd(adaptor, msg_buf);
4875 storage_adaptor_info("3rd party plugin listener stopped by adaptor cmd");
4880 /* Remove fd with disconnected plugin. */
4881 for (i = 0; i < g_list_length(dead_list); i++) {
4882 adaptor->rd_list = g_list_remove(adaptor->rd_list, (gpointer) g_list_nth_data(dead_list, i));
4884 g_list_free(dead_list);
4887 storage_adaptor_error("plugin message listener error (errno : %d)", errno);
4890 storage_adaptor_info("3rd party plugin listener stopped");
4895 void __storage_adaptor_transfer_message(const char *msg)
4897 plugin_message_h t_msg = NULL;
4899 ret = plugin_message_deserialize(msg, &t_msg);
4901 pmnumber req_type, req_id;
4902 ret = plugin_message_get_value_number(t_msg, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE, &req_type);
4903 if (!ret && (PLUGIN_MESSAGE_TYPE_FUNCTION == req_type)) {
4904 storage_adaptor_debug("Message function type : function");
4905 ret = plugin_message_get_value_number(t_msg, PLUGIN_MESSAGE_ELEMENT_REQUEST_ID, &req_id);
4907 storage_adaptor_debug("Send plugin data to requester");
4908 int hooked_fd = (int) req_id;
4909 int len = strlen(msg);
4910 ret = write(hooked_fd, &len, sizeof(int));
4911 ret = write(hooked_fd, msg, sizeof(char) * len);
4913 storage_adaptor_debug("Couldn't get request id");
4915 } else if (!ret && (PLUGIN_MESSAGE_TYPE_CALLBACK == req_type)) {
4916 storage_adaptor_debug("Message function type : callback");
4917 /*TODO call callback function */
4918 char *callback_name = NULL;
4919 ret = plugin_message_get_value_string(t_msg, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME, &callback_name);
4920 storage_adaptor_error("Callback name : %s", callback_name);
4921 if (NULL == callback_name) {
4922 storage_adaptor_error("Function name parsing error");
4923 } else if (0 == strncmp(STORAGE_PLUGIN_CALLBACK_DOWNLOAD_FILE_ASYNC_CB,
4925 strlen(STORAGE_PLUGIN_CALLBACK_DOWNLOAD_FILE_ASYNC_CB))) {
4926 pmnumber fd, state, ret_code;
4927 char *ret_msg = NULL;
4929 storage_adaptor_error_code_h error = NULL;
4930 ret = plugin_message_get_value_number(t_msg, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
4931 ret = plugin_message_get_value_string(t_msg, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_msg);
4932 if (NULL != ret_msg) {
4933 error = storage_adaptor_create_error_code((int64_t) ret_code, ret_msg);
4935 ret = plugin_message_get_param_number(t_msg, param_idx++, &fd);
4936 ret = plugin_message_get_param_number(t_msg, param_idx++, &state);
4938 storage_adaptor_download_state_changed_reply_cb((int)fd, (storage_adaptor_transfer_state_e)state, error, NULL);
4939 storage_adaptor_destroy_error_code(&error);
4940 } else if (0 == strncmp(STORAGE_PLUGIN_CALLBACK_UPLOAD_FILE_ASYNC_CB,
4942 strlen(STORAGE_PLUGIN_CALLBACK_UPLOAD_FILE_ASYNC_CB))) {
4943 pmnumber fd, state, ret_code;
4944 char *ret_msg = NULL;
4946 storage_adaptor_error_code_h error = NULL;
4947 storage_adaptor_file_info_h file_info = NULL;
4948 ret = plugin_message_get_value_number(t_msg, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
4949 ret = plugin_message_get_value_string(t_msg, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_msg);
4950 if (NULL != ret_msg) {
4951 error = storage_adaptor_create_error_code((int64_t) ret_code, ret_msg);
4953 ret = plugin_message_get_param_number(t_msg, param_idx++, &fd);
4954 ret = plugin_message_get_param_number(t_msg, param_idx++, &state);
4956 plugin_message_array_h file_info_message = NULL;
4957 ret = plugin_message_get_param_array(t_msg, param_idx++, &file_info_message);
4958 if ((0 == ret) && (NULL != file_info_message)) {
4959 file_info = _get_file_info_from_message_array(file_info_message, param_idx++);
4962 storage_adaptor_upload_state_changed_reply_cb((int)fd,
4963 (storage_adaptor_transfer_state_e)state, file_info, error, NULL);
4965 storage_adaptor_destroy_file_info(&file_info);
4966 plugin_message_array_destroy(file_info_message);
4967 storage_adaptor_destroy_error_code(&error);
4968 } else if (0 == strncmp(STORAGE_PLUGIN_CALLBACK_PROGRESS_CB,
4970 strlen(STORAGE_PLUGIN_CALLBACK_PROGRESS_CB))) {
4971 pmnumber fd, progress, total, ret_code;
4972 char *ret_msg = NULL;
4974 storage_adaptor_error_code_h error = NULL;
4975 ret = plugin_message_get_value_number(t_msg, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
4976 ret = plugin_message_get_value_string(t_msg, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_msg);
4977 if (NULL != ret_msg) {
4978 error = storage_adaptor_create_error_code((int64_t) ret_code, ret_msg);
4980 ret = plugin_message_get_param_number(t_msg, param_idx++, &fd);
4981 ret = plugin_message_get_param_number(t_msg, param_idx++, &progress);
4982 ret = plugin_message_get_param_number(t_msg, param_idx++, &total);
4984 storage_adaptor_task_progress_reply_cb((int)fd,
4985 (unsigned long long)progress, (unsigned long long)total, error, NULL);
4986 storage_adaptor_destroy_error_code(&error);
4988 storage_adaptor_error("Invalid callback name : %s", callback_name);
4990 free(callback_name);
4992 storage_adaptor_warning("Received message parsing fail.");
4994 plugin_message_destroy(t_msg);
4998 int __storage_adaptor_parse_message_cmd(storage_adaptor_h adaptor, char *msg)
5000 char *cmd_data = NULL;
5001 if (0 == strncmp(PLUGIN_MESSAGE_LISTENER_CMD_APPEND_FD, msg, strlen(PLUGIN_MESSAGE_LISTENER_CMD_APPEND_FD))) {
5002 cmd_data = msg + strlen(PLUGIN_MESSAGE_LISTENER_CMD_APPEND_FD);
5003 int fd = atoi(cmd_data);
5005 adaptor->rd_list = g_list_append(adaptor->rd_list, (gpointer)fd);
5006 } else if (0 == strncmp(PLUGIN_MESSAGE_LISTENER_CMD_STOP, msg, strlen(PLUGIN_MESSAGE_LISTENER_CMD_STOP))) {
5014 void _storage_adaptor_send_cmd_add_fd(storage_adaptor_h adaptor, int fd)
5016 char cmd_buf[256] = {0, };
5017 snprintf(cmd_buf, 255, "%s%d", PLUGIN_MESSAGE_LISTENER_CMD_APPEND_FD, fd);
5018 int len = strlen(cmd_buf);
5021 g_mutex_lock(&adaptor->rd_mutex);
5022 wr_ret = write(adaptor->rd_cmd[1], &len, sizeof(int));
5023 wr_ret = write(adaptor->rd_cmd[1], cmd_buf, sizeof(char) * len);
5024 g_mutex_unlock(&adaptor->rd_mutex);
5025 storage_adaptor_debug("writed (%d)(%s)", wr_ret, cmd_buf);
5028 void _storage_adaptor_send_cmd_stop_listen(storage_adaptor_h adaptor)
5030 char cmd_buf[256] = {0, };
5031 snprintf(cmd_buf, 255, "%s", PLUGIN_MESSAGE_LISTENER_CMD_STOP);
5032 int len = strlen(cmd_buf);
5035 g_mutex_lock(&adaptor->rd_mutex);
5036 wr_ret = write(adaptor->rd_cmd[1], &len, sizeof(int));
5037 wr_ret = write(adaptor->rd_cmd[1], cmd_buf, sizeof(char) * len);
5038 g_mutex_unlock(&adaptor->rd_mutex);
5039 storage_adaptor_debug("writed (%d)(%s)", wr_ret, cmd_buf);
5042 static int storage_adaptor_send_message_to_plugin_sync(storage_adaptor_plugin_h plugin,
5043 plugin_message_h send_message,
5044 plugin_message_h *receive_message)
5047 int wfd = plugin->wd;
5050 if (pipe(sync_hook) != -1) {
5051 char read_buf[PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE] = {0, };
5053 plugin_message_set_value_number(send_message, PLUGIN_MESSAGE_ELEMENT_REQUEST_ID, (pmnumber) sync_hook[1]);
5054 char *stream = NULL;
5055 io_ret = plugin_message_serialize(send_message, &stream);
5056 int len = strlen(stream);
5058 g_mutex_lock(&plugin->message_mutex);
5059 io_ret = write(wfd, &len, sizeof(len));
5060 io_ret = write(wfd, stream, sizeof(char) * len);
5061 g_mutex_unlock(&plugin->message_mutex);
5066 io_ret = read(sync_hook[0], &len, sizeof(len));
5067 memset(read_buf, 0, PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE);
5068 len %= (PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE - 1);
5070 io_ret = read(sync_hook[0], read_buf, len);
5072 storage_adaptor_debug("io ret : %d", io_ret);
5073 close(sync_hook[0]);
5074 close(sync_hook[1]);
5076 plugin_message_h _rcv;
5077 if (0 < strlen(read_buf)) {
5078 io_ret = plugin_message_deserialize(read_buf, &_rcv);
5080 *receive_message = _rcv;
5090 storage_adaptor_plugin_handle_h __storage_adaptor_create_3rd_party_plugin_handle(const char *plugin_uri)
5092 storage_adaptor_plugin_handle_h handle = (storage_adaptor_plugin_handle_h) calloc(1, sizeof(storage_adaptor_plugin_handle_t));
5094 if (NULL == handle) {
5098 handle->create_context = storage_plugin_send_create_context;
5099 handle->destroy_context = storage_plugin_send_destroy_context;
5100 handle->set_server_info = storage_plugin_send_set_server_info;
5101 handle->make_directory = storage_plugin_send_make_directory;
5102 handle->remove_directory = storage_plugin_send_remove_directory;
5103 handle->list = storage_plugin_send_get_list;
5104 handle->upload_file_sync = storage_plugin_send_upload_file_sync;
5105 handle->download_file_sync = storage_plugin_send_download_file_sync;
5106 handle->delete_file = storage_plugin_send_delete_file;
5107 handle->move_directory = storage_plugin_send_move_directory;
5108 handle->move_file = storage_plugin_send_move_file;
5109 handle->set_transfer_state = storage_plugin_send_set_transfer_state;
5110 handle->get_transfer_state = storage_plugin_send_get_transfer_state;
5111 handle->get_root_folder_path = storage_plugin_send_get_root_folder_path;
5113 handle->start_upload_task = storage_plugin_send_start_upload_task;
5114 handle->start_download_task = storage_plugin_send_start_download_task;
5115 handle->start_download_thumb_task = storage_plugin_send_start_download_thumb_task;
5116 handle->cancel_upload_task = storage_plugin_send_cancel_upload_task;
5117 handle->cancel_download_task = storage_plugin_send_cancel_download_task;
5118 handle->cancel_download_thumb_task = storage_plugin_send_cancel_download_thumb_task;
5120 handle->plugin_uri = strdup(plugin_uri);
5125 storage_adaptor_file_info_h _get_file_info_from_message_array(plugin_message_array_h message_array, int index)
5127 storage_adaptor_file_info_h file_info = NULL;
5129 if (NULL == message_array) {
5135 _media_meta->mime_type = NULL;
5136 _media_meta->title = NULL;
5137 _media_meta->album = NULL;
5138 _media_meta->artist = NULL;
5139 _media_meta->genere = NULL;
5140 _media_meta->recorded_date = NULL;
5141 _media_meta->width = -1;
5142 _media_meta->height = -1;
5143 _media_meta->duration = -1;
5144 _media_meta->copyright = NULL;
5145 _media_meta->track_num = NULL;
5146 _media_meta->description = NULL;
5147 _media_meta->composer = NULL;
5148 _media_meta->year = NULL;
5149 _media_meta->bitrate = -1;
5150 _media_meta->samplerate = -1;
5151 _media_meta->channel = -1;
5152 _media_meta->extra_media_meta = NULL;
5154 _cloud_meta->service_name = NULL;
5155 _cloud_meta->usage_byte = 0ULL;
5156 _cloud_meta->quota_byte = 0ULL;
5157 _cloud_meta->extra_cloud_meta = NULL;
5160 char *plugin_uri = NULL;
5161 char *object_id = NULL;
5162 char *storage_path = NULL;
5163 pmnumber file_size = 0LL;
5164 pmnumber created_time = 0LL;
5165 pmnumber modified_time = 0LL;
5166 pmnumber file_info_index = -1LL;
5167 pmnumber content_type = (pmnumber)STORAGE_ADAPTOR_CONTENT_TYPE_DEFAULT;
5168 char *extra_file_info = NULL;
5171 ret = plugin_message_array_get_element(message_array, index, &plugin_uri, &object_id, &storage_path,
5172 &file_size, &created_time, &modified_time, &file_info_index, &content_type, &extra_file_info);
5175 file_info = storage_adaptor_create_file_info();
5177 if (NULL != file_info) {
5178 file_info->plugin_uri = plugin_uri;
5179 file_info->object_id = object_id;
5180 file_info->storage_path = storage_path;
5181 file_info->file_size = (unsigned long long) file_size;
5182 file_info->created_time = (unsigned long long) created_time;
5183 file_info->modified_time = (unsigned long long) modified_time;
5184 file_info->file_info_index = (long long int) file_info_index;
5185 file_info->content_type = (int) content_type;
5186 file_info->extra_file_info = extra_file_info;
5190 free(extra_file_info);
5197 int _message_array_set_file_info(plugin_message_array_h message_array, int index, storage_adaptor_file_info_h file_info)
5199 int ret = STORAGE_ADAPTOR_ERROR_NONE;
5200 if ((NULL == message_array) || (NULL == file_info)) {
5206 _media_meta->mime_type = NULL;
5207 _media_meta->title = NULL;
5208 _media_meta->album = NULL;
5209 _media_meta->artist = NULL;
5210 _media_meta->genere = NULL;
5211 _media_meta->recorded_date = NULL;
5212 _media_meta->width = -1;
5213 _media_meta->height = -1;
5214 _media_meta->duration = -1;
5215 _media_meta->copyright = NULL;
5216 _media_meta->track_num = NULL;
5217 _media_meta->description = NULL;
5218 _media_meta->composer = NULL;
5219 _media_meta->year = NULL;
5220 _media_meta->bitrate = -1;
5221 _media_meta->samplerate = -1;
5222 _media_meta->channel = -1;
5223 _media_meta->extra_media_meta = NULL;
5225 _cloud_meta->service_name = NULL;
5226 _cloud_meta->usage_byte = 0ULL;
5227 _cloud_meta->quota_byte = 0ULL;
5228 _cloud_meta->extra_cloud_meta = NULL;
5231 char *plugin_uri = SAFE_ADD_STRING(file_info->plugin_uri);
5232 char *object_id = SAFE_ADD_STRING(file_info->object_id);
5233 char *storage_path = SAFE_ADD_STRING(file_info->storage_path);
5234 pmnumber file_size = (pmnumber) file_info->file_size;
5235 pmnumber created_time = (pmnumber) file_info->created_time;
5236 pmnumber modified_time = (pmnumber) file_info->modified_time;
5237 pmnumber file_info_index = (pmnumber) file_info->file_info_index;
5238 pmnumber content_type = (pmnumber) file_info->content_type;
5239 char *extra_file_info = SAFE_ADD_STRING(file_info->extra_file_info);
5241 ret = plugin_message_array_add_element(message_array, plugin_uri, object_id, storage_path,
5242 file_size, created_time, modified_time, file_info_index, content_type, extra_file_info);
5247 storage_error_code_t storage_plugin_send_create_context(storage_adaptor_plugin_context_h *context,
5249 const char *app_secret,
5250 const char *access_token,
5254 storage_adaptor_plugin_h plugin = NULL;
5255 plugin = (*context)->plugin_handle;
5258 plugin_message_h message = NULL;
5259 ret = plugin_message_create(&message);
5262 (*context)->context_id = (int) (intptr_t)(*context);
5264 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5265 (pmnumber) (*context)->context_id);
5266 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5267 STORAGE_PLUGIN_INTERFACE_CREATE_CONTEXT);
5269 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5270 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5272 int param_index = 1;
5273 plugin_message_set_param_string(message, param_index++, app_id);
5274 plugin_message_set_param_string(message, param_index++, app_secret);
5275 plugin_message_set_param_string(message, param_index++, access_token);
5276 plugin_message_set_param_string(message, param_index++, cid);
5277 plugin_message_set_param_string(message, param_index++, uid);
5279 plugin_message_h result_message = NULL;
5280 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5284 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5286 ret = (int) ret_code;
5288 char *ret_msg = NULL;
5289 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5290 storage_adaptor_debug("Create context successed");
5292 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5293 storage_adaptor_debug("Create context failed (%d)(%s)", ret, ret_msg);
5300 plugin_message_destroy(result_message);
5303 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5305 plugin_message_destroy(message);
5310 storage_error_code_t storage_plugin_send_destroy_context(storage_adaptor_plugin_context_h context)
5312 storage_adaptor_plugin_h plugin = NULL;
5313 plugin = context->plugin_handle;
5316 plugin_message_h message = NULL;
5317 ret = plugin_message_create(&message);
5320 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5321 (pmnumber) context->context_id);
5322 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5323 STORAGE_PLUGIN_INTERFACE_DESTROY_CONTEXT);
5325 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5326 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5328 plugin_message_h result_message = NULL;
5329 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5333 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5335 ret = (int) ret_code;
5337 char *ret_msg = NULL;
5338 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5339 storage_adaptor_debug("Destroy context successed");
5341 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5342 storage_adaptor_debug("Destroy context failed (%d)(%s)", ret, ret_msg);
5346 storage_adaptor_debug("Force release memory by adaptor process");
5347 free(context->access_token);
5351 plugin_message_destroy(result_message);
5354 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5356 plugin_message_destroy(message);
5361 storage_error_code_t storage_plugin_send_set_server_info(storage_adaptor_plugin_context_h context,
5362 GHashTable *server_info,
5364 storage_adaptor_error_code_h *error,
5367 return STORAGE_ADAPTOR_ERROR_UNSUPPORTED;
5370 storage_error_code_t storage_plugin_send_make_directory(storage_adaptor_plugin_context_h context,
5371 const char *parent_folder_storage_path,
5372 const char *folder_name,
5374 storage_adaptor_file_info_h *file_info,
5375 storage_adaptor_error_code_h *error,
5378 storage_adaptor_plugin_h plugin = NULL;
5379 plugin = context->plugin_handle;
5382 plugin_message_h message = NULL;
5383 ret = plugin_message_create(&message);
5386 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5387 (pmnumber) context->context_id);
5388 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5389 STORAGE_PLUGIN_INTERFACE_MAKE_DIRECTORY);
5391 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5392 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5394 int param_index = 1;
5395 plugin_message_set_param_string(message, param_index++, parent_folder_storage_path);
5396 plugin_message_set_param_string(message, param_index++, folder_name);
5398 plugin_message_h result_message = NULL;
5399 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5403 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5405 ret = (int) ret_code;
5406 char *ret_msg = NULL;
5407 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5408 storage_adaptor_debug("Make directory successed");
5410 if (NULL != file_info) {
5411 storage_adaptor_debug("Get file info");
5414 plugin_message_array_h file_info_message = NULL;
5415 param_ret = plugin_message_get_param_array(result_message, param_idx++, &file_info_message);
5416 if ((0 == param_ret) && (NULL != file_info_message)) {
5417 *file_info = _get_file_info_from_message_array(file_info_message, param_idx++);
5419 plugin_message_array_destroy(file_info_message);
5422 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5423 storage_adaptor_debug("Make directory failed (%d)(%s)", ret, ret_msg);
5424 if (NULL != error) {
5425 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
5426 *error = error_code;
5431 plugin_message_destroy(result_message);
5434 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5436 plugin_message_destroy(message);
5442 storage_error_code_t storage_plugin_send_remove_directory(storage_adaptor_plugin_context_h context,
5443 const char *parent_folder_storage_path,
5444 const char *folder_name,
5446 storage_adaptor_file_info_h *file_info,
5447 storage_adaptor_error_code_h *error,
5450 storage_adaptor_plugin_h plugin = NULL;
5451 plugin = context->plugin_handle;
5454 plugin_message_h message = NULL;
5455 ret = plugin_message_create(&message);
5458 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5459 (pmnumber) context->context_id);
5460 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5461 STORAGE_PLUGIN_INTERFACE_REMOVE_DIRECTORY);
5463 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5464 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5466 int param_index = 1;
5467 plugin_message_set_param_string(message, param_index++, parent_folder_storage_path);
5468 plugin_message_set_param_string(message, param_index++, folder_name);
5470 plugin_message_h result_message = NULL;
5471 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5475 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5477 ret = (int) ret_code;
5478 char *ret_msg = NULL;
5479 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5480 storage_adaptor_debug("Remove directory successed");
5482 if (NULL != file_info) {
5483 storage_adaptor_debug("Get file info");
5486 plugin_message_array_h file_info_message = NULL;
5487 param_ret = plugin_message_get_param_array(result_message, param_idx++, &file_info_message);
5488 if ((0 == param_ret) && (NULL != file_info_message)) {
5489 *file_info = _get_file_info_from_message_array(file_info_message, param_idx++);
5491 plugin_message_array_destroy(file_info_message);
5494 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5495 storage_adaptor_debug("Remove directory failed (%d)(%s)", ret, ret_msg);
5496 if (NULL != error) {
5497 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
5498 *error = error_code;
5503 plugin_message_destroy(result_message);
5506 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5508 plugin_message_destroy(message);
5513 storage_error_code_t storage_plugin_send_get_list(storage_adaptor_plugin_context_h context,
5514 const char *parent_folder_storage_path,
5515 const char *folder_name,
5517 storage_adaptor_file_info_h **file_info_list,
5518 int *file_info_list_len,
5519 storage_adaptor_error_code_h *error,
5522 storage_adaptor_plugin_h plugin = NULL;
5523 plugin = context->plugin_handle;
5526 plugin_message_h message = NULL;
5527 ret = plugin_message_create(&message);
5530 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5531 (pmnumber) context->context_id);
5532 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5533 STORAGE_PLUGIN_INTERFACE_REMOVE_DIRECTORY);
5535 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5536 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5538 int param_index = 1;
5539 plugin_message_set_param_string(message, param_index++, parent_folder_storage_path);
5540 plugin_message_set_param_string(message, param_index++, folder_name);
5542 plugin_message_h result_message = NULL;
5543 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5547 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5549 ret = (int) ret_code;
5550 char *ret_msg = NULL;
5551 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5552 storage_adaptor_debug("Get list successed");
5556 param_ret = plugin_message_get_param_number(result_message, 2, &len);
5557 if ((0 == ret) && (NULL != file_info_list) && (len > 0LL)) {
5558 storage_adaptor_debug("Get file info");
5559 plugin_message_array_h file_info_message = NULL;
5560 param_ret = plugin_message_get_param_array(result_message, 1, &file_info_message);
5561 if ((0 == param_ret) && (NULL != file_info_message)) {
5562 int i, l = (int) len;
5563 *file_info_list = (storage_adaptor_file_info_h *) calloc(l, sizeof(storage_adaptor_file_info_h));
5564 if (NULL != *file_info_list) {
5565 for (i = 0; i < l; i++) {
5566 (*file_info_list)[i] = _get_file_info_from_message_array(file_info_message, (i+1));
5568 if (NULL != file_info_list_len) {
5569 *file_info_list_len = l;
5572 plugin_message_array_destroy(file_info_message);
5576 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5577 storage_adaptor_debug("Get list failed (%d)(%s)", ret, ret_msg);
5578 if (NULL != error) {
5579 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
5580 *error = error_code;
5585 plugin_message_destroy(result_message);
5588 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5590 plugin_message_destroy(message);
5596 storage_error_code_t storage_plugin_send_upload_file_sync(storage_adaptor_plugin_context_h context,
5597 const char *parent_folder_storage_path,
5598 const char *file_name,
5599 const char *upload_file_local_path,
5602 storage_adaptor_file_info_h *file_info,
5603 storage_adaptor_error_code_h *error,
5606 storage_adaptor_plugin_h plugin = NULL;
5607 plugin = context->plugin_handle;
5610 plugin_message_h message = NULL;
5611 ret = plugin_message_create(&message);
5614 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5615 (pmnumber) context->context_id);
5616 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5617 STORAGE_PLUGIN_INTERFACE_UPLOAD_FILE_SYNC);
5619 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5620 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5622 int param_index = 1;
5623 plugin_message_set_param_string(message, param_index++, parent_folder_storage_path);
5624 plugin_message_set_param_string(message, param_index++, file_name);
5625 plugin_message_set_param_string(message, param_index++, upload_file_local_path);
5626 plugin_message_set_param_number(message, param_index++, (pmnumber) publish);
5628 plugin_message_h result_message = NULL;
5629 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5633 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5635 ret = (int) ret_code;
5636 char *ret_msg = NULL;
5637 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5638 storage_adaptor_debug("Upload sync successed");
5640 if (NULL != file_info) {
5641 storage_adaptor_debug("Get file info");
5644 plugin_message_array_h file_info_message = NULL;
5645 param_ret = plugin_message_get_param_array(result_message, param_idx++, &file_info_message);
5646 if ((0 == param_ret) && (NULL != file_info_message)) {
5647 *file_info = _get_file_info_from_message_array(file_info_message, param_idx++);
5649 plugin_message_array_destroy(file_info_message);
5652 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5653 storage_adaptor_debug("Upload sync failed (%d)(%s)", ret, ret_msg);
5654 if (NULL != error) {
5655 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
5656 *error = error_code;
5661 plugin_message_destroy(result_message);
5664 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5666 plugin_message_destroy(message);
5672 storage_error_code_t storage_plugin_send_download_file_sync(storage_adaptor_plugin_context_h context,
5673 const char *parent_folder_storage_path,
5674 const char *file_name,
5675 const char *download_file_local_path,
5677 storage_adaptor_error_code_h *error,
5680 storage_adaptor_plugin_h plugin = NULL;
5681 plugin = context->plugin_handle;
5684 plugin_message_h message = NULL;
5685 ret = plugin_message_create(&message);
5688 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5689 (pmnumber) context->context_id);
5690 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5691 STORAGE_PLUGIN_INTERFACE_DOWNLOAD_FILE_SYNC);
5693 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5694 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5696 int param_index = 1;
5697 plugin_message_set_param_string(message, param_index++, parent_folder_storage_path);
5698 plugin_message_set_param_string(message, param_index++, file_name);
5699 plugin_message_set_param_string(message, param_index++, download_file_local_path);
5701 plugin_message_h result_message = NULL;
5702 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5706 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5708 ret = (int) ret_code;
5709 char *ret_msg = NULL;
5710 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5711 storage_adaptor_debug("Download sync successed");
5713 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5714 storage_adaptor_debug("Download sync failed (%d)(%s)", ret, ret_msg);
5715 if (NULL != error) {
5716 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
5717 *error = error_code;
5722 plugin_message_destroy(result_message);
5725 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5727 plugin_message_destroy(message);
5732 storage_error_code_t storage_plugin_send_delete_file(storage_adaptor_plugin_context_h context,
5733 const char *parent_folder_storage_path,
5734 const char *file_name,
5736 storage_adaptor_file_info_h *file_info,
5737 storage_adaptor_error_code_h *error,
5740 storage_adaptor_plugin_h plugin = NULL;
5741 plugin = context->plugin_handle;
5744 plugin_message_h message = NULL;
5745 ret = plugin_message_create(&message);
5748 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5749 (pmnumber) context->context_id);
5750 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5751 STORAGE_PLUGIN_INTERFACE_DELETE_FILE);
5753 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5754 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5756 int param_index = 1;
5757 plugin_message_set_param_string(message, param_index++, parent_folder_storage_path);
5758 plugin_message_set_param_string(message, param_index++, file_name);
5760 plugin_message_h result_message = NULL;
5761 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5765 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5767 ret = (int) ret_code;
5768 char *ret_msg = NULL;
5769 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5770 storage_adaptor_debug("Delete file successed");
5772 if (NULL != file_info) {
5773 storage_adaptor_debug("Get file info");
5776 plugin_message_array_h file_info_message = NULL;
5777 param_ret = plugin_message_get_param_array(result_message, param_idx++, &file_info_message);
5778 if ((0 == param_ret) && (NULL != file_info_message)) {
5779 *file_info = _get_file_info_from_message_array(file_info_message, param_idx++);
5781 plugin_message_array_destroy(file_info_message);
5784 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5785 storage_adaptor_debug("Delete file failed (%d)(%s)", ret, ret_msg);
5786 if (NULL != error) {
5787 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
5788 *error = error_code;
5793 plugin_message_destroy(result_message);
5796 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5798 plugin_message_destroy(message);
5803 storage_error_code_t storage_plugin_send_move_directory(storage_adaptor_plugin_context_h context,
5804 const char *parent_folder_storage_path,
5805 const char *folder_name,
5806 const char *dest_parent_folder_storage_path,
5807 const char *new_folder_name,
5809 storage_adaptor_file_info_h *file_info,
5810 storage_adaptor_error_code_h *error,
5813 storage_adaptor_plugin_h plugin = NULL;
5814 plugin = context->plugin_handle;
5817 plugin_message_h message = NULL;
5818 ret = plugin_message_create(&message);
5821 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5822 (pmnumber) context->context_id);
5823 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5824 STORAGE_PLUGIN_INTERFACE_MOVE_DIRECTORY);
5826 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5827 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5829 int param_index = 1;
5830 plugin_message_set_param_string(message, param_index++, parent_folder_storage_path);
5831 plugin_message_set_param_string(message, param_index++, folder_name);
5832 plugin_message_set_param_string(message, param_index++, dest_parent_folder_storage_path);
5833 plugin_message_set_param_string(message, param_index++, new_folder_name);
5835 plugin_message_h result_message = NULL;
5836 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5840 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5842 ret = (int) ret_code;
5843 char *ret_msg = NULL;
5844 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5845 storage_adaptor_debug("Move directory successed");
5847 if (NULL != file_info) {
5848 storage_adaptor_debug("Get file info");
5851 plugin_message_array_h file_info_message = NULL;
5852 param_ret = plugin_message_get_param_array(result_message, param_idx++, &file_info_message);
5853 if ((0 == param_ret) && (NULL != file_info_message)) {
5854 *file_info = _get_file_info_from_message_array(file_info_message, param_idx++);
5856 plugin_message_array_destroy(file_info_message);
5859 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5860 storage_adaptor_debug("Move directory failed (%d)(%s)", ret, ret_msg);
5861 if (NULL != error) {
5862 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
5863 *error = error_code;
5868 plugin_message_destroy(result_message);
5871 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5873 plugin_message_destroy(message);
5878 storage_error_code_t storage_plugin_send_move_file(storage_adaptor_plugin_context_h context,
5879 const char *parent_folder_storage_path,
5880 const char *file_name,
5881 const char *dest_parent_folder_storage_path,
5882 const char *new_file_name,
5884 storage_adaptor_file_info_h *file_info,
5885 storage_adaptor_error_code_h *error,
5888 storage_adaptor_plugin_h plugin = NULL;
5889 plugin = context->plugin_handle;
5892 plugin_message_h message = NULL;
5893 ret = plugin_message_create(&message);
5896 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5897 (pmnumber) context->context_id);
5898 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5899 STORAGE_PLUGIN_INTERFACE_MOVE_FILE);
5901 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5902 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5904 int param_index = 1;
5905 plugin_message_set_param_string(message, param_index++, parent_folder_storage_path);
5906 plugin_message_set_param_string(message, param_index++, file_name);
5907 plugin_message_set_param_string(message, param_index++, dest_parent_folder_storage_path);
5908 plugin_message_set_param_string(message, param_index++, new_file_name);
5910 plugin_message_h result_message = NULL;
5911 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5915 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5917 ret = (int) ret_code;
5918 char *ret_msg = NULL;
5919 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5920 storage_adaptor_debug("Move file successed");
5922 if (NULL != file_info) {
5923 storage_adaptor_debug("Get file info");
5926 plugin_message_array_h file_info_message = NULL;
5927 param_ret = plugin_message_get_param_array(result_message, param_idx++, &file_info_message);
5928 if ((0 == param_ret) && (NULL != file_info_message)) {
5929 *file_info = _get_file_info_from_message_array(file_info_message, param_idx++);
5931 plugin_message_array_destroy(file_info_message);
5934 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5935 storage_adaptor_debug("Move file failed (%d)(%s)", ret, ret_msg);
5936 if (NULL != error) {
5937 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
5938 *error = error_code;
5943 plugin_message_destroy(result_message);
5946 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
5948 plugin_message_destroy(message);
5953 storage_error_code_t storage_plugin_send_set_transfer_state(storage_adaptor_plugin_context_h context,
5954 void *transfer_request_id,
5955 storage_adaptor_transfer_state_e state,
5957 storage_adaptor_error_code_h *error,
5960 storage_adaptor_plugin_h plugin = NULL;
5961 plugin = context->plugin_handle;
5964 plugin_message_h message = NULL;
5965 ret = plugin_message_create(&message);
5968 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
5969 (pmnumber) context->context_id);
5970 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
5971 STORAGE_PLUGIN_INTERFACE_SET_TRANSFER_STATE);
5972 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
5973 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
5975 int param_index = 1;
5976 plugin_message_set_param_number(message, param_index++, (pmnumber)(intptr_t)transfer_request_id);
5977 plugin_message_set_param_number(message, param_index++, (pmnumber)state);
5979 plugin_message_h result_message = NULL;
5980 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
5984 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
5986 ret = (int) ret_code;
5987 char *ret_msg = NULL;
5988 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
5989 storage_adaptor_debug("Set transfer state successed");
5991 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
5992 storage_adaptor_debug("Set transfer state failed (%d)(%s)", ret, ret_msg);
5993 if (NULL != error) {
5994 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
5995 *error = error_code;
6000 plugin_message_destroy(result_message);
6003 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6005 plugin_message_destroy(message);
6010 storage_error_code_t storage_plugin_send_get_transfer_state(storage_adaptor_plugin_context_h context,
6011 void *transfer_request_id,
6013 storage_adaptor_transfer_state_e *state,
6014 storage_adaptor_error_code_h *error,
6017 storage_adaptor_plugin_h plugin = NULL;
6018 plugin = context->plugin_handle;
6021 plugin_message_h message = NULL;
6022 ret = plugin_message_create(&message);
6025 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
6026 (pmnumber) context->context_id);
6027 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
6028 STORAGE_PLUGIN_INTERFACE_GET_TRANSFER_STATE);
6029 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
6030 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
6032 int param_index = 1;
6033 plugin_message_set_param_number(message, param_index++, (pmnumber)(intptr_t)transfer_request_id);
6035 plugin_message_h result_message = NULL;
6036 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
6040 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
6042 ret = (int) ret_code;
6043 char *ret_msg = NULL;
6044 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6045 storage_adaptor_debug("Get transfer state successed");
6047 plugin_message_get_param_number(message, 1, &st);
6048 if (NULL != state) {
6049 *state = (storage_adaptor_transfer_state_e)st;
6052 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
6053 storage_adaptor_debug("Get transfer state failed (%d)(%s)", ret, ret_msg);
6054 if (NULL != error) {
6055 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
6056 *error = error_code;
6061 plugin_message_destroy(result_message);
6064 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6066 plugin_message_destroy(message);
6071 storage_error_code_t storage_plugin_send_get_root_folder_path(storage_adaptor_plugin_context_h context,
6073 char **root_folder_path,
6074 storage_adaptor_error_code_h *error,
6077 storage_adaptor_plugin_h plugin = NULL;
6078 plugin = context->plugin_handle;
6081 plugin_message_h message = NULL;
6082 ret = plugin_message_create(&message);
6085 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
6086 (pmnumber) context->context_id);
6087 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
6088 STORAGE_PLUGIN_INTERFACE_GET_ROOT_FOLDER_PATH);
6089 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
6090 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
6092 /* int param_index = 1; */
6094 plugin_message_h result_message = NULL;
6095 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
6099 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
6101 ret = (int) ret_code;
6102 char *ret_msg = NULL;
6103 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6104 storage_adaptor_debug("Get root folder path successed");
6106 plugin_message_get_param_string(message, 1, &path);
6107 if (NULL != root_folder_path) {
6108 *root_folder_path = path;
6111 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
6112 storage_adaptor_debug("Get root folder path failed (%d)(%s)", ret, ret_msg);
6113 if (NULL != error) {
6114 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
6115 *error = error_code;
6120 plugin_message_destroy(result_message);
6123 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6125 plugin_message_destroy(message);
6130 /* ///////////// for 2.4 public API */
6131 storage_error_code_t storage_plugin_send_start_upload_task(storage_adaptor_plugin_context_h context,
6133 const char *upload_dir,
6134 const char *file_path,
6136 storage_adaptor_error_code_h *error,
6139 storage_adaptor_plugin_h plugin = NULL;
6140 plugin = context->plugin_handle;
6143 plugin_message_h message = NULL;
6144 ret = plugin_message_create(&message);
6147 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
6148 (pmnumber) context->context_id);
6149 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
6150 STORAGE_PLUGIN_INTERFACE_START_UPLOAD_TASK);
6152 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
6153 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
6155 int param_index = 1;
6156 plugin_message_set_param_number(message, param_index++, (pmnumber)fd);
6157 plugin_message_set_param_string(message, param_index++, upload_dir);
6158 plugin_message_set_param_string(message, param_index++, file_path);
6159 plugin_message_set_param_bool(message, param_index++, need_progress);
6162 plugin_message_set_opt_param_number(message, param_index++, (pmnumber)(intptr_t)user_data);
6164 plugin_message_h result_message = NULL;
6165 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
6167 if ((0 == ret) && (NULL != result_message)) {
6169 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
6171 ret = (int) ret_code;
6172 char *ret_msg = NULL;
6173 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6174 storage_adaptor_debug("Upload file async successed");
6176 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
6177 storage_adaptor_debug("Upload file async failed (%d)(%s)", ret, ret_msg);
6178 if (NULL != error) {
6179 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
6180 *error = error_code;
6185 plugin_message_destroy(result_message);
6188 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6190 plugin_message_destroy(message);
6195 storage_error_code_t storage_plugin_send_start_download_task(storage_adaptor_plugin_context_h context,
6196 const char *storage_dir,
6197 const char *file_path,
6200 storage_adaptor_error_code_h *error,
6203 storage_adaptor_plugin_h plugin = NULL;
6204 plugin = context->plugin_handle;
6207 plugin_message_h message = NULL;
6208 ret = plugin_message_create(&message);
6211 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
6212 (pmnumber) context->context_id);
6213 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
6214 STORAGE_PLUGIN_INTERFACE_START_DOWNLOAD_TASK);
6216 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
6217 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
6219 int param_index = 1;
6220 plugin_message_set_param_string(message, param_index++, storage_dir);
6221 plugin_message_set_param_string(message, param_index++, file_path);
6222 plugin_message_set_param_number(message, param_index++, (pmnumber)fd);
6223 plugin_message_set_param_bool(message, param_index++, need_progress);
6226 plugin_message_set_opt_param_number(message, param_index++, (pmnumber)(intptr_t)user_data);
6228 plugin_message_h result_message = NULL;
6229 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
6231 if ((0 == ret) && (NULL != result_message)) {
6233 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
6235 ret = (int) ret_code;
6236 char *ret_msg = NULL;
6237 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6238 storage_adaptor_debug("Download file async successed");
6240 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
6241 storage_adaptor_debug("Download file async failed (%d)(%s)", ret, ret_msg);
6242 if (NULL != error) {
6243 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
6244 *error = error_code;
6249 plugin_message_destroy(result_message);
6252 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6254 plugin_message_destroy(message);
6259 storage_error_code_t storage_plugin_send_start_download_thumb_task(storage_adaptor_plugin_context_h context,
6260 const char *storage_dir,
6261 const char *file_path,
6265 storage_adaptor_error_code_h *error,
6268 storage_adaptor_plugin_h plugin = NULL;
6269 plugin = context->plugin_handle;
6272 plugin_message_h message = NULL;
6273 ret = plugin_message_create(&message);
6276 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
6277 (pmnumber) context->context_id);
6278 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
6279 STORAGE_PLUGIN_INTERFACE_START_DOWNLOAD_THUMB_TASK);
6281 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
6282 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
6284 int param_index = 1;
6285 plugin_message_set_param_string(message, param_index++, storage_dir);
6286 plugin_message_set_param_string(message, param_index++, file_path);
6287 plugin_message_set_param_number(message, param_index++, (pmnumber)fd);
6288 plugin_message_set_param_number(message, param_index++, (pmnumber)thumbnail_size);
6289 plugin_message_set_param_bool(message, param_index++, need_progress);
6292 plugin_message_set_opt_param_number(message, param_index++, (pmnumber)(intptr_t)user_data);
6294 plugin_message_h result_message = NULL;
6295 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
6297 if ((0 == ret) && (NULL != result_message)) {
6299 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
6301 ret = (int) ret_code;
6302 char *ret_msg = NULL;
6303 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6304 storage_adaptor_debug("Download thumbnail async successed");
6306 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
6307 storage_adaptor_debug("Download thumbnail async failed (%d)(%s)", ret, ret_msg);
6308 if (NULL != error) {
6309 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
6310 *error = error_code;
6315 plugin_message_destroy(result_message);
6318 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6320 plugin_message_destroy(message);
6325 storage_error_code_t storage_plugin_send_cancel_upload_task(storage_adaptor_plugin_context_h context,
6327 storage_adaptor_error_code_h *error)
6329 storage_adaptor_plugin_h plugin = NULL;
6330 plugin = context->plugin_handle;
6333 plugin_message_h message = NULL;
6334 ret = plugin_message_create(&message);
6337 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
6338 (pmnumber) context->context_id);
6339 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
6340 STORAGE_PLUGIN_INTERFACE_CANCEL_UPLOAD_TASK);
6342 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
6343 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
6345 int param_index = 1;
6346 plugin_message_set_param_number(message, param_index++, (pmnumber)fd);
6348 plugin_message_h result_message = NULL;
6349 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
6351 if ((0 == ret) && (NULL != result_message)) {
6353 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
6355 ret = (int) ret_code;
6356 char *ret_msg = NULL;
6357 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6358 storage_adaptor_debug("Upload file async successed");
6360 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
6361 storage_adaptor_debug("Upload file async failed (%d)(%s)", ret, ret_msg);
6362 if (NULL != error) {
6363 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
6364 *error = error_code;
6369 plugin_message_destroy(result_message);
6372 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6374 plugin_message_destroy(message);
6379 storage_error_code_t storage_plugin_send_cancel_download_task(storage_adaptor_plugin_context_h context,
6381 storage_adaptor_error_code_h *error)
6383 storage_adaptor_plugin_h plugin = NULL;
6384 plugin = context->plugin_handle;
6387 plugin_message_h message = NULL;
6388 ret = plugin_message_create(&message);
6391 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
6392 (pmnumber) context->context_id);
6393 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
6394 STORAGE_PLUGIN_INTERFACE_CANCEL_DOWNLOAD_TASK);
6396 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
6397 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
6399 int param_index = 1;
6400 plugin_message_set_param_number(message, param_index++, (pmnumber)fd);
6402 plugin_message_h result_message = NULL;
6403 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
6405 if ((0 == ret) && (NULL != result_message)) {
6407 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
6409 ret = (int) ret_code;
6410 char *ret_msg = NULL;
6411 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6412 storage_adaptor_debug("Cancel upload file successed");
6414 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
6415 storage_adaptor_debug("Cancel upload file failed (%d)(%s)", ret, ret_msg);
6416 if (NULL != error) {
6417 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
6418 *error = error_code;
6423 plugin_message_destroy(result_message);
6426 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6428 plugin_message_destroy(message);
6433 storage_error_code_t storage_plugin_send_cancel_download_thumb_task(storage_adaptor_plugin_context_h context,
6435 storage_adaptor_error_code_h *error)
6437 storage_adaptor_plugin_h plugin = NULL;
6438 plugin = context->plugin_handle;
6441 plugin_message_h message = NULL;
6442 ret = plugin_message_create(&message);
6445 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID,
6446 (pmnumber) context->context_id);
6447 plugin_message_set_value_string(message, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME,
6448 STORAGE_PLUGIN_INTERFACE_CANCEL_DOWNLOAD_THUMB_TASK);
6450 plugin_message_set_value_number(message, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE,
6451 (pmnumber) PLUGIN_MESSAGE_TYPE_FUNCTION);
6453 int param_index = 1;
6454 plugin_message_set_param_number(message, param_index++, (pmnumber)fd);
6456 plugin_message_h result_message = NULL;
6457 ret = storage_adaptor_send_message_to_plugin_sync(plugin, message, &result_message);
6459 if ((0 == ret) && (NULL != result_message)) {
6461 plugin_message_get_value_number(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, &ret_code);
6463 ret = (int) ret_code;
6464 char *ret_msg = NULL;
6465 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6466 storage_adaptor_debug("Cancel download thumbnail successed");
6468 plugin_message_get_value_string(result_message, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, &ret_msg);
6469 storage_adaptor_debug("Cancel download thumbnail failed (%d)(%s)", ret, ret_msg);
6470 if (NULL != error) {
6471 storage_adaptor_error_code_h error_code = storage_adaptor_create_error_code(ret, ret_msg);
6472 *error = error_code;
6477 plugin_message_destroy(result_message);
6480 ret = STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL;
6482 plugin_message_destroy(message);
6487 void storage_plugin_receive_download_state_changed_cb(int file_descriptor,
6488 storage_adaptor_transfer_state_e state,
6489 storage_adaptor_error_code_h error,
6493 plugin_message_h m_callback = NULL;
6495 if ((0 != plugin_message_create(&m_callback)) || (NULL == m_callback)) {
6496 LOGE("[%s/%d] Callback message create failed", __FUNCTION__, __LINE__);
6500 const char *func_name = STORAGE_PLUGIN_CALLBACK_DOWNLOAD_FILE_ASYNC_CB;
6502 plugin_message_set_value_string(m_callback, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME, func_name);
6503 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE, PLUGIN_MESSAGE_TYPE_CALLBACK);
6505 if (NULL == error) {
6506 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)STORAGE_ADAPTOR_ERROR_NONE);
6508 LOGD("[%s/%d] Callback's error value (%lld, %s)", __FUNCTION__, __LINE__, (long long int)error->code, error->msg);
6509 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, (pmnumber)error->code);
6510 plugin_message_set_value_string(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, error->msg);
6514 plugin_message_set_param_number(m_callback, param_idx++, (pmnumber)file_descriptor);
6515 plugin_message_set_param_number(m_callback, param_idx++, (pmnumber)state);
6517 char *result = NULL;
6520 ret = plugin_message_serialize(m_callback, &result);
6522 if ((0 == ret) && (NULL != result)) {
6523 LOGD("[%s/%d] Send callback data message to adaptor", __FUNCTION__, __LINE__);
6524 int res_len = strlen(result);
6525 rcv_len = write(g_child_plugin->wd, &res_len, sizeof(int));
6526 rcv_len = write(g_child_plugin->wd, result, sizeof(char) * res_len);
6528 LOGE("[%s/%d] pipe socket writing error", __FUNCTION__, __LINE__);
6531 LOGE("[%s/%d] Callback data message serialization failed", __FUNCTION__, __LINE__);
6534 plugin_message_destroy(m_callback);
6537 void storage_plugin_receive_upload_state_changed_cb(int file_descriptor,
6538 storage_adaptor_transfer_state_e state,
6539 storage_adaptor_file_info_h file_info,
6540 storage_adaptor_error_code_h error,
6544 plugin_message_h m_callback = NULL;
6546 if ((0 != plugin_message_create(&m_callback)) || (NULL == m_callback)) {
6547 LOGE("[%s/%d] Callback message create failed", __FUNCTION__, __LINE__);
6551 const char *func_name = STORAGE_PLUGIN_CALLBACK_UPLOAD_FILE_ASYNC_CB;
6553 plugin_message_set_value_string(m_callback, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME, func_name);
6554 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE, PLUGIN_MESSAGE_TYPE_CALLBACK);
6556 if (NULL == error) {
6557 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)STORAGE_ADAPTOR_ERROR_NONE);
6559 LOGD("[%s/%d] Callback's error value (%lld, %s)", __FUNCTION__, __LINE__, (long long int)error->code, error->msg);
6560 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, (pmnumber)error->code);
6561 plugin_message_set_value_string(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, error->msg);
6565 plugin_message_set_param_number(m_callback, param_idx++, (pmnumber)file_descriptor);
6566 plugin_message_set_param_number(m_callback, param_idx++, (pmnumber)state);
6568 if (NULL != file_info) {
6569 LOGD("Insert file info to pipe message");
6571 plugin_message_array_h file_info_message = NULL;
6572 char message_array_type[20] = {0, };
6573 snprintf(message_array_type, 19, "%c%c%c%c%c%c%c%c%c", PLUGIN_DATA_TYPE_STRING,
6574 PLUGIN_DATA_TYPE_STRING,
6575 PLUGIN_DATA_TYPE_STRING,
6576 PLUGIN_DATA_TYPE_NUM,
6577 PLUGIN_DATA_TYPE_NUM,
6578 PLUGIN_DATA_TYPE_NUM,
6579 PLUGIN_DATA_TYPE_NUM,
6580 PLUGIN_DATA_TYPE_NUM,
6581 PLUGIN_DATA_TYPE_STRING);
6582 param_ret = plugin_message_array_create(message_array_type, &file_info_message);
6583 if (0 == param_ret) {
6584 _message_array_set_file_info(file_info_message, 1, file_info);
6585 param_ret = plugin_message_set_param_array(m_callback, param_idx++, file_info_message);
6586 plugin_message_array_destroy(file_info_message);
6590 char *result = NULL;
6592 ret = plugin_message_serialize(m_callback, &result);
6594 if ((0 == ret) && (NULL != result)) {
6595 LOGD("[%s/%d] Send callback data message to adaptor", __FUNCTION__, __LINE__);
6596 int res_len = strlen(result);
6597 int rcv_len = write(g_child_plugin->wd, &res_len, sizeof(int));
6598 rcv_len = write(g_child_plugin->wd, result, sizeof(char) * res_len);
6600 LOGE("[%s/%d] pipe socket writing error", __FUNCTION__, __LINE__);
6603 LOGE("[%s/%d] Callback data message serialization failed", __FUNCTION__, __LINE__);
6606 plugin_message_destroy(m_callback);
6610 void storage_plugin_receive_file_progress_cb(int file_descriptor,
6611 unsigned long long progress_size_byte,
6612 unsigned long long total_size_byte,
6613 storage_adaptor_error_code_h error,
6617 plugin_message_h m_callback = NULL;
6619 if ((0 != plugin_message_create(&m_callback)) || (NULL == m_callback)) {
6620 LOGE("[%s/%d] Callback message create failed", __FUNCTION__, __LINE__);
6624 const char *func_name = STORAGE_PLUGIN_CALLBACK_PROGRESS_CB;
6626 plugin_message_set_value_string(m_callback, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME, func_name);
6627 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE, PLUGIN_MESSAGE_TYPE_CALLBACK);
6629 if (NULL == error) {
6630 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)STORAGE_ADAPTOR_ERROR_NONE);
6632 LOGD("[%s/%d] Callback's error value (%lld, %s)", __FUNCTION__, __LINE__, (long long int)error->code, error->msg);
6633 plugin_message_set_value_number(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, (pmnumber)error->code);
6634 plugin_message_set_value_string(m_callback, PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE, error->msg);
6638 plugin_message_set_param_number(m_callback, param_idx++, (pmnumber)file_descriptor);
6639 plugin_message_set_param_number(m_callback, param_idx++, (pmnumber)progress_size_byte);
6640 plugin_message_set_param_number(m_callback, param_idx++, (pmnumber)total_size_byte);
6642 char *result = NULL;
6644 ret = plugin_message_serialize(m_callback, &result);
6646 if ((0 == ret) && (NULL != result)) {
6647 LOGD("[%s/%d] Send callback data message to adaptor", __FUNCTION__, __LINE__);
6648 int res_len = strlen(result);
6649 int rcv_len = write(g_child_plugin->wd, &res_len, sizeof(int));
6650 rcv_len = write(g_child_plugin->wd, result, sizeof(char) * res_len);
6652 LOGE("[%s/%d] pipe socket writing error", __FUNCTION__, __LINE__);
6655 LOGE("[%s/%d] Callback data message serialization failed", __FUNCTION__, __LINE__);
6658 plugin_message_destroy(m_callback);
6663 /* For forked plugin */
6664 void *_storage_plugin_request_collector(void *data)
6666 storage_adaptor_plugin_h plugin = (storage_adaptor_plugin_h) data;
6668 int rcv_len, buf_size;
6669 char msg_buf[PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE] = {0, };
6672 /* pre-read buf size */
6673 rcv_len = read(plugin->rd, &buf_size, sizeof(int));
6676 LOGD("shutdown by adaptor disconnected");
6680 /* allocates and read buf data */
6681 memset(msg_buf, 0, PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE);
6682 buf_size %= (PLUGIN_MESSAGE_PROTOCOL_MAX_BUF_SIZE - 1);
6683 rcv_len = read(plugin->rd, msg_buf, buf_size);
6684 LOGD("read message [%s][len: %d]", msg_buf, rcv_len);
6687 LOGD("shutdown by adaptor disconnected");
6691 char *result = NULL;
6692 __storage_plugin_progress_command(plugin, msg_buf, &result);
6694 if (NULL != result) {
6695 int res_len = strlen(result);
6696 rcv_len = write(plugin->wd, &res_len, sizeof(int));
6697 rcv_len = write(plugin->wd, result, sizeof(char) * res_len);
6699 /* transfer data to adaptor */
6704 storage_adaptor_plugin_context_h __storage_plugin_get_context_by_context_id(storage_adaptor_plugin_h plugin, int context_id)
6706 if (NULL == plugin) {
6710 /* For forked plugin */
6711 storage_adaptor_plugin_context_h ctx = NULL;
6713 len = g_list_length(plugin->contexts);
6715 for (i = 0; i < len; i++) {
6716 ctx = (storage_adaptor_plugin_context_h) g_list_nth_data(plugin->contexts, i);
6718 if (context_id == ctx->context_id) {
6725 void __storage_plugin_progress_command(storage_adaptor_plugin_h plugin, char *order, char **result)
6728 plugin_message_h m_order = NULL;
6729 plugin_message_h m_result = NULL;
6731 if ((NULL == order) || (plugin_message_deserialize(order, &m_order))) {
6732 LOGE("[%s/%d] Message parse error", __FUNCTION__, __LINE__);
6734 } else if (plugin_message_create(&m_result)) {
6735 plugin_message_destroy(m_order);
6738 LOGE("[%s/%d] Message parse error", __FUNCTION__, __LINE__);
6742 char *func_name = NULL;
6745 pmnumber ctx, req, type;
6747 plugin_message_get_value_number(m_order, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID, &ctx);
6748 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_CONTEXT_ID, ctx);
6749 plugin_message_get_value_number(m_order, PLUGIN_MESSAGE_ELEMENT_REQUEST_ID, &req);
6750 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_REQUEST_ID, req);
6751 plugin_message_get_value_string(m_order, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME, &func_name);
6752 plugin_message_set_value_string(m_result, PLUGIN_MESSAGE_ELEMENT_FUNCTION_NAME, func_name);
6753 plugin_message_get_value_number(m_order, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE, &type);
6754 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_MESSAGE_TYPE, type);
6755 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)STORAGE_ADAPTOR_ERROR_NONE);
6756 context_id = (int) ctx;
6757 storage_adaptor_plugin_context_h context = __storage_plugin_get_context_by_context_id(plugin, context_id);
6759 storage_adaptor_error_code_h error_code = NULL;
6760 storage_adaptor_file_info_h file_info = NULL;
6762 if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_CREATE_CONTEXT,
6763 func_name, strlen(STORAGE_PLUGIN_INTERFACE_CREATE_CONTEXT))) {
6764 LOGD(">>>>>> %s func start", func_name);
6765 char *app_id = NULL;
6766 char *app_secret = NULL;
6767 char *access_token = NULL;
6770 char *service_name = NULL;
6773 plugin_message_get_param_string(m_order, param_idx++, &app_id);
6774 plugin_message_get_param_string(m_order, param_idx++, &app_secret);
6775 plugin_message_get_param_string(m_order, param_idx++, &access_token);
6776 plugin_message_get_param_string(m_order, param_idx++, &cid);
6777 plugin_message_get_param_string(m_order, param_idx++, &uid);
6779 LOGD("Call library function");
6780 context = storage_adaptor_create_plugin_context(plugin,
6781 app_id, app_secret, access_token, cid, uid, "");
6783 if (NULL == context) {
6784 LOGE("[%s<%s>/%d] Could not create context", __FUNCTION__, func_name, __LINE__);
6785 /* error_code = storage_adaptor_create_error_code((int64_t)STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL, */
6786 /* "Could not create context"); */
6787 plugin_message_set_value_number(m_result,
6788 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
6789 (pmnumber)STORAGE_ADAPTOR_ERROR_PLUGIN_INTERNAL);
6790 plugin_message_set_value_string(m_result,
6791 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
6792 "Could not create context");
6794 LOGD("[%s<%s>/%d] Created context successfuly", __FUNCTION__, func_name, __LINE__);
6795 context->context_id = context_id;
6797 plugin_message_set_value_number(m_result,
6798 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
6799 (pmnumber)STORAGE_ADAPTOR_ERROR_NONE);
6808 LOGD("<<<<<< %s func end", func_name);
6809 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_DESTROY_CONTEXT,
6810 func_name, strlen(STORAGE_PLUGIN_INTERFACE_DESTROY_CONTEXT))) {
6811 LOGD(">>>>>> %s func start", func_name);
6812 if (NULL == context) {
6813 LOGE("[%s<%s>/%d] Could not found context", __FUNCTION__, func_name, __LINE__);
6815 LOGD("[%s<%s>/%d] function success", __FUNCTION__, func_name, __LINE__);
6816 storage_adaptor_destroy_plugin_context(plugin, context);
6818 plugin_message_set_value_number(m_result,
6819 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
6820 (pmnumber)STORAGE_ADAPTOR_ERROR_NONE);
6822 LOGD("<<<<<< %s func end", func_name);
6823 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_MAKE_DIRECTORY,
6824 func_name, strlen(STORAGE_PLUGIN_INTERFACE_MAKE_DIRECTORY))) {
6825 LOGD(">>>>>> %s func start", func_name);
6826 char *parent_path = NULL;
6827 char *folder_path = NULL;
6830 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
6831 plugin_message_get_param_string(m_order, param_idx++, &folder_path);
6833 LOGD("Call library function");
6834 ret = plugin->handle->make_directory(context, parent_path, folder_path,
6835 NULL, &file_info, &error_code, NULL);
6837 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6838 LOGD("API success");
6841 if (NULL != file_info) {
6842 LOGD("Insert file info to pipe message");
6844 plugin_message_array_h file_info_message = NULL;
6845 char message_array_type[20] = {0, };
6846 snprintf(message_array_type, 19, "%c%c%c%c%c%c%c%c%c", PLUGIN_DATA_TYPE_STRING,
6847 PLUGIN_DATA_TYPE_STRING,
6848 PLUGIN_DATA_TYPE_STRING,
6849 PLUGIN_DATA_TYPE_NUM,
6850 PLUGIN_DATA_TYPE_NUM,
6851 PLUGIN_DATA_TYPE_NUM,
6852 PLUGIN_DATA_TYPE_NUM,
6853 PLUGIN_DATA_TYPE_NUM,
6854 PLUGIN_DATA_TYPE_STRING);
6855 param_ret = plugin_message_array_create(message_array_type, &file_info_message);
6856 if (0 == param_ret) {
6857 _message_array_set_file_info(file_info_message, 1, file_info);
6858 param_ret = plugin_message_set_param_array(m_result, param_idx++, file_info_message);
6859 plugin_message_array_destroy(file_info_message);
6862 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
6863 } else if (NULL != error_code) {
6864 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
6865 plugin_message_set_value_number(m_result,
6866 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
6867 (pmnumber)error_code->code);
6868 plugin_message_set_value_string(m_result,
6869 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
6870 error_code->msg ? error_code->msg : "");
6871 free(error_code->msg);
6874 LOGD("API failed ret_code[%d]", ret);
6875 plugin_message_set_value_number(m_result,
6876 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
6881 LOGD("<<<<<< %s func end", func_name);
6882 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_REMOVE_DIRECTORY,
6883 func_name, strlen(STORAGE_PLUGIN_INTERFACE_REMOVE_DIRECTORY))) {
6884 LOGD(">>>>>> %s func start", func_name);
6885 char *parent_path = NULL;
6886 char *folder_path = NULL;
6889 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
6890 plugin_message_get_param_string(m_order, param_idx++, &folder_path);
6892 LOGD("Call library function");
6893 ret = plugin->handle->remove_directory(context, parent_path, folder_path,
6894 NULL, &file_info, &error_code, NULL);
6896 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6897 LOGD("API success");
6900 if (NULL != file_info) {
6901 LOGD("Insert file info to pipe message");
6903 plugin_message_array_h file_info_message = NULL;
6904 char message_array_type[20] = {0, };
6905 snprintf(message_array_type, 19, "%c%c%c%c%c%c%c%c%c", PLUGIN_DATA_TYPE_STRING,
6906 PLUGIN_DATA_TYPE_STRING,
6907 PLUGIN_DATA_TYPE_STRING,
6908 PLUGIN_DATA_TYPE_NUM,
6909 PLUGIN_DATA_TYPE_NUM,
6910 PLUGIN_DATA_TYPE_NUM,
6911 PLUGIN_DATA_TYPE_NUM,
6912 PLUGIN_DATA_TYPE_NUM,
6913 PLUGIN_DATA_TYPE_STRING);
6914 param_ret = plugin_message_array_create(message_array_type, &file_info_message);
6915 if (0 == param_ret) {
6916 _message_array_set_file_info(file_info_message, 1, file_info);
6917 param_ret = plugin_message_set_param_array(m_result, param_idx++, file_info_message);
6918 plugin_message_array_destroy(file_info_message);
6921 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
6922 } else if (NULL != error_code) {
6923 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
6924 plugin_message_set_value_number(m_result,
6925 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
6926 (pmnumber)error_code->code);
6927 plugin_message_set_value_string(m_result,
6928 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
6929 error_code->msg ? error_code->msg : "");
6930 free(error_code->msg);
6933 LOGD("API failed ret_code[%d]", ret);
6934 plugin_message_set_value_number(m_result,
6935 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
6940 LOGD("<<<<<< %s func end", func_name);
6941 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_GET_LIST,
6942 func_name, strlen(STORAGE_PLUGIN_INTERFACE_GET_LIST))) {
6943 LOGD(">>>>>> %s func start", func_name);
6944 char *parent_path = NULL;
6945 char *folder_path = NULL;
6948 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
6949 plugin_message_get_param_string(m_order, param_idx++, &folder_path);
6951 storage_adaptor_file_info_h *file_list = NULL;
6952 int file_list_len = 0;
6953 LOGD("Call library function");
6954 ret = plugin->handle->list(context, parent_path, folder_path,
6955 NULL, &file_list, &file_list_len, &error_code, NULL);
6957 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
6960 if ((NULL != file_list) && (0 < file_list_len)) {
6961 LOGD("Insert file list to pipe message (length : %d)", file_list_len);
6963 plugin_message_array_h file_info_message = NULL;
6964 char message_array_type[20] = {0, };
6965 snprintf(message_array_type, 19, "%c%c%c%c%c%c%c%c%c", PLUGIN_DATA_TYPE_STRING,
6966 PLUGIN_DATA_TYPE_STRING,
6967 PLUGIN_DATA_TYPE_STRING,
6968 PLUGIN_DATA_TYPE_NUM,
6969 PLUGIN_DATA_TYPE_NUM,
6970 PLUGIN_DATA_TYPE_NUM,
6971 PLUGIN_DATA_TYPE_NUM,
6972 PLUGIN_DATA_TYPE_NUM,
6973 PLUGIN_DATA_TYPE_STRING);
6974 param_ret = plugin_message_array_create(message_array_type, &file_info_message);
6975 if (0 == param_ret) {
6976 for (i = 0; i < file_list_len; i++) {
6977 _message_array_set_file_info(file_info_message, (i + 1), file_list[i]);
6978 storage_adaptor_destroy_file_info(&(file_list[i]));
6982 param_ret = plugin_message_set_param_array(m_result, param_idx++, file_info_message);
6983 param_ret = plugin_message_set_param_number(m_result, param_idx++, (pmnumber)file_list_len);
6984 plugin_message_array_destroy(file_info_message);
6987 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
6988 } else if (NULL != error_code) {
6989 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
6990 plugin_message_set_value_number(m_result,
6991 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
6992 (pmnumber)error_code->code);
6993 plugin_message_set_value_string(m_result,
6994 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
6995 error_code->msg ? error_code->msg : "");
6996 free(error_code->msg);
6999 LOGD("API failed ret_code[%d]", ret);
7000 plugin_message_set_value_number(m_result,
7001 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7006 LOGD("<<<<<< %s func end", func_name);
7007 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_UPLOAD_FILE_SYNC,
7008 func_name, strlen(STORAGE_PLUGIN_INTERFACE_UPLOAD_FILE_SYNC))) {
7009 LOGD(">>>>>> %s func start", func_name);
7010 char *parent_path = NULL;
7011 char *folder_path = NULL;
7012 char *local_path = NULL;
7016 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
7017 plugin_message_get_param_string(m_order, param_idx++, &folder_path);
7018 plugin_message_get_param_string(m_order, param_idx++, &local_path);
7019 plugin_message_get_param_number(m_order, param_idx++, &publish);
7021 LOGD("Call library function");
7022 ret = plugin->handle->upload_file_sync(context, parent_path, folder_path, local_path, (int)publish,
7023 NULL, &file_info, &error_code, NULL);
7025 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7026 LOGD("API success");
7029 if (NULL != file_info) {
7030 LOGD("Insert file info to pipe message");
7032 plugin_message_array_h file_info_message = NULL;
7033 char message_array_type[20] = {0, };
7034 snprintf(message_array_type, 19, "%c%c%c%c%c%c%c%c%c", PLUGIN_DATA_TYPE_STRING,
7035 PLUGIN_DATA_TYPE_STRING,
7036 PLUGIN_DATA_TYPE_STRING,
7037 PLUGIN_DATA_TYPE_NUM,
7038 PLUGIN_DATA_TYPE_NUM,
7039 PLUGIN_DATA_TYPE_NUM,
7040 PLUGIN_DATA_TYPE_NUM,
7041 PLUGIN_DATA_TYPE_NUM,
7042 PLUGIN_DATA_TYPE_STRING);
7043 param_ret = plugin_message_array_create(message_array_type, &file_info_message);
7044 if (0 == param_ret) {
7045 _message_array_set_file_info(file_info_message, 1, file_info);
7046 param_ret = plugin_message_set_param_array(m_result, param_idx++, file_info_message);
7047 plugin_message_array_destroy(file_info_message);
7050 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7051 } else if (NULL != error_code) {
7052 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7053 plugin_message_set_value_number(m_result,
7054 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7055 (pmnumber)error_code->code);
7056 plugin_message_set_value_string(m_result,
7057 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7058 error_code->msg ? error_code->msg : "");
7059 free(error_code->msg);
7062 LOGD("API failed ret_code[%d]", ret);
7063 plugin_message_set_value_number(m_result,
7064 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7070 LOGD("<<<<<< %s func end", func_name);
7071 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_DOWNLOAD_FILE_SYNC,
7072 func_name, strlen(STORAGE_PLUGIN_INTERFACE_DOWNLOAD_FILE_SYNC))) {
7073 LOGD(">>>>>> %s func start", func_name);
7074 char *parent_path = NULL;
7075 char *folder_path = NULL;
7076 char *local_path = NULL;
7079 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
7080 plugin_message_get_param_string(m_order, param_idx++, &folder_path);
7081 plugin_message_get_param_string(m_order, param_idx++, &local_path);
7083 LOGD("Call library function");
7084 ret = plugin->handle->download_file_sync(context, parent_path, folder_path, local_path,
7085 NULL, &error_code, NULL);
7087 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7088 LOGD("API success");
7089 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7090 } else if (NULL != error_code) {
7091 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7092 plugin_message_set_value_number(m_result,
7093 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7094 (pmnumber)error_code->code);
7095 plugin_message_set_value_string(m_result,
7096 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7097 error_code->msg ? error_code->msg : "");
7098 free(error_code->msg);
7101 LOGD("API failed ret_code[%d]", ret);
7102 plugin_message_set_value_number(m_result,
7103 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7109 LOGD("<<<<<< %s func end", func_name);
7110 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_DELETE_FILE,
7111 func_name, strlen(STORAGE_PLUGIN_INTERFACE_DELETE_FILE))) {
7112 LOGD(">>>>>> %s func start", func_name);
7113 char *parent_path = NULL;
7114 char *folder_path = NULL;
7117 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
7118 plugin_message_get_param_string(m_order, param_idx++, &folder_path);
7120 LOGD("Call library function");
7121 ret = plugin->handle->delete_file(context, parent_path, folder_path,
7122 NULL, &file_info, &error_code, NULL);
7124 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7125 LOGD("API success");
7128 if (NULL != file_info) {
7129 LOGD("Insert file info to pipe message");
7131 plugin_message_array_h file_info_message = NULL;
7132 char message_array_type[20] = {0, };
7133 snprintf(message_array_type, 19, "%c%c%c%c%c%c%c%c%c", PLUGIN_DATA_TYPE_STRING,
7134 PLUGIN_DATA_TYPE_STRING,
7135 PLUGIN_DATA_TYPE_STRING,
7136 PLUGIN_DATA_TYPE_NUM,
7137 PLUGIN_DATA_TYPE_NUM,
7138 PLUGIN_DATA_TYPE_NUM,
7139 PLUGIN_DATA_TYPE_NUM,
7140 PLUGIN_DATA_TYPE_NUM,
7141 PLUGIN_DATA_TYPE_STRING);
7142 param_ret = plugin_message_array_create(message_array_type, &file_info_message);
7143 if (0 == param_ret) {
7144 _message_array_set_file_info(file_info_message, 1, file_info);
7145 param_ret = plugin_message_set_param_array(m_result, param_idx++, file_info_message);
7146 plugin_message_array_destroy(file_info_message);
7149 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7150 } else if (NULL != error_code) {
7151 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7152 plugin_message_set_value_number(m_result,
7153 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7154 (pmnumber)error_code->code);
7155 plugin_message_set_value_string(m_result,
7156 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7157 error_code->msg ? error_code->msg : "");
7158 free(error_code->msg);
7161 LOGD("API failed ret_code[%d]", ret);
7162 plugin_message_set_value_number(m_result,
7163 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7168 LOGD("<<<<<< %s func end", func_name);
7169 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_MOVE_DIRECTORY,
7170 func_name, strlen(STORAGE_PLUGIN_INTERFACE_MOVE_DIRECTORY))) {
7171 LOGD(">>>>>> %s func start", func_name);
7172 char *parent_path = NULL;
7173 char *folder_path = NULL;
7174 char *dst_parent_path = NULL;
7175 char *dst_folder_path = NULL;
7178 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
7179 plugin_message_get_param_string(m_order, param_idx++, &folder_path);
7180 plugin_message_get_param_string(m_order, param_idx++, &dst_parent_path);
7181 plugin_message_get_param_string(m_order, param_idx++, &dst_folder_path);
7183 LOGD("Call library function");
7184 ret = plugin->handle->move_directory(context, parent_path, folder_path, dst_parent_path, dst_folder_path,
7185 NULL, &file_info, &error_code, NULL);
7187 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7188 LOGD("API success");
7191 if (NULL != file_info) {
7192 LOGD("Insert file info to pipe message");
7194 plugin_message_array_h file_info_message = NULL;
7195 char message_array_type[20] = {0, };
7196 snprintf(message_array_type, 19, "%c%c%c%c%c%c%c%c%c", PLUGIN_DATA_TYPE_STRING,
7197 PLUGIN_DATA_TYPE_STRING,
7198 PLUGIN_DATA_TYPE_STRING,
7199 PLUGIN_DATA_TYPE_NUM,
7200 PLUGIN_DATA_TYPE_NUM,
7201 PLUGIN_DATA_TYPE_NUM,
7202 PLUGIN_DATA_TYPE_NUM,
7203 PLUGIN_DATA_TYPE_NUM,
7204 PLUGIN_DATA_TYPE_STRING);
7205 param_ret = plugin_message_array_create(message_array_type, &file_info_message);
7206 if (0 == param_ret) {
7207 _message_array_set_file_info(file_info_message, 1, file_info);
7208 param_ret = plugin_message_set_param_array(m_result, param_idx++, file_info_message);
7209 plugin_message_array_destroy(file_info_message);
7212 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7213 } else if (NULL != error_code) {
7214 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7215 plugin_message_set_value_number(m_result,
7216 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7217 (pmnumber)error_code->code);
7218 plugin_message_set_value_string(m_result,
7219 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7220 error_code->msg ? error_code->msg : "");
7221 free(error_code->msg);
7224 LOGD("API failed ret_code[%d]", ret);
7225 plugin_message_set_value_number(m_result,
7226 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7231 free(dst_parent_path);
7232 free(dst_folder_path);
7233 LOGD("<<<<<< %s func end", func_name);
7234 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_MOVE_FILE,
7235 func_name, strlen(STORAGE_PLUGIN_INTERFACE_MOVE_FILE))) {
7236 LOGD(">>>>>> %s func start", func_name);
7237 char *parent_path = NULL;
7238 char *file_path = NULL;
7239 char *dst_parent_path = NULL;
7240 char *dst_file_path = NULL;
7243 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
7244 plugin_message_get_param_string(m_order, param_idx++, &file_path);
7245 plugin_message_get_param_string(m_order, param_idx++, &dst_parent_path);
7246 plugin_message_get_param_string(m_order, param_idx++, &dst_file_path);
7248 LOGD("Call library function");
7249 ret = plugin->handle->move_file(context, parent_path, file_path, dst_parent_path, dst_file_path,
7250 NULL, &file_info, &error_code, NULL);
7252 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7253 LOGD("API success");
7256 if (NULL != file_info) {
7257 LOGD("Insert file info to pipe message");
7259 plugin_message_array_h file_info_message = NULL;
7260 char message_array_type[20] = {0, };
7261 snprintf(message_array_type, 19, "%c%c%c%c%c%c%c%c%c", PLUGIN_DATA_TYPE_STRING,
7262 PLUGIN_DATA_TYPE_STRING,
7263 PLUGIN_DATA_TYPE_STRING,
7264 PLUGIN_DATA_TYPE_NUM,
7265 PLUGIN_DATA_TYPE_NUM,
7266 PLUGIN_DATA_TYPE_NUM,
7267 PLUGIN_DATA_TYPE_NUM,
7268 PLUGIN_DATA_TYPE_NUM,
7269 PLUGIN_DATA_TYPE_STRING);
7270 param_ret = plugin_message_array_create(message_array_type, &file_info_message);
7271 if (0 == param_ret) {
7272 _message_array_set_file_info(file_info_message, 1, file_info);
7273 param_ret = plugin_message_set_param_array(m_result, param_idx++, file_info_message);
7274 plugin_message_array_destroy(file_info_message);
7277 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7278 } else if (NULL != error_code) {
7279 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7280 plugin_message_set_value_number(m_result,
7281 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7282 (pmnumber)error_code->code);
7283 plugin_message_set_value_string(m_result,
7284 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7285 error_code->msg ? error_code->msg : "");
7286 free(error_code->msg);
7289 LOGD("API failed ret_code[%d]", ret);
7290 plugin_message_set_value_number(m_result,
7291 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7296 free(dst_parent_path);
7297 free(dst_file_path);
7298 LOGD("<<<<<< %s func end", func_name);
7299 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_START_UPLOAD_TASK,
7300 func_name, strlen(STORAGE_PLUGIN_INTERFACE_START_UPLOAD_TASK))) {
7301 LOGD(">>>>>> %s func start", func_name);
7302 pmnumber fd, user_data;
7303 char *parent_path = NULL;
7304 char *file_name = NULL;
7305 bool need_progress = false;
7308 plugin_message_get_param_number(m_order, param_idx++, &fd);
7309 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
7310 plugin_message_get_param_string(m_order, param_idx++, &file_name);
7311 plugin_message_get_param_bool(m_order, param_idx++, &need_progress);
7314 plugin_message_get_param_number(m_order, param_idx++, &user_data);
7316 LOGD("Call library function");
7317 ret = plugin->handle->start_upload_task(context, (int)fd, parent_path, file_name, need_progress,
7318 &error_code, (void *)(intptr_t)user_data);
7320 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7321 LOGD("API success");
7323 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7324 } else if (NULL != error_code) {
7325 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7326 plugin_message_set_value_number(m_result,
7327 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7328 (pmnumber)error_code->code);
7329 plugin_message_set_value_string(m_result,
7330 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7331 error_code->msg ? error_code->msg : "");
7332 free(error_code->msg);
7335 LOGD("API failed ret_code[%d]", ret);
7336 plugin_message_set_value_number(m_result,
7337 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7342 LOGD("<<<<<< %s func end", func_name);
7343 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_START_DOWNLOAD_TASK,
7344 func_name, strlen(STORAGE_PLUGIN_INTERFACE_START_DOWNLOAD_TASK))) {
7345 LOGD(">>>>>> %s func start", func_name);
7346 pmnumber fd, user_data;
7347 char *parent_path = NULL;
7348 char *file_name = NULL;
7349 bool need_progress = false;
7352 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
7353 plugin_message_get_param_string(m_order, param_idx++, &file_name);
7354 plugin_message_get_param_number(m_order, param_idx++, &fd);
7355 plugin_message_get_param_bool(m_order, param_idx++, &need_progress);
7358 plugin_message_get_param_number(m_order, param_idx++, &user_data);
7360 LOGD("Call library function");
7361 ret = plugin->handle->start_download_task(context, parent_path, file_name, (int)fd, need_progress,
7362 &error_code, (void *)(intptr_t)user_data);
7364 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7365 LOGD("API success");
7367 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7368 } else if (NULL != error_code) {
7369 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7370 plugin_message_set_value_number(m_result,
7371 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7372 (pmnumber)error_code->code);
7373 plugin_message_set_value_string(m_result,
7374 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7375 error_code->msg ? error_code->msg : "");
7376 free(error_code->msg);
7379 LOGD("API failed ret_code[%d]", ret);
7380 plugin_message_set_value_number(m_result,
7381 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7386 LOGD("<<<<<< %s func end", func_name);
7387 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_START_DOWNLOAD_THUMB_TASK,
7388 func_name, strlen(STORAGE_PLUGIN_INTERFACE_START_DOWNLOAD_THUMB_TASK))) {
7389 LOGD(">>>>>> %s func start", func_name);
7390 pmnumber fd, thumb_size, user_data;
7391 char *parent_path = NULL;
7392 char *file_name = NULL;
7393 bool need_progress = false;
7396 plugin_message_get_param_string(m_order, param_idx++, &parent_path);
7397 plugin_message_get_param_string(m_order, param_idx++, &file_name);
7398 plugin_message_get_param_number(m_order, param_idx++, &fd);
7399 plugin_message_get_param_number(m_order, param_idx++, &thumb_size);
7400 plugin_message_get_param_bool(m_order, param_idx++, &need_progress);
7403 plugin_message_get_param_number(m_order, param_idx++, &user_data);
7405 LOGD("Call library function");
7406 ret = plugin->handle->start_download_thumb_task(context, parent_path, file_name, (int)fd, (int)thumb_size, need_progress,
7407 &error_code, (void *)(intptr_t)user_data);
7409 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7410 LOGD("API success");
7412 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7413 } else if (NULL != error_code) {
7414 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7415 plugin_message_set_value_number(m_result,
7416 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7417 (pmnumber)error_code->code);
7418 plugin_message_set_value_string(m_result,
7419 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7420 error_code->msg ? error_code->msg : "");
7421 free(error_code->msg);
7424 LOGD("API failed ret_code[%d]", ret);
7425 plugin_message_set_value_number(m_result,
7426 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7431 LOGD("<<<<<< %s func end", func_name);
7432 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_CANCEL_UPLOAD_TASK,
7433 func_name, strlen(STORAGE_PLUGIN_INTERFACE_CANCEL_UPLOAD_TASK))) {
7434 LOGD(">>>>>> %s func start", func_name);
7438 plugin_message_get_param_number(m_order, param_idx++, &fd);
7440 LOGD("Call library function");
7441 ret = plugin->handle->cancel_upload_task(context, (int)fd, &error_code);
7443 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7444 LOGD("API success");
7446 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7447 } else if (NULL != error_code) {
7448 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7449 plugin_message_set_value_number(m_result,
7450 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7451 (pmnumber)error_code->code);
7452 plugin_message_set_value_string(m_result,
7453 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7454 error_code->msg ? error_code->msg : "");
7455 free(error_code->msg);
7458 LOGD("API failed ret_code[%d]", ret);
7459 plugin_message_set_value_number(m_result,
7460 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7463 LOGD("<<<<<< %s func end", func_name);
7464 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_CANCEL_DOWNLOAD_TASK,
7465 func_name, strlen(STORAGE_PLUGIN_INTERFACE_CANCEL_DOWNLOAD_TASK))) {
7466 LOGD(">>>>>> %s func start", func_name);
7470 plugin_message_get_param_number(m_order, param_idx++, &fd);
7472 LOGD("Call library function");
7473 ret = plugin->handle->cancel_download_task(context, (int)fd, &error_code);
7475 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7476 LOGD("API success");
7478 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7479 } else if (NULL != error_code) {
7480 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7481 plugin_message_set_value_number(m_result,
7482 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7483 (pmnumber)error_code->code);
7484 plugin_message_set_value_string(m_result,
7485 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7486 error_code->msg ? error_code->msg : "");
7487 free(error_code->msg);
7490 LOGD("API failed ret_code[%d]", ret);
7491 plugin_message_set_value_number(m_result,
7492 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7495 LOGD("<<<<<< %s func end", func_name);
7496 } else if (0 == strncmp(STORAGE_PLUGIN_INTERFACE_CANCEL_DOWNLOAD_THUMB_TASK,
7497 func_name, strlen(STORAGE_PLUGIN_INTERFACE_CANCEL_DOWNLOAD_THUMB_TASK))) {
7498 LOGD(">>>>>> %s func start", func_name);
7502 plugin_message_get_param_number(m_order, param_idx++, &fd);
7504 LOGD("Call library function");
7505 ret = plugin->handle->cancel_download_thumb_task(context, (int)fd, &error_code);
7507 if (STORAGE_ADAPTOR_ERROR_NONE == ret) {
7508 LOGD("API success");
7510 plugin_message_set_value_number(m_result, PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7511 } else if (NULL != error_code) {
7512 LOGD("API failed, error_code[%lld / %s]", (long long int)error_code->code, error_code->msg);
7513 plugin_message_set_value_number(m_result,
7514 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7515 (pmnumber)error_code->code);
7516 plugin_message_set_value_string(m_result,
7517 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7518 error_code->msg ? error_code->msg : "");
7519 free(error_code->msg);
7522 LOGD("API failed ret_code[%d]", ret);
7523 plugin_message_set_value_number(m_result,
7524 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE, (pmnumber)ret);
7527 LOGD("<<<<<< %s func end", func_name);
7528 } else { /* TODO Next */
7529 LOGD(">>>>>> %s func start", func_name);
7530 plugin_message_set_value_number(m_result,
7531 PLUGIN_MESSAGE_ELEMENT_RESULT_CODE,
7532 (pmnumber)STORAGE_ADAPTOR_ERROR_UNSUPPORTED);
7533 plugin_message_set_value_string(m_result,
7534 PLUGIN_MESSAGE_ELEMENT_RESULT_MESSAGE,
7535 "Unsupported operation");
7536 LOGD("<<<<<< %s func end", func_name);
7539 storage_adaptor_destroy_file_info(&file_info);
7542 char *result_data = NULL;
7543 plugin_message_serialize(m_result, &result_data);
7544 plugin_message_destroy(m_result);
7545 plugin_message_destroy(m_order);
7547 *result = result_data;