ocarina/include/core/tags/album.h

83 lines
2.5 KiB
C

/*
* Copyright 2014 (c) Anna Schumaker.
*
* The album tag is used to store the name and year of albums
* added to the tag database.
*
* When writing an album tag to disk, write out the album_artist, album_genre,
* and album_year fields followed by the album_name on the same line:
*
* ...0 0 1998 Hyrule Symphony
* ...0 0 2006 Twilight Princess
* ...0 0 2011 Skyward Sword
*/
#ifndef OCARINA_CORE_TAGS_ALBUM_H
#define OCARINA_CORE_TAGS_ALBUM_H
#include <core/database.h>
#include <core/tags/artist.h>
struct album {
unsigned int al_year; /* This album's year. */
gchar *al_name; /* This album's name. */
gchar **al_tokens; /* This album's tokenized strings. */
gchar **al_alts; /* This album's alternate ascii tokens. */
struct artist *al_artist;
struct genre *al_genre;
struct db_entry al_dbe;
};
#define ALBUM(dbe) ((struct album *)DBE_DATA(dbe))
/* Called to initialize the album database. */
void album_db_init();
/* Called to clean up the album database. */
void album_db_deinit();
/* Called to defragment the album database. */
bool album_db_defrag();
/* Called to clean up the album database after an upgrade. */
bool album_db_upgrade_done();
/* Called to find an album tag by artist, name and year. */
struct album *album_find(struct artist *, struct genre *,
const gchar *, unsigned int);
/* Called to get an album tag with a specific index. */
struct album *album_get(const unsigned int);
/* Called to compare two album tags by name. */
int album_compare(struct album *, struct album *);
/* Called to compare two album tags by year. */
int album_compare_year(struct album *, struct album *);
/* Called to check if an artist has a token that matches the given string. */
bool album_match_token(struct album *album, const gchar *);
/* Called to find the database index of the album tag. */
static inline unsigned int album_index(struct album *album)
{
return album->al_dbe.dbe_index;
}
/* Called to check if album artwork has been downloaded. */
bool album_artwork_exists(struct album *);
/*
* Called to find the path to an album's artwork.
* This function returns a new string that MUST be freed with g_free().
*/
gchar *album_artwork_path(struct album *);
/* Called to manually set artwork for a given album. */
bool album_artwork_import(struct album *, gchar *);
#ifdef CONFIG_TESTING
const struct db_ops *test_album_ops();
#endif /* CONFIG_TESTING */
#endif /* OCARINA_CORE_TAGS_ALBUM_H */