2016-04-24 10:36:15 -04:00
|
|
|
/*
|
|
|
|
* Copyright 2016 (c) Anna Schumaker.
|
|
|
|
*/
|
|
|
|
#ifndef OCARINA_CORE_PLAYLISTS_TYPE_H
|
|
|
|
#define OCARINA_CORE_PLAYLISTS_TYPE_H
|
|
|
|
#include <core/queue.h>
|
|
|
|
#include <core/tags/track.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
|
|
|
2016-05-06 08:05:21 -04:00
|
|
|
enum playlist_type_t {
|
|
|
|
PL_SYSTEM,
|
2016-05-15 10:19:31 -04:00
|
|
|
PL_ARTIST,
|
2016-05-09 07:52:10 -04:00
|
|
|
PL_LIBRARY,
|
2016-05-06 08:05:21 -04:00
|
|
|
PL_MAX_TYPE,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-05-02 08:13:35 -04:00
|
|
|
struct playlist {
|
2016-05-06 08:05:21 -04:00
|
|
|
enum playlist_type_t pl_type; /* This playlist's type. */
|
|
|
|
const gchar *pl_name; /* This playlist's name. */
|
|
|
|
struct queue pl_queue; /* This playlist's queue of tracks. */
|
2016-05-02 08:13:35 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-05-06 08:05:21 -04:00
|
|
|
#define DEFINE_PLAYLIST(type, name) { .pl_type = type, .pl_name = name }
|
2016-05-02 08:13:35 -04:00
|
|
|
|
|
|
|
|
2016-04-24 10:36:15 -04:00
|
|
|
struct playlist_type {
|
|
|
|
/* Called to get the queue for the playlist. */
|
|
|
|
struct queue *(*pl_get_queue)(const gchar *);
|
|
|
|
|
2016-07-28 16:03:47 -04:00
|
|
|
/* Called to convert a playlist name to an integer id. */
|
|
|
|
unsigned int (*pl_get_id)(const gchar *);
|
|
|
|
|
|
|
|
/* Called to convert a playlist id to a name. */
|
|
|
|
gchar *(*pl_get_name)(unsigned int);
|
|
|
|
|
2016-08-01 09:41:10 -04:00
|
|
|
/* Called to check if a playlist can be selected. */
|
|
|
|
bool (*pl_can_select)(const gchar *);
|
|
|
|
|
2016-05-09 10:38:47 -04:00
|
|
|
/* Called to create a new playlist. */
|
|
|
|
bool (*pl_new)(const gchar *);
|
|
|
|
|
|
|
|
/* Called to delete a playlist. */
|
|
|
|
bool (*pl_delete)(const gchar *);
|
|
|
|
|
2016-04-24 10:36:15 -04:00
|
|
|
/* Called to add a track to the playlist. */
|
|
|
|
bool (*pl_add_track)(const gchar *, struct track *);
|
|
|
|
|
|
|
|
/* Called to remove a track from the playlist. */
|
|
|
|
bool (*pl_remove_track)(const gchar *, struct track *);
|
2016-05-01 09:17:21 -04:00
|
|
|
|
|
|
|
/* Called to update a playlist. */
|
|
|
|
void (*pl_update)(const gchar *);
|
2016-05-01 19:55:47 -04:00
|
|
|
|
|
|
|
/* Called to set a playlist flag. */
|
|
|
|
void (*pl_set_flag)(const gchar *, enum queue_flags, bool);
|
2016-05-04 09:55:37 -04:00
|
|
|
|
|
|
|
/* Called to sort a playlist. */
|
|
|
|
void (*pl_sort)(const gchar *, enum compare_t, bool);
|
2016-08-05 08:00:13 -04:00
|
|
|
|
|
|
|
/* Called to pick the next track from a playlist. */
|
|
|
|
struct track *(*pl_next)(const gchar *);
|
2016-04-24 10:36:15 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-08-01 09:41:10 -04:00
|
|
|
/* Noop playlist can-select operation. */
|
|
|
|
bool playlist_noop_can_select(struct playlist *);
|
|
|
|
|
2016-07-28 11:56:50 -04:00
|
|
|
/* Noop playlist clear operation. */
|
|
|
|
void playlist_noop_clear(struct playlist *);
|
|
|
|
|
2016-05-24 07:48:11 -04:00
|
|
|
/* Noop playlist set_flag operation. */
|
|
|
|
void playlist_noop_set_flag(struct playlist *, enum queue_flags, bool);
|
|
|
|
|
2016-05-24 07:33:40 -04:00
|
|
|
/* Noop playlist sorting operation. */
|
|
|
|
void playlist_noop_sort(struct playlist *, enum compare_t, bool);
|
|
|
|
|
|
|
|
|
2016-05-24 11:55:22 -04:00
|
|
|
/* Generic playlist init function. */
|
|
|
|
void playlist_generic_init(struct playlist *, unsigned int, struct queue_ops *);
|
|
|
|
|
2016-08-01 09:41:10 -04:00
|
|
|
/* Generic playlist can-select function. */
|
|
|
|
bool playlist_generic_can_select(struct playlist *);
|
|
|
|
|
2016-07-28 11:56:50 -04:00
|
|
|
/* Generic playlist clear operation. */
|
|
|
|
void playlist_generic_clear(struct playlist *);
|
|
|
|
|
2016-05-24 11:02:47 -04:00
|
|
|
/* Generic playlist add track operation. */
|
|
|
|
bool playlist_generic_add_track(struct playlist *, struct track *);
|
|
|
|
|
2016-05-24 11:13:44 -04:00
|
|
|
/* Generic playlist remove track operation. */
|
|
|
|
bool playlist_generic_remove_track(struct playlist *, struct track *);
|
|
|
|
|
2016-06-10 11:01:03 -04:00
|
|
|
/* Generic playlist update operation. */
|
|
|
|
void playlist_generic_update(struct playlist *,
|
|
|
|
bool (*)(struct playlist *, struct track *));
|
|
|
|
|
2016-05-24 07:48:11 -04:00
|
|
|
/* Generic playlist set_flag operation. */
|
|
|
|
void playlist_generic_set_flag(struct playlist *, enum queue_flags, bool);
|
|
|
|
|
2016-05-24 07:33:40 -04:00
|
|
|
/* Generic playlist sorting operation. */
|
|
|
|
void playlist_generic_sort(struct playlist *, enum compare_t, bool);
|
|
|
|
|
2016-08-05 08:00:13 -04:00
|
|
|
/* Generic playlist next track operation. */
|
|
|
|
struct track *playlist_generic_next(struct playlist *);
|
|
|
|
|
2016-05-24 07:33:40 -04:00
|
|
|
|
2016-04-24 10:36:15 -04:00
|
|
|
#endif /* OCARINA_CORE_PLAYLISTS_TYPE_H */
|