From 24ac293591b551f132d5bc113a48a189ce024024 Mon Sep 17 00:00:00 2001 From: "Sabera Djelti (sdi2)" Date: Wed, 12 Feb 2014 14:31:47 +0100 Subject: [PATCH] Remove hardcoded path for multiuser support Bug-Tizen: PTREL-265 Change-Id: Iccdd2b3ff30f8e10928ae1ff1ff12c6e1d4528e9 Signed-off-by: Sabera Djelti (sdi2) --- include/media_info_private.h | 7 ++++--- packaging/capi-content-media-content.spec | 2 +- test/CMakeLists.txt | 2 +- test/media-content_test.c | 30 ++++++++++++++++-------------- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/include/media_info_private.h b/include/media_info_private.h index 9a2e76d..c27f644 100755 --- a/include/media_info_private.h +++ b/include/media_info_private.h @@ -30,7 +30,7 @@ #include #include #include - +#include #ifdef __cplusplus extern "C" { @@ -50,8 +50,8 @@ extern "C" { #define MEDIA_CONTENT_PATH_PHONE MEDIA_ROOT_PATH_INTERNAL /**< File path prefix of files stored in phone */ #define MEDIA_CONTENT_PATH_MMC MEDIA_ROOT_PATH_SDCARD /**< File path prefix of files stored in mmc card */ -#define MEDIA_CONTENT_THUMB_DEFAULT_PATH MEDIA_DATA_PATH"/.thumb/thumb_default.png" -#define MEDIA_CONTENT_INSERT_FILES_PATH MEDIA_DATA_PATH"/" +#define MEDIA_CONTENT_THUMB_DEFAULT_PATH tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/.thumb/thumb_default.png") +#define MEDIA_CONTENT_INSERT_FILES_PATH tzplatform_mkpath(TZ_USER_DATA, "file-manager-service/") #define MAX_QUERY_SIZE 4096 #define MIN_QUERY_SIZE 256 @@ -61,6 +61,7 @@ extern "C" { #define MEDIA_CONTENT_UUID_SIZE 36 #define BATCH_REQUEST_MAX 300 + typedef enum { MEDIA_CONTENT_TYPE = 0, MEDIA_THUMBNAIL_TYPE, diff --git a/packaging/capi-content-media-content.spec b/packaging/capi-content-media-content.spec index af0094b..61e939b 100755 --- a/packaging/capi-content-media-content.spec +++ b/packaging/capi-content-media-content.spec @@ -12,7 +12,7 @@ BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(libmedia-service) BuildRequires: pkgconfig(media-thumbnail) BuildRequires: pkgconfig(libmedia-utils) - +BuildRequires: pkgconfig(libtzplatform-config) %description A Media content library in SLP C API. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7097377..6ee9acf 100755 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,7 +2,7 @@ SET(fw_name "capi-content-media-content") SET(fw_test "${fw_name}-test") INCLUDE(FindPkgConfig) -pkg_check_modules(${fw_test} REQUIRED glib-2.0 dlog libmedia-service capi-base-common libmedia-utils) +pkg_check_modules(${fw_test} REQUIRED glib-2.0 dlog libmedia-service capi-base-common libmedia-utils libtzplatform-config) FOREACH(flag ${${fw_test}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) diff --git a/test/media-content_test.c b/test/media-content_test.c index 425fedf..9214758 100755 --- a/test/media-content_test.c +++ b/test/media-content_test.c @@ -23,6 +23,7 @@ #include #include #include +#include filter_h g_filter = NULL; filter_h g_filter_g = NULL; //filter for group like folder, tag, playlist, album, year ... @@ -1515,7 +1516,7 @@ int test_media_info_operation_2(void) #if 0 /* Bookmark */ - char *thumbnail_path1 = "/opt/media/Images and videos/My video clips/teat11.jpg"; + char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_CONTENT, "Images and videos/My video clips/teat11.jpg")); media_bookmark_insert_to_db(test_video_id, 100, thumbnail_path1); media_bookmark_insert_to_db(test_video_id, 200, thumbnail_path1); @@ -1648,7 +1649,7 @@ int test_playlist_operation(void) media_playlist_add_media(playlist_1, test_video_id); #if 0 - char *playlist_thumb_path = "/opt/usr/media/Images/Default.jpg"; + char *playlist_thumb_path = tzplatform_mkpath(TZ_USER_CONTENT, "Images/Default.jpg")); media_playlist_set_thumbnail_path(playlist_1, playlist_thumb_path); #endif @@ -1931,7 +1932,8 @@ int test_bookmark_operation(void) media_content_error("error media_filter_set_order : [%d]", ret); //insert bookmark to video - char *thumbnail_path1 = "/opt/usr/media/Images and videos/My video clips/teat11.jpg"; + char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_CONTENT, "Images and videos/My video clips/teat11.jpg"); + ret = media_bookmark_insert_to_db(test_video_id, 400, thumbnail_path1); if(ret != MEDIA_CONTENT_ERROR_NONE) media_content_error("error media_bookmark_insert_to_db : [%d]", ret); @@ -2144,7 +2146,7 @@ int test_insert(void) { int ret = MEDIA_CONTENT_ERROR_NONE; //char *path = "/opt/media/Images/Default.jpg"; - char *path = "/opt/usr/media/Others/other.txt"; + char *path = tzplatform_mkpath(TZ_USER_CONTENT, "Others/other.txt"); //char *path = NULL; media_info_h media_item = NULL; media_content_debug("\n============DB Insert Test============\n\n"); @@ -2189,7 +2191,7 @@ int test_move(void) { int ret = MEDIA_CONTENT_ERROR_NONE; const char *move_media_id = "60aea677-4742-408e-b5f7-f2628062d06d"; - char *dst_path = "/opt/usr/media/Images/XX/Default1.jpg"; + char *dst_path = tzplatform_mkpath(TZ_USER_CONTENT, "Images/XX/Default1.jpg"); media_info_h move_media = NULL; ret = media_info_get_media_from_db(move_media_id, &move_media); @@ -2610,7 +2612,7 @@ int test_batch_operations() for (i = 0; i < 10; i++) { char filepath[255] = {0,}; - snprintf(filepath, sizeof(filepath), "%s%d.jpg", "/opt/usr/media/test/image", i+1); + snprintf(filepath, sizeof(filepath), "%s%d.jpg", tzplatform_mkpath(TZ_USER_CONTENT, "test/image"), i+1); media_content_debug("File : %s\n", filepath); file_list[i] = strdup(filepath); } @@ -2621,8 +2623,8 @@ int test_batch_operations() } filter_h filter; - char *condition = "MEDIA_PATH LIKE \'/opt/usr/media/test/image%%jpg\'"; - + char *condition = "MEDIA_PATH LIKE \'"; + strncat (condition, tzplatform_mkpath(TZ_USER_CONTENT, "test/image%%jpg\'"), 17); ret = media_filter_create(&filter); if(ret != MEDIA_CONTENT_ERROR_NONE) { media_content_error("Fail to create filter"); @@ -2662,7 +2664,7 @@ gboolean test_insert_burst_shot_to_db_start(gpointer data) for (i = 0; i < 10; i++) { char filepath[255] = {0,}; - snprintf(filepath, sizeof(filepath), "%s%d.jpg", "/opt/usr/media/test/image", i+1); + snprintf(filepath, sizeof(filepath), "%s%d.jpg", tzplatform_mkpath(TZ_USER_CONTENT, "test/image"), i+1); media_content_debug("File : %s\n", filepath); file_list[i] = strdup(filepath); } @@ -2704,8 +2706,7 @@ int test_scan_file() { int ret = -1; - const char *file_path = "/opt/usr/media/test/image1.jpg"; - + const char *file_path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg"); ret = media_content_scan_file(file_path); if(ret != MEDIA_CONTENT_ERROR_NONE) { media_content_error("Fail to media_content_scan_file : %d", ret); @@ -2719,7 +2720,7 @@ gboolean test_scan_dir_start(gpointer data) { int ret = -1; - const char *dir_path = "/opt/usr/media"; + const char *dir_path = tzplatform_getenv(TZ_USER_CONTENT); ret = media_content_scan_folder(dir_path, TRUE, _scan_cb, NULL); @@ -2813,7 +2814,7 @@ gboolean _send_noti_operations(gpointer data) /* media_info_insert_to_db */ media_info_h media_item = NULL; - char *path = "/opt/usr/media/test/image1.jpg"; + char *path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg"); ret = media_info_insert_to_db(path, &media_item); if (ret < MEDIA_CONTENT_ERROR_NONE) { @@ -2826,7 +2827,8 @@ gboolean _send_noti_operations(gpointer data) /* media_info_delete_batch_from_db */ filter_h filter; - char *condition = "MEDIA_PATH LIKE \'/opt/usr/media/test/image%%jpg\'"; + char *condition = "MEDIA_PATH LIKE \'"; + strncat (condition, tzplatform_mkpath(TZ_USER_CONTENT, "test/image%%jpg\'"), 17); ret = media_filter_create(&filter); if(ret != MEDIA_CONTENT_ERROR_NONE) { -- 2.7.4