#include <media_info_private.h>
#include <media_util_private.h>
+#ifdef _USE_TVPD_MODE
+#include <media_content_type_product.h>
+#endif
static char *g_src_path = NULL;
int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e* storage_type)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_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) {
int media_folder_get_storage_id(media_folder_h folder, char **storage_id)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
+ media_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) {
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, };
media_folder_s *_folder = NULL;
if (!STRING_VALID(folder_id)) {
}
_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->path = g_strdup((const char *)sqlite3_column_text(stmt, 1));
_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);
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);
+ _folder->path = strdup(new_folder_path);
media_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");
return ret;
}
#ifdef _USE_TVPD_MODE
+int media_folder_insert_to_db(const char *path)
+{
+ char repl_path[MAX_PATH_LEN] = {0, };
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
+ bool ignore_dir = FALSE;
+
+ media_content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
+ memset(repl_path, 0, sizeof(repl_path));
+ ret = _media_content_replace_path(path, repl_path);
+ media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
+
+ ret = _media_util_check_ignore_dir(repl_path, &ignore_dir);
+ media_content_retvm_if(ignore_dir, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
+
+ ret = _media_content_check_dir(repl_path);
+ media_content_retvm_if(ret == MEDIA_CONTENT_ERROR_PERMISSION_DENIED, ret, "Permission Denied");
+ media_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) {
+ media_content_error("media_svc_get_storage_id failed : %d", ret);
+ return _content_error_capi(MEDIA_CONTENT_TYPE, 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) {
+ media_content_sec_debug("media_svc_check_folder_exist_by_path : no record : %s", repl_path);
+ media_svc_storage_type_e storage_type = 0;
+
+ ret = media_svc_get_storage_type(repl_path, &storage_type, _content_get_uid());
+ if (ret != MS_MEDIA_ERR_NONE) {
+ media_content_sec_error("media_svc_get_storage_type failed : %d", ret);
+ return _content_error_capi(MEDIA_CONTENT_TYPE, 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) {
+ media_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 {
+ media_content_sec_error("media_svc_insert_folder failed : %d (%s)", ret, repl_path);
+ }
+
+ return _content_error_capi(MEDIA_CONTENT_TYPE, 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) {
+ media_content_sec_error("ms_set_folder_scan_status failed : %d", ret);
+ return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ }
+ } else if (ret != MS_MEDIA_ERR_NONE) {
+ media_content_sec_error("media_svc_check_folder_exist_by_path failed : %d (%s)", ret, repl_path);
+ return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ }
+
+ return ret;
+}
+
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;