improve callback of data disc 09/101109/1
authorYong Yeon Kim <yy9875.kim@samsung.com>
Wed, 30 Nov 2016 09:02:41 +0000 (18:02 +0900)
committerYong Yeon Kim <yy9875.kim@samsung.com>
Wed, 30 Nov 2016 09:03:14 +0000 (18:03 +0900)
Change-Id: I9a7d0e0c8f4840b479c74157ad050cc2087f6162

src/common/include/media-common-db-svc.h
src/common/media-common-utils.c
src/server/media-server-main.c

index c969ed3..059b989 100755 (executable)
@@ -28,6 +28,7 @@
 #define INTERNAL_STORAGE_ID    "media"
 #define MMC_STORAGE_ID         "media"
 #define USB_STORAGE_REMOVED "usb_removed"
+#define DATADISC_STORAGE_ID    "data_disc"
 
 typedef struct ms_dir_info_s {
        char *dir_path;
index 5c4eb15..e7ef1d5 100755 (executable)
@@ -194,7 +194,7 @@ ms_storage_type_t ms_get_storage_type_by_full(const char *path, uid_t uid)
        } else if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && (strncmp(path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB)) == 0)) {
                ret = MS_STORAGE_EXTERNAL_USB;
        } else if (MS_STRING_VALID(MEDIA_ROOT_PATH_DISC) && (strncmp(path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0)) {
-               ret = MS_STORAGE_EXTERNAL;
+               ret = MS_STORAGE_EXTERNAL_USB;
        } else {
                MS_DBG_ERR("[%s][%s][%s]", MEDIA_ROOT_PATH_SDCARD, MEDIA_ROOT_PATH_USB, path);
                ret = MS_MEDIA_ERR_INVALID_PATH;
index 136704b..9628055 100644 (file)
@@ -163,63 +163,68 @@ void _ms_datadisc_vconf_cb(void *data)
        char *valid_type = "data";
        ms_dir_scan_type_t scan_type = MS_SCAN_PART;
        uid_t uid = MEDIA_DEFAULT_UID;
-       char start_path[11] = {0,};
+       char storage_path[11] = {0,};
        void **handle = NULL;
 
-       ms_config_get_int(MS_DISC_STATE, &disc_state);
-
-       ret = ms_load_functions();
-       if (ret != MS_MEDIA_ERR_NONE) {
-               MS_DBG_ERR("ms_load_functions failed [%d]", ret);
-               return;
+       /*check disc type */
+       if (!ms_config_get_str(MS_DISC_TYPE, &disc_type)) {
+               MS_DBG_ERR("Get MS_DISC_TYPE failed.");
+               goto END;
        }
 
-       /* request scanning */
-       ms_sys_get_uid(&uid);
+       MS_DBG("[disc type] %s", disc_type);
 
-       ms_connect_db(&handle, uid);
+       if (strcmp(disc_type, valid_type) == 0) {
+               ms_config_get_int(MS_DISC_STATE, &disc_state);
 
-       if (disc_state == 1) {
-               /*check disc type */
-               if (!ms_config_get_str(MS_DISC_TYPE, &disc_type)) {
-                       MS_DBG_ERR("Get MS_DISC_TYPE failed.");
-                       goto END;
+               ret = ms_load_functions();
+               if (ret != MS_MEDIA_ERR_NONE) {
+                       MS_DBG_ERR("ms_load_functions failed [%d]", ret);
+                       return;
                }
 
-               MS_DBG_WARN("[DISC INSERTED][%s]",disc_type);
+               /* request scanning */
+               ms_sys_get_uid(&uid);
 
-               if (strcmp(disc_type, valid_type) == 0) {
-                       /* check mount path */
-                       if (!ms_config_get_str(MS_DISC_PATH, &disc_path)) {
-                               MS_DBG_ERR("Get MS_DISC_PATH failed.");
-                               goto END;
-                       }
+               ms_connect_db(&handle, uid);
+
+               /* check mount path */
+               if (!ms_config_get_str(MS_DISC_PATH, &disc_path)) {
+                       MS_DBG_ERR("Get MS_DISC_PATH failed.");
+                       goto END;
+               }
 
-                       memset(start_path, 0x0, sizeof(start_path));
-                       strncpy(start_path, disc_path, sizeof(start_path)-1);
-                       MS_DBG_WARN("MOUNT PATH [%s]", start_path);
+               MS_DBG("[disc path] %s", disc_path);
+               memset(storage_path, 0x0, sizeof(storage_path));
+               strncpy(storage_path, disc_path, sizeof(storage_path)-1);
 
+               if (disc_state == 1) {
+                       MS_DBG_WARN("[DISC INSERTED][%s]",disc_type);
+               
+                       MS_DBG_WARN("MOUNT PATH [%s]", storage_path);
 
-                       ret = ms_insert_storage(handle, MMC_STORAGE_ID, NULL, start_path, uid);
+                       ret = ms_insert_storage(handle, DATADISC_STORAGE_ID, NULL, storage_path, uid);
                        if (ret != MS_MEDIA_ERR_NONE) {
                                MS_DBG_ERR("ms_insert_storage failed");
+                       } else {
+                               ms_send_storage_scan_request(storage_path, DATADISC_STORAGE_ID, scan_type, uid);
                        }
-
-                       ms_send_storage_scan_request(start_path, MMC_STORAGE_ID, scan_type, uid);
+               } else {
+                       MS_DBG_WARN("[DISC REMOVED]");
+                       ms_set_storage_validity(handle, DATADISC_STORAGE_ID, 0, uid);
+                       ms_set_folder_validity(handle, DATADISC_STORAGE_ID, storage_path, false, true, uid);
+                       ms_validaty_change_all_items(handle, DATADISC_STORAGE_ID, MS_STORAGE_EXTERNAL_USB, false, uid);
                }
-       } else {
-               MS_DBG_WARN("[DISC REMOVED]");
-               ms_set_storage_validity(handle, MMC_STORAGE_ID, 0, uid);
+
+               ms_disconnect_db(&handle);
+
+               ms_unload_functions();
        }
 
 END:
        MS_SAFE_FREE(disc_type);
        MS_SAFE_FREE(disc_path);
 
-       ms_disconnect_db(&handle);
-
-       ms_unload_functions();
-
        return;
 }
 #endif