myMPD
Internal API documentation
Loading...
Searching...
No Matches
stickerdb.h File Reference

MPD sticker functions. More...

Include dependency graph for stickerdb.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

bool stickerdb_connect (struct t_stickerdb_state *stickerdb)
 
void stickerdb_disconnect (struct t_stickerdb_state *stickerdb)
 
bool stickerdb_idle (struct t_stickerdb_state *stickerdb)
 
bool stickerdb_enter_idle (struct t_stickerdb_state *stickerdb)
 
bool stickerdb_exit_idle (struct t_stickerdb_state *stickerdb)
 
bool stickerdb_check_error_and_recover (struct t_stickerdb_state *stickerdb, const char *command)
 
sds stickerdb_get (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *uri, const char *name)
 
int64_t stickerdb_get_int64 (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *uri, const char *name)
 
struct t_stickerstickerdb_get_all (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *uri, struct t_sticker *sticker, bool user_defined)
 
sds stickerdb_get_batch (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *uri, const char *name)
 
int64_t stickerdb_get_int64_batch (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *uri, const char *name)
 
struct t_stickerstickerdb_get_all_batch (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *uri, struct t_sticker *sticker, bool user_defined)
 
rax * stickerdb_find_stickers_by_name (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *name)
 
rax * stickerdb_find_stickers_by_name_value (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *name, enum mpd_sticker_operator op, const char *value)
 
void stickerdb_free_find_result (rax *stickers)
 
struct t_liststickerdb_find_stickers_sorted (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *baseuri, const char *name, enum mpd_sticker_operator op, const char *value, enum mpd_sticker_sort sort, bool sort_desc, unsigned start, unsigned end)
 
bool stickerdb_set (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *uri, const char *name, const char *value)
 
bool stickerdb_set_int64 (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *uri, const char *name, int64_t value)
 
bool stickerdb_inc (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *uri, const char *name, unsigned value)
 
bool stickerdb_dec (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *uri, const char *name, unsigned value)
 
bool stickerdb_inc_set (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *uri, enum mympd_sticker_names name_inc, enum mympd_sticker_names name_timestamp, time_t timestamp)
 
bool stickerdb_set_elapsed (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *uri, time_t elapsed)
 
bool stickerdb_inc_play_count (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *uri, time_t timestamp)
 
bool stickerdb_inc_skip_count (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *uri)
 
bool stickerdb_set_like (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *uri, enum sticker_like value)
 
bool stickerdb_set_rating (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *uri, int value)
 
bool stickerdb_remove (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, const char *uri, const char *name)
 
bool stickerdb_get_names (struct t_stickerdb_state *stickerdb, enum mympd_sticker_type type, struct t_list *sticker_names)
 
bool check_get_sticker (bool featSticker, const struct t_stickers *stickers)
 

Detailed Description

MPD sticker functions.

Function Documentation

◆ check_get_sticker()

bool check_get_sticker ( bool  featSticker,
const struct t_stickers stickers 
)

Checks if stickers should be fetched

Parameters
featStickerFlag indicating enabled sticker support
stickersPointer to t_stickers struct
Returns
bool true if stickers should be fetched, else false

◆ stickerdb_check_error_and_recover()

bool stickerdb_check_error_and_recover ( struct t_stickerdb_state stickerdb,
const char *  command 
)

Calls mpd_response_finish and checks for an mpd error and tries to recover.

Parameters
stickerdbpointer to the stickerdb state
commandcommand to check for the error
Returns
true on success, else false

◆ stickerdb_connect()

bool stickerdb_connect ( struct t_stickerdb_state stickerdb)

This function connects to mpd sticker instance on demand or exits the idle mode

Parameters
stickerdbpointer to the stickerdb state
Returns
true on success, else false

◆ stickerdb_dec()

bool stickerdb_dec ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  uri,
const char *  name,
unsigned  value 
)

Decrements a sticker

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
uristicker uri
namesticker name
valuevalue to decrement
Returns
true on success, else false

◆ stickerdb_disconnect()

void stickerdb_disconnect ( struct t_stickerdb_state stickerdb)

Disconnects from MPD

Parameters
stickerdbpointer to stickerdb state

◆ stickerdb_enter_idle()

bool stickerdb_enter_idle ( struct t_stickerdb_state stickerdb)

Enters the idle mode

Parameters
stickerdbpointer to the stickerdb state
Returns
true on success, else false

◆ stickerdb_exit_idle()

bool stickerdb_exit_idle ( struct t_stickerdb_state stickerdb)

Exits the idle mode, ignoring all idle events

Parameters
stickerdbpointer to the stickerdb state
Returns
true on success, else false

◆ stickerdb_find_stickers_by_name()

rax * stickerdb_find_stickers_by_name ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  name 
)

Gets all stickers by name

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
namesticker name
Returns
newly allocated radix tree or NULL on error

◆ stickerdb_find_stickers_by_name_value()

rax * stickerdb_find_stickers_by_name_value ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  name,
enum mpd_sticker_operator  op,
const char *  value 
)

Gets all stickers by name and value

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
namesticker name
opcompare operator: MPD_STICKER_OP_EQ, MPD_STICKER_OP_GT, MPD_STICKER_OP_LT
valuesticker value
Returns
newly allocated radix tree or NULL on error

◆ stickerdb_find_stickers_sorted()

