Use _USE_TVPD_MODE instead of _USE_DEVICED_DBUS 91/303191/2
authorminje.ahn <minje.ahn@samsung.com>
Thu, 21 Dec 2023 05:13:19 +0000 (14:13 +0900)
committerminje.ahn <minje.ahn@samsung.com>
Tue, 26 Dec 2023 04:07:00 +0000 (13:07 +0900)
Both flags are TV features.

Change-Id: I3f2fd32199bf1f049fd55407d37de27ffecabbf7
Signed-off-by: minje.ahn <minje.ahn@samsung.com>
packaging/media-server.spec
src/common/include/media-common-external-storage.h
src/common/include/media-common-system.h
src/common/media-common-external-storage.c
src/common/media-common-system.c
src/common/media-common-utils.c
src/server/include/media-server-device-block.h
src/server/media-server-device-block.c
src/server/media-server-main.c

index 1d63ae5..9600326 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       media-server
 Summary:    A server for media content management
-Version:    0.4.26
+Version:    0.4.27
 Release:    0
 Group:      Multimedia/Service
 License:    Apache-2.0
@@ -71,7 +71,7 @@ cp %{SOURCE1001} %{SOURCE1002} %{SOURCE1003} .
 %if 0%{?product_tv}
 export CFLAGS="$CFLAGS -D_USE_TVPD_MODE"
 %else
-export CFLAGS="$CFLAGS -D_USE_MULTI_USER -D_USE_META_UPDATE -D_USE_DEVICED_DBUS"
+export CFLAGS="$CFLAGS -D_USE_MULTI_USER -D_USE_META_UPDATE"
 %endif
 export CFLAGS="$CFLAGS -D_GNU_SOURCE -D_FORTIFY_SOURCE=2 -DTIZEN_DEBUG_ENABLE -DSYSCONFDIR=\\\"%{_sysconfdir}\\\""
 export CFLAGS+=" -DPATH_LIBDIR=\\\"%{_libdir}\\\""
index c56b120..6f8f4f5 100755 (executable)
@@ -21,9 +21,9 @@
 #ifndef _MEDIA_SERVER_EXTERNAL_STORAGE_H_
 #define _MEDIA_SERVER_EXTERNAL_STORAGE_H_
 
+#ifdef _USE_TVPD_MODE
 #include "media-common-types.h"
 
-#ifndef _USE_DEVICED_DBUS
 int ms_read_device_info(const char *root_path, char **device_uuid);
 int ms_write_device_info(const char *root_path, char *device_uuid);
 int ms_get_added_storage_path(const char *add_path, char **device_id);
index c5dcc6f..c4ebe05 100755 (executable)
@@ -22,7 +22,8 @@
 #define _MEDIA_COMMON_SYSTEM_H_
 
 #include <glib.h>
-#ifndef _USE_DEVICED_DBUS
+
+#ifdef _USE_TVPD_MODE
 #include <usb-device.h>
 #include <dd-power.h>
 #include <power-defs.h>
@@ -42,20 +43,20 @@ typedef struct ms_block_info_s {
        char *mount_uuid;
 } ms_block_info_s;
 
-#ifdef _USE_DEVICED_DBUS
+#ifdef _USE_TVPD_MODE
+int ms_sys_set_device_block_event_cb(usb_connected_cb usr_callback, void *usr_data);
+#else
 typedef void (*block_changed_cb)(ms_block_info_s *block_info, void *user_data);
 int ms_sys_set_device_block_event_cb(block_changed_cb usr_callback, void *usr_data);
-#else
-int ms_sys_set_device_block_event_cb(usb_connected_cb usr_callback, void *usr_data);
 #endif
 void ms_sys_unset_device_block_event_cb(void);
 int ms_sys_get_device_list(GSList **dev_list);
 
