UCL_DECLARE_REF_ALIASES(CustomMediaAlbum);
+ /**
+ * @brief Implements IMediaAlbum
+ */
class CustomMediaAlbum final : public IMediaAlbum {
public:
+
+ /**
+ * @brief Contsructor
+ */
CustomMediaAlbum();
+
+ /**
+ * @brief Desructor
+ */
virtual ~CustomMediaAlbum();
+ /**
+ * @brief Adds media item to album
+ * @param[in] item Shared reference to MediaItem object
+ */
void addItem(MediaItemSRef item);
+ /**
+ * @brief Gets album contents
+ * @return Vector of media items
+ */
const MediaItems &getItems() const;
// IMediaAlbum //
+ /**
+ * @brief Adds change handler
+ * @param[in] handler Change handler
+ */
virtual void addChangeHandler(NotiHandler handler) final override;
+
+ /**
+ * @brief Deletes change handler
+ * @param[in] handler Change handler
+ */
virtual void delChangeHandler(
NotiHandler::CDRef handler) final override;
+ /**
+ * @brief Calls a provided callback function once for each MediaAlbum entry
+ * @param[in] cb Callback function
+ * @return RES_OK on success, otherwise an error code on failure
+ */
virtual ucl::Result forEachMedia(EachCb cb) const final override;
+
+ /**
+ * @brief Gets number of items in album
+ * @param[out] count Media count
+ * @return RES_OK on success, otherwise an error code on failure
+ */
virtual ucl::Result getMediaCount(int &count) const final override;
+ /**
+ * @brief Defragments media album contents
+ */
virtual void defragment() final override;
private:
UCL_DECLARE_REF_ALIASES(Gallery);
+ /**
+ * @brief Represents application main model class
+ */
class Gallery final : public ucl::NonCopyable {
public:
+
+ /**
+ * @brief Creates new instance of Gallery
+ * @return Shared reference to Gallery object
+ */
static GallerySRef newInstance();
+
+ /**
+ * @brief Destructor
+ */
~Gallery();
+ /**
+ * @brief Gets media album
+ * @return Shared reference to media album object
+ */
IMediaAlbumSRef getAlbum();
private:
UCL_DECLARE_REF_ALIASES(IJob);
+ /**
+ * @brief Represents abstract job
+ */
class IJob : protected ucl::NonCopyable {
public:
+
+ /**
+ * @brief Gets result
+ * @return Result. @see ucl::Result
+ */
virtual ucl::Result getResult() const = 0;
+
+ /**
+ * @brief Check if job can be canceled
+ * @return true if cancelable, false if not cancelable
+ */
virtual bool isCancelable() const = 0;
+
+ /**
+ * @brief Cancels job
+ * @return RES_OK on success, otherwise an error code
+ */
virtual ucl::Result cancel() = 0;
};
}
UCL_DECLARE_REF_ALIASES(IMediaAlbum);
+ /**
+ * @brief Represents media album interface
+ */
class IMediaAlbum : protected ucl::NonCopyable {
public:
+ /**
+ * @brief Callback for each item in album type
+ */
using EachCb = ucl::Delegate<bool(MediaItemSRef media)>;
public:
+
+ /**
+ * @brief Adds change handler
+ * @param[in] handler Change handler
+ */
virtual void addChangeHandler(NotiHandler handler) = 0;
+
+ /**
+ * @brief Removes change handler
+ * @param[in] handler Change handler
+ */
virtual void delChangeHandler(NotiHandler::CDRef handler) = 0;
+ /**
+ * @brief Calls a provided callback function once for each MediaAlbum entry
+ * @param[in] cb Callback function
+ * @return RES_OK on success, otherwise an error code on failure
+ */
virtual ucl::Result forEachMedia(EachCb cb) const = 0;
+
+ /**
+ * @brief Gets number of items in album
+ * @param[out] count Media count
+ * @return RES_OK on success, otherwise an error code on failure
+ */
virtual ucl::Result getMediaCount(int &count) const = 0;
+ /**
+ * @brief Defragments media album contents
+ */
virtual void defragment() = 0;
};
// Non-member functions //
+ /**
+ * @brief Checks if album is empty
+ * @return true if album is empty, false if album is filled
+ */
bool isEmpty(const IMediaAlbum &album);
}
using MediaItems = std::vector<MediaItemSRef>;
+ /**
+ * @brief Represents media item
+ */
class MediaItem : protected ucl::NonCopyable {
public:
+ /**
+ * @brief Callback for thumbnail creation type
+ */
using ThumbnailPathGetCb =
ucl::WeakDelegate<void(ucl::Result, const std::string &path)>;
+ /**
+ * @brief Provides removal option
+ */
class Remover;
+
+ /**
+ * @brief Builder for the job that removes file
+ */
class RemoverBuilder final {
public:
+ /**
+ * @brief Stages items for delition
+ * @param[in] items Vector of items
+ * @return RemoverBuilder object
+ */
RemoverBuilder &setItems(MediaItems items);
+
+ /**
+ * @brief Creates job
+ * @param[in] onComplete Completion handler
+ * @return Shared reference to IJob
+ */
IJobSRef build(const NotiHandler &onComplete) const;
private:
ucl::SharedRef<MediaItems> m_items;
};
+ /**
+ * @brief Provides saving option
+ */
class Saver;
+
+ /**
+ * @brief Builder for the job that saves file on the device
+ */
class SaverBuilder final {
public:
+ /**
+ * @brief Sets item to save
+ * @param[in] item Shared reference to MediaItem
+ * @return SaverBuilder object
+ */
SaverBuilder &setItem(const MediaItemSRef &item);
+
+ /**
+ * @brief Creates job
+ * @param[in] onComplete Completion handler
+ * @return Shared reference to IJob
+ */
IJobSRef build(const NotiHandler &onComplete) const;
private:
MediaItemSRef m_item;
};
+ /**
+ * @brief Enumeration of possible flags
+ */
enum {
- FLAG_THUMBNAIL = 1,
- FLAG_REMOVE = 2,
- FLAG_SAVE = 4,
- FLAG_RESOLUTION = 8,
+ FLAG_THUMBNAIL = 1, /**< Thumbnail*/
+ FLAG_REMOVE = 2, /**< Staged for deletion*/
+ FLAG_SAVE = 4, /**< Save*/
+ FLAG_RESOLUTION = 8, /**< Resolution*/
FLAGS_FROM_MEDIA_DB = (FLAG_THUMBNAIL | FLAG_REMOVE |
- FLAG_RESOLUTION),
- FLAGS_SIMPLE_FILE = (FLAG_SAVE)
+ FLAG_RESOLUTION), /**< File from media DB*/
+ FLAGS_SIMPLE_FILE = (FLAG_SAVE) /**< Simple file*/
};
public:
+
+ /**
+ * @brief Creates new instance of MediaItem
+ * @param[in] media Media info
+ * @return Shared reference to MediaItem object
+ */
static MediaItemSRef newInstance(media_info_h media);
+
+ /**
+ * @brief Creates new instance of MediaItem
+ * @param[in] filePath Path to file
+ * @return Shared reference to MediaItem object
+ */
static MediaItemSRef newInstance(std::string filePath);
public:
+ /**
+ * @brief Checks if MediaItem is valid
+ * @return true if valid, false if invalid
+ */
bool isValid() const;
+
+ /**
+ * @brief Gets MediaItem flags
+ * @return Flags
+ */
int getFlags() const;
+
+ /**
+ * @brief Gets type
+ * @return Media item type
+ */
MediaType getType() const;
+ /**
+ * @brief Gets ID
+ * @return Media item ID
+ */
const std::string &getId() const;
+ /**
+ * @brief Gets resolution
+ * @param[out] x X axis size
+ * @param[out] y Y axis size
+ * @return RES_OK on success, otherwise an error code on failure
+ */
ucl::Result getResolution(int &x, int &y) const;
+ /**
+ * @brief Gets file path
+ * @return File path
+ */
const std::string &getFilePath() const;
+ /**
+ * @brief Gets path to thumbnail
+ * @param[in] cb Thumbnail creation callback
+ * @return RES_OK on synchronous callback, RES_FALSE on asynchronous,
+ * otherwise an error code on failure
+ */
ucl::Result getThumbnailPath(const ThumbnailPathGetCb &cb) const;
+
+ /**
+ * @brief Cancels getting path to thumbnail
+ * @details Cancels callback and thumbnail generation
+ * @param[in] cb Callback
+ * @return RES_OK on synchronous callback, RES_FALSE on asynchronous,
+ * otherwise an error code on failure
+ */
void cancelThumbnailPathGet(const ThumbnailPathGetCb &cb) const;
+ /**
+ * @brief Removes media items file
+ * @return RES_OK on success, otherwise an error code on failure
+ */
ucl::Result removeFile();
+
+ /**
+ * @brief Saves media items file locally
+ * @return RES_OK on success, otherwise an error code on failure
+ */
ucl::Result saveToDevice();
protected:
friend class ucl::ReffedObj<MediaItem>;
+
+ /**
+ * @brief Constructor
+ * @param[in] flags Flags
+ * @param[in] type Media type
+ */
MediaItem(int flags, MediaType type);
+
+ /**
+ * @brief Destructor
+ */
virtual ~MediaItem();
+ /**
+ * @brief Prepares media image data
+ * @param[in] media Media info
+ * @return RES_OK on success, otherwise an error code on failure
+ */
ucl::Result prepare(media_info_h media);
+
+ /**
+ * @brief Prepares media image data
+ * @param[in] media Media info
+ * @return RES_OK on success, otherwise an error code on failure
+ */
ucl::Result prepareImage(media_info_h media);
+
+ /**
+ * @brief Prepares media image data
+ * @param[in] filePath Path to media file
+ * @return RES_OK on success, otherwise an error code on failure
+ */
ucl::Result prepare(std::string filePath);
private:
UCL_DECLARE_REF_ALIASES(SoundManager);
+ /**
+ * @brief Provides set of instruments to operate with sound parameters
+ */
class SoundManager final : public ucl::NonCopyable {
public:
+
+ /**
+ * @brief Creates new instance of SoundManager
+ * @return Shared reference to SoundManager object
+ */
static SoundManagerSRef newInstance();
public:
+
+ /**
+ * @brief Checks if media device is ready
+ * @return true if ready, false if not ready
+ */
bool isMediaDeviceReady() const;
+ /**
+ * @brief Gets current volume level
+ * @return Current volume level
+ */
int getCurrentMediaVolume() const;
+
+ /**
+ * @brief Gets max volume level
+ * @return Max volume level
+ */
int getMaxMediaVolume() const;
+ /**
+ * @brief Adds media device state change handler
+ * @param[in] handler Handler
+ */
void addMediaDeviceStateChangeHandler(NotiHandler handler);
+
+ /**
+ * @brief Removes media device state change handler
+ * @param[in] handler Handler
+ */
void delMediaDeviceStateChangeHandler(NotiHandler::CDRef handler);
+ /**
+ * @brief Adds media volume state change handler
+ * @param[in] handler Handler
+ */
void addMediaVolumeChangeHandler(NotiHandler handler);
+
+ /**
+ * @brief Adds media volume change handler
+ * @param[in] handler Handler
+ */
void delMediaVolumeChangeHandler(NotiHandler::CDRef handler);
private:
namespace gallery { namespace util {
+ /**
+ * @brief Creates CustomMediaAlbum
+ * @param[in] filePathArray Vector of file paths
+ * @return Shared reference to CustomMediaAlbum
+ */
CustomMediaAlbumSRef makeMediaAlbum(
const std::vector<std::string> &filePathArray);
}}
namespace gallery {
+ /**
+ * @brief Enumeration of media types
+ */
enum class MediaType {
- IMAGE,
- VIDEO,
- SOUND,
- MUSIC,
- OTHERS
+ IMAGE, /**< Image*/
+ VIDEO, /**< Video*/
+ SOUND, /**< Sound*/
+ MUSIC, /**< Music*/
+ OTHERS /**< Others*/
};
}