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

myMPD settings API More...

#include "compile_time.h"
#include "src/mympd_api/settings.h"
#include "src/lib/api.h"
#include "src/lib/cache/cache_rax_album.h"
#include "src/lib/convert.h"
#include "src/lib/json/json_print.h"
#include "src/lib/json/json_query.h"
#include "src/lib/json/json_rpc.h"
#include "src/lib/list.h"
#include "src/lib/log.h"
#include "src/lib/mem.h"
#include "src/lib/msg_queue.h"
#include "src/lib/sds_extras.h"
#include "src/lib/state_files.h"
#include "src/lib/utility.h"
#include "src/lib/validate.h"
#include "src/mympd_api/jukebox.h"
#include "src/mympd_api/sticker.h"
#include "src/mympd_api/timer.h"
#include "src/mympd_api/timer_handlers.h"
#include "src/mympd_api/trigger.h"
#include "src/mympd_client/errorhandler.h"
#include "src/mympd_client/jukebox.h"
#include "src/mympd_client/presets.h"
#include "src/mympd_client/shortcuts.h"
#include "src/mympd_client/tags.h"
#include "src/webserver/mg_user_data.h"
#include <inttypes.h>
#include <string.h>
Include dependency graph for settings.c:

Functions

static void set_invalid_value (struct t_json_parse_error *error, const char *path, sds key, sds value, const char *message)
 
static void set_invalid_field (struct t_json_parse_error *error, const char *path, sds key)
 
static void enable_set_conn_options (struct t_mympd_state *mympd_state)
 
bool settings_to_webserver (struct t_mympd_state *mympd_state)
 
bool mympd_api_settings_connection_save (const char *path, sds key, sds value, enum json_vtype vtype, validate_callback vcb, void *userdata, struct t_json_parse_error *error)
 
bool mympd_api_settings_view_save (struct t_mympd_state *mympd_state, sds view, sds mode, sds fields)
 
bool mympd_api_settings_set (const char *path, sds key, sds value, enum json_vtype vtype, validate_callback vcb, void *userdata, struct t_json_parse_error *error)
 
bool mympd_api_settings_partition_set (const char *path, sds key, sds value, enum json_vtype vtype, validate_callback vcb, void *userdata, struct t_json_parse_error *error)
 
bool mympd_api_settings_mpd_options_set (const char *path, sds key, sds value, enum json_vtype vtype, validate_callback vcb, void *userdata, struct t_json_parse_error *error)
 
void mympd_api_settings_statefiles_global_read (struct t_mympd_state *mympd_state)
 
void mympd_api_settings_statefiles_partition_read (struct t_partition_state *partition_state)
 
sds mympd_api_settings_get (struct t_mympd_state *mympd_state, struct t_partition_state *partition_state, sds buffer, unsigned request_id)
 

Detailed Description

myMPD settings API

Function Documentation

◆ enable_set_conn_options()

static void enable_set_conn_options ( struct t_mympd_state mympd_state)
static

Enables the set_conn_options flag for all partitions

Parameters
mympd_statepointer to central myMPD state

◆ mympd_api_settings_connection_save()

bool mympd_api_settings_connection_save ( const char *  path,
sds  key,
sds  value,
enum json_vtype  vtype,
validate_callback  vcb,
void *  userdata,
struct t_json_parse_error error 
)

Saves connection specific settings

Parameters
pathjsonrpc path
keysetting key
valuesetting value
vtypevalue type
vcbvalidation callback (unused)
userdatapointer to the t_mympd_state struct
errorpointer to t_json_parse_error
Returns
true on success, else false

◆ mympd_api_settings_get()

sds mympd_api_settings_get ( struct t_mympd_state mympd_state,
struct t_partition_state partition_state,
sds  buffer,
unsigned  request_id 
)

Prints all settings

Parameters
mympd_statepointer to mympd state
partition_statepointer to partition state
bufferalready allocated sds string to append the response
request_idjsonrpc request id
Returns
pointer to buffer

◆ mympd_api_settings_mpd_options_set()

bool mympd_api_settings_mpd_options_set ( const char *  path,
sds  key,
sds  value,
enum json_vtype  vtype,
validate_callback  vcb,
void *  userdata,
struct t_json_parse_error error 
)

Sets mpd options and jukebox settings

Parameters
pathjsonrpc path
keysetting key
valuesetting value
vtypevalue type
vcbvalidation callback (unused)
userdatapointer to the t_partition_state struct
errorpointer to t_json_parse_error
Returns
true on success, else false

◆ mympd_api_settings_partition_set()

bool mympd_api_settings_partition_set ( const char *  path,
sds  key,
sds  value,
enum json_vtype  vtype,
validate_callback  vcb,
void *  userdata,
struct t_json_parse_error error 
)

Saves partition settings

Parameters
pathjsonrpc path
keysetting key
valuesetting value
vtypevalue type
vcbvalidation callback (unused)
userdatapointer to partition state
errorpointer to t_json_parse_error
Returns
true on success, else false

◆ mympd_api_settings_set()

bool mympd_api_settings_set ( const char *  path,
sds  key,
sds  value,
enum json_vtype  vtype,
validate_callback  vcb,
void *  userdata,
struct t_json_parse_error error 
)

Saves settings

Parameters
pathjsonrpc path
keysetting key
valuesetting value
vtypevalue type
vcbvalidation callback (unused)
userdatapointer to central myMPD state
errorpointer to t_json_parse_error
Returns
true on success, else false

◆ mympd_api_settings_statefiles_global_read()

void mympd_api_settings_statefiles_global_read ( struct t_mympd_state mympd_state)

Reads the settings from the state files. If the state file does not exist, it is populated with the default value and created.

Parameters
mympd_statepointer to the t_mympd_state struct

◆ mympd_api_settings_statefiles_partition_read()

void mympd_api_settings_statefiles_partition_read ( struct t_partition_state partition_state)

Reads the partition specific settings from the state files. If the state file does not exist, it is populated with the default value and created.

Parameters
partition_statepointer to the t_partition_state struct

◆ mympd_api_settings_view_save()

bool mympd_api_settings_view_save ( struct t_mympd_state mympd_state,
sds  view,
sds  mode,
sds  fields 
)

Saves columns

Parameters
mympd_statepointer to the t_mympd_state struct
viewsave columns for this view
modemode for this view: table, grid
fieldsjson object with the columns
Returns
true on success, else false

◆ set_invalid_field()

static void set_invalid_field ( struct t_json_parse_error error,
const char *  path,
sds  key 
)
static

Helper function to set an error message

Parameters
errorpointer to t_json_parse_error
pathjsonrpc path
keysetting key

◆ set_invalid_value()

static void set_invalid_value ( struct t_json_parse_error error,
const char *  path,
sds  key,
sds  value,
const char *  message 
)
static

Private declarations

Privat functions Helper function to set an error message

Parameters
errorpointer to t_json_parse_error
pathjsonrpc path
keysetting key
valuesetting value
messagethe message to print, leave empty for generic invalid message

◆ settings_to_webserver()

bool settings_to_webserver ( struct t_mympd_state mympd_state)

Pushes some settings to the webserver thread

Parameters
mympd_statepointer to central myMPD state
Returns
true on success, else false