myMPD
Internal API documentation
Loading...
Searching...
No Matches
presets.c File Reference

MPD presets functions. More...

#include "compile_time.h"
#include "src/mympd_client/presets.h"
#include "src/lib/filehandler.h"
#include "src/lib/json/json_query.h"
#include "src/lib/list.h"
#include "src/lib/log.h"
#include "src/lib/sds_extras.h"
#include "src/mympd_api/requests.h"
#include "src/mympd_api/settings.h"
#include <errno.h>
Include dependency graph for presets.c:

Functions

bool preset_apply (struct t_partition_state *partition_state, sds preset_name, sds *error)
 
sds presets_list (struct t_list *preset_list, sds buffer)
 
bool preset_save (struct t_list *preset_list, sds preset_name, sds preset_value, sds *error)
 
bool preset_delete (struct t_list *preset_list, const char *preset_name)
 
static sds preset_to_line_cb (sds buffer, struct t_list_node *current, bool newline)
 
bool preset_list_save (struct t_partition_state *partition_state)
 
bool preset_list_load (struct t_partition_state *partition_state)
 

Detailed Description

MPD presets functions.

Function Documentation

◆ preset_apply()

bool preset_apply ( struct t_partition_state partition_state,
sds  preset_name,
sds *  error 
)

Applies a preset

Parameters
partition_statepointer to partition state
preset_namepreset name
errorpointer to already allocated sds string to append the error message
Returns
true on success, else false

◆ preset_delete()

bool preset_delete ( struct t_list preset_list,
const char *  preset_name 
)

Deletes a preset

Parameters
preset_listpointer to preset list
preset_namepreset name
Returns
bool

◆ preset_list_load()

bool preset_list_load ( struct t_partition_state partition_state)

Reads the presets file from disc

Parameters
partition_statepointer to partition state
Returns
bool true on success, else false

◆ preset_list_save()

bool preset_list_save ( struct t_partition_state partition_state)

Writes the preset list to disc

Parameters
partition_statepointer to partition state
Returns
bool true on success, else false

◆ preset_save()

bool preset_save ( struct t_list preset_list,
sds  preset_name,
sds  preset_value,
sds *  error 
)

Saves a preset

Parameters
preset_listpointer to preset list
preset_namepreset name
preset_valuepreset value (stringified json)
errorpointer to alreay allocated sds string to append the error message
Returns
true on success, else false

◆ preset_to_line_cb()

static sds preset_to_line_cb ( sds  buffer,
struct t_list_node current,
bool  newline 
)
static

Callback function for presets_save

Parameters
bufferbuffer to append the line
currentlist node to print
newlineappend a newline char
Returns
pointer to buffer

◆ presets_list()

sds presets_list ( struct t_list preset_list,
sds  buffer 
)

Prints the list of presets as json array

Parameters
preset_listpreset list
buffersds string to append the array
Returns
sds pointer to buffer