Cleanup header 41/307241/4 accepted/tizen/unified/20240308.174235 accepted/tizen/unified/x/20240311.100113
authorminje.ahn <minje.ahn@samsung.com>
Wed, 6 Mar 2024 08:31:46 +0000 (17:31 +0900)
committerminje.ahn <minje.ahn@samsung.com>
Thu, 7 Mar 2024 05:13:22 +0000 (14:13 +0900)
Change-Id: I6674f047317e5115a8a90b2b981fcbdc88a70ef5
Signed-off-by: minje.ahn <minje.ahn@samsung.com>
18 files changed:
CMakeLists.txt
include/media-svc.h
packaging/libmedia-service.spec
plugin/media-content-plugin.c
src/common/media-svc-album.c
src/common/media-svc-db-utils.c
src/common/media-svc-media-folder.c
src/common/media-svc-media.c
src/common/media-svc-noti.c
src/common/media-svc-storage.c
src/common/media-svc-util.c
src/common/media-svc.c
src/include/common/media-svc-media-folder.h
src/include/common/media-svc-noti.h
src/include/common/media-svc-util.h
unittest/CMakeLists.txt [deleted file]
unittest/libmedia_service_unittest.cpp [deleted file]
unittest/libmedia_service_unittest.h [deleted file]

index 1e0f981..80d6670 100644 (file)
@@ -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})
index e91f2ed..8bf1289 100755 (executable)
 #ifndef _MEDIA_SVC_H_
 #define _MEDIA_SVC_H_
 
-#include <media-util.h>
 #include <stdbool.h>
+#include <sys/types.h>
 #include <sqlite3.h>
+#include <glib.h>
 
 #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
 }
index 1c1bb48..fc8ff1d 100644 (file)
@@ -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
 
index 580ae0b..2c32c18 100755 (executable)
  *
  */
 
-#include <string.h>
-#include <mm_file.h>
-#include <media-util.h>
+#include <stddef.h>
 #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)
index c92ee34..2949270 100755 (executable)
@@ -17,7 +17,6 @@
  *
  */
 
-#include <media-util-err.h>
 #include "media-svc-album.h"
 #include "media-svc-debug.h"
 #include "media-svc-env.h"
index 68b73b1..bea6cae 100755 (executable)
  */
 
 #include <unistd.h>
-#include <media-util.h>
+#include <media-util-db.h>
 #include <errno.h>
+
 #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;
index 8f0903b..64e9441 100755 (executable)
@@ -18,7 +18,8 @@
  */
 
 #include <glib/gstdio.h>
-#include <media-util-err.h>
+#include <media-util-user.h>
+
 #include "media-svc-media-folder.h"
 #include "media-svc-debug.h"
 #include "media-svc-env.h"
index 9a68030..57afd2b 100755 (executable)
@@ -20,7 +20,6 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/types.h>
-#include <media-util-err.h>
 #include "media-svc-media.h"
 #include "media-svc-media-folder.h"
 #include "media-svc-debug.h"
index 69f0916..2f0d314 100755 (executable)
@@ -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);
index a076418..1871921 100755 (executable)
@@ -17,7 +17,8 @@
  *
  */
 
-#include "media-util-err.h"
+
+#include <media-util-user.h>
 #include "media-svc-debug.h"
 #include "media-svc-env.h"
 #include "media-svc-db-utils.h"
index 2e7930a..bed0fc3 100644 (file)
@@ -27,9 +27,9 @@
 #include <aul/aul.h>
 #include <mm_file.h>
 #include <libexif/exif-data.h>
-#include <media-util.h>
 #include <uuid/uuid.h>
 #include <media-thumbnail.h>
+#include <media-util-user.h>
 #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)
index 01a6e3a..432f2b2 100755 (executable)
@@ -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
index aee822f..ff7f388 100755 (executable)
@@ -22,7 +22,6 @@
 
 #include <sqlite3.h>
 #include <stdbool.h>
-#include <media-util.h>
 
 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);
index d3768ee..2da0533 100755 (executable)
@@ -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_*/
index 83a6c90..1c99112 100755 (executable)
 
 #include <string.h>
 #include <stdbool.h>
+#include <sys/types.h>
 #include <sqlite3.h>
 #include <time.h>
-#include <media-util.h>
+#include <glib.h>
+#include <media-util-err.h>
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt
deleted file mode 100644 (file)
index 8e217cb..0000000
+++ /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 (executable)
index 982b575..0000000
+++ /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 <media-util.h>
-
-
-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 (file)
index 3d29651..0000000
+++ /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 <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-#undef LOG_TAG
-#define LOG_TAG                "GTEST_LIBMEDIA_SERVICE"
-
-#endif /*__LIB_MM_UTILITY_UNITTEST_H__*/