Bind the plugin for scanner-v2 47/303347/1
authorminje.ahn <minje.ahn@samsung.com>
Tue, 26 Dec 2023 05:19:23 +0000 (14:19 +0900)
committerminje.ahn <minje.ahn@samsung.com>
Tue, 26 Dec 2023 05:19:23 +0000 (14:19 +0900)
Change-Id: Ic16db80f14a4e16c3b1b80d3e795d5f0816bbe37
Signed-off-by: minje.ahn <minje.ahn@samsung.com>
Makefile.am
packaging/media-server.spec
src/common/include/media-common-system.h
src/common/include/media-common-utils.h
src/common/media-common-db-svc.c
src/common/media-common-utils.c
src/server/include/media-server-db-manage.h
src/server/media-server-db-manage.c
src/server/media-server-main.c
src/server/media-server-socket.c

index 5f616dc..f5a13af 100755 (executable)
@@ -143,7 +143,6 @@ media_server_LDADD += $(SECURITY_LIBS) \
 if !USE_PRODUCT_TV
 media_scanner_SOURCES = src/common/media-common-utils.c \
                        src/common/media-common-system.c \
-                       src/common/media-common-external-storage.c \
                        src/common/media-common-db-svc.c \
                        src/scanner/media-scanner-scan.c \
                        src/scanner/media-scanner-socket.c \
index adddfc8..501ad82 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       media-server
 Summary:    A server for media content management
-Version:    0.4.28
+Version:    0.4.29
 Release:    0
 Group:      Multimedia/Service
 License:    Apache-2.0
