From 3c8e1e935443fbd648d4f2051c66b3f3e08d9383 Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Tue, 14 Jul 2020 17:02:55 +0900 Subject: [PATCH] Remove unnecessary plugin API 1. Remove plugin APIs that are no longer used. 2. Remove unnecessary parameters. Change-Id: I26b403d74c2194479af6369c3b7b13346840b728 Signed-off-by: Minje Ahn --- src/common/include/media-common-db-svc.h | 10 +++----- src/common/media-common-db-svc.c | 43 ++++---------------------------- src/scanner-v2/media-scanner-scan-v2.c | 31 +++++++++++------------ src/scanner/media-scanner-scan.c | 20 +++++++-------- 4 files changed, 32 insertions(+), 72 deletions(-) diff --git a/src/common/include/media-common-db-svc.h b/src/common/include/media-common-db-svc.h index 89d6c55..75f9b7d 100755 --- a/src/common/include/media-common-db-svc.h +++ b/src/common/include/media-common-db-svc.h @@ -37,10 +37,8 @@ typedef enum { } ms_noti_type_e; typedef int (*CLEANUP_DB)(sqlite3*, uid_t); -typedef int (*INSERT_ITEM_BEGIN)(int, bool, int); +typedef int (*INSERT_ITEM_BEGIN)(bool, int); typedef int (*INSERT_ITEM_END)(uid_t); -typedef int (*SET_ITEM_VALIDITY_BEGIN)(int); -typedef int (*SET_ITEM_VALIDITY_END)(uid_t); typedef int (*SEND_DIR_UPDATE_NOTI)(const char *, const char *, int, int); typedef int (*INSERT_ITEM)(sqlite3 *, const char *, const char *, int, uid_t); @@ -119,14 +117,12 @@ bool ms_check_support_media_type(const char *path); /* FOR BULK COMMIT */ void ms_register_start(bool noti_status, int pid); void ms_register_end(uid_t uid); -void ms_validate_start(void); -void ms_validate_end(uid_t uid); int ms_get_extract_list(sqlite3 *handle, const char* storage_id, int storage_type, int scan_type, const char* path, int is_end, uid_t uid, void* array); int ms_update_one_extract_item(sqlite3 *handle, const char* storage_id, int storage_type, void* data); int ms_query_do_update_list(sqlite3 *handle); -void ms_batch_commit_enable(bool ins_status, bool valid_status, bool noti_enable, int pid); -void ms_batch_commit_disable(bool ins_status, bool valid_status, uid_t uid); +void ms_batch_commit_enable(bool noti_enable, int pid); +void ms_batch_commit_disable(uid_t uid); #endif /*_MEDIA_COMMON_DB_SVC_H_*/ diff --git a/src/common/media-common-db-svc.c b/src/common/media-common-db-svc.c index f2fe040..37caaf1 100644 --- a/src/common/media-common-db-svc.c +++ b/src/common/media-common-db-svc.c @@ -29,8 +29,6 @@ #include #define CONFIG_PATH PATH_LIBDIR"/libmedia-content-plugin.so" -#define MSC_REGISTER_COUNT 300 /*For bundle commit*/ -#define MSC_VALID_COUNT 300 /*For bundle commit*/ static GMutex db_mutex; static void **func_array; @@ -43,8 +41,6 @@ enum func_list { eINSERT_END, eINSERT_BATCH, eINSERT_SCAN, - eSET_VALIDITY_BEGIN, - eSET_VALIDITY_END, eSET_VALIDITY, eDELETE_FOLDER, eSEND_DIR_UPDATE_NOTI, @@ -85,8 +81,6 @@ int ms_load_functions(void) "insert_item_end", "insert_item", "insert_item_scan", - "set_item_validity_begin", - "set_item_validity_end", "set_item_validity", "delete_all_invalid_items_in_folder", "send_dir_update_noti", @@ -723,7 +717,7 @@ void ms_register_start(bool noti_status, int pid) { int ret = MS_MEDIA_ERR_NONE; - ret = ((INSERT_ITEM_BEGIN)func_array[eINSERT_BEGIN])(MSC_REGISTER_COUNT, noti_status, pid);/*dlopen*/ + ret = ((INSERT_ITEM_BEGIN)func_array[eINSERT_BEGIN])(noti_status, pid);/*dlopen*/ if (ret != MS_MEDIA_ERR_NONE) MS_DBG_ERR("INSERT_ITEM_BEGIN failed [%d]", ret); } @@ -737,24 +731,6 @@ void ms_register_end(uid_t uid) MS_DBG_ERR("INSERT_ITEM_END failed [%d]", ret); } -void ms_validate_start(void) -{ - int ret = MS_MEDIA_ERR_NONE; - - ret = ((SET_ITEM_VALIDITY_BEGIN)func_array[eSET_VALIDITY_BEGIN])(MSC_VALID_COUNT);/*dlopen*/ - if (ret != MS_MEDIA_ERR_NONE) - MS_DBG_ERR("SET_ITEM_VALIDITY_BEGIN failed [%d]", ret); -} - -void ms_validate_end(uid_t uid) -{ - int ret = MS_MEDIA_ERR_NONE; - - ret = ((SET_ITEM_VALIDITY_END)func_array[eSET_VALIDITY_END])(uid);/*dlopen*/ - if (ret != MS_MEDIA_ERR_NONE) - MS_DBG_ERR("SET_ITEM_VALIDITY_END failed [%d]", ret); -} - int ms_get_folder_scan_status(sqlite3 *handle, const char *storage_id, const char *path, int *scan_status) { int ret = MS_MEDIA_ERR_NONE; @@ -864,22 +840,13 @@ bool ms_check_support_media_type(const char *path) return true; } -void ms_batch_commit_enable(bool ins_status, bool valid_status, bool noti_enable, int pid) +void ms_batch_commit_enable(bool noti_enable, int pid) { /*call for bundle commit*/ - if (ins_status) - ms_register_start(noti_enable, pid); - - if (valid_status) - ms_validate_start(); + ms_register_start(noti_enable, pid); } -void ms_batch_commit_disable(bool ins_status, bool valid_status, uid_t uid) +void ms_batch_commit_disable(uid_t uid) { - /*call for bundle commit*/ - if (valid_status) - ms_validate_end(uid); - - if (ins_status) - ms_register_end(uid); + ms_register_end(uid); } diff --git a/src/scanner-v2/media-scanner-scan-v2.c b/src/scanner-v2/media-scanner-scan-v2.c index aee22a2..71125b8 100644 --- a/src/scanner-v2/media-scanner-scan-v2.c +++ b/src/scanner-v2/media-scanner-scan-v2.c @@ -294,8 +294,8 @@ static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, co goto STOP_SCAN; } - ms_batch_commit_disable(true, true, uid); - ms_batch_commit_enable(true, true, false, pid); + ms_batch_commit_disable(uid); + ms_batch_commit_enable(false, pid); /* get the current path from directory array */ current_path = g_array_index(dir_array , char*, 0); g_array_remove_index(dir_array, 0); @@ -527,7 +527,7 @@ END_SCAN: __msc_clear_file_list(dir_array); - ms_batch_commit_disable(true, true, uid); + ms_batch_commit_disable(uid); if (ret != MS_MEDIA_ERR_NONE) MS_DBG_INFO("ret : %d", ret); @@ -571,7 +571,7 @@ static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, c scan_function = (scan_type == MS_MSG_STORAGE_ALL) ? ms_scan_item_batch : ms_scan_validate_item; - ms_batch_commit_disable(true, true, uid); + ms_batch_commit_disable(uid); /*start db update. the number of element in the array , db update is complete.*/ while (dir_array->len != 0) { /*check poweroff status*/ @@ -579,8 +579,8 @@ static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, c if (ret != MS_MEDIA_ERR_NONE) goto STOP_SCAN; - /*ms_batch_commit_disable(true, true, uid);*/ - ms_batch_commit_enable(true, true, false, pid); + /*ms_batch_commit_disable(uid);*/ + ms_batch_commit_enable(false, pid); /* get the current path from directory array */ current_path = g_array_index(dir_array , char*, 0); @@ -756,7 +756,7 @@ static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, c } /*commit to db before set scan done, fix timing issue storage scan, then folder scan for same folder*/ - ms_batch_commit_disable(true, true, uid); + ms_batch_commit_disable(uid); ms_set_folder_scan_status(handle, storage_id, current_path, MS_DIR_SCAN_DONE, uid); if (fd != -1) { @@ -843,7 +843,7 @@ EXIT: __msc_set_storage_scan_cur_path(NULL); __msc_clear_file_list(dir_array); - ms_batch_commit_disable(true, true, uid); + ms_batch_commit_disable(uid); if (ret != MS_MEDIA_ERR_NONE) MS_DBG_INFO("ret : %d", ret); @@ -1191,13 +1191,13 @@ gpointer msc_directory_scan_thread(gpointer data) MS_DBG_ERR("error : %d", err); /*call for bundle commit*/ - ms_batch_commit_enable(true, true, false, 0); + ms_batch_commit_enable(false, 0); /*insert data into media db */ ret = __msc_db_update(handle, storage_id, scan_data); /*call for bundle commit*/ - ms_batch_commit_disable(true, true, uid); + ms_batch_commit_disable(uid); MS_DBG_WARN("folder scan done, sent cb event path = [%.*s]", MAX_MSG_SIZE, scan_data->msg); __msc_call_dir_scan_cb(); @@ -1305,7 +1305,6 @@ gpointer msc_storage_scan_thread(gpointer data) sqlite3 *handle = NULL; ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL; int scan_type; - bool valid_status = true; char *update_path = NULL; uid_t uid = MEDIA_DEFAULT_UID; @@ -1359,10 +1358,8 @@ gpointer msc_storage_scan_thread(gpointer data) /*start db updating */ ms_set_db_status(MS_DB_UPDATING, storage_type); - valid_status = (scan_type == MS_MSG_STORAGE_PARTIAL || MS_MSG_STORAGE_ALL == scan_type) ? true : false; - if (scan_type != MS_MSG_STORAGE_INVALID) - ms_batch_commit_enable(true, valid_status, false, 0); + ms_batch_commit_enable(false, 0); if (scan_type == MS_MSG_STORAGE_ALL) { /* Delete all data before full scanning */ @@ -1374,7 +1371,7 @@ gpointer msc_storage_scan_thread(gpointer data) /*call for bundle commit*/ if (scan_type != MS_MSG_STORAGE_INVALID) - ms_batch_commit_disable(true, valid_status, uid); + ms_batch_commit_disable(uid); if (scan_type == MS_MSG_STORAGE_PARTIAL && ret == MS_MEDIA_ERR_NONE) { /*delete invalid folder first, then delete invalid item, avoid to folder was deleted but item not when unmount*/ @@ -1527,7 +1524,7 @@ static int __msc_batch_insert(int pid, GArray *path_array, uid_t uid) /*start db updating */ /*call for bundle commit*/ - ms_batch_commit_enable(true, false, true, pid); + ms_batch_commit_enable(true, pid); MS_DBG_WARN("BULK REGISTER START"); @@ -1555,7 +1552,7 @@ static int __msc_batch_insert(int pid, GArray *path_array, uid_t uid) } /*call for bundle commit*/ - ms_batch_commit_disable(true, false, uid); + ms_batch_commit_disable(uid); /*disconnect form media db*/ if (handle) ms_disconnect_db(handle); diff --git a/src/scanner/media-scanner-scan.c b/src/scanner/media-scanner-scan.c index 91d8d08..6fcd99e 100644 --- a/src/scanner/media-scanner-scan.c +++ b/src/scanner/media-scanner-scan.c @@ -189,9 +189,9 @@ static int __msc_directory_scan_insert_only(sqlite3 *handle, ms_comm_msg_s *scan start_path = g_strdup(scan_data->msg); - ms_batch_commit_enable(true, true, false, 0); + ms_batch_commit_enable(false, 0); ret = __msc_dir_scan(handle, scan_data->storage_id, start_path, false, is_recursive, scan_data->uid); - ms_batch_commit_disable(true, true, scan_data->uid); + ms_batch_commit_disable(scan_data->uid); if (ret != MS_MEDIA_ERR_SCANNER_FORCE_STOP) { MS_DBG_INFO("working normally"); @@ -229,9 +229,9 @@ static int __msc_directory_scan_update_and_delete(sqlite3 *handle, ms_comm_msg_s return ret; } - ms_batch_commit_enable(true, true, false, 0); + ms_batch_commit_enable(false, 0); ret = __msc_dir_scan(handle, scan_data->storage_id, start_path, true, is_recursive, scan_data->uid); - ms_batch_commit_disable(true, true, scan_data->uid); + ms_batch_commit_disable(scan_data->uid); if (ms_delete_invalid_items(handle, scan_data->storage_id, scan_data->uid) != MS_MEDIA_ERR_NONE) MS_DBG_ERR("deleting invalid items in storage failed"); @@ -336,9 +336,9 @@ static int __msc_storage_scan_partial(ms_comm_msg_s *scan_data, ms_user_storage_ return ret; } - ms_batch_commit_enable(true, true, false, 0); + ms_batch_commit_enable(false, 0); ret = __msc_db_update(handle, scan_data->storage_id, scan_data); - ms_batch_commit_disable(true, true, scan_data->uid); + ms_batch_commit_disable(scan_data->uid); if (ms_delete_invalid_items(handle, scan_data->storage_id, scan_data->uid) != MS_MEDIA_ERR_NONE) MS_DBG_ERR("deleting invalid items in storage failed"); @@ -361,9 +361,9 @@ static int __msc_storage_scan_all(ms_comm_msg_s *scan_data, ms_user_storage_type ms_set_db_status(MS_DB_UPDATING, storage_type); - ms_batch_commit_enable(true, false, false, 0); + ms_batch_commit_enable(false, 0); ret = __msc_db_update(handle, scan_data->storage_id, scan_data); - ms_batch_commit_disable(true, false, scan_data->uid); + ms_batch_commit_disable(scan_data->uid); ms_disconnect_db(handle); @@ -480,7 +480,7 @@ static int __msc_batch_insert(int pid, GPtrArray *path_array, uid_t uid) ret = ms_connect_db(&handle, uid); MS_DBG_RETV_IF(ret != MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_DB_INTERNAL); - ms_batch_commit_enable(true, false, true, pid); + ms_batch_commit_enable(true, pid); for (i = 0; i < path_array->len; i++) { insert_path = g_ptr_array_index(path_array, i); @@ -500,7 +500,7 @@ static int __msc_batch_insert(int pid, GPtrArray *path_array, uid_t uid) } /*call for bundle commit*/ - ms_batch_commit_disable(true, false, uid); + ms_batch_commit_disable(uid); ms_disconnect_db(handle); return ret; -- 2.7.4