2013-10-27 17:25:26 -04:00
|
|
|
/*
|
|
|
|
* Copyright 2013 (c) Anna Schumaker.
|
|
|
|
*/
|
|
|
|
#ifndef OCARINA_LIBRARY_H
|
|
|
|
#define OCARINA_LIBRARY_H
|
|
|
|
|
|
|
|
#include <database.h>
|
|
|
|
#include <string>
|
|
|
|
|
2013-11-10 16:57:28 -05:00
|
|
|
#include <taglib/tag.h>
|
2013-11-10 17:37:35 -05:00
|
|
|
#include <taglib/fileref.h>
|
2013-11-10 16:57:28 -05:00
|
|
|
|
2014-01-01 20:26:18 -05:00
|
|
|
struct ImportData;
|
|
|
|
|
2013-10-27 17:25:26 -04:00
|
|
|
namespace library
|
|
|
|
{
|
|
|
|
|
|
|
|
enum DB_Type {
|
|
|
|
DB_ALBUM,
|
|
|
|
DB_ARTIST,
|
|
|
|
DB_GENRE,
|
|
|
|
DB_LIBRARY,
|
|
|
|
DB_TRACK,
|
|
|
|
};
|
|
|
|
|
2013-11-10 16:09:31 -05:00
|
|
|
|
2014-01-01 13:34:25 -05:00
|
|
|
class AGInfo : public DatabaseEntry {
|
2013-11-10 16:09:31 -05:00
|
|
|
public:
|
2014-01-01 13:34:25 -05:00
|
|
|
DB_Type db_type;
|
|
|
|
std :: string key_lower;
|
2013-11-10 16:09:31 -05:00
|
|
|
|
2014-01-01 13:34:25 -05:00
|
|
|
AGInfo();
|
|
|
|
AGInfo(DB_Type, TagLib :: Tag *);
|
2014-01-01 20:26:18 -05:00
|
|
|
AGInfo(DB_Type, const std::string &);
|
2013-11-10 16:09:31 -05:00
|
|
|
void read(File &);
|
|
|
|
void write(File &);
|
2014-01-01 20:58:53 -05:00
|
|
|
#ifdef CONFIG_TEST
|
2013-11-10 16:09:31 -05:00
|
|
|
void print();
|
2014-01-01 20:58:53 -05:00
|
|
|
#endif /* CONFIG_TEST */
|
2013-11-10 16:09:31 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-12-31 20:14:52 -05:00
|
|
|
class Album : public DatabaseEntry {
|
2013-11-10 16:45:52 -05:00
|
|
|
public:
|
2013-12-10 17:38:42 -05:00
|
|
|
std :: string name;
|
2014-01-01 13:34:25 -05:00
|
|
|
std :: string name_lower;
|
2013-11-10 16:45:52 -05:00
|
|
|
unsigned int year;
|
|
|
|
unsigned int artist_id;
|
|
|
|
|
|
|
|
Album();
|
2013-11-10 16:57:28 -05:00
|
|
|
Album(TagLib :: Tag *, unsigned int);
|
2014-01-01 20:26:18 -05:00
|
|
|
Album(const std::string &, unsigned int, unsigned int);
|
2013-11-10 16:45:52 -05:00
|
|
|
void read(File &);
|
|
|
|
void write(File &);
|
2014-01-01 20:58:53 -05:00
|
|
|
#ifdef CONFIG_TEST
|
2013-11-10 16:45:52 -05:00
|
|
|
void print();
|
2014-01-01 20:58:53 -05:00
|
|
|
#endif /* CONFIG_TEST */
|
2013-11-10 16:45:52 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-12-31 20:14:52 -05:00
|
|
|
class Library : public DatabaseEntry {
|
2013-10-27 17:25:26 -04:00
|
|
|
public:
|
|
|
|
std::string root_path;
|
2014-01-01 20:36:30 -05:00
|
|
|
unsigned int size;
|
2013-10-27 17:25:26 -04:00
|
|
|
bool enabled;
|
|
|
|
|
2013-11-03 16:03:01 -05:00
|
|
|
Library();
|
2013-10-27 17:25:26 -04:00
|
|
|
Library(const std::string &, bool);
|
|
|
|
void read(File &);
|
|
|
|
void write(File &);
|
2014-01-01 20:58:53 -05:00
|
|
|
#ifdef CONFIG_TEST
|
2013-10-27 17:25:26 -04:00
|
|
|
void print();
|
2014-01-01 20:58:53 -05:00
|
|
|
#endif /* CONFIG_TEST */
|
2013-10-27 17:25:26 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-12-31 20:14:52 -05:00
|
|
|
class Track : public DatabaseEntry {
|
2013-11-10 17:37:35 -05:00
|
|
|
public:
|
|
|
|
unsigned int library_id;
|
|
|
|
unsigned int artist_id;
|
|
|
|
unsigned int album_id;
|
|
|
|
unsigned int genre_id;
|
|
|
|
|
|
|
|
unsigned int track;
|
|
|
|
unsigned int last_year;
|
|
|
|
unsigned int last_month;
|
|
|
|
unsigned int last_day;
|
|
|
|
unsigned int play_count;
|
|
|
|
unsigned int length;
|
|
|
|
|
|
|
|
std :: string title;
|
2014-01-01 13:34:25 -05:00
|
|
|
std :: string title_lower;
|
2013-11-10 17:37:35 -05:00
|
|
|
std :: string length_str;
|
|
|
|
std :: string filepath;
|
|
|
|
|
|
|
|
Track();
|
|
|
|
Track(TagLib :: Tag *, TagLib :: AudioProperties *,
|
|
|
|
unsigned int, unsigned int, unsigned int,
|
|
|
|
unsigned int, const std :: string &);
|
2014-01-01 20:26:18 -05:00
|
|
|
Track(ImportData *, unsigned int, unsigned int,
|
|
|
|
unsigned int, unsigned int);
|
2013-11-10 17:37:35 -05:00
|
|
|
void read(File &);
|
|
|
|
void write(File &);
|
2014-01-01 20:58:53 -05:00
|
|
|
#ifdef CONFIG_TEST
|
2013-11-10 17:37:35 -05:00
|
|
|
void print();
|
2014-01-01 20:58:53 -05:00
|
|
|
#endif /* CONFIG_TEST */
|
2013-11-10 17:37:35 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-11-17 14:41:22 -05:00
|
|
|
struct Song {
|
|
|
|
library :: Album *album;
|
2014-01-01 13:34:25 -05:00
|
|
|
library :: AGInfo *artist;
|
|
|
|
library :: AGInfo *genre;
|
2013-11-17 14:41:22 -05:00
|
|
|
library :: Library *library;
|
|
|
|
library :: Track *track;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-11-03 16:03:01 -05:00
|
|
|
void init();
|
2014-01-01 13:34:25 -05:00
|
|
|
void add_path(const std::string &);
|
2013-10-27 17:25:26 -04:00
|
|
|
void del_path(unsigned int);
|
2013-11-10 16:09:31 -05:00
|
|
|
void update_path(unsigned int);
|
2014-01-01 13:34:25 -05:00
|
|
|
void update_all();
|
2014-01-18 12:32:41 -05:00
|
|
|
void set_enabled(unsigned int, bool);
|
2014-01-01 13:34:25 -05:00
|
|
|
void lookup(unsigned int, library :: Song *);
|
2014-01-01 20:55:07 -05:00
|
|
|
Library *lookup_path(unsigned int);
|
2014-01-01 20:26:18 -05:00
|
|
|
void import();
|
2014-01-29 22:45:01 -05:00
|
|
|
void track_played(unsigned int);
|
2014-01-01 20:58:53 -05:00
|
|
|
#ifdef CONFIG_TEST
|
2013-10-27 17:25:26 -04:00
|
|
|
void print_db(DB_Type);
|
|
|
|
void reset();
|
2014-01-01 20:58:53 -05:00
|
|
|
#endif /* CONFIG_TEST */
|
2013-10-27 17:25:26 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* OCARINA_LIBRARY_H */
|