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-thumbnail.h>
26 #include <media-util.h>
27 #include "media-svc.h"
28 #include "media-svc-util.h"
30 #define MEDIA_SVC_PLUGIN_ERROR_NONE 0
31 #define MEDIA_SVC_PLUGIN_ERROR -1
33 #define STRING_VALID(str) \
34 ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
35 #define STORAGE_VALID(storage)\
36 (((storage == MEDIA_SVC_STORAGE_INTERNAL) || (storage == MEDIA_SVC_STORAGE_EXTERNAL) || (storage == MEDIA_SVC_STORAGE_EXTERNAL_USB)) ? TRUE : FALSE)
48 } media_svc_error_type_e;
50 static void __set_error_message(int err_type, char **err_msg);
52 static void __set_error_message(int err_type, char **err_msg)
59 if (err_type == ERR_HANDLE)
60 *err_msg = strdup("invalid handle");
61 else if (err_type == ERR_FILE_PATH)
62 *err_msg = strdup("invalid file path");
63 else if (err_type == ERR_FOLDER_PATH)
64 *err_msg = strdup("invalid folder path");
65 else if (err_type == ERR_MIME_TYPE)
66 *err_msg = strdup("invalid mime type");
67 else if (err_type == ERR_NOT_MEDIAFILE)
68 *err_msg = strdup("not media content");
69 else if (err_type == ERR_STORAGE_TYPE)
70 *err_msg = strdup("invalid storage type");
71 else if (err_type == ERR_CHECK_ITEM)
72 *err_msg = strdup("item does not exist");
73 else if (err_type == MS_MEDIA_ERR_DB_CONNECT_FAIL)
74 *err_msg = strdup("DB connect error");
75 else if (err_type == MS_MEDIA_ERR_DB_DISCONNECT_FAIL)
76 *err_msg = strdup("DB disconnect error");
77 else if (err_type == MS_MEDIA_ERR_INVALID_PARAMETER)
78 *err_msg = strdup("invalid parameter");
79 else if (err_type == MS_MEDIA_ERR_DB_INTERNAL)
80 *err_msg = strdup("DB internal error");
81 else if (err_type == MS_MEDIA_ERR_DB_NO_RECORD)
82 *err_msg = strdup("not found in DB");
83 else if (err_type == MS_MEDIA_ERR_INTERNAL)
84 *err_msg = strdup("media service internal error");
85 else if (err_type == MS_MEDIA_ERR_DB_CORRUPT)
86 *err_msg = strdup("DB corrupt error");
88 *err_msg = strdup("error unknown");
93 int connect_db(void **handle, uid_t uid, char **err_msg)
95 int ret = media_svc_connect(handle, uid, true);
98 __set_error_message(ret, err_msg);
99 return MEDIA_SVC_PLUGIN_ERROR;
102 return MEDIA_SVC_PLUGIN_ERROR_NONE;
105 int disconnect_db(void *handle, char **err_msg)
107 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
109 if (handle == NULL) {
110 __set_error_message(ERR_HANDLE, err_msg);
111 return MEDIA_SVC_PLUGIN_ERROR;
114 ret = media_svc_disconnect(handle);
116 __set_error_message(ret, err_msg);
117 return MEDIA_SVC_PLUGIN_ERROR;
120 return MEDIA_SVC_PLUGIN_ERROR_NONE;
123 int check_item_exist(void *handle, const char *storage_id, const char *file_path, bool *modified, char **err_msg)
125 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
128 if (handle == NULL) {
129 __set_error_message(ERR_HANDLE, err_msg);
130 return MEDIA_SVC_PLUGIN_ERROR;
133 if (!STRING_VALID(file_path)) {
134 __set_error_message(ERR_FILE_PATH, err_msg);
135 return MEDIA_SVC_PLUGIN_ERROR;
138 time_t modified_time = 0;
139 unsigned long long file_size = 0;
142 ret = media_svc_get_file_info(handle, storage_id, file_path, &modified_time, &file_size);
143 if (ret == MS_MEDIA_ERR_NONE) {
144 memset(&st, 0, sizeof(struct stat));
145 if (stat(file_path, &st) == 0) {
146 if ((st.st_mtime != modified_time) || (st.st_size != file_size))
152 return MEDIA_SVC_PLUGIN_ERROR_NONE; /*exist */
155 __set_error_message(ERR_CHECK_ITEM, err_msg);
157 return MEDIA_SVC_PLUGIN_ERROR; /*not exist */
160 int insert_item_begin(void *handle, int item_cnt, int with_noti, int from_pid, char **err_msg)
162 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
164 ret = media_svc_insert_item_begin(item_cnt, with_noti, from_pid);
166 __set_error_message(ret, err_msg);
167 return MEDIA_SVC_PLUGIN_ERROR;
170 return MEDIA_SVC_PLUGIN_ERROR_NONE;
173 int insert_item_end(void *handle, uid_t uid, char **err_msg)
175 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
177 ret = media_svc_insert_item_end(uid);
179 __set_error_message(ret, err_msg);
180 return MEDIA_SVC_PLUGIN_ERROR;
183 return MEDIA_SVC_PLUGIN_ERROR_NONE;
186 int insert_item(void *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
188 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
190 if (handle == NULL) {
191 __set_error_message(ERR_HANDLE, err_msg);
192 return MEDIA_SVC_PLUGIN_ERROR;
195 if (!STRING_VALID(file_path)) {
196 __set_error_message(ERR_FILE_PATH, err_msg);
197 return MEDIA_SVC_PLUGIN_ERROR;
200 if (!STORAGE_VALID(storage_type)) {
201 __set_error_message(ERR_STORAGE_TYPE, err_msg);
202 return MEDIA_SVC_PLUGIN_ERROR;
205 ret = media_svc_insert_item_bulk(handle, storage_id, storage_type, file_path, FALSE, uid);
207 __set_error_message(ret, err_msg);
208 return MEDIA_SVC_PLUGIN_ERROR;
211 return MEDIA_SVC_PLUGIN_ERROR_NONE;
214 int insert_burst_item(void *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
216 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
218 if (handle == NULL) {
219 __set_error_message(ERR_HANDLE, err_msg);
220 return MEDIA_SVC_PLUGIN_ERROR;
223 if (!STRING_VALID(file_path)) {
224 __set_error_message(ERR_FILE_PATH, err_msg);
225 return MEDIA_SVC_PLUGIN_ERROR;
228 if (!STORAGE_VALID(storage_type)) {
229 __set_error_message(ERR_STORAGE_TYPE, err_msg);
230 return MEDIA_SVC_PLUGIN_ERROR;
233 ret = media_svc_insert_item_bulk(handle, storage_id, storage_type, file_path, TRUE, uid);
235 __set_error_message(ret, err_msg);
236 return MEDIA_SVC_PLUGIN_ERROR;
239 return MEDIA_SVC_PLUGIN_ERROR_NONE;
242 int set_all_storage_items_validity(void *handle, const char *storage_id, int storage_type, int validity, uid_t uid, char **err_msg)
244 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
246 if (!STORAGE_VALID(storage_type)) {
247 __set_error_message(ERR_STORAGE_TYPE, err_msg);
248 return MEDIA_SVC_PLUGIN_ERROR;
251 ret = media_svc_set_all_storage_items_validity(storage_id, storage_type, validity, uid);
253 __set_error_message(ret, err_msg);
254 return MEDIA_SVC_PLUGIN_ERROR;
257 return MEDIA_SVC_PLUGIN_ERROR_NONE;
260 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)
262 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
264 if (handle == NULL) {
265 __set_error_message(ERR_HANDLE, err_msg);
266 return MEDIA_SVC_PLUGIN_ERROR;
269 if (!STRING_VALID(folder_path)) {
270 __set_error_message(ERR_FOLDER_PATH, err_msg);
271 return MEDIA_SVC_PLUGIN_ERROR;
274 ret = media_svc_set_folder_items_validity(handle, storage_id, folder_path, validity, recursive, uid);
276 __set_error_message(ret, err_msg);
277 return MEDIA_SVC_PLUGIN_ERROR;
280 return MEDIA_SVC_PLUGIN_ERROR_NONE;
283 int set_item_validity_begin(void *handle, int item_cnt, char **err_msg)
285 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
287 ret = media_svc_set_item_validity_begin(item_cnt);
289 __set_error_message(ret, err_msg);
290 return MEDIA_SVC_PLUGIN_ERROR;
293 return MEDIA_SVC_PLUGIN_ERROR_NONE;
296 int set_item_validity_end(void *handle, uid_t uid, char **err_msg)
298 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
300 ret = media_svc_set_item_validity_end(uid);
302 __set_error_message(ret, err_msg);
303 return MEDIA_SVC_PLUGIN_ERROR;
306 return MEDIA_SVC_PLUGIN_ERROR_NONE;
309 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)
311 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
313 if (!STRING_VALID(file_path)) {
314 __set_error_message(ERR_FILE_PATH, err_msg);
315 return MEDIA_SVC_PLUGIN_ERROR;
318 ret = media_svc_set_item_validity(storage_id, file_path, validity, uid);
321 __set_error_message(ret, err_msg);
322 return MEDIA_SVC_PLUGIN_ERROR;
325 return MEDIA_SVC_PLUGIN_ERROR_NONE;
328 int delete_item(void *handle, const char *storage_id, const char *file_path, uid_t uid, char **err_msg)
330 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
332 if (handle == NULL) {
333 __set_error_message(ERR_HANDLE, err_msg);
334 return MEDIA_SVC_PLUGIN_ERROR;
337 if (!STRING_VALID(file_path)) {
338 __set_error_message(ERR_FILE_PATH, err_msg);
339 return MEDIA_SVC_PLUGIN_ERROR;
342 ret = media_svc_check_item_exist_by_path(handle, storage_id, file_path);
344 ret = media_svc_delete_item_by_path(handle, storage_id, file_path, uid);
347 __set_error_message(ret, err_msg);
348 return MEDIA_SVC_PLUGIN_ERROR;
350 return MEDIA_SVC_PLUGIN_ERROR_NONE;
353 __set_error_message(ERR_CHECK_ITEM, err_msg); /*not exist in DB so can't delete item. */
354 return MEDIA_SVC_PLUGIN_ERROR;
357 int delete_all_items_in_storage(void *handle, const char *storage_id, int storage_type, uid_t uid, char **err_msg)
359 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
361 if (!STORAGE_VALID(storage_type)) {
362 __set_error_message(ERR_STORAGE_TYPE, err_msg);
363 return MEDIA_SVC_PLUGIN_ERROR;
366 ret = media_svc_delete_all_items_in_storage(storage_id, storage_type, uid);
368 __set_error_message(ret, err_msg);
369 return MEDIA_SVC_PLUGIN_ERROR;
372 return MEDIA_SVC_PLUGIN_ERROR_NONE;
375 int delete_all_invalid_items_in_storage(void *handle, const char *storage_id, int storage_type, uid_t uid, char **err_msg)
377 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
379 if (handle == NULL) {
380 __set_error_message(ERR_HANDLE, err_msg);
381 return MEDIA_SVC_PLUGIN_ERROR;
384 if (!STORAGE_VALID(storage_type)) {
385 __set_error_message(ERR_STORAGE_TYPE, err_msg);
386 return MEDIA_SVC_PLUGIN_ERROR;
389 ret = media_svc_delete_invalid_items_in_storage(handle, storage_id, storage_type, uid);
391 __set_error_message(ret, err_msg);
392 return MEDIA_SVC_PLUGIN_ERROR;
395 return MEDIA_SVC_PLUGIN_ERROR_NONE;
398 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)
400 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
402 if (!STRING_VALID(dir_path)) {
403 __set_error_message(ERR_FOLDER_PATH, err_msg);
404 return MEDIA_SVC_PLUGIN_ERROR;
407 ret = media_svc_send_dir_update_noti(handle, storage_id, dir_path, folder_id, (media_item_update_type_e)update_type, pid);
409 __set_error_message(ret, err_msg);
410 return MEDIA_SVC_PLUGIN_ERROR;
413 return MEDIA_SVC_PLUGIN_ERROR_NONE;
416 int check_db(void *handle, uid_t uid, char **err_msg)
418 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
419 int user_version = -1;
421 ret = media_svc_get_user_version(handle, &user_version);
423 __set_error_message(ret, err_msg);
424 return MEDIA_SVC_PLUGIN_ERROR;
427 if (user_version == 0) {
429 ret = media_svc_create_table(uid);
431 __set_error_message(ret, err_msg);
432 return MEDIA_SVC_PLUGIN_ERROR;
436 ret = media_svc_check_db_upgrade(handle, user_version, uid);
438 __set_error_message(ret, err_msg);
439 return MEDIA_SVC_PLUGIN_ERROR;
443 return MEDIA_SVC_PLUGIN_ERROR_NONE;
446 int check_db_corrupt(void *handle, char **err_msg)
448 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
451 ret = media_svc_check_db_corrupt(handle);
453 __set_error_message(ret, err_msg);
454 return MEDIA_SVC_PLUGIN_ERROR;
457 return MEDIA_SVC_PLUGIN_ERROR_NONE;
460 int update_folder_time(void *handle, const char *storage_id, char *folder_path, uid_t uid, char **err_msg)
462 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
464 if (handle == NULL) {
465 __set_error_message(ERR_HANDLE, err_msg);
466 return MEDIA_SVC_PLUGIN_ERROR;
469 if (folder_path == NULL) {
470 __set_error_message(ERR_HANDLE, err_msg);
471 return MEDIA_SVC_PLUGIN_ERROR;
474 ret = media_svc_update_folder_time(handle, storage_id, folder_path, uid);
476 __set_error_message(ret, err_msg);
477 return MEDIA_SVC_PLUGIN_ERROR;
480 return MEDIA_SVC_PLUGIN_ERROR_NONE;
483 int get_uuid(void * handle, char **uuid, char **err_msg)
485 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
487 ret = media_svc_generate_uuid(uuid);
489 __set_error_message(ret, err_msg);
490 return MEDIA_SVC_PLUGIN_ERROR;
493 return MEDIA_SVC_PLUGIN_ERROR_NONE;
496 int get_mmc_info(void * handle, char **storage_name, char **storage_path, int *validity, bool *info_exist, char **err_msg)
498 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
500 if (handle == NULL) {
501 __set_error_message(ERR_HANDLE, err_msg);
502 return MEDIA_SVC_PLUGIN_ERROR;
505 ret = media_svc_get_mmc_info(handle, storage_name, storage_path, validity, info_exist);
507 __set_error_message(MS_MEDIA_ERR_DB_NO_RECORD, err_msg);
508 return MEDIA_SVC_PLUGIN_ERROR;
511 return MEDIA_SVC_PLUGIN_ERROR_NONE;
514 int check_storage(void * handle, const char *storage_id, char **storage_path, int *validity, uid_t uid, char **err_msg)
516 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
518 if (handle == NULL) {
519 __set_error_message(ERR_HANDLE, err_msg);
520 return MEDIA_SVC_PLUGIN_ERROR;
523 ret = media_svc_check_storage(handle, storage_id, storage_path, validity, uid);
525 __set_error_message(ret, err_msg);
526 return MEDIA_SVC_PLUGIN_ERROR;
529 return MEDIA_SVC_PLUGIN_ERROR_NONE;
532 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)
534 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
536 if (handle == NULL) {
537 __set_error_message(ERR_HANDLE, err_msg);
538 return MEDIA_SVC_PLUGIN_ERROR;
541 ret = media_svc_insert_storage(handle, storage_id, storage_name, storage_path, storage_type, uid);
543 __set_error_message(ret, err_msg);
544 return MEDIA_SVC_PLUGIN_ERROR;
547 return MEDIA_SVC_PLUGIN_ERROR_NONE;
550 int update_storage(void *handle, const char *storage_id, const char *storage_path, uid_t uid, char **err_msg)
552 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
554 if (handle == NULL) {
555 __set_error_message(ERR_HANDLE, err_msg);
556 return MEDIA_SVC_PLUGIN_ERROR;
559 ret = media_svc_update_storage(handle, storage_id, storage_path, uid);
561 __set_error_message(ret, err_msg);
562 return MEDIA_SVC_PLUGIN_ERROR;
565 return MEDIA_SVC_PLUGIN_ERROR_NONE;
568 int delete_storage(void * handle, const char *storage_id, uid_t uid, char **err_msg)
570 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
572 if (handle == NULL) {
573 __set_error_message(ERR_HANDLE, err_msg);
574 return MEDIA_SVC_PLUGIN_ERROR;
577 ret = media_svc_delete_storage(handle, storage_id, uid);
579 __set_error_message(ret, err_msg);
580 return MEDIA_SVC_PLUGIN_ERROR;
583 return MEDIA_SVC_PLUGIN_ERROR_NONE;
586 int set_storage_validity(void * handle, const char *storage_id, int validity, uid_t uid, char **err_msg)
588 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
590 if (handle == NULL) {
591 __set_error_message(ERR_HANDLE, err_msg);
592 return MEDIA_SVC_PLUGIN_ERROR;
595 ret = media_svc_set_storage_validity(handle, storage_id, validity, uid);
597 __set_error_message(ret, err_msg);
598 return MEDIA_SVC_PLUGIN_ERROR;
601 return MEDIA_SVC_PLUGIN_ERROR_NONE;
604 int set_all_storage_validity(void * handle, int validity, uid_t uid, char **err_msg)
606 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
608 if (handle == NULL) {
609 __set_error_message(ERR_HANDLE, err_msg);
610 return MEDIA_SVC_PLUGIN_ERROR;
613 ret = media_svc_set_storage_validity(handle, NULL, validity, uid);
615 __set_error_message(ret, err_msg);
616 return MEDIA_SVC_PLUGIN_ERROR;
619 return MEDIA_SVC_PLUGIN_ERROR_NONE;
622 int get_storage_id(void * handle, const char *path, char *storage_id, uid_t uid, char **err_msg)
624 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
626 if (handle == NULL) {
627 __set_error_message(ERR_HANDLE, err_msg);
628 return MEDIA_SVC_PLUGIN_ERROR;
631 ret = media_svc_get_storage_id(handle, path, storage_id, uid);
633 __set_error_message(ret, err_msg);
634 return MEDIA_SVC_PLUGIN_ERROR;
637 return MEDIA_SVC_PLUGIN_ERROR_NONE;
640 int set_storage_scan_status(void *handle, const char *storage_id, int status, uid_t uid, char **err_msg)
642 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
643 media_svc_scan_status_type_e storage_status = status;
645 ret = media_svc_set_storage_scan_status(storage_id, storage_status, uid);
647 __set_error_message(ret, err_msg);
648 return MEDIA_SVC_PLUGIN_ERROR;
651 return MEDIA_SVC_PLUGIN_ERROR_NONE;
654 int get_storage_list(void *handle, char ***storage_list, char ***storage_id_list, int **scan_status_list, int *count, char **err_msg)
656 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
658 if (handle == NULL) {
659 __set_error_message(ERR_HANDLE, err_msg);
660 return MEDIA_SVC_PLUGIN_ERROR;
664 __set_error_message(ERR_HANDLE, err_msg);
665 return MEDIA_SVC_PLUGIN_ERROR;
668 ret = media_svc_get_storage_list(handle, storage_list, storage_id_list, scan_status_list, count);
670 __set_error_message(ret, err_msg);
671 return MEDIA_SVC_PLUGIN_ERROR;
674 return MEDIA_SVC_PLUGIN_ERROR_NONE;
677 int update_item_begin(void *handle, int item_cnt, char **err_msg)
679 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
681 ret = media_svc_update_item_begin(item_cnt);
683 __set_error_message(ret, err_msg);
684 return MEDIA_SVC_PLUGIN_ERROR;
687 return MEDIA_SVC_PLUGIN_ERROR_NONE;
690 int update_item_end(void *handle, uid_t uid, char **err_msg)
692 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
694 ret = media_svc_update_item_end(uid);
696 __set_error_message(ret, err_msg);
697 return MEDIA_SVC_PLUGIN_ERROR;
700 return MEDIA_SVC_PLUGIN_ERROR_NONE;
703 int update_item_meta(void *handle, const char *file_path, const char *storage_id, int storage_type, uid_t uid, char **err_msg)
705 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
707 if (handle == NULL) {
708 __set_error_message(ERR_HANDLE, err_msg);
709 return MEDIA_SVC_PLUGIN_ERROR;
712 if (file_path == NULL) {
713 __set_error_message(ERR_HANDLE, err_msg);
714 return MEDIA_SVC_PLUGIN_ERROR;
717 if (storage_id == NULL) {
718 __set_error_message(ERR_HANDLE, err_msg);
719 return MEDIA_SVC_PLUGIN_ERROR;
722 ret = media_svc_update_item_meta(handle, file_path, storage_id, storage_type, uid);
724 __set_error_message(ret, err_msg);
725 return MEDIA_SVC_PLUGIN_ERROR;
728 return MEDIA_SVC_PLUGIN_ERROR_NONE;
731 int insert_item_scan(void * handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
733 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
735 if (handle == NULL) {
736 __set_error_message(ERR_HANDLE, err_msg);
737 return MEDIA_SVC_PLUGIN_ERROR;
740 if (!STRING_VALID(file_path)) {
741 __set_error_message(ERR_FILE_PATH, err_msg);
742 return MEDIA_SVC_PLUGIN_ERROR;
745 if (!STORAGE_VALID(storage_type)) {
746 __set_error_message(ERR_STORAGE_TYPE, err_msg);
747 return MEDIA_SVC_PLUGIN_ERROR;
750 ret = media_svc_insert_item_pass1(handle, storage_id, storage_type, file_path, FALSE, uid);
752 __set_error_message(ret, err_msg);
753 return MEDIA_SVC_PLUGIN_ERROR;
756 return MEDIA_SVC_PLUGIN_ERROR_NONE;
759 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)
762 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
764 if (handle == NULL) {
765 __set_error_message(ERR_HANDLE, err_msg);
766 return MEDIA_SVC_PLUGIN_ERROR;
769 if (!STORAGE_VALID(storage_type)) {
770 __set_error_message(ERR_STORAGE_TYPE, err_msg);
771 return MEDIA_SVC_PLUGIN_ERROR;
774 ret = media_svc_pass2_get_extract_list(handle, storage_id, storage_type, scan_type, path, burst, uid, array);
776 __set_error_message(ret, err_msg);
777 return MEDIA_SVC_PLUGIN_ERROR;
780 return MEDIA_SVC_PLUGIN_ERROR_NONE;
783 int update_one_extract_item(void* handle, const char* storage_id, int storage_type, void* data, int burst, char** err_msg)
786 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
788 if (handle == NULL) {
789 __set_error_message(ERR_HANDLE, err_msg);
790 return MEDIA_SVC_PLUGIN_ERROR;
793 if (!STORAGE_VALID(storage_type)) {
794 __set_error_message(ERR_STORAGE_TYPE, err_msg);
795 return MEDIA_SVC_PLUGIN_ERROR;
798 ret = media_svc_insert_one_item_pass2(handle, storage_id, storage_type, data, burst);
800 __set_error_message(ret, err_msg);
801 return MEDIA_SVC_PLUGIN_ERROR;
804 return MEDIA_SVC_PLUGIN_ERROR_NONE;
807 int query_do_update_list(void* handle, char** err_msg)
810 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
812 if (handle == NULL) {
813 __set_error_message(ERR_HANDLE, err_msg);
814 return MEDIA_SVC_PLUGIN_ERROR;
817 ret = media_svc_query_do_update_list(handle);
819 __set_error_message(ret, err_msg);
820 return MEDIA_SVC_PLUGIN_ERROR;
823 return MEDIA_SVC_PLUGIN_ERROR_NONE;
826 int insert_folder_begin(void * handle, int item_cnt, char **err_msg)
828 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
830 ret = media_svc_insert_folder_begin(item_cnt);
832 __set_error_message(ret, err_msg);
833 return MEDIA_SVC_PLUGIN_ERROR;
836 return MEDIA_SVC_PLUGIN_ERROR_NONE;
839 int insert_folder_end(void *handle, uid_t uid, char **err_msg)
841 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
843 ret = media_svc_insert_folder_end(uid);
845 __set_error_message(ret, err_msg);
846 return MEDIA_SVC_PLUGIN_ERROR;
849 return MEDIA_SVC_PLUGIN_ERROR_NONE;
852 int insert_folder(void * handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid, char **err_msg)
854 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
856 if (handle == NULL) {
857 __set_error_message(ERR_HANDLE, err_msg);
858 return MEDIA_SVC_PLUGIN_ERROR;
861 if (!STRING_VALID(file_path)) {
862 __set_error_message(ERR_FILE_PATH, err_msg);
863 return MEDIA_SVC_PLUGIN_ERROR;
866 if (!STORAGE_VALID(storage_type)) {
867 __set_error_message(ERR_STORAGE_TYPE, err_msg);
868 return MEDIA_SVC_PLUGIN_ERROR;
871 ret = media_svc_insert_folder(handle, storage_id, storage_type, file_path, uid);
873 __set_error_message(ret, err_msg);
874 return MEDIA_SVC_PLUGIN_ERROR;
877 return MEDIA_SVC_PLUGIN_ERROR_NONE;
880 int delete_invalid_folder(void * handle, const char *storage_id, int storage_type, uid_t uid, char **err_msg)
882 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
884 ret = media_svc_delete_invalid_folder(storage_id, storage_type, uid);
886 __set_error_message(ret, err_msg);
887 return MEDIA_SVC_PLUGIN_ERROR;
890 return MEDIA_SVC_PLUGIN_ERROR_NONE;
893 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)
895 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
897 if (handle == NULL) {
898 __set_error_message(ERR_HANDLE, err_msg);
899 return MEDIA_SVC_PLUGIN_ERROR;
902 ret = media_svc_set_folder_validity(handle, storage_id, start_path, validity, is_recursive, uid);
904 __set_error_message(ret, err_msg);
905 return MEDIA_SVC_PLUGIN_ERROR;
908 return MEDIA_SVC_PLUGIN_ERROR_NONE;
911 int get_folder_scan_status(void *handle, const char *storage_id, const char *path, int *status, char **err_msg)
913 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
914 int storage_status = 0;
916 if (handle == NULL) {
917 __set_error_message(ERR_HANDLE, err_msg);
918 return MEDIA_SVC_PLUGIN_ERROR;
921 ret = media_svc_get_folder_scan_status(handle, storage_id, path, &storage_status);
923 __set_error_message(ret, err_msg);
924 return MEDIA_SVC_PLUGIN_ERROR;
927 *status = storage_status;
932 int set_folder_scan_status(void *handle, const char *storage_id, const char *path, int status, uid_t uid, char **err_msg)
934 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
935 int storage_status = status;
937 ret = media_svc_set_folder_scan_status(storage_id, path, storage_status, uid);
939 __set_error_message(ret, err_msg);
940 return MEDIA_SVC_PLUGIN_ERROR;
946 int check_folder_modified(void *handle, const char *path, const char *storage_id, bool *modified, char **err_msg)
948 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
951 if (handle == NULL) {
952 __set_error_message(ERR_HANDLE, err_msg);
953 return MEDIA_SVC_PLUGIN_ERROR;
956 if (!STRING_VALID(path)) {
957 __set_error_message(ERR_FILE_PATH, err_msg);
958 return MEDIA_SVC_PLUGIN_ERROR;
961 ret = media_svc_get_folder_modified_time(handle, path, storage_id, modified);
963 __set_error_message(ret, err_msg);
964 return MEDIA_SVC_PLUGIN_ERROR;
970 int get_null_scan_folder_list(void *handle, const char *storage_id, const char *folder_path, char ***folder_list, int *count, char **err_msg)
972 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
974 if (handle == NULL) {
975 __set_error_message(ERR_HANDLE, err_msg);
976 return MEDIA_SVC_PLUGIN_ERROR;
980 __set_error_message(ERR_HANDLE, err_msg);
981 return MEDIA_SVC_PLUGIN_ERROR;
984 ret = media_svc_get_null_scan_folder_list(handle, storage_id, folder_path, folder_list, count);
986 __set_error_message(ret, err_msg);
987 return MEDIA_SVC_PLUGIN_ERROR;
993 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)
995 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
997 ret = media_svc_change_validity_item_batch(storage_id, path, des_validity, src_validity, uid);
999 __set_error_message(ret, err_msg);
1000 return MEDIA_SVC_PLUGIN_ERROR;
1006 int check_folder_exist(void * handle, const char *storage_id, const char *folder_path, char **err_msg)
1008 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
1010 if (handle == NULL) {
1011 __set_error_message(ERR_HANDLE, err_msg);
1012 return MEDIA_SVC_PLUGIN_ERROR;
1015 ret = media_svc_check_folder_exist_by_path(handle, storage_id, folder_path);
1017 __set_error_message(ret, err_msg);
1018 return MEDIA_SVC_PLUGIN_ERROR;
1021 return MEDIA_SVC_PLUGIN_ERROR_NONE;
1024 int get_folder_id(void * handle, const char *storage_id, const char *path, char *folder_id, char **err_msg)
1026 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
1028 if (handle == NULL) {
1029 __set_error_message(ERR_HANDLE, err_msg);
1030 return MEDIA_SVC_PLUGIN_ERROR;
1033 ret = media_svc_get_folder_id(handle, storage_id, path, folder_id);
1035 __set_error_message(ret, err_msg);
1036 return MEDIA_SVC_PLUGIN_ERROR;
1039 return MEDIA_SVC_PLUGIN_ERROR_NONE;
1042 int get_media_type(void *handle, const char *path, int *mediatype, char **err_msg)
1044 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
1046 if (handle == NULL) {
1047 __set_error_message(ERR_HANDLE, err_msg);
1048 return MEDIA_SVC_PLUGIN_ERROR;
1051 ret = media_svc_get_media_type(path, mediatype);
1053 __set_error_message(ret, err_msg);
1054 return MEDIA_SVC_PLUGIN_ERROR;
1057 return MEDIA_SVC_PLUGIN_ERROR_NONE;