index c4ebe05..07608cc 100755 (executable)
@@ -45,21 +45,16 @@ typedef struct ms_block_info_s {
 
 #ifdef _USE_TVPD_MODE
 int ms_sys_set_device_block_event_cb(usb_connected_cb usr_callback, void *usr_data);
+int ms_sys_set_poweroff_cb(device_changed_cb user_callback, void *user_data);
 #else
 typedef void (*block_changed_cb)(ms_block_info_s *block_info, void *user_data);
 int ms_sys_set_device_block_event_cb(block_changed_cb usr_callback, void *usr_data);
-#endif
-void ms_sys_unset_device_block_event_cb(void);
-int ms_sys_get_device_list(GSList **dev_list);
-
-#ifdef _USE_TVPD_MODE
-int ms_sys_set_poweroff_cb(device_changed_cb user_callback, void *user_data);
-#else
 typedef void (*power_off_cb)(void *user_data);
 int ms_sys_set_poweroff_cb(power_off_cb user_callback, void *user_data);
 #endif
+void ms_sys_unset_device_block_event_cb(void);
+int ms_sys_get_device_list(GSList **dev_list);
 
 void ms_sys_unset_poweroff_cb(void);
-
 int ms_sys_get_uid(uid_t *uid);
 #endif
index 5e26385..a4b1fb9 100755 (executable)
 
 bool ms_config_get_int(const char *key, int *value);
 bool ms_config_set_int(const char *key, int value);
-int ms_get_remain_space(uint64_t *free_space);
 
 bool ms_is_valid_symlink(const char *path);
 int ms_check_file_path(const char *file_path, uid_t uid);
 int ms_check_ignore_dir(const char *full_path, uid_t uid);
 int ms_check_scan_ignore(char * path, uid_t uid);
-bool ms_storage_mount_status(const char* start_path);
 int ms_set_db_status(ms_db_status_type_t status, ms_user_storage_type_e storage_type);
 int ms_set_power_mode(ms_db_status_type_t status);
 void ms_trim_dir_path(char *dir_path);
-int ms_check_size_mediadb(uid_t uid, uint64_t *db_size);
+
 #ifdef _USE_TVPD_MODE
+int ms_get_remain_space(uint64_t *free_space);
+int ms_check_size_mediadb(uid_t uid, uint64_t *db_size);
+bool ms_storage_mount_status(const char* start_path);
 bool ms_is_support_pvr(void);
 int ms_set_vip_process(void);
 #endif
index 41e5f67..3fd8e29 100644 (file)
@@ -35,73 +35,77 @@ static void **func_array;
 static void *func_handle = NULL;
 static int scan_other_type = -1;
 
-typedef int (*CLEANUP_DB)(sqlite3*, uid_t);
 typedef int (*INSERT_ITEM_BEGIN)(bool, int);
 typedef int (*INSERT_ITEM_END)(uid_t);
 
 typedef int (*SEND_DIR_UPDATE_NOTI)(const char *, const char *, int, int);
 typedef int (*INSERT_ITEM)(sqlite3 *, const char *, const char *, int, uid_t);
 typedef int (*SET_ITEM_VALIDITY)(const char *, const char *, int, int, uid_t);
-typedef int (*DELETE_ALL_INVALID_ITEMS_IN_FOLDER)(sqlite3 *, const char *, const char *, bool, uid_t);
-typedef int (*UPDATE_FOLDER_TIME)(sqlite3 *, const char *, const char *, uid_t);
 typedef int (*GET_STORAGE_ID)(sqlite3 *, const char *, char *, uid_t uid);
-typedef int (*SET_STORAGE_SCAN_STATUS)(sqlite3 *, const char *, int, uid_t);
 typedef int (*INSERT_FOLDER)(sqlite3 *, const char *, const char *, int, uid_t);
 typedef int (*SET_FOLDER_VALIDITY)(sqlite3 *, const char *, const char *, int, bool, uid_t);
-typedef int (*INSERT_ITEM_SCAN)(sqlite3 *, const char *, const char *, int, uid_t);
-typedef int (*GET_FOLDER_SCAN_STATUS)(sqlite3 *, const char *, const char *, int *);
-typedef int (*SET_FOLDER_SCAN_STATUS)(sqlite3 *, const char *, const char *, int, uid_t);
-typedef int (*CHECK_FOLDER_MODIFIED)(sqlite3 *, const char *, const char *, bool *);
-typedef int (*GET_NULL_SCAN_FOLDER_LIST)(sqlite3 *, const char *, const char *, GPtrArray **);
-typedef int (*CHANGE_VALIDITY_ITEM_BATCH)(sqlite3 *, const char *, const char *, int, int, uid_t);
 
 typedef int (*CHECK_DB)(sqlite3*, uid_t);
-typedef int (*GET_UUID)(char **);
 typedef int (*CHECK_STORAGE)(sqlite3 *, const char *, char **, int *, uid_t);
 typedef int (*INSERT_STORAGE)(sqlite3 *, const char *, int, const char *, uid_t);
 typedef int (*UPDATE_STORAGE)(sqlite3 *, const char *, const char *, uid_t);
 typedef int (*SET_STORAGE_VALIDITY)(sqlite3 *, const char *, int, uid_t uid);
 typedef int (*SET_ALL_STORAGE_VALIDITY)(sqlite3 *, int, uid_t);
-
-typedef int (*DELETE_INVALID_FOLDER_BY_PATH)(sqlite3 *, const char *, const char *, uid_t);
 typedef int (*CHECK_FOLDER_EXIST)(sqlite3*, const char*, const char*);
-typedef int (*GET_EXTRACT_LIST)(sqlite3*, const char*, int, const char*, int, void*);
-typedef int (*UPDATE_ONE_EXTRACT_ITEM)(sqlite3*, const char*, int, void *);
 typedef int (*GET_MEDIA_TYPE)(const char *, int *);
 typedef int (*REFRESH_ITEM)(sqlite3 *, const char *, const char *, uid_t);
 
+#ifdef _USE_TVPD_MODE
+typedef int (*CLEANUP_DB)(sqlite3*, uid_t);
+typedef int (*UPDATE_FOLDER_TIME)(sqlite3 *, const char *, const char *, uid_t);
+typedef int (*GET_UUID)(char **);
+typedef int (*SET_STORAGE_SCAN_STATUS)(sqlite3 *, const char *, int, uid_t);
+typedef int (*INSERT_ITEM_SCAN)(sqlite3 *, const char *, const char *, int, uid_t);
+typedef int (*GET_EXTRACT_LIST)(sqlite3*, const char*, int, const char*, int, void*);
+typedef int (*UPDATE_ONE_EXTRACT_ITEM)(sqlite3*, const char*, int, void *);
+typedef int (*DELETE_ALL_INVALID_ITEMS_IN_FOLDER)(sqlite3 *, const char *, const char *, bool, uid_t);
+typedef int (*DELETE_INVALID_FOLDER_BY_PATH)(sqlite3 *, const char *, const char *, uid_t);
+typedef int (*GET_FOLDER_SCAN_STATUS)(sqlite3 *, const char *, const char *, int *);
+typedef int (*SET_FOLDER_SCAN_STATUS)(sqlite3 *, const char *, const char *, int, uid_t);
+typedef int (*CHECK_FOLDER_MODIFIED)(sqlite3 *, const char *, const char *, bool *);
+typedef int (*GET_NULL_SCAN_FOLDER_LIST)(sqlite3 *, const char *, const char *, GPtrArray **);
+typedef int (*CHANGE_VALIDITY_ITEM_BATCH)(sqlite3 *, const char *, const char *, int, int, uid_t);
+#endif
+
 enum func_list {
-       eCLEANUP_DB,
        eINSERT_BEGIN,
        eINSERT_END,
        eINSERT_BATCH,
-       eINSERT_SCAN,
        eSET_VALIDITY,
-       eDELETE_FOLDER,
        eSEND_DIR_UPDATE_NOTI,
-       eUPDATE_FOLDER_TIME,
        eGET_STORAGE_ID,
-       eSET_STORAGE_SCAN_STATUS,
        eINSERT_FOLDER,
        eSET_FOLDER_VALIDITY,
-       eGET_FOLDER_SCAN_STATUS,
-       eSET_FOLDER_SCAN_STATUS,
-       eCHECK_FOLDER_MODIFIED,
-       eGET_NULL_SCAN_FOLDER_LIST,
-       eCHANGE_VALIDITY_ITEM_BATCH,
        eCHECK_DB,
-       eGET_UUID,
        eCHECK_STORAGE,
        eINSERT_STORAGE,
        eUPDATE_STORAGE,
        eSET_STORAGE_VALIDITY,
        eSET_ALL_STORAGE_VALIDITY,
-       eDELETE_INVALID_FOLDER_BY_PATH,
        eCHECK_FOLDER_EXIST,
        eGET_MEDIA_TYPE,
+       eREFRESH_ITEM,
+#ifdef _USE_TVPD_MODE
+       eCLEANUP_DB,
+       eUPDATE_FOLDER_TIME,
+       eGET_UUID,
+       eSET_STORAGE_SCAN_STATUS,
+       eINSERT_SCAN,
        eGET_EXTRACT_LIST,
        eUPDATE_ONE_EXTRACT_ITEM,
-       eREFRESH_ITEM,
+       eDELETE_FOLDER,
+       eDELETE_INVALID_FOLDER_BY_PATH,
+       eGET_FOLDER_SCAN_STATUS,
+       eSET_FOLDER_SCAN_STATUS,
+       eCHECK_FOLDER_MODIFIED,
+       eGET_NULL_SCAN_FOLDER_LIST,
+       eCHANGE_VALIDITY_ITEM_BATCH,
+#endif
        eFUNC_MAX
 };
 
@@ -109,37 +113,39 @@ int ms_load_functions(void)
 {
        int func_index;
        char func_list[eFUNC_MAX][40] = {
-               "cleanup_db",
                "insert_item_begin",
                "insert_item_end",
                "insert_item",
-               "insert_item_scan",
                "set_item_validity",
-               "delete_all_invalid_items_in_folder",
                "send_dir_update_noti",
-               "update_folder_time",
                "get_storage_id",
-               "set_storage_scan_status",
                "insert_folder",
                "set_folder_validity",
-               "get_folder_scan_status",
-               "set_folder_scan_status",
-               "check_folder_modified",
-               "get_null_scan_folder_list",
-               "change_validity_item_batch",
                "check_db",
-               "get_uuid",
                "check_storage",
                "insert_storage",
                "update_storage",
                "set_storage_validity",
                "set_all_storage_validity",
-               "delete_invalid_folder_by_path",
                "check_folder_exist",
                "get_media_type",
+               "refresh_item",
+#ifdef _USE_TVPD_MODE
+               "cleanup_db",
+               "update_folder_time",
+               "get_uuid",
+               "set_storage_scan_status",
+               "insert_item_scan",
                "get_extract_list",
                "update_one_extract_item",
-               "refresh_item",
+               "delete_all_invalid_items_in_folder",
+               "delete_invalid_folder_by_path",
+               "get_folder_scan_status",
+               "set_folder_scan_status",
+               "check_folder_modified",
+               "get_null_scan_folder_list",
+               "change_validity_item_batch",
+#endif
                };
 
        func_handle = dlopen(CONFIG_PATH, RTLD_LAZY);
@@ -187,18 +193,6 @@ void ms_disconnect_db(sqlite3 *handle)
        media_db_disconnect(handle);
 }
 
-int ms_cleanup_db(sqlite3 *handle, uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-
-       ret = ((CLEANUP_DB)func_array[eCLEANUP_DB])(handle, uid);
-       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "CLEANUP_DB failed [%d]", ret);
-
-       MS_DBG_INFO("Cleanup Media DB");
-
-       return ret;
-}
-
 static int __ms_check_item_exist(sqlite3 *handle, const char *storage_id, const char *path, bool *modified)
 {
        int ret = MS_MEDIA_ERR_NONE;
@@ -331,42 +325,6 @@ int ms_insert_item_batch(sqlite3 *handle, const char *storage_id, const char *pa
        return ret;
 }
 
-int ms_scan_item_batch(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-       ms_user_storage_type_e storage_type;
-
-       MS_DBG_FENTER();
-
-       ret = ms_user_get_storage_type(uid, path, &storage_type);
-       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Fail to get storage type");
-
-       ret = ((INSERT_ITEM_SCAN)func_array[eINSERT_SCAN])(handle, storage_id, path, storage_type, uid);
-       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "INSERT_ITEM_SCAN failed [%d]", ret);
-
-       return ret;
-}
-
-int ms_get_extract_list(sqlite3 *handle, const char* storage_id, int scan_type, const char* path, int is_end, void *array)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-
-       ret = ((GET_EXTRACT_LIST)func_array[eGET_EXTRACT_LIST])(handle, storage_id, scan_type, path, is_end, array);
-       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "GET_EXTRACT_LIST failed [%d]", ret);
-
-       return ret;
-}
-
-int ms_update_one_extract_item(sqlite3 *handle, const char* storage_id, int storage_type, void *data)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-
-       ret = ((UPDATE_ONE_EXTRACT_ITEM)func_array[eUPDATE_ONE_EXTRACT_ITEM])(handle, storage_id, storage_type, data);
-       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "UPDATE_ONE_EXTRACT_ITEM failed [%d]", ret);
-
-       return ret;
-}
-
 int ms_delete_invalid_items(sqlite3 *handle, const char *storage_id, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
@@ -450,16 +408,6 @@ int ms_set_folder_item_validity(sqlite3 *handle, const char *storage_id, const c
        return ret;
 }
 
-int ms_delete_invalid_items_in_folder(sqlite3 *handle, const char *storage_id, const char *path, bool is_recursive, uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-
-       ret = ((DELETE_ALL_INVALID_ITEMS_IN_FOLDER)func_array[eDELETE_FOLDER])(handle, storage_id, path, is_recursive, uid);
-       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "DELETE_ALL_INVALID_ITEMS_IN_FOLDER failed [%d]", ret);
-
-       return ret;
-}
-
 int ms_send_dir_update_noti(const char*path, const char*folder_id, ms_noti_type_e noti_type, int pid)
 {
        int ret = MS_MEDIA_ERR_NONE;
@@ -470,16 +418,6 @@ int ms_send_dir_update_noti(const char*path, const char*folder_id, ms_noti_type_
        return ret;
 }
 
-int ms_update_folder_time(sqlite3 *handle, const char *storage_id, char *folder_path, uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-
-       ret = ((UPDATE_FOLDER_TIME)func_array[eUPDATE_FOLDER_TIME])(handle, storage_id, folder_path, uid);
-       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "UPDATE_FOLDER_TIME failed [%d]", ret);
-
-       return ret;
-}
-
 int ms_get_storage_id(sqlite3 *handle, const char *path, char *storage_id, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
@@ -494,21 +432,6 @@ int ms_get_storage_id(sqlite3 *handle, const char *path, char *storage_id, uid_t
        return ret;
 }
 
-int ms_set_storage_scan_status(sqlite3 *handle, char *storage_id, media_scan_status_e scan_status, uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-       int status = scan_status;
-
-       MS_DBG_FENTER();
-
-       ret = ((SET_STORAGE_SCAN_STATUS)func_array[eSET_STORAGE_SCAN_STATUS])(handle, storage_id, status, uid);
-       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "SET_STORAGE_SCAN_STATUS failed [%d]", ret);
-
-       MS_DBG("storage_id [%s], scan_status [%d]", storage_id, scan_status);
-
-       return ret;
-}
-
 int ms_insert_folder(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
@@ -566,16 +489,6 @@ int ms_check_db(sqlite3 *handle, uid_t uid)
        return ret;
 }
 
