4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
25 #include <media-util.h>
26 #include "media-svc.h"
27 #include "media-svc-util.h"
29 #define MEDIA_SVC_PLUGIN_ERROR_NONE 0
30 #define MEDIA_SVC_PLUGIN_ERROR -1
32 #define STRING_VALID(str) \
33 ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
34 #define STORAGE_VALID(storage)\
35 (((storage == MEDIA_SVC_STORAGE_INTERNAL) || (storage == MEDIA_SVC_STORAGE_EXTERNAL) || (storage == MEDIA_SVC_STORAGE_EXTERNAL_USB)) ? TRUE : FALSE)
47 } media_svc_error_type_e;
49 static void __set_error_message(int err_type, char **err_msg);
51 static void __set_error_message(int err_type, char **err_msg)
58 if (err_type == ERR_HANDLE)
59 *err_msg = strdup("invalid handle");
60 else if (err_type == ERR_FILE_PATH)
61 *err_msg = strdup("invalid file path");
62 else if (err_type == ERR_FOLDER_PATH)
63 *err_msg = strdup("invalid folder path");
64 else if (err_type == ERR_MIME_TYPE)
65 *err_msg = strdup("invalid mime type");
66 else if (err_type == ERR_NOT_MEDIAFILE)
67 *err_msg = strdup("not media content");
68 else if (err_type == ERR_STORAGE_TYPE)
69 *err_msg = strdup("invalid storage type");
70 else if (err_type == ERR_CHECK_ITEM)
71 *err_msg = strdup("item does not exist");
72 else if (err_type == MS_MEDIA_ERR_DB_CONNECT_FAIL)
73 *err_msg = strdup("DB connect error");
74 else if (err_type == MS_MEDIA_ERR_DB_DISCONNECT_FAIL)
75 *err_msg = strdup("DB disconnect error");
76 else if (err_type == MS_MEDIA_ERR_INVALID_PARAMETER)
77 *err_msg = strdup("invalid parameter");
78 else if (err_type == MS_MEDIA_ERR_DB_INTERNAL)
79 *err_msg = strdup("DB internal error");
80 else if (err_type == MS_MEDIA_ERR_DB_NO_RECORD)
81 *err_msg = strdup("not found in DB");
82 else if (err_type == MS_MEDIA_ERR_INTERNAL)
83 *err_msg = strdup("media service internal error");
84 else if (err_type == MS_MEDIA_ERR_DB_CORRUPT)
85 *err_msg = strdup("DB corrupt error");
87 *err_msg = strdup("error unknown");
92 int connect_db(void **handle, uid_t uid, char **err_msg)
94 int ret = media_svc_connect(handle, uid, FALSE);
97 __set_error_message(ret, err_msg);
98 return MEDIA_SVC_PLUGIN_ERROR;
101 return MEDIA_SVC_PLUGIN_ERROR_NONE;
104 int disconnect_db(void *handle, char **err_msg)
106 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
108 if (handle == NULL) {
109 __set_error_message(ERR_HANDLE, err_msg);
110 return MEDIA_SVC_PLUGIN_ERROR;
113 ret = media_svc_disconnect(handle);
115 __set_error_message(ret, err_msg);
116 return MEDIA_SVC_PLUGIN_ERROR;
119 return MEDIA_SVC_PLUGIN_ERROR_NONE;
122 int cleanup_db(void *handle, uid_t uid, char **err_msg)
124 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
126 if (handle == NULL) {
127 __set_error_message(ERR_HANDLE, err_msg);
128 return MEDIA_SVC_PLUGIN_ERROR;
131 ret = media_svc_cleanup_db(handle, uid);
133 __set_error_message(ret, err_msg);
134 return MEDIA_SVC_PLUGIN_ERROR;
137 return MEDIA_SVC_PLUGIN_ERROR_NONE;
140 int check_item_exist(void *handle, const char *storage_id, const char *file_path, bool *modified, char **err_msg)
142 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
145 if (handle == NULL) {
146 __set_error_message(ERR_HANDLE, err_msg);
147 return MEDIA_SVC_PLUGIN_ERROR;
150 if (!STRING_VALID(file_path)) {
151 __set_error_message(ERR_FILE_PATH, err_msg);
152 return MEDIA_SVC_PLUGIN_ERROR;
155 time_t modified_time = 0;
156 unsigned long long file_size = 0;
159 ret = media_svc_get_file_info(handle, storage_id, file_path, &modified_time, &file_size);
160 if (ret == MS_MEDIA_ERR_NONE) {
161 memset(&st, 0, sizeof(struct stat));
162 if (stat(file_path, &st) == 0) {
163 if ((st.st_mtime != modified_time) || (st.st_size != file_size))
169 return MEDIA_SVC_PLUGIN_ERROR_NONE; /*exist */
172 __set_error_message(ERR_CHECK_ITEM, err_msg);
174 return MEDIA_SVC_PLUGIN_ERROR; /*not exist */
177 int insert_item_begin(void *handle, int item_cnt, int with_noti, int from_pid, char **err_msg)
179 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
181 ret = media_svc_insert_item_begin(item_cnt, with_noti, from_pid);
183 __set_error_message(ret, err_msg);
184 return MEDIA_SVC_PLUGIN_ERROR;
187 return MEDIA_SVC_PLUGIN_ERROR_NONE;
190 int insert_item_end(void *handle, uid_t uid, char **err_msg)
192 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
194 ret = media_svc_insert_item_end(uid);
196 __set_error_message(ret, err_msg);
197 return MEDIA_SVC_PLUGIN_ERROR;
200 return MEDIA_SVC_PLUGIN_ERROR_NONE;
203 int insert_item(void *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
205 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
207 if (handle == NULL) {
208 __set_error_message(ERR_HANDLE, err_msg);
209 return MEDIA_SVC_PLUGIN_ERROR;
212 if (!STRING_VALID(file_path)) {
213 __set_error_message(ERR_FILE_PATH, err_msg);
214 return MEDIA_SVC_PLUGIN_ERROR;
217 if (!STORAGE_VALID(storage_type)) {
218 __set_error_message(ERR_STORAGE_TYPE, err_msg);
219 return MEDIA_SVC_PLUGIN_ERROR;
222 ret = media_svc_insert_item_bulk(handle, storage_id, storage_type, file_path, FALSE, uid);
224 __set_error_message(ret, err_msg);
225 return MEDIA_SVC_PLUGIN_ERROR;
228 return MEDIA_SVC_PLUGIN_ERROR_NONE;
231 int insert_burst_item(void *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
233 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
235 if (handle == NULL) {
236 __set_error_message(ERR_HANDLE, err_msg);
237 return MEDIA_SVC_PLUGIN_ERROR;
240 if (!STRING_VALID(file_path)) {
241 __set_error_message(ERR_FILE_PATH, err_msg);
242 return MEDIA_SVC_PLUGIN_ERROR;
245 if (!STORAGE_VALID(storage_type)) {
246 __set_error_message(ERR_STORAGE_TYPE, err_msg);
247 return MEDIA_SVC_PLUGIN_ERROR;
250 ret = media_svc_insert_item_bulk(handle, storage_id, storage_type, file_path, TRUE, uid);
252 __set_error_message(ret, err_msg);
253 return MEDIA_SVC_PLUGIN_ERROR;
256 return MEDIA_SVC_PLUGIN_ERROR_NONE;
259 int set_all_storage_items_validity(void *handle, const char *storage_id, int storage_type, int validity, uid_t uid, char **err_msg)
261 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
263 if (!STORAGE_VALID(storage_type)) {
264 __set_error_message(ERR_STORAGE_TYPE, err_msg);
265 return MEDIA_SVC_PLUGIN_ERROR;
268 ret = media_svc_set_all_storage_items_validity(storage_id, storage_type, validity, uid);
270 __set_error_message(ret, err_msg);
271 return MEDIA_SVC_PLUGIN_ERROR;
274 return MEDIA_SVC_PLUGIN_ERROR_NONE;
277 int set_folder_item_validity(void *handle, const char *storage_id, const char *folder_path, int validity, int recursive, uid_t uid, char **err_msg)
279 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
281 if (handle == NULL) {
282 __set_error_message(ERR_HANDLE, err_msg);
283 return MEDIA_SVC_PLUGIN_ERROR;
286 if (!STRING_VALID(folder_path)) {
287 __set_error_message(ERR_FOLDER_PATH, err_msg);
288 return MEDIA_SVC_PLUGIN_ERROR;
291 ret = media_svc_set_folder_items_validity(handle, storage_id, folder_path, validity, recursive, uid);
293 __set_error_message(ret, err_msg);
294 return MEDIA_SVC_PLUGIN_ERROR;
297 return MEDIA_SVC_PLUGIN_ERROR_NONE;
300 int set_item_validity_begin(void *handle, int item_cnt, char **err_msg)
302 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
304 ret = media_svc_set_item_validity_begin(item_cnt);
306 __set_error_message(ret, err_msg);
307 return MEDIA_SVC_PLUGIN_ERROR;
310 return MEDIA_SVC_PLUGIN_ERROR_NONE;
313 int set_item_validity_end(void *handle, uid_t uid, char **err_msg)
315 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
317 ret = media_svc_set_item_validity_end(uid);
319 __set_error_message(ret, err_msg);
320 return MEDIA_SVC_PLUGIN_ERROR;
323 return MEDIA_SVC_PLUGIN_ERROR_NONE;
326 int set_item_validity(void *handle, const char *storage_id, const char *file_path, int storage_type, int validity, uid_t uid, char **err_msg)
328 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
330 if (!STRING_VALID(file_path)) {
331 __set_error_message(ERR_FILE_PATH, err_msg);
332 return MEDIA_SVC_PLUGIN_ERROR;
335 ret = media_svc_set_item_validity(storage_id, file_path, validity, uid);
338 __set_error_message(ret, err_msg);
339 return MEDIA_SVC_PLUGIN_ERROR;
342 return MEDIA_SVC_PLUGIN_ERROR_NONE;
345 int delete_item(void *handle, const char *storage_id, const char *file_path, uid_t uid, char **err_msg)
347 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
349 if (handle == NULL) {
350 __set_error_message(ERR_HANDLE, err_msg);
351 return MEDIA_SVC_PLUGIN_ERROR;
354 if (!STRING_VALID(file_path)) {
355 __set_error_message(ERR_FILE_PATH, err_msg);
356 return MEDIA_SVC_PLUGIN_ERROR;
359 ret = media_svc_check_item_exist_by_path(handle, storage_id, file_path);
361 ret = media_svc_delete_item_by_path(handle, storage_id, file_path, uid);
364 __set_error_message(ret, err_msg);
365 return MEDIA_SVC_PLUGIN_ERROR;
367 return MEDIA_SVC_PLUGIN_ERROR_NONE;
370 __set_error_message(ERR_CHECK_ITEM, err_msg); /*not exist in DB so can't delete item. */
371 return MEDIA_SVC_PLUGIN_ERROR;
374 int delete_all_items_in_storage(void *handle, const char *storage_id, int storage_type, uid_t uid, char **err_msg)
376 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
378 if (!STORAGE_VALID(storage_type)) {
379 __set_error_message(ERR_STORAGE_TYPE, err_msg);
380 return MEDIA_SVC_PLUGIN_ERROR;
383 ret = media_svc_delete_all_items_in_storage(storage_id, storage_type, uid);
385 __set_error_message(ret, err_msg);
386 return MEDIA_SVC_PLUGIN_ERROR;
389 return MEDIA_SVC_PLUGIN_ERROR_NONE;
392 int delete_all_invalid_items_in_storage(void *handle, const char *storage_id, int storage_type, uid_t uid, char **err_msg)
394 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
396 if (handle == NULL) {
397 __set_error_message(ERR_HANDLE, err_msg);
398 return MEDIA_SVC_PLUGIN_ERROR;
401 if (!STORAGE_VALID(storage_type)) {
402 __set_error_message(ERR_STORAGE_TYPE, err_msg);
403 return MEDIA_SVC_PLUGIN_ERROR;
406 ret = media_svc_delete_invalid_items_in_storage(handle, storage_id, storage_type, uid);
408 __set_error_message(ret, err_msg);
409 return MEDIA_SVC_PLUGIN_ERROR;
412 return MEDIA_SVC_PLUGIN_ERROR_NONE;
415 int send_dir_update_noti(void *handle, const char *storage_id, const char *dir_path, const char *folder_id, int update_type, int pid, char **err_msg)
417 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
419 if (!STRING_VALID(dir_path)) {
420 __set_error_message(ERR_FOLDER_PATH, err_msg);
421 return MEDIA_SVC_PLUGIN_ERROR;
424 ret = media_svc_send_dir_update_noti(handle, storage_id, dir_path, folder_id, (media_item_update_type_e)update_type, pid);
426 __set_error_message(ret, err_msg);
427 return MEDIA_SVC_PLUGIN_ERROR;
430 return MEDIA_SVC_PLUGIN_ERROR_NONE;
433 int check_db(void *handle, uid_t uid, char **err_msg)
435 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
436 int user_version = -1;
438 ret = media_svc_get_user_version(handle, &user_version);
440 __set_error_message(ret, err_msg);
441 return MEDIA_SVC_PLUGIN_ERROR;
444 if (user_version == 0) {
446 ret = media_svc_create_table(uid);
448 __set_error_message(ret, err_msg);
449 return MEDIA_SVC_PLUGIN_ERROR;
453 ret = media_svc_check_db_upgrade(handle, user_version, uid);
455 __set_error_message(ret, err_msg);
456 return MEDIA_SVC_PLUGIN_ERROR;
460 return MEDIA_SVC_PLUGIN_ERROR_NONE;
463 int update_folder_time(void *handle, const char *storage_id, char *folder_path, uid_t uid, char **err_msg)
465 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
467 if (handle == NULL) {
468 __set_error_message(ERR_HANDLE, err_msg);
469 return MEDIA_SVC_PLUGIN_ERROR;
472 if (folder_path == NULL) {
473 __set_error_message(ERR_HANDLE, err_msg);
474 return MEDIA_SVC_PLUGIN_ERROR;
477 ret = media_svc_update_folder_time(handle, storage_id, folder_path, uid);
479 __set_error_message(ret, err_msg);
480 return MEDIA_SVC_PLUGIN_ERROR;
483 return MEDIA_SVC_PLUGIN_ERROR_NONE;
486 int get_uuid(void * handle, char **uuid, char **err_msg)
488 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
490 ret = media_svc_generate_uuid(uuid);
492 __set_error_message(ret, err_msg);
493 return MEDIA_SVC_PLUGIN_ERROR;
496 return MEDIA_SVC_PLUGIN_ERROR_NONE;
499 int get_mmc_info(void * handle, char **storage_name, char **storage_path, int *validity, bool *info_exist, char **err_msg)
501 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
503 if (handle == NULL) {
504 __set_error_message(ERR_HANDLE, err_msg);
505 return MEDIA_SVC_PLUGIN_ERROR;
508 ret = media_svc_get_mmc_info(handle, storage_name, storage_path, validity, info_exist);
510 __set_error_message(MS_MEDIA_ERR_DB_NO_RECORD, err_msg);
511 return MEDIA_SVC_PLUGIN_ERROR;
514 return MEDIA_SVC_PLUGIN_ERROR_NONE;
517 int check_storage(void * handle, const char *storage_id, char **storage_path, int *validity, uid_t uid, char **err_msg)
519 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
521 if (handle == NULL) {
522 __set_error_message(ERR_HANDLE, err_msg);
523 return MEDIA_SVC_PLUGIN_ERROR;
526 ret = media_svc_check_storage(handle, storage_id, storage_path, validity, uid);
528 __set_error_message(ret, err_msg);
529 return MEDIA_SVC_PLUGIN_ERROR;
532 return MEDIA_SVC_PLUGIN_ERROR_NONE;
535 int insert_storage(void *handle, const char *storage_id, int storage_type, const char *storage_name, const char *storage_path, uid_t uid, char **err_msg)
537 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
539 if (handle == NULL) {
540 __set_error_message(ERR_HANDLE, err_msg);
541 return MEDIA_SVC_PLUGIN_ERROR;
544 ret = media_svc_insert_storage(handle, storage_id, storage_name, storage_path, storage_type, uid);
546 __set_error_message(ret, err_msg);
547 return MEDIA_SVC_PLUGIN_ERROR;
550 return MEDIA_SVC_PLUGIN_ERROR_NONE;
553 int update_storage(void *handle, const char *storage_id, const char *storage_path, uid_t uid, char **err_msg)
555 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
557 if (handle == NULL) {
558 __set_error_message(ERR_HANDLE, err_msg);
559 return MEDIA_SVC_PLUGIN_ERROR;
562 ret = media_svc_update_storage(handle, storage_id, storage_path, uid);
564 __set_error_message(ret, err_msg);
565 return MEDIA_SVC_PLUGIN_ERROR;
568 return MEDIA_SVC_PLUGIN_ERROR_NONE;
571 int delete_storage(void * handle, const char *storage_id, uid_t uid, char **err_msg)
573 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
575 if (handle == NULL) {
576 __set_error_message(ERR_HANDLE, err_msg);
577 return MEDIA_SVC_PLUGIN_ERROR;
580 ret = media_svc_delete_storage(handle, storage_id, uid);
582 __set_error_message(ret, err_msg);
583 return MEDIA_SVC_PLUGIN_ERROR;
586 return MEDIA_SVC_PLUGIN_ERROR_NONE;
589 int set_storage_validity(void * handle, const char *storage_id, int validity, uid_t uid, char **err_msg)
591 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
593 if (handle == NULL) {
594 __set_error_message(ERR_HANDLE, err_msg);
595 return MEDIA_SVC_PLUGIN_ERROR;
598 ret = media_svc_set_storage_validity(handle, storage_id, validity, uid);
600 __set_error_message(ret, err_msg);
601 return MEDIA_SVC_PLUGIN_ERROR;
604 return MEDIA_SVC_PLUGIN_ERROR_NONE;
607 int set_all_storage_validity(void * handle, int validity, uid_t uid, char **err_msg)
609 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
611 if (handle == NULL) {
612 __set_error_message(ERR_HANDLE, err_msg);
613 return MEDIA_SVC_PLUGIN_ERROR;
616 ret = media_svc_set_storage_validity(handle, NULL, validity, uid);
618 __set_error_message(ret, err_msg);
619 return MEDIA_SVC_PLUGIN_ERROR;
622 return MEDIA_SVC_PLUGIN_ERROR_NONE;
625 int get_storage_id(void * handle, const char *path, char *storage_id, uid_t uid, char **err_msg)
627 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
629 if (handle == NULL) {
630 __set_error_message(ERR_HANDLE, err_msg);
631 return MEDIA_SVC_PLUGIN_ERROR;
634 ret = media_svc_get_storage_id(handle, path, storage_id, uid);
636 __set_error_message(ret, err_msg);
637 return MEDIA_SVC_PLUGIN_ERROR;
640 return MEDIA_SVC_PLUGIN_ERROR_NONE;
643 int set_storage_scan_status(void *handle, const char *storage_id, int status, uid_t uid, char **err_msg)
645 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
646 media_svc_scan_status_type_e storage_status = status;
648 ret = media_svc_set_storage_scan_status(storage_id, storage_status, uid);
650 __set_error_message(ret, err_msg);
651 return MEDIA_SVC_PLUGIN_ERROR;
654 return MEDIA_SVC_PLUGIN_ERROR_NONE;
657 int get_storage_list(void *handle, char ***storage_list, char ***storage_id_list, int **scan_status_list, int *count, char **err_msg)
659 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
661 if (handle == NULL) {
662 __set_error_message(ERR_HANDLE, err_msg);
663 return MEDIA_SVC_PLUGIN_ERROR;
667 __set_error_message(ERR_HANDLE, err_msg);
668 return MEDIA_SVC_PLUGIN_ERROR;
671 ret = media_svc_get_storage_list(handle, storage_list, storage_id_list, scan_status_list, count);
673 __set_error_message(ret, err_msg);
674 return MEDIA_SVC_PLUGIN_ERROR;
677 return MEDIA_SVC_PLUGIN_ERROR_NONE;
680 int update_item_begin(void *handle, int item_cnt, char **err_msg)
682 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
684 ret = media_svc_update_item_begin(item_cnt);
686 __set_error_message(ret, err_msg);
687 return MEDIA_SVC_PLUGIN_ERROR;
690 return MEDIA_SVC_PLUGIN_ERROR_NONE;
693 int update_item_end(void *handle, uid_t uid, char **err_msg)
695 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
697 ret = media_svc_update_item_end(uid);
699 __set_error_message(ret, err_msg);
700 return MEDIA_SVC_PLUGIN_ERROR;
703 return MEDIA_SVC_PLUGIN_ERROR_NONE;
706 int update_item_meta(void *handle, const char *file_path, const char *storage_id, int storage_type, uid_t uid, char **err_msg)
708 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
710 if (handle == NULL) {
711 __set_error_message(ERR_HANDLE, err_msg);
712 return MEDIA_SVC_PLUGIN_ERROR;
715 if (file_path == NULL) {
716 __set_error_message(ERR_HANDLE, err_msg);
717 return MEDIA_SVC_PLUGIN_ERROR;
720 if (storage_id == NULL) {
721 __set_error_message(ERR_HANDLE, err_msg);
722 return MEDIA_SVC_PLUGIN_ERROR;
725 ret = media_svc_update_item_meta(handle, file_path, storage_id, storage_type, uid);
727 __set_error_message(ret, err_msg);
728 return MEDIA_SVC_PLUGIN_ERROR;
731 return MEDIA_SVC_PLUGIN_ERROR_NONE;
734 int insert_item_scan(void * handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
736 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
738 if (handle == NULL) {
739 __set_error_message(ERR_HANDLE, err_msg);
740 return MEDIA_SVC_PLUGIN_ERROR;
743 if (!STRING_VALID(file_path)) {
744 __set_error_message(ERR_FILE_PATH, err_msg);
745 return MEDIA_SVC_PLUGIN_ERROR;
748 if (!STORAGE_VALID(storage_type)) {
749 __set_error_message(ERR_STORAGE_TYPE, err_msg);
750 return MEDIA_SVC_PLUGIN_ERROR;
753 ret = media_svc_insert_item_pass1(handle, storage_id, storage_type, file_path, FALSE, uid);
755 __set_error_message(ret, err_msg);
756 return MEDIA_SVC_PLUGIN_ERROR;
759 return MEDIA_SVC_PLUGIN_ERROR_NONE;
762 int get_extract_list(void* handle, const char* storage_id, int storage_type, int scan_type, const char* path, int burst, uid_t uid, void* array, char** err_msg)
765 return MEDIA_SVC_PLUGIN_ERROR_NONE;
768 int update_one_extract_item(void* handle, const char* storage_id, int storage_type, void* data, int burst, char** err_msg)
771 return MEDIA_SVC_PLUGIN_ERROR_NONE;
774 int query_do_update_list(void* handle, char** err_msg)
777 return MEDIA_SVC_PLUGIN_ERROR_NONE;
780 int insert_folder_begin(void * handle, int item_cnt, char **err_msg)
782 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
784 ret = media_svc_insert_folder_begin(item_cnt);
786 __set_error_message(ret, err_msg);
787 return MEDIA_SVC_PLUGIN_ERROR;
790 return MEDIA_SVC_PLUGIN_ERROR_NONE;
793 int insert_folder_end(void *handle, uid_t uid, char **err_msg)
795 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
797 ret = media_svc_insert_folder_end(uid);
799 __set_error_message(ret, err_msg);
800 return MEDIA_SVC_PLUGIN_ERROR;
803 return MEDIA_SVC_PLUGIN_ERROR_NONE;
806 int insert_folder(void * handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
808 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
810 if (handle == NULL) {
811 __set_error_message(ERR_HANDLE, err_msg);
812 return MEDIA_SVC_PLUGIN_ERROR;
815 if (!STRING_VALID(file_path)) {
816 __set_error_message(ERR_FILE_PATH, err_msg);
817 return MEDIA_SVC_PLUGIN_ERROR;
820 if (!STORAGE_VALID(storage_type)) {
821 __set_error_message(ERR_STORAGE_TYPE, err_msg);
822 return MEDIA_SVC_PLUGIN_ERROR;
825 ret = media_svc_insert_folder(handle, storage_id, storage_type, file_path, uid);
827 __set_error_message(ret, err_msg);
828 return MEDIA_SVC_PLUGIN_ERROR;
831 return MEDIA_SVC_PLUGIN_ERROR_NONE;
834 int delete_invalid_folder(void * handle, const char *storage_id, int storage_type, uid_t uid, char **err_msg)
836 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
838 ret = media_svc_delete_invalid_folder(storage_id, storage_type, uid);
840 __set_error_message(ret, err_msg);
841 return MEDIA_SVC_PLUGIN_ERROR;
844 return MEDIA_SVC_PLUGIN_ERROR_NONE;
847 int set_folder_validity(void * handle, const char *storage_id, const char* start_path, int validity, bool is_recursive, uid_t uid, char **err_msg)
849 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
851 if (handle == NULL) {
852 __set_error_message(ERR_HANDLE, err_msg);
853 return MEDIA_SVC_PLUGIN_ERROR;
856 ret = media_svc_set_folder_validity(handle, storage_id, start_path, validity, is_recursive, uid);
858 __set_error_message(ret, err_msg);
859 return MEDIA_SVC_PLUGIN_ERROR;
862 return MEDIA_SVC_PLUGIN_ERROR_NONE;
865 int get_folder_scan_status(void *handle, const char *storage_id, const char *path, int *status, char **err_msg)
867 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
868 int storage_status = 0;
870 if (handle == NULL) {
871 __set_error_message(ERR_HANDLE, err_msg);
872 return MEDIA_SVC_PLUGIN_ERROR;
875 ret = media_svc_get_folder_scan_status(handle, storage_id, path, &storage_status);
877 __set_error_message(ret, err_msg);
878 return MEDIA_SVC_PLUGIN_ERROR;
881 *status = storage_status;
886 int set_folder_scan_status(void *handle, const char *storage_id, const char *path, int status, uid_t uid, char **err_msg)
888 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
889 int storage_status = status;
891 ret = media_svc_set_folder_scan_status(storage_id, path, storage_status, uid);
893 __set_error_message(ret, err_msg);
894 return MEDIA_SVC_PLUGIN_ERROR;
900 int check_folder_modified(void *handle, const char *path, const char *storage_id, bool *modified, char **err_msg)
902 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
905 if (handle == NULL) {
906 __set_error_message(ERR_HANDLE, err_msg);
907 return MEDIA_SVC_PLUGIN_ERROR;
910 if (!STRING_VALID(path)) {
911 __set_error_message(ERR_FILE_PATH, err_msg);
912 return MEDIA_SVC_PLUGIN_ERROR;
915 ret = media_svc_get_folder_modified_time(handle, path, storage_id, modified);
917 __set_error_message(ret, err_msg);
918 return MEDIA_SVC_PLUGIN_ERROR;
924 int get_null_scan_folder_list(void *handle, const char *storage_id, const char *folder_path, char ***folder_list, int *count, char **err_msg)
926 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
928 if (handle == NULL) {
929 __set_error_message(ERR_HANDLE, err_msg);
930 return MEDIA_SVC_PLUGIN_ERROR;
934 __set_error_message(ERR_HANDLE, err_msg);
935 return MEDIA_SVC_PLUGIN_ERROR;
938 ret = media_svc_get_null_scan_folder_list(handle, storage_id, folder_path, folder_list, count);
940 __set_error_message(ret, err_msg);
941 return MEDIA_SVC_PLUGIN_ERROR;
947 int change_validity_item_batch(void **handle, const char *storage_id, const char *path, int des_validity, int src_validity, uid_t uid, char **err_msg)
949 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
951 ret = media_svc_change_validity_item_batch(storage_id, path, des_validity, src_validity, uid);
953 __set_error_message(ret, err_msg);
954 return MEDIA_SVC_PLUGIN_ERROR;
960 int check_folder_exist(void * handle, const char *storage_id, const char *folder_path, char **err_msg)
962 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
964 if (handle == NULL) {
965 __set_error_message(ERR_HANDLE, err_msg);
966 return MEDIA_SVC_PLUGIN_ERROR;
969 ret = media_svc_check_folder_exist_by_path(handle, storage_id, folder_path);
971 __set_error_message(ret, err_msg);
972 return MEDIA_SVC_PLUGIN_ERROR;
975 return MEDIA_SVC_PLUGIN_ERROR_NONE;
978 int get_folder_id(void * handle, const char *storage_id, const char *path, char *folder_id, char **err_msg)
980 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
982 if (handle == NULL) {
983 __set_error_message(ERR_HANDLE, err_msg);
984 return MEDIA_SVC_PLUGIN_ERROR;
987 ret = media_svc_get_folder_id(handle, storage_id, path, folder_id);
989 __set_error_message(ret, err_msg);
990 return MEDIA_SVC_PLUGIN_ERROR;
993 return MEDIA_SVC_PLUGIN_ERROR_NONE;
996 int get_media_type(void *handle, const char *path, int *mediatype, char **err_msg)
998 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
1000 if (handle == NULL) {
1001 __set_error_message(ERR_HANDLE, err_msg);
1002 return MEDIA_SVC_PLUGIN_ERROR;
1005 ret = media_svc_get_media_type(path, mediatype);
1007 __set_error_message(ret, err_msg);
1008 return MEDIA_SVC_PLUGIN_ERROR;
1011 return MEDIA_SVC_PLUGIN_ERROR_NONE;