add new path for the disc 27/98227/5
authorYong Yeon Kim <yy9875.kim@samsung.com>
Wed, 16 Nov 2016 12:35:17 +0000 (21:35 +0900)
committerYong Yeon Kim <yy9875.kim@samsung.com>
Thu, 17 Nov 2016 01:50:33 +0000 (10:50 +0900)
Change-Id: I1a79a24f99d8c3aa105cb3d0970d65e3ec5fa162

lib/include/media-util.h
lib/media-util-register.c
packaging/media-server.spec
src/common/include/media-common-types.h
src/common/media-common-utils.c
src/scanner-v2/media-scanner-scan-v2.c
src/server/media-server-main.c

index c98d30c..18f57c9 100755 (executable)
@@ -49,6 +49,8 @@
 #define MEDIA_ROOT_PATH_SENIOR_MODE "/opt/familytv"
 #endif
 
+#define MEDIA_ROOT_PATH_DISC "/mnt/cdrom"
+
 #define MEDIA_DB_SIZE_LIMIT_2 20000000.0
 #define MEDIA_DB_SIZE_LIMIT_1 10000000.0
 #define MEDIA_DB_SPACE_LIMIT 20971520.0
index 652bcf3..a61af84 100755 (executable)
@@ -176,6 +176,8 @@ static bool _is_valid_path(const char *path, uid_t uid)
                ret = true;
        } else if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && (strncmp(path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB)) == 0)) {
                ret = true;
+       } else if (MS_STRING_VALID(MEDIA_ROOT_PATH_DISC) && (strncmp(path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0)) {
+               ret = true;
        }
 #ifdef _USE_SENIOR_MODE
        else if (strncmp(path, MEDIA_ROOT_PATH_SENIOR_MODE, strlen(MEDIA_ROOT_PATH_SENIOR_MODE)) == 0) {
index 324d80b..12e683c 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       media-server
 Summary:    A server for media content management
-Version:    0.3.14
+Version:    0.3.15
 Release:    0
 Group:      Multimedia/Service
 License:    Apache-2.0
index ba14c3f..1a17051 100755 (executable)
@@ -42,6 +42,9 @@
 #define MS_SERVER_STATUS "memory/private/mediaserver/server_status"
 #define MS_DB_LIMIT "file/private/mediaserver/db_limit"
 #define MS_DB_RESET "file/private/mediaserver/db_reset"
+#define MS_DISC_STATE "db/disc/mount/state"
+#define MS_DISC_PATH "memory/disc/info/mount_path"
+#define MS_DISC_TYPE "memory/disc/info/logical_type"
 
 /*Use for Poweroff sequence*/
 #define POWEROFF -1 /*This number uses for stopping Scannig thread*/
index f309a1f..cf5dca6 100755 (executable)
@@ -193,6 +193,8 @@ ms_storage_type_t ms_get_storage_type_by_full(const char *path, uid_t uid)
                ret = MS_STORAGE_EXTERNAL;
        } 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;
        } else {
                MS_DBG_ERR("[%s][%s][%s]", MEDIA_ROOT_PATH_SDCARD, MEDIA_ROOT_PATH_USB, path);
                ret = MS_MEDIA_ERR_INVALID_PATH;
@@ -506,6 +508,8 @@ int ms_check_ignore_dir(const char *full_path, uid_t uid)
                        break;
                else if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && (strncmp(dir_path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB)) == 0))
                        break;
+               else if (MS_STRING_VALID(MEDIA_ROOT_PATH_DISC) && (strncmp(dir_path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0))
+                       break;
 
                leaf_path = strrchr(dir_path, '/');
                if (leaf_path != NULL) {
@@ -774,6 +778,8 @@ bool ms_is_valid_path(const char *path, uid_t uid)
                ret = true;
        else if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && (strncmp(path, MEDIA_ROOT_PATH_USB, strlen(MEDIA_ROOT_PATH_USB)) == 0))
                ret = true;
+       else if (MS_STRING_VALID(MEDIA_ROOT_PATH_DISC) && (strncmp(path, MEDIA_ROOT_PATH_DISC, strlen(MEDIA_ROOT_PATH_DISC)) == 0))
+               ret = true;
        else
                ret = false;
 
index 9f464a4..b452890 100755 (executable)
@@ -444,6 +444,17 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
                                        continue;
                                }
 
+                               if (d->d_type == DT_UNKNOWN) {
+                                       struct stat st;
+                                       if (stat(path, &st) == 0) {
+                                               if (S_ISREG(st.st_mode)) {
+                                                       d->d_type = DT_REG;
+                                               } else if (S_ISDIR(st.st_mode)) {
+                                                       d->d_type = DT_DIR;
+                                               }
+                                       }
+                               }
+
                                if (d->d_type == DT_REG) {
                                        ms_get_media_type(handle, path, &media_type);
                                        if (media_type == MS_MEDIA_TYPE_OTHER) {
@@ -457,7 +468,7 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
                                                MS_DBG_ERR("failed to update db : %d\n", scan_type);
                                                if (ret == MS_MEDIA_ERR_FILE_IO) {
                                                        MS_DBG_ERR("I/O ERROR COUNT[%d]", io_err_folder++);
-                                               }                                                       
+                                               }
                                                bpos += d->d_reclen;
                                                continue;
                                        } else {
@@ -733,6 +744,17 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
                                        continue;
                                }
 
