Improve msc_metadata_update 67/212967/5
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 29 Aug 2019 03:09:13 +0000 (12:09 +0900)
committerhj kim <backto.kim@samsung.com>
Fri, 30 Aug 2019 00:31:59 +0000 (00:31 +0000)
Change-Id: Iee34dfa43a7e77b60a2de0f93a0c01a5d4a26631
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
CMakeLists.txt
include/media-svc-types.h [deleted file]
include/media-svc.h
plugin/media-content-plugin.c
src/common/media-svc-media.c
src/common/media-svc-storage.c
src/common/media-svc-util.c
src/common/media-svc.c
src/include/common/media-svc-media.h
src/include/common/media-svc-storage.h
src/include/common/media-svc-util.h

index 5542d43..45ad6b7 100644 (file)
@@ -101,4 +101,3 @@ INSTALL(TARGETS ${MEDIACONTENT-PLUGIN-LIB} LIBRARY DESTINATION ${LIB_INSTALL_DIR
 #INSTALL(TARGETS ${MEDIACONTENT-PLUGIN-LIB} LIBRARY DESTINATION /usr/lib)
 
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-svc.h DESTINATION include/media-service/)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/media-svc-types.h DESTINATION include/media-service/)
diff --git a/include/media-svc-types.h b/include/media-svc-types.h
deleted file mode 100755 (executable)
index 6f26dca..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * libmedia-service
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Hyunjun Ko <zzoon.ko@samsung.com>, Haejeong Kim <backto.kim@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-
-#ifndef _MEDIA_SVC_TYPES_H_
-#define _MEDIA_SVC_TYPES_H_
-
-/**
- * Type definition for scanning status
- */
-typedef enum {
-       MEDIA_SVC_SCAN_PREPARE          = 0,    /**< Prepare scanning*/
-       MEDIA_SVC_SCAN_PROCESSING       = 1,    /**< Process scanning*/
-       MEDIA_SVC_SCAN_STOP                     = 2,    /**< Stop scanning*/
-       MEDIA_SVC_SCAN_COMPLETE         = 3,    /**< Complete scanning*/
-       MEDIA_SVC_SCAN_MAX                      = 4,    /**< Invalid status*/
-} media_svc_scan_status_type_e;
-
-#endif /*_MEDIA_SVC_TYPES_H_*/
index b8d3776..10aef39 100755 (executable)
@@ -24,7 +24,6 @@
 #ifndef _MEDIA_SVC_H_
 #define _MEDIA_SVC_H_
 
-#include "media-svc-types.h"
 #include <media-util.h>
 #include <time.h>
 #include <stdbool.h>
@@ -62,9 +61,7 @@ int media_svc_check_db_upgrade(sqlite3 *handle, int user_version, uid_t uid);
 int media_svc_publish_noti(media_item_update_type_e update_type, const char *path, media_type_e media_type, const char *uuid, const char *mime_type);
 int media_svc_get_pinyin(const char *src_str, char **pinyin_str);
 int media_svc_check_pinyin_support(bool *support);
-int media_svc_update_item_begin(int data_cnt);
-int media_svc_update_item_end(uid_t uid);
-int media_svc_update_item_meta(const char *file_path, const char *storage_id, int storage_type, uid_t uid);
+int media_svc_update_item_meta(sqlite3 *handle, uid_t uid);
 
 int media_svc_generate_uuid(char **uuid);
 int media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid);
index c7a46b2..6a47bfd 100755 (executable)
@@ -130,19 +130,9 @@ int set_storage_scan_status(sqlite3 *handle, const char *storage_id, int status,
        return MS_MEDIA_ERR_NONE;
 }
 
-int update_item_begin(int item_cnt)
+int update_item_meta(sqlite3 *handle, uid_t uid)
 {
-       return media_svc_update_item_begin(item_cnt);
-}
-
-int update_item_end(uid_t uid)
-{
-       return media_svc_update_item_end(uid);
-}
-
-int update_item_meta(const char *file_path, const char *storage_id, int storage_type, uid_t uid)
-{
-       return media_svc_update_item_meta(file_path, storage_id, storage_type, uid);
+       return media_svc_update_item_meta(handle, uid);
 }
 
 int insert_item_scan(sqlite3 *handle, const char *storage_id, const char *file_path, int storage_type, uid_t uid)