struct t_list * stickerdb_find_stickers_sorted ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  baseuri,
const char *  name,
enum mpd_sticker_operator  op,
const char *  value,
enum mpd_sticker_sort  sort,
bool  sort_desc,
unsigned  start,
unsigned  end 
)

Gets a sorted list of stickers by name and value

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
baseuribaseuri for search
namesticker name
opmpd sticker compare operator
valuesticker value or NULL to get all stickers with this name
sortsticker sort type
sort_descsort descending?
startwindow start (including)
endwindow end (excluding), use UINT_MAX for open end
Returns
new allocated struct t_list

◆ stickerdb_free_find_result()

void stickerdb_free_find_result ( rax *  stickers)

Frees the sticker find result

Parameters
stickerspointer to stickers rax tree

◆ stickerdb_get()

sds stickerdb_get ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  uri,
const char *  name 
)

Gets a sticker.

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
uristicker uri
namesticker name
Returns
pointer to sticker value

◆ stickerdb_get_all()

struct t_sticker * stickerdb_get_all ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  uri,
struct t_sticker sticker,
bool  user_defined 
)

Gets all stickers

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
uristicker uri
stickerpointer to t_sticker struct to populate
user_definedget user defines stickers?
Returns
Initialized and populated sticker struct or NULL on error

◆ stickerdb_get_all_batch()

struct t_sticker * stickerdb_get_all_batch ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  uri,
struct t_sticker sticker,
bool  user_defined 
)

Gets all stickers. You must manage the idle state manually.

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
uristicker uri
stickerpointer to t_sticker struct to populate
user_definedget user defines stickers?
Returns
Initialized and populated sticker struct or NULL on error

◆ stickerdb_get_batch()

sds stickerdb_get_batch ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  uri,
const char *  name 
)

Gets a sticker. You must manage the idle state manually.

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
uristicker uri
namesticker name
Returns
pointer to sticker value

◆ stickerdb_get_int64()

int64_t stickerdb_get_int64 ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  uri,
const char *  name 
)

Gets an int64_t value sticker.

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
uristicker uri
namesticker name
Returns
sticker value or 0 on error

◆ stickerdb_get_int64_batch()

int64_t stickerdb_get_int64_batch ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  uri,
const char *  name 
)

Gets an int64_t value sticker. You must manage the idle state manually.

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
uristicker uri
namesticker name
Returns
sticker value or 0 on error

◆ stickerdb_get_names()

bool stickerdb_get_names ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
struct t_list sticker_names 
)

Gets all sticker names by type

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
sticker_namesList to populate
Returns
true on success, else false

◆ stickerdb_idle()

bool stickerdb_idle ( struct t_stickerdb_state stickerdb)

Discards waiting idle events for the stickerdb connection. This prevents the connection to timeout.

Parameters
stickerdbpointer to the stickerdb state
Returns
true on success, else false

◆ stickerdb_inc()

bool stickerdb_inc ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  uri,
const char *  name,
unsigned  value 
)

Increments a sticker

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
uristicker uri
namesticker name
valuevalue to increment
Returns
true on success, else false

◆ stickerdb_inc_play_count()

bool stickerdb_inc_play_count ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  uri,
time_t  timestamp 
)

Increments the myMPD play count and sets the last played time

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
uristicker uri
timestamptimestamp to set
Returns
true on success, else false

◆ stickerdb_inc_set()

bool stickerdb_inc_set ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  uri,
enum mympd_sticker_names  name_inc,
enum mympd_sticker_names  name_timestamp,
time_t  timestamp 
)

Increments a counter and sets a timestamp

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
uristicker uri
name_incsticker name for counter
name_timestampsticker name for timestamp
timestamptimestamp to set
Returns
true on success, else false

◆ stickerdb_inc_skip_count()

bool stickerdb_inc_skip_count ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  uri 
)

Increments the myMPD skip count and sets the last skipped time

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
uristicker uri
Returns
true on success, else false

◆ stickerdb_remove()

bool stickerdb_remove ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  uri,
const char *  name 
)

Removes a sticker

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
uristicker uri
namesticker name
Returns
bool true on success, else false

◆ stickerdb_set()

bool stickerdb_set ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  uri,
const char *  name,
const char *  value 
)

Sets a sticker

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
uristicker uri
namesticker name
valuesticker value
Returns
true on success, else false

◆ stickerdb_set_elapsed()

bool stickerdb_set_elapsed ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  uri,
time_t  elapsed 
)

Sets the myMPD elapsed timestamp sticker

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
uristicker uri
elapsedtimestamp
Returns
true on success, else false

◆ stickerdb_set_int64()

bool stickerdb_set_int64 ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  uri,
const char *  name,
int64_t  value 
)

Sets a sticker

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
uristicker uri
namesticker name
valuesticker value
Returns
true on success, else false

◆ stickerdb_set_like()

bool stickerdb_set_like ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  uri,
enum sticker_like  value 
)

Sets the myMPD like sticker

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
uristicker uri
value0 = hate, 1 = neutral, 2 = like
Returns
true on success, else false

◆ stickerdb_set_rating()

bool stickerdb_set_rating ( struct t_stickerdb_state stickerdb,
enum mympd_sticker_type  type,
const char *  uri,
int  value 
)

Sets the myMPD rating sticker

Parameters
stickerdbpointer to the stickerdb state
typeMPD sticker type
uristicker uri
value0 - 10 stars
Returns
true on success, else false