#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/app.h"

Go to the source code of this file.
Functions | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| static int | load_module (void) |
| static int | originate_exec (struct ast_channel *chan, const char *data) |
| static int | unload_module (void) |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Originate call" , .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, .load_pri = AST_MODPRI_DEFAULT, } |
| static const char | app_originate [] = "Originate" |
| static struct ast_module_info * | ast_module_info = &__mod_info |
Definition in file app_originate.c.
| static void __reg_module | ( | void | ) | [static] |
Definition at line 245 of file app_originate.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 245 of file app_originate.c.
| static int load_module | ( | void | ) | [static] |
Definition at line 236 of file app_originate.c.
References AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_register_application_xml, and originate_exec().
00237 { 00238 int res; 00239 00240 res = ast_register_application_xml(app_originate, originate_exec); 00241 00242 return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS; 00243 }
| static int originate_exec | ( | struct ast_channel * | chan, | |
| const char * | data | |||
| ) | [static] |
Definition at line 99 of file app_originate.c.
References args, AST_APP_ARG, ast_autoservice_start(), ast_autoservice_stop(), AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_HANGUP, AST_CONTROL_RINGING, ast_debug, AST_DECLARE_APP_ARGS, ast_format_cap_add(), ast_format_cap_alloc_nolock(), ast_format_cap_destroy(), ast_format_set(), AST_FORMAT_SLINEAR, AST_FORMAT_SLINEAR12, AST_FORMAT_SLINEAR16, AST_FORMAT_SLINEAR192, AST_FORMAT_SLINEAR24, AST_FORMAT_SLINEAR32, AST_FORMAT_SLINEAR44, AST_FORMAT_SLINEAR48, AST_FORMAT_SLINEAR96, ast_log(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), exten, LOG_ERROR, LOG_NOTICE, LOG_WARNING, parse(), pbx_builtin_setvar_helper(), S_OR, strsep(), and type.
Referenced by load_module().
00100 { 00101 AST_DECLARE_APP_ARGS(args, 00102 AST_APP_ARG(tech_data); 00103 AST_APP_ARG(type); 00104 AST_APP_ARG(arg1); 00105 AST_APP_ARG(arg2); 00106 AST_APP_ARG(arg3); 00107 AST_APP_ARG(timeout); 00108 ); 00109 char *parse; 00110 char *chantech, *chandata; 00111 int res = -1; 00112 int outgoing_status = 0; 00113 unsigned int timeout = 30; 00114 static const char default_exten[] = "s"; 00115 struct ast_format tmpfmt; 00116 struct ast_format_cap *cap_slin = ast_format_cap_alloc_nolock(); 00117 00118 ast_autoservice_start(chan); 00119 if (!cap_slin) { 00120 goto return_cleanup; 00121 } 00122 ast_format_cap_add(cap_slin, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0)); 00123 ast_format_cap_add(cap_slin, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR12, 0)); 00124 ast_format_cap_add(cap_slin, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR16, 0)); 00125 ast_format_cap_add(cap_slin, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR24, 0)); 00126 ast_format_cap_add(cap_slin, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR32, 0)); 00127 ast_format_cap_add(cap_slin, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR44, 0)); 00128 ast_format_cap_add(cap_slin, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR48, 0)); 00129 ast_format_cap_add(cap_slin, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR96, 0)); 00130 ast_format_cap_add(cap_slin, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR192, 0)); 00131 00132 if (ast_strlen_zero(data)) { 00133 ast_log(LOG_ERROR, "Originate() requires arguments\n"); 00134 goto return_cleanup; 00135 } 00136 00137 parse = ast_strdupa(data); 00138 00139 AST_STANDARD_APP_ARGS(args, parse); 00140 00141 if (args.argc < 3) { 00142 ast_log(LOG_ERROR, "Incorrect number of arguments\n"); 00143 goto return_cleanup; 00144 } 00145 00146 if (!ast_strlen_zero(args.timeout)) { 00147 if(sscanf(args.timeout, "%u", &timeout) != 1) { 00148 ast_log(LOG_NOTICE, "Invalid timeout: '%s'. Setting timeout to 30 seconds\n", args.timeout); 00149 timeout = 30; 00150 } 00151 } 00152 00153 chandata = ast_strdupa(args.tech_data); 00154 chantech = strsep(&chandata, "/"); 00155 00156 if (ast_strlen_zero(chandata) || ast_strlen_zero(chantech)) { 00157 ast_log(LOG_ERROR, "Channel Tech/Data invalid: '%s'\n", args.tech_data); 00158 goto return_cleanup; 00159 } 00160 00161 if (!strcasecmp(args.type, "exten")) { 00162 int priority = 1; /* Initialized in case priority not specified */ 00163 const char *exten = args.arg2; 00164 00165 if (args.argc == 5) { 00166 /* Context/Exten/Priority all specified */ 00167 if (sscanf(args.arg3, "%30d", &priority) != 1) { 00168 ast_log(LOG_ERROR, "Invalid priority: '%s'\n", args.arg3); 00169 goto return_cleanup; 00170 } 00171 } else if (args.argc == 3) { 00172 /* Exten not specified */ 00173 exten = default_exten; 00174 } 00175 00176 ast_debug(1, "Originating call to '%s/%s' and connecting them to extension %s,%s,%d\n", 00177 chantech, chandata, args.arg1, exten, priority); 00178 00179 ast_pbx_outgoing_exten(chantech, cap_slin, chandata, 00180 timeout * 1000, args.arg1, exten, priority, &outgoing_status, 0, NULL, 00181 NULL, NULL, NULL, NULL); 00182 } else if (!strcasecmp(args.type, "app")) { 00183 ast_debug(1, "Originating call to '%s/%s' and connecting them to %s(%s)\n", 00184 chantech, chandata, args.arg1, S_OR(args.arg2, "")); 00185 00186 ast_pbx_outgoing_app(chantech, cap_slin, chandata, 00187 timeout * 1000, args.arg1, args.arg2, &outgoing_status, 0, NULL, 00188 NULL, NULL, NULL, NULL); 00189 } else { 00190 ast_log(LOG_ERROR, "Incorrect type, it should be 'exten' or 'app': %s\n", 00191 args.type); 00192 goto return_cleanup; 00193 } 00194 00195 res = 0; 00196 00197 return_cleanup: 00198 if (res) { 00199 pbx_builtin_setvar_helper(chan, "ORIGINATE_STATUS", "FAILED"); 00200 } else { 00201 switch (outgoing_status) { 00202 case 0: 00203 case AST_CONTROL_ANSWER: 00204 pbx_builtin_setvar_helper(chan, "ORIGINATE_STATUS", "SUCCESS"); 00205 break; 00206 case AST_CONTROL_BUSY: 00207 pbx_builtin_setvar_helper(chan, "ORIGINATE_STATUS", "BUSY"); 00208 break; 00209 case AST_CONTROL_CONGESTION: 00210 pbx_builtin_setvar_helper(chan, "ORIGINATE_STATUS", "CONGESTION"); 00211 break; 00212 case AST_CONTROL_HANGUP: 00213 pbx_builtin_setvar_helper(chan, "ORIGINATE_STATUS", "HANGUP"); 00214 break; 00215 case AST_CONTROL_RINGING: 00216 pbx_builtin_setvar_helper(chan, "ORIGINATE_STATUS", "RINGING"); 00217 break; 00218 default: 00219 ast_log(LOG_WARNING, "Unknown originate status result of '%d'\n", 00220 outgoing_status); 00221 pbx_builtin_setvar_helper(chan, "ORIGINATE_STATUS", "UNKNOWN"); 00222 break; 00223 } 00224 } 00225 cap_slin = ast_format_cap_destroy(cap_slin); 00226 ast_autoservice_stop(chan); 00227 00228 return res; 00229 }
| static int unload_module | ( | void | ) | [static] |
Definition at line 231 of file app_originate.c.
References ast_unregister_application().
00232 { 00233 return ast_unregister_application(app_originate); 00234 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Originate call" , .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, .load_pri = AST_MODPRI_DEFAULT, } [static] |
Definition at line 245 of file app_originate.c.
const char app_originate[] = "Originate" [static] |
Definition at line 49 of file app_originate.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 245 of file app_originate.c.
1.5.6