myMPD timer API
More...
#include "dist/sds/sds.h"
#include "src/lib/json/json_query.h"
#include "src/lib/mympd_state.h"
Go to the source code of this file.
|
| enum | timer_intervals { TIMER_ONE_SHOT_REMOVE = -1
, TIMER_ONE_SHOT_DISABLE = 0
} |
| |
|
| void | mympd_api_timer_timerlist_init (struct t_timer_list *l) |
| |
| void | mympd_api_timer_timerlist_clear (struct t_timer_list *l) |
| |
| bool | mympd_api_timer_check (int fd, struct t_timer_list *timer_list) |
| |
| bool | mympd_api_timer_save (struct t_partition_state *partition_state, struct t_timer_list *timer_list, int interval, unsigned timerid, struct t_timer_definition *timer_def, sds *error) |
| |
| bool | mympd_api_timer_add (struct t_timer_list *l, int timeout, int interval, timer_handler handler, unsigned timer_id, struct t_timer_definition *definition) |
| |
| bool | mympd_api_timer_replace (struct t_timer_list *l, int timeout, int interval, timer_handler handler, unsigned timer_id, struct t_timer_definition *definition) |
| |
| bool | mympd_api_timer_remove (struct t_timer_list *l, unsigned timer_id) |
| |
| bool | mympd_api_timer_toggle (struct t_timer_list *l, unsigned timer_id, sds *error) |
| |
| void * | mympd_api_timer_free_definition (struct t_timer_definition *timer_def) |
| |
| struct t_timer_definition * | mympd_api_timer_parse (sds str, const char *partition, struct t_json_parse_error *error) |
| |
| int | mympd_api_timer_calc_starttime (int start_hour, int start_minute, int interval) |
| |
| sds | mympd_api_timer_list (struct t_timer_list *timer_list, sds buffer, unsigned request_id, const char *partition) |
| |
| sds | mympd_api_timer_get (struct t_timer_list *timer_list, sds buffer, unsigned request_id, unsigned timer_id) |
| |
| bool | mympd_api_timer_file_read (struct t_timer_list *timer_list, sds workdir) |
| |
| bool | mympd_api_timer_file_save (struct t_timer_list *timer_list, sds workdir) |
| |
◆ timer_handler
Callback functions for timers
◆ timer_intervals
◆ mympd_api_timer_add()
Adds a timer with given timer_id
- Parameters
-
| l | timer list |
| timeout | seconds when timer will run (offset from now) |
| interval | reschedule timer interval |
| handler | timer callback function |
| timer_id | id of the timer |
| definition | pointer to timer definition (GUI) or NULL |
- Returns
- true on success, else false
◆ mympd_api_timer_calc_starttime()
| int mympd_api_timer_calc_starttime |
( |
int |
start_hour, |
|
|
int |
start_minute, |
|
|
int |
interval |
|
) |
| |
Calculates the offset from now for next start time for a timer
- Parameters
-
| start_hour | start hour |
| start_minute | start minute |
| interval | reschedule interval |
- Returns
- unix timestamp of next start
◆ mympd_api_timer_check()
| bool mympd_api_timer_check |
( |
int |
fd, |
|
|
struct t_timer_list * |
timer_list |
|
) |
| |
Checks the timer event and executes the callback function
- Parameters
-
| fd | fd with POLLIN event |
| timer_list | timer list |
- Returns
- true on success, else false
◆ mympd_api_timer_file_read()
| bool mympd_api_timer_file_read |
( |
struct t_timer_list * |
timer_list, |
|
|
sds |
workdir |
|
) |
| |
Reads the timer file and populates the timer list
- Parameters
-
| timer_list | timer list |
| workdir | working directory |
- Returns
- true on success, else false
◆ mympd_api_timer_file_save()
| bool mympd_api_timer_file_save |
( |
struct t_timer_list * |
timer_list, |
|
|
sds |
workdir |
|
) |
| |
Saves the timer list to the timer file on disc
- Parameters
-
| timer_list | timer list |
| workdir | working directory |
- Returns
- true on success, else false
◆ mympd_api_timer_free_definition()
Frees a timer definition
- Parameters
-
| timer_def | pointer to timer definition |
- Returns
- NULL
◆ mympd_api_timer_get()
| sds mympd_api_timer_get |
( |
struct t_timer_list * |
timer_list, |
|
|
sds |
buffer, |
|
|
unsigned |
request_id, |
|
|
unsigned |
timer_id |
|
) |
| |
Gets the timer with the given id as an jsonrpc response
- Parameters
-
| timer_list | timer list |
| buffer | already allocated sds string to append the response |
| request_id | jsonrpc request id |
| timer_id | timer id |
- Returns
- pointer to buffer
◆ mympd_api_timer_list()
| sds mympd_api_timer_list |
( |
struct t_timer_list * |
timer_list, |
|
|
sds |
buffer, |
|
|
unsigned |
request_id, |
|
|
const char * |
partition |
|
) |
| |
Gets the timer list as an jsonrpc response
- Parameters
-
| timer_list | timer list |
| buffer | already allocated sds string to append the response |
| request_id | jsonrpc request id |
| partition | mpd partition |
- Returns
- pointer to buffer
◆ mympd_api_timer_parse()
Parses a json object string to a timer definition.
- Parameters
-
| str | string to parse |
| partition | mpd partition |
| error | pointer to sds string to populate an error string |
- Returns
- pointer to timer_def or NULL on error
◆ mympd_api_timer_remove()
| bool mympd_api_timer_remove |
( |
struct t_timer_list * |
l, |
|
|
unsigned |
timer_id |
|
) |
| |
Removes a timer with given id
- Parameters
-
| l | timer list |
| timer_id | timer id to remove |
- Returns
- true on success, else false
◆ mympd_api_timer_replace()
Replaces a timer with given timer_id
- Parameters
-
| l | timer list |
| timeout | seconds when timer will run |
| interval | reschedule timer interval |
| handler | timer callback function |
| timer_id | id of the timer |
| definition | pointer to timer definition (GUI) or NULL |
- Returns
- true on success, else false
◆ mympd_api_timer_save()
Saves a new or existing timer
- Parameters
-
| partition_state | pointer to partition state |
| timer_list | pointer to timer list |
| interval | timer interval |
| timerid | the timerid |
| timer_def | pointer to populated timer definition |
| error | pointer to already allocated sds string to append an error message |
- Returns
- true on success, else false
◆ mympd_api_timer_timerlist_clear()
| void mympd_api_timer_timerlist_clear |
( |
struct t_timer_list * |
l | ) |
|
Clears the timer list
- Parameters
-
◆ mympd_api_timer_timerlist_init()
| void mympd_api_timer_timerlist_init |
( |
struct t_timer_list * |
l | ) |
|
Public functions Inits the timer list
- Parameters
-
| l | pointer to already allocated timer list |
◆ mympd_api_timer_toggle()
| bool mympd_api_timer_toggle |
( |
struct t_timer_list * |
l, |
|
|
unsigned |
timer_id, |
|
|
sds * |
error |
|
) |
| |
Toggles the enabled state of a timer
- Parameters
-
| l | timer list |
| timer_id | timer id to toggle |
| error | pointer to already allocated sds string to append an error message |
- Returns
- true on success, else false