130 static const char *
const app_page=
"Page";
132 enum page_opt_flags {
133 PAGE_DUPLEX = (1 << 0),
134 PAGE_QUIET = (1 << 1),
135 PAGE_RECORD = (1 << 2),
136 PAGE_SKIP = (1 << 3),
137 PAGE_IGNORE_FORWARDS = (1 << 4),
138 PAGE_ANNOUNCE = (1 << 5),
139 PAGE_NOCALLERANNOUNCE = (1 << 6),
140 PAGE_PREDIAL_CALLEE = (1 << 7),
141 PAGE_PREDIAL_CALLER = (1 << 8),
145 OPT_ARG_ANNOUNCE = 0,
146 OPT_ARG_PREDIAL_CALLEE = 1,
147 OPT_ARG_PREDIAL_CALLER = 2,
148 OPT_ARG_ARRAY_SIZE = 3,
163 #define PAGE_BEEP "beep"
167 char *opts[OPT_ARG_ARRAY_SIZE];
182 if (ast_test_flag(&options->flags, PAGE_RECORD)) {
183 ast_func_write(chan,
"CONFBRIDGE(bridge,record_conference)",
"yes");
200 if (!ast_test_flag(&options->flags, PAGE_DUPLEX)) {
203 if (ast_test_flag(&options->flags, PAGE_ANNOUNCE)
204 && !ast_strlen_zero(options->opts[OPT_ARG_ANNOUNCE])) {
205 ast_func_write(chan,
"CONFBRIDGE(user,announcement)", options->opts[OPT_ARG_ANNOUNCE]);
222 if (!ast_test_flag(&options->flags, PAGE_NOCALLERANNOUNCE)
223 && ast_test_flag(&options->flags, PAGE_ANNOUNCE)
224 && !ast_strlen_zero(options->opts[OPT_ARG_ANNOUNCE])) {
225 ast_func_write(chan,
"CONFBRIDGE(user,announcement)", options->opts[OPT_ARG_ANNOUNCE]);
229 static void page_state_callback(
struct ast_dial *dial)
240 setup_profile_bridge(chan, options);
241 setup_profile_paged(chan, options);
244 static int page_exec(
struct ast_channel *chan,
const char *data)
249 char *predial_callee = NULL;
250 char confbridgeopts[128];
253 unsigned int confid = ast_random();
259 unsigned int num_dials;
270 ast_log(LOG_WARNING,
"There is no ConfBridge application available!\n");
278 ast_copy_string(originator, ast_channel_name(chan),
sizeof(originator));
279 if ((tmp = strchr(originator,
'-'))) {
283 if (!ast_strlen_zero(args.options)) {
287 if (!ast_strlen_zero(args.timeout)) {
288 timeout = atoi(args.timeout);
291 snprintf(confbridgeopts,
sizeof(confbridgeopts),
"ConfBridge,%u", confid);
295 tmp = args.devices ?:
"";
304 ast_log(LOG_ERROR,
"Can't allocate %ld bytes for dial list\n", (
long)(
sizeof(
struct ast_dial *) * num_dials));
309 if (ast_test_flag(&options.flags, PAGE_PREDIAL_CALLEE)
310 && !ast_strlen_zero(options.opts[OPT_ARG_PREDIAL_CALLEE])) {
317 if (ast_test_flag(&options.flags, PAGE_PREDIAL_CALLER)
318 && !ast_strlen_zero(options.opts[OPT_ARG_PREDIAL_CALLER])) {
324 while ((tech = strsep(&args.devices,
"&"))) {
329 if (ast_strlen_zero(tech)) {
335 if (!strcasecmp(tech, originator)) {
340 if (!(resource = strchr(tech,
'/'))) {
341 ast_log(LOG_WARNING,
"Incomplete destination: '%s' supplied.\n", tech);
346 if (ast_test_flag(&options.flags, PAGE_SKIP)) {
349 ast_verb(3,
"Destination '%s' has device state '%s'. Paging anyway.\n",
352 ast_verb(3,
"Destination '%s' has device state '%s'.\n",
362 ast_log(LOG_WARNING,
"Failed to create dialing structure.\n");
368 ast_log(LOG_ERROR,
"Failed to add %s/%s to outbound dial\n", tech, resource);
376 if (predial_callee) {
384 if (ast_test_flag(&options.flags, PAGE_IGNORE_FORWARDS)) {
395 dial_list[pos++] = dial;
398 ast_free(predial_callee);
400 if (!ast_test_flag(&options.flags, PAGE_QUIET)) {
402 ast_log(LOG_WARNING,
"Missing required sound file: '" PAGE_BEEP
"'\n");
404 res =
ast_streamfile(chan, PAGE_BEEP, ast_channel_language(chan));
412 setup_profile_bridge(chan, &options);
413 setup_profile_caller(chan, &options);
415 snprintf(confbridgeopts,
sizeof(confbridgeopts),
"%u", confid);
416 pbx_exec(chan, app, confbridgeopts);
420 for (i = 0; i < pos; i++) {
421 struct ast_dial *dial = dial_list[i];
438 static int unload_module(
void)
443 static int load_module(
void)
448 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT,
"Page Multiple Phones",
449 .support_level = AST_MODULE_SUPPORT_CORE,
451 .unload = unload_module,
452 .requires =
"app_confbridge",
const char * ast_devstate2str(enum ast_device_state devstate) attribute_pure
Convert device state to text string for output.
Main Channel structure associated with a channel.
ast_device_state
Device States.
int ast_dial_destroy(struct ast_dial *dial)
Destroys a dialing structure.
int ast_streamfile(struct ast_channel *c, const char *filename, const char *preflang)
Streams a file.
int ast_dial_option_global_enable(struct ast_dial *dial, enum ast_dial_option option, void *data)
Enables an option globally.
Asterisk main include file. File version handling, generic pbx functions.
void * ast_dial_get_user_data(struct ast_dial *dial)
Return the user data on a dial structure.
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
Main dialing structure. Contains global options, channels being dialed, and more! ...
void ast_dial_set_global_timeout(struct ast_dial *dial, int timeout)
Set the maximum time (globally) allowed for trying to ring phones.
const char * ast_app_expand_sub_args(struct ast_channel *chan, const char *args)
Add missing context/exten to subroutine argument string.
void ast_dial_hangup(struct ast_dial *dial)
Hangup channels.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
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_unregister_application(const char *app)
Unregister an application.
void ast_dial_set_user_data(struct ast_dial *dial, void *user_data)
Set user data on a dial structure.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
void ast_dial_set_state_callback(struct ast_dial *dial, ast_dial_state_callback callback)
Set a callback for state changes.
void ast_replace_subargument_delimiter(char *s)
Replace '^' in a string with ','.
General Asterisk PBX channel definitions.
enum ast_dial_result ast_dial_join(struct ast_dial *dial)
Cancel async thread.
#define ast_strdupa(s)
duplicate a string in memory from the stack
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
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.
enum ast_dial_result ast_dial_state(struct ast_dial *dial)
Return state of dial.
Core PBX routines and definitions.
enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *chan, int async)
Execute dialing synchronously or asynchronously.
#define AST_APP_OPTION_ARG(option, flagno, argno)
Declares an application option that accepts an argument.
int ast_dial_append(struct ast_dial *dial, const char *tech, const char *device, const struct ast_assigned_ids *assignedids)
Append a channel.
struct ast_channel * ast_dial_answered(struct ast_dial *dial)
Return channel that answered.
#define ast_calloc(num, len)
A wrapper for calloc()
struct ast_dial * ast_dial_create(void)
New dialing structure.
Structure used to handle boolean flags.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
ast_app: A registered application
int ast_waitstream(struct ast_channel *c, const char *breakon)
Waits for a stream to stop or digit to be pressed.
int ast_fileexists(const char *filename, const char *fmt, const char *preflang)
Checks for the existence of a given file.
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.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
struct ast_app * pbx_findapp(const char *app)
Look up an application.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
int ast_func_write(struct ast_channel *chan, const char *function, const char *value)
executes a write operation on a function
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define AST_APP_ARG(name)
Define an application argument.