Reduce DB connection when noti 11/206011/5 submit/tizen/20190515.071609
authorMinje Ahn <minje.ahn@samsung.com>
Mon, 13 May 2019 07:59:29 +0000 (16:59 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Wed, 15 May 2019 07:07:10 +0000 (16:07 +0900)
Change-Id: Iaa04ae49271fdb26df960ffd3233f60a778ec291
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
include/media-svc.h
plugin/media-content-plugin.c
src/common/media-svc-media.c
src/common/media-svc-noti.c
src/common/media-svc-util.c
src/common/media-svc.c
src/include/common/media-svc-media.h
src/include/common/media-svc-noti.h
src/include/common/media-svc-util.h

index 3a930cb..b5c9b29 100755 (executable)
@@ -44,15 +44,22 @@ int media_svc_insert_item_begin(int data_cnt, int with_noti, int from_pid);
 int media_svc_insert_item_end(uid_t uid);
 int media_svc_insert_item_bulk(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid);
 int media_svc_insert_item_immediately(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid);
-int media_svc_move_item(sqlite3 *handle, const char *src_path, const char *dest_path, uid_t uid);
+int media_svc_move_item(sqlite3 *handle,
+                                                               const char *src_path,
+                                                               const char *dest_path,
+                                                               const char *media_id,
+                                                               int media_type,
+                                                               const char *mime_type,
+                                                               uid_t uid);
+
 int media_svc_set_item_validity_begin(int data_cnt);
 int media_svc_set_item_validity_end(uid_t uid);
 int media_svc_set_item_validity(const char *storage_id, const char *path, int validity, uid_t uid);
 int media_svc_delete_item_by_path(sqlite3 *handle, bool is_direct, const char *storage_id, const char *path, uid_t uid);
 int media_svc_refresh_item(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid);
-int media_svc_send_dir_update_noti(sqlite3 *handle, const char *storage_id, const char *dir_path, const char *folder_id, media_item_update_type_e update_type, int pid);
+int media_svc_send_dir_update_noti(const char *dir_path, const char *folder_id, media_item_update_type_e update_type, int pid);
 int media_svc_check_db_upgrade(sqlite3 *handle, int user_version, uid_t uid);
-int media_svc_publish_noti(media_item_type_e update_item, 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_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);
index b1f890b..8c701fa 100755 (executable)
@@ -66,9 +66,9 @@ int delete_item(sqlite3 *handle, const char *storage_id, const char *file_path,
        return media_svc_delete_item_by_path(handle, true, storage_id, file_path, uid);
 }
 
-int send_dir_update_noti(sqlite3 *handle, const char *storage_id, const char *dir_path, const char *folder_id, int update_type, int pid)
+int send_dir_update_noti(const char *dir_path, const char *folder_id, int update_type, int pid)
 {
-       return media_svc_send_dir_update_noti(handle, storage_id, dir_path, folder_id, (media_item_update_type_e)update_type, pid);
+       return media_svc_send_dir_update_noti(dir_path, folder_id, (media_item_update_type_e)update_type, pid);
 }
 
 int check_db(sqlite3 *handle, uid_t uid)
index c6ac6a2..406e895 100755 (executable)
@@ -215,10 +215,7 @@ int _media_svc_insert_item_with_data(sqlite3 *handle, bool is_direct, const char
                        ret = _media_svc_sql_query(sql, uid);
 
                SQLITE3_SAFE_FREE(sql);
-               if (ret != MS_MEDIA_ERR_NONE) {
-                       media_svc_error("failed to insert item");
-                       return ret;
-               }
+               media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "failed to insert item");
        } else {
                media_svc_sec_debug("Query[%s]", sql);
                _media_svc_sql_query_add(&g_media_svc_insert_item_query_list, &sql);
@@ -579,55 +576,29 @@ int _media_svc_append_query_list(const char *query, uid_t uid)
        return ret;
 }
 
