summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaejeong Kim <backto.kim@samsung.com>2017-05-19 16:18:57 +0900
committerHaejeong Kim <backto.kim@samsung.com>2017-05-19 17:35:36 +0900
commit09909647fa401b2777320ce48ab42b2023f6d7fd (patch)
treec5ecd7f70a54544d121a8a00fa9a25ce534201cf
parent5b72911417d6d59d5449c20fa98c2bd3926bd9a8 (diff)
downloadlibmedia-service-09909647fa401b2777320ce48ab42b2023f6d7fd.tar.gz
libmedia-service-09909647fa401b2777320ce48ab42b2023f6d7fd.tar.bz2
libmedia-service-09909647fa401b2777320ce48ab42b2023f6d7fd.zip
Remove default thumbnail handling code
Change-Id: Ie30bd18476b2ea020c5f77d47340b437a69358ba
-rw-r--r--packaging/libmedia-service.spec2
-rwxr-xr-xsrc/common/media-svc-media.c36
-rwxr-xr-xsrc/common/media-svc.c81
-rwxr-xr-xsrc/include/common/media-svc-media.h1
4 files changed, 29 insertions, 91 deletions
diff --git a/packaging/libmedia-service.spec b/packaging/libmedia-service.spec
index 11ce1b6..6742281 100644
--- a/packaging/libmedia-service.spec
+++ b/packaging/libmedia-service.spec
@@ -1,6 +1,6 @@
Name: libmedia-service
Summary: Media information service library for multimedia applications
-Version: 0.3.4
+Version: 0.3.5
Release: 0
Group: Multimedia/Libraries
License: Apache-2.0 and PD
diff --git a/src/common/media-svc-media.c b/src/common/media-svc-media.c
index ecbf711..c817bc8 100755
--- a/src/common/media-svc-media.c
+++ b/src/common/media-svc-media.c
@@ -174,24 +174,6 @@ int _media_svc_count_record_with_path(sqlite3 *handle, const char *storage_id, c
return MS_MEDIA_ERR_NONE;
}
-char *_media_svc_get_thumb_default_path(uid_t uid)
-{
- int ret = 0;
- char *result_path = NULL;
-
- ret = tzplatform_set_user(uid);
- if (ret != 0) {
- media_svc_error("Invalid UID[%d]", uid);
- return NULL;
- } else {
- const char *result = tzplatform_mkpath(TZ_USER_SHARE, "media/.thumb/thumb_default.png");
- result_path = strndup(result, strlen(result));
- tzplatform_reset_user();
- }
-
- return result_path;
-}
-
int _media_svc_insert_item_with_data(sqlite3 *handle, const char *storage_id, media_svc_content_info_s *content_info, int is_burst, bool stack_query, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
@@ -642,9 +624,8 @@ int _media_svc_delete_invalid_items(sqlite3 *handle, const char *storage_id, med
}
/*Delete thumbnails*/
- char *default_thumbnail_path = _media_svc_get_thumb_default_path(uid);
for (idx = 0; idx < invalid_count; idx++) {
- if ((strlen(thumbpath_record[idx].thumbnail_path) > 0) && (STRING_VALID(default_thumbnail_path)) && (strncmp(thumbpath_record[idx].thumbnail_path, default_thumbnail_path, strlen(default_thumbnail_path)) != 0)) {
+ if (STRING_VALID(thumbpath_record[idx].thumbnail_path)) {
ret = _media_svc_remove_file(thumbpath_record[idx].thumbnail_path);
if (ret != MS_MEDIA_ERR_NONE)
media_svc_error("fail to remove thumbnail file.");
@@ -652,7 +633,6 @@ int _media_svc_delete_invalid_items(sqlite3 *handle, const char *storage_id, med
}
SAFE_FREE(thumbpath_record);
- SAFE_FREE(default_thumbnail_path);
return MS_MEDIA_ERR_NONE;
}
@@ -706,19 +686,15 @@ int _media_svc_delete_invalid_folder_items(sqlite3 *handle, const char *storage_
/*Delete thumbnails*/
if (thumbpath_record != NULL) {
- char *default_thumbnail_path = _media_svc_get_thumb_default_path(uid);
- if (STRING_VALID(default_thumbnail_path)) {
- for (idx = 0; idx < invalid_count; idx++) {
- if ((strlen(thumbpath_record[idx].thumbnail_path) > 0) && (strncmp(thumbpath_record[idx].thumbnail_path, default_thumbnail_path, strlen(default_thumbnail_path)) != 0)) {
- ret = _media_svc_remove_file(thumbpath_record[idx].thumbnail_path);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("fail to remove thumbnail file.");
- }
+ for (idx = 0; idx < invalid_count; idx++) {
+ if (STRING_VALID(thumbpath_record[idx].thumbnail_path)) {
+ ret = _media_svc_remove_file(thumbpath_record[idx].thumbnail_path);
+ if (ret != MS_MEDIA_ERR_NONE)
+ media_svc_error("fail to remove thumbnail file.");
}
}
SAFE_FREE(thumbpath_record);
- SAFE_FREE(default_thumbnail_path);
}
return MS_MEDIA_ERR_NONE;
diff --git a/src/common/media-svc.c b/src/common/media-svc.c
index 1aac544..518c1c9 100755
--- a/src/common/media-svc.c
+++ b/src/common/media-svc.c
@@ -552,14 +552,7 @@ int media_svc_move_item(MediaSvcHandle *handle, const char *storage_id, media_sv
return ret;
}
- /* If old thumb path is default or not */
- char *default_thumbnail_path = _media_svc_get_thumb_default_path(uid);
- if (STRING_VALID(default_thumbnail_path) && (strncmp(old_thumb_path, default_thumbnail_path, strlen(default_thumbnail_path)) == 0))
- _strncpy_safe(new_thumb_path, default_thumbnail_path, sizeof(new_thumb_path));
- else
- _media_svc_get_thumbnail_path(dest_storage, new_thumb_path, dest_path, THUMB_EXT, uid);
-
- SAFE_FREE(default_thumbnail_path);
+ _media_svc_get_thumbnail_path(dest_storage, new_thumb_path, dest_path, THUMB_EXT, uid);
}
if (g_media_svc_move_item_data_cnt == 1) {
@@ -641,13 +634,11 @@ int media_svc_move_item(MediaSvcHandle *handle, const char *storage_id, media_sv
}
/*rename thumbnail file*/
-/* if ((media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) || (media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO)) { */
- if ((strlen(old_thumb_path) > 0) && (STRING_VALID(MEDIA_SVC_THUMB_DEFAULT_PATH)) && (strncmp(old_thumb_path, MEDIA_SVC_THUMB_DEFAULT_PATH, strlen(MEDIA_SVC_THUMB_DEFAULT_PATH)) != 0)) {
+ if (STRING_VALID(old_thumb_path)) {
ret = _media_svc_rename_file(old_thumb_path, new_thumb_path);
if (ret != MS_MEDIA_ERR_NONE)
media_svc_error("_media_svc_rename_file failed : %d", ret);
}
-/* } */
return MS_MEDIA_ERR_NONE;
}
@@ -785,28 +776,12 @@ int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *storage_id
}
/*Delete thumbnail*/
- char *default_thumbnail_path = _media_svc_get_thumb_default_path(uid);
- if ((strlen(thumb_path) > 0) && ((STRING_VALID(default_thumbnail_path)) && (strncmp(thumb_path, default_thumbnail_path, strlen(default_thumbnail_path)) != 0))) {
-/*
- int thumb_count = 1;
- // Get count of media, which contains same thumbnail for music
- if ((media_type == MEDIA_SVC_MEDIA_TYPE_SOUND) ||(media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC)) {
- ret = _media_svc_get_thumbnail_count(db_handle, storage_id, thumb_path, &thumb_count);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("Failed to get thumbnail count : %d", ret);
- }
- }
-
- if (thumb_count == 1) {
-*/
- ret = _media_svc_remove_file(thumb_path);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("fail to remove thumbnail file.");
-/* } */
+ if (STRING_VALID(thumb_path)) {
+ ret = _media_svc_remove_file(thumb_path);
+ if (ret != MS_MEDIA_ERR_NONE)
+ media_svc_error("fail to remove thumbnail file.");
}
- SAFE_FREE(default_thumbnail_path);
-
return MS_MEDIA_ERR_NONE;
}
@@ -924,7 +899,7 @@ int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media
return ret;
}
- if (g_file_test(thumb_path, G_FILE_TEST_EXISTS) && (STRING_VALID(MEDIA_SVC_THUMB_DEFAULT_PATH)) && (strncmp(thumb_path, MEDIA_SVC_THUMB_DEFAULT_PATH, strlen(MEDIA_SVC_THUMB_DEFAULT_PATH)) != 0)) {
+ if (g_file_test(thumb_path, G_FILE_TEST_EXISTS)) {
ret = _media_svc_remove_file(thumb_path);
if (ret != MS_MEDIA_ERR_NONE)
media_svc_error("_media_svc_remove_file failed : %s", thumb_path);
@@ -1091,32 +1066,22 @@ int media_svc_rename_folder(MediaSvcHandle *handle, const char *storage_id, cons
ms_user_storage_type_t storage_type = -1;
if (!no_thumb) {
- /* If old thumb path is default or not */
- char *default_thumbnail_path = _media_svc_get_thumb_default_path(uid);
- if (STRING_VALID(default_thumbnail_path) && (strncmp(media_thumb_path, default_thumbnail_path, strlen(default_thumbnail_path)) == 0)) {
- _strncpy_safe(media_new_thumb_path, default_thumbnail_path, sizeof(media_new_thumb_path));
- } else {
- ret = ms_user_get_storage_type(uid, replaced_path, &storage_type);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_sec_error("ms_user_get_storage_type failed : [%d], path[%s] storage_type[%d]", ret, replaced_path, storage_type);
- SAFE_FREE(replaced_path);
- SAFE_FREE(default_thumbnail_path);
- _media_svc_sql_rollback_trans(uid);
- return ret;
- }
-
- ret = _media_svc_get_thumbnail_path(storage_type, media_new_thumb_path, replaced_path, THUMB_EXT, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("_media_svc_get_thumbnail_path failed : %d", ret);
- SAFE_FREE(replaced_path);
- SAFE_FREE(default_thumbnail_path);
- SQLITE3_FINALIZE(sql_stmt);
- _media_svc_sql_rollback_trans(uid);
- return ret;
- }
+ ret = ms_user_get_storage_type(uid, replaced_path, &storage_type);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ media_svc_sec_error("ms_user_get_storage_type failed : [%d], path[%s] storage_type[%d]", ret, replaced_path, storage_type);
+ SAFE_FREE(replaced_path);
+ _media_svc_sql_rollback_trans(uid);
+ return ret;
}
- SAFE_FREE(default_thumbnail_path);
+ ret = _media_svc_get_thumbnail_path(storage_type, media_new_thumb_path, replaced_path, THUMB_EXT, uid);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ media_svc_error("_media_svc_get_thumbnail_path failed : %d", ret);
+ SAFE_FREE(replaced_path);
+ SQLITE3_FINALIZE(sql_stmt);
+ _media_svc_sql_rollback_trans(uid);
+ return ret;
+ }
/*media_svc_debug("New media thumbnail path : %s", media_new_thumb_path); */
}
@@ -1149,14 +1114,12 @@ int media_svc_rename_folder(MediaSvcHandle *handle, const char *storage_id, cons
}
/* Rename thumbnail file of file system */
- char *default_thumbnail_path = _media_svc_get_thumb_default_path(uid);
- if ((!no_thumb) && (default_thumbnail_path != NULL) && (strncmp(media_thumb_path, default_thumbnail_path, strlen(default_thumbnail_path)) != 0)) {
+ if (!no_thumb) {
ret = _media_svc_rename_file(media_thumb_path, media_new_thumb_path);
if (ret != MS_MEDIA_ERR_NONE)
media_svc_error("_media_svc_rename_file failed : %d", ret);
}
- SAFE_FREE(default_thumbnail_path);
}
SQLITE3_FINALIZE(sql_stmt);
diff --git a/src/include/common/media-svc-media.h b/src/include/common/media-svc-media.h
index 414b716..7e385d2 100755
--- a/src/include/common/media-svc-media.h
+++ b/src/include/common/media-svc-media.h
@@ -48,7 +48,6 @@ int _media_svc_update_thumbnail_path(const char *storage_id, const char *path, c
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_count_invalid_folder_items(sqlite3 *handle, const char *storage_id, const char *folder_path, int *count);
int _media_svc_get_thumbnail_count(sqlite3 *handle, const char *storage_id, const char *thumb_path, int *count);
-char *_media_svc_get_thumb_default_path(uid_t uid);
int _media_svc_get_fileinfo_by_path(sqlite3 *handle, const char *storage_id, const char *path, time_t *modified_time, unsigned long long *size);
int _media_svc_update_meta_with_data(media_svc_content_info_s *content_info);