-int ms_genarate_uuid(char **uuid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-
-       ret = ((GET_UUID)func_array[eGET_UUID])(uuid);
-       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "GET_UUID failed [%d]", ret);
-
-       return ret;
-}
-
 int ms_check_storage(sqlite3 *handle, const char *storage_id, char **storage_path, int *validity, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
@@ -642,16 +555,6 @@ int ms_set_all_storage_validity(sqlite3 *handle, int validity, uid_t uid)
        return ret;
 }
 
-int ms_delete_invalid_folder_by_path(sqlite3 *handle, const char *storage_id, const char *folder_path, uid_t uid)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-
-       ret = ((DELETE_INVALID_FOLDER_BY_PATH)func_array[eDELETE_INVALID_FOLDER_BY_PATH])(handle, storage_id, folder_path, uid);
-       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "DELETE_INVALID_FOLDER_BY_PATH failed [%d]", ret);
-
-       return ret;
-}
-
 int ms_check_folder_exist(sqlite3 *handle, const char *storage_id, const char *folder_path)
 {
        int ret = MS_MEDIA_ERR_NONE;
@@ -714,6 +617,149 @@ void ms_register_end(uid_t uid)
                MS_DBG_ERR("INSERT_ITEM_END failed [%d]", ret);
 }
 