-#ifdef _USE_DEVICED_DBUS
+#ifdef _USE_TVPD_MODE
+int ms_sys_set_poweroff_cb(device_changed_cb user_callback, void *user_data);
+#else
 typedef void (*power_off_cb)(void *user_data);
 int ms_sys_set_poweroff_cb(power_off_cb user_callback, void *user_data);
-#else
-int ms_sys_set_poweroff_cb(device_changed_cb user_callback, void *user_data);
 #endif
 
 void ms_sys_unset_poweroff_cb(void);
index 475d79d..3375546 100755 (executable)
@@ -19,6 +19,7 @@
  *
  */
 
+#ifdef _USE_TVPD_MODE
 #include "media-util.h"
 #include "media-common-dbg.h"
 #include "media-common-db-svc.h"
@@ -26,7 +27,6 @@
 
 #define DEVICE_INFO_FILE ".device_info_"
 
-#ifndef _USE_DEVICED_DBUS
 int ms_read_device_info(const char *root_path, char **device_uuid)
 {
        int ret = MS_MEDIA_ERR_NONE;
index 76a88a6..2351b05 100644 (file)
 #include "media-common-db-svc.h"
 #include "media-common-system.h"
 
+#ifdef _USE_TVPD_MODE
+static int __ms_sys_subscribe_device_block_event(usb_connected_cb usr_callback, void *usr_data)
+{
+       MS_DBG_FENTER();
+
+       usb_device_init();
+       usb_set_connected_cb(usr_callback, usr_data);
+
+       MS_DBG_FLEAVE();
+
+       return MS_MEDIA_ERR_NONE;
+}
+
+int ms_sys_set_device_block_event_cb(usb_connected_cb usr_callback, void *usr_data)
+{
+       MS_DBG_FENTER();
+
+       return __ms_sys_subscribe_device_block_event(usr_callback, usr_data);
+}
+
+void ms_sys_unset_device_block_event_cb(void)
+{
+       usb_device_fini();
+}
+
+int ms_sys_get_device_list(GSList **dev_list)
+{
+       int i = 0;
+       int count = 0;
+       int err = 0;
+       usb_device_list_h list;
+       usb_device_h device;
+       char *mount_path = NULL;
 
-//////////////////////////////////////////////////////////////////////////////
-/// CHECK THE EXTERNAL STORATE STATE
-//////////////////////////////////////////////////////////////////////////////
-#ifdef _USE_DEVICED_DBUS
+       err = usb_device_get_device_list(USB_MASS_STORAGE, &list);
+       MS_DBG_RETVM_IF(err != 0, MS_MEDIA_ERR_INTERNAL, "usb_device_get_device_list failed [%d]", err);
+
+       count = usb_device_list_get_count(list);
+       if (count > 0) {
+               for (i = 0; i < count; i++) {
+                       if (i == 0) {
+                               err = usb_device_list_get_first(list, &device);
+                               if (err != USB_ERROR_LIST_FAILED_TO_GET && device != NULL) {
+                                       mount_path = usb_device_get_mountpath(device);
+                                       if (mount_path != NULL)
+                                               MS_DBG_SWARN("mount_path [%s]", mount_path);
+                               }
+                       } else {
+                               usb_device_list_get_next(list, &device);
+                               if (device != NULL) {
+                                       mount_path = usb_device_get_mountpath(device);
+                                       if (mount_path != NULL)
+                                               MS_DBG_SWARN("mount_path [%s]", mount_path);
+                               }
+                       }
+
+                       char *storage_id = NULL;
+                       ms_block_info_s *data = NULL;
+
+                       err = ms_get_added_storage_path(mount_path, &storage_id);
+                       if ((err == MS_MEDIA_ERR_NONE) && (storage_id != NULL)) {
+                               data = g_new0(ms_block_info_s, 1);
+                               data->mount_path = g_strdup(mount_path);
+                               data->mount_uuid = storage_id;
+                               *dev_list = g_slist_append(*dev_list, data);
+                       } else {
+                               MS_DBG_ERR("ms_get_added_stroage_path failed [%d]", err);
+                       }
+               }
+       }
+
+       usb_device_free_device_list(list);
+
+       return MS_MEDIA_ERR_NONE;
+}
+
+device_changed_cb g_user_callback;
+
+int ms_sys_set_poweroff_cb(device_changed_cb user_callback, void *user_data)
+{
+       MS_DBG_FENTER();
+       device_power_subscribe_standby(user_callback, user_data);
+       g_user_callback = user_callback;
+       MS_DBG_FLEAVE();
+
+       return MS_MEDIA_ERR_NONE;
+}
+
+void ms_sys_unset_poweroff_cb(void)
+{
+       device_power_unsubscribe_standby(g_user_callback);
+       g_user_callback = NULL;
+}
+#else  /*_USE_TVPD_MODE*/
 #define DEVICED_BUS_NAME               "org.tizen.system.storage"
 #define DEVICED_PATH                   "/Org/Tizen/System/Storage/Block/Manager"
 #define DEVICED_INTERFACE              DEVICED_BUS_NAME".BlockManager"
@@ -78,9 +167,7 @@ static void __ms_block_changed(GDBusConnection *connection,
 
        (g_storage_cb_data.usr_cb)(&block_info, g_storage_cb_data.usr_data);
 }
-#endif
 
-#ifdef _USE_DEVICED_DBUS
 static int __ms_sys_subscribe_device_block_event(block_changed_cb usr_callback, void *usr_data)
 {
        GError *error = NULL;
@@ -116,37 +203,14 @@ static int __ms_sys_subscribe_device_block_event(block_changed_cb usr_callback,
 
        return MS_MEDIA_ERR_NONE;
 }
-#else
-static int __ms_sys_subscribe_device_block_event(usb_connected_cb usr_callback, void *usr_data)
-{
-       MS_DBG_FENTER();
-
-       usb_device_init();
-       usb_set_connected_cb(usr_callback, usr_data);
 
-       MS_DBG_FLEAVE();
-
-       return MS_MEDIA_ERR_NONE;
-}
-#endif
-
-#ifdef _USE_DEVICED_DBUS
 int ms_sys_set_device_block_event_cb(block_changed_cb usr_callback, void *usr_data)
 {
        MS_DBG_FENTER();
 
        return __ms_sys_subscribe_device_block_event(usr_callback, usr_data);
 }
-#else
-int ms_sys_set_device_block_event_cb(usb_connected_cb usr_callback, void *usr_data)
-{
-       MS_DBG_FENTER();
-
-       return __ms_sys_subscribe_device_block_event(usr_callback, usr_data);
-}
-#endif
 
-#ifdef _USE_DEVICED_DBUS
 void ms_sys_unset_device_block_event_cb(void)
 {
        if (!g_storage_bus)
@@ -156,14 +220,7 @@ void ms_sys_unset_device_block_event_cb(void)
        g_object_unref(g_storage_bus);
        g_storage_bus = NULL;
 }
-#else
-void ms_sys_unset_device_block_event_cb(void)
-{
-       usb_device_fini();
-}
-#endif
 
-#ifdef _USE_DEVICED_DBUS
 int ms_sys_get_device_list(GSList **dev_list)
 {
        GDBusConnection *g_bus = NULL;
@@ -236,82 +293,7 @@ int ms_sys_get_device_list(GSList **dev_list)
 
        return MS_MEDIA_ERR_NONE;
 }
-#else
-int ms_sys_get_device_list(GSList **dev_list)
-{
-       int i = 0;
-       int count = 0;
-       int err = 0;
-       usb_device_list_h list;
-       usb_device_h device;
-       char *mount_path = NULL;
-
-       err = usb_device_get_device_list(USB_MASS_STORAGE, &list);
-       MS_DBG_RETVM_IF(err != 0, MS_MEDIA_ERR_INTERNAL, "usb_device_get_device_list failed [%d]", err);
-
-       count = usb_device_list_get_count(list);
-       if (count > 0) {
-               for (i = 0; i < count; i++) {
-                       if (i == 0) {
-                               err = usb_device_list_get_first(list, &device);
-                               if (err != USB_ERROR_LIST_FAILED_TO_GET && device != NULL) {
-                                       mount_path = usb_device_get_mountpath(device);
-                                       if (mount_path != NULL)
-                                               MS_DBG_SWARN("mount_path [%s]", mount_path);
-                               }
-                       } else {
-                               usb_device_list_get_next(list, &device);
-                               if (device != NULL) {
-                                       mount_path = usb_device_get_mountpath(device);
-                                       if (mount_path != NULL)
-                                               MS_DBG_SWARN("mount_path [%s]", mount_path);
-                               }
-                       }
 
-                       char *storage_id = NULL;
-                       ms_block_info_s *data = NULL;
-
-                       err = ms_get_added_storage_path(mount_path, &storage_id);
-                       if ((err == MS_MEDIA_ERR_NONE) && (storage_id != NULL)) {
-                               data = g_new0(ms_block_info_s, 1);
-                               data->mount_path = g_strdup(mount_path);
-                               data->mount_uuid = storage_id;
-                               *dev_list = g_slist_append(*dev_list, data);
-                       } else {
-                               MS_DBG_ERR("ms_get_added_stroage_path failed [%d]", err);
-                       }
-               }
-       }
-
-       usb_device_free_device_list(list);
-
-       return MS_MEDIA_ERR_NONE;
-}
-#endif
-
-//////////////////////////////////////////////////////////////////////////////
-/// GET ACTIVATE USER ID
-//////////////////////////////////////////////////////////////////////////////
-int ms_sys_get_uid(uid_t *uid)
-{
-       uid_t *list = NULL;
-       int users = -1;
-       users = sd_get_uids(&list);
-       if (users > 0) {
-               *uid = list[0];
-               MS_SAFE_FREE(list);
-       } else {
-               MS_DBG_ERR("No login user!.");
-               MS_SAFE_FREE(list);
-               return MS_MEDIA_ERR_INTERNAL;
-       }
-       return MS_MEDIA_ERR_NONE;
-}
-
-//////////////////////////////////////////////////////////////////////////////
-/// CHECK THE POWER STATE
-//////////////////////////////////////////////////////////////////////////////
-#ifdef _USE_DEVICED_DBUS
 #define POWER_DBUS_NAME "ChangeState"
 #define POWER_DBUS_PATH "/Org/Tizen/System/DeviceD/PowerOff"
 #define POWER_DBUS_INTERFACE "org.tizen.system.deviced.PowerOff"
@@ -400,23 +382,9 @@ int ms_sys_set_poweroff_cb(power_off_cb user_callback, void *user_data)
 
        return MS_MEDIA_ERR_NONE;
 }
-#else
-device_changed_cb g_user_callback;
-
-int ms_sys_set_poweroff_cb(device_changed_cb user_callback, void *user_data)
-{
-       MS_DBG_FENTER();
-       device_power_subscribe_standby(user_callback, user_data);
-       g_user_callback = user_callback;
-       MS_DBG_FLEAVE();
-
-       return MS_MEDIA_ERR_NONE;
-}
-#endif
 
 void ms_sys_unset_poweroff_cb(void)
 {
-#ifdef _USE_DEVICED_DBUS
        if (!g_power_bus)
                return;
 
@@ -425,9 +393,21 @@ void ms_sys_unset_poweroff_cb(void)
        g_power_bus = NULL;
 
        g_free(g_power_cb_data);
-#else
-       device_power_unsubscribe_standby(g_user_callback);
-       g_user_callback = NULL;
-#endif
 }
+#endif /*_USE_TVPD_MODE*/
 
+int ms_sys_get_uid(uid_t *uid)
+{
+       uid_t *list = NULL;
+       int users = -1;
+       users = sd_get_uids(&list);
+       if (users > 0) {
+               *uid = list[0];
+               MS_SAFE_FREE(list);
+       } else {
+               MS_DBG_ERR("No login user!.");
+               MS_SAFE_FREE(list);
+               return MS_MEDIA_ERR_INTERNAL;
+       }
+       return MS_MEDIA_ERR_NONE;
+}
index a90ead4..d9124d3 100644 (file)
 
 #ifdef _USE_TVPD_MODE
 #include <sys/prctl.h>
+#include <usb-device.h>
 #endif
 #include <system_info.h>
 #include <device/power.h>
 
-#ifndef _USE_DEVICED_DBUS
-#include <usb-device.h>
-#endif
-
 #include "media-util.h"
 #include "media-server-ipc.h"
 #include "media-common-dbg.h"
@@ -276,8 +273,7 @@ int ms_check_scan_ignore(char * path, uid_t uid)
        return ret;
 }
 
