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.
24 #include <media-thumbnail.h>
25 #include "media-svc.h"
26 #include "audio-svc.h"
27 #include "visual-svc.h"
29 #define MEDIA_SVC_PLUGIN_ERROR_NONE 0
30 #define MEDIA_SVC_PLUGIN_ERROR -1
31 #define MEDIA_SVC_PLUGIN_STORAGE_INTERNAL 0
32 #define MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL 1
34 #define STRING_VALID(str) \
35 ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
36 #define STORAGE_VALID(storage)\
37 (((storage == MEDIA_SVC_PLUGIN_STORAGE_INTERNAL) || (storage == MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL)) ? TRUE : FALSE)
45 }media_svc_content_type_e;
55 }media_svc_error_type_e;
57 #define MS_CATEGORY_UNKNOWN 0x00000000 /**< Default */
58 #define MS_CATEGORY_ETC 0x00000001 /**< ETC category */
59 #define MS_CATEGORY_IMAGE 0x00000002 /**< Image category */
60 #define MS_CATEGORY_VIDEO 0x00000004 /**< Video category */
61 #define MS_CATEGORY_MUSIC 0x00000008 /**< Music category */
62 #define MS_CATEGORY_SOUND 0x00000010 /**< Sound category */
64 #define CONTENT_TYPE_NUM 4
65 #define MUSIC_MIME_NUM 28
66 #define SOUND_MIME_NUM 1
67 #define MIME_TYPE_LENGTH 255
68 #define MIME_LENGTH 50
69 #define _3GP_FILE ".3gp"
70 #define _MP4_FILE ".mp4"
74 char content_type[15];
76 } fex_content_table_t;
78 static const fex_content_table_t content_category[CONTENT_TYPE_NUM] = {
79 {"audio", MS_CATEGORY_SOUND},
80 {"image", MS_CATEGORY_IMAGE},
81 {"video", MS_CATEGORY_VIDEO},
82 {"application", MS_CATEGORY_ETC},
85 static const char music_mime_table[MUSIC_MIME_NUM][MIME_LENGTH] = {
86 /*known mime types of normal files*/
92 /* known mime types of drm files*/
94 "x-mp3", /*alias of audio/mpeg*/
95 "x-mpeg", /*alias of audio/mpeg*/
97 "x-ogg", /*alias of audio/ogg*/
98 "vnd.ms-playready.media.pya:*.pya", /*playready*/
101 "x-m4a", /*alias of audio/mp4*/
102 /* below mimes are rare*/
112 "x-vorbis", /*alias of audio/x-vorbis+ogg*/
113 "vorbis", /*alias of audio/x-vorbis+ogg*/
115 "x-mp2", /*alias of audio/mp2*/
116 "x-pn-realaudio", /*alias of audio/vnd.rn-realaudio*/
117 "vnd.m-realaudio", /*alias of audio/vnd.rn-realaudio*/
120 static const char sound_mime_table[SOUND_MIME_NUM][MIME_LENGTH] = {
124 static int __get_content_type_from_mime(const char * path, const char * mimetype, int * category);
125 static int __get_content_type(const char * file_path, const char * mime_type);
126 static void __set_error_message(int err_type, char ** err_msg);
128 static int __get_content_type_from_mime(const char * path, const char * mimetype, int * category)
133 *category = MS_CATEGORY_UNKNOWN;
135 //MS_DBG("mime type : %s", mimetype);
137 /*categorize from mimetype */
138 for (i = 0; i < CONTENT_TYPE_NUM; i++) {
139 if (strstr(mimetype, content_category[i].content_type) != NULL) {
140 *category = (*category | content_category[i].category_by_mime);
145 /*in application type, exitst sound file ex) x-smafs */
146 if (*category & MS_CATEGORY_ETC) {
147 int prefix_len = strlen(content_category[0].content_type);
149 for (i = 0; i < SOUND_MIME_NUM; i++) {
150 if (strstr(mimetype + prefix_len, sound_mime_table[i]) != NULL) {
151 *category ^= MS_CATEGORY_ETC;
152 *category |= MS_CATEGORY_SOUND;
158 /*check music file in soun files. */
159 if (*category & MS_CATEGORY_SOUND) {
160 int prefix_len = strlen(content_category[0].content_type) + 1;
162 //MS_DBG("mime_type : %s", mimetype + prefix_len);
164 for (i = 0; i < MUSIC_MIME_NUM; i++) {
165 if (strcmp(mimetype + prefix_len, music_mime_table[i]) == 0) {
166 *category ^= MS_CATEGORY_SOUND;
167 *category |= MS_CATEGORY_MUSIC;
171 } else if (*category & MS_CATEGORY_VIDEO) {
172 /*some video files don't have video stream. in this case it is categorize as music. */
174 /*"3gp" and "mp4" must check video stream and then categorize in directly. */
175 ext = strrchr(path, '.');
177 if ((strncasecmp(ext, _3GP_FILE, 4) == 0) || (strncasecmp(ext, _MP4_FILE, 5) == 0)) {
181 err = mm_file_get_stream_info(path, &audio, &video);
183 if (audio > 0 && video == 0) {
184 *category ^= MS_CATEGORY_VIDEO;
185 *category |= MS_CATEGORY_MUSIC;
192 //MS_DBG("category_from_ext : %d", *category);
197 static int __get_content_type(const char * file_path, const char * mime_type)
199 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
202 ret = __get_content_type_from_mime(file_path, mime_type, &category);
206 if (category & MS_CATEGORY_SOUND) return CONTENT_TYPE_SOUND;
207 else if (category & MS_CATEGORY_MUSIC) return CONTENT_TYPE_MUSIC;
208 else if (category & MS_CATEGORY_IMAGE) return CONTENT_TYPE_IMAGE;
209 else if (category & MS_CATEGORY_VIDEO) return CONTENT_TYPE_VIDEO;
210 else return CONTENT_TYPE_MAX;
214 static void __set_error_message(int err_type, char ** err_msg)
219 if(err_type == ERR_FILE_PATH)
220 *err_msg = strdup("invalid file path");
221 if(err_type == ERR_HANDLE)
222 *err_msg = strdup("invalid handle");
223 else if(err_type == ERR_MIME_TYPE)
224 *err_msg = strdup("invalid mime type");
225 else if(err_type == ERR_NOT_MEDIAFILE)
226 *err_msg = strdup("not media content");
227 else if(err_type == ERR_STORAGE_TYPE)
228 *err_msg = strdup("invalid storage type");
229 else if(err_type == ERR_CHECK_ITEM)
230 *err_msg = strdup("item does not exist");
231 else if(err_type == MEDIA_INFO_ERROR_DATABASE_CONNECT)
232 *err_msg = strdup("DB connect error");
233 else if(err_type == MEDIA_INFO_ERROR_DATABASE_DISCONNECT)
234 *err_msg = strdup("DB disconnect error");
235 else if((err_type == AUDIO_SVC_ERROR_INVALID_PARAMETER) || (err_type == MB_SVC_ERROR_INVALID_PARAMETER))
236 *err_msg = strdup("invalid parameter");
237 else if((err_type == AUDIO_SVC_ERROR_DB_INTERNAL) ||(err_type == MB_SVC_ERROR_DB_INTERNAL))
238 *err_msg = strdup("DB internal error");
239 else if((err_type == AUDIO_SVC_ERROR_INTERNAL) || (err_type == MB_SVC_ERROR_INTERNAL))
240 *err_msg = strdup("media service internal error");
242 *err_msg = strdup("error unknown");
246 int check_item(const char *file_path, const char * mime_type, char ** err_msg)
248 int content_type = 0;
250 if (!STRING_VALID(file_path)) {
251 __set_error_message(ERR_FILE_PATH, err_msg);
252 return MEDIA_SVC_PLUGIN_ERROR;
255 if (!STRING_VALID(mime_type)) {
256 __set_error_message(ERR_MIME_TYPE, err_msg);
257 return MEDIA_SVC_PLUGIN_ERROR;
260 content_type = __get_content_type(file_path, mime_type);
262 if(content_type == CONTENT_TYPE_MAX) {
263 __set_error_message(ERR_NOT_MEDIAFILE, err_msg);
264 return MEDIA_SVC_PLUGIN_ERROR; //not media file
267 return MEDIA_SVC_PLUGIN_ERROR_NONE; //media file
271 int connect(void ** handle, char ** err_msg)
273 int ret = media_svc_connect(handle);
276 __set_error_message(ret, err_msg);
277 return MEDIA_SVC_PLUGIN_ERROR;
280 return MEDIA_SVC_PLUGIN_ERROR_NONE;
283 int disconnect(void * handle, char ** err_msg)
285 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
288 __set_error_message(ERR_HANDLE, err_msg);
289 return MEDIA_SVC_PLUGIN_ERROR;
292 ret = media_svc_disconnect(handle);
294 __set_error_message(ret, err_msg);
295 return MEDIA_SVC_PLUGIN_ERROR;
298 return MEDIA_SVC_PLUGIN_ERROR_NONE;
301 int check_item_exist(void* handle, const char *file_path, int storage_type, char ** err_msg)
303 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
306 __set_error_message(ERR_HANDLE, err_msg);
307 return MEDIA_SVC_PLUGIN_ERROR;
310 if (!STRING_VALID(file_path)) {
311 __set_error_message(ERR_FILE_PATH, err_msg);
312 return MEDIA_SVC_PLUGIN_ERROR;
315 if(!STORAGE_VALID(storage_type)) {
316 __set_error_message(ERR_STORAGE_TYPE, err_msg);
317 return MEDIA_SVC_PLUGIN_ERROR;
320 ret = audio_svc_check_item_exist(handle, file_path);
322 return MEDIA_SVC_PLUGIN_ERROR_NONE; //exist
324 ret = minfo_check_item_exist(handle, file_path);
326 return MEDIA_SVC_PLUGIN_ERROR_NONE; //exist
328 __set_error_message(ERR_CHECK_ITEM, err_msg);
329 return MEDIA_SVC_PLUGIN_ERROR; //not exist
333 int insert_item_begin(void * handle, int item_cnt, char ** err_msg)
335 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
338 __set_error_message(ERR_HANDLE, err_msg);
339 return MEDIA_SVC_PLUGIN_ERROR;
342 ret = audio_svc_insert_item_start(handle, item_cnt);
344 __set_error_message(ret, err_msg);
345 return MEDIA_SVC_PLUGIN_ERROR;
348 ret = minfo_add_media_start(handle, item_cnt);
350 __set_error_message(ret, err_msg);
351 return MEDIA_SVC_PLUGIN_ERROR;
354 return MEDIA_SVC_PLUGIN_ERROR_NONE;
357 int insert_item_end(void * handle, char ** err_msg)
359 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
362 __set_error_message(ERR_HANDLE, err_msg);
363 return MEDIA_SVC_PLUGIN_ERROR;
366 ret = audio_svc_insert_item_end(handle);
368 __set_error_message(ret, err_msg);
369 return MEDIA_SVC_PLUGIN_ERROR;
372 ret = minfo_add_media_end(handle);
374 __set_error_message(ret, err_msg);
375 return MEDIA_SVC_PLUGIN_ERROR;
378 return MEDIA_SVC_PLUGIN_ERROR_NONE;
381 int insert_item(void * handle, const char *file_path, int storage_type, const char * mime_type, char ** err_msg)
383 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
386 __set_error_message(ERR_HANDLE, err_msg);
387 return MEDIA_SVC_PLUGIN_ERROR;
390 if (!STRING_VALID(file_path)) {
391 __set_error_message(ERR_FILE_PATH, err_msg);
392 return MEDIA_SVC_PLUGIN_ERROR;
395 if (!STRING_VALID(mime_type)) {
396 __set_error_message(ERR_MIME_TYPE, err_msg);
397 return MEDIA_SVC_PLUGIN_ERROR;
400 if(!STORAGE_VALID(storage_type)) {
401 __set_error_message(ERR_STORAGE_TYPE, err_msg);
402 return MEDIA_SVC_PLUGIN_ERROR;
405 media_svc_content_type_e content_type = __get_content_type(file_path, mime_type);
407 if(content_type == CONTENT_TYPE_SOUND || content_type == CONTENT_TYPE_MUSIC) {
409 if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_INTERNAL) {
411 if(content_type == CONTENT_TYPE_SOUND)
412 ret = audio_svc_insert_item(handle, AUDIO_SVC_STORAGE_PHONE, file_path, AUDIO_SVC_CATEGORY_SOUND);
414 ret = audio_svc_insert_item(handle, AUDIO_SVC_STORAGE_PHONE, file_path, AUDIO_SVC_CATEGORY_MUSIC);
416 } else if (storage_type == MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL) {
418 if(content_type == CONTENT_TYPE_SOUND)
419 ret = audio_svc_insert_item(handle, AUDIO_SVC_STORAGE_MMC, file_path, AUDIO_SVC_CATEGORY_SOUND);
421 ret = audio_svc_insert_item(handle, AUDIO_SVC_STORAGE_MMC, file_path, AUDIO_SVC_CATEGORY_MUSIC);
425 } else if (content_type == CONTENT_TYPE_IMAGE || content_type == CONTENT_TYPE_VIDEO) {
427 if(content_type == CONTENT_TYPE_IMAGE)
428 ret = minfo_add_media_batch(handle, file_path, MINFO_ITEM_IMAGE);
430 ret = minfo_add_media_batch(handle, file_path, MINFO_ITEM_VIDEO);
434 __set_error_message(ERR_NOT_MEDIAFILE, err_msg);
435 return MEDIA_SVC_PLUGIN_ERROR;
440 __set_error_message(ret, err_msg);
441 return MEDIA_SVC_PLUGIN_ERROR;
444 return MEDIA_SVC_PLUGIN_ERROR_NONE;
447 int insert_item_immediately(void * handle, const char *file_path, int storage_type, const char * mime_type, char ** err_msg)
449 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
452 __set_error_message(ERR_HANDLE, err_msg);
453 return MEDIA_SVC_PLUGIN_ERROR;
456 if (!STRING_VALID(file_path)) {
457 __set_error_message(ERR_FILE_PATH, err_msg);
458 return MEDIA_SVC_PLUGIN_ERROR;
461 if (!STRING_VALID(mime_type)) {
462 __set_error_message(ERR_MIME_TYPE, err_msg);
463 return MEDIA_SVC_PLUGIN_ERROR;
466 if(!STORAGE_VALID(storage_type)) {
467 __set_error_message(ERR_STORAGE_TYPE, err_msg);
468 return MEDIA_SVC_PLUGIN_ERROR;
471 media_svc_content_type_e content_type = __get_content_type(file_path, mime_type);
473 if(content_type == CONTENT_TYPE_SOUND || content_type == CONTENT_TYPE_MUSIC) {
475 if(storage_type == 0) {
477 if(content_type == CONTENT_TYPE_SOUND)
478 ret = audio_svc_insert_item_immediately(handle, AUDIO_SVC_STORAGE_PHONE, file_path, AUDIO_SVC_CATEGORY_SOUND);
480 ret = audio_svc_insert_item_immediately(handle, AUDIO_SVC_STORAGE_PHONE, file_path, AUDIO_SVC_CATEGORY_MUSIC);
482 } else if (storage_type == 1) {
484 if(content_type == CONTENT_TYPE_SOUND)
485 ret = audio_svc_insert_item_immediately(handle, AUDIO_SVC_STORAGE_MMC, file_path, AUDIO_SVC_CATEGORY_SOUND);
487 ret = audio_svc_insert_item_immediately(handle, AUDIO_SVC_STORAGE_MMC, file_path, AUDIO_SVC_CATEGORY_MUSIC);
491 } else if (content_type == CONTENT_TYPE_IMAGE || content_type == CONTENT_TYPE_VIDEO) {
493 if(content_type == CONTENT_TYPE_IMAGE)
494 ret = minfo_add_media(handle, file_path, MINFO_ITEM_IMAGE);
496 ret = minfo_add_media(handle, file_path, MINFO_ITEM_VIDEO);
500 __set_error_message(ERR_NOT_MEDIAFILE, err_msg);
501 return MEDIA_SVC_PLUGIN_ERROR;
506 __set_error_message(ret, err_msg);
507 return MEDIA_SVC_PLUGIN_ERROR;
510 return MEDIA_SVC_PLUGIN_ERROR_NONE;
514 int move_item_begin(void * handle, int item_cnt, char ** err_msg)
516 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
519 __set_error_message(ERR_HANDLE, err_msg);
520 return MEDIA_SVC_PLUGIN_ERROR;
523 ret = audio_svc_move_item_start(handle, item_cnt);
525 __set_error_message(ret, err_msg);
526 return MEDIA_SVC_PLUGIN_ERROR;
529 ret = minfo_move_media_start(handle, item_cnt);
531 __set_error_message(ret, err_msg);
532 return MEDIA_SVC_PLUGIN_ERROR;
535 return MEDIA_SVC_PLUGIN_ERROR_NONE;
538 int move_item_end(void * handle, char ** err_msg)
540 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
543 __set_error_message(ERR_HANDLE, err_msg);
544 return MEDIA_SVC_PLUGIN_ERROR;
547 ret = audio_svc_move_item_end(handle);
549 __set_error_message(ret, err_msg);
550 return MEDIA_SVC_PLUGIN_ERROR;
553 ret = minfo_move_media_end(handle);
555 __set_error_message(ret, err_msg);
556 return MEDIA_SVC_PLUGIN_ERROR;
559 return MEDIA_SVC_PLUGIN_ERROR_NONE;
562 int move_item(void * handle, const char *src_path, int src_storage_type, const char *dest_path, int dest_storage_type, const char * mime_type, char ** err_msg)
564 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
567 __set_error_message(ERR_HANDLE, err_msg);
568 return MEDIA_SVC_PLUGIN_ERROR;
571 if ((!STRING_VALID(src_path)) || (!STRING_VALID(dest_path))) {
572 __set_error_message(ERR_FILE_PATH, err_msg);
573 return MEDIA_SVC_PLUGIN_ERROR;
576 if (!STRING_VALID(mime_type)) {
577 __set_error_message(ERR_MIME_TYPE, err_msg);
578 return MEDIA_SVC_PLUGIN_ERROR;
581 if((!STORAGE_VALID(src_storage_type)) || (!STORAGE_VALID(dest_storage_type))) {
582 __set_error_message(ERR_STORAGE_TYPE, err_msg);
583 return MEDIA_SVC_PLUGIN_ERROR;
586 media_svc_content_type_e content_type = __get_content_type(src_path, mime_type);
588 if(content_type == CONTENT_TYPE_SOUND || content_type == CONTENT_TYPE_MUSIC) {
590 ret = audio_svc_move_item(handle, src_storage_type, src_path, dest_storage_type, dest_path);
592 } else if (content_type == CONTENT_TYPE_IMAGE || content_type == CONTENT_TYPE_VIDEO) {
594 if(content_type == CONTENT_TYPE_IMAGE)
595 ret = minfo_move_media(handle, src_path, dest_path, MINFO_ITEM_IMAGE);
597 ret = minfo_move_media(handle, src_path, dest_path, MINFO_ITEM_VIDEO);
601 __set_error_message(ERR_NOT_MEDIAFILE, err_msg);
602 return MEDIA_SVC_PLUGIN_ERROR;
607 __set_error_message(ret, err_msg);
608 return MEDIA_SVC_PLUGIN_ERROR;
611 return MEDIA_SVC_PLUGIN_ERROR_NONE;
615 int set_all_storage_items_validity(void * handle, int storage_type, int validity, char ** err_msg)
617 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
620 __set_error_message(ERR_HANDLE, err_msg);
621 return MEDIA_SVC_PLUGIN_ERROR;
624 if(!STORAGE_VALID(storage_type)) {
625 __set_error_message(ERR_STORAGE_TYPE, err_msg);
626 return MEDIA_SVC_PLUGIN_ERROR;
629 if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_INTERNAL) {
630 ret = audio_svc_set_db_valid(handle, AUDIO_SVC_STORAGE_PHONE, validity);
632 __set_error_message(ret, err_msg);
633 return MEDIA_SVC_PLUGIN_ERROR;
636 ret = minfo_set_db_valid(handle, MINFO_PHONE, validity);
638 __set_error_message(ret, err_msg);
639 return MEDIA_SVC_PLUGIN_ERROR;
642 } else if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL) {
644 ret = audio_svc_set_db_valid(handle, AUDIO_SVC_STORAGE_MMC, validity);
646 __set_error_message(ret, err_msg);
647 return MEDIA_SVC_PLUGIN_ERROR;
650 ret = minfo_set_db_valid(handle, MINFO_MMC, validity);
652 __set_error_message(ret, err_msg);
653 return MEDIA_SVC_PLUGIN_ERROR;
657 return MEDIA_SVC_PLUGIN_ERROR_NONE;
660 int set_item_validity_begin(void * handle, int item_cnt, char ** err_msg)
662 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
665 __set_error_message(ERR_HANDLE, err_msg);
666 return MEDIA_SVC_PLUGIN_ERROR;
669 ret = audio_svc_set_item_valid_start(handle, item_cnt);
671 __set_error_message(ret, err_msg);
672 return MEDIA_SVC_PLUGIN_ERROR;
675 ret = minfo_set_item_valid_start(handle, item_cnt);
677 __set_error_message(ret, err_msg);
678 return MEDIA_SVC_PLUGIN_ERROR;
681 return MEDIA_SVC_PLUGIN_ERROR_NONE;
684 int set_item_validity_end(void * handle, char ** err_msg)
686 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
689 __set_error_message(ERR_HANDLE, err_msg);
690 return MEDIA_SVC_PLUGIN_ERROR;
693 ret = audio_svc_set_item_valid_end(handle);
695 __set_error_message(ret, err_msg);
696 return MEDIA_SVC_PLUGIN_ERROR;
699 ret = minfo_set_item_valid_end(handle);
701 __set_error_message(ret, err_msg);
702 return MEDIA_SVC_PLUGIN_ERROR;
705 return MEDIA_SVC_PLUGIN_ERROR_NONE;
708 int set_item_validity(void * handle, const char *file_path, int storage_type, const char * mime_type, int validity, char ** err_msg)
710 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
713 __set_error_message(ERR_HANDLE, err_msg);
714 return MEDIA_SVC_PLUGIN_ERROR;
717 if (!STRING_VALID(file_path)) {
718 __set_error_message(ERR_FILE_PATH, err_msg);
719 return MEDIA_SVC_PLUGIN_ERROR;
722 if (!STRING_VALID(mime_type)) {
723 __set_error_message(ERR_MIME_TYPE, err_msg);
724 return MEDIA_SVC_PLUGIN_ERROR;
727 if(!STORAGE_VALID(storage_type)) {
728 __set_error_message(ERR_STORAGE_TYPE, err_msg);
729 return MEDIA_SVC_PLUGIN_ERROR;
732 media_svc_content_type_e content_type = __get_content_type(file_path, mime_type);
734 if(content_type == CONTENT_TYPE_SOUND || content_type == CONTENT_TYPE_MUSIC) {
736 ret = audio_svc_set_item_valid(handle, file_path, validity);
738 } else if (content_type == CONTENT_TYPE_IMAGE || content_type == CONTENT_TYPE_VIDEO) {
740 if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_INTERNAL)
741 ret = minfo_set_item_valid(handle, MINFO_PHONE, file_path, validity);
742 else if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL)
743 ret = minfo_set_item_valid(handle, MINFO_MMC, file_path, validity);
747 __set_error_message(ERR_NOT_MEDIAFILE, err_msg);
748 return MEDIA_SVC_PLUGIN_ERROR;
753 __set_error_message(ret, err_msg);
754 return MEDIA_SVC_PLUGIN_ERROR;
757 return MEDIA_SVC_PLUGIN_ERROR_NONE;
760 int delete_item(void * handle, const char *file_path, int storage_type, char ** err_msg)
762 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
765 __set_error_message(ERR_HANDLE, err_msg);
766 return MEDIA_SVC_PLUGIN_ERROR;
769 if (!STRING_VALID(file_path)) {
770 __set_error_message(ERR_FILE_PATH, err_msg);
771 return MEDIA_SVC_PLUGIN_ERROR;
774 if(!STORAGE_VALID(storage_type)) {
775 __set_error_message(ERR_STORAGE_TYPE, err_msg);
776 return MEDIA_SVC_PLUGIN_ERROR;
779 ret = audio_svc_check_item_exist(handle, file_path);
780 if(ret == 0) { /*audio file*/
781 ret = audio_svc_delete_item_by_path(handle, file_path);
784 __set_error_message(ret, err_msg);
785 return MEDIA_SVC_PLUGIN_ERROR;
787 return MEDIA_SVC_PLUGIN_ERROR_NONE;
790 ret = minfo_check_item_exist(handle, file_path);
791 if(ret == 0) { /*visual file*/
792 ret = minfo_delete_media(handle, file_path);
795 __set_error_message(ret, err_msg);
796 return MEDIA_SVC_PLUGIN_ERROR;
799 return MEDIA_SVC_PLUGIN_ERROR_NONE;
802 __set_error_message(ERR_CHECK_ITEM, err_msg); //not exist in DB so can't delete item.
803 return MEDIA_SVC_PLUGIN_ERROR;
806 int delete_all_items_in_storage(void * handle, int storage_type, char ** err_msg)
808 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
811 __set_error_message(ERR_HANDLE, err_msg);
812 return MEDIA_SVC_PLUGIN_ERROR;
815 if(!STORAGE_VALID(storage_type)) {
816 __set_error_message(ERR_STORAGE_TYPE, err_msg);
817 return MEDIA_SVC_PLUGIN_ERROR;
820 if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_INTERNAL) {
822 ret = audio_svc_delete_all(handle, AUDIO_SVC_STORAGE_PHONE);
824 __set_error_message(ret, err_msg);
825 return MEDIA_SVC_PLUGIN_ERROR;
828 ret = minfo_delete_all_media_records(handle, MINFO_PHONE);
830 __set_error_message(ret, err_msg);
831 return MEDIA_SVC_PLUGIN_ERROR;
834 } else if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL) {
836 ret = audio_svc_delete_all(handle,AUDIO_SVC_STORAGE_MMC);
838 __set_error_message(ret, err_msg);
839 return MEDIA_SVC_PLUGIN_ERROR;
841 ret = minfo_delete_all_media_records(handle, MINFO_MMC);
843 __set_error_message(ret, err_msg);
844 return MEDIA_SVC_PLUGIN_ERROR;
848 return MEDIA_SVC_PLUGIN_ERROR_NONE;
851 int delete_all_invalid_items_in_storage(void * handle, int storage_type, char ** err_msg)
853 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
856 __set_error_message(ERR_HANDLE, err_msg);
857 return MEDIA_SVC_PLUGIN_ERROR;
860 if(!STORAGE_VALID(storage_type)) {
861 __set_error_message(ERR_STORAGE_TYPE, err_msg);
862 return MEDIA_SVC_PLUGIN_ERROR;
865 if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_INTERNAL) {
867 ret = audio_svc_delete_invalid_items(handle,AUDIO_SVC_STORAGE_PHONE);
869 __set_error_message(ret, err_msg);
870 return MEDIA_SVC_PLUGIN_ERROR;
873 ret = minfo_delete_invalid_media_records(handle, MINFO_PHONE);
875 __set_error_message(ret, err_msg);
876 return MEDIA_SVC_PLUGIN_ERROR;
879 } else if(storage_type == MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL) {
881 ret = audio_svc_delete_invalid_items(handle,AUDIO_SVC_STORAGE_MMC);
883 __set_error_message(ret, err_msg);
884 return MEDIA_SVC_PLUGIN_ERROR;
887 ret = minfo_delete_invalid_media_records(handle, MINFO_MMC);
889 __set_error_message(ret, err_msg);
890 return MEDIA_SVC_PLUGIN_ERROR;
894 return MEDIA_SVC_PLUGIN_ERROR_NONE;
897 int delete_all_items(void * handle, char ** err_msg)
899 int ret = MEDIA_SVC_PLUGIN_ERROR_NONE;
902 __set_error_message(ERR_HANDLE, err_msg);
903 return MEDIA_SVC_PLUGIN_ERROR;
906 ret = delete_all_items_in_storage(handle, MEDIA_SVC_PLUGIN_STORAGE_INTERNAL, err_msg);
908 return MEDIA_SVC_PLUGIN_ERROR;
910 ret = delete_all_items_in_storage(handle, MEDIA_SVC_PLUGIN_STORAGE_EXTERNAL, err_msg);
912 return MEDIA_SVC_PLUGIN_ERROR;
914 return MEDIA_SVC_PLUGIN_ERROR_NONE;
917 int update_begin(void)
919 return MEDIA_SVC_PLUGIN_ERROR_NONE;
924 return MEDIA_SVC_PLUGIN_ERROR_NONE;