+int ms_get_media_type(const char *path, int *media_type)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+
+       ret = ((GET_MEDIA_TYPE)func_array[eGET_MEDIA_TYPE])(path, media_type);
+       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "GET_MEDIA_TYPE failed [%d]", ret);
+
+       return ret;
+}
+
+bool ms_check_support_media_type(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 (!scan_other_type) {
+               ret = ms_get_media_type(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;
+}
+
+#ifdef _USE_TVPD_MODE
+int ms_cleanup_db(sqlite3 *handle, uid_t uid)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+
+       ret = ((CLEANUP_DB)func_array[eCLEANUP_DB])(handle, uid);
+       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "CLEANUP_DB failed [%d]", ret);
+
+       MS_DBG_INFO("Cleanup Media DB");
+
+       return ret;
+}
+
+int ms_update_folder_time(sqlite3 *handle, const char *storage_id, char *folder_path, uid_t uid)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+
+       ret = ((UPDATE_FOLDER_TIME)func_array[eUPDATE_FOLDER_TIME])(handle, storage_id, folder_path, uid);
+       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "UPDATE_FOLDER_TIME failed [%d]", ret);
+
+       return ret;
+}
+
+int ms_set_storage_scan_status(sqlite3 *handle, char *storage_id, media_scan_status_e scan_status, uid_t uid)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+       int status = scan_status;
+
+       MS_DBG_FENTER();
+
+       ret = ((SET_STORAGE_SCAN_STATUS)func_array[eSET_STORAGE_SCAN_STATUS])(handle, storage_id, status, uid);
+       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "SET_STORAGE_SCAN_STATUS failed [%d]", ret);
+
+       MS_DBG("storage_id [%s], scan_status [%d]", storage_id, scan_status);
+
+       return ret;
+}
+
+int ms_genarate_uuid(char **uuid)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+
+       ret = ((GET_UUID)func_array[eGET_UUID])(uuid);
+       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "GET_UUID failed [%d]", ret);
+
+       return ret;
+}
+
+int ms_scan_item_batch(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+       ms_user_storage_type_e storage_type;
+
+       MS_DBG_FENTER();
+
+       ret = ms_user_get_storage_type(uid, path, &storage_type);
+       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Fail to get storage type");
+
+       ret = ((INSERT_ITEM_SCAN)func_array[eINSERT_SCAN])(handle, storage_id, path, storage_type, uid);
+       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "INSERT_ITEM_SCAN failed [%d]", ret);
+
+       return ret;
+}
+
+int ms_get_extract_list(sqlite3 *handle, const char* storage_id, int scan_type, const char* path, int is_end, void *array)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+
+       ret = ((GET_EXTRACT_LIST)func_array[eGET_EXTRACT_LIST])(handle, storage_id, scan_type, path, is_end, array);
+       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "GET_EXTRACT_LIST failed [%d]", ret);
+
+       return ret;
+}
+
+int ms_update_one_extract_item(sqlite3 *handle, const char* storage_id, int storage_type, void *data)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+
+       ret = ((UPDATE_ONE_EXTRACT_ITEM)func_array[eUPDATE_ONE_EXTRACT_ITEM])(handle, storage_id, storage_type, data);
+       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "UPDATE_ONE_EXTRACT_ITEM failed [%d]", ret);
+
+       return ret;
+}
+
+int ms_delete_invalid_items_in_folder(sqlite3 *handle, const char *storage_id, const char *path, bool is_recursive, uid_t uid)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+
+       ret = ((DELETE_ALL_INVALID_ITEMS_IN_FOLDER)func_array[eDELETE_FOLDER])(handle, storage_id, path, is_recursive, uid);
+       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "DELETE_ALL_INVALID_ITEMS_IN_FOLDER failed [%d]", ret);
+
+       return ret;
+}
+
+int ms_delete_invalid_folder_by_path(sqlite3 *handle, const char *storage_id, const char *folder_path, uid_t uid)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+
+       ret = ((DELETE_INVALID_FOLDER_BY_PATH)func_array[eDELETE_INVALID_FOLDER_BY_PATH])(handle, storage_id, folder_path, uid);
+       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "DELETE_INVALID_FOLDER_BY_PATH failed [%d]", ret);
+
+       return ret;
+}
+
 int ms_get_folder_scan_status(sqlite3 *handle, const char *storage_id, const char *path, int *scan_status)
 {
        int ret = MS_MEDIA_ERR_NONE;
@@ -771,42 +817,4 @@ int ms_change_validity_item_batch(sqlite3 *handle, const char *storage_id, const
 
        return ret;
 }
-
-int ms_get_media_type(const char *path, int *media_type)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-
-       ret = ((GET_MEDIA_TYPE)func_array[eGET_MEDIA_TYPE])(path, media_type);
-       MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "GET_MEDIA_TYPE failed [%d]", ret);
-
-       return ret;
-}
-
-bool ms_check_support_media_type(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 (!scan_other_type) {
-               ret = ms_get_media_type(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;
-}
+#endif
index a861da4..4e97300 100644 (file)
@@ -74,6 +74,7 @@ bool ms_config_set_int(const char *key, int value)
        return false;
 }
 
+#ifdef _USE_TVPD_MODE
 int ms_get_remain_space(uint64_t *free_space)
 {
        int ret = MS_MEDIA_ERR_NONE;
@@ -93,7 +94,6 @@ int ms_get_remain_space(uint64_t *free_space)
        return MS_MEDIA_ERR_NONE;
 }
 
-#ifdef _USE_TVPD_MODE
 bool ms_is_support_pvr(void)
 {
        bool bSupportPVR = false;
@@ -236,7 +236,7 @@ int ms_check_scan_ignore(char * path, uid_t uid)
        } else {
                MS_DBG_ERR("g_file_test fails[%s]", path);
                ret = MS_MEDIA_ERR_INVALID_PARAMETER;
-
+#ifdef _USE_TVPD_MODE
                if (!MS_STRING_VALID(MEDIA_ROOT_PATH_USB)) {
                        MS_DBG_ERR("Fail to get USB path");
                        return ret;
@@ -249,6 +249,7 @@ int ms_check_scan_ignore(char * path, uid_t uid)
                                return MS_MEDIA_ERR_USB_UNMOUNTED;
                        }
                }
+#endif
        }
 
        return ret;