index 17bcfac..0fe9de4 100755 (executable)
@@ -233,31 +233,7 @@ int _media_svc_update_meta_with_data(media_svc_content_info_s *content_info)
        char *test_sql = sqlite3_mprintf("%f, %f, %f", content_info->media_meta.longitude, content_info->media_meta.latitude, content_info->media_meta.altitude);
        SQLITE3_SAFE_FREE(test_sql);
 
-       /*Update Pinyin If Support Pinyin*/
-       if (_media_svc_check_pinyin_support()) {
-               if (STRING_VALID(content_info->file_name))
-                       _media_svc_get_pinyin_str(content_info->file_name, &content_info->file_name_pinyin);
-               if (STRING_VALID(content_info->media_meta.title))
-                       _media_svc_get_pinyin_str(content_info->media_meta.title, &content_info->media_meta.title_pinyin);
-               if (STRING_VALID(content_info->media_meta.album))
-                       _media_svc_get_pinyin_str(content_info->media_meta.album, &content_info->media_meta.album_pinyin);
-               if (STRING_VALID(content_info->media_meta.artist))
-                       _media_svc_get_pinyin_str(content_info->media_meta.artist, &content_info->media_meta.artist_pinyin);
-               if (STRING_VALID(content_info->media_meta.album_artist))
-                       _media_svc_get_pinyin_str(content_info->media_meta.album_artist, &content_info->media_meta.album_artist_pinyin);
-               if (STRING_VALID(content_info->media_meta.genre))
-                       _media_svc_get_pinyin_str(content_info->media_meta.genre, &content_info->media_meta.genre_pinyin);
-               if (STRING_VALID(content_info->media_meta.composer))
-                       _media_svc_get_pinyin_str(content_info->media_meta.composer, &content_info->media_meta.composer_pinyin);
-               if (STRING_VALID(content_info->media_meta.copyright))
-                       _media_svc_get_pinyin_str(content_info->media_meta.copyright, &content_info->media_meta.copyright_pinyin);
-               if (STRING_VALID(content_info->media_meta.description))
-                       _media_svc_get_pinyin_str(content_info->media_meta.description, &content_info->media_meta.description_pinyin);
-       }
-
-       char *sql = sqlite3_mprintf("UPDATE '%q' SET media_title=%Q, media_album=%Q, media_artist=%Q, media_album_artist=%Q, media_genre=%Q, media_composer=%Q, media_copyright=%Q, media_description=%Q, \
-               media_file_name_pinyin=%Q, media_title_pinyin=%Q, media_album_pinyin=%Q, media_artist_pinyin=%Q, media_album_artist_pinyin=%Q, media_genre_pinyin=%Q, media_composer_pinyin=%Q, media_copyright_pinyin=%Q, media_description_pinyin=%Q \
-               WHERE path=%Q;",
+       char *sql = sqlite3_mprintf("UPDATE '%q' SET media_title=%Q, media_album=%Q, media_artist=%Q, media_album_artist=%Q, media_genre=%Q, media_composer=%Q, media_copyright=%Q, media_description=%Q WHERE media_path=%Q;",
                                content_info->storage_uuid,
                                content_info->media_meta.title,
                                content_info->media_meta.album,
@@ -267,15 +243,6 @@ int _media_svc_update_meta_with_data(media_svc_content_info_s *content_info)
                                content_info->media_meta.composer,
                                content_info->media_meta.copyright,
                                content_info->media_meta.description,
-                               content_info->file_name_pinyin,
-                               content_info->media_meta.title_pinyin,
-                               content_info->media_meta.album_pinyin,
-                               content_info->media_meta.artist_pinyin,
-                               content_info->media_meta.album_artist_pinyin,
-                               content_info->media_meta.genre_pinyin,
-                               content_info->media_meta.composer_pinyin,
-                               content_info->media_meta.copyright_pinyin,
-                               content_info->media_meta.description_pinyin,
                                content_info->path
                                );
 
@@ -568,6 +535,34 @@ int _media_svc_append_query_list(const char *query, uid_t uid)
        return ret;
 }
 
