[db] Add functions to access/modify the queue table

This commit is contained in:
chme 2016-11-04 15:34:00 +01:00
parent 0beb68e1f1
commit 8ebf2f9307
2 changed files with 1622 additions and 0 deletions

1483
src/db.c

File diff suppressed because it is too large Load Diff

139
src/db.h
View File

@ -374,6 +374,60 @@ struct directory_enum {
sqlite3_stmt *stmt;
};
struct db_queue_item
{
/* Item-Id is a unique id for this queue item. If the same item appears multiple
times in the queue each corresponding queue item has its own id. */
uint32_t item_id;
/* Id of the file/item in the files database */
uint32_t file_id;
/* Length of the item in ms */
uint32_t song_length;
/* Data type of the item */
enum data_kind data_kind;
/* Media type of the item */
enum media_kind media_kind;
uint32_t seek;
uint32_t pos;
uint32_t shuffle_pos;
char *path;
char *virtual_path;
char *title;
char *artist;
char *album_artist;
char *album;
char *genre;
int64_t songalbumid;
uint32_t time_modified;
char *artist_sort;
char *album_sort;
char *album_artist_sort;
uint32_t year;
uint32_t track;
uint32_t disc;
};
struct db_queue_enum
{
/* 0 = ordered by position, 1 = ordered by position in shuffle queue */
int orderby_shufflepos;
char *filter;
/* Private enum context, keep out */
sqlite3_stmt *stmt;
};
char *
db_escape_string(const char *str);
@ -392,6 +446,9 @@ free_pli(struct playlist_info *pli, int content_only);
void
free_di(struct directory_info *di, int content_only);
void
free_queue_item(struct db_queue_item *queue_item, int content_only);
/* Maintenance and DB hygiene */
void
db_hook_post_scan(void);
@ -409,6 +466,9 @@ db_transaction_begin(void);
void
db_transaction_end(void);
void
db_transaction_rollback(void);
/* Queries */
int
db_query_start(struct query_params *qp);
@ -646,6 +706,85 @@ db_speaker_get(uint64_t id, int *selected, int *volume);
void
db_speaker_clear_all(void);
/* Queue */
int
db_queue_get_version();
int
db_queue_add_by_queryafteritemid(struct query_params *qp, uint32_t item_id);
int
db_queue_add_by_query(struct query_params *qp, char reshuffle, uint32_t item_id);
int
db_queue_add_by_playlistid(int plid, char reshuffle, uint32_t item_id);
int
db_queue_add_by_fileid(int id, char reshuffle, uint32_t item_id);
int
db_queue_enum_start(struct db_queue_enum *queue_enum);
void
db_queue_enum_end(struct db_queue_enum *queue_enum);
int
db_queue_enum_fetch(struct db_queue_enum *queue_enum, struct db_queue_item *queue_item);
struct db_queue_item *
db_queue_fetch_byitemid(uint32_t item_id);
struct db_queue_item *
db_queue_fetch_byfileid(uint32_t file_id);
struct db_queue_item *
db_queue_fetch_bypos(uint32_t pos, char shuffle);
struct db_queue_item *
db_queue_fetch_byposrelativetoitem(int pos, uint32_t item_id, char shuffle);
struct db_queue_item *
db_queue_fetch_next(uint32_t item_id, char shuffle);
struct db_queue_item *
db_queue_fetch_prev(uint32_t item_id, char shuffle);
int
db_queue_cleanup();
int
db_queue_clear();
int
db_queue_delete_byitemid(uint32_t item_id);
int
db_queue_delete_bypos(uint32_t pos, int count);
int
db_queue_delete_byposrelativetoitem(uint32_t pos, uint32_t item_id, char shuffle);
int
db_queue_move_byitemid(uint32_t item_id, int pos_to);
int
db_queue_move_bypos(int pos_from, int pos_to);
int
db_queue_move_byposrelativetoitem(uint32_t from_pos, uint32_t to_offset, uint32_t item_id, char shuffle);
int
db_queue_reshuffle(uint32_t item_id);
int
db_queue_get_count();
int
db_queue_get_pos(uint32_t item_id, char shuffle);
int
db_queue_get_pos_byfileid(uint32_t file_id, char shuffle);
/* Inotify */
int
db_watch_clear(void);