From: Minje Ahn Date: Fri, 18 Jan 2019 00:39:58 +0000 (+0900) Subject: Move get_folder_id X-Git-Tag: accepted/tizen/unified/20190129.064317~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f0a83ca5278bf6cce65ee76a43d8e2bdd2e3fe22;p=platform%2Fcore%2Fmultimedia%2Fmedia-server.git Move get_folder_id Move API from plugin to media-common Change-Id: Ifc31e0146dfd839ad3bcca460b0765bc1b1c4147 Signed-off-by: Minje Ahn --- diff --git a/src/common/include/media-common-db-svc.h b/src/common/include/media-common-db-svc.h index 07eb01f..a3c1981 100755 --- a/src/common/include/media-common-db-svc.h +++ b/src/common/include/media-common-db-svc.h @@ -95,7 +95,6 @@ typedef int (*UPDATE_ITEM_END)(uid_t); typedef int (*DELETE_INVALID_FOLDER_BY_PATH)(sqlite3 *, const char *, const char *, uid_t); typedef int (*CHECK_FOLDER_EXIST)(sqlite3*, const char*, const char*); -typedef int (*GET_FOLDER_ID)(sqlite3 *, const char *, const char *, char *); typedef int (*GET_EXTRACT_LIST)(sqlite3*, const char*, int, int, const char*, int, uid_t, void*); typedef int (*UPDATE_ONE_EXTRACT_ITEM)(sqlite3*, const char*, int, void *); typedef int (*QUERY_DO_UPDATE_LIST)(sqlite3*); diff --git a/src/common/media-common-db-svc.c b/src/common/media-common-db-svc.c index 1aff3d7..4527248 100755 --- a/src/common/media-common-db-svc.c +++ b/src/common/media-common-db-svc.c @@ -81,7 +81,6 @@ enum func_list { eUPDATE_ITEM_END, eDELETE_INVALID_FOLDER_BY_PATH, eCHECK_FOLDER_EXIST, - eGET_FOLDER_ID, eGET_MEDIA_TYPE, eGET_EXTRACT_LIST, eUPDATE_ONE_EXTRACT_ITEM, @@ -184,7 +183,6 @@ int ms_load_functions(void) "update_item_end", "delete_invalid_folder_by_path", "check_folder_exist", - "get_folder_id", "get_media_type", "get_extract_list", "update_one_extract_item", @@ -882,23 +880,27 @@ int ms_check_folder_exist(sqlite3 *handle, const char *storage_id, const char *f int ms_get_folder_id(sqlite3 *handle, const char *storage_id, const char *path, char **folder_id) { - int lib_index; int ret = MS_MEDIA_ERR_NONE; - char folder_uuid[MS_UUID_SIZE] = {0,}; + sqlite3_stmt *sql_stmt = NULL; + char *sql = NULL; - MS_DBG_FENTER(); + MS_DBG_RETVM_IF(storage_id == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL"); + MS_DBG_RETVM_IF(path == NULL, MS_MEDIA_ERR_INVALID_PARAMETER, "path is NULL"); - for (lib_index = 0; lib_index < lib_num; lib_index++) { - ret = ((GET_FOLDER_ID)func_array[lib_index][eGET_FOLDER_ID])(handle, storage_id, path, folder_uuid); /*dlopen*/ - MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Error : %s", g_array_index(so_array, char*, lib_index)); - } + sql = sqlite3_mprintf("SELECT folder_uuid FROM folder WHERE (storage_uuid='%q' AND path='%q')", storage_id, path); - if (strlen(folder_uuid) == (MS_UUID_SIZE-1)) - *folder_id = strdup(folder_uuid); - else + ret = media_db_get_result(handle, sql, &sql_stmt); + MS_DBG_RETV_IF(ret != MS_MEDIA_ERR_NONE, ret); + + if (sqlite3_step(sql_stmt) == SQLITE_ROW) { + *folder_id = g_strdup((const char *)sqlite3_column_text(sql_stmt, 0)); + MS_DBG("folder_id [%s]", *folder_id); + } else { *folder_id = NULL; + ret = MS_MEDIA_ERR_DB_NO_RECORD; + } - MS_DBG("folder_id [%s]", *folder_id); + MS_SQLITE3_FINALIZE(sql_stmt); return ret; }