+int _media_svc_get_media(sqlite3 *handle, const char *sql, GArray **path_list)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+       media_svc_file_s *file_info = NULL;
+
+       media_svc_retvm_if(!sql, MS_MEDIA_ERR_INVALID_PARAMETER, "query is NULL");
+       media_svc_retvm_if(!path_list, MS_MEDIA_ERR_INVALID_PARAMETER, "array is NULL");
+
+       ret = _media_svc_sql_prepare_to_step_simple(handle, sql, &sql_stmt);
+       media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "_media_svc_sql_prepare_to_step_simple() failed [%d]", ret);
+       while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
+               file_info = malloc(sizeof(media_svc_file_s));
+               if (!file_info) {
+                       media_svc_error("Allcation failed");
+                       continue;
+               }
+
+               SAFE_STRLCPY(file_info->path, (char *)sqlite3_column_text(sql_stmt, 0), sizeof(file_info->path));
+               SAFE_STRLCPY(file_info->storage_id, (char *)sqlite3_column_text(sql_stmt, 1), sizeof(file_info->storage_id));
+               g_array_append_val(*path_list, file_info);
+       }
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return ret;
+}
+
 int _media_svc_get_noti_info(sqlite3 *handle, const char *storage_id, const char *path, media_svc_noti_item **item)
 {
        int ret = MS_MEDIA_ERR_NONE;
index f891e36..a39ea02 100755 (executable)
@@ -281,3 +281,28 @@ int _media_svc_get_storage_uuid(sqlite3 *handle, const char *path, char *storage
 
        return ret;
 }
+
+int _media_svc_get_storage_path(sqlite3 *handle, GArray **storage_path)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+       sqlite3_stmt *sql_stmt = NULL;
+       char *sql = NULL;
+       char *root_path = NULL;
+
+       media_svc_retvm_if(!storage_path, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_path is NULL");
+
+       sql = sqlite3_mprintf("SELECT storage_path FROM %q WHERE validity=1", MEDIA_SVC_DB_TABLE_STORAGE);
+
+       ret = _media_svc_sql_prepare_to_step_simple(handle, sql, &sql_stmt);
+       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
+
+       while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
+               root_path = g_strdup((const char *)sqlite3_column_text(sql_stmt, 0));
+               g_array_append_val(*storage_path, root_path);
+       }
+
+       SQLITE3_FINALIZE(sql_stmt);
+
+       return ret;
+}
+
index d6d1347..25493a3 100755 (executable)
@@ -1194,96 +1194,87 @@ GET_WIDTH_HEIGHT:
        return MS_MEDIA_ERR_NONE;
 }
 
-int _media_svc_extract_music_metadata_for_update(media_svc_content_info_s *content_info, media_svc_media_type_e media_type)
+int _media_svc_extract_music_metadata_for_update(media_svc_content_info_s *content_info, const char *storage_id, const char *path)
 {
        MMHandleType tag = 0;
        char *p = NULL;
        int size = -1;
        int mmf_error = FILEINFO_ERROR_NONE;
        char *err_attr_name = NULL;
-       int album_id = 0;
 
-       /*Get Content Tag attribute ===========*/
+       content_info->storage_uuid = g_strdup(storage_id);
+       content_info->path = g_strdup(path);
+
        mmf_error = mm_file_create_tag_attrs(&tag, content_info->path);
+       if (mmf_error != FILEINFO_ERROR_NONE)
+               return MS_MEDIA_ERR_INTERNAL;
 
-       if (mmf_error == FILEINFO_ERROR_NONE) {
-               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM, &p, &size, NULL);
-               if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
-                       content_info->media_meta.album = g_strdup(p);
-               else
-                       SAFE_FREE(err_attr_name);
+       mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM, &p, &size, NULL);
+       if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+               content_info->media_meta.album = g_strdup(p);
+       else
+               SAFE_FREE(err_attr_name);
 
-               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTIST, &p, &size, NULL);
-               if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
-                       content_info->media_meta.artist = g_strdup(p);
-               else
-                       SAFE_FREE(err_attr_name);
+       mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTIST, &p, &size, NULL);
+       if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+               content_info->media_meta.artist = g_strdup(p);
+       else
+               SAFE_FREE(err_attr_name);
 
-               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM_ARTIST, &p, &size, NULL);
-               if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
-                       content_info->media_meta.album_artist = g_strdup(p);
-               else
-                       SAFE_FREE(err_attr_name);
+       mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM_ARTIST, &p, &size, NULL);
+       if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+               content_info->media_meta.album_artist = g_strdup(p);
+       else
+               SAFE_FREE(err_attr_name);
 
