2014-09-13 10:38:54 -04:00
|
|
|
/**
|
2013-10-27 17:25:26 -04:00
|
|
|
* Copyright 2013 (c) Anna Schumaker.
|
|
|
|
*/
|
2014-06-21 09:37:47 -04:00
|
|
|
#ifndef OCARINA_CORE_LIBRARY_H
|
|
|
|
#define OCARINA_CORE_LIBRARY_H
|
2013-10-27 17:25:26 -04:00
|
|
|
|
2014-06-05 10:19:22 -04:00
|
|
|
#include <core/queue.h>
|
2013-10-27 17:25:26 -04:00
|
|
|
#include <string>
|
|
|
|
|
2014-09-13 10:38:54 -04:00
|
|
|
|
|
|
|
/**
|
2014-12-10 08:23:32 -05:00
|
|
|
* The Library is in charge of scanning and updating Library tags along
|
|
|
|
* with every other tag in the tag database. This code will also manage
|
|
|
|
* a special Queue used by the UI to display all enabled Tracks.
|
|
|
|
*
|
|
|
|
* The library queue is dynamic, so saving involves only storing the current
|
|
|
|
* flags and sort order.
|
|
|
|
*
|
|
|
|
* ... << flags << _sort_order.size()
|
|
|
|
* ... << _sort_order[N].field << _sort_order[N].ascending << ...
|
2014-09-13 10:38:54 -04:00
|
|
|
*/
|
2015-10-23 10:21:12 -04:00
|
|
|
namespace collection
|
2013-10-27 17:25:26 -04:00
|
|
|
{
|
|
|
|
|
2014-09-13 10:38:54 -04:00
|
|
|
/**
|
2014-12-10 08:23:32 -05:00
|
|
|
* Scan over every Track tag and add each enabled Track to the
|
|
|
|
* library queue.
|
2014-09-13 10:38:54 -04:00
|
|
|
*/
|
2015-11-24 08:18:31 -05:00
|
|
|
void init(struct queue_ops *);
|
|
|
|
|
|
|
|
void save(struct queue *, enum queue_flags);
|
2014-05-24 12:47:33 -04:00
|
|
|
|
2014-09-13 10:38:54 -04:00
|
|
|
/**
|
|
|
|
* Add a new directory to the library.
|
|
|
|
*
|
|
|
|
* @param dir The directory that should be scanned.
|
2014-12-10 08:23:32 -05:00
|
|
|
* @return The newly created Library tag or NULL if a
|
|
|
|
* tag could not be created.
|
2014-09-13 10:38:54 -04:00
|
|
|
*/
|
2015-10-23 10:21:12 -04:00
|
|
|
struct library *add(const std::string &);
|
2014-09-13 10:38:54 -04:00
|
|
|
|
|
|
|
/**
|
2014-12-10 08:23:32 -05:00
|
|
|
* Remove a Library tag from the database along with every
|
|
|
|
* Track associated with this library.
|
2014-09-13 10:38:54 -04:00
|
|
|
*
|
|
|
|
* @param library The library path that should be removed.
|
|
|
|
*/
|
2015-10-23 10:21:12 -04:00
|
|
|
void remove(struct library *);
|
2014-09-13 10:38:54 -04:00
|
|
|
|
|
|
|
/**
|
2014-12-10 08:23:32 -05:00
|
|
|
* First, scan over every Track in the database and remove
|
|
|
|
* tracks that no longer exist in the filesystem.
|
|
|
|
*
|
|
|
|
* Next, scan over every file in the Library's root directory
|
|
|
|
* and create new Track tags for every file found.
|
2014-09-13 10:38:54 -04:00
|
|
|
*
|
|
|
|
* @param library The library path that should be updated.
|
|
|
|
*/
|
2015-10-23 10:21:12 -04:00
|
|
|
void update(struct library *);
|
2014-09-13 10:38:54 -04:00
|
|
|
|
|
|
|
/**
|
2014-12-10 08:23:32 -05:00
|
|
|
* Call library :: update() on all Library tags.
|
2014-09-13 10:38:54 -04:00
|
|
|
*/
|
2014-01-01 13:34:25 -05:00
|
|
|
void update_all();
|
2014-05-24 12:47:33 -04:00
|
|
|
|
2014-09-13 10:38:54 -04:00
|
|
|
/**
|
2014-12-10 08:23:32 -05:00
|
|
|
* Use to enable or disable a library path. When a Library path
|
|
|
|
* is disabled, its tracks will be removed from the Library queue.
|
2014-09-13 10:38:54 -04:00
|
|
|
*
|
|
|
|
* @param library The library to be enabled or disabled.
|
|
|
|
* @param enabled Set to true if the library should be enabled,
|
|
|
|
* and false to disable it.
|
|
|
|
*/
|
2015-10-23 10:21:12 -04:00
|
|
|
void set_enabled(struct library *, bool);
|
2014-09-13 10:38:54 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Use to access the library queue.
|
|
|
|
*
|
|
|
|
* @return The queue of tracks currently in the library.
|
|
|
|
*/
|
2015-11-16 09:12:15 -05:00
|
|
|
queue *get_queue();
|
2014-05-24 12:47:33 -04:00
|
|
|
|
2013-10-27 17:25:26 -04:00
|
|
|
};
|
|
|
|
|
2014-06-21 09:37:47 -04:00
|
|
|
#endif /* OCARINA_CORE_LIBRARY_H */
|