Add storage update event when usb mount/unmount 43/268443/2 accepted/tizen/unified/20211228.140419 submit/tizen/20211227.040650
authorchengyj1985 <yujie.cheng@samsung.com>
Thu, 23 Dec 2021 02:15:48 +0000 (10:15 +0800)
committerchengyj1985 <yujie.cheng@samsung.com>
Fri, 24 Dec 2021 02:09:06 +0000 (10:09 +0800)
Change-Id: Ib6a88e41804840b4e5cf3d13f6e897c9465c5ec4

lib/include/media-util-noti.h
lib/media-util-noti.c
src/server/media-server-device-block.c

index 6bc630f..28bdd93 100755 (executable)
@@ -37,6 +37,7 @@ extern "C" {
 typedef enum {
        MS_MEDIA_ITEM_FILE                      = 0,
        MS_MEDIA_ITEM_DIRECTORY = 1,
+       MS_MEDIA_ITEM_STORAGE   = 2,
 } media_item_type_e;
 
 typedef enum {
index afcf734..486a8c8 100755 (executable)
@@ -83,6 +83,10 @@ int media_db_update_send(int pid, /* mandatory */
                        message = g_variant_new("(iiiss)", item, pid, update_type, path, uuid);
                else
                        message = g_variant_new("(iiis)", item, pid, update_type, path);
+#ifdef _USE_TVPD_MODE
+       } else if (item == MS_MEDIA_ITEM_STORAGE) {
+               message = g_variant_new("(iiissis)", item, pid, update_type, path, uuid, media_type, mime_type);
+#endif
        } else {
                MSAPI_DBG("this request is wrong");
        }
index b7cc7ac..49f907c 100644 (file)
 #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"
+#define PROD_CUSTOM_MIME_REMOVED "0"
+#endif
 
 int ms_storage_insert_handler(const char *mount_path, const char *mount_uuid)
 {
@@ -175,9 +180,16 @@ static void __ms_usb_add_event(const char *mount_path)
                                ms_set_storage_validity(handle, storage_id, 1, uid);
                                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");
@@ -239,6 +251,9 @@ 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);