-#ifndef _USE_DEVICED_DBUS
-
+#ifdef _USE_TVPD_MODE
 typedef struct storage_result {
        char *storage_path;
        bool result;
@@ -300,7 +296,7 @@ static void __ms_check_mount_status(usb_device_h usb_device, void *user_data)
 bool ms_storage_mount_status(const char *start_path)
 {
        bool ret = false;
-#ifndef _USE_DEVICED_DBUS
+#ifdef _USE_TVPD_MODE
        storage_result_s res = {0, };
        char *remain_path = NULL;
        int remain_len = 0;
index 1dc47fb..8778995 100755 (executable)
 
 int ms_storage_insert_handler(const char *mount_path, const char *mount_uuid);
 void ms_storage_remove_handler(const char *mount_path, const char *mount_uuid);
-#ifdef _USE_DEVICED_DBUS
-void ms_device_block_changed_cb(ms_block_info_s *block_info, void *user_data);
-#else
+#ifdef _USE_TVPD_MODE
 void ms_device_block_changed_cb(usb_device_h usb_device, char *action, void *user_data);
 int ms_check_mounted_storage(uid_t uid);
+#else
+void ms_device_block_changed_cb(ms_block_info_s *block_info, void *user_data);
 #endif
 
 #endif
index 9f122ca..1067661 100644 (file)
@@ -29,6 +29,7 @@
 #include "media-server-scanner.h"
 #include "media-server-db-manage.h"
 #include "media-server-device-block.h"
+
 #ifdef _USE_TVPD_MODE
 #include <media-util-noti.h>
 #define PROD_CUSTOM_MIME_ADDED   "1"
@@ -132,25 +133,9 @@ void ms_storage_remove_handler(const char *mount_path, const char *mount_uuid)
 
                ms_disconnect_db(handle);
        }
-
 }
 
