#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);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(folder_count);
+
+#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);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(callback);
+
+#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;
- 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);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(STRING_VALID(folder_id));
+ content_retip_if_fail(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
return ret;
}
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- if((callback != NULL) && STRING_VALID(folder_id))
- {
- ret = _media_db_get_group_item(folder_id, filter, callback, user_data, MEDIA_GROUP_FOLDER);
- }
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(STRING_VALID(folder_id));
+ content_retip_if_fail(callback);
+
+#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
return ret;
}
int media_folder_destroy(media_folder_h folder)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_folder_s *_folder = (media_folder_s*)folder;
- if(_folder)
- {
- SAFE_FREE(_folder->path);
- SAFE_FREE(_folder->name);
- SAFE_FREE(_folder->folder_id);
- SAFE_FREE(_folder->parent_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);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
+ content_retip_if_fail(folder);
+
+ g_free(_folder->path);
+ g_free(_folder->name);
+ g_free(_folder->folder_id);
+ g_free(_folder->storage_uuid);
+ g_free(_folder);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int media_folder_clone(media_folder_h *dst, media_folder_h src)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_folder_s *_src = (media_folder_s*)src;
- 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");
-
- 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);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- if(STRING_VALID(_src->parent_folder_id))
- {
- _dst->parent_folder_id = strdup(_src->parent_folder_id);
- if(_dst->parent_folder_id == NULL)
- {
- media_folder_destroy((media_folder_h)_dst);
- media_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);
- 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);
- 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);
- media_folder_destroy((media_folder_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
+ content_retip_if_fail(dst);
+ content_retip_if_fail(src);
- _dst->storage_type = _src->storage_type;
- _dst->modified_time = _src->modified_time;
- _dst->folder_order= _src->folder_order;
+ media_folder_s *_dst = g_new0(media_folder_s, 1);
- *dst = (media_folder_h)_dst;
+ _dst->folder_id = g_strdup(_src->folder_id);
+ _dst->name = g_strdup(_src->name);
+ _dst->path = g_strdup(_src->path);
+ _dst->storage_uuid = g_strdup(_src->storage_uuid);
+ _dst->storage_type = _src->storage_type;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ *dst = (media_folder_h)_dst;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int media_folder_get_folder_id(media_folder_h folder, char **folder_id)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_folder_s *_folder = (media_folder_s*)folder;
- 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");
- }
- 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;
-}
+ content_retip_if_fail(folder);
+ content_retip_if_fail(folder_id);
-int media_folder_get_parent_folder_id(media_folder_h folder, char **parent_folder_id)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_folder_s *_folder = (media_folder_s*)folder;
-
- if(_folder)
- {
- if(STRING_VALID(_folder->parent_folder_id))
- {
- *parent_folder_id = strdup(_folder->parent_folder_id);
- media_content_retvm_if(*parent_folder_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
- else
- {
- *parent_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;
- }
+ *folder_id = g_strdup(_folder->folder_id);
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int media_folder_get_path(media_folder_h folder, char **path)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_folder_s *_folder = (media_folder_s*)folder;
- 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");
- }
- else
- {
- *path = 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;
- }
+ content_retip_if_fail(folder);
+ content_retip_if_fail(path);
- return ret;
+ *path = g_strdup(_folder->path);
+ return MEDIA_CONTENT_ERROR_NONE;
}
int media_folder_get_name(media_folder_h folder, char **name)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
media_folder_s *_folder = (media_folder_s*)folder;
- 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");
- }
- else
- {
- *name = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
+ content_retip_if_fail(folder);
+ content_retip_if_fail(name);
- }
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ *name = g_strdup(_folder->name);
- return ret;
-}
-
-int media_folder_get_modified_time(media_folder_h folder, time_t* time)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- 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);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
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);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(folder);
+ content_retip_if_fail(storage_type);
- return ret;
+ *storage_type = _folder->storage_type;
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
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");
- }
- else
- {
- *storage_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_order(media_folder_h folder, int *order)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_folder_s *_folder = (media_folder_s*)folder;
+ content_retip_if_fail(folder);
+ content_retip_if_fail(storage_id);
- 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;
- }
+ *storage_id = g_strdup(_folder->storage_uuid);
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
-
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];
-
- if(!STRING_VALID(folder_id))
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ char select_query[DEFAULT_QUERY_SIZE] = {0, };
+ media_folder_s *_folder = NULL;
- memset(select_query, 0x00, sizeof(select_query));
+ content_retip_if_fail(STRING_VALID(folder_id));
+ content_retip_if_fail(folder);
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);
- media_folder_s *_folder = NULL;
+ if (sqlite3_step(stmt) == SQLITE_ROW) {
+ _folder = g_new0(media_folder_s, 1);
- while(sqlite3_step(stmt) == SQLITE_ROW)
- {
- if(_folder)
- media_folder_destroy((media_folder_h)_folder);
-
- _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);
- SQLITE3_FINALIZE(stmt);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- media_content_error("folder handle %x", _folder);
-
- _folder->folder_id = g_strdup((const char *)sqlite3_column_text(stmt, 0));
- _folder->path = g_strdup((const char *)sqlite3_column_text(stmt, 1));
- _folder->name = g_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;
}
return ret;
}
-
+#ifdef _USE_TVPD_MODE
int media_folder_update_to_db(media_folder_h folder)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
+ 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;
- if((_folder == NULL) || (_folder->folder_id == NULL))
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(folder);
+ content_retip_if_fail(STRING_VALID(_folder->folder_id));
+
+ if (!g_src_path)
+ return ret;
+
+ ret = media_svc_rename_folder(_content_get_db_handle(), _folder->storage_uuid, g_src_path, _folder->path, _content_get_uid());
+ SAFE_FREE(g_src_path);
+
+ return _content_error_capi(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;
+ char *parent_folder_path = NULL;
- /* Update folder order */
- sql = sqlite3_mprintf(UPDATE_FOLDER_ORDER, _folder->folder_order, _folder->folder_id);
+ content_retip_if_fail(folder);
+ content_retip_if_fail(STRING_VALID(name));
+ content_retip_if_fail(name[0] != '.');
+ content_retip_if_fail(STRING_VALID(_folder->path));
+ content_retip_if_fail(STRING_VALID(_folder->name));
- ret = _content_query_sql(sql);
- SQLITE3_SAFE_FREE(sql);
+ // Change name..
+ g_free(_folder->name);
+ _folder->name = g_strdup(name);
- if(STRING_VALID(_folder->folder_id) && g_src_path)
- {
- char *name_pinyin = NULL;
- bool pinyin_support = FALSE;
+ // Change path..
+ g_free(g_src_path);
+ g_src_path = g_strdup(_folder->path);
+ g_free(_folder->path);
- /* Set modified time */
- time_t date;
- time(&date);
- _folder->modified_time = date;
+ parent_folder_path = g_path_get_dirname(g_src_path);
+ _folder->path = g_strdup_printf("%s/%s", parent_folder_path, name);
+ g_free(parent_folder_path);
- /*Update Pinyin If Support Pinyin*/
- media_svc_check_pinyin_support(&pinyin_support);
- if(pinyin_support)
- media_svc_get_pinyin(_content_get_db_handle(), _folder->name, &name_pinyin);
+ content_sec_debug("Old[%s] New[%s]", g_src_path, _folder->path);
- sql = sqlite3_mprintf("UPDATE %Q SET path='%q', name='%q', modified_time=%d, name_pinyin='%q' WHERE folder_uuid=%Q",
- DB_TABLE_FOLDER, _folder->path, _folder->name, _folder->modified_time, name_pinyin, _folder->folder_id);
+ return ret;
+}
- ret = _content_query_sql(sql);
- SQLITE3_SAFE_FREE(sql);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- SAFE_FREE(g_src_path);
- return ret;
- }
+int media_folder_insert_to_db(const char *path)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
- /* Update all folder record's path, which are matched by old parent path */
- char *update_folder_path_sql = NULL;
- char src_path_slash[MAX_QUERY_SIZE + 1] = {0, };
- char dst_path_slash[MAX_QUERY_SIZE + 1] = {0, };
+ content_retip_if_fail(STRING_VALID(path));
- snprintf(src_path_slash, sizeof(src_path_slash), "%s/", g_src_path);
- snprintf(dst_path_slash, sizeof(dst_path_slash), "%s/", _folder->path);
+ content_retvm_if(_media_util_is_ignorable_dir(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
- update_folder_path_sql = sqlite3_mprintf("UPDATE folder SET path = REPLACE( path, '%q', '%q');", src_path_slash, dst_path_slash);
+ ret = _media_content_check_dir(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 = _content_query_sql(update_folder_path_sql);
- SQLITE3_SAFE_FREE(update_folder_path_sql);
- if (ret != MEDIA_CONTENT_ERROR_NONE) {
- SAFE_FREE(g_src_path);
- return ret;
+ ret = media_svc_get_storage_id(_content_get_db_handle(), 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, path);
+ if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
+ content_sec_debug("media_svc_check_folder_exist_by_path : no record : %s", path);
+ ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
+
+ ret = ms_user_get_storage_type(_content_get_uid(), 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_rename_folder(_content_get_db_handle(), _folder->storage_uuid, g_src_path, _folder->path, tzplatform_getuid(TZ_USER_NAME));
- SAFE_FREE(g_src_path);
+ ret = media_svc_insert_folder(_content_get_db_handle(), storage_id, storage_type, path, false, _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)", path);
+ ret = MEDIA_CONTENT_ERROR_NONE;
+ } else {
+ content_sec_error("media_svc_insert_folder failed : %d (%s)", ret, path);
+ }
- return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ return _content_error_capi(ret);
+ }
+
+ ret = media_svc_set_folder_scan_status(storage_id, path, MEDIA_DIR_SCAN_DONE, false, _content_get_uid());
+ if (ret != MS_MEDIA_ERR_NONE) {
+ content_sec_error("media_svc_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, path);
+ return _content_error_capi(ret);
}
return ret;
}
-int media_folder_set_name(media_folder_h folder, const char *name)
+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;
- media_folder_s *_folder = (media_folder_s*)folder;
+ int status = MEDIA_DIR_SCAN_NONE;
- if(_folder != NULL && STRING_VALID(name))
- {
- if (STRING_VALID(_folder->path) && STRING_VALID(_folder->name)) {
- char *folder_path = NULL;
- char new_folder_path[MAX_QUERY_SIZE] = {0,};
- bool ignore_dir = FALSE;
-
- folder_path = g_path_get_dirname(_folder->path);
- media_content_sec_debug("Existed Folder Path : %s", _folder->path);
- snprintf(new_folder_path, sizeof(new_folder_path), "%s/%s", folder_path, name);
- media_content_sec_debug("New Path : %s", new_folder_path);
-
- ret = _media_util_check_ignore_dir(new_folder_path, &ignore_dir);
- if (ignore_dir == TRUE) {
- media_content_error("Invalid folder path");
- SAFE_FREE(folder_path);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- SAFE_FREE(g_src_path);
- g_src_path = strdup(_folder->path);
-
- SAFE_FREE(_folder->path);
- SAFE_FREE(_folder->name);
- SAFE_FREE(folder_path);
- _folder->path = strdup(new_folder_path);
- media_content_retvm_if(_folder->path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- }
+ content_retip_if_fail(STRING_VALID(storage_uuid));
+ content_retip_if_fail(STRING_VALID(path));
+ content_retip_if_fail(scan_status);
- _folder->name = strdup(name);
- media_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);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+ 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;
}
return ret;
}
-int media_folder_set_order(media_folder_h folder, int order)
+int media_folder_reset_scan_status(const char *storage_uuid, const char* path)
{
int ret = MEDIA_CONTENT_ERROR_NONE;
- media_folder_s *_folder = (media_folder_s*)folder;
- if(_folder != NULL && order >= 0)
- {
- _folder->folder_order = order;
+ content_retip_if_fail(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");
+ return _content_error_capi(ret);
}
- else
- {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+
+ ret = media_svc_set_folder_scan_status(storage_uuid, path, MEDIA_DIR_SCAN_NONE, false, _content_get_uid());
+ if (ret != MS_MEDIA_ERR_NONE) {
+ content_error("media_folder_reset_scan_status failed");
+ return _content_error_capi(ret);
}
return ret;
}
+#endif