237#define PARK_AND_ANNOUNCE_APPLICATION "ParkAndAnnounce"
269 ast_log(
LOG_ERROR,
"No duration value provided for the timeout ('t') option.\n");
273 if (sscanf(timeout_arg,
"%d",
var) != 1 || *
var < 0) {
274 ast_log(
LOG_ERROR,
"Duration value provided for timeout ('t') option must be 0 or greater.\n");
281static int park_app_parse_data(
const char *data,
int *disable_announce,
int *use_ringing,
int *randomize,
int *time_limit,
282 char **comeback_override,
char **lot_name,
char **musicclass)
310 if (disable_announce) {
311 *disable_announce = 1;
354 .
type =
"park entry data",
375 const char *attended_transfer;
376 const char *blind_transfer;
385 if (!(park_datastore =
ast_calloc(1,
sizeof(*park_datastore)))) {
389 datastore->
data = park_datastore;
405 attended_transfer =
NULL;
411 ast_verb(4,
"Setting Parker dial string to %s from %s value\n",
413 attended_transfer ?
"ATTENDEDTRANSFER" :
"BLINDTRANSFER");
453 data = datastore->
data;
458 data_copy =
ast_calloc(1,
sizeof(*data_copy));
493 const char *lot_name,
const char *comeback_override,
const char *musicclass,
494 int use_ringing,
int randomize,
int time_limit,
int silence_announcements)
523 if (!parking_bridge) {
534 silence_announcements);
535 return parking_bridge;
539 const char *lot_name,
const char *comeback_override,
540 int use_ringing,
int randomize,
int time_limit,
int silence_announcements)
542 return park_common_setup2(parkee, parker, lot_name, comeback_override,
NULL, use_ringing, randomize, time_limit, silence_announcements);
546 int *silence_announcements)
557 park_app_parse_data(
app_data, silence_announcements, &use_ringing, &randomize, &time_limit, &comeback_override, &lot_name_app_arg, &musicclass);
560 return park_common_setup2(parkee, parker, lot_name_app_arg, comeback_override, musicclass, use_ringing,
561 randomize, time_limit, silence_announcements ? *silence_announcements : 0);
571 int silence_announcements = 0;
585 if (!silence_announcements && !blind_transfer) {
596 if (!silence_announcements && !blind_transfer) {
630 int target_space = -1;
633 const char *lot_name;
649 lot_name =
args.lot_name;
666 if (sscanf(
args.parking_space,
"%d", &target_space) != 1 || target_space < 0) {
668 ast_log(
LOG_ERROR,
"value '%s' for parking_space argument is invalid. Must be an integer greater than 0.\n",
args.parking_space);
686 if (!retrieval_bridge) {
745 if (!(pa_data =
ast_calloc(1,
sizeof(*pa_data)))) {
788 if (varname[0] ==
'_') {
790 if (varname[1] ==
'_') {
806 ast_debug(1,
"Inheriting variable %s from %s.\n",
829 dial_tech =
strsep(&dial_string,
"/");
830 ast_verb(3,
"Dial Tech,String: (%s,%s)\n", dial_tech, dial_string);
834 goto announce_cleanup;
838 snprintf(
buf,
sizeof(
buf),
"%d", parkingspace);
852 goto announce_cleanup;
855 ast_verb(4,
"Announce Template: %s\n", announce_string);
857 for (cur_announce =
strsep(&announce_string,
":"); cur_announce; cur_announce =
strsep(&announce_string,
":")) {
858 ast_verb(4,
"Announce:%s\n", cur_announce);
859 if (!strcmp(cur_announce,
"PARKED")) {
916 int silence_announcements = 1;
932 ast_log(
LOG_ERROR,
"ParkAndAnnounce has required arguments. No arguments were provided.\n");
941 ast_log(
LOG_ERROR,
"ParkAndAnnounce requires the announce_template argument.\n");
951 if (!strchr(
args.dial,
'/')) {
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_calloc(num, len)
A wrapper for calloc()
int ast_bridge_join(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, struct ast_bridge_tech_optimizations *tech_args, enum ast_bridge_join_flags flags)
Join a channel to a bridge (blocking)
int ast_bridge_destroy(struct ast_bridge *bridge, int cause)
Destroy a bridge.
@ AST_BRIDGE_JOIN_PASS_REFERENCE
int ast_bridge_move(struct ast_bridge *dst_bridge, struct ast_bridge *src_bridge, struct ast_channel *chan, struct ast_channel *swap, int attempt_recovery)
Move a channel from one bridge to another.
Basic bridge subclass API.
struct ast_bridge * ast_bridge_basic_new(void)
Create a new basic class bridge.
int ast_bridge_features_init(struct ast_bridge_features *features)
Initialize bridge features structure.
void ast_bridge_features_cleanup(struct ast_bridge_features *features)
Clean up the contents of a bridge features structure.
int ast_channel_set_bridge_role_option(struct ast_channel *channel, const char *role_name, const char *option, const char *value)
Set a role option on a channel.
static struct stasis_forward * parking_subscription
Our subscription for parking.
const char * ast_channel_name(const struct ast_channel *chan)
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
struct varshead * ast_channel_varshead(struct ast_channel *chan)
#define ast_channel_lock(chan)
struct ast_channel * __ast_request_and_dial(const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
Request a channel of a given type, with data as optional information used by the low level module and...
const char * ast_channel_uniqueid(const struct ast_channel *chan)
void ast_channel_name_to_dial_string(char *channel_name)
Removes the trailing identifiers from a channel name string.
@ AST_SOFTHANGUP_ASYNCGOTO
const char * ast_channel_language(const struct ast_channel *chan)
int ast_channel_softhangup_internal_flag(struct ast_channel *chan)
#define ast_channel_cleanup(c)
Cleanup a channel reference.
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
int ast_answer(struct ast_channel *chan)
Answer a channel.
#define ast_channel_unlock(chan)
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
ast_channel_state
ast_channel states
const char * ast_var_full_name(const struct ast_var_t *var)
const char * ast_var_value(const struct ast_var_t *var)
Configuration option-handling.
#define ast_datastore_alloc(info, uid)
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Call Parking and Pickup API Includes code and algorithms from the Zapata library.
@ AST_FEATURE_FLAG_BYCALLER
int ast_stopstream(struct ast_channel *c)
Stops a stream.
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char *digits)
stream file until digit If the file name is non-empty, try to play it.
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
struct stasis_topic * ast_parking_topic(void)
accessor for the parking stasis topic
struct stasis_message_type * ast_parked_call_type(void)
accessor for the parked call stasis message type
struct stasis_message_type * stasis_subscription_change_type(void)
Gets the message type for subscription change notices.
struct ast_channel_snapshot * ast_channel_snapshot_create(struct ast_channel *chan)
Generate a snapshot of the channel state. This is an ao2 object, so ao2_cleanup() to deallocate.
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
#define AST_APP_OPTION_ARG(option, flagno, argno)
Declares an application option that accepts an argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
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.
char * strsep(char **str, const char *delims)
Configuration File Parser.
#define ast_variable_new(name, value, filename)
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
#define ast_debug(level,...)
Log a DEBUG message.
#define ast_verb(level,...)
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
#define SCOPED_CHANNELLOCK(varname, chan)
scoped lock specialization for channels.
Asterisk module definitions.
int ast_unregister_application(const char *app)
Unregister an application.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define PARK_APPLICATION
The default parking application that Asterisk expects.
static int setup_park_common_datastore(struct ast_channel *parkee, const char *parker_uuid, const char *comeback_override, int randomize, int time_limit, int silence_announce)
void park_common_datastore_free(struct park_common_datastore *datastore)
Free a park common datastore struct.
static void park_announce_update_cb(void *data, struct stasis_subscription *sub, struct stasis_message *message)
struct ast_bridge * park_common_setup(struct ast_channel *parkee, struct ast_channel *parker, const char *lot_name, const char *comeback_override, int use_ringing, int randomize, int time_limit, int silence_announcements)
Setup a parked call on a parking bridge without needing to parse appdata.
void unload_parking_applications(void)
Unregister parking applications.
static void inherit_channel_vars_from_id(struct outgoing_helper *oh, const char *channel_id)
int load_parking_applications(void)
Register parking applications.
static void park_announce_subscription_data_destroy(void *data)
static void park_common_datastore_destroy(void *data)
static int park_app_exec(struct ast_channel *chan, const char *data)
static int park_and_announce_app_exec(struct ast_channel *chan, const char *data)
static int park_app_parse_data(const char *data, int *disable_announce, int *use_ringing, int *randomize, int *time_limit, char **comeback_override, char **lot_name, char **musicclass)
static struct park_announce_subscription_data * park_announce_subscription_data_create(const char *parkee_uuid, const char *dial_string, const char *announce_string)
static void wipe_park_common_datastore(struct ast_channel *chan)
struct park_common_datastore * get_park_common_datastore_copy(struct ast_channel *parkee)
Get a copy of the park_common_datastore from a channel that is being parked.
struct ast_bridge * park_application_setup(struct ast_channel *parkee, struct ast_channel *parker, const char *app_data, int *silence_announcements)
Function to prepare a channel for parking by determining which parking bridge should be used,...
static const struct ast_datastore_info park_common_info
static const struct ast_app_option park_opts[128]
static int parked_call_app_exec(struct ast_channel *chan, const char *data)
@ MUXFLAG_COMEBACK_OVERRIDE
@ MUXFLAG_TIMEOUT_OVERRIDE
#define PARK_AND_ANNOUNCE_APPLICATION
static struct ast_bridge * park_common_setup2(struct ast_channel *parkee, struct ast_channel *parker, const char *lot_name, const char *comeback_override, const char *musicclass, int use_ringing, int randomize, int time_limit, int silence_announcements)
static void announce_to_dial(char *dial_string, char *announce_string, int parkingspace, struct ast_channel_snapshot *parkee_snapshot)
static int apply_option_timeout(int *var, char *timeout_arg)
void parked_call_retrieve_enable_features(struct ast_channel *chan, struct parking_lot *lot, int recipient_mode)
Apply features based on the parking lot feature options.
int parking_channel_set_roles(struct ast_channel *chan, struct parking_lot *lot, int force_ringing)
Set necessary bridge roles on a channel that is about to enter a parking lot.
struct parked_user * parking_lot_retrieve_parked_user(struct parking_lot *lot, int target)
Determine if there is a parked user in a parking space and pull it from the parking lot if there is.
struct ast_bridge * parking_lot_get_bridge(struct parking_lot *lot)
Get a reference to a parking lot's bridge. If it doesn't exist, create it and get a reference.
void publish_parked_call_failure(struct ast_channel *parkee)
Publish a stasis parked call message for the channel indicating failure to park.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
struct stasis_forward * sub
Call Parking Resource Internal API.
#define PARKED_CALL_APPLICATION
struct parking_lot * parking_create_dynamic_lot(const char *name, struct ast_channel *chan)
Create a dynamic parking lot.
const char * find_channel_parking_lot_name(struct ast_channel *chan)
Find parking lot name from channel.
struct parking_lot * parking_lot_find_by_name(const char *lot_name)
Find a parking lot based on its name.
Say numbers and dates (maybe words one day too)
int ast_say_digits(struct ast_channel *chan, int num, const char *ints, const char *lang)
says digits
struct stasis_message_type * stasis_message_type(const struct stasis_message *msg)
Get the message type for a stasis_message.
@ STASIS_SUBSCRIPTION_FILTER_SELECTIVE
int stasis_subscription_accept_message_type(struct stasis_subscription *subscription, const struct stasis_message_type *type)
Indicate to a subscription that we are interested in a message type.
int stasis_subscription_set_filter(struct stasis_subscription *subscription, enum stasis_subscription_message_filter filter)
Set the message type filtering level on a subscription.
#define stasis_subscribe_pool(topic, callback, data)
void * stasis_message_data(const struct stasis_message *msg)
Get the data contained in a message.
int stasis_subscription_final_message(struct stasis_subscription *sub, struct stasis_message *msg)
Determine whether a message is the final message to be received on a subscription.
struct stasis_subscription * stasis_unsubscribe(struct stasis_subscription *subscription)
Cancel a subscription.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Structure that contains features information.
Structure that contains information about a bridge.
const ast_string_field uniqueid
const ast_string_field number
const ast_string_field name
Structure representing a snapshot of channel state.
struct ast_channel_snapshot_base * base
struct ast_channel_snapshot_caller * caller
Main Channel structure associated with a channel.
Structure for a data store type.
Structure for a data store object.
Structure used to handle boolean flags.
A parked call message payload.
unsigned int parkingspace
struct ast_channel_snapshot * parkee
enum ast_parked_call_event_type event_type
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next
struct ast_variable * vars
char * parker_dial_string
#define ast_test_flag(p, flag)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.