From f96a9aa1abf2792adb7cc5657e2546749935429b Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Thu, 9 Aug 2018 09:50:38 +0900 Subject: [PATCH] Update path replacement function Use hardcording instead of storage API (because of storage API changes) Change-Id: I74b20f6bdd6c562e08c07de707c84734436e3128 Signed-off-by: Minje Ahn --- lib/include/media-util.h | 8 +++----- lib/include/private.h | 1 - lib/media-util-noti-internal.c | 30 ++++-------------------------- lib/media-util-noti.c | 29 +++-------------------------- packaging/media-server.spec | 2 +- 5 files changed, 11 insertions(+), 59 deletions(-) diff --git a/lib/include/media-util.h b/lib/include/media-util.h index c838798..cfd91af 100755 --- a/lib/include/media-util.h +++ b/lib/include/media-util.h @@ -35,6 +35,9 @@ #include +/* TEMP :: Will be removed */ +#define MEDIA_ROOT_PATH_INTERNAL_OLD "/opt/usr/media" + #define MEDIA_ROOT_PATH_INTERNAL tzplatform_getenv(TZ_USER_CONTENT) #define MEDIA_ROOT_PATH_EXTERNAL tzplatform_getenv(TZ_SYS_STORAGE) #define MEDIA_ROOT_PATH_SDCARD tzplatform_mkpath(TZ_SYS_STORAGE, "SDCard") @@ -44,11 +47,6 @@ #endif #ifdef _USE_SENIOR_MODE -#define MEDIA_CONTENT_PATH "content" /**< user content folder name*/ -#else -#define MEDIA_CONTENT_PATH "media" /**< user content folder name*/ -#endif -#ifdef _USE_SENIOR_MODE #define MEDIA_ROOT_PATH_SENIOR_MODE "/opt/familytv" #endif diff --git a/lib/include/private.h b/lib/include/private.h index 8411ef1..ae14613 100755 --- a/lib/include/private.h +++ b/lib/include/private.h @@ -65,6 +65,5 @@ static inline tizen_profile_t _get_tizen_profile() } #define _USE_SDCARD (_get_tizen_profile() == TIZEN_PROFILE_MOBILE) -#define _USE_TV_PATH (_get_tizen_profile() == TIZEN_PROFILE_TV) #endif /* _MEDIA_SERVER_PRIVATE_H_ */ diff --git a/lib/media-util-noti-internal.c b/lib/media-util-noti-internal.c index 5e179b1..e488ce3 100755 --- a/lib/media-util-noti-internal.c +++ b/lib/media-util-noti-internal.c @@ -60,11 +60,7 @@ int media_db_update_send_internal(int pid, /* mandatory */ GVariant *message = NULL; GDBusConnection *bus = NULL; GError *error = NULL; - char repl_path[MAX_FILEPATH_LEN] = {0, }; -#if !defined(_USE_SENIOR_MODE) - char *tmp_path = NULL; - const char *old_path = "/opt/usr/media"; -#endif + bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); if (!bus) { MSAPI_DBG("Failed to get gdbus connection: %s", error->message); @@ -72,29 +68,11 @@ int media_db_update_send_internal(int pid, /* mandatory */ return MS_MEDIA_ERR_INTERNAL; } - memset(repl_path, 0, sizeof(repl_path)); -#if !defined(_USE_SENIOR_MODE) - if (!_USE_TV_PATH) { - /* Need uid to change path */ - if (strncmp(path, "/opt/usr/home", strlen("/opt/usr/home")) == 0) { - tmp_path = strstr(path, MEDIA_CONTENT_PATH); - snprintf(repl_path, sizeof(repl_path), "%s%s", old_path, tmp_path + strlen(MEDIA_CONTENT_PATH)); - } else { - snprintf(repl_path, sizeof(repl_path), "%s", path); - } - - MSAPI_DBG("New path: [%s]", repl_path); - } else -#endif - { - snprintf(repl_path, sizeof(repl_path), "%s", path); - } - if (item == MS_MEDIA_ITEM_FILE) { MSAPI_DBG("FILE CHANGED"); if (uuid != NULL && mime_type != NULL) { /* fill all datas */ - message = g_variant_new("(iiissis)", item, pid, update_type, repl_path, uuid, media_type, mime_type); + message = g_variant_new("(iiissis)", item, pid, update_type, path, uuid, media_type, mime_type); } else { MSAPI_DBG_ERR("uuid or mime_type is NULL"); return MS_MEDIA_ERR_INVALID_PARAMETER; @@ -103,9 +81,9 @@ int media_db_update_send_internal(int pid, /* mandatory */ MSAPI_DBG("DIRECTORY CHANGED"); /* fill all datas */ if (uuid != NULL) - message = g_variant_new("(iiiss)", item, pid, update_type, repl_path, uuid); + message = g_variant_new("(iiiss)", item, pid, update_type, path, uuid); else - message = g_variant_new("(iiis)", item, pid, update_type, repl_path); + message = g_variant_new("(iiis)", item, pid, update_type, path); } else { MSAPI_DBG("this request is wrong"); } diff --git a/lib/media-util-noti.c b/lib/media-util-noti.c index 02ee13d..ab15642 100755 --- a/lib/media-util-noti.c +++ b/lib/media-util-noti.c @@ -198,11 +198,6 @@ int media_db_update_send(int pid, /* mandatory */ GVariant *message = NULL; GDBusConnection *bus = NULL; GError *error = NULL; - char repl_path[MAX_FILEPATH_LEN] = {0, }; -#if !defined(_USE_SENIOR_MODE) - char *tmp_path = NULL; - const char *old_path = "/opt/usr/media"; -#endif bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); if (!bus) { @@ -211,29 +206,11 @@ int media_db_update_send(int pid, /* mandatory */ return MS_MEDIA_ERR_INTERNAL; } - memset(repl_path, 0, sizeof(repl_path)); -#if !defined(_USE_SENIOR_MODE) - if (!_USE_TV_PATH) { - /* Need uid to change path */ - if (strncmp(path, "/opt/usr/home", strlen("/opt/usr/home")) == 0) { - tmp_path = strstr(path, MEDIA_CONTENT_PATH); - snprintf(repl_path, sizeof(repl_path), "%s%s", old_path, tmp_path + strlen(MEDIA_CONTENT_PATH)); - } else { - snprintf(repl_path, sizeof(repl_path), "%s", path); - } - - MSAPI_DBG("New path: [%s]", repl_path); - } else -#endif - { - snprintf(repl_path, sizeof(repl_path), "%s", path); - } - if (item == MS_MEDIA_ITEM_FILE) { MSAPI_DBG("FILE CHANGED"); if (uuid != NULL && mime_type != NULL) { /* fill all datas */ - message = g_variant_new("(iiissis)", item, pid, update_type, repl_path, uuid, media_type, mime_type); + message = g_variant_new("(iiissis)", item, pid, update_type, path, uuid, media_type, mime_type); } else { MSAPI_DBG_ERR("uuid or mime_type is NULL"); g_object_unref(bus); @@ -243,9 +220,9 @@ int media_db_update_send(int pid, /* mandatory */ MSAPI_DBG("DIRECTORY CHANGED"); /* fill all datas */ if (uuid != NULL) - message = g_variant_new("(iiiss)", item, pid, update_type, repl_path, uuid); + message = g_variant_new("(iiiss)", item, pid, update_type, path, uuid); else - message = g_variant_new("(iiis)", item, pid, update_type, repl_path); + message = g_variant_new("(iiis)", item, pid, update_type, path); } else { MSAPI_DBG("this request is wrong"); } diff --git a/packaging/media-server.spec b/packaging/media-server.spec index 941be69..3837ed4 100755 --- a/packaging/media-server.spec +++ b/packaging/media-server.spec @@ -1,6 +1,6 @@ Name: media-server Summary: A server for media content management -Version: 0.3.63 +Version: 0.3.64 Release: 0 Group: Multimedia/Service License: Apache-2.0 -- 2.7.4