block: Add mmc inserted & removed popup 45/172645/1 accepted/tizen/unified/20180320.065835 submit/tizen/20180319.102056 submit/tizen/20180320.020048
authorpr.jung <pr.jung@samsung.com>
Thu, 15 Mar 2018 04:30:16 +0000 (13:30 +0900)
committerpr.jung <pr.jung@samsung.com>
Thu, 15 Mar 2018 04:30:16 +0000 (13:30 +0900)
- Launch notice popup when mmc is mounted and unexpectedly removed

Change-Id: I0978c2bb8eee80129490065bac1749cf03883674
Signed-off-by: pr.jung <pr.jung@samsung.com>
src/block/block.c
src/shared/dbus_macro.h

index 9eec602..4779adb 100644 (file)
 #define PKGDIR_PATH            "/org/tizen/pkgdir_tool"
 #define PKGDIR_INTERFACE       "org.tizen.pkgdir_tool"
 
+#define MMC_POPUP_NOTI         "SDcardNoti"
+#define MMC_INSERTED           "inserted"
+#define MMC_REMOVED            "removed"
+
 #define ARRAY_SIZE(name)       (sizeof(name)/sizeof(name[0]))
 
 #define FILE_NAME_LEN_MAX      255
@@ -983,10 +987,33 @@ static bool pipe_cb(int fd, void *data)
                pdata.bdev->data->primary) {
                create_external_apps_directory();
                mmc_make_default_path(pdata.bdev->data->mount_point);
+
+               _D("prprprpr inserted");
+               ret = dbus_method_sync_var(POPUP_BUS_NAME,
+                       POPUP_PATH_NOTI,
+                       POPUP_INTERFACE_NOTI,
+                       MMC_POPUP_NOTI,
+                       g_variant_new("(s)", MMC_INSERTED));
+               if (ret != 0)
+                       _E("Popup failed: %d", ret);
        }
        if (pdata.op == BLOCK_DEV_UNMOUNT) {
                /* Remove file for block device /run/xxxxxx/id */
                remove_file(pdata.bdev->data->id, pdata.bdev->data->block_type == BLOCK_EXTENDEDSD_DEV);
+
+               if (pdata.bdev->data->block_type == BLOCK_MMC_DEV &&
+                       pdata.bdev->data->primary &&
+                       BLOCK_IS_FLAG_SET(pdata.bdev->data, UNMOUNT_UNSAFE) ) {
+                       _D("prprprpr unexpectedly removed");
+
+                       ret = dbus_method_sync_var(POPUP_BUS_NAME,
+                               POPUP_PATH_NOTI,
+                               POPUP_INTERFACE_NOTI,
+                               MMC_POPUP_NOTI,
+                               g_variant_new("(s)", MMC_REMOVED));
+                       if (ret != 0)
+                               _E("Popup failed: %d", ret);
+               }
        }
 
        /* Broadcast to mmc and usb storage module */
index af7ea0c..d6fa082 100644 (file)
@@ -98,6 +98,9 @@
 #define POPUP_PATH_SYSTEM                   POPUP_OBJECT_PATH"/System"
 #define POPUP_INTERFACE_SYSTEM              POPUP_INTERFACE_NAME".System"
 
+#define POPUP_PATH_NOTI                     POPUP_OBJECT_PATH"/Noti"
+#define POPUP_INTERFACE_NOTI                POPUP_INTERFACE_NAME".Noti"
+
 /* ODE */
 #define POPUP_METHOD_LAUNCH                 "PopupLaunch"
 #define POPUP_KEY_CONTENT                   "_SYSPOPUP_CONTENT_"