@@ -272,12 +273,10 @@ static void __ms_check_mount_status(usb_device_h usb_device, void *user_data)
        MS_DBG_SWARN("mount_path [%s]", mount_path);
        data->result = (g_strcmp0(mount_path, data->storage_path) == 0);
 }
-#endif
 
 bool ms_storage_mount_status(const char *start_path)
 {
        bool ret = false;
-#ifdef _USE_TVPD_MODE
        storage_result_s res = {0, };
        char *remain_path = NULL;
        int remain_len = 0;
@@ -296,10 +295,30 @@ bool ms_storage_mount_status(const char *start_path)
 
        if (ret)
                MS_DBG_SWARN("start path is mounted [%s]", start_path);
-#endif
        return ret;
 }
 
+int ms_check_size_mediadb(uid_t uid, uint64_t *db_size)
+{
+       int ret = MS_MEDIA_ERR_NONE;
+       char *db_path = NULL;
+       struct stat buf;
+
+       ret = ms_user_get_media_db_path(uid, &db_path);
+
+       if (stat(db_path, &buf) == 0) {
+               *db_size = (uint64_t)buf.st_size;
+       } else {
+               MS_DBG_STRERROR("stat failed");
+               ret = MS_MEDIA_ERR_INTERNAL;
+       }
+
+       g_free(db_path);
+
+       return ret;
+}
+#endif
+
 int ms_set_db_status(ms_db_status_type_t status, ms_user_storage_type_e storage_type)
 {
        int ret = MS_MEDIA_ERR_NONE;
@@ -366,26 +385,6 @@ void ms_trim_dir_path(char *dir_path)
                dir_path[len -1] = '\0';
 }
 
