summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorminje.ahn <minje.ahn@samsung.com>2024-03-06 17:31:46 +0900
committerminje.ahn <minje.ahn@samsung.com>2024-03-07 14:13:22 +0900
commit70ba71b0b3e71696473eda4838b0ffc30d0e479d (patch)
tree66330f2cdc7710b1f4428376847d9a02bf243e87
parentf0baeacb7de890ac56dd98fbd89f4a7153513dbb (diff)
downloadlibmedia-service-70ba71b0b3e71696473eda4838b0ffc30d0e479d.tar.gz
libmedia-service-70ba71b0b3e71696473eda4838b0ffc30d0e479d.tar.bz2
libmedia-service-70ba71b0b3e71696473eda4838b0ffc30d0e479d.zip
Change-Id: I6674f047317e5115a8a90b2b981fcbdc88a70ef5 Signed-off-by: minje.ahn <minje.ahn@samsung.com>
-rw-r--r--CMakeLists.txt6
-rwxr-xr-xinclude/media-svc.h8
-rw-r--r--packaging/libmedia-service.spec9
-rwxr-xr-xplugin/media-content-plugin.c19
-rwxr-xr-xsrc/common/media-svc-album.c1
-rwxr-xr-xsrc/common/media-svc-db-utils.c5
-rwxr-xr-xsrc/common/media-svc-media-folder.c3
-rwxr-xr-xsrc/common/media-svc-media.c1
-rwxr-xr-xsrc/common/media-svc-noti.c4
-rwxr-xr-xsrc/common/media-svc-storage.c3
-rw-r--r--src/common/media-svc-util.c8
-rwxr-xr-xsrc/common/media-svc.c25
-rwxr-xr-xsrc/include/common/media-svc-media-folder.h1
-rwxr-xr-xsrc/include/common/media-svc-noti.h4
-rwxr-xr-xsrc/include/common/media-svc-util.h4
-rw-r--r--unittest/CMakeLists.txt37
-rwxr-xr-xunittest/libmedia_service_unittest.cpp55
-rw-r--r--unittest/libmedia_service_unittest.h26
18 files changed, 45 insertions, 174 deletions
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 <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
}
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 <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)
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 <media-util-err.h>
#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 <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;
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 <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"
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 <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"
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 <media-util-user.h>
#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 <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)
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 <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);
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 <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
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 <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
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 <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-#undef LOG_TAG
-#define LOG_TAG "GTEST_LIBMEDIA_SERVICE"
-
-#endif /*__LIB_MM_UTILITY_UNITTEST_H__*/