23 #ifndef _ASTERISK_APP_H 24 #define _ASTERISK_APP_H 36 #if defined(__cplusplus) || defined(c_plusplus) 107 #define AST_IVR_FLAG_AUTORESTART (1 << 0) 109 #define AST_IVR_DECLARE_MENU(holder, title, flags, foo...) \ 110 static struct ast_ivr_option __options_##holder[] = foo;\ 111 static struct ast_ivr_menu holder = { title, flags, __options_##holder } 185 struct ast_channel *macro_chan,
const char *macro_name,
const char *macro_args);
445 const char *
context,
const char *folder,
int descending,
476 const char *oldfolder,
const char *old_msg_ids[],
const char *newfolder);
493 const char *folder,
const char *msgs[]);
515 const char *from_folder,
const char *to_mailbox,
const char *to_context,
516 const char *to_folder,
size_t num_msgs,
const char *msg_ids[],
int delete_old);
536 #define VM_MODULE_VERSION 2 588 #define ast_vm_register(vm_table) __ast_vm_register(vm_table, AST_MODULE_SELF) 599 #ifdef TEST_FRAMEWORK 615 #define VM_GREETER_MODULE_VERSION 1 657 #define ast_vm_greeter_register(vm_table) __ast_vm_greeter_register(vm_table, AST_MODULE_SELF) 669 #ifdef TEST_FRAMEWORK 721 int ast_app_inboxcount2(
const char *mailboxes,
int *urgentmsgs,
int *newmsgs,
int *oldmsgs);
773 int combine_INBOX_and_OLD);
800 const char *oldfolder,
801 const char *old_msg_ids[],
802 const char *newfolder);
840 const char *from_context,
841 const char *from_folder,
842 const char *to_mailbox,
843 const char *to_context,
844 const char *to_folder,
846 const char *msg_ids[],
869 #ifdef TEST_FRAMEWORK 954 unsigned int durationkp,
unsigned int durationst,
int is_external);
1031 const char *fwd,
const char *rev,
const char *
stop,
const char *
suspend,
1032 const char *restart,
int skipms,
const char *lang,
long *offsetms);
1060 const char *restart,
1109 int ast_play_and_record_full(
struct ast_channel *chan,
const char *playfile,
const char *recordfile,
int maxtime_sec,
const char *fmt,
int *duration,
int *sound_duration,
int beep,
int silencethreshold,
int maxsilence_ms,
const char *path,
const char *acceptdtmf,
const char *canceldtmf,
int skip_confirmation_sound,
enum ast_record_if_exists if_exists);
1131 int ast_play_and_record(
struct ast_channel *chan,
const char *playfile,
const char *recordfile,
int maxtime_sec,
const char *fmt,
int *duration,
int *sound_duration,
int silencethreshold,
int maxsilence_ms,
const char *path);
1232 #define AST_APP_ARG(name) char *name 1249 #define AST_DECLARE_APP_ARGS(name, arglist) AST_DEFINE_APP_ARGS_TYPE(argtype_##name, arglist) name = { 0, } 1266 #define AST_DEFINE_APP_ARGS_TYPE(type, arglist) \ 1267 struct __subtype_##type { arglist }; \ 1269 unsigned int argc; \ 1271 char *argv[sizeof(struct __subtype_##type) / sizeof(char*)]; \ 1272 struct { arglist }; \ 1285 #define AST_STANDARD_APP_ARGS(args, parse) \ 1286 args.argc = __ast_app_separate_args(parse, ',', 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0]))) 1287 #define AST_STANDARD_RAW_ARGS(args, parse) \ 1288 args.argc = __ast_app_separate_args(parse, ',', 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0]))) 1300 #define AST_NONSTANDARD_APP_ARGS(args, parse, sep) \ 1301 args.argc = __ast_app_separate_args(parse, sep, 1, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0]))) 1302 #define AST_NONSTANDARD_RAW_ARGS(args, parse, sep) \ 1303 args.argc = __ast_app_separate_args(parse, sep, 0, args.argv, ((sizeof(args) - offsetof(typeof(args), argv)) / sizeof(args.argv[0]))) 1321 #define ast_app_separate_args(a,b,c,d) __ast_app_separate_args(a,b,1,c,d) 1343 #define BEGIN_OPTIONS { 1344 #define END_OPTIONS } 1393 #define AST_APP_OPTIONS(holder, options...) \ 1394 static const struct ast_app_option holder[128] = options 1402 #define AST_APP_OPTION(option, flagno) \ 1403 [option] = { .flag = flagno } 1413 #define AST_APP_OPTION_ARG(option, flagno, argno) \ 1414 [option] = { .flag = flagno, .arg_index = argno + 1 } 1452 int ast_record_review(
struct ast_channel *chan,
const char *playfile,
const char *recordfile,
int maxtime,
const char *fmt,
int *duration,
const char *path);
1533 #if defined(__cplusplus) || defined(c_plusplus)
void ast_install_stack_functions(const struct ast_app_stack_funcs *funcs)
Set stack application function callbacks.
unsigned int module_version
The version of this function table.
int ast_vm_is_registered(void)
Determine if a voicemail provider is registered.
int ast_vm_greeter_is_registered(void)
Determine if a voicemail greeter provider is registered.
int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration)
Send a string of DTMF digits to a channel.
static char exten[AST_MAX_EXTENSION]
Main Channel structure associated with a channel.
struct ast_module * module
The module for the voicemail provider.
static const struct ast_vm_functions vm_table
int __ast_vm_register(const struct ast_vm_functions *vm_table, struct ast_module *module)
Set voicemail function callbacks.
void ast_set_lock_type(enum AST_LOCK_TYPE type)
Set the type of locks used by ast_lock_path()
char * ast_get_encoded_str(const char *stream, char *result, size_t result_len)
Decode a stream of encoded control or extended ASCII characters.
void ast_unreplace_sigchld(void)
Restore the SIGCHLD handler.
String manipulation functions.
int() ast_vm_msg_move_fn(const char *mailbox, const char *context, size_t num_msgs, const char *oldfolder, const char *old_msg_ids[], const char *newfolder)
Move messages from one folder to another.
struct ast_group_info * ast_app_group_list_head(void)
Get the head of the group count list.
const char * ast_app_expand_sub_args(struct ast_channel *chan, const char *args)
Add missing context/exten to subroutine argument string.
int ast_app_sayname(struct ast_channel *chan, const char *mailbox_id)
Play a recorded user name for the mailbox to the specified channel.
int ast_control_streamfile_lang(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *suspend, const char *restart, int skipms, const char *lang, long *offsetms)
Version of ast_control_streamfile() which allows the language of the media file to be specified...
int() ast_sayname_fn(struct ast_channel *chan, const char *mailbox_id)
Play a recorded user name for the mailbox to the specified channel.
int ast_app_run_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_name, const char *macro_args)
Run a macro on a channel, placing an optional second channel into autoservice.
ast_inboxcount_fn * inboxcount
void ast_install_vm_test_functions(ast_vm_test_create_user_fn *vm_test_create_user_func, ast_vm_test_destroy_user_fn *vm_test_destroy_user_func)
unsigned int __ast_app_separate_args(char *buf, char delim, int remove_chars, char **array, int arraylen)
Separate a string into arguments in an array.
Stasis Message Bus API. See Stasis Message Bus API for detailed documentation.
void ast_uninstall_vm_test_functions(void)
Voicemail greeter function table definition.
static struct stasis_rest_handlers mailboxes
REST handler for /api-docs/mailboxes.json.
ast_vm_mailbox_snapshot_destroy_fn * mailbox_snapshot_destroy
int() ast_vm_msg_remove_fn(const char *mailbox, const char *context, size_t num_msgs, const char *folder, const char *msgs[])
Remove/delete messages from a mailbox folder.
struct stasis_topic * ast_queue_topic_all(void)
Get the Stasis Message Bus API topic for queue messages.
void ast_close_fds_above_n(int n)
Common routine for child processes, to close all fds prior to exec(2)
int ast_control_tone(struct ast_channel *chan, const char *tone)
Controls playback of a tone.
void ast_app_options2str64(const struct ast_app_option *options, struct ast_flags64 *flags, char *buf, size_t len)
Given a list of options array, return an option string based on passed flags.
void ast_vm_unregister(const char *module_name)
Unregister the specified voicemail provider.
int ast_vm_test_destroy_user(const char *context, const char *mailbox)
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
int ast_play_and_prepend(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime_sec, char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence_ms)
Record a file based on input frm a channel. Recording is performed in 'prepend' mode which works a li...
int() ast_vm_msg_play_fn(struct ast_channel *chan, const char *mailbox, const char *context, const char *folder, const char *msg_num, ast_vm_msg_play_cb *cb)
Play a voicemail msg back on a channel.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
int ast_unlock_path(const char *path)
Unlock a path.
int ast_control_streamfile(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *pause, const char *restart, int skipms, long *offsetms)
Stream a file with fast forward, pause, reverse, restart.
Definitions to aid in the use of thread local storage.
Structure used to handle a large number of boolean flags == used only in app_dial?
int ast_str_get_encoded_str(struct ast_str **str, int maxlen, const char *stream)
Decode a stream of encoded control or extended ASCII characters.
int() ast_vm_msg_forward_fn(const char *from_mailbox, const char *from_context, const char *from_folder, const char *to_mailbox, const char *to_context, const char *to_folder, size_t num_msgs, const char *msg_ids[], int delete_old)
forward a message from one mailbox to another.
void() ast_vm_msg_play_cb(struct ast_channel *chan, const char *playfile, int duration)
Voicemail playback callback function definition.
char * ast_read_textfile(const char *file)
Read a file into asterisk.
def from_mailbox(key, val, section, pjsip, nmapped)
int ast_app_group_update(struct ast_channel *oldchan, struct ast_channel *newchan)
Update all group counting for a channel to a new one.
int() ast_messagecount_fn(const char *mailbox_id, const char *folder)
Gets the number of messages that exist in a mailbox folder.
int ast_linear_stream(struct ast_channel *chan, const char *filename, int fd, int allowoverride)
Stream a filename (or file descriptor) as a generator.
AST_THREADSTORAGE_EXTERNAL(ast_str_thread_global_buf)
int ast_record_review(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, const char *path)
Allow to record message and have a review option.
enum AST_LOCK_RESULT ast_lock_path(const char *path)
Lock a filesystem path.
static char mailbox[AST_MAX_MAILBOX_UNIQUEID]
int ast_app_inboxcount2(const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Determine number of urgent/new/old messages in a mailbox.
ast_has_voicemail_fn * has_voicemail
int ast_app_getdata_full(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout, int audiofd, int ctrlfd)
Full version with audiofd and controlfd. NOTE: returns '2' on ctrlfd available, not '1' like other fu...
int ast_ivr_menu_run(struct ast_channel *c, struct ast_ivr_menu *menu, void *cbdata)
Runs an IVR menu.
int ast_vm_msg_move(const char *mailbox, const char *context, size_t num_msgs, const char *oldfolder, const char *old_msg_ids[], const char *newfolder)
Move messages from one folder to another.
A structure to hold the description of an application 'option'.
ast_vm_mailbox_snapshot_create_fn * mailbox_snapshot_create
int() ast_inboxcount_fn(const char *mailboxes, int *newmsgs, int *oldmsgs)
Gets the number of messages that exist for the mailbox list.
void ast_safe_fork_cleanup(void)
Common routine to cleanup after fork'ed process is complete (if reaping was stopped) ...
static int silencethreshold
#define AST_STRING_FIELD(name)
Declare a string field.
int ast_play_and_wait(struct ast_channel *chan, const char *fn)
Play a stream and wait for a digit, returning the digit that was pressed.
int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence_ms, const char *path, const char *acceptdtmf, const char *canceldtmf, int skip_confirmation_sound, enum ast_record_if_exists if_exists)
Record a file based on input from a channel This function will play "auth-thankyou" upon successful r...
A set of macros to manage forward-linked lists.
int ast_get_encoded_char(const char *stream, char *result, size_t *consumed)
Decode an encoded control or extended ASCII character.
AST_LIST_HEAD_NOLOCK(contactliststruct, contact)
int ast_app_exec_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const char *macro_args)
Run a macro on a channel, placing an optional second channel into autoservice.
const char *() ast_vm_index_to_foldername_fn(int id)
Convert the mailbox folder id to a folder name.
ast_copy_recording_to_vm_fn * copy_recording_to_vm
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
void ast_replace_sigchld(void)
Replace the SIGCHLD handler.
int ast_vm_msg_play(struct ast_channel *chan, const char *mailbox, const char *context, const char *folder, const char *msg_num, ast_vm_msg_play_cb *cb)
Play a voicemail msg back on a channel.
struct ast_vm_mailbox_snapshot * ast_vm_mailbox_snapshot_destroy(struct ast_vm_mailbox_snapshot *mailbox_snapshot)
destroy a snapshot
int() ast_inboxcount2_fn(const char *mailboxes, int *urgentmsgs, int *newmsgs, int *oldmsgs)
Gets the number of messages that exist for the mailbox list.
int ast_app_parse_options64(const struct ast_app_option *options, struct ast_flags64 *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
int ast_vm_msg_remove(const char *mailbox, const char *context, size_t num_msgs, const char *folder, const char *msgs[])
Remove/delete messages from a mailbox folder.
struct ast_module * module
The module for the voicemail greeter provider.
void ast_vm_greeter_unregister(const char *module_name)
Unregister the specified voicemail greeter provider.
struct ast_vm_mailbox_snapshot *() ast_vm_mailbox_snapshot_destroy_fn(struct ast_vm_mailbox_snapshot *mailbox_snapshot)
destroy a snapshot
int() ast_has_voicemail_fn(const char *mailboxes, const char *folder)
Determines if the given folder has messages.
uint64_t flag
The flag bit that represents this option.
int() ast_ivr_callback(struct ast_channel *chan, char *option, void *cbdata)
Callback function for IVR.
int __ast_vm_greeter_register(const struct ast_vm_greeter_functions *vm_table, struct ast_module *module)
Set voicemail greeter function callbacks.
ast_vm_msg_move_fn * msg_move
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
int ast_safe_system(const char *s)
Safely spawn an OS shell command while closing file descriptors.
struct ast_vm_mailbox_snapshot * ast_vm_mailbox_snapshot_create(const char *mailbox, const char *context, const char *folder, int descending, enum ast_vm_snapshot_sort_val sort_val, int combine_INBOX_and_OLD)
Create a snapshot of a mailbox which contains information about every msg.
void() ast_waitstream_fr_cb(struct ast_channel *chan, long ms, enum ast_waitstream_fr_cb_values val)
callback used during dtmf controlled file playback to indicate location of playback in a file after r...
static int array(struct ast_channel *chan, const char *cmd, char *var, const char *value)
const char * module_name
The name of the module that provides the voicemail greeter functionality.
int() ast_vm_test_destroy_user_fn(const char *context, const char *user)
const char * ast_vm_index_to_foldername(int id)
Return name of folder, given an id.
Stack applications callback functions.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ast_mf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration, unsigned int durationkp, unsigned int durationst, int is_external)
Send a string of MF digits to a channel.
int ast_safe_fork(int stop_reaper)
Common routine to safely fork without a chance of a signal handler firing badly in the child...
int ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int *sound_duration, int silencethreshold, int maxsilence_ms, const char *path)
Record a file based on input from a channel. Use default accept and cancel DTMF. This function will p...
int() ast_vm_test_create_user_fn(const char *context, const char *user)
ast_vm_msg_forward_fn * msg_forward
void ast_vm_test_swap_table_out(void)
Used after ast_vm_test_swap_table_in to restore the original set of voicemail functions.
int ast_app_run_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_location, const char *sub_args, int ignore_hangup)
Run a subroutine on a channel, placing an optional second channel into autoservice.
ast_vm_msg_play_fn * msg_play
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
int ast_app_group_list_unlock(void)
Unlock the group count list.
int() ast_copy_recording_to_vm_fn(struct ast_vm_recording_data *vm_rec_data)
Creates a voicemail based on a specified file to a mailbox.
int ast_app_group_split_group(const char *data, char *group, int group_max, char *category, int category_max)
Split a group string into group and category, returning a default category if none is provided...
int ast_vm_msg_forward(const char *from_mailbox, const char *from_context, const char *from_folder, const char *to_mailbox, const char *to_context, const char *to_folder, size_t num_msgs, const char *msg_ids[], int delete_old)
forward a message from one mailbox to another.
static void suspend(struct cc_core_instance *core_instance)
int ast_app_group_match_get_count(const char *groupmatch, const char *category)
Get the current channel count of all groups that match the specified pattern and category.
int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout)
Plays a stream and gets DTMF data from a channel.
unsigned int arg_index
The index of the entry in the arguments array that should be used for this option's argument...
structure to hold users read from users.conf
Structure used to handle boolean flags.
int ast_app_has_voicemail(const char *mailboxes, const char *folder)
Determine if a given mailbox has any voicemail If folder is NULL, defaults to "INBOX". If folder is "INBOX", includes the number of messages in the "Urgent" folder.
int ast_app_messagecount(const char *mailbox_id, const char *folder)
Get the number of messages in a given mailbox folder.
const char * module_name
The name of the module that provides the voicemail functionality.
Structure used for ast_copy_recording_to_vm in order to cleanly supply data needed for making the rec...
int ast_app_group_list_rdlock(void)
Read Lock the group count list.
struct ast_vm_mailbox_snapshot *() ast_vm_mailbox_snapshot_create_fn(const char *user, const char *context, const char *folder, int descending, enum ast_vm_snapshot_sort_val sort_val, int combine_INBOX_and_OLD)
Create a snapshot of a mailbox which contains information about every msg.
ast_inboxcount2_fn * inboxcount2
int ast_app_dtget(struct ast_channel *chan, const char *context, char *collect, size_t size, int maxlen, int timeout)
Present a dialtone and collect a certain length extension.
ast_vm_msg_remove_fn * msg_remove
int ast_app_exec_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_args, int ignore_hangup)
Run a subroutine on a channel, placing an optional second channel into autoservice.
unsigned int module_version
The version of this function table.
int ast_control_streamfile_w_cb(struct ast_channel *chan, const char *file, const char *fwd, const char *rev, const char *stop, const char *pause, const char *restart, int skipms, long *offsetms, ast_waitstream_fr_cb cb)
Stream a file with fast forward, pause, reverse, restart.
ast_messagecount_fn * messagecount
int ast_vm_test_create_user(const char *context, const char *mailbox)
static struct ast_str * prompt
int ast_app_group_discard(struct ast_channel *chan)
Discard all group counting for a channel.
static char context[AST_MAX_CONTEXT]
int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen defunit)
Common routine to parse time lengths, with optional time unit specifier.
struct stasis_topic * ast_queue_topic(const char *queuename)
Get the Stasis Message Bus API topic for queue messages for a particular queue name.
void ast_vm_test_swap_table_in(const struct ast_vm_functions *vm_table)
Swap out existing voicemail functions with a temporary set of functions for use with unit tests...
Voicemail function table definition.
AST_LOCK_TYPE
Type of locking to use in ast_lock_path / ast_unlock_path.
int ast_safe_execvp(int dualfork, const char *file, char *const argv[])
Safely spawn an external program while closing file descriptors.
int ast_app_copy_recording_to_vm(struct ast_vm_recording_data *vm_rec_data)
param[in] vm_rec_data Contains data needed to make the recording. retval 0 voicemail successfully cre...
int ast_app_group_set_channel(struct ast_channel *chan, const char *data)
Set the group for a channel, splitting the provided data into group and category, if specified...
void ast_dtmf_stream_external(struct ast_channel *chan, const char *digits, int between, unsigned int duration)
Send a string of DTMF digits to a channel from an external thread.
int ast_app_group_list_wrlock(void)
Write Lock the group count list.
int app_init(void)
Initialize the application core.
int ast_app_group_get_count(const char *group, const char *category)
Get the current channel count of the specified group and category.
ast_vm_index_to_foldername_fn * index_to_foldername
int ast_app_inboxcount(const char *mailboxes, int *newmsgs, int *oldmsgs)
Determine number of new/old messages in a mailbox.