-int _media_svc_get_noti_info(sqlite3 *handle, const char *storage_id, const char *path, int update_item, media_svc_noti_item **item)
+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;
        sqlite3_stmt *sql_stmt = NULL;
        char *sql = NULL;
-       int is_root_dir = FALSE;
 
        media_svc_retvm_if(item == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "item is NULL");
        media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
        media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
 
-       if (update_item == MS_MEDIA_ITEM_FILE)
-               sql = sqlite3_mprintf("SELECT media_id, media_type, media_mime_type FROM '%q' WHERE media_path=%Q", storage_id, path);
-       else if (update_item == MS_MEDIA_ITEM_DIRECTORY)
-               sql = sqlite3_mprintf("SELECT folder_id FROM '%q' WHERE folder_path=%Q AND storage_uuid='%q'", MEDIA_SVC_DB_TABLE_FOLDER, path, storage_id);
-       else {
-               media_svc_error("_media_svc_get_noti_info failed : update item");
-               return MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
-
+       sql = sqlite3_mprintf("SELECT media_id, media_type, media_mime_type FROM '%q' WHERE media_path=%Q", storage_id, path);
        ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
-
-       if (ret != MS_MEDIA_ERR_NONE) {
-               if (ret == MS_MEDIA_ERR_DB_NO_RECORD && update_item == MS_MEDIA_ITEM_DIRECTORY) {
-                       media_svc_debug("This is root directory of media");
-                       sql_stmt = NULL;
-                       is_root_dir = TRUE;
-               } else {
-                       media_svc_error("error when _media_svc_get_noti_info. err = [%d]", ret);
-                       return ret;
-               }
-       }
+       media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "_media_svc_sql_prepare_to_step() failed [%d]", ret);
 
        *item = calloc(1, sizeof(media_svc_noti_item));
        if (*item == NULL) {
-               media_svc_error("_media_svc_get_noti_info failed : calloc");
+               media_svc_error("Allocation failed");
                return MS_MEDIA_ERR_OUT_OF_MEMORY;
        }
 
-       if (update_item == MS_MEDIA_ITEM_FILE) {
-               (*item)->media_uuid = g_strdup((const char *)sqlite3_column_text(sql_stmt, 0));
-               (*item)->media_type = sqlite3_column_int(sql_stmt, 1);
-               (*item)->mime_type = g_strdup((const char *)sqlite3_column_text(sql_stmt, 2));
-       } else if (update_item == MS_MEDIA_ITEM_DIRECTORY) {
-               if (is_root_dir)
-                       (*item)->media_uuid = NULL;
-               else
-                       (*item)->media_uuid = g_strdup((const char *)sqlite3_column_text(sql_stmt, 0));
-       }
+       (*item)->media_uuid = g_strdup((const char *)sqlite3_column_text(sql_stmt, 0));
+       (*item)->media_type = sqlite3_column_int(sql_stmt, 1);
+       (*item)->mime_type = g_strdup((const char *)sqlite3_column_text(sql_stmt, 2));
 
        SQLITE3_FINALIZE(sql_stmt);
 
index f542c5e..733dc2c 100755 (executable)
@@ -48,55 +48,28 @@ static int __media_svc_publish_noti_by_item(media_svc_noti_item *noti_item)
        return ret;
 }
 