-               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_GENRE, &p, &size, NULL);
-               if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
-                       content_info->media_meta.genre = g_strdup(p);
+       mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_GENRE, &p, &size, NULL);
+       if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+               content_info->media_meta.genre = g_strdup(p);
+       else
+               SAFE_FREE(err_attr_name);
 
-                       /* If genre is Ringtone, it's categorized as sound. But this logic is commented */
-                       /*
-                       if ((strcasecmp("Ringtone", p) == 0) | (strcasecmp("Alert tone", p) == 0)) {
-                               content_info->media_type = MEDIA_SVC_MEDIA_TYPE_SOUND;
-                       }
-                       */
+       mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TITLE, &p, &size, NULL);
+       if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+               if (!isspace(*p)) {
+                       content_info->media_meta.title = g_strdup(p);
                } else {
-                       SAFE_FREE(err_attr_name);
-               }
-
-               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TITLE, &p, &size, NULL);
-               if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
-                       if (!isspace(*p)) {
-                               content_info->media_meta.title = g_strdup(p);
-                       } else {
-                               int idx = 0;
+                       int idx = 0;
 
-                               for (idx = 0; idx < size; idx++) {
-                                       if (isspace(*p)) {
-                                               media_svc_debug("SPACE [%s]", p);
-                                               p++;
-                                               continue;
-                                       } else {
-                                               media_svc_debug("Not SPACE [%s]", p);
-                                               content_info->media_meta.title = g_strdup(p);
-                                               break;
-                                       }
+                       for (idx = 0; idx < size; idx++) {
+                               if (isspace(*p)) {
+                                       media_svc_debug("SPACE [%s]", p);
+                                       p++;
+                                       continue;
+                               } else {
+                                       media_svc_debug("Not SPACE [%s]", p);
+                                       content_info->media_meta.title = g_strdup(p);
+                                       break;
                                }
                        }
                }
+       }
 
-               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DESCRIPTION, &p, &size, NULL);
-               if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
-                       content_info->media_meta.description = g_strdup(p);
-               else
-                       SAFE_FREE(err_attr_name);
+       mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DESCRIPTION, &p, &size, NULL);
+       if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+               content_info->media_meta.description = g_strdup(p);
+       else
+               SAFE_FREE(err_attr_name);
 
-               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_AUTHOR, &p, &size, NULL);
-               if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
-                       content_info->media_meta.composer = g_strdup(p);
-               else
-                       SAFE_FREE(err_attr_name);
+       mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_AUTHOR, &p, &size, NULL);
+       if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+               content_info->media_meta.composer = g_strdup(p);
+       else
+               SAFE_FREE(err_attr_name);
 
-               mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_COPYRIGHT, &p, &size, NULL);
-               if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
-                       content_info->media_meta.copyright = g_strdup(p);
-               else
-                       SAFE_FREE(err_attr_name);
+       mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_COPYRIGHT, &p, &size, NULL);
+       if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
+               content_info->media_meta.copyright = g_strdup(p);
+       else
+               SAFE_FREE(err_attr_name);
 
-               mmf_error = mm_file_destroy_tag_attrs(tag);
-               if (mmf_error != FILEINFO_ERROR_NONE)
-                       media_svc_error("fail to free tag attr - err(%x)", mmf_error);
-       } else {
-               content_info->album_id = album_id;
-       }
+       mmf_error = mm_file_destroy_tag_attrs(tag);
+       if (mmf_error != FILEINFO_ERROR_NONE)
+               media_svc_error("fail to free tag attr - err(%x)", mmf_error);
 
        return MS_MEDIA_ERR_NONE;
 }
index 483ff26..1e81ccc 100755 (executable)
@@ -38,9 +38,6 @@ static __thread int g_media_svc_item_validity_cur_data_cnt = 0;
 static __thread int g_media_svc_insert_item_data_cnt = 1;
 static __thread int g_media_svc_insert_item_cur_data_cnt = 0;
 
-static __thread int g_media_svc_update_item_data_cnt = 1;
-static __thread int g_media_svc_update_item_cur_data_cnt = 0;
-
 /* Flag for items to be published by notification */
 static __thread bool g_insert_with_noti = false;
 
