Add checker for content.scanning.others feature 26/165426/1 submit/tizen/20180102.060639 submit/tizen/20180103.002528
authorMinje Ahn <minje.ahn@samsung.com>
Fri, 22 Dec 2017 01:59:52 +0000 (10:59 +0900)
committerhj kim <backto.kim@samsung.com>
Fri, 29 Dec 2017 02:40:47 +0000 (11:40 +0900)
Change-Id: I3bcfc13170ad7e84253431d44e7c2b1b92ddc4e8
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/common/include/media-common-db-svc.h
src/common/media-common-db-svc.c
src/common/media-common-utils.c
src/scanner-v2/media-scanner-scan-v2.c
src/scanner/media-scanner-scan.c

index 42345df..b7e667b 100755 (executable)
@@ -22,6 +22,7 @@
 #define _MEDIA_COMMON_DB_SVC_H_
 
 #include <glib.h>
+#include <system_info.h>
 
 #include "media-common-types.h"
 
@@ -148,6 +149,7 @@ int ms_update_meta_batch(void **handle, const char *path, const char *storage_id
 int ms_check_folder_exist(void **handle, const char *storage_id, const char *folder_path);
 int ms_get_folder_id(void **handle, const char *storage_id, const char *path, char **folder_id);
 int ms_get_media_type(void **handle, const char *path, int *media_type);
+bool ms_check_support_media_type(void **handle, const char *path);
 
 /* FOR BULK COMMIT */
 void ms_register_start(void **handle, ms_noti_switch_e noti_status, int pid);
index 903318f..a6f4842 100755 (executable)
@@ -40,6 +40,7 @@ static int lib_num;
 static void **func_handle = NULL; /*dlopen handel*/
 int insert_count_for_partial = 0;
 int set_count_for_partial = 0;
+static int scan_other_type = -1;
 
 enum func_list {
        eCONNECT,
@@ -1417,6 +1418,36 @@ int ms_get_media_type(void **handle, const char *path, int *media_type)
        return res;
 }
 
+bool ms_check_support_media_type(void **handle, const char *path)
+{
+       int ret = SYSTEM_INFO_ERROR_NONE;
+       int media_type = -1;
+       bool is_supported = false;
+
+       MS_DBG_RETVM_IF(!MS_STRING_VALID(path), false, "path is empty");
+
+       if (scan_other_type == -1) {
+               ret = system_info_get_platform_bool("http://tizen.org/feature/content.scanning.others", &is_supported);
+               if (ret != SYSTEM_INFO_ERROR_NONE) {
+                       MS_DBG_ERR("SYSTEM_INFO_ERROR: content.scanning.others [%d]", ret);
+                       return false;
+               }
+
+               scan_other_type = is_supported;
+       }
+
+       /* If not, check media type */
+       if (!scan_other_type) {
+               ret = ms_get_media_type(handle, path, &media_type);
+               MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, false, "Failed to get media type");
+
+               if (media_type == MS_MEDIA_TYPE_OTHER)
+                       return false;
+       }
+
+       return true;
+}
+
 void ms_bacth_commit_enable(void* handle, bool ins_status, bool valid_status, bool noti_enable, int pid)
 {
        /*call for bundle commit*/
index 12189dc..2227ad3 100755 (executable)
@@ -531,4 +531,4 @@ int ms_set_vip_process(void)
        close(id);
        return MS_MEDIA_ERR_NONE;
 }
-#endif
+#endif
\ No newline at end of file
index f2c81a0..7058645 100755 (executable)
@@ -260,7 +260,6 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
        char path[MS_FILE_PATH_LEN_MAX] = {0, };
        bool is_recursive = true;
        char *new_start_path = NULL;
-       int media_type = MS_MEDIA_TYPE_OTHER;
 
        int fd = -1;
        int nread = 0;
@@ -468,8 +467,7 @@ static int __msc_dir_scan_for_folder(void **handle, const char *storage_id, cons
                                }
 
                                if (d->d_type == DT_REG) {
-                                       ms_get_media_type(handle, path, &media_type);
-                                       if (media_type == MS_MEDIA_TYPE_OTHER) {
+                                       if (!ms_check_support_media_type(handle, path)) {
                                                bpos += d->d_reclen;
                                                continue;
                                        }
@@ -591,7 +589,6 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
        char path[MS_FILE_PATH_LEN_MAX] = { 0 };
        int (*scan_function)(void **, const char*, const char*, uid_t) = NULL;
        char *new_start_path = NULL;
-       int media_type = MS_MEDIA_TYPE_OTHER;
 
        int fd = -1;
        int nread = 0;
@@ -769,11 +766,11 @@ static int __msc_dir_scan_for_storage(void **handle, const char *storage_id, con
 
                                if (d->d_type == DT_REG) {
                                        /* check media type */
-                                       ms_get_media_type(handle, path, &media_type);
-                                       if (media_type == MS_MEDIA_TYPE_OTHER) {
+                                       if (!ms_check_support_media_type(handle, path)) {
                                                bpos += d->d_reclen;
                                                continue;
                                        }
+
                                        /* insert into media DB */
                                        ret = scan_function(handle, storage_id, path, uid);
                                        if (ret != MS_MEDIA_ERR_NONE) {
index 14cf7b8..6a730bd 100755 (executable)
@@ -107,6 +107,12 @@ static int __msc_dir_scan(void **handle, const char *storage_id, const char*star
                                }
 
                                if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
+                                       /* Check content.scanning.others feature */
+                                       if (!ms_check_support_media_type(handle, path)) {
+                                               MS_DBG("Unsupported media type");
+                                               continue;
+                                       }
+
                                        if (scan_function(handle, storage_id, path, uid) != MS_MEDIA_ERR_NONE) {
                                                MS_DBG_ERR("failed to update db");
                                                continue;