summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2019-05-13 16:59:29 +0900
committerMinje Ahn <minje.ahn@samsung.com>2019-05-15 16:07:10 +0900
commit6fdac0c2e28600810e17893b33329582ebbedf85 (patch)
tree998c6dce7c00783c9ed2dbbbf92f5a3665063509 /src/common
parent92b3eb68a3815d90934b2fa44bc503ac5a704bb1 (diff)
downloadlibmedia-service-6fdac0c2e28600810e17893b33329582ebbedf85.tar.gz
libmedia-service-6fdac0c2e28600810e17893b33329582ebbedf85.tar.bz2
libmedia-service-6fdac0c2e28600810e17893b33329582ebbedf85.zip
Reduce DB connection when notisubmit/tizen/20190515.071609
Change-Id: Iaa04ae49271fdb26df960ffd3233f60a778ec291 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
Diffstat (limited to 'src/common')
-rwxr-xr-xsrc/common/media-svc-media.c45
-rwxr-xr-xsrc/common/media-svc-noti.c51
-rwxr-xr-xsrc/common/media-svc-util.c14
-rwxr-xr-xsrc/common/media-svc.c136
4 files changed, 74 insertions, 172 deletions
diff --git a/src/common/media-svc-media.c b/src/common/media-svc-media.c
index c6ac6a2..406e895 100755
--- a/src/common/media-svc-media.c
+++ b/src/common/media-svc-media.c
@@ -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);
diff --git a/src/common/media-svc-noti.c b/src/common/media-svc-noti.c
index f542c5e..733dc2c 100755
--- a/src/common/media-svc-noti.c
+++ b/src/common/media-svc-noti.c
@@ -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;
}
diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c
index 4758449..2e2a03b 100755
--- a/src/common/media-svc-util.c
+++ b/src/common/media-svc-util.c
@@ -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;
}
diff --git a/src/common/media-svc.c b/src/common/media-svc.c
index aab6eb5..2cdcf17 100755
--- a/src/common/media-svc.c
+++ b/src/common/media-svc.c
@@ -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)