From 531c7b8f3b46060e03fc655ec87291ca0b952e11 Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Thu, 29 Nov 2018 10:59:54 +0900 Subject: [PATCH] Change storage type function Use media-util function instead Change-Id: I83c690b20c900201fe284de7ab7b6181b7eed56c Signed-off-by: Minje Ahn --- CMakeLists.txt | 1 - include/media-svc-types.h | 10 -- include/media-svc.h | 17 ++- src/common/media-svc-media-folder.c | 10 +- src/common/media-svc-media.c | 8 +- src/common/media-svc-storage.c | 4 +- src/common/media-svc-util.c | 4 +- src/common/media-svc.c | 36 ++--- src/include/common/media-svc-media-folder.h | 7 +- src/include/common/media-svc-media.h | 6 +- src/include/common/media-svc-storage.h | 4 +- src/include/common/media-svc-util.h | 5 +- test/CMakeLists.txt | 18 --- test/media-service-test.c | 212 ---------------------------- test/plugin/Makefile | 14 -- test/plugin/media_svc_plugin_test.c | 212 ---------------------------- 16 files changed, 42 insertions(+), 526 deletions(-) delete mode 100755 test/CMakeLists.txt delete mode 100755 test/media-service-test.c delete mode 100644 test/plugin/Makefile delete mode 100755 test/plugin/media_svc_plugin_test.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 35d3a2a..9301826 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,7 +77,6 @@ SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--hash-style=both") CONFIGURE_FILE(libmedia-service.pc.in libmedia-service.pc @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libmedia-service.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) -#ADD_SUBDIRECTORY(test) IF(BUILD_GTESTS) ADD_SUBDIRECTORY(unittest) ENDIF(BUILD_GTESTS) diff --git a/include/media-svc-types.h b/include/media-svc-types.h index ab46721..118c8dd 100755 --- a/include/media-svc-types.h +++ b/include/media-svc-types.h @@ -29,16 +29,6 @@ typedef void MediaSvcHandle; /**< Handle */ /** - * Type definition for storage type - */ -typedef enum { - MEDIA_SVC_STORAGE_INTERNAL = 0, /**< The device's internal storage */ - MEDIA_SVC_STORAGE_EXTERNAL = 1, /**< The device's external storage like sd card*/ - MEDIA_SVC_STORAGE_EXTERNAL_USB = 2, /**< The external USB storage (Since 2.4) */ - MEDIA_SVC_STORAGE_MAX, /**< Invalid storage*/ -} media_svc_storage_type_e; - -/** * Type definition for content type */ typedef enum { diff --git a/include/media-svc.h b/include/media-svc.h index 77932c1..0f6869e 100755 --- a/include/media-svc.h +++ b/include/media-svc.h @@ -25,7 +25,7 @@ #define _MEDIA_SVC_H_ #include "media-svc-types.h" -#include +#include #include #include #ifdef __cplusplus @@ -39,22 +39,21 @@ int media_svc_cleanup_db(MediaSvcHandle *handle, uid_t uid); int media_svc_get_user_version(MediaSvcHandle *handle, int *user_version); int media_svc_create_table(uid_t uid); int media_svc_check_item_exist_by_path(MediaSvcHandle *handle, const char *storage_id, const char *path); -int media_svc_insert_folder(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid); +int media_svc_insert_folder(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid); int media_svc_insert_item_begin(int with_noti, int data_cnt, int from_pid); int media_svc_insert_item_end(uid_t uid); -int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid); -int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid); +int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid); +int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid); int media_svc_move_item(MediaSvcHandle *handle, const char *src_path, const char *dest_path, uid_t uid); 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_delete_item_by_path(MediaSvcHandle *handle, const char *storage_id, const char *path, uid_t uid); -int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, uid_t uid); -int media_svc_set_all_storage_items_validity(const char *storage_id, media_svc_storage_type_e storage_type, int validity, uid_t uid); +int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, uid_t uid); +int media_svc_set_all_storage_items_validity(const char *storage_id, ms_user_storage_type_e storage_type, int validity, uid_t uid); int media_svc_set_folder_items_validity(MediaSvcHandle *handle, const char *storage_id, const char *folder_path, int validity, int recursive, uid_t uid); -int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid); +int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid); int media_svc_request_update_db(const char *db_query, uid_t uid); -int media_svc_get_storage_type(const char *path, media_svc_storage_type_e *storage_type, uid_t uid); int media_svc_get_file_info(MediaSvcHandle *handle, const char *storage_id, const char *path, time_t *modified_time, unsigned long long *size); int media_svc_send_dir_update_noti(MediaSvcHandle *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_check_db_upgrade(MediaSvcHandle *handle, int user_version, uid_t uid); @@ -67,7 +66,7 @@ int media_svc_update_item_meta(MediaSvcHandle *handle, const char *file_path, co int media_svc_generate_uuid(char **uuid); int media_svc_check_storage(MediaSvcHandle *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid); -int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_path, media_svc_storage_type_e storage_type, uid_t uid); +int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_path, ms_user_storage_type_e storage_type, uid_t uid); int media_svc_update_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_path, uid_t uid); int media_svc_set_storage_validity(MediaSvcHandle *handle, const char *storage_id, int validity, uid_t uid); int media_svc_get_storage_id(MediaSvcHandle *handle, const char *path, char *storage_id, uid_t uid); diff --git a/src/common/media-svc-media-folder.c b/src/common/media-svc-media-folder.c index ff7bb37..600f79b 100755 --- a/src/common/media-svc-media-folder.c +++ b/src/common/media-svc-media-folder.c @@ -82,7 +82,7 @@ int _media_svc_get_folder_id_by_foldername_with_validity(sqlite3 *handle, const return ret; } -static int __media_svc_append_folder(const char *storage_id, media_svc_storage_type_e storage_type, +static int __media_svc_append_folder(const char *storage_id, ms_user_storage_type_e storage_type, const char *folder_id, const char *folder_path, bool stack_query, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; @@ -129,7 +129,7 @@ int _media_svc_update_folder_modified_time_by_folder_uuid(const char *folder_uui return ret; } -static int __media_svc_get_and_append_parent_folder(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, uid_t uid) +static int __media_svc_get_and_append_parent_folder(sqlite3 *handle, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, char *folder_id, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; unsigned int next_pos = 0; @@ -267,7 +267,7 @@ static int __media_svc_update_parent_folder_validity(sqlite3 *handle, const char return MS_MEDIA_ERR_NONE; } -int _media_svc_get_and_append_folder(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, uid_t uid) +int _media_svc_get_and_append_folder(sqlite3 *handle, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, char *folder_id, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; int validity = -1; @@ -282,7 +282,7 @@ int _media_svc_get_and_append_folder(sqlite3 *handle, const char *storage_id, co return ret; } -int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, uid_t uid) +int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, char *folder_id, uid_t uid) { char *dir_path = NULL; int ret = MS_MEDIA_ERR_NONE; @@ -296,7 +296,7 @@ int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *sto return ret; } -int _media_svc_get_and_append_folder_id_by_folder_path(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, bool stack_query, uid_t uid) +int _media_svc_get_and_append_folder_id_by_folder_path(sqlite3 *handle, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, char *folder_id, bool stack_query, uid_t uid) { char *path_name = NULL; int ret = MS_MEDIA_ERR_NONE; diff --git a/src/common/media-svc-media.c b/src/common/media-svc-media.c index 2096d63..98070f6 100755 --- a/src/common/media-svc-media.c +++ b/src/common/media-svc-media.c @@ -429,7 +429,7 @@ int _media_svc_delete_item_by_path(const char *storage_id, const char *path, boo return ret; } -int _media_svc_delete_invalid_items(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, uid_t uid) +int _media_svc_delete_invalid_items(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; GArray *thumb_list = NULL; @@ -437,7 +437,7 @@ int _media_svc_delete_invalid_items(sqlite3 *handle, const char *storage_id, med thumb_list = g_array_new(FALSE, FALSE, sizeof(char*)); /*If external USB, no need this process */ - if (storage_type != MEDIA_SVC_STORAGE_EXTERNAL_USB) { + if (storage_type != MS_USER_STORAGE_EXTERNAL_USB) { ret = __media_svc_get_invalid_records_with_thumbnail(handle, storage_id, &thumb_list); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("error when get thumbnail record"); @@ -510,7 +510,7 @@ int _media_svc_update_thumbnail_path(const char *storage_id, const char *path, c return ret; } -int _media_svc_update_storage_item_validity(const char *storage_id, media_svc_storage_type_e storage_type, int validity, uid_t uid) +int _media_svc_update_storage_item_validity(const char *storage_id, ms_user_storage_type_e storage_type, int validity, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; @@ -567,7 +567,7 @@ int _media_svc_update_recursive_folder_item_validity(const char *storage_id, con return ret; } -int _media_svc_update_item_by_path(const char *org_storage_id, const char *src_path, const char *dst_storage_id, media_svc_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 *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) { /* update path, filename, modified_time, folder_uuid, thumbnail_path, */ diff --git a/src/common/media-svc-storage.c b/src/common/media-svc-storage.c index 39eb497..13326fe 100755 --- a/src/common/media-svc-storage.c +++ b/src/common/media-svc-storage.c @@ -69,7 +69,7 @@ int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **sto return MS_MEDIA_ERR_NONE; } -int _media_svc_append_storage(const char *storage_id, const char *storage_path, media_svc_storage_type_e storage_type, uid_t uid) +int _media_svc_append_storage(const char *storage_id, const char *storage_path, ms_user_storage_type_e storage_type, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; char *sql = sqlite3_mprintf("INSERT INTO %q (storage_uuid, storage_path, storage_type) values (%Q, %Q, %d);", @@ -138,7 +138,7 @@ int __media_svc_delete_thumbnail(sqlite3 *handle, const char *storage_id) return ret; } -int _media_svc_delete_invalid_storage(sqlite3 *handle, media_svc_storage_type_e storage_type, uid_t uid) +int _media_svc_delete_invalid_storage(sqlite3 *handle, ms_user_storage_type_e storage_type, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; char *sql = NULL; diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c index 33b2654..6f408a3 100755 --- a/src/common/media-svc-util.c +++ b/src/common/media-svc-util.c @@ -813,7 +813,7 @@ 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, media_svc_storage_type_e storage_type, +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 ret = MS_MEDIA_ERR_NONE; @@ -1456,7 +1456,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s } /*Do not extract artwork for the USB Storage content*/ - if (content_info->storage_type != MEDIA_SVC_STORAGE_EXTERNAL_USB) { + if (content_info->storage_type != MS_USER_STORAGE_EXTERNAL_USB) { mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTWORK, &image, &size, NULL); if (mmf_error != FILEINFO_ERROR_NONE) { media_svc_error("fail to get tag artwork - err(%x)", mmf_error); diff --git a/src/common/media-svc.c b/src/common/media-svc.c index d36dcdf..ae2ab93 100755 --- a/src/common/media-svc.c +++ b/src/common/media-svc.c @@ -21,7 +21,6 @@ #include #include -#include #include "media-svc.h" #include "media-svc-media.h" #include "media-svc-debug.h" @@ -50,11 +49,11 @@ static __thread int g_insert_with_noti = FALSE; #define BATCH_REQUEST_MAX 300 -static bool __media_svc_check_storage(media_svc_storage_type_e storage_type) +static bool __media_svc_check_storage(ms_user_storage_type_e storage_type) { - if ((storage_type != MEDIA_SVC_STORAGE_INTERNAL) - && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL) - && (storage_type != MEDIA_SVC_STORAGE_EXTERNAL_USB)) { + if ((storage_type != MS_USER_STORAGE_INTERNAL) + && (storage_type != MS_USER_STORAGE_EXTERNAL) + && (storage_type != MS_USER_STORAGE_EXTERNAL_USB)) { media_svc_error("storage type is incorrect[%d]", storage_type); return FALSE; } @@ -215,19 +214,6 @@ ERROR: return ret; } -int media_svc_get_storage_type(const char *path, media_svc_storage_type_e *storage_type, uid_t uid) -{ - int ret = MS_MEDIA_ERR_NONE; - ms_user_storage_type_e type = -1; - - ret = ms_user_get_storage_type(uid, path, &type); - media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "ms_user_get_storage_type failed : %d", ret); - - *storage_type = type; - - return ret; -} - int media_svc_get_file_info(MediaSvcHandle *handle, const char *storage_id, const char *path, time_t *modified_time, unsigned long long *size) { int ret = MS_MEDIA_ERR_NONE; @@ -311,7 +297,7 @@ int media_svc_insert_item_end(uid_t uid) return ret; } -int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid) +int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; sqlite3 *db_handle = (sqlite3 *)handle; @@ -401,7 +387,7 @@ int media_svc_insert_item_bulk(MediaSvcHandle *handle, const char *storage_id, m return MS_MEDIA_ERR_NONE; } -int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid) +int media_svc_insert_item_immediately(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; sqlite3 *db_handle = (sqlite3 *)handle; @@ -678,7 +664,7 @@ int media_svc_delete_item_by_path(MediaSvcHandle *handle, const char *storage_id return MS_MEDIA_ERR_NONE; } -int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, uid_t uid) +int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, uid_t uid) { sqlite3 *db_handle = (sqlite3 *)handle; @@ -692,7 +678,7 @@ int media_svc_delete_invalid_items_in_storage(MediaSvcHandle *handle, const char return _media_svc_delete_invalid_items(db_handle, storage_id, storage_type, uid); } -int media_svc_set_all_storage_items_validity(const char *storage_id, media_svc_storage_type_e storage_type, int validity, uid_t uid) +int media_svc_set_all_storage_items_validity(const char *storage_id, ms_user_storage_type_e storage_type, int validity, uid_t uid) { media_svc_retvm_if(!STRING_VALID(storage_id), MS_MEDIA_ERR_INVALID_PARAMETER, "storage_id is NULL"); media_svc_retvm_if(__media_svc_check_storage(storage_type) != TRUE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid storage_type"); @@ -714,7 +700,7 @@ int media_svc_set_folder_items_validity(MediaSvcHandle *handle, const char *stor return _media_svc_update_folder_item_validity(db_handle, storage_id, folder_path, validity, uid); } -int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid) +int media_svc_refresh_item(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; sqlite3 *db_handle = (sqlite3 *)handle; @@ -1044,7 +1030,7 @@ int media_svc_update_storage(MediaSvcHandle *handle, const char *storage_id, con return _media_svc_update_storage_path(db_handle, storage_id, storage_path, uid); } -int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_path, media_svc_storage_type_e storage_type, uid_t uid) +int media_svc_insert_storage(MediaSvcHandle *handle, const char *storage_id, const char *storage_path, ms_user_storage_type_e storage_type, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; sqlite3 *db_handle = (sqlite3 *)handle; @@ -1097,7 +1083,7 @@ int media_svc_insert_folder_end(uid_t uid) return ret; } -int media_svc_insert_folder(MediaSvcHandle *handle, const char *storage_id, media_svc_storage_type_e storage_type, const char *path, uid_t uid) +int media_svc_insert_folder(MediaSvcHandle *handle, const char *storage_id, ms_user_storage_type_e storage_type, const char *path, uid_t uid) { int ret = MS_MEDIA_ERR_NONE; sqlite3 * db_handle = (sqlite3 *)handle; diff --git a/src/include/common/media-svc-media-folder.h b/src/include/common/media-svc-media-folder.h index c52fa27..f424b41 100755 --- a/src/include/common/media-svc-media-folder.h +++ b/src/include/common/media-svc-media-folder.h @@ -25,13 +25,14 @@ #include #include #include "media-svc-types.h" +#include int _media_svc_get_folder_id_by_foldername(sqlite3 *handle, const char *storage_id, const char *folder_name, char *folder_id, uid_t uid); int _media_svc_get_folder_id_by_foldername_with_validity(sqlite3 *handle, const char *storage_id, const char *folder_name, char *folder_id, uid_t uid, int *validity); int _media_svc_update_folder_modified_time_by_folder_uuid(const char *folder_uuid, const char *folder_path, uid_t uid); -int _media_svc_get_and_append_folder(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, uid_t uid); -int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, uid_t uid); -int _media_svc_get_and_append_folder_id_by_folder_path(sqlite3 *handle, const char *storage_id, const char *path, media_svc_storage_type_e storage_type, char *folder_id, bool stack_query, uid_t uid); +int _media_svc_get_and_append_folder(sqlite3 *handle, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, char *folder_id, uid_t uid); +int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, char *folder_id, uid_t uid); +int _media_svc_get_and_append_folder_id_by_folder_path(sqlite3 *handle, const char *storage_id, const char *path, ms_user_storage_type_e storage_type, char *folder_id, bool stack_query, uid_t uid); int _media_svc_delete_invalid_folder(const char *storage_id, int storage_type, uid_t uid); int _media_svc_set_folder_validity(sqlite3 *handle, const char *storage_id, const char *start_path, int validity, bool is_recursive, uid_t uid); GList ** _media_svc_get_folder_list_ptr(void); diff --git a/src/include/common/media-svc-media.h b/src/include/common/media-svc-media.h index f0e0f24..36d2198 100755 --- a/src/include/common/media-svc-media.h +++ b/src/include/common/media-svc-media.h @@ -34,12 +34,12 @@ int _media_svc_update_item_with_data(const char *storage_id, media_svc_content_i 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, bool stack_query, uid_t uid); -int _media_svc_delete_invalid_items(sqlite3 *handle, const char *storage_id, media_svc_storage_type_e storage_type, uid_t uid); -int _media_svc_update_storage_item_validity(const char *storage_id, media_svc_storage_type_e storage_type, int validity, uid_t uid); +int _media_svc_delete_invalid_items(sqlite3 *handle, const char *storage_id, ms_user_storage_type_e storage_type, uid_t uid); +int _media_svc_update_storage_item_validity(const char *storage_id, ms_user_storage_type_e storage_type, int validity, uid_t uid); int _media_svc_update_folder_item_validity(sqlite3 *handle, const char *storage_id, const char *folder_path, int validity, uid_t uid); int _media_svc_update_recursive_folder_item_validity(const char *storage_id, const char *folder_path, int validity, 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, media_svc_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 *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_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, int update_item, media_svc_noti_item **item); diff --git a/src/include/common/media-svc-storage.h b/src/include/common/media-svc-storage.h index cccbba8..b1fe3d4 100755 --- a/src/include/common/media-svc-storage.h +++ b/src/include/common/media-svc-storage.h @@ -25,9 +25,9 @@ #include int _media_svc_check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid); -int _media_svc_append_storage(const char *storage_id, const char *storage_path, media_svc_storage_type_e storage_type, uid_t uid); +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, media_svc_storage_type_e storage_type, uid_t uid); +int _media_svc_delete_invalid_storage(sqlite3 *handle, ms_user_storage_type_e storage_type, uid_t uid); int _media_svc_update_storage_validity(const char *storage_id, int validity, uid_t uid); int _media_svc_get_storage_uuid(sqlite3 *handle, const char *path, char *storage_id, uid_t uid); int _media_svc_get_all_storage(sqlite3 *handle, char ***storage_list, char ***storage_id_list, int *count); diff --git a/src/include/common/media-svc-util.h b/src/include/common/media-svc-util.h index e98a035..7cb9be5 100755 --- a/src/include/common/media-svc-util.h +++ b/src/include/common/media-svc-util.h @@ -46,9 +46,6 @@ extern "C" { #define STRING_VALID(str) \ ((str != NULL && strlen(str) > 0) ? TRUE : FALSE) -#define STORAGE_VALID(storage)\ - (((storage == MEDIA_SVC_STORAGE_INTERNAL) || (storage == MEDIA_SVC_STORAGE_EXTERNAL) || (storage == MEDIA_SVC_STORAGE_EXTERNAL_USB)) ? TRUE : FALSE) - #define SAFE_STRLCAT(dst, src, n) g_strlcat(dst, src, n); #define SAFE_STRLCPY(dst, src, n) g_strlcpy(dst, src, n); @@ -57,7 +54,7 @@ int _media_svc_remove_file(const char *path); int _media_svc_get_thumbnail_path(media_svc_media_type_e media_type, char *thumb_path, const char *pathname, const char *img_format, uid_t uid); int _media_svc_get_file_time(const char *full_path); int _media_svc_set_default_value(media_svc_content_info_s *content_info, bool refresh); -int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, media_svc_storage_type_e storage_type, +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_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s *content_info); int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s *content_info, uid_t uid); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100755 index 9e829ec..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -SET(fw_name "media-service") -SET(fw_test "${fw_name}-test") - -INCLUDE(FindPkgConfig) -pkg_check_modules(${fw_test} REQUIRED glib-2.0 dlog libmedia-utils libtzplatform-config) -FOREACH(flag ${${fw_test}_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE") - -aux_source_directory(. sources) -FOREACH(src ${sources}) - GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) - MESSAGE("${src_name}") - ADD_EXECUTABLE(${src_name} ${src}) - TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS}) -ENDFOREACH() diff --git a/test/media-service-test.c b/test/media-service-test.c deleted file mode 100755 index 4c21532..0000000 --- a/test/media-service-test.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * libmedia-service - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hyunjun Ko , Haejeong Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include -#include -#include - -#define SAFE_FREE(src) { if (src) { free(src); src = NULL; } } - -GMainLoop *g_loop = NULL; -MediaSvcHandle *g_db_handle = NULL; - -void _noti_cb(int pid, - media_item_type_e update_item, - media_item_update_type_e update_type, - char *path, - char *uuid, - media_type_e content_type, - char *mime_type, - void *user_data) -{ - media_svc_debug("Noti from PID(%d)", pid); - - if (update_item == MS_MEDIA_ITEM_FILE) - media_svc_debug("Noti item : MS_MEDIA_ITEM_FILE"); - else if (update_item == MS_MEDIA_ITEM_DIRECTORY) - media_svc_debug("Noti item : MS_MEDIA_ITEM_DIRECTORY"); - - if (update_type == MS_MEDIA_ITEM_INSERT) - media_svc_debug("Noti type : MS_MEDIA_ITEM_INSERT"); - else if (update_type == MS_MEDIA_ITEM_DELETE) - media_svc_debug("Noti type : MS_MEDIA_ITEM_DELETE"); - else if (update_type == MS_MEDIA_ITEM_UPDATE) - media_svc_debug("Noti type : MS_MEDIA_ITEM_UPDATE"); - - /*media_svc_debug("content type : %d", content_type); */ - printf("content type : %d\n", content_type); - - if (path) - printf("path : %s\n", path); - else - printf("path not"); - - if (mime_type) - printf("mime_type : %s", mime_type); - else - printf("mime not"); - - if (user_data) printf("String : %s\n", (char *)user_data); - else - printf("user not"); - - return; -} - -#if 1 -gboolean _send_noti_batch_operations(gpointer data) -{ - int ret = MS_MEDIA_ERR_NONE; - - /* First of all, noti subscription */ - char *user_str = strdup("hi"); - /* 1. media_svc_insert_item_immediately */ - char *path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg"); - - media_svc_storage_type_e storage_type; - - ret = media_svc_get_storage_type(path, &storage_type, tzplatform_getuid(TZ_USER_NAME)); - if (ret != MS_MEDIA_ERR_NONE) { - media_svc_error("media_svc_get_storage_type failed : %d (%s)", ret, path); - SAFE_FREE(user_str); - return FALSE; - } - - int idx = 0; - char *file_list[10]; - - ret = media_svc_insert_item_begin(100, TRUE, getpid()); - /*ret = media_svc_insert_item_begin(g_db_handle, 100); */ - for (idx = 0; idx < 10; idx++) { - char filepath[255] = {0, }; - snprintf(filepath, sizeof(filepath), "%s%d.jpg", tzplatform_mkpath(TZ_USER_CONTENT, "test/image"), idx + 1); - media_svc_debug("File : %s\n", filepath); - file_list[idx] = strdup(filepath); - ret = media_svc_insert_item_bulk(g_db_handle, storage_type, file_list[idx], FALSE); - if (ret != 0) - media_svc_error("media_svc_insert_item_bulk[%d] failed", idx); - else - media_svc_debug("media_svc_insert_item_bulk[%d] success", idx); - } - - ret = media_svc_insert_item_end(tzplatform_getuid(TZ_USER_NAME)); - - SAFE_FREE(user_str); - return FALSE; -} -#endif - -gboolean _send_noti_operations(gpointer data) -{ - int ret = MS_MEDIA_ERR_NONE; - - /* First of all, noti subscription */ - char *user_str = strdup("hi"); - - /* 1. media_svc_insert_item_immediately */ - char *path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg"); - media_svc_storage_type_e storage_type; - - ret = media_svc_get_storage_type(path, &storage_type, tzplatform_getuid(TZ_USER_NAME)); - if (ret != MS_MEDIA_ERR_NONE) { - media_svc_error("media_svc_get_storage_type failed : %d (%s)", ret, path); - SAFE_FREE(user_str); - return FALSE; - } - - ret = media_svc_insert_item_immediately(g_db_handle, storage_type, path); - if (ret != MS_MEDIA_ERR_NONE) { - media_svc_error("media_svc_insert_item_immediately failed : %d", ret); - SAFE_FREE(user_str); - return FALSE; - } - - media_svc_debug("media_svc_insert_item_immediately success"); - - /* 2. media_svc_move_item */ - const char *dst_path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image11.jpg"); - ret = media_svc_move_item(g_db_handle, path, dst_path); - if (ret != MS_MEDIA_ERR_NONE) { - media_svc_error("media_svc_move_item failed : %d", ret); - return FALSE; - } - media_svc_debug("media_svc_move_item success"); - - ret = media_svc_move_item(g_db_handle, storage_type, dst_path, storage_type, path); - if (ret != MS_MEDIA_ERR_NONE) { - media_svc_error("media_svc_move_item failed : %d", ret); - return FALSE; - } - media_svc_debug("media_svc_move_item success"); - - /* 4. media_svc_delete_item_by_path */ - ret = media_svc_delete_item_by_path(g_db_handle, path); - if (ret != MS_MEDIA_ERR_NONE) { - media_svc_error("media_svc_delete_item_by_path failed : %d", ret); - return FALSE; - } - media_svc_debug("media_svc_delete_item_by_path success"); - - return FALSE; -} - -int test_noti() -{ - GSource *source = NULL; - GMainContext *context = NULL; - - g_loop = g_main_loop_new(NULL, FALSE); - context = g_main_loop_get_context(g_loop); - source = g_idle_source_new(); -#if 0 - g_source_set_callback(source, _send_noti_operations, NULL, NULL); -#else - g_source_set_callback(source, _send_noti_batch_operations, NULL, NULL); -#endif - g_source_attach(source, context); - - g_main_loop_run(g_loop); - - g_main_loop_unref(g_loop); - - return MS_MEDIA_ERR_NONE; -} - -int main() -{ - int ret = MS_MEDIA_ERR_NONE; - ret = media_svc_connect(&g_db_handle, tzplatform_getuid(TZ_USER_NAME), true); - if (ret != MS_MEDIA_ERR_NONE) - media_svc_error("media_svc_connect failed : %d", ret); - else - media_svc_debug("media_svc_connect success"); - - ret = test_noti(); - if (ret < MS_MEDIA_ERR_NONE) - media_svc_error("test_noti failed : %d", ret); - else - media_svc_debug("test_noti success"); - - media_svc_disconnect(g_db_handle); - return ret; -} - diff --git a/test/plugin/Makefile b/test/plugin/Makefile deleted file mode 100644 index 94e3a27..0000000 --- a/test/plugin/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -CC =gcc -LIBS = libmedia-service - -OBJS = media_svc_plugin_test.o -SRCS = media_svc_plugin_test.c -TARGET = plugin_test - -TARGET : $(OBJS) - $(CC) -o $(TARGET) $(OBJS) -ldl `pkg-config $(LIBS) --cflags --libs` -g -$(OBJS) : $(SRCS) - $(CC) -c $(SRCS) -I../../include -L../../cmake_build_tmp `pkg-config $(LIBS) --cflags --libs` -g -clean : - rm $(TARGET) - rm $(OBJS) diff --git a/test/plugin/media_svc_plugin_test.c b/test/plugin/media_svc_plugin_test.c deleted file mode 100755 index 27efa25..0000000 --- a/test/plugin/media_svc_plugin_test.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * libmedia-service - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: Hyunjun Ko , Haejeong Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include -#include -#include -#include -#include - -#include - -#define PLUGIN_SO_FILE_NAME "/usr/lib/libmedia-content-plugin.so" -void *funcHandle = NULL; - -static void msg_print(int line, char *msg); - -int (*svc_connect)(void **handle, char **err_msg); -int (*svc_disconnect)(void *handle, char **err_msg); -int (*svc_check_item_exist)(void *handle, const char *file_path, bool *modified, char **err_msg); -int (*svc_insert_item_immediately)(void *handle, const char *file_path, int storage_type, const char *mime_type, char **err_msg); -int (*svc_set_folder_item_validity)(void *handle, const char *folder_path, int validity, int recursive, char **err_msg); -int (*svc_delete_all_invalid_items_in_folder)(void *handle, const char *folder_path, char **err_msg); - -int __load_functions() -{ - msg_print(__LINE__, "__load_functions"); - - funcHandle = dlopen(PLUGIN_SO_FILE_NAME, RTLD_LAZY); - if (!funcHandle) - fprintf(stderr, "error: %s\n", dlerror()); - - svc_connect = dlsym(funcHandle, "connect"); - svc_disconnect = dlsym(funcHandle, "disconnect"); - svc_check_item_exist = dlsym(funcHandle, "check_item_exist"); - svc_insert_item_immediately = dlsym(funcHandle, "insert_item_immediately"); - svc_set_folder_item_validity = dlsym(funcHandle, "set_folder_item_validity"); - svc_delete_all_invalid_items_in_folder = dlsym(funcHandle, "delete_all_invalid_items_in_folder"); - - if (!svc_connect || !svc_disconnect || !svc_insert_item_immediately || !svc_set_folder_item_validity || !svc_delete_all_invalid_items_in_folder || !svc_check_item_exist) { - fprintf(stderr, "error: %s\n", dlerror()); - return -1; - } - - return 0; -} - -int __unload_functions(void) -{ - msg_print(__LINE__, "__unload_functions"); - - if (funcHandle) - dlclose(funcHandle); - - return 0; -} - -int main() -{ - int ret = 0; - MediaSvcHandle *db_handle = NULL; - char *err_msg = NULL; - char path[1024] = {0, }; - char type[1024] = {0, }; - - ret = __load_functions(); - if (ret < 0) { - msg_print(__LINE__, "__load_functions error"); - return -1; - } else { - msg_print(__LINE__, "__load_functions success"); - } - - /*db open ================================================== */ - ret = svc_connect(&db_handle, &err_msg); - if (ret < 0) { - msg_print(__LINE__, "svc_connect error"); - if (err_msg != NULL) { - printf("err_msg[%s]\n", err_msg); - free(err_msg); - err_msg = NULL; - } - __unload_functions(); - return -1; - } else { - msg_print(__LINE__, "svc_connect success"); - } - -#if 1 - ret = media_svc_create_table(tzplatform_getuid(TZ_USER_NAME)); - if (ret < 0) - msg_print(__LINE__, "table already exists"); - else - msg_print(__LINE__, "table create success"); -#endif - -#if 1 - while (1) { - - printf("Enter path and mimetype ( ex. %s image ) : ", tzplatform_mkpath(TZ_USER_CONTENT, "a.jpg")); - scanf("%s %s", path, type); - bool modified = false; - /*check_item_exist ============================================ */ - ret = svc_check_item_exist(db_handle, path, &modified, &err_msg); - if (ret < 0) { - msg_print(__LINE__, "svc_check_item_exist error"); - if (err_msg != NULL) { - printf("err_msg[%s]\n", err_msg); - free(err_msg); - err_msg = NULL; - } - /*__unload_functions(); */ - /*return -1; */ - } else { - if (modified) - msg_print(__LINE__, "svc_check_item_exist success. Modified"); - else - msg_print(__LINE__, "svc_check_item_exist success. Not modified"); - } - - /* svc_check_item_exist ============================================ */ - ret = svc_insert_item_immediately(db_handle, path, 0, type, &err_msg); - if (ret < 0) { - msg_print(__LINE__, "svc_insert_item_immediately error"); - if (err_msg != NULL) { - printf("err_msg[%s]\n", err_msg); - free(err_msg); - err_msg = NULL; - } - /*__unload_functions(); */ - /*return -1; */ - } else { - msg_print(__LINE__, "svc_insert_item_immediately success"); - } - } /* End of While */ - - ret = media_svc_insert_folder(db_handle, 0, path); - if (ret < 0) - msg_print(__LINE__, "media_svc_insert_folder error "); - else - msg_print(__LINE__, "media_svc_insert_folder success"); -#endif - - /*folder test ================================================== */ - char *folder_path = tzplatform_mkpath(TZ_USER_CONTENT, "Sounds"); - ret = svc_set_folder_item_validity(db_handle, folder_path, 0, 1, &err_msg); - if (ret < 0) { - msg_print(__LINE__, "svc_set_folder_item_validity error"); - if (err_msg != NULL) { - printf("err_msg[%s]\n", err_msg); - free(err_msg); - err_msg = NULL; - } - } else { - msg_print(__LINE__, "svc_insert_item_immediately success"); - } - - ret = svc_delete_all_invalid_items_in_folder(db_handle, folder_path, &err_msg); - if (ret < 0) { - msg_print(__LINE__, "svc_delete_all_invalid_items_in_folder error"); - if (err_msg != NULL) { - printf("err_msg[%s]\n", err_msg); - free(err_msg); - err_msg = NULL; - } - } else { - msg_print(__LINE__, "svc_insert_item_immediately success"); - } - - /*db close ================================================== */ - ret = svc_disconnect(db_handle, &err_msg); - if (ret < 0) { - msg_print(__LINE__, "svc_disconnect error"); - if (err_msg != NULL) { - printf("err_msg[%s]\n", err_msg); - free(err_msg); - err_msg = NULL; - } - __unload_functions(); - return -1; - } else { - msg_print(__LINE__, "svc_disconnect success"); - } - - __unload_functions(); - - return 0; -} - - -static void msg_print(int line, char *msg) -{ - fprintf(stderr, "[%d]%s\n", line, msg); -} - -- 2.7.4