-int ms_check_size_mediadb(uid_t uid, uint64_t *db_size)
-{
-       int ret = MS_MEDIA_ERR_NONE;
-       char *db_path = NULL;
-       struct stat buf;
-
-       ret = ms_user_get_media_db_path(uid, &db_path);
-
-       if (stat(db_path, &buf) == 0) {
-               *db_size = (uint64_t)buf.st_size;
-       } else {
-               MS_DBG_STRERROR("stat failed");
-               ret = MS_MEDIA_ERR_INTERNAL;
-       }
-
-       g_free(db_path);
-
-       return ret;
-}
-
 #ifdef _USE_TVPD_MODE
 #define PROC_OOM_SCORE_ADJ_PATH                "/proc/%d/oom_score_adj"
 #define VIP_OOM_SCORE_ADJ                      (-1000)
index a4c8165..2e2dcba 100755 (executable)
 #ifndef _MEDIA_SERVER_DB_MANAGER_H__
 #define _MEDIA_SERVER_DB_MANAGER_H__
 
+#ifdef _USE_TVPD_MODE
 #include "media-common-types.h"
 
 int ms_reset_mediadb(uid_t uid);
 int ms_check_mediadb(uid_t uid, bool *is_reset);
 int ms_check_corrupt_mediadb(void);
