*/
-#include <media_content.h>
#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;
-
-static char *__media_folder_get_update_folder_sql(media_folder_h folder);
-
-static char *__media_folder_get_update_folder_sql(media_folder_h folder)
-{
- media_folder_s *_folder = (media_folder_s*)folder;
- char *return_sql = NULL;
-
- return_sql = sqlite3_mprintf("%q='%q', %q='%q', %q=%d ",
- DB_FIELD_FOLDER_PATH, _folder->path,
- DB_FIELD_FOLDER_NAME, _folder->name,
- DB_FIELD_FOLDER_MODIFIED_TIME, _folder->modified_time);
-
- return return_sql;
-}
+#endif
int media_folder_get_folder_count_from_db(filter_h filter, int *folder_count)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_debug_func();
-
- if(!folder_count)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ if (!folder_count) {
+ 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;
- media_content_debug_func();
-
- if(callback == NULL)
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ if (callback == NULL) {
+ 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_folder(filter, callback, user_data);
+#ifdef _USE_TVPD_MODE
+ g_mutex_unlock(_content_get_db_mutex());
+#endif
+
return ret;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_debug_func();
+ if (STRING_VALID(folder_id) && media_count) {
+#ifdef _USE_TVPD_MODE
+ g_mutex_lock(_content_get_db_mutex());
+#endif
- if(STRING_VALID(folder_id) && media_count)
- {
ret = _media_db_get_group_item_count(folder_id, filter, MEDIA_GROUP_FOLDER, media_count);
- }
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+
+#ifdef _USE_TVPD_MODE
+ g_mutex_unlock(_content_get_db_mutex());
+#endif
+
+ } else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_content_debug_func();
+ if ((callback != NULL) && STRING_VALID(folder_id)) {
+#ifdef _USE_TVPD_MODE
+ g_mutex_lock(_content_get_db_mutex());
+#endif
- if((callback != NULL) && STRING_VALID(folder_id))
- {
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 {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+
+ return ret;
+}
+
+#ifdef _USE_SENIOR_MODE
+int media_folder_foreach_media_from_db_by_union_select(const char* folder_id, filter_h filter1, filter_h filter2, media_info_cb callback, void* user_data)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ if ((callback != NULL) && STRING_VALID(folder_id)) {
+ ret = _media_db_get_group_item_by_union_select(folder_id, filter1, filter2, callback, user_data);
+ } else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
return ret;
}
+#endif
int media_folder_destroy(media_folder_h folder)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
media_folder_s *_folder = (media_folder_s*)folder;
- if(_folder)
- {
+ if (_folder) {
SAFE_FREE(_folder->path);
SAFE_FREE(_folder->name);
SAFE_FREE(_folder->folder_id);
+ SAFE_FREE(_folder->storage_uuid);
SAFE_FREE(_folder);
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ } else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_folder_s *_src = (media_folder_s*)src;
- if(_src != NULL)
- {
+ if (_src != NULL) {
media_folder_s *_dst = (media_folder_s*)calloc(1, sizeof(media_folder_s));
- if(_dst == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
+ content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- if(STRING_VALID(_src->folder_id))
- {
+ if (STRING_VALID(_src->folder_id)) {
_dst->folder_id = strdup(_src->folder_id);
- if(_dst->folder_id == NULL)
- {
+ 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;
}
}
- _dst->storage_type = _src->storage_type;
-
- if(STRING_VALID(_src->name))
- {
+ 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);
+ if (_dst->name == NULL) {
+ 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))
- {
+ 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);
+ if (_dst->path == NULL) {
+ 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) {
+ 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 = (media_folder_h)_dst;
ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ } else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int ret = MEDIA_CONTENT_ERROR_NONE;
media_folder_s *_folder = (media_folder_s*)folder;
- if(_folder)
- {
- if(STRING_VALID(_folder->folder_id))
- {
+ if (_folder) {
+ if (STRING_VALID(_folder->folder_id)) {
*folder_id = strdup(_folder->folder_id);
- if(*folder_id == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ 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);
+ } else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
media_folder_s *_folder = (media_folder_s*)folder;
- if(_folder)
- {
- if(STRING_VALID(_folder->path))
- {
+
+ if (_folder) {
+ if (STRING_VALID(_folder->path)) {
*path = strdup(_folder->path);
- if(*path == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ 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);
+ } else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
media_folder_s *_folder = (media_folder_s*)folder;
- if(_folder)
- {
- if(STRING_VALID(_folder->name))
- {
+
+ if (_folder) {
+ if (STRING_VALID(_folder->name)) {
*name = strdup(_folder->name);
- if(*name == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
+ 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);
+ } else {
+ 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 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)
- {
- *time = _folder->modified_time;
+
+ 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);
+ } else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
return ret;
}
-int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e* storage_type)
+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)
- {
- *storage_type = _folder->storage_type;
+
+ if (_folder) {
+ if (STRING_VALID(_folder->storage_uuid)) {
+ *storage_id = strdup(_folder->storage_uuid);
+ 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);
+
+ } else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
}
int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folder)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- int ret_view = MEDIA_CONTENT_ERROR_NONE;
sqlite3_stmt *stmt = NULL;
- char select_query[DEFAULT_QUERY_SIZE];
+ 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);
+ if (!STRING_VALID(folder_id)) {
+ 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);
- while(sqlite3_step(stmt) == SQLITE_ROW)
- {
- media_folder_s *_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);
+ if (sqlite3_step(stmt) == SQLITE_ROW) {
+ _folder = (media_folder_s*)calloc(1, sizeof(media_folder_s));
+ if (_folder == NULL) {
+ content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
SQLITE3_FINALIZE(stmt);
return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
}
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0)))
- _folder->folder_id = strdup((const char *)sqlite3_column_text(stmt, 0));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
- _folder->path = strdup((const char *)sqlite3_column_text(stmt, 1));
-
- if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2)))
- _folder->name = strdup((const char *)sqlite3_column_text(stmt, 2));
+ _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;
}
SQLITE3_FINALIZE(stmt);
+
return ret;
}
-
+#ifdef _USE_TVPD_MODE
int media_folder_update_to_db(media_folder_h folder)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- int len = 0;
+ 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 repl_path[MAX_PATH_LEN] = {0, };
- char sql[MAX_QUERY_SIZE];
- memset(sql, '\0', sizeof(sql));
- char *set_sql = NULL;
- char *where_sql = NULL;
-
- if((_folder != NULL) && STRING_VALID(_folder->folder_id) && g_src_path)
- {
- /* Set modified time */
- time_t date;
- time(&date);
- _folder->modified_time = date;
-
- set_sql = __media_folder_get_update_folder_sql((media_folder_h)_folder);
- if(set_sql == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- where_sql = sqlite3_mprintf("folder_uuid='%q'", _folder->folder_id);
+ if ((_folder == NULL) || (_folder->folder_id == NULL)) {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
- len = snprintf(sql, sizeof(sql), UPDATE_SQL, DB_TABLE_FOLDER, set_sql, where_sql);
- if (len > 0) {
- sql[len] = '\0';
- } else {
- media_content_error("snprintf failed");
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ if (STRING_VALID(_folder->folder_id) && g_src_path) {
+ ret = _media_content_replace_path(_folder->path, repl_path);
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ SAFE_FREE(g_src_path);
+ return ret;
}
+ 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);
- ret = _content_query_sql(sql);
-
- sqlite3_free(set_sql);
- sqlite3_free(where_sql);
-
- /* Do folder rename operation using libmedia-service */
- ret = media_svc_rename_folder(_content_get_db_handle(), g_src_path, _folder->path, tzplatform_getuid(TZ_USER_NAME));
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
- }
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ 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;
+ 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))
- {
+ if (_folder != NULL && STRING_VALID(name) && name[0] != '.') {
if (STRING_VALID(_folder->path) && STRING_VALID(_folder->name)) {
char *folder_path = NULL;
- char new_folder_path[MAX_QUERY_SIZE] = {0,};
+ char new_folder_path[MAX_PATH_LEN] = {0,};
+ char repl_path[MAX_PATH_LEN] = {0, };
- folder_path = g_path_get_dirname(_folder->path);
- media_content_debug("Existed Folder Path : %s", _folder->path);
- snprintf(new_folder_path, sizeof(new_folder_path), "%s/%s", folder_path, name);
- media_content_debug("New Path : %s", new_folder_path);
+ ret = _media_content_replace_path(_folder->path, repl_path);
+ content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
+
+ folder_path = g_path_get_dirname(repl_path);
+ content_sec_debug("Existed Folder Path : %s", repl_path);
+ snprintf(new_folder_path, sizeof(new_folder_path), "%s/%s", folder_path, name);
+ content_sec_debug("New Path : %s", new_folder_path);
SAFE_FREE(g_src_path);
- g_src_path = strdup(_folder->path);
+ g_src_path = strdup(repl_path);
SAFE_FREE(_folder->path);
SAFE_FREE(_folder->name);
+ SAFE_FREE(folder_path);
+
_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);
+ content_retvm_if(_folder->name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+ } else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+ ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ }
- if(_folder->path == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+ return ret;
+}
+
+int media_folder_insert_to_db(const char *path)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ char repl_path[MAX_PATH_LEN] = {0, };
+ char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
+
+ 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);
}
- _folder->name = strdup(name);
- if(_folder->name == NULL)
- {
- media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+ 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;
+}
+
+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;
+ int status = MEDIA_DIR_SCAN_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) {
+ content_error("media_svc_get_folder_scan_status failed");
+ ret = _content_error_capi(ret);
+ } else {
+ *scan_status = status;
}
+ } else {
+ 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);
+
+ 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;
}
return ret;
}
+#endif