summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinje Ahn <minje.ahn@samsung.com>2019-11-05 10:09:13 +0900
committerMinje Ahn <minje.ahn@samsung.com>2019-11-05 10:09:13 +0900
commitde4e06d91f1b81c367a2544793ecf29b883d30fa (patch)
tree75a7925f10049b65ec44f52af6e018b67894e3b2
parentcfe76145706a57197cbb24796b13276ed200a35b (diff)
downloadlibmedia-service-de4e06d91f1b81c367a2544793ecf29b883d30fa.tar.gz
libmedia-service-de4e06d91f1b81c367a2544793ecf29b883d30fa.tar.bz2
libmedia-service-de4e06d91f1b81c367a2544793ecf29b883d30fa.zip
Change-Id: I9cacdf6fe6ca5bcbe28a7122e0c949ec270fe7c5 Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
-rwxr-xr-xinclude/media-svc.h4
-rw-r--r--packaging/libmedia-service.spec2
-rwxr-xr-xplugin/media-content-plugin.c4
-rwxr-xr-xsrc/common/media-svc-db-utils.c134
-rwxr-xr-xsrc/common/media-svc-media-folder.c2
-rwxr-xr-xsrc/common/media-svc-media.c115
-rwxr-xr-xsrc/common/media-svc-storage.c83
-rw-r--r--src/common/media-svc-util.c3
-rwxr-xr-xsrc/common/media-svc.c71
-rwxr-xr-xsrc/include/common/media-svc-db-utils.h2
-rwxr-xr-xsrc/include/common/media-svc-env.h10
-rwxr-xr-xsrc/include/common/media-svc-media.h21
-rwxr-xr-xsrc/include/common/media-svc-storage.h2
-rwxr-xr-xsrc/include/common/media-svc-util.h10
14 files changed, 99 insertions, 364 deletions
diff --git a/include/media-svc.h b/include/media-svc.h
index 10aef39..d8c2539 100755
--- a/include/media-svc.h
+++ b/include/media-svc.h
@@ -53,7 +53,7 @@ int media_svc_move_item(sqlite3 *handle,
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_set_item_validity(const char *path, int validity, uid_t uid);
int media_svc_delete_item_by_path(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid);
int media_svc_refresh_item(sqlite3 *handle, bool is_direct, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid);
int media_svc_send_dir_update_noti(const char *dir_path, const char *folder_id, media_item_update_type_e update_type, int pid);
@@ -64,7 +64,7 @@ int media_svc_check_pinyin_support(bool *support);
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);
+int media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity);
int media_svc_insert_storage(sqlite3 *handle, const char *storage_id, const char *storage_path, ms_user_storage_type_e storage_type, uid_t uid);
int media_svc_update_storage(sqlite3 *handle, const char *storage_id, const char *storage_path, uid_t uid);
int media_svc_set_storage_validity(sqlite3 *handle, const char *storage_id, int validity, uid_t uid);
diff --git a/packaging/libmedia-service.spec b/packaging/libmedia-service.spec
index 15e130f..ab10364 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.4.3
+Version: 0.4.4
Release: 0
Group: Multimedia/Libraries
License: Apache-2.0 and PD
diff --git a/plugin/media-content-plugin.c b/plugin/media-content-plugin.c
index 6a47bfd..6dd33cb 100755
--- a/plugin/media-content-plugin.c
+++ b/plugin/media-content-plugin.c
@@ -58,7 +58,7 @@ int set_item_validity_end(uid_t uid)
int set_item_validity(const char *storage_id, const char *file_path, int storage_type, int validity, uid_t uid)
{
- return media_svc_set_item_validity(storage_id, file_path, validity, uid);
+ return media_svc_set_item_validity(file_path, validity, uid);
}
int send_dir_update_noti(const char *dir_path, const char *folder_id, int update_type, int pid)
@@ -96,7 +96,7 @@ int get_uuid(char **uuid)
int check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid)
{
- return media_svc_check_storage(handle, storage_id, storage_path, validity, uid);
+ return media_svc_check_storage(handle, storage_id, storage_path, validity);
}
int insert_storage(sqlite3 *handle, const char *storage_id, int storage_type, const char *storage_path, uid_t uid)
diff --git a/src/common/media-svc-db-utils.c b/src/common/media-svc-db-utils.c
index 9fd602a..add00c4 100755
--- a/src/common/media-svc-db-utils.c
+++ b/src/common/media-svc-db-utils.c
@@ -122,8 +122,6 @@ static int __media_svc_rebuild_view_query(sqlite3 *db_handle, uid_t uid)
char temp[1024] = {0, };
bool sflag = false;
int i, len;
- /*media */
- _media_svc_update_media_view(db_handle, uid);
/*drop playlist_view, tag_view */
sql = sqlite3_mprintf(MEDIA_SVC_DB_QUERY_DROP_VIEW, MEDIA_SVC_DB_VIEW_PLAYLIST);
@@ -171,7 +169,7 @@ static int __media_svc_rebuild_view_query(sqlite3 *db_handle, uid_t uid)
for (i = 1; i < len; i++) {
col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_MEDIA], i);
if (col_ptr->is_view) {
- snprintf(temp, sizeof(temp), ", media_view.%s", col_ptr->name);
+ snprintf(temp, sizeof(temp), ", media.%s", col_ptr->name);
SAFE_STRLCAT(table_query, temp, sizeof(table_query));
}
memset(temp, 0, sizeof(temp));
@@ -216,7 +214,7 @@ static int __media_svc_rebuild_view_query(sqlite3 *db_handle, uid_t uid)
for (i = 1; i < len; i++) {
col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_MEDIA], i);
if (col_ptr->is_view) {
- snprintf(temp, sizeof(temp), ", media_view.%s", col_ptr->name);
+ snprintf(temp, sizeof(temp), ", media.%s", col_ptr->name);
SAFE_STRLCAT(table_query, temp, sizeof(table_query));
}
memset(temp, 0, sizeof(temp));
@@ -387,7 +385,7 @@ int _media_svc_make_table_query(const char *table_name, media_svc_table_slist_e
for (i = 1; i < len; i++) {
col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_MEDIA], i);
if (col_ptr->is_view) {
- snprintf(temp, sizeof(temp), ", media_view.%s", col_ptr->name);
+ snprintf(temp, sizeof(temp), ", media.%s", col_ptr->name);
SAFE_STRLCAT(table_query, temp, sizeof(table_query));
}
memset(temp, 0, sizeof(temp));
@@ -429,7 +427,7 @@ int _media_svc_make_table_query(const char *table_name, media_svc_table_slist_e
for (i = 1; i < len; i++) {
col_ptr = g_slist_nth_data(column_list[MEDIA_SVC_DB_LIST_MEDIA], i);
if (col_ptr->is_view) {
- snprintf(temp, sizeof(temp), ", media_view.%s", col_ptr->name);
+ snprintf(temp, sizeof(temp), ", media.%s", col_ptr->name);
SAFE_STRLCAT(table_query, temp, sizeof(table_query));
}
memset(temp, 0, sizeof(temp));
@@ -504,7 +502,7 @@ int _media_svc_init_table_query(const char *event_table_name)
column_list[i] = g_slist_alloc();
/*table specification.. (table_name, index, unique set, trigger, view, trigger name, event table, action table, view name) */
- ret = __media_svc_add_table_info(MEDIA_SVC_DB_TABLE_MEDIA, NULL, NULL, NULL, MEDIA_SVC_DB_VIEW_MEDIA);
+ ret = __media_svc_add_table_info(MEDIA_SVC_DB_TABLE_MEDIA, NULL, NULL, NULL, NULL);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
ret = __media_svc_add_table_info(MEDIA_SVC_DB_TABLE_FOLDER, MEDIA_SVC_DB_TRIGGER_FOLDER, event_table_name, MEDIA_SVC_DB_TABLE_FOLDER, NULL);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
@@ -1586,125 +1584,3 @@ int _media_svc_check_db_upgrade(sqlite3 *db_handle, int user_version, uid_t uid)
return MS_MEDIA_ERR_NONE;
}
}
-
-int _media_svc_create_media_table_with_id(const char *table_id, uid_t uid)
-{
- int ret = MS_MEDIA_ERR_NONE;
-
- ret = _media_svc_init_table_query(table_id);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("_media_svc_init_table_query failed");
- goto ERROR;
- }
-
- ret = _media_svc_make_table_query(table_id, MEDIA_SVC_DB_LIST_MEDIA, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("_media_svc_make_table_query failed");
- goto ERROR;
- }
-
- /* Add for trigger */
- ret = _media_svc_make_table_query(MEDIA_SVC_DB_TABLE_FOLDER, MEDIA_SVC_DB_LIST_FOLDER, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("_media_svc_make_table_query failed");
- goto ERROR;
- }
-
- ret = _media_svc_make_table_query(MEDIA_SVC_DB_TABLE_PLAYLIST_MAP, MEDIA_SVC_DB_LIST_PLAYLIST_MAP, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("_media_svc_make_table_query failed");
- goto ERROR;
- }
-
- ret = _media_svc_make_table_query(MEDIA_SVC_DB_TABLE_ALBUM, MEDIA_SVC_DB_LIST_ALBUM, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("_media_svc_make_table_query failed");
- goto ERROR;
- }
-
- ret = _media_svc_make_table_query(MEDIA_SVC_DB_TABLE_TAG_MAP, MEDIA_SVC_DB_LIST_TAG_MAP, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("_media_svc_make_table_query failed");
- goto ERROR;
- }
-
- ret = _media_svc_make_table_query(MEDIA_SVC_DB_TABLE_BOOKMARK, MEDIA_SVC_DB_LIST_BOOKMARK, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("_media_svc_make_table_query failed");
- goto ERROR;
- }
-
- _media_svc_destroy_table_query();
-
- return ret;
-ERROR:
-
- _media_svc_destroy_table_query();
-
- return ret;
-}
-
-int _media_svc_update_media_view(sqlite3 *db_handle, uid_t uid)
-{
- int ret = MS_MEDIA_ERR_NONE;
- char *sql = NULL;
- sqlite3_stmt *sql_stmt = NULL;
- int item_cnt = 0;
- int idx = 0;
- GList *storage_list = NULL;
- char view_query[MEDIA_SVC_QUERY_LEN_NORMAL] = {0, };
- memset(view_query, 0x00, sizeof(view_query));
-
- snprintf(view_query, sizeof(view_query), "DROP VIEW IF EXISTS %s; CREATE VIEW IF NOT EXISTS %s AS SELECT * from %s ", MEDIA_SVC_DB_VIEW_MEDIA, MEDIA_SVC_DB_VIEW_MEDIA, MEDIA_SVC_DB_TABLE_MEDIA);
-
- /*Select list of storage*/
- sql = sqlite3_mprintf("SELECT storage_id FROM '%s' WHERE validity=1", MEDIA_SVC_DB_TABLE_STORAGE);
- ret = _media_svc_sql_prepare_to_step_simple(db_handle, sql, &sql_stmt);
- media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-
- while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
- if (STRING_VALID((const char *)sqlite3_column_text(sql_stmt, 0)))
- storage_list = g_list_append(storage_list, strdup((char *)sqlite3_column_text(sql_stmt, 0)));
- }
- SQLITE3_FINALIZE(sql_stmt);
-
- if ((storage_list != NULL) && (g_list_length(storage_list) > 0)) {
- item_cnt = g_list_length(storage_list);
-
- for (idx = 0; idx < item_cnt; idx++) {
- int table_cnt = 0;
- char *storage_id = NULL;
- storage_id = g_list_nth_data(storage_list, idx);
-
- if (STRING_VALID(storage_id)) {
- /*Select list of storage*/
- sql = sqlite3_mprintf("SELECT COUNT(*) FROM SQLITE_MASTER WHERE type='table' and name='%q'", storage_id);
- ret = _media_svc_sql_prepare_to_step(db_handle, sql, &sql_stmt);
- if (ret != MS_MEDIA_ERR_NONE) {
- SAFE_FREE(storage_id);
- continue;
- }
-
- table_cnt = sqlite3_column_int(sql_stmt, 0);
- SQLITE3_FINALIZE(sql_stmt);
-
- if (table_cnt > 0) {
- char append_query[128] = {0, };
- memset(append_query, 0x00, sizeof(append_query));
- snprintf(append_query, sizeof(append_query), " UNION SELECT * from '%s'", storage_id);
- SAFE_STRLCAT(view_query, append_query, sizeof(view_query));
- } else {
- media_svc_error("media table not exist for storage [%s]", storage_id);
- }
-
- SAFE_FREE(storage_id);
- }
- }
- g_list_free(storage_list);
- }
-
- ret = _media_svc_sql_query(view_query, uid);
- media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-
- return ret;
-}
diff --git a/src/common/media-svc-media-folder.c b/src/common/media-svc-media-folder.c
index 94f7288..9257055 100755
--- a/src/common/media-svc-media-folder.c
+++ b/src/common/media-svc-media-folder.c
@@ -33,7 +33,7 @@ int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *storage_
sqlite3_stmt *sql_stmt = NULL;
char *sql = NULL;
- sql = sqlite3_mprintf("SELECT folder_id FROM %q WHERE storage_uuid = '%q' AND folder_path = '%q';", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, folder_name);
+ sql = sqlite3_mprintf("SELECT folder_id FROM %q WHERE storage_uuid=%Q AND folder_path=%Q", MEDIA_SVC_DB_TABLE_FOLDER, storage_id, folder_name);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
if (ret != MS_MEDIA_ERR_NONE) {
diff --git a/src/common/media-svc-media.c b/src/common/media-svc-media.c
index 8222de7..246b518 100755
--- a/src/common/media-svc-media.c
+++ b/src/common/media-svc-media.c
@@ -37,16 +37,15 @@ static __thread GList *g_media_svc_insert_item_query_list = NULL;
static __thread GList *g_media_svc_update_item_query_list = NULL;
static __thread GList *g_media_svc_update_list = NULL;
-int _media_svc_count_record_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count)
+int _media_svc_count_record_with_path(sqlite3 *handle, const char *path, int *count)
{
int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *sql = 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");
- sql = sqlite3_mprintf("SELECT count(*) FROM '%q' WHERE media_path='%q'", storage_id, path);
+ sql = sqlite3_mprintf("SELECT count(*) FROM %q WHERE media_path=%Q", MEDIA_SVC_DB_TABLE_MEDIA, path);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
@@ -57,16 +56,15 @@ int _media_svc_count_record_with_path(sqlite3 *handle, const char *storage_id, c
return MS_MEDIA_ERR_NONE;
}
-int _media_svc_get_modified_time(sqlite3 *handle, const char *storage_id, const char *path, int *modified_time)
+int _media_svc_get_modified_time(sqlite3 *handle, const char *path, int *modified_time)
{
int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *sql = 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");
- sql = sqlite3_mprintf("SELECT media_modified_time FROM '%q' WHERE media_path='%q'", storage_id, path);
+ sql = sqlite3_mprintf("SELECT media_modified_time FROM %q WHERE media_path=%Q", MEDIA_SVC_DB_TABLE_MEDIA, path);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
@@ -77,7 +75,7 @@ int _media_svc_get_modified_time(sqlite3 *handle, const char *storage_id, const
return MS_MEDIA_ERR_NONE;
}
-int _media_svc_insert_item_with_data(bool is_direct, const char *storage_id, media_svc_content_info_s *content_info, bool stack_query, uid_t uid)
+int _media_svc_insert_item_with_data(bool is_direct, media_svc_content_info_s *content_info, bool stack_query, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
@@ -117,11 +115,11 @@ int _media_svc_insert_item_with_data(bool is_direct, const char *storage_id, med
_media_svc_get_pinyin_str(content_info->media_meta.description, &content_info->media_meta.description_pinyin);
}
- char *sql = sqlite3_mprintf("INSERT INTO '%q' (%q) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %d, %Q, \
+ char *sql = sqlite3_mprintf("INSERT INTO %q(%q) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %d, %Q, \
%Q, %Q, %d, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %d, \
%d, %d, %d, %d, %d, %.6f, %.6f, %.6f, %Q, %.6f, %d, %Q, %d, %d, %Q, %d, \
%d, %d, %d, %d, %d, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %Q, %d);",
- content_info->storage_uuid, db_fields,
+ MEDIA_SVC_DB_TABLE_MEDIA, db_fields,
content_info->media_uuid,
content_info->path,
content_info->file_name,
@@ -184,8 +182,8 @@ int _media_svc_insert_item_with_data(bool is_direct, const char *storage_id, med
media_svc_debug("Query length is over %d byte.. So, remake query using only basic information..", MEDIA_SVC_QUERY_LEN_MAX - 1);
SQLITE3_SAFE_FREE(sql);
- sql = sqlite3_mprintf("INSERT INTO '%q' (%q) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %d, %Q, %Q, %d, %d, %d, %d, %d, %d, %d, %d, %Q, %Q, %d);",
- content_info->storage_uuid, db_fields_basic,
+ sql = sqlite3_mprintf("INSERT INTO %q(%q) VALUES (%Q, %Q, %Q, %d, %Q, %lld, %d, %d, %Q, %Q, %d, %d, %d, %d, %d, %d, %d, %d, %Q, %Q, %d);",
+ MEDIA_SVC_DB_TABLE_MEDIA, db_fields_basic,
content_info->media_uuid,
content_info->path,
content_info->file_name,
@@ -233,8 +231,8 @@ 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);
- 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,
+ 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;",
+ MEDIA_SVC_DB_TABLE_MEDIA,
content_info->media_meta.title,
content_info->media_meta.album,
content_info->media_meta.artist,
@@ -257,7 +255,7 @@ int _media_svc_update_meta_with_data(media_svc_content_info_s *content_info)
return ret;
}
-int _media_svc_update_item_with_data(bool is_direct, const char *storage_id, media_svc_content_info_s *content_info, uid_t uid)
+int _media_svc_update_item_with_data(bool is_direct, media_svc_content_info_s *content_info, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
@@ -288,10 +286,10 @@ int _media_svc_update_item_with_data(bool is_direct, const char *storage_id, med
_media_svc_get_pinyin_str(content_info->media_meta.description, &content_info->media_meta.description_pinyin);
}
- char *sql = sqlite3_mprintf("UPDATE '%q' SET media_size=%lld, media_modified_time=%d, media_thumbnail_path=%Q, media_title=%Q, album_id=%d, media_album=%Q, media_artist=%Q, media_album_artist=%Q, media_genre=%Q, \
+ char *sql = sqlite3_mprintf("UPDATE %q SET media_size=%lld, media_modified_time=%d, media_thumbnail_path=%Q, media_title=%Q, album_id=%d, media_album=%Q, media_artist=%Q, media_album_artist=%Q, media_genre=%Q, \
media_composer=%Q, media_year=%Q, media_recorded_date=%Q, media_copyright=%Q, media_track_num=%Q, media_description=%Q, media_bitrate=%d, media_bitpersample=%d, media_samplerate=%d, media_channel=%d, media_duration=%d, \
media_longitude=%f, media_latitude=%f, media_altitude=%f, exposure_time=%Q, fnumber=%f, iso=%d, model=%Q, media_width=%d, media_height=%d, media_datetaken=%Q, media_orientation=%d WHERE media_path=%Q;",
- storage_id,
+ MEDIA_SVC_DB_TABLE_MEDIA,
content_info->size,
content_info->modified_time,
content_info->thumbnail_path,
@@ -345,7 +343,7 @@ int _media_svc_get_thumbnail_path_by_path(sqlite3 *handle, const char *path, cha
media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
- sql = sqlite3_mprintf("SELECT media_thumbnail_path FROM '%q' WHERE media_path='%q'", MEDIA_SVC_DB_VIEW_MEDIA, path);
+ sql = sqlite3_mprintf("SELECT media_thumbnail_path FROM %q WHERE media_path='%q'", MEDIA_SVC_DB_TABLE_MEDIA, path);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
@@ -365,40 +363,14 @@ int _media_svc_get_thumbnail_path_by_path(sqlite3 *handle, const char *path, cha
return MS_MEDIA_ERR_NONE;
}
-int _media_svc_get_media_type_by_path(sqlite3 *handle, const char *storage_id, const char *path, int *media_type)
+int _media_svc_delete_item_by_path(const char *path, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
- sqlite3_stmt *sql_stmt = NULL;
char *sql = 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");
- sql = sqlite3_mprintf("SELECT media_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) {
- media_svc_error("error when _media_svc_get_media_type_by_path. err = [%d]", ret);
- return ret;
- }
-
- *media_type = sqlite3_column_int(sql_stmt, 0);
-
- SQLITE3_FINALIZE(sql_stmt);
-
- return MS_MEDIA_ERR_NONE;
-}
-
-int _media_svc_delete_item_by_path(const char *storage_id, const char *path, uid_t uid)
-{
- int ret = MS_MEDIA_ERR_NONE;
- char *sql = 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");
-
- sql = sqlite3_mprintf("DELETE FROM '%q' WHERE media_path='%q';", storage_id, path);
+ sql = sqlite3_mprintf("DELETE FROM %q WHERE media_path=%Q;", MEDIA_SVC_DB_TABLE_MEDIA, path);
ret = _media_svc_sql_query(sql, uid);
SQLITE3_SAFE_FREE(sql);
@@ -407,17 +379,16 @@ int _media_svc_delete_item_by_path(const char *storage_id, const char *path, uid
return ret;
}
-int _media_svc_update_item_validity(const char *storage_id, const char *path, int validity, bool stack_query, uid_t uid)
+int _media_svc_update_item_validity(const char *path, int validity, bool stack_query, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
char *sql = 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");
media_svc_debug("path=[%s], validity=[%d]", path, validity);
- sql = sqlite3_mprintf("UPDATE '%q' SET validity=%d WHERE media_path='%q';", storage_id, validity, path);
+ sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE media_path='%q';", MEDIA_SVC_DB_TABLE_MEDIA, validity, path);
if (!stack_query) {
ret = _media_svc_sql_query_direct(sql, uid);
@@ -429,11 +400,11 @@ int _media_svc_update_item_validity(const char *storage_id, const char *path, in
return ret;
}
-int _media_svc_update_thumbnail_path(const char *storage_id, const char *path, const char *thumb_path, uid_t uid)
+int _media_svc_update_thumbnail_path(const char *path, const char *thumb_path, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
- char *sql = sqlite3_mprintf("UPDATE '%q' SET media_thumbnail_path=%Q WHERE media_path=%Q;", storage_id, thumb_path, path);
+ char *sql = sqlite3_mprintf("UPDATE %q SET media_thumbnail_path=%Q WHERE media_path=%Q;", MEDIA_SVC_DB_TABLE_MEDIA, thumb_path, path);
ret = _media_svc_sql_query(sql, uid);
SQLITE3_SAFE_FREE(sql);
@@ -441,30 +412,12 @@ int _media_svc_update_thumbnail_path(const char *storage_id, const char *path, c
return ret;
}
-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_update_item_by_path(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)
{
- /* update path, filename, modified_time, folder_uuid, thumbnail_path, */
-
- /* NOTICE (This operation is abnormal. Modifications should be cautious.)
- 1. Update source to destination info
- 2. Insert destination table
- 3. Remove source info
- */
int ret = MS_MEDIA_ERR_NONE;
- char *update = sqlite3_mprintf("UPDATE '%q' SET media_path=%Q, media_display_name=%Q, media_modified_time=%d, folder_id=%Q, media_storage_type=%d, storage_uuid='%q' WHERE media_path=%Q;",
- org_storage_id, dest_path, file_name, modified_time, folder_uuid, dest_storage, dst_storage_id, src_path);
- char *insert = sqlite3_mprintf("INSERT OR REPLACE INTO '%q' SELECT * FROM '%q' WHERE media_path = '%q';", dst_storage_id, org_storage_id, dest_path);
- char *remove = sqlite3_mprintf("DELETE FROM '%q' WHERE media_path = '%q';", org_storage_id, dest_path);
- char *query = NULL;
-
- if (strcmp(org_storage_id, dst_storage_id) != 0)
- query = sqlite3_mprintf("%s %s %s", update, insert, remove);
- else
- query = sqlite3_mprintf("%s %s", update, insert);
- SQLITE3_SAFE_FREE(update);
- SQLITE3_SAFE_FREE(insert);
- SQLITE3_SAFE_FREE(remove);
+ char *query = sqlite3_mprintf("UPDATE %q SET media_path=%Q, media_display_name=%Q, media_modified_time=%d, folder_id=%Q, media_storage_type=%d, storage_uuid='%q' WHERE media_path=%Q;",
+ MEDIA_SVC_DB_TABLE_MEDIA, dest_path, file_name, modified_time, folder_uuid, dest_storage, dst_storage_id, src_path);
ret = _media_svc_sql_query(query, uid);
SQLITE3_SAFE_FREE(query);
@@ -517,11 +470,11 @@ 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 _media_svc_get_media(sqlite3 *handle, const char *sql, GPtrArray **path_list)
{
int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
- media_svc_file_s *file_info = NULL;
+ char *path = 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");
@@ -529,15 +482,8 @@ int _media_svc_get_media(sqlite3 *handle, const char *sql, GArray **path_list)
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);
+ path = g_strdup((const char *)sqlite3_column_text(sql_stmt, 0));
+ g_ptr_array_add(*path_list, path);
}
SQLITE3_FINALIZE(sql_stmt);
@@ -545,17 +491,16 @@ int _media_svc_get_media(sqlite3 *handle, const char *sql, GArray **path_list)
return ret;
}
-int _media_svc_get_noti_info(sqlite3 *handle, const char *storage_id, const char *path, media_svc_noti_item **item)
+int _media_svc_get_noti_info(sqlite3 *handle, const char *path, media_svc_noti_item **item)
{
int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
char *sql = NULL;
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");
- sql = sqlite3_mprintf("SELECT media_id, media_type, media_mime_type FROM '%q' WHERE media_path=%Q", storage_id, path);
+ sql = sqlite3_mprintf("SELECT media_id, media_type, media_mime_type FROM %q WHERE media_path=%Q", MEDIA_SVC_DB_TABLE_MEDIA, path);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "_media_svc_sql_prepare_to_step() failed [%d]", ret);
diff --git a/src/common/media-svc-storage.c b/src/common/media-svc-storage.c
index 50cc443..9903a71 100755
--- a/src/common/media-svc-storage.c
+++ b/src/common/media-svc-storage.c
@@ -26,7 +26,7 @@
#include "media-svc-util.h"
#include "media-svc-storage.h"
-int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid)
+int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity)
{
int ret = MS_MEDIA_ERR_NONE;
sqlite3_stmt *sql_stmt = NULL;
@@ -39,7 +39,7 @@ int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **sto
*storage_path = NULL;
*validity = 0;
- sql = sqlite3_mprintf("SELECT storage_path, validity FROM '%q' WHERE storage_id=%Q", MEDIA_SVC_DB_TABLE_STORAGE, storage_id);
+ sql = sqlite3_mprintf("SELECT storage_path, validity FROM %q WHERE storage_id=%Q", MEDIA_SVC_DB_TABLE_STORAGE, storage_id);
ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
@@ -48,28 +48,6 @@ int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **sto
SQLITE3_FINALIZE(sql_stmt);
- /*check storage media table*/
- if (STRING_VALID(storage_id)) {
- int table_cnt = 0;
-
- /*Select list of storage*/
- sql = sqlite3_mprintf("SELECT COUNT(*) FROM SQLITE_MASTER WHERE type='table' and name='%q'", storage_id);
- ret = _media_svc_sql_prepare_to_step(handle, sql, &sql_stmt);
- media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
-
- table_cnt = sqlite3_column_int(sql_stmt, 0);
- SQLITE3_FINALIZE(sql_stmt);
-
- if (table_cnt > 0) {
- /*DO NOT THING*/
- } else {
- media_svc_error("media table not exist for storage [%s]", storage_id);
- /*make storage media table*/
- ret = _media_svc_create_media_table_with_id(storage_id, uid);
- media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "create media table failed : %d", ret);
- }
- }
-
return MS_MEDIA_ERR_NONE;
}
@@ -96,11 +74,11 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons
media_svc_retvm_if(path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL");
/*Get old path*/
- ret = _media_svc_check_storage(handle, storage_id, &old_storage_path, &validity, uid);
+ ret = _media_svc_check_storage(handle, storage_id, &old_storage_path, &validity);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*Storage table update*/
- sql = sqlite3_mprintf("UPDATE '%q' SET storage_path=%Q WHERE storage_id=%Q;", MEDIA_SVC_DB_TABLE_STORAGE, path, storage_id);
+ sql = sqlite3_mprintf("UPDATE %q SET storage_path=%Q WHERE storage_id=%Q", MEDIA_SVC_DB_TABLE_STORAGE, path, storage_id);
ret = _media_svc_sql_query_direct(sql, uid);
SQLITE3_SAFE_FREE(sql);
if (ret != MS_MEDIA_ERR_NONE) {
@@ -109,7 +87,7 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons
}
/*Folder table update*/
- sql = sqlite3_mprintf("UPDATE '%q' SET folder_path=REPLACE(folder_path, %Q, %Q) WHERE storage_uuid=%Q;", MEDIA_SVC_DB_TABLE_FOLDER, old_storage_path, path, storage_id);
+ sql = sqlite3_mprintf("UPDATE %q SET folder_path=REPLACE(folder_path, %Q, %Q) WHERE storage_uuid=%Q", MEDIA_SVC_DB_TABLE_FOLDER, old_storage_path, path, storage_id);
ret = _media_svc_sql_query_direct(sql, uid);
SQLITE3_SAFE_FREE(sql);
if (ret != MS_MEDIA_ERR_NONE) {
@@ -118,7 +96,7 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons
}
/*Media table update*/
- sql = sqlite3_mprintf("UPDATE '%q' SET media_path=REPLACE(media_path, %Q, %Q);", storage_id, old_storage_path, path);
+ sql = sqlite3_mprintf("UPDATE %q SET media_path=REPLACE(media_path, %Q, %Q) WHERE storage_uuid=%Q", MEDIA_SVC_DB_TABLE_MEDIA, old_storage_path, path, storage_id);
ret = _media_svc_sql_query_direct(sql, uid);
SQLITE3_SAFE_FREE(sql);
g_free(old_storage_path);
@@ -127,13 +105,13 @@ int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, cons
return ret;
}
-int __media_svc_delete_thumbnail(sqlite3 *handle, const char *storage_id)
+int __media_svc_delete_thumbnail(sqlite3 *handle)
{
int ret = MS_MEDIA_ERR_NONE;
char *sql = NULL;
sqlite3_stmt *sql_stmt = NULL;
- sql = sqlite3_mprintf("SELECT media_thumbnail_path FROM '%q' WHERE media_thumbnail_path is not null;", storage_id);
+ sql = sqlite3_mprintf("SELECT media_thumbnail_path FROM %q WHERE validity=0 AND media_thumbnail_path is not null", MEDIA_SVC_DB_TABLE_MEDIA);
ret = _media_svc_sql_prepare_to_step_simple(handle, sql, &sql_stmt);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
@@ -149,48 +127,15 @@ int _media_svc_delete_invalid_storage(sqlite3 *handle, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
char *sql = NULL;
- char *storage_id = NULL;
- sqlite3_stmt *sql_stmt = NULL;
- GPtrArray *storage_list = NULL;
- int i = 0;
-
- sql = sqlite3_mprintf("SELECT storage_id FROM '%q' WHERE validity=0;", 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);
- storage_list = g_ptr_array_new_with_free_func(g_free);
+ ret = __media_svc_delete_thumbnail(handle);
+ media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Fail to remove thumbnail");
- while (sqlite3_step(sql_stmt) == SQLITE_ROW) {
- storage_id = g_strdup((const char *)sqlite3_column_text(sql_stmt, 0));
- if (storage_id != NULL)
- g_ptr_array_add(storage_list, storage_id);
- }
+ sql = sqlite3_mprintf("DELETE FROM %q WHERE validity=0;DELETE FROM %q WHERE validity=0;DELETE FROM %q WHERE validity=0;",
+ MEDIA_SVC_DB_TABLE_MEDIA, MEDIA_SVC_DB_TABLE_STORAGE, MEDIA_SVC_DB_TABLE_FOLDER);
- SQLITE3_FINALIZE(sql_stmt);
-
- for (i = 0; i < storage_list->len; i++) {
- storage_id = g_ptr_array_index(storage_list, i);
-
- ret = __media_svc_delete_thumbnail(handle, storage_id);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("Fail to remove thumbnail");
-
- /* remove media before drop table (for clear playlist, and tag table)*/
- sql = sqlite3_mprintf("DELETE FROM '%q';DROP TABLE '%q';", storage_id, storage_id);
- ret = _media_svc_sql_query_direct(sql, uid);
- SQLITE3_SAFE_FREE(sql);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("Fail to drop table[%s]", storage_id);
- }
-
- /* Update storage, folder table */
- sql = sqlite3_mprintf("DELETE FROM %q WHERE validity=0;DELETE FROM %q WHERE validity=0;", MEDIA_SVC_DB_TABLE_STORAGE, MEDIA_SVC_DB_TABLE_FOLDER);
ret = _media_svc_sql_query_direct(sql, uid);
SQLITE3_SAFE_FREE(sql);
- if (ret != MS_MEDIA_ERR_NONE)
- media_svc_error("Fail to update storage table");
-
- g_ptr_array_free(storage_list, TRUE);
return ret;
}
@@ -201,9 +146,9 @@ int _media_svc_update_storage_validity(const char *storage_id, int validity, uid
char *sql = NULL;
if (storage_id == NULL)
- sql = sqlite3_mprintf("UPDATE '%q' SET validity=%d;", MEDIA_SVC_DB_TABLE_STORAGE, validity);
+ sql = sqlite3_mprintf("UPDATE %q SET validity=%d", MEDIA_SVC_DB_TABLE_STORAGE, validity);
else
- sql = sqlite3_mprintf("UPDATE '%q' SET validity=%d WHERE storage_id=%Q;", MEDIA_SVC_DB_TABLE_STORAGE, validity, storage_id);
+ sql = sqlite3_mprintf("UPDATE %q SET validity=%d WHERE storage_id=%Q", MEDIA_SVC_DB_TABLE_STORAGE, validity, storage_id);
ret = _media_svc_sql_query_direct(sql, uid);
SQLITE3_SAFE_FREE(sql);
diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c
index fc3f052..72b543b 100644
--- a/src/common/media-svc-util.c
+++ b/src/common/media-svc-util.c
@@ -1161,7 +1161,7 @@ GET_WIDTH_HEIGHT:
return MS_MEDIA_ERR_NONE;
}
-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_extract_music_metadata_for_update(media_svc_content_info_s *content_info, const char *path)
{
MMHandleType tag = 0;
char *p = NULL;
@@ -1169,7 +1169,6 @@ int _media_svc_extract_music_metadata_for_update(media_svc_content_info_s *conte
int mmf_error = FILEINFO_ERROR_NONE;
char *err_attr_name = NULL;
- 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);
diff --git a/src/common/media-svc.c b/src/common/media-svc.c
index 3e15520..bb1a96c 100755
--- a/src/common/media-svc.c
+++ b/src/common/media-svc.c
@@ -162,7 +162,7 @@ int media_svc_check_item_exist_by_path(sqlite3 *handle, const char *storage_id,
int ret = MS_MEDIA_ERR_NONE;
int count = -1;
- ret = _media_svc_count_record_with_path(handle, storage_id, path, &count);
+ ret = _media_svc_count_record_with_path(handle, path, &count);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
if (count > 0) {
@@ -178,7 +178,7 @@ int media_svc_check_item_exist_by_path(sqlite3 *handle, const char *storage_id,
int media_svc_get_modified_time(sqlite3 *handle, const char *storage_id, const char *path, int *modified_time)
{
- return _media_svc_get_modified_time(handle, storage_id, path, modified_time);
+ return _media_svc_get_modified_time(handle, path, modified_time);
}
int media_svc_insert_item_begin(int data_cnt, bool with_noti, int from_pid)
@@ -269,7 +269,7 @@ int media_svc_insert_item_bulk(sqlite3 *handle, const char *storage_id, ms_user_
if (g_media_svc_insert_item_data_cnt == 1) {
- ret = _media_svc_insert_item_with_data(true, storage_id, &content_info, false, uid);
+ ret = _media_svc_insert_item_with_data(true, &content_info, false, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
if (g_insert_with_noti)
@@ -277,7 +277,7 @@ int media_svc_insert_item_bulk(sqlite3 *handle, const char *storage_id, ms_user_
} else if (g_media_svc_insert_item_cur_data_cnt < (g_media_svc_insert_item_data_cnt - 1)) {
- ret = _media_svc_insert_item_with_data(true, storage_id, &content_info, true, uid);
+ ret = _media_svc_insert_item_with_data(true, &content_info, true, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
if (g_insert_with_noti)
@@ -287,7 +287,7 @@ int media_svc_insert_item_bulk(sqlite3 *handle, const char *storage_id, ms_user_
} else if (g_media_svc_insert_item_cur_data_cnt == (g_media_svc_insert_item_data_cnt - 1)) {
- ret = _media_svc_insert_item_with_data(true, storage_id, &content_info, true, uid);
+ ret = _media_svc_insert_item_with_data(true, &content_info, true, uid);
media_svc_retv_del_if(ret != MS_MEDIA_ERR_NONE, ret, &content_info);
if (g_insert_with_noti)
@@ -370,7 +370,7 @@ int media_svc_insert_item_immediately(sqlite3 *handle, const char *storage_id, m
}
}
- ret = _media_svc_insert_item_with_data(false, storage_id, &content_info, false, uid);
+ ret = _media_svc_insert_item_with_data(false, &content_info, false, uid);
if (ret == MS_MEDIA_ERR_NONE) {
media_svc_debug("Insertion is successful. Sending noti for this");
@@ -397,7 +397,6 @@ int media_svc_move_item(sqlite3 *handle,
int modified_time = 0;
char folder_uuid[MEDIA_SVC_UUID_SIZE + 1] = {0, };
char old_thumb_path[MEDIA_SVC_PATHNAME_SIZE] = {0, };
- char org_stg_id[MEDIA_SVC_UUID_SIZE + 1] = {0, };
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;
@@ -411,8 +410,6 @@ int media_svc_move_item(sqlite3 *handle,
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);
- media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
ret = _media_svc_get_storage_uuid(handle, dest_path, dst_stg_id, uid);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/* Get storage_type */
@@ -446,7 +443,7 @@ int media_svc_move_item(sqlite3 *handle,
}
/*move item*/
- ret = _media_svc_update_item_by_path(org_stg_id, src_path, dst_stg_id, dst_stg_type, dest_path, file_name, modified_time, folder_uuid, uid);
+ ret = _media_svc_update_item_by_path(src_path, dst_stg_id, dst_stg_type, dest_path, file_name, modified_time, folder_uuid, uid);
SAFE_FREE(file_name);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
@@ -489,24 +486,24 @@ int media_svc_set_item_validity_end(uid_t uid)
return ret;
}
-int media_svc_set_item_validity(const char *storage_id, const char *path, int validity, uid_t uid)
+int media_svc_set_item_validity(const char *path, int validity, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
if (g_media_svc_item_validity_data_cnt == 1) {
- return _media_svc_update_item_validity(storage_id, path, validity, false, uid);
+ return _media_svc_update_item_validity(path, validity, false, uid);
} else if (g_media_svc_item_validity_cur_data_cnt < (g_media_svc_item_validity_data_cnt - 1)) {
- ret = _media_svc_update_item_validity(storage_id, path, validity, true, uid);
+ ret = _media_svc_update_item_validity(path, validity, true, uid);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
g_media_svc_item_validity_cur_data_cnt++;
} else if (g_media_svc_item_validity_cur_data_cnt == (g_media_svc_item_validity_data_cnt - 1)) {
- ret = _media_svc_update_item_validity(storage_id, path, validity, true, uid);
+ ret = _media_svc_update_item_validity(path, validity, true, uid);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
ret = _media_svc_list_query_do(MEDIA_SVC_QUERY_SET_ITEM_VALIDITY, uid);
@@ -536,11 +533,11 @@ int media_svc_delete_item_by_path(sqlite3 *handle, const char *storage_id, const
media_svc_retv_if((ret != MS_MEDIA_ERR_NONE) && (ret != MS_MEDIA_ERR_DB_NO_RECORD), ret);
/* Get notification info */
- ret = _media_svc_get_noti_info(handle, storage_id, path, &noti_item);
+ ret = _media_svc_get_noti_info(handle, path, &noti_item);
media_svc_retv_if(ret != MS_MEDIA_ERR_NONE, ret);
/*Delete item*/
- ret = _media_svc_delete_item_by_path(storage_id, path, uid);
+ ret = _media_svc_delete_item_by_path(path, uid);
if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("_media_svc_delete_item_by_path failed : %d", ret);
_media_svc_destroy_noti_item(noti_item);
@@ -595,7 +592,7 @@ int media_svc_refresh_item(sqlite3 *handle, bool is_direct, const char *storage_
media_svc_error("_media_svc_remove_file failed : %s", thumb_path);
}
- ret = _media_svc_update_thumbnail_path(storage_id, path, NULL, uid);
+ ret = _media_svc_update_thumbnail_path(path, NULL, uid);
if (ret != MS_MEDIA_ERR_NONE) {
_media_svc_destroy_content_info(&content_info);
return ret;
@@ -604,7 +601,7 @@ int media_svc_refresh_item(sqlite3 *handle, bool is_direct, const char *storage_
/* Get notification info */
media_svc_noti_item *noti_item = NULL;
- ret = _media_svc_get_noti_info(handle, storage_id, path, &noti_item);
+ ret = _media_svc_get_noti_info(handle, path, &noti_item);
if (ret != MS_MEDIA_ERR_NONE) {
_media_svc_destroy_content_info(&content_info);
return ret;
@@ -639,7 +636,7 @@ int media_svc_refresh_item(sqlite3 *handle, bool is_direct, const char *storage_
}
}
- ret = _media_svc_update_item_with_data(is_direct, storage_id, &content_info, uid);
+ ret = _media_svc_update_item_with_data(is_direct, &content_info, uid);
if (ret == MS_MEDIA_ERR_NONE) {
media_svc_debug("Update is successful. Sending noti for this");
@@ -698,38 +695,31 @@ static void __media_svc_noti_all_storage(sqlite3 *handle, uid_t uid)
g_ptr_array_free(path_list, TRUE);
}
-static void __file_info_free(gpointer data)
-{
- SAFE_FREE(*(media_svc_file_s **)data);
-}
-
int media_svc_update_item_meta(sqlite3 *handle, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
int i = 0;
- /* NOTICE : After 6.0, change 'media_view' to 'media', add 'AND validity=1', and no need storage id */
char *sql = NULL;
+ char *file_path = NULL;
media_svc_content_info_s content_info;
- media_svc_file_s *file_info = NULL;
- GArray *path_list = NULL;
+ GPtrArray *path_list = NULL;
- path_list = g_array_new(FALSE, FALSE, sizeof(media_svc_file_s *));
+ path_list = g_ptr_array_new_with_free_func(g_free);
media_svc_retvm_if(!path_list, MS_MEDIA_ERR_OUT_OF_MEMORY, "Allocation failed");
- g_array_set_clear_func(path_list, __file_info_free);
- sql = sqlite3_mprintf("SELECT media_path, storage_uuid FROM %q WHERE media_type=3", MEDIA_SVC_DB_VIEW_MEDIA);
+ sql = sqlite3_mprintf("SELECT media_path FROM %q WHERE media_type=3 AND validity=1", MEDIA_SVC_DB_TABLE_MEDIA);
ret = _media_svc_get_media(handle, sql, &path_list);
if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("Fail to get media list");
- g_array_free(path_list, TRUE);
+ g_ptr_array_free(path_list, TRUE);
return ret;
}
for (i = 0; i < path_list->len; i++) {
- file_info = g_array_index(path_list, media_svc_file_s *, i);
+ file_path = g_ptr_array_index(path_list, i);
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);
+ ret = _media_svc_extract_music_metadata_for_update(&content_info, file_path);
if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("Fail to extract metadata");
_media_svc_destroy_content_info(&content_info);
@@ -743,7 +733,7 @@ int media_svc_update_item_meta(sqlite3 *handle, uid_t uid)
_media_svc_destroy_content_info(&content_info);
}
- g_array_free(path_list, TRUE);
+ g_ptr_array_free(path_list, TRUE);
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");
@@ -780,9 +770,6 @@ int media_svc_set_storage_validity(sqlite3 *handle, const char *storage_id, int
ret = _media_svc_update_storage_validity(storage_id, validity, uid);
media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "update storage validity failed: %d", ret);
- ret = _media_svc_update_media_view(handle, uid);
- media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "update media view failed : %d", ret);
-
return ret;
}
@@ -802,9 +789,9 @@ int media_svc_generate_uuid(char **uuid)
return MS_MEDIA_ERR_NONE;
}
-int media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid)
+int media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity)
{
- return _media_svc_check_storage(handle, storage_id, storage_path, validity, uid);
+ return _media_svc_check_storage(handle, storage_id, storage_path, validity);
}
int media_svc_update_storage(sqlite3 *handle, const char *storage_id, const char *storage_path, uid_t uid)
@@ -824,12 +811,6 @@ int media_svc_insert_storage(sqlite3 *handle, const char *storage_id, const char
ret = _media_svc_append_storage(storage_id, storage_path, storage_type, uid);
media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "append storage failed : %d", ret);
- ret = _media_svc_create_media_table_with_id(storage_id, uid);
- media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "create media table failed : %d", ret);
-
- ret = _media_svc_update_media_view(handle, uid);
- media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "update media view failed : %d", ret);
-
/* Remove external storage that validity is 0 */
ret = _media_svc_delete_invalid_storage(handle, uid);
media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Delete invalid storage failed : %d", ret);
diff --git a/src/include/common/media-svc-db-utils.h b/src/include/common/media-svc-db-utils.h
index b25e57b..cb62307 100755
--- a/src/include/common/media-svc-db-utils.h
+++ b/src/include/common/media-svc-db-utils.h
@@ -32,8 +32,6 @@
int _media_svc_make_table_query(const char *table_name, media_svc_table_slist_e list, uid_t uid);
int _media_svc_init_table_query(const char *event_table_name);
void _media_svc_destroy_table_query();
-int _media_svc_create_media_table_with_id(const char *table_id, uid_t uid);
-int _media_svc_update_media_view(sqlite3 *db_handle, uid_t uid);
int _media_svc_sql_query(const char *sql_str, uid_t uid);
int _media_svc_sql_query_direct(const char *sql_str, uid_t uid);
int _media_svc_get_user_version(sqlite3 *db_handle, int *user_version);
diff --git a/src/include/common/media-svc-env.h b/src/include/common/media-svc-env.h
index 3dfd52c..77440db 100755
--- a/src/include/common/media-svc-env.h
+++ b/src/include/common/media-svc-env.h
@@ -72,7 +72,7 @@ extern "C" {
/**
* View Name
*/
-#define MEDIA_SVC_DB_VIEW_MEDIA "media_view" /**< media_view*/
+#define MEDIA_SVC_DB_VIEW_MEDIA "media_view" /**< media_view(For upgrade func) */
#define MEDIA_SVC_DB_VIEW_PLAYLIST "playlist_view" /**< playlist_view*/
#define MEDIA_SVC_DB_VIEW_TAG "tag_view" /**< tag_view*/
@@ -115,12 +115,12 @@ extern "C" {
#define MEDIA_SVC_DB_QUERY_VIEW_MEDIA "CREATE VIEW IF NOT EXISTS %s AS SELECT * from %s;"
#define MEDIA_SVC_DB_QUERY_VIEW_PLAYLIST "CREATE VIEW IF NOT EXISTS %s AS SELECT %s FROM playlist \
LEFT OUTER JOIN playlist_map ON playlist.playlist_id = playlist_map.playlist_id \
- LEFT OUTER JOIN media_view ON (playlist_map.media_id = media_view.media_id AND media_view.validity=1) \
- LEFT OUTER JOIN (SELECT count(playlist_id) as playlist_media_count, playlist_id FROM playlist_map group by playlist_id) as cnt_tbl ON (cnt_tbl.playlist_id=playlist_map.playlist_id AND media_view.validity=1);"
+ LEFT OUTER JOIN media ON (playlist_map.media_id = media.media_id AND media.validity=1) \
+ LEFT OUTER JOIN (SELECT count(playlist_id) as playlist_media_count, playlist_id FROM playlist_map group by playlist_id) as cnt_tbl ON (cnt_tbl.playlist_id=playlist_map.playlist_id AND media.validity=1);"
#define MEDIA_SVC_DB_QUERY_VIEW_TAG "CREATE VIEW IF NOT EXISTS %s AS SELECT %s FROM tag \
LEFT OUTER JOIN tag_map ON tag.tag_id=tag_map.tag_id \
- LEFT OUTER JOIN media_view ON (tag_map.media_id = media_view.media_id AND media_view.validity=1) \
- LEFT OUTER JOIN (SELECT count(tag_id) as tag_media_count, tag_id FROM tag_map group by tag_id) as cnt_tbl ON (cnt_tbl.tag_id=tag_map.tag_id AND media_view.validity=1);"
+ LEFT OUTER JOIN media ON (tag_map.media_id = media.media_id AND media.validity=1) \
+ LEFT OUTER JOIN (SELECT count(tag_id) as tag_media_count, tag_id FROM tag_map group by tag_id) as cnt_tbl ON (cnt_tbl.tag_id=tag_map.tag_id AND media.validity=1);"
#define MEDIA_SVC_DB_QUERY_ALTER_TABLE "ALTER TABLE %s ADD COLUMN %s;"
#define MEDIA_SVC_DB_QUERY_DROP_VIEW "DROP VIEW IF EXISTS %s;"
diff --git a/src/include/common/media-svc-media.h b/src/include/common/media-svc-media.h
index 6b7d0cd..171f4b7 100755
--- a/src/include/common/media-svc-media.h
+++ b/src/include/common/media-svc-media.h
@@ -28,21 +28,20 @@
#include "media-svc-noti.h"
#include "media-svc-util.h"
-int _media_svc_count_record_with_path(sqlite3 *handle, const char *storage_id, const char *path, int *count);
-int _media_svc_get_modified_time(sqlite3 *handle, const char *storage_id, const char *path, int *modified_time);
-int _media_svc_insert_item_with_data(bool is_direct, const char *storage_id, media_svc_content_info_s *content_info, bool stack_query, uid_t uid);
-int _media_svc_update_item_with_data(bool is_direct, const char *storage_id, media_svc_content_info_s *content_info, uid_t uid);
+int _media_svc_count_record_with_path(sqlite3 *handle, const char *path, int *count);
+int _media_svc_get_modified_time(sqlite3 *handle, const char *path, int *modified_time);
+int _media_svc_insert_item_with_data(bool is_direct, media_svc_content_info_s *content_info, bool stack_query, uid_t uid);
+int _media_svc_update_item_with_data(bool is_direct, media_svc_content_info_s *content_info, uid_t uid);
int _media_svc_get_thumbnail_path_by_path(sqlite3 *handle, const char *path, char *thumbnail_path);
-int _media_svc_get_media_type_by_path(sqlite3 *handle, const char *storage_id, const char *path, int *media_type);
-int _media_svc_delete_item_by_path(const char *storage_id, const char *path, uid_t uid);
-int _media_svc_update_item_validity(const char *storage_id, const char *path, int validity, bool stack_query, uid_t uid);
-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_delete_item_by_path(const char *path, uid_t uid);
+int _media_svc_update_item_validity(const char *path, int validity, bool stack_query, uid_t uid);
+int _media_svc_update_item_by_path(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, media_svc_noti_item **item);
+int _media_svc_update_thumbnail_path(const char *path, const char *thumb_path, uid_t uid);
+int _media_svc_get_noti_info(sqlite3 *handle, 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);
-int _media_svc_get_media(sqlite3 *handle, const char *sql, GArray **path_list);
+int _media_svc_get_media(sqlite3 *handle, const char *sql, GPtrArray **path_list);
#endif /*_MEDIA_SVC_MEDIA_H_*/
diff --git a/src/include/common/media-svc-storage.h b/src/include/common/media-svc-storage.h
index 48f47a2..f46d3ee 100755
--- a/src/include/common/media-svc-storage.h
+++ b/src/include/common/media-svc-storage.h
@@ -24,7 +24,7 @@
#include <sqlite3.h>
-int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid);
+int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity);
int _media_svc_append_storage(const char *storage_id, const char *storage_path, ms_user_storage_type_e storage_type, uid_t uid);
int _media_svc_update_storage_path(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid);
int _media_svc_delete_invalid_storage(sqlite3 *handle, uid_t uid);
diff --git a/src/include/common/media-svc-util.h b/src/include/common/media-svc-util.h
index 2b69c46..56e0d49 100755
--- a/src/include/common/media-svc-util.h
+++ b/src/include/common/media-svc-util.h
@@ -112,14 +112,6 @@ 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 {
@@ -146,7 +138,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, const char *storage_id, const char *path);
+int _media_svc_extract_music_metadata_for_update(media_svc_content_info_s *content_info, 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);