-
+#endif
 #endif
index 1d7598f..4ad5e03 100755 (executable)
@@ -19,6 +19,7 @@
  *
  */
 
+#ifdef _USE_TVPD_MODE
 #include <gio/gio.h>
 
 #include "media-util.h"
@@ -78,9 +79,7 @@ static int __ms_remake_mediadb(uid_t uid)
        MS_DBG_ERR("THE SIZE OF MEDIA DB REACH THE LIMIT. RESET MEDIA DB.");
 
        /*write read schema*/
-#ifdef _USE_TVPD_MODE
        ms_config_set_int(MS_DB_RESET, 1);
-#endif
        ms_reset_mediadb(uid);
 
        ms_connect_db(&handle, uid);
@@ -94,9 +93,7 @@ static int __ms_remake_mediadb(uid_t uid)
        /*disconnect form media db*/
        ms_disconnect_db(handle);
 
-#ifdef _USE_TVPD_MODE
        ms_config_set_int(MS_DB_RESET, 0);
-#endif
        return MS_MEDIA_ERR_NONE;
 }
 
@@ -140,3 +137,4 @@ int ms_check_corrupt_mediadb(void)
 
        return MS_MEDIA_ERR_NONE;
 }
+#endif
index 2336099..6b9d1fa 100644 (file)
 #include "media-server-dcm.h"
 #include "media-server-db-manage.h"
 