-int _media_svc_publish_noti(media_item_type_e update_item,
-                                       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_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 ret = MS_MEDIA_ERR_NONE;
+       media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
 
-       if (STRING_VALID(path)) {
-               ret = media_db_update_send_internal(getpid(), update_item, update_type, (char *)path, (char *)uuid, media_type, (char *)mime_type);
-               if (ret != MS_MEDIA_ERR_NONE) {
-                       media_svc_error("media_db_update_send_internal failed : %d [%s]", ret, path);
-                       ret = MS_MEDIA_ERR_SEND_NOTI_FAIL;
-               } else {
-                       media_svc_debug("media_db_update_send_internal success [%d][%d]", update_item, update_type);
-               }
-       } else {
-               media_svc_debug("invalid path");
-               ret = MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
+       ret = media_db_update_send_internal(getpid(), MS_MEDIA_ITEM_FILE, update_type, (char *)path, (char *)uuid, media_type, (char *)mime_type);
+       media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Send noti failed[%d][%s]", ret, path);
+
+       media_svc_debug("Send noti [%s]", path);
 
        return ret;
 }
 
-int _media_svc_publish_dir_noti_v2(media_item_type_e update_item,
-                                                       media_item_update_type_e update_type,
-                                                       const char *path,
-                                                       media_type_e media_type,
-                                                       const char *uuid,
-                                                       const char *mime_type,
-                                                       int pid
-)
+int _media_svc_publish_dir_noti(media_item_update_type_e update_type, const char *path, const char *uuid, int pid)
 {
        int ret = MS_MEDIA_ERR_NONE;
+       media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
 
-       if (STRING_VALID(path)) {
-               ret = media_db_update_send_internal(pid, update_item, update_type, (char *)path, (char *)uuid, media_type, (char *)mime_type);
-               if (ret != MS_MEDIA_ERR_NONE) {
-                       media_svc_error("Send noti failed : %d [%s]", ret, path);
-                       ret = MS_MEDIA_ERR_SEND_NOTI_FAIL;
-               } else {
-                       media_svc_debug("Send noti success [%d][%d]", update_item, update_type);
-               }
-       } else {
-               media_svc_debug("invalid path");
-               ret = MS_MEDIA_ERR_INVALID_PARAMETER;
-       }
+       ret = media_db_update_send_internal(pid, MS_MEDIA_ITEM_DIRECTORY, update_type, (char *)path, (char *)uuid, MS_MEDIA_UNKNOWN, NULL);
+       media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Send dir noti failed[%d][%s]", ret, path);
+
+       media_svc_debug("Send dir noti [%s]", path);
 
        return ret;
 }
index 4758449..2e2a03b 100755 (executable)
@@ -819,13 +819,13 @@ int _media_svc_set_default_value(media_svc_content_info_s *content_info, bool re
        return MS_MEDIA_ERR_NONE;
 }
 
-int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, ms_user_storage_type_e storage_type,
-                       const char *path, media_svc_media_type_e *media_type, bool refresh)
+int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, bool refresh)
 {
        int ret = MS_MEDIA_ERR_NONE;
        char * media_uuid = NULL;
        bool drm_type = false;
        char mime_type[256] = {0, };
+       media_svc_media_type_e media_type;
 
        media_svc_retvm_if(_media_svc_check_storage_type(storage_type) != TRUE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid storage_type");
        media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
@@ -877,19 +877,19 @@ int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char
        media_svc_debug("mime [%s]", mime_type);
        content_info->is_drm = drm_type;
 
-       ret = __media_svc_get_media_type(path, mime_type, media_type);
+       ret = __media_svc_get_media_type(path, mime_type, &media_type);
        media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, content_info);
-       if ((*media_type < MEDIA_SVC_MEDIA_TYPE_IMAGE) || (*media_type > MEDIA_SVC_MEDIA_TYPE_OTHER)) {
-               media_svc_error("invalid media_type condition[%d]", *media_type);
+       if ((media_type < MEDIA_SVC_MEDIA_TYPE_IMAGE) || (media_type > MEDIA_SVC_MEDIA_TYPE_OTHER)) {
+               media_svc_error("invalid media_type condition[%d]", media_type);
                return MS_MEDIA_ERR_INVALID_PARAMETER;
        }
 
        content_info->mime_type = g_strdup(mime_type);
        media_svc_retv_del_if(content_info->mime_type == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
 
-       media_svc_sec_debug("storage[%d], path[%s], media_type[%d]", storage_type, path, *media_type);
+       media_svc_sec_debug("storage[%d], path[%s], media_type[%d]", storage_type, path, media_type);
 
-       content_info->media_type = *media_type;
+       content_info->media_type = media_type;
 
        return MS_MEDIA_ERR_NONE;
 }
index aab6eb5..2cdcf17 100755 (executable)
@@ -235,7 +235,6 @@ int media_svc_insert_item_bulk(sqlite3 *handle, const char *storage_id, ms_user_
 {
        int ret = MS_MEDIA_ERR_NONE;
        char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, };
-       media_svc_media_type_e media_type;
 
        media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
        media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
@@ -247,16 +246,16 @@ int media_svc_insert_item_bulk(sqlite3 *handle, const char *storage_id, ms_user_
 
        /*Set media info*/
        /* if drm_contentinfo is not NULL, the file is OMA DRM.*/
-       ret = _media_svc_set_media_info(&content_info, storage_id, storage_type, path, &media_type, FALSE);
+       ret = _media_svc_set_media_info(&content_info, storage_id, storage_type, path, FALSE);
        if (ret != MS_MEDIA_ERR_NONE)
                return ret;
 
-       if (media_type == MEDIA_SVC_MEDIA_TYPE_OTHER
-       || (media_type == MEDIA_SVC_MEDIA_TYPE_PVR)
-       || (media_type == MEDIA_SVC_MEDIA_TYPE_UHD)
-       || (media_type == MEDIA_SVC_MEDIA_TYPE_SCSA))
-               media_svc_debug("Do nothing[%d]", media_type);
-       else if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE)
+       if (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_OTHER
+       || (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_PVR)
+       || (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_UHD)
+       || (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_SCSA))
+               media_svc_debug("Do nothing[%d]", content_info.media_type);
+       else if (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE)
                ret = _media_svc_extract_image_metadata(&content_info);
        else
                ret = _media_svc_extract_media_metadata(handle, true, &content_info, uid);
@@ -324,7 +323,6 @@ int media_svc_insert_item_immediately(sqlite3 *handle, const char *storage_id, m
 {
        int ret = MS_MEDIA_ERR_NONE;
        char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, };
-       media_svc_media_type_e media_type;
 
        media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
        media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL");
@@ -335,16 +333,16 @@ int media_svc_insert_item_immediately(sqlite3 *handle, const char *storage_id, m
        memset(&content_info, 0, sizeof(media_svc_content_info_s));
 
        /*Set media info*/
-       ret = _media_svc_set_media_info(&content_info, storage_id, storage_type, path, &media_type, FALSE);
+       ret = _media_svc_set_media_info(&content_info, storage_id, storage_type, path, FALSE);
        if (ret != MS_MEDIA_ERR_NONE)
                return ret;
 
-       if (media_type == MEDIA_SVC_MEDIA_TYPE_OTHER
-       || (media_type == MEDIA_SVC_MEDIA_TYPE_PVR)
-       || (media_type == MEDIA_SVC_MEDIA_TYPE_UHD)
-       || (media_type == MEDIA_SVC_MEDIA_TYPE_SCSA)) {
+       if (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_OTHER
+       || (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_PVR)
+       || (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_UHD)
+       || (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_SCSA)) {
                /*Do nothing.*/
-       } else if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) {
+       } else if (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) {
                ret = _media_svc_extract_image_metadata(&content_info);
        } else {
                ret = _media_svc_extract_media_metadata(handle, false, &content_info, uid);
@@ -361,10 +359,10 @@ int media_svc_insert_item_immediately(sqlite3 *handle, const char *storage_id, m
 
        /* Extracting thumbnail */
        if (content_info.thumbnail_path == NULL) {
-               if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
+               if (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || content_info.media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
                        char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
 
-                       ret = _media_svc_create_thumbnail(content_info.path, thumb_path, media_type, uid);
+                       ret = _media_svc_create_thumbnail(content_info.path, thumb_path, content_info.media_type, uid);
                        if (ret == MS_MEDIA_ERR_NONE)
                                content_info.thumbnail_path = g_strdup(thumb_path);
                }
@@ -374,7 +372,7 @@ int media_svc_insert_item_immediately(sqlite3 *handle, const char *storage_id, m
 
        if (ret == MS_MEDIA_ERR_NONE) {
                media_svc_debug("Insertion is successful. Sending noti for this");
-               _media_svc_publish_noti(MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_INSERT, content_info.path, content_info.media_type, content_info.media_uuid, content_info.mime_type);
+               _media_svc_publish_noti(MS_MEDIA_ITEM_INSERT, content_info.path, content_info.media_type, content_info.media_uuid, content_info.mime_type);
        } else if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) {
                media_svc_error("This item is already inserted. This may be normal operation because other process already did this");
        }
@@ -383,7 +381,13 @@ int media_svc_insert_item_immediately(sqlite3 *handle, const char *storage_id, m
        return ret;
 }
 
-int media_svc_move_item(sqlite3 *handle, const char *src_path, const char *dest_path, uid_t uid)
+int media_svc_move_item(sqlite3 *handle,
+                                                               const char *src_path,
+                                                               const char *dest_path,
+                                                               const char *media_id,
+                                                               int media_type,
+                                                               const char *mime_type,
+                                                               uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
        char *file_name = NULL;
@@ -395,13 +399,14 @@ int media_svc_move_item(sqlite3 *handle, const char *src_path, const char *dest_
        char dst_stg_id[MEDIA_SVC_UUID_SIZE + 1] = {0, };
        ms_user_storage_type_e org_stg_type = MS_USER_STORAGE_INTERNAL;
        ms_user_storage_type_e dst_stg_type = MS_USER_STORAGE_INTERNAL;
-       int media_type = -1;
 
        media_svc_debug_fenter();
 
        media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
        media_svc_retvm_if(!STRING_VALID(src_path), MS_MEDIA_ERR_INVALID_PARAMETER, "src_path is NULL");
        media_svc_retvm_if(!STRING_VALID(dest_path), MS_MEDIA_ERR_INVALID_PARAMETER, "dest_path is NULL");
+       media_svc_retvm_if(!STRING_VALID(media_id), MS_MEDIA_ERR_INVALID_PARAMETER, "media_id is NULL");
+       media_svc_retvm_if(!STRING_VALID(mime_type), MS_MEDIA_ERR_INVALID_PARAMETER, "mime_type is NULL");
 
        /* Get storage_id */
        ret = _media_svc_get_storage_uuid(handle, src_path, org_stg_id, uid);
@@ -424,13 +429,6 @@ int media_svc_move_item(sqlite3 *handle, const char *src_path, const char *dest_
        /*get modified_time*/
        modified_time = _media_svc_get_file_time(dest_path);
 
-       ret = _media_svc_get_media_type_by_path(handle, org_stg_id, src_path, &media_type);
-       if (ret != MS_MEDIA_ERR_NONE) {
-               media_svc_error("_media_svc_get_media_type_by_path failed");
-               SAFE_FREE(file_name);
-               return ret;
-       }
-
        /*get old thumbnail_path and remove thumbnail */
        ret = _media_svc_get_thumbnail_path_by_path(handle, src_path, old_thumb_path);
        if ((ret != MS_MEDIA_ERR_NONE) && (ret != MS_MEDIA_ERR_DB_NO_RECORD)) {
@@ -451,15 +449,7 @@ int media_svc_move_item(sqlite3 *handle, const char *src_path, const char *dest_
        media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
 
        media_svc_debug("Move is successful. Sending noti for this");
-
-       /* Get notification info */
-       media_svc_noti_item *noti_item = NULL;
-       ret = _media_svc_get_noti_info(handle, dst_stg_id, dest_path, MS_MEDIA_ITEM_FILE, &noti_item);
-       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-
-       /* Send notification for move */
-       _media_svc_publish_noti(MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_UPDATE, src_path, media_type, noti_item->media_uuid, noti_item->mime_type);
-       _media_svc_destroy_noti_item(noti_item);
+       _media_svc_publish_noti(MS_MEDIA_ITEM_UPDATE, src_path, media_type, media_id, mime_type);
 
        /*update folder modified_time*/
        folder_path = g_path_get_dirname(dest_path);
@@ -538,10 +528,6 @@ int media_svc_delete_item_by_path(sqlite3 *handle, bool is_direct, const char *s
 
        media_svc_debug_fenter();
 
-       int media_type = -1;
-       ret = _media_svc_get_media_type_by_path(handle, storage_id, path, &media_type);
-       media_svc_retv_if((ret != MS_MEDIA_ERR_NONE), ret);
-
        /*Get thumbnail path to delete*/
        ret = _media_svc_get_thumbnail_path_by_path(handle, path, thumb_path);
        media_svc_retv_if((ret != MS_MEDIA_ERR_NONE) && (ret != MS_MEDIA_ERR_DB_NO_RECORD), ret);
@@ -550,7 +536,7 @@ int media_svc_delete_item_by_path(sqlite3 *handle, bool is_direct, const char *s
 
                /* Get notification info */
                media_svc_noti_item *noti_item = NULL;
-               ret = _media_svc_get_noti_info(handle, storage_id, path, MS_MEDIA_ITEM_FILE, &noti_item);
+               ret = _media_svc_get_noti_info(handle, storage_id, path, &noti_item);
                media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
 
                /*Delete item*/
@@ -564,7 +550,7 @@ int media_svc_delete_item_by_path(sqlite3 *handle, bool is_direct, const char *s
 
                /* Send notification */
                media_svc_debug("Deletion is successful. Sending noti for this");
-               _media_svc_publish_noti(MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_DELETE, path, media_type, noti_item->media_uuid, noti_item->mime_type);
+               _media_svc_publish_noti(MS_MEDIA_ITEM_DELETE, path, noti_item->media_type, noti_item->media_uuid, noti_item->mime_type);
                _media_svc_destroy_noti_item(noti_item);
        } else {
                ret = _media_svc_delete_item_by_path(is_direct, storage_id, path, TRUE, uid);
@@ -588,7 +574,6 @@ int media_svc_delete_item_by_path(sqlite3 *handle, bool is_direct, const char *s
 int media_svc_refresh_item(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
-       media_svc_media_type_e media_type;
        char thumb_path[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
 
        media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
@@ -600,7 +585,7 @@ int media_svc_refresh_item(sqlite3 *handle, const char *storage_id, ms_user_stor
        memset(&content_info, 0, sizeof(media_svc_content_info_s));
 
        /*Set media info*/
-       ret = _media_svc_set_media_info(&content_info, storage_id, storage_type, path, &media_type, TRUE);
+       ret = _media_svc_set_media_info(&content_info, storage_id, storage_type, path, TRUE);
        if (ret != MS_MEDIA_ERR_NONE)
                return ret;
 
@@ -627,21 +612,20 @@ int media_svc_refresh_item(sqlite3 *handle, const char *storage_id, ms_user_stor
 
        /* Get notification info */
        media_svc_noti_item *noti_item = NULL;
-       ret = _media_svc_get_noti_info(handle, storage_id, path, MS_MEDIA_ITEM_FILE, &noti_item);
+       ret = _media_svc_get_noti_info(handle, storage_id, path, &noti_item);
        if (ret != MS_MEDIA_ERR_NONE) {
                _media_svc_destroy_content_info(&content_info);
                return ret;
        }
 
-       media_type = noti_item->media_type;
-       content_info.media_type = media_type;
+       content_info.media_type = noti_item->media_type;
 
-       if (media_type == MEDIA_SVC_MEDIA_TYPE_OTHER
-       || (media_type == MEDIA_SVC_MEDIA_TYPE_PVR)
-       || (media_type == MEDIA_SVC_MEDIA_TYPE_UHD)
-       || (media_type == MEDIA_SVC_MEDIA_TYPE_SCSA))
-               media_svc_debug("Do nothing [%d]", media_type);
-       else if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE)
+       if (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_OTHER
+       || (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_PVR)
+       || (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_UHD)
+       || (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_SCSA))
+               media_svc_debug("Do nothing [%d]", content_info.media_type);
+       else if (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE)
                ret = _media_svc_extract_image_metadata(&content_info);
        else
                ret = _media_svc_extract_media_metadata(handle, false, &content_info, uid);
@@ -654,10 +638,10 @@ int media_svc_refresh_item(sqlite3 *handle, const char *storage_id, ms_user_stor
 
        /* Extracting thumbnail */
        if (content_info.thumbnail_path == NULL) {
-               if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
+               if (content_info.media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE || content_info.media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
                        memset(thumb_path, 0, sizeof(thumb_path));
 
-                       ret = _media_svc_create_thumbnail(content_info.path, thumb_path, media_type, uid);
+                       ret = _media_svc_create_thumbnail(content_info.path, thumb_path, content_info.media_type, uid);
                        if (ret == MS_MEDIA_ERR_NONE)
                                content_info.thumbnail_path = g_strdup(thumb_path);
                }
@@ -667,7 +651,7 @@ int media_svc_refresh_item(sqlite3 *handle, const char *storage_id, ms_user_stor
 
        if (ret == MS_MEDIA_ERR_NONE) {
                media_svc_debug("Update is successful. Sending noti for this");
-               _media_svc_publish_noti(MS_MEDIA_ITEM_FILE, MS_MEDIA_ITEM_UPDATE, content_info.path, noti_item->media_type, noti_item->media_uuid, noti_item->mime_type);
+               _media_svc_publish_noti(MS_MEDIA_ITEM_UPDATE, content_info.path, noti_item->media_type, noti_item->media_uuid, noti_item->mime_type);
        } else {
                media_svc_error("_media_svc_update_item_with_data failed : %d", ret);
        }
@@ -678,36 +662,11 @@ int media_svc_refresh_item(sqlite3 *handle, const char *storage_id, ms_user_stor
        return ret;
 }
 
-int media_svc_send_dir_update_noti(sqlite3 *handle, const char *storage_id, const char *dir_path, const char *folder_id, media_item_update_type_e update_type, int pid)
+int media_svc_send_dir_update_noti(const char *dir_path, const char *folder_id, media_item_update_type_e update_type, int pid)
 {
-       int ret = MS_MEDIA_ERR_NONE;
-       char *uuid = NULL;
-
-       media_svc_retvm_if(handle == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "Handle is NULL");
        media_svc_retvm_if(!STRING_VALID(dir_path), MS_MEDIA_ERR_INVALID_PARAMETER, "dir_path is NULL");
 
-       /* Get notification info */
-       media_svc_noti_item *noti_item = NULL;
-       ret = _media_svc_get_noti_info(handle, storage_id, dir_path, MS_MEDIA_ITEM_DIRECTORY, &noti_item);
-       media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-
-       if (folder_id != NULL) {
-               uuid = strndup(folder_id, strlen(folder_id));
-       } else {
-               if (noti_item->media_uuid != NULL) {
-                       uuid = strndup(noti_item->media_uuid, strlen(noti_item->media_uuid));
-               } else {
-                       _media_svc_destroy_noti_item(noti_item);
-                       media_svc_error("folder uuid is wrong");
-                       return MS_MEDIA_ERR_DB_INTERNAL;
-               }
-       }
-
-       ret = _media_svc_publish_dir_noti_v2(MS_MEDIA_ITEM_DIRECTORY, update_type, dir_path, -1, uuid, NULL, pid);
-       _media_svc_destroy_noti_item(noti_item);
-       SAFE_FREE(uuid);
-
-       return ret;
+       return _media_svc_publish_dir_noti(update_type, dir_path, folder_id, pid);
 }
 
 int media_svc_check_db_upgrade(sqlite3 *handle, int user_version, uid_t uid)
@@ -747,17 +706,16 @@ 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 ret = MS_MEDIA_ERR_NONE;
-       media_svc_media_type_e media_type;
        media_svc_content_info_s content_info;
        memset(&content_info, 0, sizeof(media_svc_content_info_s));
 
        /*Set media info*/
-       ret = _media_svc_set_media_info(&content_info, storage_id, storage_type, file_path, &media_type, FALSE);
+       ret = _media_svc_set_media_info(&content_info, storage_id, storage_type, file_path, FALSE);
        if (ret != MS_MEDIA_ERR_NONE)
                return ret;
 
-       if (media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC)
-               ret = _media_svc_extract_music_metadata_for_update(&content_info, media_type);
+       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;
@@ -801,9 +759,9 @@ int media_svc_update_item_meta(const char *file_path, const char *storage_id, in
        return ret;
 }
 
-int media_svc_publish_noti(media_item_type_e update_item, 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_publish_noti(media_item_update_type_e update_type, const char *path, media_type_e media_type, const char *uuid, const char *mime_type)
 {
-       return _media_svc_publish_noti(update_item, update_type, path, media_type, uuid, mime_type);
+       return _media_svc_publish_noti(update_type, path, media_type, uuid, mime_type);
 }
 
 int media_svc_get_pinyin(const char *src_str, char **pinyin_str)
index 723226d..a294234 100755 (executable)
@@ -39,7 +39,7 @@ int _media_svc_update_item_validity(const char *storage_id, const char *path, in
 int _media_svc_update_item_by_path(const char *org_storage_id, const char *src_path, const char *dst_storage_id, ms_user_storage_type_e dest_storage, const char *dest_path, const char *file_name, int modified_time, const char *folder_uuid, uid_t uid);
 int _media_svc_list_query_do(media_svc_query_type_e query_type, uid_t uid);
 int _media_svc_update_thumbnail_path(const char *storage_id, const char *path, const char *thumb_path, uid_t uid);
-int _media_svc_get_noti_info(sqlite3 *handle, const char *storage_id, const char *path, int update_item, media_svc_noti_item **item);
+int _media_svc_get_noti_info(sqlite3 *handle, const char *storage_id, const char *path, media_svc_noti_item **item);
 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);
index 05d194d..24cde31 100755 (executable)
@@ -46,22 +46,8 @@ int _media_svc_insert_item_to_noti_list(media_svc_content_info_s *content_info,
 int _media_svc_destroy_noti_list(int all_cnt);
 int _media_svc_publish_noti_list(int all_cnt);
 int _media_svc_destroy_noti_item(media_svc_noti_item *item);
-int _media_svc_publish_noti(media_item_type_e update_item,
-                                                       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_publish_dir_noti_v2(media_item_type_e update_item,
-                                                       media_item_update_type_e update_type,
-                                                       const char *path,
-                                                       media_type_e media_type,
-                                                       const char *uuid,
-                                                       const char *mime_type,
-                                                       int pid
-);
+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_publish_dir_noti(media_item_update_type_e update_type, const char *path, const char *uuid, int pid);
 
 
 
index d148d96..c92e1b2 100755 (executable)
@@ -138,8 +138,7 @@ int _media_svc_remove_file(const char *path);
 int _media_svc_get_thumbnail_path(media_svc_media_type_e media_type, char *thumb_path, const char *pathname, const char *img_format, uid_t uid);
 int _media_svc_get_file_time(const char *full_path);
 int _media_svc_set_default_value(media_svc_content_info_s *content_info, bool refresh);
-int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, ms_user_storage_type_e storage_type,
-               const char *path, media_svc_media_type_e *media_type, bool refresh);
+int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, bool refresh);
 int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info);
 int _media_svc_extract_media_metadata(sqlite3 *handle, bool is_direct, media_svc_content_info_s *content_info, uid_t uid);
 time_t __media_svc_get_timeline_from_str(const char *timstr);