extern "C" {
#endif
-typedef enum {
- MS_USER_STORAGE_INTERNAL = 0, /**< The device's internal storage */
- MS_USER_STORAGE_EXTERNAL = 1, /**< The device's external storage */
- MS_USER_STORAGE_EXTERNAL_USB = 2, /**< The external USB storage (Since 2.4) */
-} ms_user_storage_type_e;
-
int ms_user_get_internal_root_path(uid_t uid, char **path);
-int ms_user_get_storage_type(uid_t uid, const char *path, ms_user_storage_type_e *storage_type);
+bool ms_user_is_valid_path(uid_t uid, const char *path);
+bool ms_user_thumb_support(uid_t uid, const char *path);
int ms_user_get_root_thumb_store_path(uid_t uid, char **path);
int ms_user_get_media_db_path(uid_t uid, char **path);
int ms_user_get_wordbook_db_path(uid_t uid, char **path);
static int __check_dir_path(const char *dir_path, uid_t uid)
{
- int ret = MS_MEDIA_ERR_NONE;
- ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
-
- ret = ms_user_get_storage_type(uid, dir_path, &storage_type);
- MSAPI_RETVM_IF(ret != MS_MEDIA_ERR_NONE, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
+ MSAPI_RETVM_IF(!ms_user_is_valid_path(uid, dir_path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
/* dir_path can be a deleted path. */
if (g_file_test(dir_path, G_FILE_TEST_EXISTS)) {
return MS_MEDIA_ERR_NONE;
}
-int ms_user_get_storage_type(uid_t uid, const char *path, ms_user_storage_type_e *storage_type)
+static bool __ms_user_is_internal(uid_t uid, const char *path)
{
int ret = MS_MEDIA_ERR_NONE;
- char *internal_path = NULL;
+ g_autofree gchar *internal_path = NULL;
- MSAPI_RETVM_IF(!MS_STRING_VALID(path), MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
+ MSAPI_RETVM_IF(!MS_STRING_VALID(path), false, "Invalid path");
ret = ms_user_get_internal_root_path(uid, &internal_path);
- MSAPI_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Fail to get internal root path");
-
- if (g_str_has_prefix(path, internal_path)) {
- *storage_type = MS_USER_STORAGE_INTERNAL;
- } else if (MS_STRING_VALID(MEDIA_ROOT_PATH_SDCARD) && g_str_has_prefix(path, MEDIA_ROOT_PATH_SDCARD)) {
- *storage_type = MS_USER_STORAGE_EXTERNAL;
- } else if (MS_STRING_VALID(MEDIA_ROOT_PATH_USB) && g_str_has_prefix(path, MEDIA_ROOT_PATH_USB)) {
- *storage_type = MS_USER_STORAGE_EXTERNAL_USB;
- } else {
- MSAPI_DBG_ERR("[%s][%s][%s]", MEDIA_ROOT_PATH_SDCARD, MEDIA_ROOT_PATH_USB, path);
- ret = MS_MEDIA_ERR_INVALID_PARAMETER;
- }
+ MSAPI_RETVM_IF(ret != MS_MEDIA_ERR_NONE, false, "Fail to get internal root path");
- g_free(internal_path);
+ return g_str_has_prefix(path, internal_path);
+}
- return ret;
+bool ms_user_is_valid_path(uid_t uid, const char *path)
+{
+ if (__ms_user_is_internal(uid, path))
+ return true;
+
+ if (MS_STRING_VALID(MEDIA_ROOT_PATH_EXTERNAL) && g_str_has_prefix(path, MEDIA_ROOT_PATH_EXTERNAL))
+ return true;
+
+ MSAPI_DBG_ERR("Invalid path[%s]", path);
+
+ return false;
+}
+
+bool ms_user_thumb_support(uid_t uid, const char *path)
+{
+ if (__ms_user_is_internal(uid, path))
+ return true;
+
+ if (MS_STRING_VALID(MEDIA_ROOT_PATH_SDCARD) && g_str_has_prefix(path, MEDIA_ROOT_PATH_SDCARD))
+ return true;
+
+ return false;
}
int ms_user_get_root_thumb_store_path(uid_t uid, char **path)
Name: media-server
Summary: A server for media content management
-Version: 0.5.1
+Version: 0.5.2
Release: 0
Group: Multimedia/Service
License: Apache-2.0
int ms_genarate_uuid(char **uuid);
int ms_scan_item_batch(sqlite3 *handle, const char *storage_id, const char *path, uid_t uid);
int ms_get_extract_list(sqlite3 *handle, const char *storage_id, int scan_type, const char* path, int is_end, void *array);
-int ms_update_one_extract_item(sqlite3 *handle, const char *storage_id, int storage_type, void *data);
+int ms_update_one_extract_item(sqlite3 *handle, const char *storage_id, void *data);
int ms_delete_invalid_items_in_folder(sqlite3 *handle, const char *storage_id, const char *path, bool is_recursive, uid_t uid);
int ms_delete_invalid_folder_by_path(sqlite3 *handle, const char *storage_id, const char *folder_path, uid_t uid);
int ms_get_folder_scan_status(sqlite3 *handle, const char *storage_id, const char *path, int *scan_status);
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 (*INSERT_ITEM)(sqlite3 *, const char *, const char *, uid_t);
typedef int (*SET_ITEM_VALIDITY)(const char *, const char *, int, int, uid_t);
typedef int (*GET_STORAGE_ID)(sqlite3 *, const char *, char *, uid_t uid);
-typedef int (*INSERT_FOLDER)(sqlite3 *, const char *, const char *, int, uid_t);
+typedef int (*INSERT_FOLDER)(sqlite3 *, const char *, const char *, uid_t);
typedef int (*SET_FOLDER_VALIDITY)(sqlite3 *, const char *, const char *, int, bool, uid_t);
typedef int (*CHECK_DB)(sqlite3 *, uid_t);
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 (*INSERT_STORAGE)(sqlite3 *, const char *, 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 (*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 (*INSERT_ITEM_SCAN)(sqlite3 *, const char *, const char *, 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 (*UPDATE_ONE_EXTRACT_ITEM)(sqlite3 *, const char *, 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 *);
int ms_insert_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 = -1;
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)func_array[eINSERT_BATCH])(handle, storage_id, path, storage_type, uid);
+ ret = ((INSERT_ITEM)func_array[eINSERT_BATCH])(handle, storage_id, path, uid);
MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "INSERT_ITEM failed [%d]", ret);
return ret;
int ms_insert_folder(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;
-
- 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_FOLDER)func_array[eINSERT_FOLDER])(handle, storage_id, path, storage_type, uid);
+ ret = ((INSERT_FOLDER)func_array[eINSERT_FOLDER])(handle, storage_id, path, uid);
MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "INSERT_FOLDER failed [%d]", ret);
return ret;
int ms_insert_storage(sqlite3 *handle, const char *storage_id, const char *storage_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, storage_path, &storage_type);
- MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Fail to get storage type");
-
- ret = ((INSERT_STORAGE)func_array[eINSERT_STORAGE])(handle, storage_id, storage_type, storage_path, uid);
+ ret = ((INSERT_STORAGE)func_array[eINSERT_STORAGE])(handle, storage_id, storage_path, uid);
MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "INSERT_STORAGE failed [%d]", ret);
MS_DBG_FLEAVE();
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);
+ ret = ((INSERT_ITEM_SCAN)func_array[eINSERT_SCAN])(handle, storage_id, path, uid);
MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "INSERT_ITEM_SCAN failed [%d]", ret);
return ret;
return ret;
}
-int ms_update_one_extract_item(sqlite3 *handle, const char* storage_id, int storage_type, void *data)
+int ms_update_one_extract_item(sqlite3 *handle, const char* storage_id, 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);
+ ret = ((UPDATE_ONE_EXTRACT_ITEM)func_array[eUPDATE_ONE_EXTRACT_ITEM])(handle, storage_id, data);
MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "UPDATE_ONE_EXTRACT_ITEM failed [%d]", ret);
return ret;
int ret = MS_MEDIA_ERR_NONE;
char *dir_path = NULL;
char *next = NULL;
- int next_pos = 0;
- ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
-
- ret = ms_user_get_storage_type(uid, full_path, &storage_type);
- MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "Invalid path");
-
- if (storage_type == MS_USER_STORAGE_INTERNAL) {
- ret = ms_user_get_internal_root_path(uid, &dir_path);
- MS_DBG_RETVM_IF(ret != MS_MEDIA_ERR_NONE, ret, "ms_user_get_internal_root_path() fail");
-
- next_pos = strlen(dir_path);
- g_free(dir_path);
- dir_path = NULL;
- } else {
- next_pos = strlen(MEDIA_ROOT_PATH_USB) + 1;
- }
+ int next_pos = 1;
while ((next = strstr(full_path + next_pos, "/"))) {
next_pos = (next - full_path);
g_cond_clear(&extract_data_cond);
}
-static int __msc_folder_bulk_extract(sqlite3 *handle, const char *storage_id, int storage_type, const char *path, int scan_type, int pid, bool is_end)
+static int __msc_folder_bulk_extract(sqlite3 *handle, const char *storage_id, const char *path, int scan_type, int pid, bool is_end)
{
MS_DBG_WARN("begin of __msc_folder_bulk_extract");
int ret = MS_MEDIA_ERR_NONE;
g_array_remove_index(data_array, 0);
g_mutex_lock(&decode_mutex);
- ms_update_one_extract_item(handle, storage_id, storage_type, db_data);
+ ms_update_one_extract_item(handle, storage_id, db_data);
g_mutex_unlock(&decode_mutex);
if (db_data) {
int ret = MS_MEDIA_ERR_NONE;
sqlite3 *handle = NULL;
int end_flag = NORMAL_EVENT;
- ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
while (1) {
extract_data = g_async_queue_pop(folder_extract_queue);
}
end_flag = extract_data->result ? LAST_EVENT : NORMAL_EVENT;
- ret = ms_user_get_storage_type(extract_data->uid, extract_data->msg, &storage_type);
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_user_get_storage_type failed");
- goto NEXT;
- }
-
ret = __msc_check_extract_stop_status(extract_data->msg_type, extract_data->msg, extract_data->pid);
if (ret == MS_MEDIA_ERR_SCANNER_FORCE_STOP) {
MS_DBG_ERR("MS_MEDIA_ERR_SCANNER_FORCE_STOP");
goto NEXT;
}
- ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, storage_type, extract_data->msg, extract_data->msg_type, extract_data->pid, end_flag);
+ ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, extract_data->msg, extract_data->msg_type, extract_data->pid, end_flag);
NEXT:
g_directory_extract_processing = false;
ms_comm_msg_s *extract_data = NULL;
int ret = MS_MEDIA_ERR_NONE;
sqlite3 *handle = NULL;
- ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
int end_flag = NORMAL_EVENT;
resource_pid_t stResource = {};
goto NEXT;
}
- ret = ms_user_get_storage_type(extract_data->uid, extract_data->msg, &storage_type);
- if (ret != MS_MEDIA_ERR_NONE) {
- MS_DBG_ERR("ms_user_get_storage_type failed");
- goto NEXT;
- }
- if (storage_type == MS_USER_STORAGE_EXTERNAL_USB) {
+ if (MEDIA_ROOT_PATH_EXTERNAL && g_str_has_prefix(extract_data->msg, MEDIA_ROOT_PATH_EXTERNAL)) {
if (!ms_storage_mount_status(extract_data->msg)) {
MS_DBG_ERR("%s is unmounted", extract_data->msg);
ret = MS_MEDIA_ERR_USB_UNMOUNTED;
}
/*extract meta*/
- ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, storage_type, extract_data->msg, extract_data->msg_type, extract_data->pid, end_flag);
+ ret = __msc_folder_bulk_extract(handle, extract_data->storage_id, extract_data->msg, extract_data->msg_type, extract_data->pid, end_flag);
MS_DBG_WARN("extract PAUSE");
__msc_pause_extract();
MS_DBG_WARN("extract RESUME");