@@ -663,85 +660,84 @@ int media_svc_check_db_upgrade(sqlite3 *handle, int user_version, uid_t uid)
        return _media_svc_check_db_upgrade(handle, user_version, uid);
 }
 
-int media_svc_update_item_begin(int data_cnt)
+static void __media_svc_noti_all_storage(sqlite3 *handle, uid_t uid)
 {
-       media_svc_debug("Transaction data count : [%d]", data_cnt);
-
-       media_svc_retvm_if(data_cnt < 1, MS_MEDIA_ERR_INVALID_PARAMETER, "data_cnt shuld be bigger than 1");
+       int ret = MS_MEDIA_ERR_NONE;
+       char *root_path = NULL;
+       GArray *path_list = NULL;
 
-       g_media_svc_update_item_data_cnt = data_cnt;
-       g_media_svc_update_item_cur_data_cnt = 0;
+       ms_user_get_internal_root_path(uid, &root_path);
+       ret = _media_svc_publish_dir_noti(MS_MEDIA_ITEM_UPDATE, root_path, NULL, 0);
+       if (ret != MS_MEDIA_ERR_NONE)
+               media_svc_error("Fail to send noti");
 
-       return MS_MEDIA_ERR_NONE;
-}
+       SAFE_FREE(root_path);
 
-int media_svc_update_item_end(uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
+       path_list = g_array_new(FALSE, FALSE, sizeof(char *));
+       _media_svc_get_storage_path(handle, &path_list);
 
-       media_svc_debug_fenter();
+       while (path_list->len != 0) {
+               root_path = g_array_index(path_list , char *, 0);
+               g_array_remove_index(path_list, 0);
 
-       if (g_media_svc_update_item_cur_data_cnt > 0)
-               ret = _media_svc_list_query_do(MEDIA_SVC_QUERY_UPDATE_ITEM, uid);
+               ret = _media_svc_publish_dir_noti(MS_MEDIA_ITEM_UPDATE, root_path, NULL, 0);
+               if (ret != MS_MEDIA_ERR_NONE)
+                       media_svc_error("Fail to send noti");
 
-       g_media_svc_update_item_data_cnt = 1;
-       g_media_svc_update_item_cur_data_cnt = 0;
+               SAFE_FREE(root_path);
+       }
 
-       return ret;
+       g_array_free(path_list, false);
 }
 