+#ifdef _USE_TVPD_MODE
 #define MS_VCONF_KEY_RESET_STATUS "db/media_server/reset_status"
+#define SMARTHUB_RESET_VCONF "db/smarthub/reset/firstscreen"
+
+bool smarthub_reset;
+#endif
+
 extern GMutex scanner_mutex;
 
 GMainLoop *mainloop = NULL;
 bool power_off; /*If this is true, poweroff notification received*/
 
-#define SMARTHUB_RESET_VCONF "db/smarthub/reset/firstscreen"
-bool smarthub_reset_start;
-bool smarthub_reset;
 static guint main_source_id;
 
 static void __ms_check_mediadb(void);
@@ -426,9 +429,10 @@ static void __ms_check_mediadb(void)
                return;
        }
 
+#ifdef _USE_TVPD_MODE
        if (ms_set_storage_scan_status(db_handle, NULL, MEDIA_SCAN_PREPARE, uid) != MS_MEDIA_ERR_NONE)
                MS_DBG_ERR("ms_set_storage_scan_status fail");
-
+#endif
        /*update just valid type*/
        if (ms_set_all_storage_validity(db_handle, 0, uid) != MS_MEDIA_ERR_NONE)
                MS_DBG_ERR("ms_set_all_storage_validity fail");
@@ -441,7 +445,6 @@ static void __ms_check_mediadb(void)
        ms_send_storage_scan_request(internal_path, INTERNAL_STORAGE_ID, MS_SCAN_PART, uid);
        g_free(internal_path);
 #endif
-
        ms_disconnect_db(db_handle);
 #endif
 
index c243def..936ad9e 100644 (file)
@@ -170,9 +170,9 @@ static void __ms_recovery_media_db(uid_t uid)
        /*reset */
 #ifdef _USE_TVPD_MODE
        ms_config_set_int(MS_DB_RESET, 1);
+       ms_reset_mediadb(uid);
 #endif
        ms_reset_ownerlist();
-       ms_reset_mediadb(uid);
 
        /*write read schema*/
        ms_connect_db(&handle, uid);