2005-10-12 22:56:53 +00:00
|
|
|
/*
|
|
|
|
* Asterisk -- An open source telephony toolkit.
|
|
|
|
*
|
2006-04-11 21:51:17 +00:00
|
|
|
* Copyright (c) 2004 - 2006 Digium, Inc. All rights reserved.
|
2005-10-12 22:56:53 +00:00
|
|
|
*
|
|
|
|
* Mark Spencer <markster@digium.com>
|
|
|
|
*
|
|
|
|
* This code is released under the GNU General Public License
|
|
|
|
* version 2.0. See LICENSE for more information.
|
|
|
|
*
|
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-10-24 20:12:06 +00:00
|
|
|
/*! \file
|
2005-10-12 22:56:53 +00:00
|
|
|
*
|
2005-10-24 20:12:06 +00:00
|
|
|
* \brief page() - Paging application
|
2005-10-12 22:56:53 +00:00
|
|
|
*
|
2005-12-30 21:18:06 +00:00
|
|
|
* \author Mark Spencer <markster@digium.com>
|
|
|
|
*
|
2005-11-06 15:09:47 +00:00
|
|
|
* \ingroup applications
|
2005-10-12 22:56:53 +00:00
|
|
|
*/
|
|
|
|
|
2006-04-24 17:11:45 +00:00
|
|
|
/*** MODULEINFO
|
2012-03-10 20:06:46 +00:00
|
|
|
<depend>app_confbridge</depend>
|
2011-07-14 20:28:54 +00:00
|
|
|
<support_level>core</support_level>
|
2006-04-24 17:11:45 +00:00
|
|
|
***/
|
|
|
|
|
2006-06-07 18:54:56 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
|
2005-10-12 22:56:53 +00:00
|
|
|
#include "asterisk/channel.h"
|
|
|
|
#include "asterisk/pbx.h"
|
|
|
|
#include "asterisk/module.h"
|
2005-10-14 00:23:47 +00:00
|
|
|
#include "asterisk/file.h"
|
2005-10-13 05:37:49 +00:00
|
|
|
#include "asterisk/app.h"
|
Merged revisions 7265-7266,7268-7275 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r7265 | oej | 2005-12-01 17:18:14 -0600 (Thu, 01 Dec 2005) | 2 lines
Changing bug report address to the Asterisk issue tracker
........
r7266 | kpfleming | 2005-12-01 17:18:29 -0600 (Thu, 01 Dec 2005) | 3 lines
Makefile 'update' target now supports updating from Subversion repositories (issue #5875)
remove support for 'patches' subdirectory, it's no longer useful
........
r7268 | kpfleming | 2005-12-01 17:34:58 -0600 (Thu, 01 Dec 2005) | 2 lines
ensure channel's scheduling context is freed (issue #5788)
........
r7269 | kpfleming | 2005-12-01 17:49:44 -0600 (Thu, 01 Dec 2005) | 2 lines
don't block waiting for the Festival server forever when it goes away (issue #5882)
........
r7270 | kpfleming | 2005-12-01 18:26:12 -0600 (Thu, 01 Dec 2005) | 2 lines
allow variables to exist on both 'halves' of the Local channel (issue #5810)
........
r7271 | kpfleming | 2005-12-01 18:28:48 -0600 (Thu, 01 Dec 2005) | 2 lines
protect agent_bridgedchannel() from segfaulting when there is no bridged channel (issue #5879)
........
r7272 | kpfleming | 2005-12-01 18:39:00 -0600 (Thu, 01 Dec 2005) | 3 lines
properly handle password changes when mailbox is last line of config file and not followed by a newline (issue #5870)
reformat password changing code to conform to coding guidelines (issue #5870)
........
r7273 | kpfleming | 2005-12-01 18:42:40 -0600 (Thu, 01 Dec 2005) | 2 lines
allow previous context-searching behavior to be used if desired (issue #5899)
........
r7274 | kpfleming | 2005-12-01 18:51:15 -0600 (Thu, 01 Dec 2005) | 2 lines
inherit channel variables into channels created by Page() application (issue #5888)
........
r7275 | oej | 2005-12-01 18:52:13 -0600 (Thu, 01 Dec 2005) | 2 lines
Bug #5907. Improve SIP INFO DTMF debugging output. (1.2 & Trunk)
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7276 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2005-12-02 01:01:11 +00:00
|
|
|
#include "asterisk/chanvars.h"
|
2006-01-13 03:34:31 +00:00
|
|
|
#include "asterisk/utils.h"
|
2007-01-18 05:24:08 +00:00
|
|
|
#include "asterisk/devicestate.h"
|
2007-01-24 18:23:07 +00:00
|
|
|
#include "asterisk/dial.h"
|
2005-10-12 22:56:53 +00:00
|
|
|
|
2008-11-01 21:10:07 +00:00
|
|
|
/*** DOCUMENTATION
|
|
|
|
<application name="Page" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Page series of phones
|
|
|
|
</synopsis>
|
|
|
|
<syntax>
|
|
|
|
<parameter name="Technology/Resource" required="true" argsep="&">
|
|
|
|
<argument name="Technology/Resource" required="true">
|
|
|
|
<para>Specification of the device(s) to dial. These must be in the format of
|
|
|
|
<literal>Technology/Resource</literal>, where <replaceable>Technology</replaceable>
|
|
|
|
represents a particular channel driver, and <replaceable>Resource</replaceable> represents a resource
|
|
|
|
available to that particular channel driver.</para>
|
|
|
|
</argument>
|
|
|
|
<argument name="Technology2/Resource2" multiple="true">
|
2013-02-05 18:28:51 +00:00
|
|
|
<para>Optional extra devices to dial in parallel</para>
|
|
|
|
<para>If you need more than one, enter them as Technology2/Resource2&
|
2015-11-06 13:52:00 +00:00
|
|
|
Technology3/Resource3&.....</para>
|
2008-11-01 21:10:07 +00:00
|
|
|
</argument>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="options">
|
|
|
|
<optionlist>
|
2013-12-09 22:17:14 +00:00
|
|
|
<option name="b" argsep="^">
|
|
|
|
<para>Before initiating an outgoing call, Gosub to the specified
|
|
|
|
location using the newly created channel. The Gosub will be
|
|
|
|
executed for each destination channel.</para>
|
|
|
|
<argument name="context" required="false" />
|
|
|
|
<argument name="exten" required="false" />
|
|
|
|
<argument name="priority" required="true" hasparams="optional" argsep="^">
|
|
|
|
<argument name="arg1" multiple="true" required="true" />
|
|
|
|
<argument name="argN" />
|
|
|
|
</argument>
|
|
|
|
</option>
|
|
|
|
<option name="B" argsep="^">
|
|
|
|
<para>Before initiating the outgoing call(s), Gosub to the specified
|
|
|
|
location using the current channel.</para>
|
|
|
|
<argument name="context" required="false" />
|
|
|
|
<argument name="exten" required="false" />
|
|
|
|
<argument name="priority" required="true" hasparams="optional" argsep="^">
|
|
|
|
<argument name="arg1" multiple="true" required="true" />
|
|
|
|
<argument name="argN" />
|
|
|
|
</argument>
|
|
|
|
</option>
|
2008-11-01 21:10:07 +00:00
|
|
|
<option name="d">
|
|
|
|
<para>Full duplex audio</para>
|
|
|
|
</option>
|
2008-12-15 20:07:03 +00:00
|
|
|
<option name="i">
|
|
|
|
<para>Ignore attempts to forward the call</para>
|
|
|
|
</option>
|
2008-11-01 21:10:07 +00:00
|
|
|
<option name="q">
|
|
|
|
<para>Quiet, do not play beep to caller</para>
|
|
|
|
</option>
|
|
|
|
<option name="r">
|
2013-02-05 18:28:51 +00:00
|
|
|
<para>Record the page into a file (<literal>CONFBRIDGE(bridge,record_conference)</literal>)</para>
|
2008-11-01 21:10:07 +00:00
|
|
|
</option>
|
|
|
|
<option name="s">
|
2008-11-02 02:55:25 +00:00
|
|
|
<para>Only dial a channel if its device state says that it is <literal>NOT_INUSE</literal></para>
|
2008-11-01 21:10:07 +00:00
|
|
|
</option>
|
2009-12-10 17:31:23 +00:00
|
|
|
<option name="A">
|
|
|
|
<argument name="x" required="true">
|
2013-02-05 18:28:51 +00:00
|
|
|
<para>The announcement to playback to all devices</para>
|
2009-12-10 17:31:23 +00:00
|
|
|
</argument>
|
2013-02-05 18:28:51 +00:00
|
|
|
<para>Play an announcement to all paged participants</para>
|
2009-12-10 17:31:23 +00:00
|
|
|
</option>
|
|
|
|
<option name="n">
|
2013-02-05 18:28:51 +00:00
|
|
|
<para>Do not play announcement to caller (alters <literal>A(x)</literal> behavior)</para>
|
2009-12-10 17:31:23 +00:00
|
|
|
</option>
|
2008-11-01 21:10:07 +00:00
|
|
|
</optionlist>
|
|
|
|
</parameter>
|
|
|
|
<parameter name="timeout">
|
|
|
|
<para>Specify the length of time that the system will attempt to connect a call.
|
2013-02-05 18:28:51 +00:00
|
|
|
After this duration, any page calls that have not been answered will be hung up by the
|
2008-11-01 21:10:07 +00:00
|
|
|
system.</para>
|
|
|
|
</parameter>
|
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>Places outbound calls to the given <replaceable>technology</replaceable>/<replaceable>resource</replaceable>
|
|
|
|
and dumps them into a conference bridge as muted participants. The original
|
|
|
|
caller is dumped into the conference as a speaker and the room is
|
2013-02-05 18:28:51 +00:00
|
|
|
destroyed when the original caller leaves.</para>
|
2008-11-01 21:10:07 +00:00
|
|
|
</description>
|
2008-11-05 13:07:29 +00:00
|
|
|
<see-also>
|
2012-03-10 20:06:46 +00:00
|
|
|
<ref type="application">ConfBridge</ref>
|
2008-11-05 13:07:29 +00:00
|
|
|
</see-also>
|
2008-11-01 21:10:07 +00:00
|
|
|
</application>
|
|
|
|
***/
|
2009-05-12 13:59:35 +00:00
|
|
|
static const char * const app_page= "Page";
|
2005-10-12 22:56:53 +00:00
|
|
|
|
2009-06-15 19:10:10 +00:00
|
|
|
enum page_opt_flags {
|
2005-11-03 21:19:11 +00:00
|
|
|
PAGE_DUPLEX = (1 << 0),
|
|
|
|
PAGE_QUIET = (1 << 1),
|
2006-05-03 22:38:56 +00:00
|
|
|
PAGE_RECORD = (1 << 2),
|
2007-01-18 05:24:08 +00:00
|
|
|
PAGE_SKIP = (1 << 3),
|
2008-12-15 20:07:03 +00:00
|
|
|
PAGE_IGNORE_FORWARDS = (1 << 4),
|
2009-12-10 17:31:23 +00:00
|
|
|
PAGE_ANNOUNCE = (1 << 5),
|
|
|
|
PAGE_NOCALLERANNOUNCE = (1 << 6),
|
2013-12-09 22:17:14 +00:00
|
|
|
PAGE_PREDIAL_CALLEE = (1 << 7),
|
|
|
|
PAGE_PREDIAL_CALLER = (1 << 8),
|
2009-12-10 17:31:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
OPT_ARG_ANNOUNCE = 0,
|
2013-12-09 22:17:14 +00:00
|
|
|
OPT_ARG_PREDIAL_CALLEE = 1,
|
|
|
|
OPT_ARG_PREDIAL_CALLER = 2,
|
|
|
|
OPT_ARG_ARRAY_SIZE = 3,
|
2009-06-15 19:10:10 +00:00
|
|
|
};
|
2005-11-03 21:19:11 +00:00
|
|
|
|
|
|
|
AST_APP_OPTIONS(page_opts, {
|
2013-12-09 22:17:14 +00:00
|
|
|
AST_APP_OPTION_ARG('b', PAGE_PREDIAL_CALLEE, OPT_ARG_PREDIAL_CALLEE),
|
|
|
|
AST_APP_OPTION_ARG('B', PAGE_PREDIAL_CALLER, OPT_ARG_PREDIAL_CALLER),
|
2005-11-03 21:19:11 +00:00
|
|
|
AST_APP_OPTION('d', PAGE_DUPLEX),
|
|
|
|
AST_APP_OPTION('q', PAGE_QUIET),
|
2006-05-03 22:38:56 +00:00
|
|
|
AST_APP_OPTION('r', PAGE_RECORD),
|
2007-01-18 05:24:08 +00:00
|
|
|
AST_APP_OPTION('s', PAGE_SKIP),
|
2008-12-15 20:07:03 +00:00
|
|
|
AST_APP_OPTION('i', PAGE_IGNORE_FORWARDS),
|
2009-12-10 17:31:23 +00:00
|
|
|
AST_APP_OPTION_ARG('A', PAGE_ANNOUNCE, OPT_ARG_ANNOUNCE),
|
|
|
|
AST_APP_OPTION('n', PAGE_NOCALLERANNOUNCE),
|
2005-10-13 05:37:49 +00:00
|
|
|
});
|
|
|
|
|
2012-03-10 20:06:46 +00:00
|
|
|
/* We use this structure as a way to pass this to all dialed channels */
|
|
|
|
struct page_options {
|
|
|
|
char *opts[OPT_ARG_ARRAY_SIZE];
|
|
|
|
struct ast_flags flags;
|
|
|
|
};
|
|
|
|
|
2013-02-05 19:11:33 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Setup the page bridge profile.
|
|
|
|
*
|
|
|
|
* \param chan Setup bridge profile on this channel.
|
|
|
|
* \param options Options to setup bridge profile.
|
|
|
|
*
|
|
|
|
* \return Nothing
|
|
|
|
*/
|
|
|
|
static void setup_profile_bridge(struct ast_channel *chan, struct page_options *options)
|
2012-03-10 20:06:46 +00:00
|
|
|
{
|
2013-02-05 19:11:33 +00:00
|
|
|
/* Use default_bridge as a starting point */
|
|
|
|
ast_func_write(chan, "CONFBRIDGE(bridge,template)", "");
|
2012-03-10 20:06:46 +00:00
|
|
|
if (ast_test_flag(&options->flags, PAGE_RECORD)) {
|
|
|
|
ast_func_write(chan, "CONFBRIDGE(bridge,record_conference)", "yes");
|
|
|
|
}
|
2013-02-05 19:11:33 +00:00
|
|
|
}
|
2012-03-10 20:06:46 +00:00
|
|
|
|
2013-02-05 19:11:33 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Setup the paged user profile.
|
|
|
|
*
|
|
|
|
* \param chan Setup user profile on this channel.
|
|
|
|
* \param options Options to setup paged user profile.
|
|
|
|
*
|
|
|
|
* \return Nothing
|
|
|
|
*/
|
|
|
|
static void setup_profile_paged(struct ast_channel *chan, struct page_options *options)
|
|
|
|
{
|
|
|
|
/* Use default_user as a starting point */
|
|
|
|
ast_func_write(chan, "CONFBRIDGE(user,template)", "");
|
2012-03-10 20:06:46 +00:00
|
|
|
ast_func_write(chan, "CONFBRIDGE(user,quiet)", "yes");
|
|
|
|
ast_func_write(chan, "CONFBRIDGE(user,end_marked)", "yes");
|
|
|
|
if (!ast_test_flag(&options->flags, PAGE_DUPLEX)) {
|
|
|
|
ast_func_write(chan, "CONFBRIDGE(user,startmuted)", "yes");
|
|
|
|
}
|
2013-02-05 19:11:33 +00:00
|
|
|
if (ast_test_flag(&options->flags, PAGE_ANNOUNCE)
|
|
|
|
&& !ast_strlen_zero(options->opts[OPT_ARG_ANNOUNCE])) {
|
|
|
|
ast_func_write(chan, "CONFBRIDGE(user,announcement)", options->opts[OPT_ARG_ANNOUNCE]);
|
|
|
|
}
|
|
|
|
}
|
2012-03-10 20:06:46 +00:00
|
|
|
|
2013-02-05 19:11:33 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Setup the caller user profile.
|
|
|
|
*
|
|
|
|
* \param chan Setup user profile on this channel.
|
|
|
|
* \param options Options to setup caller user profile.
|
|
|
|
*
|
|
|
|
* \return Nothing
|
|
|
|
*/
|
|
|
|
static void setup_profile_caller(struct ast_channel *chan, struct page_options *options)
|
|
|
|
{
|
|
|
|
/* Use default_user as a starting point if not already setup. */
|
|
|
|
ast_func_write(chan, "CONFBRIDGE(user,template)", "");
|
|
|
|
ast_func_write(chan, "CONFBRIDGE(user,quiet)", "yes");
|
|
|
|
ast_func_write(chan, "CONFBRIDGE(user,marked)", "yes");
|
|
|
|
if (!ast_test_flag(&options->flags, PAGE_NOCALLERANNOUNCE)
|
|
|
|
&& ast_test_flag(&options->flags, PAGE_ANNOUNCE)
|
|
|
|
&& !ast_strlen_zero(options->opts[OPT_ARG_ANNOUNCE])) {
|
2012-03-10 20:06:46 +00:00
|
|
|
ast_func_write(chan, "CONFBRIDGE(user,announcement)", options->opts[OPT_ARG_ANNOUNCE]);
|
|
|
|
}
|
|
|
|
}
|
2005-10-14 00:23:47 +00:00
|
|
|
|
2013-02-05 19:11:33 +00:00
|
|
|
static void page_state_callback(struct ast_dial *dial)
|
|
|
|
{
|
|
|
|
struct ast_channel *chan;
|
|
|
|
struct page_options *options;
|
|
|
|
|
|
|
|
if (ast_dial_state(dial) != AST_DIAL_RESULT_ANSWERED ||
|
|
|
|
!(chan = ast_dial_answered(dial)) ||
|
|
|
|
!(options = ast_dial_get_user_data(dial))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
setup_profile_bridge(chan, options);
|
|
|
|
setup_profile_paged(chan, options);
|
|
|
|
}
|
|
|
|
|
2009-05-21 21:13:09 +00:00
|
|
|
static int page_exec(struct ast_channel *chan, const char *data)
|
2005-10-12 22:56:53 +00:00
|
|
|
{
|
2015-09-22 22:08:49 +00:00
|
|
|
char *tech;
|
|
|
|
char *resource;
|
|
|
|
char *tmp;
|
|
|
|
char *predial_callee = NULL;
|
|
|
|
char confbridgeopts[128];
|
|
|
|
char originator[AST_CHANNEL_NAME];
|
2012-03-10 20:06:46 +00:00
|
|
|
struct page_options options = { { 0, }, { 0, } };
|
2006-04-05 17:44:44 +00:00
|
|
|
unsigned int confid = ast_random();
|
2005-10-12 22:56:53 +00:00
|
|
|
struct ast_app *app;
|
2015-09-22 22:08:49 +00:00
|
|
|
int res = 0;
|
|
|
|
int pos = 0;
|
|
|
|
int i = 0;
|
2009-01-14 02:00:40 +00:00
|
|
|
struct ast_dial **dial_list;
|
|
|
|
unsigned int num_dials;
|
2008-10-31 20:05:46 +00:00
|
|
|
int timeout = 0;
|
|
|
|
char *parse;
|
|
|
|
|
|
|
|
AST_DECLARE_APP_ARGS(args,
|
|
|
|
AST_APP_ARG(devices);
|
|
|
|
AST_APP_ARG(options);
|
|
|
|
AST_APP_ARG(timeout);
|
|
|
|
);
|
2005-10-12 22:56:53 +00:00
|
|
|
|
2005-10-26 19:48:14 +00:00
|
|
|
if (ast_strlen_zero(data)) {
|
2005-10-13 13:14:03 +00:00
|
|
|
ast_log(LOG_WARNING, "This application requires at least one argument (destination(s) to page)\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-03-10 20:06:46 +00:00
|
|
|
if (!(app = pbx_findapp("ConfBridge"))) {
|
|
|
|
ast_log(LOG_WARNING, "There is no ConfBridge application available!\n");
|
2005-10-13 13:14:03 +00:00
|
|
|
return -1;
|
|
|
|
};
|
|
|
|
|
2008-10-31 20:05:46 +00:00
|
|
|
parse = ast_strdupa(data);
|
|
|
|
|
|
|
|
AST_STANDARD_APP_ARGS(args, parse);
|
2005-10-13 13:14:03 +00:00
|
|
|
|
2012-01-09 22:15:50 +00:00
|
|
|
ast_copy_string(originator, ast_channel_name(chan), sizeof(originator));
|
2008-10-31 20:05:46 +00:00
|
|
|
if ((tmp = strchr(originator, '-'))) {
|
2006-04-13 17:41:43 +00:00
|
|
|
*tmp = '\0';
|
2008-10-31 20:05:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ast_strlen_zero(args.options)) {
|
2012-03-10 20:06:46 +00:00
|
|
|
ast_app_parse_options(page_opts, &options.flags, options.opts, args.options);
|
2008-10-31 20:05:46 +00:00
|
|
|
}
|
2006-04-13 17:41:43 +00:00
|
|
|
|
2008-10-31 20:05:46 +00:00
|
|
|
if (!ast_strlen_zero(args.timeout)) {
|
|
|
|
timeout = atoi(args.timeout);
|
|
|
|
}
|
2005-10-13 13:14:03 +00:00
|
|
|
|
2012-03-10 20:06:46 +00:00
|
|
|
snprintf(confbridgeopts, sizeof(confbridgeopts), "ConfBridge,%u", confid);
|
2006-04-11 21:51:17 +00:00
|
|
|
|
2009-01-14 02:00:40 +00:00
|
|
|
/* Count number of extensions in list by number of ampersands + 1 */
|
|
|
|
num_dials = 1;
|
|
|
|
tmp = args.devices;
|
2009-01-25 13:35:48 +00:00
|
|
|
while (*tmp) {
|
|
|
|
if (*tmp == '&') {
|
|
|
|
num_dials++;
|
|
|
|
}
|
|
|
|
tmp++;
|
2009-01-14 02:00:40 +00:00
|
|
|
}
|
|
|
|
|
2009-01-25 13:35:48 +00:00
|
|
|
if (!(dial_list = ast_calloc(num_dials, sizeof(struct ast_dial *)))) {
|
|
|
|
ast_log(LOG_ERROR, "Can't allocate %ld bytes for dial list\n", (long)(sizeof(struct ast_dial *) * num_dials));
|
2009-01-14 02:00:40 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-09-22 22:08:49 +00:00
|
|
|
/* PREDIAL: Preprocess any callee gosub arguments. */
|
|
|
|
if (ast_test_flag(&options.flags, PAGE_PREDIAL_CALLEE)
|
|
|
|
&& !ast_strlen_zero(options.opts[OPT_ARG_PREDIAL_CALLEE])) {
|
|
|
|
ast_replace_subargument_delimiter(options.opts[OPT_ARG_PREDIAL_CALLEE]);
|
|
|
|
predial_callee =
|
|
|
|
(char *) ast_app_expand_sub_args(chan, options.opts[OPT_ARG_PREDIAL_CALLEE]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PREDIAL: Run gosub on the caller's channel */
|
2013-12-09 22:17:14 +00:00
|
|
|
if (ast_test_flag(&options.flags, PAGE_PREDIAL_CALLER)
|
|
|
|
&& !ast_strlen_zero(options.opts[OPT_ARG_PREDIAL_CALLER])) {
|
|
|
|
ast_replace_subargument_delimiter(options.opts[OPT_ARG_PREDIAL_CALLER]);
|
|
|
|
ast_app_exec_sub(NULL, chan, options.opts[OPT_ARG_PREDIAL_CALLER], 0);
|
|
|
|
}
|
|
|
|
|
2007-01-24 18:23:07 +00:00
|
|
|
/* Go through parsing/calling each device */
|
2008-10-31 20:05:46 +00:00
|
|
|
while ((tech = strsep(&args.devices, "&"))) {
|
2007-01-18 05:24:08 +00:00
|
|
|
int state = 0;
|
2007-01-24 18:23:07 +00:00
|
|
|
struct ast_dial *dial = NULL;
|
2007-01-18 05:24:08 +00:00
|
|
|
|
2006-04-11 21:51:17 +00:00
|
|
|
/* don't call the originating device */
|
|
|
|
if (!strcasecmp(tech, originator))
|
|
|
|
continue;
|
|
|
|
|
2007-01-24 18:23:07 +00:00
|
|
|
/* If no resource is available, continue on */
|
2007-01-18 05:24:08 +00:00
|
|
|
if (!(resource = strchr(tech, '/'))) {
|
2005-10-13 13:14:03 +00:00
|
|
|
ast_log(LOG_WARNING, "Incomplete destination '%s' supplied.\n", tech);
|
2007-01-18 05:24:08 +00:00
|
|
|
continue;
|
2005-10-12 22:56:53 +00:00
|
|
|
}
|
2007-01-18 05:24:08 +00:00
|
|
|
|
|
|
|
/* Ensure device is not in use if skip option is enabled */
|
2012-03-10 20:06:46 +00:00
|
|
|
if (ast_test_flag(&options.flags, PAGE_SKIP)) {
|
2008-03-11 20:36:14 +00:00
|
|
|
state = ast_device_state(tech);
|
|
|
|
if (state == AST_DEVICE_UNKNOWN) {
|
2008-11-04 18:47:20 +00:00
|
|
|
ast_log(LOG_WARNING, "Destination '%s' has device state '%s'. Paging anyway.\n", tech, ast_devstate2str(state));
|
2008-03-11 20:36:14 +00:00
|
|
|
} else if (state != AST_DEVICE_NOT_INUSE) {
|
2008-11-04 18:47:20 +00:00
|
|
|
ast_log(LOG_WARNING, "Destination '%s' has device state '%s'.\n", tech, ast_devstate2str(state));
|
2008-03-11 20:36:14 +00:00
|
|
|
continue;
|
|
|
|
}
|
2007-01-18 05:24:08 +00:00
|
|
|
}
|
2007-01-24 18:23:07 +00:00
|
|
|
|
2007-01-18 05:24:08 +00:00
|
|
|
*resource++ = '\0';
|
2007-01-24 18:23:07 +00:00
|
|
|
|
|
|
|
/* Create a dialing structure */
|
|
|
|
if (!(dial = ast_dial_create())) {
|
|
|
|
ast_log(LOG_WARNING, "Failed to create dialing structure.\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Append technology and resource */
|
uniqueid: channel linkedid, ami, ari object creation with id's
Much needed was a way to assign id to objects on creation, and
much change was necessary to accomplish it. Channel uniqueids
and linkedids are split into separate string and creation time
components without breaking linkedid propgation. This allowed
the uniqueid to be specified by the user interface - and those
values are now carried through to channel creation, adding the
assignedids value to every function in the chain including the
channel drivers. For local channels, the second channel can be
specified or left to default to a ;2 suffix of first. In ARI,
bridge, playback, and snoop objects can also be created with a
specified uniqueid.
Along the way, the args order to allocating channels was fixed
in chan_mgcp and chan_gtalk, and linkedid is no longer lost as
masquerade occurs.
(closes issue ASTERISK-23120)
Review: https://reviewboard.asterisk.org/r/3191/
........
Merged revisions 410157 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410158 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-03-07 15:47:55 +00:00
|
|
|
if (ast_dial_append(dial, tech, resource, NULL) == -1) {
|
2008-10-31 20:05:46 +00:00
|
|
|
ast_log(LOG_ERROR, "Failed to add %s to outbound dial\n", tech);
|
2012-05-18 14:43:44 +00:00
|
|
|
ast_dial_destroy(dial);
|
2008-10-31 20:05:46 +00:00
|
|
|
continue;
|
|
|
|
}
|
2007-01-24 18:23:07 +00:00
|
|
|
|
|
|
|
/* Set ANSWER_EXEC as global option */
|
2012-03-10 20:06:46 +00:00
|
|
|
ast_dial_option_global_enable(dial, AST_DIAL_OPTION_ANSWER_EXEC, confbridgeopts);
|
2007-01-24 18:23:07 +00:00
|
|
|
|
2015-09-22 22:08:49 +00:00
|
|
|
if (predial_callee) {
|
|
|
|
ast_dial_option_global_enable(dial, AST_DIAL_OPTION_PREDIAL, predial_callee);
|
2013-12-09 22:17:14 +00:00
|
|
|
}
|
|
|
|
|
2008-10-31 20:05:46 +00:00
|
|
|
if (timeout) {
|
|
|
|
ast_dial_set_global_timeout(dial, timeout * 1000);
|
|
|
|
}
|
|
|
|
|
2012-03-10 20:06:46 +00:00
|
|
|
if (ast_test_flag(&options.flags, PAGE_IGNORE_FORWARDS)) {
|
2008-12-15 20:07:03 +00:00
|
|
|
ast_dial_option_global_enable(dial, AST_DIAL_OPTION_DISABLE_CALL_FORWARDING, NULL);
|
|
|
|
}
|
|
|
|
|
2012-03-10 20:06:46 +00:00
|
|
|
ast_dial_set_state_callback(dial, &page_state_callback);
|
|
|
|
ast_dial_set_user_data(dial, &options);
|
|
|
|
|
2007-01-24 18:23:07 +00:00
|
|
|
/* Run this dial in async mode */
|
|
|
|
ast_dial_run(dial, chan, 1);
|
|
|
|
|
|
|
|
/* Put in our dialing array */
|
2009-01-14 02:00:40 +00:00
|
|
|
dial_list[pos++] = dial;
|
2005-10-12 22:56:53 +00:00
|
|
|
}
|
2006-04-11 21:51:17 +00:00
|
|
|
|
2015-09-22 22:08:49 +00:00
|
|
|
ast_free(predial_callee);
|
|
|
|
|
2012-03-10 20:06:46 +00:00
|
|
|
if (!ast_test_flag(&options.flags, PAGE_QUIET)) {
|
2012-01-24 20:12:09 +00:00
|
|
|
res = ast_streamfile(chan, "beep", ast_channel_language(chan));
|
2005-10-14 00:23:47 +00:00
|
|
|
if (!res)
|
|
|
|
res = ast_waitstream(chan, "");
|
|
|
|
}
|
2006-12-20 04:32:59 +00:00
|
|
|
|
2005-10-14 00:23:47 +00:00
|
|
|
if (!res) {
|
2013-02-05 19:11:33 +00:00
|
|
|
setup_profile_bridge(chan, &options);
|
|
|
|
setup_profile_caller(chan, &options);
|
2012-03-10 20:06:46 +00:00
|
|
|
|
|
|
|
snprintf(confbridgeopts, sizeof(confbridgeopts), "%u", confid);
|
|
|
|
pbx_exec(chan, app, confbridgeopts);
|
2005-10-14 00:23:47 +00:00
|
|
|
}
|
2005-10-13 13:14:03 +00:00
|
|
|
|
2007-01-24 18:23:07 +00:00
|
|
|
/* Go through each dial attempt cancelling, joining, and destroying */
|
|
|
|
for (i = 0; i < pos; i++) {
|
2009-01-14 02:00:40 +00:00
|
|
|
struct ast_dial *dial = dial_list[i];
|
2007-01-24 18:23:07 +00:00
|
|
|
|
2012-03-10 20:06:46 +00:00
|
|
|
/* We have to wait for the async thread to exit as it's possible ConfBridge won't throw them out immediately */
|
2007-03-16 16:14:04 +00:00
|
|
|
ast_dial_join(dial);
|
2007-01-24 18:23:07 +00:00
|
|
|
|
|
|
|
/* Hangup all channels */
|
|
|
|
ast_dial_hangup(dial);
|
|
|
|
|
|
|
|
/* Destroy dialing structure */
|
|
|
|
ast_dial_destroy(dial);
|
|
|
|
}
|
|
|
|
|
2012-03-24 03:11:43 +00:00
|
|
|
ast_free(dial_list);
|
|
|
|
|
2005-10-12 22:56:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
static int unload_module(void)
|
2005-10-12 22:56:53 +00:00
|
|
|
{
|
2007-07-16 13:35:20 +00:00
|
|
|
return ast_unregister_application(app_page);
|
2005-10-12 22:56:53 +00:00
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
static int load_module(void)
|
2005-10-12 22:56:53 +00:00
|
|
|
{
|
2008-11-01 21:10:07 +00:00
|
|
|
return ast_register_application_xml(app_page, page_exec);
|
2005-10-12 22:56:53 +00:00
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Page Multiple Phones");
|