-int media_svc_update_item_meta(const char *file_path, const char *storage_id, int storage_type, uid_t uid)
+int media_svc_update_item_meta(sqlite3 *handle, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
+       /* NOTICE : After 6.0, change 'media_view' to 'media', add 'AND validity=1', and no need storage id */
+       char *sql = NULL;
        media_svc_content_info_s content_info;
-       memset(&content_info, 0, sizeof(media_svc_content_info_s));
+       media_svc_file_s *file_info = NULL;
+       GArray *path_list = NULL;
 
-       /*Set media info*/
-       ret = _media_svc_set_media_info(&content_info, storage_id, storage_type, file_path, false);
-       if (ret != MS_MEDIA_ERR_NONE)
-               return ret;
-
-       if (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC)
-               ret = _media_svc_extract_music_metadata_for_update(&content_info, content_info.media_type);
-       else {
-               _media_svc_destroy_content_info(&content_info);
-               return MS_MEDIA_ERR_NONE;
-       }
+       path_list = g_array_new(FALSE, FALSE, sizeof(media_svc_file_s *));
+       media_svc_retvm_if(!path_list, MS_MEDIA_ERR_OUT_OF_MEMORY, "Allocation failed");
 
+       sql = sqlite3_mprintf("SELECT media_path, storage_uuid FROM %q WHERE media_type=3", MEDIA_SVC_DB_VIEW_MEDIA);
+       ret = _media_svc_get_media(handle, sql, &path_list);
        if (ret != MS_MEDIA_ERR_NONE) {
-               _media_svc_destroy_content_info(&content_info);
+               media_svc_error("Fail to get media list");
+               g_array_free(path_list, false);
                return ret;
        }
 
-       if (g_media_svc_update_item_data_cnt == 1) {
-
-               ret = _media_svc_update_meta_with_data(&content_info);
-               media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
-
-       } else if (g_media_svc_update_item_cur_data_cnt < (g_media_svc_update_item_data_cnt - 1)) {
+       while (path_list->len != 0) {
+               file_info = g_array_index(path_list, media_svc_file_s *, 0);
+               g_array_remove_index(path_list, 0);
 
-               ret = _media_svc_update_meta_with_data(&content_info);
-               media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
-
-               g_media_svc_update_item_cur_data_cnt++;
-
-       } else if (g_media_svc_update_item_cur_data_cnt == (g_media_svc_update_item_data_cnt - 1)) {
+               memset(&content_info, 0, sizeof(media_svc_content_info_s));
+               ret = _media_svc_extract_music_metadata_for_update(&content_info, file_info->storage_id, file_info->path);
+               if (ret != MS_MEDIA_ERR_NONE) {
+                       media_svc_error("Fail to extract metadata");
+                       _media_svc_destroy_content_info(&content_info);
+                       SAFE_FREE(file_info);
+                       continue;
+               }
 
                ret = _media_svc_update_meta_with_data(&content_info);
-               media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
-
-               ret = _media_svc_list_query_do(MEDIA_SVC_QUERY_UPDATE_ITEM, uid);
-               media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
-
-               g_media_svc_update_item_cur_data_cnt = 0;
+               if (ret != MS_MEDIA_ERR_NONE)
+                       media_svc_error("Fail to append item[%s]", content_info.path);
 
-       } else {
-               media_svc_error("Error in media_svc_update_item_meta");
                _media_svc_destroy_content_info(&content_info);
-               return MS_MEDIA_ERR_INTERNAL;
+               SAFE_FREE(file_info);
        }
 
-       _media_svc_destroy_content_info(&content_info);
+       g_array_free(path_list, false);
+
+       ret = _media_svc_list_query_do(MEDIA_SVC_QUERY_UPDATE_ITEM, uid);
+       media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "_media_svc_list_query_do failed");
+
+       /* Noti for this */
+       __media_svc_noti_all_storage(handle, uid);
 
        return ret;
 }
index c36861b..6b7d0cd 100755 (executable)
@@ -43,5 +43,6 @@ int _media_svc_get_noti_info(sqlite3 *handle, const char *storage_id, const char
 int _media_svc_update_meta_with_data(media_svc_content_info_s *content_info);
 
 int _media_svc_append_query_list(const char *query, uid_t uid);
+int _media_svc_get_media(sqlite3 *handle, const char *sql, GArray **path_list);
 
 #endif /*_MEDIA_SVC_MEDIA_H_*/
index f8b727d..ccc482b 100755 (executable)
@@ -30,5 +30,6 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons
 int _media_svc_delete_invalid_storage(sqlite3 *handle, uid_t uid);
 int _media_svc_update_storage_validity(const char *storage_id, int validity, uid_t uid);
 int _media_svc_get_storage_uuid(sqlite3 *handle, const char *path, char *storage_id, uid_t uid);
+int _media_svc_get_storage_path(sqlite3 *handle, GArray **storage_path);
 
 #endif /*_MEDIA_SVC_STORAGE_H_*/
index f8a5e7a..2b69c46 100755 (executable)
@@ -112,6 +112,14 @@ typedef struct {
 } media_svc_content_info_s;
 
 /**
+ * Media data information
+ */
+typedef struct {
+       char storage_id[MEDIA_SVC_UUID_SIZE + 1];
+       char path[MEDIA_SVC_PATHNAME_SIZE];
+} media_svc_file_s;
+
+/**
  * Type definition for content type
  */
 typedef enum {
@@ -138,7 +146,7 @@ void _media_svc_destroy_content_info(media_svc_content_info_s *content_info);
 int _media_svc_create_thumbnail(const char *path, char *thumb_path, media_svc_media_type_e media_type, uid_t uid);
 int _media_svc_get_pinyin_str(const char *src_str, char **pinyin_str);
 bool _media_svc_check_pinyin_support(void);
-int _media_svc_extract_music_metadata_for_update(media_svc_content_info_s *content_info, media_svc_media_type_e media_type);
+int _media_svc_extract_music_metadata_for_update(media_svc_content_info_s *content_info, const char *storage_id, const char *path);
 int _media_svc_get_media_type(const char *path, int *mediatype);
 bool _media_svc_is_valid_storage_type(ms_user_storage_type_e storage_type);