*/
int media_storage_get_scan_status(const char *storage_uuid, media_storage_scan_status_e *scan_status);
+/**
+ * @brief Iterates through media storage from the media database.
+ * @details This function gets all media storage handles meeting the given @a filter.
+ * The @a callback function will be invoked for every retrieved media storage.
+ * If @c NULL is passed to the @a filter, then no filtering is applied.
+ *
+ * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
+ *
+ * @param[in] filter The handle to the media filter
+ * @param[in] callback The callback function to be invoked
+ * @param[in] user_data The user data to be passed to the callback function
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB Operation failed
+ * @retval #MEDIA_CONTENT_ERROR_DB_BUSY DB Operation busy
+ *
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @post This function invokes media_storage_destroy().
+ *
+ * @see media_content_connect()
+ * @see media_storage_destroy()
+ */
+int media_storage_foreach_storage_from_db(filter_h filter, media_storage_cb callback, void *user_data);
+
+/**
+ * @brief Destroys media storage handle.
+ * @details The function frees all resources related to the media storage handle. This handle
+ * can no longer be used to perform any operations. New media storage handle has to
+ * be created before the next usage.
+ *
+ * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
+ *
+ * @param[in] storage The media storage handle
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @pre Get copy of media_storage_h handle by calling media_storage_clone().
+ *
+ * @see media_storage_clone()
+ */
+int media_storage_destroy(media_storage_h storage);
+/**
+ * @brief Clones the media storage handle.
+ *
+ * @details This function copies the media storage handle from a source to the destination.
+ * There is no media_storage_create() function. The media_storage_h is created internally and
+ * available through media storage foreach function such as media_storage_foreach_storage_from_db().
+ * To use this handle outside of these foreach functions, use this function.
+ *
+ * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
+ *
+ * @remarks The @a dst should be released using media_storage_destroy().
+ *
+ * @param[out] dst The destination handle to the media storage
+ * @param[in] src The source handle to the media storage
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @see media_storage_destroy()
+ * @see media_storage_foreach_storage_from_db()
+ * @see media_storage_get_storage_info_from_db()
+ */
+int media_storage_clone(media_storage_h *dst, media_storage_h src);
+
+/**
+ * @brief Gets the storage id of media storage.
+ * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
+ *
+ * @remarks The @a storage_id should be released using free().
+ *
+ * @param[in] storage The media storage handle
+ * @param[out] storage_id The ID of the media storage
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int media_storage_get_id(media_storage_h storage, char **storage_id);
+
+/**
+ * @brief Gets the storage path of media storage.
+ * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
+ *
+ * @remarks The @a storage_path should be released using free().
+ *
+ * @param[in] storage The media storage handle
+ * @param[out] storage_path The storage path of the media storage
+ *
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ *
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int media_storage_get_path(media_storage_h storage, char **storage_path);
#ifdef __cplusplus
}
#endif /* __cplusplus */
MEDIA_GROUP_MAX,
} media_group_e;
+typedef struct {
+ char *storage_id;
+ char *storage_path;
+ int storage_type;
+} media_storage_s;
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_STORAGE_MODULE
+ * @deprecated Deprecated since 5.0.
+ * @brief The structure type for the Media storage handle.
+ * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
+ */
+typedef void *media_storage_h;
+
/**
* @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE
* @brief The structure type for the Media info handle.
typedef bool (*media_group_cb)(const char *group_name, void *user_data);
/**
+ * @ingroup CAPI_CONTENT_MEDIA_STORAGE_MODULE
+ * @brief Called for every storage in the obtained list of storages.
+ * @details Iterates over a media storage list.
+ *
+ * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
+ *
+ * @remarks You should not destroy @a storage returned by this function. \n
+ * The callback is called in the main loop.
+ *
+ * @param[in] storage The handle of the media storage
+ * @param[in] user_data The user data passed from the foreach function
+ *
+ * @return @c true to continue with the next iteration of the loop,
+ * otherwise @c false to break out of the loop
+ *
+ * @pre media_storage_foreach_storage_from_db() will invoke this function.
+ * @see media_storage_foreach_storage_from_db()
+ */
+typedef bool (*media_storage_cb)(media_storage_h storage, void *user_data);
+
+/**
* @ingroup CAPI_CONTENT_MEDIA_FACE_MODULE
* @brief Called for every face in the obtained list of face.
* @details Iterates over a media face list.
int _media_db_get_pvr_group_item(const char *group_name, filter_h filter, media_group_e group, media_pvr_cb callback, void *user_data);
int _media_db_get_uhd(filter_h filter, media_uhd_cb callback, void *user_data);
void _media_uhd_item_get_detail(sqlite3_stmt* stmt, media_uhd_h uhd);
-
+int _media_db_get_storage(filter_h filter, media_storage_cb callback, void *user_data);
int _media_filter_build_condition(bool is_full, const char *condition, media_content_collation_e collate_type, char **result);
int _media_filter_build_option(filter_h filter, char **result);
return ret;
}
+
+int _media_db_get_storage(filter_h filter, media_storage_cb callback, void *user_data)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ char *condition_query = NULL;
+ char *option_query = NULL;
+ sqlite3_stmt *stmt = NULL;
+
+ ret = __media_db_make_query(filter, &condition_query, &option_query);
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+ ret = _content_query_prepare(SELECT_STORAGE_LIST, condition_query, option_query, &stmt);
+ g_free(condition_query);
+ g_free(option_query);
+ content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
+ media_storage_s *_storage = g_new0(media_storage_s, 1);
+
+ _storage->storage_id = g_strdup((const char *)sqlite3_column_text(stmt, 0));
+ _storage->storage_path = g_strdup((const char *)sqlite3_column_text(stmt, 1));
+ _storage->storage_type = sqlite3_column_int(stmt, 2);
+
+ if (callback((media_storage_h)_storage, user_data) == false) {
+ media_storage_destroy((media_storage_h) _storage);
+ break;
+ }
+
+ media_storage_destroy((media_storage_h) _storage);
+ }
+
+ SQLITE3_FINALIZE(stmt);
+
+ return ret;
+}
#endif
return ret;
}
+
+int media_storage_foreach_storage_from_db(filter_h filter, media_storage_cb callback, void *user_data)
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+
+ content_retip_if_fail(callback);
+ g_mutex_lock(_content_get_db_mutex());
+ ret = _media_db_get_storage(filter, callback, user_data);
+ g_mutex_unlock(_content_get_db_mutex());
+
+ return ret;
+}
+
+int media_storage_destroy(media_storage_h storage)
+{
+ media_storage_s *_storage = (media_storage_s*)storage;
+
+ content_retip_if_fail(storage);
+
+ g_free(_storage->storage_id);
+ g_free(_storage->storage_path);
+ g_free(_storage);
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int media_storage_clone(media_storage_h *dst, media_storage_h src)
+{
+ media_storage_s *_src = (media_storage_s*)src;
+
+ content_retip_if_fail(dst);
+ content_retip_if_fail(src);
+
+ media_storage_s *_dst = g_new0(media_storage_s, 1);
+
+ _dst->storage_id = g_strdup(_src->storage_id);
+ _dst->storage_path = g_strdup(_src->storage_path);
+ _dst->storage_type = _src->storage_type;
+
+ *dst = (media_storage_h)_dst;
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int media_storage_get_id(media_storage_h storage, char **storage_id)
+{
+ media_storage_s *_storage = (media_storage_s*)storage;
+
+ content_retip_if_fail(storage);
+ content_retip_if_fail(storage_id);
+
+ *storage_id = g_strdup(_storage->storage_id);
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int media_storage_get_path(media_storage_h storage, char **storage_path)
+{
+ media_storage_s *_storage = (media_storage_s*)storage;
+
+ content_retip_if_fail(storage);
+ content_retip_if_fail(storage_path);
+
+ *storage_path = g_strdup(_storage->storage_path);
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
#endif