core/tags/library: Remove unused "enabled" field

This was used to enable and disable library paths in previous Ocarina
versions.  This isn't used anymore now that we have library-based
playlists.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2016-09-11 09:42:00 -04:00
parent 784cd3eb91
commit 30cebb4a45
4 changed files with 14 additions and 33 deletions

View File

@ -203,18 +203,9 @@ static bool sys_pl_collection_can_select(struct playlist *playlist)
return true;
}
static bool sys_pl_collection_add(struct playlist *playlist, struct track *track)
{
if (track->tr_library->li_enabled != true)
return false;
return sys_pl_generic_add(playlist, track);
}
static bool sys_pl_collection_update(struct playlist *playlist,
struct track *track)
{
if (track->tr_library->li_enabled != true)
return false;
return sys_pl_generic_add(playlist, track) || true;
}
@ -224,7 +215,7 @@ static struct sys_playlist sys_collection = {
.spl_save = sys_pl_save_partial,
.spl_load = sys_pl_load_partial,
.spl_can_select = sys_pl_collection_can_select,
.spl_add = sys_pl_collection_add,
.spl_add = sys_pl_generic_add,
.spl_remove = playlist_generic_remove_track,
.spl_clear = playlist_noop_clear,
.spl_update = sys_pl_collection_update,

View File

@ -3,16 +3,16 @@
*/
#include <core/tags/library.h>
#define LIBRARY_DB_MIN 0 /* Ocarina 6.0 */
#define LIBRARY_DB_CUR 1 /* Ocarina 6.5 */
static struct database library_db;
static struct library *__library_alloc(gchar *path, bool enabled)
static struct library *__library_alloc(gchar *path)
{
struct library *library = g_malloc(sizeof(struct library));
dbe_init(&library->li_dbe, library);
library->li_size = 0;
library->li_enabled = enabled;
library->li_path = path;
library->li_playlist = NULL;
@ -21,7 +21,7 @@ static struct library *__library_alloc(gchar *path, bool enabled)
static struct db_entry *library_alloc(const gchar *path)
{
return &__library_alloc(g_strdup(path), true)->li_dbe;
return &__library_alloc(g_strdup(path))->li_dbe;
}
static void library_free(struct db_entry *dbe)
@ -39,14 +39,16 @@ static struct db_entry *library_read(struct file *file)
int enabled;
gchar *path;
file_readf(file, "%d %m[^\n]", &enabled, &path);
return &__library_alloc(path, enabled)->li_dbe;
if (file_version(file) == 0)
file_readf(file, "%d", &enabled);
file_readf(file, " %m[^\n]", &path);
return &__library_alloc(path)->li_dbe;
}
static void library_write(struct file *file, struct db_entry *dbe)
{
file_writef(file, "%d %s", LIBRARY(dbe)->li_enabled,
LIBRARY(dbe)->li_path);
file_writef(file, "%s", LIBRARY(dbe)->li_path);
}
@ -62,7 +64,8 @@ static const struct db_ops library_ops = {
void library_db_init()
{
db_init(&library_db, "library.db", true, &library_ops, 0, 0);
db_init(&library_db, "library.db", true, &library_ops, LIBRARY_DB_MIN,
LIBRARY_DB_CUR);
db_load_idle(&library_db);
}
@ -97,12 +100,6 @@ void library_remove(struct library *library)
db_remove(&library_db, &library->li_dbe);
}
void library_set_enabled(struct library *library, bool enabled)
{
library->li_enabled = enabled;
db_save(&library_db);
}
gchar *library_file(struct library *library, const gchar *path)
{
return g_strdup_printf("%s/%s", library->li_path, path);

View File

@ -17,7 +17,6 @@
struct library {
unsigned int li_size; /* This library's track count. */
bool li_enabled; /* True if this library is enabled. */
gchar *li_path; /* This library's root path. */
void *li_playlist; /* This library's associated playlist. */
struct db_entry li_dbe;
@ -49,9 +48,6 @@ struct library *library_get(const unsigned int);
/* Called to remove a specific library tag. */
void library_remove(struct library *);
/* Called to configure if the library tag is enabled. */
void library_set_enabled(struct library *, bool);
/* Called to find the database index of the library tag. */
static inline unsigned int library_index(struct library *library)
{

View File

@ -7,7 +7,6 @@
static void test_verify_zelda(struct library *library)
{
const struct db_ops *library_ops = test_library_ops();
g_assert_true(library->li_enabled);
g_assert_cmpuint(library->li_size, ==, 0);
g_assert_null(library->li_playlist);
g_assert_cmpstr(library_ops->dbe_key(&library->li_dbe), ==, "/home/Zelda/Music");
@ -16,7 +15,6 @@ static void test_verify_zelda(struct library *library)
static void test_verify_link(struct library *library)
{
const struct db_ops *library_ops = test_library_ops();
g_assert_false(library->li_enabled);
g_assert_cmpuint(library->li_size, ==, 0);
g_assert_null(library->li_playlist);
g_assert_cmpstr(library_ops->dbe_key(&library->li_dbe), ==, "/home/Link/Music");
@ -31,7 +29,6 @@ static void test_library()
link = LIBRARY(library_ops->dbe_alloc("/home/Link/Music"));
zelda = LIBRARY(library_ops->dbe_alloc("/home/Zelda/Music"));
library_set_enabled(link, false);
test_verify_link(link);
test_verify_zelda(zelda);
@ -88,7 +85,7 @@ static void test_library_db()
g_assert(library_get(0) == library);
g_assert_null(library_get(1));
db_init(&library_db, "library.db", false, library_ops, 0, 0);
db_init(&library_db, "library.db", false, library_ops, 1, 1);
db_load(&library_db);
g_assert_cmpuint(library_db.db_size, ==, 1);
g_assert_cmpuint(db_actual_size(&library_db), ==, 1);