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
|
|
|
|
<depend>zaptel</depend>
|
2007-06-01 19:35:41 +00:00
|
|
|
<depend>app_meetme</depend>
|
2006-04-24 17:11:45 +00:00
|
|
|
***/
|
|
|
|
|
2006-06-07 18:54:56 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
|
|
|
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
|
|
|
2005-10-12 22:56:53 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
2005-10-14 00:23:47 +00:00
|
|
|
#include <errno.h>
|
2005-10-12 22:56:53 +00:00
|
|
|
|
|
|
|
#include "asterisk/options.h"
|
|
|
|
#include "asterisk/logger.h"
|
|
|
|
#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
|
|
|
|
2005-10-13 13:14:03 +00:00
|
|
|
static const char *app_page= "Page";
|
2005-10-12 22:56:53 +00:00
|
|
|
|
2005-10-13 13:14:03 +00:00
|
|
|
static const char *page_synopsis = "Pages phones";
|
2005-10-12 22:56:53 +00:00
|
|
|
|
2005-10-13 13:14:03 +00:00
|
|
|
static const char *page_descrip =
|
2007-07-31 01:10:47 +00:00
|
|
|
"Page(Technology/Resource&Technology2/Resource2[,options])\n"
|
2005-10-12 22:56:53 +00:00
|
|
|
" Places outbound calls to the given technology / resource and dumps\n"
|
|
|
|
"them into a conference bridge as muted participants. The original\n"
|
|
|
|
"caller is dumped into the conference as a speaker and the room is\n"
|
2005-10-13 05:37:49 +00:00
|
|
|
"destroyed when the original caller leaves. Valid options are:\n"
|
2005-11-07 22:01:22 +00:00
|
|
|
" d - full duplex audio\n"
|
2006-10-26 20:27:52 +00:00
|
|
|
" q - quiet, do not play beep to caller\n"
|
2007-01-18 05:24:08 +00:00
|
|
|
" r - record the page into a file (see 'r' for app_meetme)\n"
|
|
|
|
" s - only dial channel if devicestate says it is not in use\n";
|
2005-10-12 22:56:53 +00:00
|
|
|
|
2005-11-03 21:19:11 +00:00
|
|
|
enum {
|
|
|
|
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),
|
2005-11-03 21:19:11 +00:00
|
|
|
} page_opt_flags;
|
|
|
|
|
|
|
|
AST_APP_OPTIONS(page_opts, {
|
|
|
|
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),
|
2005-10-13 05:37:49 +00:00
|
|
|
});
|
|
|
|
|
2007-01-24 18:23:07 +00:00
|
|
|
#define MAX_DIALS 128
|
2005-10-14 00:23:47 +00:00
|
|
|
|
2005-10-12 22:56:53 +00:00
|
|
|
static int page_exec(struct ast_channel *chan, void *data)
|
|
|
|
{
|
2007-01-24 18:23:07 +00:00
|
|
|
char *options, *tech, *resource, *tmp;
|
2007-07-23 19:51:41 +00:00
|
|
|
char meetmeopts[88], originator[AST_CHANNEL_NAME], *opts[0];
|
2005-10-13 05:37:49 +00:00
|
|
|
struct ast_flags flags = { 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;
|
2007-01-24 18:23:07 +00:00
|
|
|
int res = 0, pos = 0, i = 0;
|
|
|
|
struct ast_dial *dials[MAX_DIALS];
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(app = pbx_findapp("MeetMe"))) {
|
|
|
|
ast_log(LOG_WARNING, "There is no MeetMe application available!\n");
|
|
|
|
return -1;
|
|
|
|
};
|
|
|
|
|
2006-05-10 13:22:15 +00:00
|
|
|
options = ast_strdupa(data);
|
2005-10-13 13:14:03 +00:00
|
|
|
|
2006-04-13 17:41:43 +00:00
|
|
|
ast_copy_string(originator, chan->name, sizeof(originator));
|
|
|
|
if ((tmp = strchr(originator, '-')))
|
|
|
|
*tmp = '\0';
|
|
|
|
|
2007-07-23 19:51:41 +00:00
|
|
|
tmp = strsep(&options, ",");
|
2005-10-13 13:14:03 +00:00
|
|
|
if (options)
|
2007-07-23 19:51:41 +00:00
|
|
|
ast_app_parse_options(page_opts, &flags, opts, options);
|
2005-10-13 13:14:03 +00:00
|
|
|
|
2007-07-31 01:10:47 +00:00
|
|
|
snprintf(meetmeopts, sizeof(meetmeopts), "MeetMe,%ud,%s%sqxdw(5)", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "m"),
|
2006-05-03 22:38:56 +00:00
|
|
|
(ast_test_flag(&flags, PAGE_RECORD) ? "r" : "") );
|
2006-04-11 21:51:17 +00:00
|
|
|
|
2007-01-24 18:23:07 +00:00
|
|
|
/* Go through parsing/calling each device */
|
2005-10-13 13:14:03 +00:00
|
|
|
while ((tech = strsep(&tmp, "&"))) {
|
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 */
|
|
|
|
if (ast_test_flag(&flags, PAGE_SKIP) && (state = ast_device_state(tech)) != AST_DEVICE_NOT_INUSE) {
|
|
|
|
ast_log(LOG_WARNING, "Destination '%s' has device state '%s'.\n", tech, devstate2str(state));
|
|
|
|
continue;
|
|
|
|
}
|
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 */
|
|
|
|
ast_dial_append(dial, tech, resource);
|
|
|
|
|
|
|
|
/* Set ANSWER_EXEC as global option */
|
|
|
|
ast_dial_option_global_enable(dial, AST_DIAL_OPTION_ANSWER_EXEC, meetmeopts);
|
|
|
|
|
|
|
|
/* Run this dial in async mode */
|
|
|
|
ast_dial_run(dial, chan, 1);
|
|
|
|
|
|
|
|
/* Put in our dialing array */
|
|
|
|
dials[pos++] = dial;
|
2005-10-12 22:56:53 +00:00
|
|
|
}
|
2006-04-11 21:51:17 +00:00
|
|
|
|
2005-10-14 00:23:47 +00:00
|
|
|
if (!ast_test_flag(&flags, PAGE_QUIET)) {
|
|
|
|
res = ast_streamfile(chan, "beep", chan->language);
|
|
|
|
if (!res)
|
|
|
|
res = ast_waitstream(chan, "");
|
|
|
|
}
|
2006-12-20 04:32:59 +00:00
|
|
|
|
2005-10-14 00:23:47 +00:00
|
|
|
if (!res) {
|
2007-07-31 01:10:47 +00:00
|
|
|
snprintf(meetmeopts, sizeof(meetmeopts), "%ud,A%s%sqxd", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "t"),
|
2006-05-03 22:38:56 +00:00
|
|
|
(ast_test_flag(&flags, PAGE_RECORD) ? "r" : "") );
|
2006-03-30 21:29:39 +00:00
|
|
|
pbx_exec(chan, app, meetmeopts);
|
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++) {
|
|
|
|
struct ast_dial *dial = dials[i];
|
|
|
|
|
2007-03-16 16:14:04 +00:00
|
|
|
/* We have to wait for the async thread to exit as it's possible Meetme won't throw them out immediately */
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
return ast_register_application(app_page, page_exec, page_synopsis, page_descrip);
|
|
|
|
}
|
|
|
|
|
2006-08-21 02:11:39 +00:00
|
|
|
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Page Multiple Phones");
|
2006-04-24 17:11:45 +00:00
|
|
|
|