-#ifdef _USE_DEVICED_DBUS
-void ms_device_block_changed_cb(ms_block_info_s *block_info, void *user_data)
-{
-       MS_DBG_WARN("GET EXTERNAL EVENT");
-       if (block_info->mount_path != NULL && block_info->mount_uuid != NULL) {
-               MS_DBG("uuid[%s] path[%s]", block_info->mount_uuid, block_info->mount_path);
-
-               if (block_info->state == MS_STG_INSERTED)
-                       ms_storage_insert_handler(block_info->mount_path, block_info->mount_uuid);
-               else if (block_info->state == MS_STG_REMOVED)
-                       ms_storage_remove_handler(block_info->mount_path, block_info->mount_uuid);
-       } else {
-               MS_DBG_ERR("mount_path or mount_uuid is NULL");
-       }
-}
-#else
+#ifdef _USE_TVPD_MODE
 static void __ms_usb_add_event(const char *mount_path)
 {
        int ret = MS_MEDIA_ERR_NONE;
@@ -186,15 +171,12 @@ static void __ms_usb_add_event(const char *mount_path)
                                if (ms_set_storage_scan_status(handle, storage_id, MEDIA_SCAN_PREPARE, uid) != MS_MEDIA_ERR_NONE)
                                        MS_DBG_ERR("ms_set_storage_scan_status failed");
 
-#ifdef _USE_TVPD_MODE
                                media_db_update_send(getpid(), MS_MEDIA_ITEM_STORAGE, MS_MEDIA_ITEM_UPDATE, mount_path, storage_id, MS_MEDIA_UNKNOWN, PROD_CUSTOM_MIME_ADDED);
-#endif
                        } else {
                                /* there is no information of this storage in Media DB */
                                ret = ms_insert_storage(handle, storage_id, mount_path, uid);
-#ifdef _USE_TVPD_MODE
+
                                media_db_update_send(getpid(), MS_MEDIA_ITEM_STORAGE, MS_MEDIA_ITEM_INSERT, mount_path, storage_id, MS_MEDIA_UNKNOWN, PROD_CUSTOM_MIME_ADDED);
-#endif
                        }
                } else {
                        MS_DBG_ERR("STORAGE ID IS NUILL");
@@ -256,9 +238,8 @@ static void __ms_usb_remove_event(const char *mount_path)
                        /*So try to remove it.*/
                        ms_send_storage_otg_scan_request(mount_path, device_id, MS_SCAN_INVALID, uid);
                }
