#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include "asterisk/options.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/file.h"
#include "asterisk/app.h"
#include "asterisk/chanvars.h"
#include "asterisk/utils.h"
#include "asterisk/dial.h"
#include "asterisk/devicestate.h"

Go to the source code of this file.
Defines | |
| #define | MAX_DIALS 128 |
Enumerations | |
| enum | { PAGE_DUPLEX = (1 << 0), PAGE_QUIET = (1 << 1), PAGE_RECORD = (1 << 2) } |
Functions | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| static int | load_module (void) |
| static int | page_exec (struct ast_channel *chan, void *data) |
| static int | unload_module (void) |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Page Multiple Phones" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } |
| static const char * | app_page = "Page" |
| static const struct ast_module_info * | ast_module_info = &__mod_info |
| static const char * | page_descrip |
| enum { ... } | page_opt_flags |
| static struct ast_app_option | page_opts [128] = { [ 'd' ] = { .flag = PAGE_DUPLEX }, [ 'q' ] = { .flag = PAGE_QUIET }, [ 'r' ] = { .flag = PAGE_RECORD },} |
| static const char * | page_synopsis = "Pages phones" |
Definition in file app_page.c.
| #define MAX_DIALS 128 |
| anonymous enum |
Definition at line 69 of file app_page.c.
00069 { 00070 PAGE_DUPLEX = (1 << 0), 00071 PAGE_QUIET = (1 << 1), 00072 PAGE_RECORD = (1 << 2), 00073 } page_opt_flags;
| static void __reg_module | ( | void | ) | [static] |
Definition at line 202 of file app_page.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 202 of file app_page.c.
| static int load_module | ( | void | ) | [static] |
Definition at line 197 of file app_page.c.
References ast_register_application(), and page_exec().
00198 { 00199 return ast_register_application(app_page, page_exec, page_synopsis, page_descrip); 00200 }
| static int page_exec | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
Definition at line 83 of file app_page.c.
References app, ast_app_parse_options(), AST_CHANNEL_NAME, ast_copy_string(), ast_dial_append(), ast_dial_create(), ast_dial_destroy(), ast_dial_hangup(), ast_dial_join(), AST_DIAL_OPTION_ANSWER_EXEC, ast_dial_option_global_enable(), ast_dial_run(), ast_log(), ast_module_user_add, ast_module_user_remove, ast_random(), ast_strdupa, ast_streamfile(), ast_strlen_zero(), ast_test_flag, ast_waitstream(), ast_channel::language, LOG_WARNING, MAX_DIALS, ast_channel::name, PAGE_DUPLEX, page_opts, PAGE_QUIET, PAGE_RECORD, pbx_exec(), and pbx_findapp().
Referenced by load_module().
00084 { 00085 struct ast_module_user *u; 00086 char *options, *tech, *resource, *tmp; 00087 char meetmeopts[88], originator[AST_CHANNEL_NAME]; 00088 struct ast_flags flags = { 0 }; 00089 unsigned int confid = ast_random(); 00090 struct ast_app *app; 00091 int res = 0, pos = 0, i = 0; 00092 struct ast_dial *dials[MAX_DIALS]; 00093 00094 if (ast_strlen_zero(data)) { 00095 ast_log(LOG_WARNING, "This application requires at least one argument (destination(s) to page)\n"); 00096 return -1; 00097 } 00098 00099 u = ast_module_user_add(chan); 00100 00101 if (!(app = pbx_findapp("MeetMe"))) { 00102 ast_log(LOG_WARNING, "There is no MeetMe application available!\n"); 00103 ast_module_user_remove(u); 00104 return -1; 00105 }; 00106 00107 options = ast_strdupa(data); 00108 00109 ast_copy_string(originator, chan->name, sizeof(originator)); 00110 if ((tmp = strchr(originator, '-'))) 00111 *tmp = '\0'; 00112 00113 tmp = strsep(&options, "|"); 00114 if (options) 00115 ast_app_parse_options(page_opts, &flags, NULL, options); 00116 00117 snprintf(meetmeopts, sizeof(meetmeopts), "MeetMe|%ud|%s%sqxdw(5)", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "m"), 00118 (ast_test_flag(&flags, PAGE_RECORD) ? "r" : "") ); 00119 00120 /* Go through parsing/calling each device */ 00121 while ((tech = strsep(&tmp, "&"))) { 00122 struct ast_dial *dial = NULL; 00123 00124 /* don't call the originating device */ 00125 if (!strcasecmp(tech, originator)) 00126 continue; 00127 00128 /* If no resource is available, continue on */ 00129 if (!(resource = strchr(tech, '/'))) { 00130 ast_log(LOG_WARNING, "Incomplete destination '%s' supplied.\n", tech); 00131 continue; 00132 } 00133 00134 *resource++ = '\0'; 00135 00136 /* Create a dialing structure */ 00137 if (!(dial = ast_dial_create())) { 00138 ast_log(LOG_WARNING, "Failed to create dialing structure.\n"); 00139 continue; 00140 } 00141 00142 /* Append technology and resource */ 00143 ast_dial_append(dial, tech, resource); 00144 00145 /* Set ANSWER_EXEC as global option */ 00146 ast_dial_option_global_enable(dial, AST_DIAL_OPTION_ANSWER_EXEC, meetmeopts); 00147 00148 /* Run this dial in async mode */ 00149 ast_dial_run(dial, chan, 1); 00150 00151 /* Put in our dialing array */ 00152 dials[pos++] = dial; 00153 } 00154 00155 if (!ast_test_flag(&flags, PAGE_QUIET)) { 00156 res = ast_streamfile(chan, "beep", chan->language); 00157 if (!res) 00158 res = ast_waitstream(chan, ""); 00159 } 00160 00161 if (!res) { 00162 snprintf(meetmeopts, sizeof(meetmeopts), "%ud|A%s%sqxd", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "t"), 00163 (ast_test_flag(&flags, PAGE_RECORD) ? "r" : "") ); 00164 pbx_exec(chan, app, meetmeopts); 00165 } 00166 00167 /* Go through each dial attempt cancelling, joining, and destroying */ 00168 for (i = 0; i < pos; i++) { 00169 struct ast_dial *dial = dials[i]; 00170 00171 /* We have to wait for the async thread to exit as it's possible Meetme won't throw them out immediately */ 00172 ast_dial_join(dial); 00173 00174 /* Hangup all channels */ 00175 ast_dial_hangup(dial); 00176 00177 /* Destroy dialing structure */ 00178 ast_dial_destroy(dial); 00179 } 00180 00181 ast_module_user_remove(u); 00182 00183 return -1; 00184 }
| static int unload_module | ( | void | ) | [static] |
Definition at line 186 of file app_page.c.
References ast_module_user_hangup_all, and ast_unregister_application().
00187 { 00188 int res; 00189 00190 res = ast_unregister_application(app_page); 00191 00192 ast_module_user_hangup_all(); 00193 00194 return res; 00195 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Page Multiple Phones" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static] |
Definition at line 202 of file app_page.c.
const char* app_page = "Page" [static] |
Definition at line 55 of file app_page.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 202 of file app_page.c.
const char* page_descrip [static] |
Definition at line 59 of file app_page.c.
| enum { ... } page_opt_flags |
struct ast_app_option page_opts[128] = { [ 'd' ] = { .flag = PAGE_DUPLEX }, [ 'q' ] = { .flag = PAGE_QUIET }, [ 'r' ] = { .flag = PAGE_RECORD },} [static] |
const char* page_synopsis = "Pages phones" [static] |
Definition at line 57 of file app_page.c.
1.5.9