+                               if (d->d_type == DT_UNKNOWN) {
+                                       struct stat st;
+                                       if (stat(path, &st) == 0) {
+                                               if (S_ISREG(st.st_mode)) {
+                                                       d->d_type = DT_REG;
+                                               } else if (S_ISDIR(st.st_mode)) {
+                                                       d->d_type = DT_DIR;
+                                               }
+                                       }
+                               }
+
                                if (d->d_type == DT_REG) {
                                        /* check media type */
                                        ms_get_media_type(handle, path, &media_type);
@@ -814,24 +836,28 @@ NEXT_SCAN:
                }
        }
 
-       /*remove invalid folder in folder table.*/
-       if (ms_storage_mount_status(new_start_path)) {
-               if ((g_directory_scan_processing2 != DIR_SCAN_NON_SCAN)
-                       && (__msc_dir_and_storage_scan_same_path(new_start_path) == MS_MEDIA_ERR_NONE)) {
-                       __msc_set_dir_scan_cb(__msc_dir_scan_cb);
-                       MS_DBG_ERR("storage scan pause...\n");
-                       __msc_pause_scan();
+       if (strstr(new_start_path, MEDIA_ROOT_PATH_USB) != NULL) {
+               if (!ms_storage_mount_status(new_start_path)) {
+                       MS_DBG_ERR("start path is unmounted");
+                       goto EXIT;
+               }
+       }
 
-                       MS_DBG_ERR("wait folder scan callback");
+       if ((g_directory_scan_processing2 != DIR_SCAN_NON_SCAN)
+               && (__msc_dir_and_storage_scan_same_path(new_start_path) == MS_MEDIA_ERR_NONE)) {
+               __msc_set_dir_scan_cb(__msc_dir_scan_cb);
+               MS_DBG_ERR("storage scan pause...\n");
+               __msc_pause_scan();
 
-                       __msc_remove_dir_scan_cb();
-               }
-               if (ms_delete_invalid_folder(handle, storage_id, storage_type, uid) != MS_MEDIA_ERR_NONE) {
-                       MS_DBG_ERR("delete invalid folder failed");
-                       ret = MS_MEDIA_ERR_DB_DELETE_FAIL;
-               }
-       } else {
-               MS_DBG_ERR("start path is unmounted");
+               MS_DBG_ERR("wait folder scan callback");
+
+               __msc_remove_dir_scan_cb();
+       }
+
+       /*remove invalid folder in folder table.*/
+       if (ms_delete_invalid_folder(handle, storage_id, storage_type, uid) != MS_MEDIA_ERR_NONE) {
+               MS_DBG_ERR("delete invalid folder failed");
+               ret = MS_MEDIA_ERR_DB_DELETE_FAIL;
        }
 
        goto EXIT;
index 5f3e34e..a46487d 100644 (file)
@@ -153,6 +153,75 @@ void _ms_smarthub_vconf_cb(void *data)
 
        return;
 }
+
+void _ms_datadisc_vconf_cb(void *data)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+       int disc_state = 0;
+       char *disc_type = NULL;
+       char *disc_path = NULL;
+       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,};
+       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 ret;
+       }
+
+       /* request scanning */
+       ms_sys_get_uid(&uid);
+
+       ms_connect_db(&handle, uid);
+
+       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;
+               }
+
+               MS_DBG_ERR("[DISC INSERTED][%s]",disc_type);
+
+               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;
+                       }
+
+                       memset(start_path, 0x0, sizeof(start_path));
+                       strncpy(start_path, disc_path, sizeof(start_path)-1);
+                       MS_DBG_ERR("MOUNT PATH [%s]", start_path);
+
+
+                       ret = ms_insert_storage(handle, MMC_STORAGE_ID, NULL, start_path, uid);
+                       if (ret != MS_MEDIA_ERR_NONE) {
+                               MS_DBG_ERR("ms_insert_storage failed");
+                       }
+
+                       ms_send_storage_scan_request(start_path, MMC_STORAGE_ID, scan_type, uid);
+               }
+       } else {
+               MS_DBG_ERR("[DISC REMOVED]");
+               ms_set_storage_validity(handle, MMC_STORAGE_ID, 0, uid);
+       }
+
+END:
+       MS_SAFE_FREE(disc_type);
+       MS_SAFE_FREE(disc_path);
+
+       ms_disconnect_db(&handle);
+
+       ms_unload_functions();
+
+       return;
+}
 #endif
 int ms_write_media_server_status(void)
 {
@@ -485,6 +554,10 @@ static void __ms_add_event_receiver(GIOChannel *channel)
        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);
+
+       err = vconf_notify_key_changed(MS_DISC_STATE, (vconf_callback_fn) _ms_datadisc_vconf_cb, NULL);
+       if (err == -1)
+               MS_DBG_ERR("add call back function for event %s fails", MS_DISC_STATE);
 #endif
        /*set power off callback function*/
        ms_sys_set_poweroff_cb(_power_off_cb, channel);