-#ifdef _USE_TVPD_MODE
+
                media_db_update_send(getpid(), MS_MEDIA_ITEM_STORAGE, MS_MEDIA_ITEM_UPDATE, mount_path, device_id, MS_MEDIA_UNKNOWN, PROD_CUSTOM_MIME_REMOVED);
-#endif
        }
 
        ms_disconnect_db(handle);
@@ -424,4 +405,19 @@ int ms_check_mounted_storage(uid_t uid)
 
        return ret;
 }
-#endif
+#else /*_USE_TVPD_MODE*/
+void ms_device_block_changed_cb(ms_block_info_s *block_info, void *user_data)
+{
+       MS_DBG_WARN("GET EXTERNAL EVENT");
+       if (block_info->mount_path != NULL && block_info->mount_uuid != NULL) {
+               MS_DBG("uuid[%s] path[%s]", block_info->mount_uuid, block_info->mount_path);
+
+               if (block_info->state == MS_STG_INSERTED)
+                       ms_storage_insert_handler(block_info->mount_path, block_info->mount_uuid);
+               else if (block_info->state == MS_STG_REMOVED)
+                       ms_storage_remove_handler(block_info->mount_path, block_info->mount_uuid);
+       } else {
+               MS_DBG_ERR("mount_path or mount_uuid is NULL");
+       }
+}
+#endif /*_USE_TVPD_MODE*/
index b824b39..a0459c9 100644 (file)
@@ -158,7 +158,7 @@ int ms_write_media_server_status(void)
 }
 
 
-#ifdef _USE_DEVICED_DBUS
+#ifndef _USE_TVPD_MODE
 static void __power_off_cb(void *data)
 {
        MS_DBG_ERR("POWER OFF");
@@ -422,9 +422,8 @@ static void __ms_add_event_receiver(void)
        err = vconf_notify_key_changed(SMARTHUB_RESET_VCONF, (vconf_callback_fn) __ms_smarthub_vconf_cb, NULL);
        if (err == -1)
                MS_DBG_ERR("add call back function for event %s fails", SMARTHUB_RESET_VCONF);
-#endif
+#else
        /*set power off callback function*/
-#ifdef _USE_DEVICED_DBUS
        ms_sys_set_poweroff_cb(__power_off_cb, NULL);
 #endif
        ms_sys_set_device_block_event_cb(ms_device_block_changed_cb, NULL);