#include <media_info_private.h>
#include <media_util_private.h>
+#ifdef _USE_TVPD_MODE
+#include <media_content_type_product.h>
+#endif
+#ifdef _USE_TVPD_MODE
static char *g_src_path = NULL;
+#endif
int media_folder_get_folder_count_from_db(filter_h filter, int *folder_count)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
if (!folder_count) {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
+#ifdef _USE_TVPD_MODE
+ g_mutex_lock(_content_get_db_mutex());
+#endif
ret = _media_db_get_group_count(filter, MEDIA_GROUP_FOLDER, folder_count);
+#ifdef _USE_TVPD_MODE
+ g_mutex_unlock(_content_get_db_mutex());
+#endif
+
+
return ret;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
if (callback == NULL) {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
if (STRING_VALID(folder_id) && media_count) {
+#ifdef _USE_TVPD_MODE
+ g_mutex_lock(_content_get_db_mutex());
+#endif
+
ret = _media_db_get_group_item_count(folder_id, filter, MEDIA_GROUP_FOLDER, media_count);
+
+#ifdef _USE_TVPD_MODE
+ g_mutex_unlock(_content_get_db_mutex());
+#endif
+
} else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
if ((callback != NULL) && STRING_VALID(folder_id)) {
+#ifdef _USE_TVPD_MODE
+ g_mutex_lock(_content_get_db_mutex());
+#endif
+
ret = _media_db_get_group_item(folder_id, filter, callback, user_data, MEDIA_GROUP_FOLDER);
+
+#ifdef _USE_TVPD_MODE
+ g_mutex_unlock(_content_get_db_mutex());
+#endif
+
} else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
if ((callback != NULL) && STRING_VALID(folder_id)) {
ret = _media_db_get_group_item_by_union_select(folder_id, filter1, filter2, callback, user_data);
} else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
SAFE_FREE(_folder);
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
if (_src != NULL) {
media_folder_s *_dst = (media_folder_s*)calloc(1, sizeof(media_folder_s));
- media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
if (STRING_VALID(_src->folder_id)) {
_dst->folder_id = strdup(_src->folder_id);
if (_dst->folder_id == NULL) {
SAFE_FREE(_dst);
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
}
}
if (STRING_VALID(_src->name)) {
_dst->name = strdup(_src->name);
if (_dst->name == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
media_folder_destroy((media_folder_h)_dst);
return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
}
if (STRING_VALID(_src->path)) {
_dst->path = strdup(_src->path);
if (_dst->path == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
media_folder_destroy((media_folder_h)_dst);
return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
}
if (STRING_VALID(_src->storage_uuid)) {
_dst->storage_uuid = strdup(_src->storage_uuid);
if (_dst->storage_uuid == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
media_folder_destroy((media_folder_h)_dst);
return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
}
}
_dst->storage_type = _src->storage_type;
- _dst->modified_time = _src->modified_time;
- _dst->folder_order = _src->folder_order;
*dst = (media_folder_h)_dst;
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
if (_folder) {
if (STRING_VALID(_folder->folder_id)) {
*folder_id = strdup(_folder->folder_id);
- media_content_retvm_if(*folder_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ content_retvm_if(*folder_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
} else {
*folder_id = NULL;
}
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_folder_get_parent_folder_id(media_folder_h folder, char **parent_folder_id)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_folder_get_parent_folder_id() is deprecated and will be removed from next release.");
- media_folder_s *_folder = (media_folder_s*)folder;
- sqlite3_stmt *stmt = NULL;
- char tmp_path[MAX_PATH_LEN] = {0, };
- char *parent_path = NULL;
- char select_query[MAX_QUERY_SIZE] = {0, };
-
- /* Usage is low. So, DB access when this fuction is called */
- if (_folder) {
- memset(tmp_path, 0x00, sizeof(tmp_path));
- memset(select_query, 0x00, sizeof(select_query));
-
- _media_content_replace_path(_folder->path, tmp_path);
-
- parent_path = g_path_get_dirname(tmp_path);
- snprintf(select_query, sizeof(select_query), SELECT_FOLDER_ID_BY_PATH, parent_path);
- SAFE_FREE(parent_path);
-
- ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
-
- if (sqlite3_step(stmt) == SQLITE_ROW)
- *parent_folder_id = g_strdup((const char *)sqlite3_column_text(stmt, 0));
- else
- *parent_folder_id = NULL;
-
- SQLITE3_FINALIZE(stmt);
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
if (_folder) {
if (STRING_VALID(_folder->path)) {
*path = strdup(_folder->path);
- media_content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
} else {
*path = NULL;
}
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
if (_folder) {
if (STRING_VALID(_folder->name)) {
*name = strdup(_folder->name);
- media_content_retvm_if(*name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ content_retvm_if(*name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
} else {
*name = NULL;
}
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_folder_get_modified_time(media_folder_h folder, time_t* time)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_folder_get_modified_time() is deprecated and will be removed from next release.");
- media_folder_s *_folder = (media_folder_s*)folder;
-
- if (_folder) {
- *time = _folder->modified_time;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e* storage_type)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
+ content_warn("DEPRECATION WARNING: media_folder_get_storage_type() is deprecated and will be removed from next release. Use storage_get_type_dev() instead.");
media_folder_s *_folder = (media_folder_s*)folder;
if (_folder) {
*storage_type = _folder->storage_type;
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int media_folder_get_storage_id(media_folder_h folder, char **storage_id)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
+ content_warn("DEPRECATION WARNING: media_folder_get_storage_id() is deprecated and will be removed from next release.");
media_folder_s *_folder = (media_folder_s*)folder;
if (_folder) {
if (STRING_VALID(_folder->storage_uuid)) {
*storage_id = strdup(_folder->storage_uuid);
- media_content_retvm_if(*storage_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ content_retvm_if(*storage_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
} else {
*storage_id = NULL;
}
ret = MEDIA_CONTENT_ERROR_NONE;
} else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
return ret;
}
-int media_folder_get_order(media_folder_h folder, int *order)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_folder_get_order() is deprecated and will be removed from next release.");
- media_folder_s *_folder = (media_folder_s*)folder;
-
- if (_folder) {
- *order = _folder->folder_order;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-
int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folder)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
sqlite3_stmt *stmt = NULL;
- char select_query[DEFAULT_QUERY_SIZE];
- char *tmp_path = NULL;
- char repl_path[MAX_PATH_LEN] = {0, };
+ char select_query[DEFAULT_QUERY_SIZE] = {0, };
media_folder_s *_folder = NULL;
if (!STRING_VALID(folder_id)) {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
- memset(select_query, 0x00, sizeof(select_query));
snprintf(select_query, sizeof(select_query), SELECT_FOLDER_FROM_FOLDER, folder_id);
- ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
- media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+ ret = _content_get_result(select_query, &stmt);
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
if (sqlite3_step(stmt) == SQLITE_ROW) {
_folder = (media_folder_s*)calloc(1, sizeof(media_folder_s));
if (_folder == NULL) {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+ content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
SQLITE3_FINALIZE(stmt);
return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
}
- _folder->folder_id = g_strdup((const char *)sqlite3_column_text(stmt, 0));
-
- tmp_path = g_strdup((const char *)sqlite3_column_text(stmt, 1));
- _media_content_rollback_path(tmp_path, repl_path);
- _folder->path = g_strdup(repl_path);
- SAFE_FREE(tmp_path);
-
- _folder->name = g_strdup((const char *)sqlite3_column_text(stmt, 2));
- _folder->modified_time = (int)sqlite3_column_int(stmt, 3);
- _folder->storage_type = (int)sqlite3_column_int(stmt, 5);
- _folder->storage_uuid = g_strdup((const char *)sqlite3_column_text(stmt, 6));
- _folder->folder_order = (int)sqlite3_column_int(stmt, 7);
+ _folder->folder_id = g_strdup(folder_id);
+ _folder->path = g_strdup((const char *)sqlite3_column_text(stmt, 0));
+ _folder->name = g_strdup((const char *)sqlite3_column_text(stmt, 1));
+ _folder->storage_type = (int)sqlite3_column_int(stmt, 2);
+ _folder->storage_uuid = g_strdup((const char *)sqlite3_column_text(stmt, 3));
*folder = (media_folder_h)_folder;
}
return ret;
}
-
+#ifdef _USE_TVPD_MODE
int media_folder_update_to_db(media_folder_h folder)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_folder_update_to_db() is deprecated and will be removed from next release.");
+ content_warn("DEPRECATION WARNING: media_folder_update_to_db() is deprecated and will be removed from next release.");
media_folder_s *_folder = (media_folder_s*)folder;
- char *sql = NULL;
char repl_path[MAX_PATH_LEN] = {0, };
if ((_folder == NULL) || (_folder->folder_id == NULL)) {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
- /* Update folder order */
- sql = sqlite3_mprintf(UPDATE_FOLDER_ORDER, _folder->folder_order, _folder->folder_id);
-
- ret = _content_query_sql(sql);
- SQLITE3_SAFE_FREE(sql);
-
if (STRING_VALID(_folder->folder_id) && g_src_path) {
ret = _media_content_replace_path(_folder->path, repl_path);
if (ret != MEDIA_CONTENT_ERROR_NONE) {
ret = media_svc_rename_folder(_content_get_db_handle(), _folder->storage_uuid, g_src_path, repl_path, _content_get_uid());
SAFE_FREE(g_src_path);
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ return _content_error_capi(ret);
}
return ret;
int media_folder_set_name(media_folder_h folder, const char *name)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_folder_set_name() is deprecated and will be removed from next release.");
+ content_warn("DEPRECATION WARNING: media_folder_set_name() is deprecated and will be removed from next release.");
media_folder_s *_folder = (media_folder_s*)folder;
if (_folder != NULL && STRING_VALID(name) && name[0] != '.') {
char new_folder_path[MAX_PATH_LEN] = {0,};
char repl_path[MAX_PATH_LEN] = {0, };
- memset(repl_path, 0, sizeof(repl_path));
ret = _media_content_replace_path(_folder->path, repl_path);
- media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
+ content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
folder_path = g_path_get_dirname(repl_path);
- media_content_sec_debug("Existed Folder Path : %s", repl_path);
+ content_sec_debug("Existed Folder Path : %s", repl_path);
snprintf(new_folder_path, sizeof(new_folder_path), "%s/%s", folder_path, name);
- media_content_sec_debug("New Path : %s", new_folder_path);
+ content_sec_debug("New Path : %s", new_folder_path);
SAFE_FREE(g_src_path);
g_src_path = strdup(repl_path);
SAFE_FREE(_folder->path);
SAFE_FREE(_folder->name);
SAFE_FREE(folder_path);
- memset(repl_path, 0, sizeof(repl_path));
- ret = _media_content_rollback_path(new_folder_path, repl_path);
- media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
- _folder->path = strdup(repl_path);
- media_content_retvm_if(_folder->path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ _folder->path = strdup(new_folder_path);
+ content_retvm_if(_folder->path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
_folder->name = strdup(name);
- media_content_retvm_if(_folder->name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ content_retvm_if(_folder->name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
} else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
} else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
return ret;
}
-int media_folder_set_order(media_folder_h folder, int order)
+int media_folder_insert_to_db(const char *path)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_warn("DEPRECATION WARNING: media_folder_set_order() is deprecated and will be removed from next release.");
- media_folder_s *_folder = (media_folder_s*)folder;
+ char repl_path[MAX_PATH_LEN] = {0, };
+ char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
- if (_folder != NULL && order >= 0) {
- _folder->folder_order = order;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
+
+ ret = _media_content_replace_path(path, repl_path);
+ content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
+
+ content_retvm_if(_media_util_is_ignorable_dir(repl_path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
+
+ ret = _media_content_check_dir(repl_path);
+ content_retvm_if(ret == MEDIA_CONTENT_ERROR_PERMISSION_DENIED, ret, "Permission Denied");
+ content_retvm_if(ret == MEDIA_CONTENT_ERROR_INVALID_PARAMETER, ret, "invalid path[%s]", path);
+
+ ret = media_svc_get_storage_id(_content_get_db_handle(), repl_path, storage_id, _content_get_uid());
+ if (ret != MS_MEDIA_ERR_NONE) {
+ content_error("media_svc_get_storage_id failed : %d", ret);
+ return _content_error_capi(ret);
+ }
+
+ ret = media_svc_check_folder_exist_by_path(_content_get_db_handle(), storage_id, repl_path);
+ if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
+ content_sec_debug("media_svc_check_folder_exist_by_path : no record : %s", repl_path);
+ ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
+
+ ret = ms_user_get_storage_type(_content_get_uid(), repl_path, &storage_type);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ content_sec_error("ms_user_get_storage_type failed : %d", ret);
+ return _content_error_capi(ret);
+ }
+
+ ret = media_svc_insert_folder(_content_get_db_handle(), storage_id, storage_type, repl_path, _content_get_uid());
+ if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret == MS_MEDIA_ERR_DB_CONSTRAINT_FAIL) {
+ content_sec_error("This item is already inserted. This may be normal operation because other process already did this (%s)", repl_path);
+ ret = MEDIA_CONTENT_ERROR_NONE;
+ } else {
+ content_sec_error("media_svc_insert_folder failed : %d (%s)", ret, repl_path);
+ }
+
+ return _content_error_capi(ret);
+ }
+
+ ret = media_svc_set_folder_scan_status(storage_id, repl_path, MEDIA_DIR_SCAN_DONE, _content_get_uid());
+ if (ret != MS_MEDIA_ERR_NONE) {
+ content_sec_error("ms_set_folder_scan_status failed : %d", ret);
+ return _content_error_capi(ret);
+ }
+ } else if (ret != MS_MEDIA_ERR_NONE) {
+ content_sec_error("media_svc_check_folder_exist_by_path failed : %d (%s)", ret, repl_path);
+ return _content_error_capi(ret);
}
return ret;
}
-#ifdef _USE_TVPD_MODE
+
int media_folder_get_scan_status(const char *storage_uuid, char* path, media_folder_scan_status_e *scan_status)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
if (STRING_VALID(storage_uuid) && STRING_VALID(path)) {
ret = media_svc_get_folder_scan_status(_content_get_db_handle(), storage_uuid, path, &status);
if (ret != MS_MEDIA_ERR_NONE) {
- media_content_error("media_svc_get_folder_scan_status failed");
- ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ content_error("media_svc_get_folder_scan_status failed");
+ ret = _content_error_capi(ret);
} else {
*scan_status = status;
}
} else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+
+ return ret;
+}
+
+int media_folder_reset_scan_status(const char *storage_uuid, const char* path)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ if (STRING_VALID(path)) {
+ ret = media_svc_set_folder_validity(FALSE, storage_uuid, path, 0, TRUE, _content_get_uid());
+ if (ret != MS_MEDIA_ERR_NONE) {
+ content_error("set folder validity failed");
+ ret = _content_error_capi(ret);
+ return ret;
+ }
+
+ ret = media_svc_set_folder_scan_status(storage_uuid, path, MEDIA_DIR_SCAN_NONE, _content_get_uid());
+ if (ret != MS_MEDIA_ERR_NONE) {
+ content_error("media_folder_reset_scan_status failed");
+ ret = _content_error_capi(ret);
+ }
+ } else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}