|
myMPD
Internal API documentation
|
myMPD timer API More...
#include "compile_time.h"#include "src/mympd_api/timer.h"#include "src/lib/datetime.h"#include "src/lib/filehandler.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/sds_extras.h"#include "src/lib/state_files.h"#include "src/lib/timer.h"#include "src/mympd_api/timer_handlers.h"#include <errno.h>#include <stdbool.h>#include <string.h>
Functions | |
| static void | mympd_api_timer_free_node (struct t_list_node *node) |
| static struct t_list_node * | get_timer_from_fd (struct t_timer_list *l, int fd) |
| static sds | print_timer_node (sds buffer, unsigned timer_id, struct t_timer_node *current) |
| void | mympd_api_timer_timerlist_init (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_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_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_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_timerlist_clear (struct t_timer_list *l) |
| 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) |
myMPD timer API
|
static |
Gets the timer associated with the fd
| l | timer list |
| fd | timer fd |
| 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 | ||
| ) |
Adds a timer with given timer_id
| 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 |
| 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
| start_hour | start hour |
| start_minute | start minute |
| interval | reschedule interval |
| bool mympd_api_timer_check | ( | int | fd, |
| struct t_timer_list * | timer_list | ||
| ) |
Checks the timer event and executes the callback function
| fd | fd with POLLIN event |
| timer_list | timer list |
| bool mympd_api_timer_file_read | ( | struct t_timer_list * | timer_list, |
| sds | workdir | ||
| ) |
Reads the timer file and populates the timer list
| timer_list | timer list |
| workdir | working directory |
| bool mympd_api_timer_file_save | ( | struct t_timer_list * | timer_list, |
| sds | workdir | ||
| ) |
Saves the timer list to the timer file on disc
| timer_list | timer list |
| workdir | working directory |
| void * mympd_api_timer_free_definition | ( | struct t_timer_definition * | timer_def | ) |
Frees a timer definition
| timer_def | pointer to timer definition |
|
static |
Private definitions
Private functions Frees a timer node
| node | timer node to free |
| 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
| timer_list | timer list |
| buffer | already allocated sds string to append the response |
| request_id | jsonrpc request id |
| timer_id | timer id |
| 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
| timer_list | timer list |
| buffer | already allocated sds string to append the response |
| request_id | jsonrpc request id |
| partition | mpd partition |
| struct t_timer_definition * mympd_api_timer_parse | ( | sds | str, |
| const char * | partition, | ||
| struct t_json_parse_error * | error | ||
| ) |
Parses a json object string to a timer definition.
| str | string to parse |
| partition | mpd partition |
| error | pointer to sds string to populate an error string |
| bool mympd_api_timer_remove | ( | struct t_timer_list * | l, |
| unsigned | timer_id | ||
| ) |
Removes a timer with given id
| l | timer list |
| timer_id | timer id to remove |
| 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 | ||
| ) |
Replaces a timer with given timer_id
| 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 |
| 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 | ||
| ) |
Saves a new or existing timer
| 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 |
| void mympd_api_timer_timerlist_clear | ( | struct t_timer_list * | l | ) |
Clears the timer list
| l | timer list |
| void mympd_api_timer_timerlist_init | ( | struct t_timer_list * | l | ) |
Public functions Inits the timer list
| l | pointer to already allocated timer list |
| bool mympd_api_timer_toggle | ( | struct t_timer_list * | l, |
| unsigned | timer_id, | ||
| sds * | error | ||
| ) |
Toggles the enabled state of a timer
| l | timer list |
| timer_id | timer id to toggle |
| error | pointer to already allocated sds string to append an error message |
|
static |
Prints a timer node as a json object string
| buffer | already allocated sds string to append the response |
| timer_id | the timer id |
| current | timer node to print |