From 70ba71b0b3e71696473eda4838b0ffc30d0e479d Mon Sep 17 00:00:00 2001 From: "minje.ahn" Date: Wed, 6 Mar 2024 17:31:46 +0900 Subject: [PATCH] Cleanup header Change-Id: I6674f047317e5115a8a90b2b981fcbdc88a70ef5 Signed-off-by: minje.ahn --- CMakeLists.txt | 6 +--- include/media-svc.h | 8 +++-- packaging/libmedia-service.spec | 9 +---- plugin/media-content-plugin.c | 19 ++-------- src/common/media-svc-album.c | 1 - src/common/media-svc-db-utils.c | 5 ++- src/common/media-svc-media-folder.c | 3 +- src/common/media-svc-media.c | 1 - src/common/media-svc-noti.c | 4 +-- src/common/media-svc-storage.c | 3 +- src/common/media-svc-util.c | 8 ++--- src/common/media-svc.c | 25 ++++++++++--- src/include/common/media-svc-media-folder.h | 1 - src/include/common/media-svc-noti.h | 4 +-- src/include/common/media-svc-util.h | 4 ++- unittest/CMakeLists.txt | 37 ------------------- unittest/libmedia_service_unittest.cpp | 55 ----------------------------- unittest/libmedia_service_unittest.h | 26 -------------- 18 files changed, 45 insertions(+), 174 deletions(-) delete mode 100644 unittest/CMakeLists.txt delete mode 100755 unittest/libmedia_service_unittest.cpp delete mode 100644 unittest/libmedia_service_unittest.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e0f981..80d6670 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6...2.8.12) PROJECT(media-service C CXX) SET(VERSION_MAJOR 1) SET(VERSION "${VERSION_MAJOR}.0.0") @@ -77,10 +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) -IF(BUILD_GTESTS) - ADD_SUBDIRECTORY(unittest) -ENDIF(BUILD_GTESTS) - LINK_DIRECTORIES(${LIB_INSTALL_DIR}) ADD_LIBRARY(${MEDIASERVICE-LIB} SHARED ${SRCS}) diff --git a/include/media-svc.h b/include/media-svc.h index e91f2ed..8bf1289 100755 --- a/include/media-svc.h +++ b/include/media-svc.h @@ -22,9 +22,10 @@ #ifndef _MEDIA_SVC_H_ #define _MEDIA_SVC_H_ -#include #include +#include #include +#include #ifdef __cplusplus extern "C" { @@ -51,8 +52,8 @@ int media_svc_move_item(sqlite3 *handle, 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, 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); -int media_svc_publish_noti(media_item_update_type_e update_type, const char *path, media_type_e media_type, const char *uuid, const char *mime_type); +int media_svc_send_dir_update_noti(const char *dir_path, const char *folder_id, int update_type, int pid); +int media_svc_publish_update_noti(const char *path, int media_type, const char *uuid, const char *mime_type); 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, uid_t uid); @@ -70,6 +71,7 @@ int media_svc_get_media_type(const char *path, int *mediatype); int media_svc_create_thumbnail(const char *file_path, int media_type, uid_t uid, char **thumbnail_path); int media_svc_get_book_by_keyword(sqlite3 *handle, const char *keyword, uid_t uid, GList **result); +int media_svc_check_db(sqlite3 *handle, uid_t uid); #ifdef __cplusplus } diff --git a/packaging/libmedia-service.spec b/packaging/libmedia-service.spec index 1c1bb48..fc8ff1d 100644 --- a/packaging/libmedia-service.spec +++ b/packaging/libmedia-service.spec @@ -25,10 +25,6 @@ BuildRequires: pkgconfig(media-thumbnail) BuildRequires: pkgconfig(libpodofo) BuildRequires: pkgconfig(iniparser) -%if 0%{?gtests:1} -BuildRequires: pkgconfig(gmock) -%endif - %description This package is a library that provides the media information service for the multimedia applications. @@ -46,7 +42,7 @@ cp %{SOURCE1001} . %build export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE -DSYSCONFDIR=\\\"%{_sysconfdir}\\\" -DPATH_LIBDIR=\\\"%{_libdir}\\\"" -%cmake . -DBUILD_GTESTS=%{?gtests:1}%{!?gtests:0} +%cmake . make %{?jobs:-j%jobs} %install @@ -63,9 +59,6 @@ rm -rf %{buildroot} %{_libdir}/libmedia-content-plugin.so %{_libdir}/libmedia-content-plugin.so.* %{_libdir}/libmedia-ebook-plugin.so -%if 0%{?gtests:1} -%{_bindir}/gtest* -%endif #License %license LICENSE.APLv2.0 diff --git a/plugin/media-content-plugin.c b/plugin/media-content-plugin.c index 580ae0b..2c32c18 100755 --- a/plugin/media-content-plugin.c +++ b/plugin/media-content-plugin.c @@ -17,11 +17,8 @@ * */ -#include -#include -#include +#include #include "media-svc.h" -#include "media-svc-util.h" int insert_item_begin(bool with_noti, int from_pid) { @@ -45,22 +42,12 @@ int set_item_validity(const char *storage_id, const char *file_path, int validit int send_dir_update_noti(const char *dir_path, const char *folder_id, int update_type, int pid) { - return media_svc_send_dir_update_noti(dir_path, folder_id, (media_item_update_type_e)update_type, pid); + return media_svc_send_dir_update_noti(dir_path, folder_id, update_type, pid); } int check_db(sqlite3 *handle, uid_t uid) { - int ret = MS_MEDIA_ERR_NONE; - bool exist = false; - - ret = media_svc_check_table_exist(handle, &exist); - if (ret != MS_MEDIA_ERR_NONE) - return ret; - - if (!exist) - ret = media_svc_create_table(uid); - - return ret; + return media_svc_check_db(handle, uid); } int check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid) diff --git a/src/common/media-svc-album.c b/src/common/media-svc-album.c index c92ee34..2949270 100755 --- a/src/common/media-svc-album.c +++ b/src/common/media-svc-album.c @@ -17,7 +17,6 @@ * */ -#include #include "media-svc-album.h" #include "media-svc-debug.h" #include "media-svc-env.h" diff --git a/src/common/media-svc-db-utils.c b/src/common/media-svc-db-utils.c index 68b73b1..bea6cae 100755 --- a/src/common/media-svc-db-utils.c +++ b/src/common/media-svc-db-utils.c @@ -18,14 +18,13 @@ */ #include -#include +#include #include + #include "media-svc-env.h" #include "media-svc-debug.h" #include "media-svc-util.h" #include "media-svc-db-utils.h" -#include "media-util-err.h" -#include "media-util-db.h" #include "media-svc-media.h" static GHashTable *table; diff --git a/src/common/media-svc-media-folder.c b/src/common/media-svc-media-folder.c index 8f0903b..64e9441 100755 --- a/src/common/media-svc-media-folder.c +++ b/src/common/media-svc-media-folder.c @@ -18,7 +18,8 @@ */ #include -#include +#include + #include "media-svc-media-folder.h" #include "media-svc-debug.h" #include "media-svc-env.h" diff --git a/src/common/media-svc-media.c b/src/common/media-svc-media.c index 9a68030..57afd2b 100755 --- a/src/common/media-svc-media.c +++ b/src/common/media-svc-media.c @@ -20,7 +20,6 @@ #include #include #include -#include #include "media-svc-media.h" #include "media-svc-media-folder.h" #include "media-svc-debug.h" diff --git a/src/common/media-svc-noti.c b/src/common/media-svc-noti.c index 69f0916..2f0d314 100755 --- a/src/common/media-svc-noti.c +++ b/src/common/media-svc-noti.c @@ -52,7 +52,7 @@ static void __media_svc_destroy_noti_item(gpointer data) g_free(item); } -int _media_svc_publish_noti(media_item_update_type_e update_type, const char *path, media_type_e media_type, const char *uuid, const char *mime_type) +int _media_svc_publish_noti(media_item_update_type_e update_type, const char *path, int media_type, const char *uuid, const char *mime_type) { int ret = MS_MEDIA_ERR_NONE; media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path"); @@ -70,7 +70,7 @@ int _media_svc_publish_dir_noti(media_item_update_type_e update_type, const char int ret = MS_MEDIA_ERR_NONE; media_svc_retvm_if(!STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path"); - ret = media_db_update_send(pid, MS_MEDIA_ITEM_DIRECTORY, update_type, path, uuid, MS_MEDIA_UNKNOWN, NULL); + ret = media_db_update_send(pid, MS_MEDIA_ITEM_DIRECTORY, update_type, path, uuid, 0, NULL); media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Send dir noti failed[%d][%s]", ret, path); media_svc_sec_debug("Send dir noti [%s]", path); diff --git a/src/common/media-svc-storage.c b/src/common/media-svc-storage.c index a076418..1871921 100755 --- a/src/common/media-svc-storage.c +++ b/src/common/media-svc-storage.c @@ -17,7 +17,8 @@ * */ -#include "media-util-err.h" + +#include #include "media-svc-debug.h" #include "media-svc-env.h" #include "media-svc-db-utils.h" diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c index 2e7930a..bed0fc3 100644 --- a/src/common/media-svc-util.c +++ b/src/common/media-svc-util.c @@ -27,9 +27,9 @@ #include #include #include -#include #include #include +#include #include "media-svc-util.h" #include "media-svc-db-utils.h" #include "media-svc-debug.h" @@ -1074,11 +1074,7 @@ int _media_svc_create_thumbnail(const char *path, char *thumb_path, media_svc_me //1. make thumb path ret = __media_svc_get_thumbnail_path(thumb_path, path, NULL, uid); - if (ret != MS_MEDIA_ERR_NONE) { - media_svc_error("Failed to create thumbnail path[%d]", ret); - g_strlcpy(thumb_path, "", MAX_FILEPATH_LEN); - return ret; - } + media_svc_retvm_if(ret != MS_MEDIA_ERR_NONE, ret, "Failed to create thumbnail path[%d]", ret); //2. save thumbnail if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) diff --git a/src/common/media-svc.c b/src/common/media-svc.c index 01a6e3a..432f2b2 100755 --- a/src/common/media-svc.c +++ b/src/common/media-svc.c @@ -554,16 +554,16 @@ REFRESH_FINALIZE: return ret; } -int media_svc_send_dir_update_noti(const char *dir_path, const char *folder_id, media_item_update_type_e update_type, int pid) +int media_svc_send_dir_update_noti(const char *dir_path, const char *folder_id, int update_type, int pid) { media_svc_retvm_if(!STRING_VALID(dir_path), MS_MEDIA_ERR_INVALID_PARAMETER, "dir_path is NULL"); - return _media_svc_publish_dir_noti(update_type, dir_path, folder_id, pid); + return _media_svc_publish_dir_noti((media_item_update_type_e)update_type, dir_path, folder_id, pid); } -int media_svc_publish_noti(media_item_update_type_e update_type, const char *path, media_type_e media_type, const char *uuid, const char *mime_type) +int media_svc_publish_update_noti(const char *path, int media_type, const char *uuid, const char *mime_type) { - return _media_svc_publish_noti(update_type, path, media_type, uuid, mime_type); + return _media_svc_publish_noti(MS_MEDIA_ITEM_UPDATE, path, media_type, uuid, mime_type); } int media_svc_set_storage_validity(const char *storage_id, int validity, uid_t uid) @@ -645,7 +645,7 @@ int media_svc_create_thumbnail(const char *file_path, int media_type, uid_t uid, char *sql = NULL; // 1. Check media type - if (media_type != MS_MEDIA_IMAGE && media_type != MS_MEDIA_VIDEO) + if (media_type != MEDIA_SVC_MEDIA_TYPE_IMAGE && media_type != MEDIA_SVC_MEDIA_TYPE_VIDEO) return MS_MEDIA_ERR_THUMB_UNSUPPORTED; // 2. try to create thumbnail @@ -728,3 +728,18 @@ int media_svc_get_book_by_keyword(sqlite3 *handle, const char *keyword, uid_t ui return ret; } + +int media_svc_check_db(sqlite3 *handle, uid_t uid) +{ + int ret = MS_MEDIA_ERR_NONE; + bool exist = false; + + ret = media_svc_check_table_exist(handle, &exist); + if (ret != MS_MEDIA_ERR_NONE) + return ret; + + if (!exist) + ret = media_svc_create_table(uid); + + return ret; +} \ No newline at end of file diff --git a/src/include/common/media-svc-media-folder.h b/src/include/common/media-svc-media-folder.h index aee822f..ff7f388 100755 --- a/src/include/common/media-svc-media-folder.h +++ b/src/include/common/media-svc-media-folder.h @@ -22,7 +22,6 @@ #include #include -#include int _media_svc_update_folder_modified_time(const char *folder_path, uid_t uid); int _media_svc_get_and_append_folder_id_by_path(sqlite3 *handle, bool is_direct, const char *storage_id, const char *path, long long int *folder_id, uid_t uid); diff --git a/src/include/common/media-svc-noti.h b/src/include/common/media-svc-noti.h index d3768ee..2da0533 100755 --- a/src/include/common/media-svc-noti.h +++ b/src/include/common/media-svc-noti.h @@ -29,7 +29,7 @@ struct _media_svc_noti_item { int pid; media_item_type_e update_item; media_item_update_type_e update_type; - media_type_e media_type; + int media_type; char *media_uuid; char *path; char *mime_type; @@ -40,7 +40,7 @@ void _media_svc_initialize_noti_list(void); void _media_svc_insert_item_to_noti_list(media_svc_content_info_s *content_info); void _media_svc_publish_noti_list(void); void _media_svc_destroy_noti_item(media_svc_noti_item *item); -int _media_svc_publish_noti(media_item_update_type_e update_type, const char *path, media_type_e media_type, const char *uuid, const char *mime_type); +int _media_svc_publish_noti(media_item_update_type_e update_type, const char *path, int media_type, const char *uuid, const char *mime_type); int _media_svc_publish_dir_noti(media_item_update_type_e update_type, const char *path, const char *uuid, int pid); #endif /*_MEDIA_SVC_NOTI_H_*/ diff --git a/src/include/common/media-svc-util.h b/src/include/common/media-svc-util.h index 83a6c90..1c99112 100755 --- a/src/include/common/media-svc-util.h +++ b/src/include/common/media-svc-util.h @@ -24,9 +24,11 @@ #include #include +#include #include #include -#include +#include +#include #ifdef __cplusplus extern "C" { diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt deleted file mode 100644 index 8e217cb..0000000 --- a/unittest/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(gtest-libmedia-service C CXX) - -SET(GTEST_TEST "gtest-libmedia-service") -ADD_DEFINITIONS("-DUSE_DLOG") - -SET(REQUIRES_LIST ${REQUIRES_LIST} - glib-2.0 - gio-2.0 - gmock - dlog - libmedia-utils -) - -SET(PKG_LIBRARIES ${PKG_LIBRARIES} - "media-service" -) - -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(GTEST_TEST_PKG REQUIRED ${REQUIRES_LIST}) - -FOREACH(flag ${GTEST_TEST_PKG_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}") -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") - -FILE(GLOB GTEST_TEST_SRCS *.cpp) -SET(GTEST_TEST_SRCS ${GTEST_TEST_SRCS}) - -ADD_EXECUTABLE(${GTEST_TEST} ${GTEST_TEST_SRCS}) -TARGET_LINK_LIBRARIES(${GTEST_TEST} ${PKG_LIBRARIES} ${GTEST_TEST_LDFLAGS} ${GTEST_TEST_PKG_LDFLAGS} -ldl) - -INSTALL(TARGETS ${GTEST_TEST} RUNTIME DESTINATION bin) diff --git a/unittest/libmedia_service_unittest.cpp b/unittest/libmedia_service_unittest.cpp deleted file mode 100755 index 982b575..0000000 --- a/unittest/libmedia_service_unittest.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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 "libmedia_service_unittest.h" -#include "media-svc.h" -#include - - -using ::testing::InitGoogleTest; -using ::testing::Test; -using ::testing::TestCase; - -class libmedia_service_Test : public ::testing::Test { - protected: - void SetUp() { - std::cout << "SetUp()" << std::endl; - } - - void TearDown() { - std::cout << "TearDown()" << std::endl; - } -}; - -TEST(libmedia_service_Test, media_svc_connect_disconnect_p) -{ - MediaSvcHandle *handle = NULL; - int ret = MS_MEDIA_ERR_NONE; - - ret = media_svc_connect(&handle, getuid(), false); - EXPECT_EQ(ret, MS_MEDIA_ERR_NONE); - - ret = media_svc_disconnect(handle); - EXPECT_EQ(ret, MS_MEDIA_ERR_NONE); -} - -int main(int argc, char **argv) -{ - InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); -} diff --git a/unittest/libmedia_service_unittest.h b/unittest/libmedia_service_unittest.h deleted file mode 100644 index 3d29651..0000000 --- a/unittest/libmedia_service_unittest.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved - * - * 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. - */ - -#ifndef __LIB_MEDIA_SERVICE_UNITTEST_H__ -#define __LIB_MEDIA_SERVICE_UNITTEST_H__ - -#include -#include - -#undef LOG_TAG -#define LOG_TAG "GTEST_LIBMEDIA_SERVICE" - -#endif /*__LIB_MM_UTILITY_UNITTEST_H__*/ -- 2.7.4