File: | src/mod/applications/mod_dptools/mod_dptools.c |
Location: | line 163, column 8 |
Description: | Value stored to 'string' during its initialization is never read |
1 | /* |
2 | * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application |
3 | * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org> |
4 | * |
5 | * Version: MPL 1.1 |
6 | * |
7 | * The contents of this file are subject to the Mozilla Public License Version |
8 | * 1.1 (the "License"); you may not use this file except in compliance with |
9 | * the License. You may obtain a copy of the License at |
10 | * http://www.mozilla.org/MPL/ |
11 | * |
12 | * Software distributed under the License is distributed on an "AS IS" basis, |
13 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
14 | * for the specific language governing rights and limitations under the |
15 | * License. |
16 | * |
17 | * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application |
18 | * |
19 | * The Initial Developer of the Original Code is |
20 | * Anthony Minessale II <anthm@freeswitch.org> |
21 | * Portions created by the Initial Developer are Copyright (C) |
22 | * the Initial Developer. All Rights Reserved. |
23 | * |
24 | * Contributor(s): |
25 | * |
26 | * Anthony Minessale II <anthm@freeswitch.org> |
27 | * Ken Rice <krice@freeswitch.org> |
28 | * Michael Murdock <mike at mmurdock dot org> |
29 | * Neal Horman <neal at wanlink dot com> |
30 | * Bret McDanel <trixter AT 0xdecafbad dot com> |
31 | * Luke Dashjr <luke@openmethods.com> (OpenMethods, LLC) |
32 | * Cesar Cepeda <cesar@auronix.com> |
33 | * Christopher M. Rienzo <chris@rienzo.com> |
34 | * Seven Du <dujinfang@gmail.com> |
35 | * William King <william.king@quentustech.com> |
36 | * |
37 | * mod_dptools.c -- Raw Audio File Streaming Application Module |
38 | * |
39 | */ |
40 | #include <switch.h> |
41 | |
42 | SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)switch_status_t mod_dptools_load (switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool); |
43 | SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dptools_shutdown)switch_status_t mod_dptools_shutdown (void); |
44 | SWITCH_MODULE_DEFINITION(mod_dptools, mod_dptools_load, mod_dptools_shutdown, NULL)static const char modname[] = "mod_dptools" ; __attribute__(( visibility("default"))) switch_loadable_module_function_table_t mod_dptools_module_interface = { 5, mod_dptools_load, mod_dptools_shutdown , ((void*)0), SMODF_NONE }; |
45 | |
46 | SWITCH_STANDARD_DIALPLAN(inline_dialplan_hunt)static switch_caller_extension_t *inline_dialplan_hunt (switch_core_session_t *session, void *arg, switch_caller_profile_t *caller_profile ) |
47 | { |
48 | switch_caller_extension_t *extension = NULL((void*)0); |
49 | char *argv[128] = { 0 }; |
50 | int argc; |
51 | switch_channel_t *channel = switch_core_session_get_channel(session); |
52 | int x = 0; |
53 | char *lbuf; |
54 | char *target = arg; |
55 | char delim = ','; |
56 | |
57 | if (!caller_profile) { |
58 | caller_profile = switch_channel_get_caller_profile(channel); |
59 | } |
60 | |
61 | if ((extension = switch_caller_extension_new(session, "inline", "inline")) == 0) { |
62 | abort(); |
63 | } |
64 | |
65 | if (zstr(target)_zstr(target)) { |
66 | target = caller_profile->destination_number; |
67 | } |
68 | |
69 | |
70 | if (zstr(target)_zstr(target)) { |
71 | return NULL((void*)0); |
72 | } else { |
73 | lbuf = switch_core_session_strdup(session, target)switch_core_perform_session_strdup(session, target, "mod_dptools.c" , (const char *)__func__, 73); |
74 | } |
75 | |
76 | if (*lbuf == 'm' && *(lbuf + 1) == ':' && *(lbuf + 3) == ':') { |
77 | delim = *(lbuf + 2); |
78 | lbuf += 4; |
79 | } |
80 | |
81 | argc = switch_separate_string(lbuf, delim, argv, (sizeof(argv) / sizeof(argv[0]))); |
82 | |
83 | for (x = 0; x < argc; x++) { |
84 | char *app = argv[x]; |
85 | char *data = strchr(app, ':')(__extension__ (__builtin_constant_p (':') && !__builtin_constant_p (app) && (':') == '\0' ? (char *) __rawmemchr (app, ':' ) : __builtin_strchr (app, ':'))); |
86 | |
87 | if (data) { |
88 | *data++ = '\0'; |
89 | } |
90 | |
91 | while (*app == ' ') { |
92 | app++; |
93 | } |
94 | |
95 | switch_caller_extension_add_application(session, extension, app, data); |
96 | } |
97 | |
98 | caller_profile->destination_number = (char *) caller_profile->rdnis; |
99 | caller_profile->rdnis = SWITCH_BLANK_STRING""; |
100 | |
101 | return extension; |
102 | } |
103 | |
104 | struct action_binding { |
105 | char *realm; |
106 | char *input; |
107 | char *string; |
108 | char *value; |
109 | switch_digit_action_target_t target; |
110 | switch_core_session_t *session; |
111 | }; |
112 | |
113 | static switch_status_t digit_nomatch_action_callback(switch_ivr_dmachine_match_t *match) |
114 | { |
115 | switch_core_session_t *session = (switch_core_session_t *) match->user_data; |
116 | switch_channel_t *channel; |
117 | switch_event_t *event; |
118 | switch_status_t status; |
119 | switch_core_session_t *use_session = session; |
120 | |
121 | if (switch_ivr_dmachine_get_target(match->dmachine) == DIGIT_TARGET_PEER) { |
122 | if (switch_core_session_get_partner(session, &use_session)switch_core_session_perform_get_partner(session, &use_session , "mod_dptools.c", (const char *)__func__, 122) != SWITCH_STATUS_SUCCESS) { |
123 | use_session = session; |
124 | } |
125 | } |
126 | |
127 | channel = switch_core_session_get_channel(use_session); |
128 | |
129 | |
130 | switch_channel_set_variable(channel, "last_non_matching_digits", match->match_digits)switch_channel_set_variable_var_check(channel, "last_non_matching_digits" , match->match_digits, SWITCH_TRUE); |
131 | |
132 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 132, (const char*)(use_session), SWITCH_LOG_DEBUG, "%s Digit NOT match binding [%s]\n", |
133 | switch_channel_get_name(channel), match->match_digits); |
134 | |
135 | if (switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) { |
136 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "digits", match->match_digits); |
137 | |
138 | if ((status = switch_core_session_queue_event(use_session, &event)) != SWITCH_STATUS_SUCCESS) { |
139 | switch_event_destroy(&event); |
140 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 140, (const char*)(use_session), SWITCH_LOG_WARNING, "%s event queue failure.\n", |
141 | switch_core_session_get_name(use_session)switch_channel_get_name(switch_core_session_get_channel(use_session ))); |
142 | } |
143 | } |
144 | |
145 | /* send it back around and skip the dmachine */ |
146 | switch_channel_queue_dtmf_string(channel, match->match_digits); |
147 | |
148 | if (use_session != session) { |
149 | switch_core_session_rwunlock(use_session); |
150 | } |
151 | |
152 | |
153 | return SWITCH_STATUS_SUCCESS; |
154 | } |
155 | |
156 | static switch_status_t digit_action_callback(switch_ivr_dmachine_match_t *match) |
157 | { |
158 | struct action_binding *act = (struct action_binding *) match->user_data; |
159 | switch_event_t *event; |
160 | switch_status_t status; |
161 | int exec = 0; |
162 | int api = 0; |
163 | char *string = act->string; |
Value stored to 'string' during its initialization is never read | |
164 | switch_channel_t *channel; |
165 | switch_core_session_t *use_session = act->session; |
166 | int x = 0; |
167 | char *flags = ""; |
168 | |
169 | if (switch_ivr_dmachine_get_target(match->dmachine) == DIGIT_TARGET_PEER || act->target == DIGIT_TARGET_PEER || act->target == DIGIT_TARGET_BOTH) { |
170 | if (switch_core_session_get_partner(act->session, &use_session)switch_core_session_perform_get_partner(act->session, & use_session, "mod_dptools.c", (const char *)__func__, 170) != SWITCH_STATUS_SUCCESS) { |
171 | use_session = act->session; |
172 | } |
173 | } |
174 | |
175 | top: |
176 | x++; |
177 | |
178 | string = switch_core_session_strdup(use_session, act->string)switch_core_perform_session_strdup(use_session, act->string , "mod_dptools.c", (const char *)__func__, 178); |
179 | exec = 0; |
180 | api = 0; |
181 | |
182 | channel = switch_core_session_get_channel(use_session); |
183 | |
184 | switch_channel_set_variable(channel, "last_matching_digits", match->match_digits)switch_channel_set_variable_var_check(channel, "last_matching_digits" , match->match_digits, SWITCH_TRUE); |
185 | |
186 | |
187 | if (switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) { |
188 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(act->session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 188, (const char*)(act->session), SWITCH_LOG_DEBUG, "%s Digit match binding [%s][%s]\n", |
189 | switch_channel_get_name(channel), act->string, act->value); |
190 | |
191 | if (!strncasecmp(string, "exec", 4)) { |
192 | char *e; |
193 | |
194 | string += 4; |
195 | if (*string == ':') { |
196 | string++; |
197 | exec = 1; |
198 | } else if (*string == '[') { |
199 | flags = string; |
200 | if ((e = switch_find_end_paren(flags, '[', ']'))) { |
201 | if (e && *++e == ':') { |
202 | flags++; |
203 | *e++ = '\0'; |
204 | string = e; |
205 | exec = strchr(flags, 'i')(__extension__ (__builtin_constant_p ('i') && !__builtin_constant_p (flags) && ('i') == '\0' ? (char *) __rawmemchr (flags , 'i') : __builtin_strchr (flags, 'i'))) ? 2 : 1; |
206 | } |
207 | } |
208 | } |
209 | } else if (!strncasecmp(string, "api:", 4)) { |
210 | string += 4; |
211 | api = 1; |
212 | } |
213 | |
214 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, string, act->value); |
215 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "digits", match->match_digits); |
216 | |
217 | if (exec) { |
218 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "execute", exec == 1 ? "non-blocking" : "blocking"); |
219 | } |
220 | |
221 | if ((status = switch_core_session_queue_event(use_session, &event)) != SWITCH_STATUS_SUCCESS) { |
222 | switch_event_destroy(&event); |
223 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(use_session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 223, (const char*)(use_session), SWITCH_LOG_WARNING, "%s event queue failure.\n", |
224 | switch_core_session_get_name(use_session)switch_channel_get_name(switch_core_session_get_channel(use_session ))); |
225 | } |
226 | } |
227 | |
228 | if (exec) { |
229 | if (exec == 2) { |
230 | switch_core_session_execute_application(use_session, string, act->value)switch_core_session_execute_application_get_flags(use_session , string, act->value, ((void*)0)); |
231 | } else { |
232 | char *cmd = switch_core_session_sprintf(use_session, "%s::%s", string, act->value); |
233 | switch_media_flag_enum_t exec_flags = SMF_ECHO_ALEG; |
234 | |
235 | if (act->target != DIGIT_TARGET_BOTH && !strchr(flags, 'H')(__extension__ (__builtin_constant_p ('H') && !__builtin_constant_p (flags) && ('H') == '\0' ? (char *) __rawmemchr (flags , 'H') : __builtin_strchr (flags, 'H')))) { |
236 | exec_flags |= SMF_HOLD_BLEG; |
237 | } |
238 | |
239 | switch_ivr_broadcast_in_thread(use_session, cmd, exec_flags); |
240 | } |
241 | } else if (api) { |
242 | switch_stream_handle_t stream = { 0 }; |
243 | SWITCH_STANDARD_STREAM(stream)memset(&stream, 0, sizeof(stream)); stream.data = malloc( 1024); ((stream.data) ? (void) (0) : __assert_fail ("stream.data" , "mod_dptools.c", 243, __PRETTY_FUNCTION__)); memset(stream. data, 0, 1024); stream.end = stream.data; stream.data_size = 1024 ; stream.write_function = switch_console_stream_write; stream .raw_write_function = switch_console_stream_raw_write; stream .alloc_len = 1024; stream.alloc_chunk = 1024; |
244 | switch_api_execute(string, act->value, NULL((void*)0), &stream); |
245 | if (stream.data) { |
246 | switch_channel_set_variable(channel, "bind_digit_action_api_result", (char *)stream.data)switch_channel_set_variable_var_check(channel, "bind_digit_action_api_result" , (char *)stream.data, SWITCH_TRUE); |
247 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(act->session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 247, (const char*)(act->session), SWITCH_LOG_DEBUG, "%s Digit match binding [%s][%s] api executed, %s\n", |
248 | switch_core_session_get_name(use_session)switch_channel_get_name(switch_core_session_get_channel(use_session )), act->string, act->value, (char *)stream.data); |
249 | } else { |
250 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(act->session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 250, (const char*)(act->session), SWITCH_LOG_DEBUG, "%s Digit match binding [%s][%s] api executed\n", |
251 | switch_core_session_get_name(use_session)switch_channel_get_name(switch_core_session_get_channel(use_session )), act->string, act->value); |
252 | } |
253 | switch_safe_free(stream.data)if (stream.data) {free(stream.data);stream.data=((void*)0);}; |
254 | } |
255 | |
256 | |
257 | if (use_session != act->session) { |
258 | switch_core_session_rwunlock(use_session); |
259 | |
260 | if (act->target == DIGIT_TARGET_BOTH) { |
261 | use_session = act->session; |
262 | goto top; |
263 | } |
264 | } |
265 | |
266 | return SWITCH_STATUS_SUCCESS; |
267 | } |
268 | |
269 | static switch_digit_action_target_t str2target(const char *target_str) |
270 | { |
271 | if (!strcasecmp(target_str, "peer")) { |
272 | return DIGIT_TARGET_PEER; |
273 | } |
274 | |
275 | if (!strcasecmp(target_str, "both")) { |
276 | return DIGIT_TARGET_BOTH; |
277 | } |
278 | |
279 | return DIGIT_TARGET_SELF; |
280 | } |
281 | |
282 | #define CLEAR_DIGIT_ACTION_USAGE"<realm>|all[,target]" "<realm>|all[,target]" |
283 | SWITCH_STANDARD_APP(clear_digit_action_function)static void clear_digit_action_function (switch_core_session_t *session, const char *data) |
284 | { |
285 | //switch_channel_t *channel = switch_core_session_get_channel(session); |
286 | switch_ivr_dmachine_t *dmachine; |
287 | char *realm = NULL((void*)0); |
288 | char *target_str; |
289 | switch_digit_action_target_t target = DIGIT_TARGET_SELF; |
290 | |
291 | if (zstr((char *)data)_zstr((char *)data)) { |
292 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 292, ((void*)0), SWITCH_LOG_WARNING, "clear_digit_action called with no args"); |
293 | return; |
294 | } |
295 | |
296 | realm = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 296); |
297 | |
298 | if ((target_str = strchr(realm, ',')(__extension__ (__builtin_constant_p (',') && !__builtin_constant_p (realm) && (',') == '\0' ? (char *) __rawmemchr (realm , ',') : __builtin_strchr (realm, ','))))) { |
299 | *target_str++ = '\0'; |
300 | target = str2target(target_str); |
301 | } |
302 | |
303 | |
304 | if ((dmachine = switch_core_session_get_dmachine(session, target))) { |
305 | if (zstr(realm)_zstr(realm) || !strcasecmp(realm, "all")) { |
306 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 306, ((void*)0), SWITCH_LOG_INFO, "Digit parser %s: Clearing all realms\n", switch_ivr_dmachine_get_name(dmachine)); |
307 | switch_core_session_set_dmachine(session, NULL((void*)0), target); |
308 | switch_ivr_dmachine_destroy(&dmachine); |
309 | } else { |
310 | switch_ivr_dmachine_clear_realm(dmachine, realm); |
311 | } |
312 | } |
313 | } |
314 | |
315 | #define DIGIT_ACTION_SET_REALM_USAGE"<realm>[,<target>]" "<realm>[,<target>]" |
316 | SWITCH_STANDARD_APP(digit_action_set_realm_function)static void digit_action_set_realm_function (switch_core_session_t *session, const char *data) |
317 | { |
318 | switch_ivr_dmachine_t *dmachine; |
319 | char *realm = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 319); |
320 | char *target_str; |
321 | switch_digit_action_target_t target = DIGIT_TARGET_SELF; |
322 | |
323 | if ((target_str = strchr(realm, ',')(__extension__ (__builtin_constant_p (',') && !__builtin_constant_p (realm) && (',') == '\0' ? (char *) __rawmemchr (realm , ',') : __builtin_strchr (realm, ','))))) { |
324 | *target_str++ = '\0'; |
325 | target = str2target(target_str); |
326 | } |
327 | |
328 | if (zstr(data)_zstr(data)) { |
329 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 329, (const char*)(session), SWITCH_LOG_WARNING, "Syntax Error, USAGE %s\n", DIGIT_ACTION_SET_REALM_USAGE"<realm>[,<target>]"); |
330 | return; |
331 | } |
332 | |
333 | |
334 | if ((dmachine = switch_core_session_get_dmachine(session, target))) { |
335 | switch_ivr_dmachine_set_realm(dmachine, realm); |
336 | } |
337 | |
338 | } |
339 | |
340 | |
341 | static void bind_to_session(switch_core_session_t *session, |
342 | const char *arg0, const char *arg1, const char *arg2, const char *arg3, |
343 | switch_digit_action_target_t target, switch_digit_action_target_t bind_target) |
344 | { |
345 | struct action_binding *act; |
346 | switch_ivr_dmachine_t *dmachine; |
347 | switch_channel_t *channel = switch_core_session_get_channel(session); |
348 | const char *terminators = NULL((void*)0); |
349 | |
350 | if (!(dmachine = switch_core_session_get_dmachine(session, target))) { |
351 | uint32_t digit_timeout = 1500; |
352 | uint32_t input_timeout = 0; |
353 | const char *var; |
354 | |
355 | if ((var = switch_channel_get_variable(channel, "bind_digit_digit_timeout")switch_channel_get_variable_dup(channel, "bind_digit_digit_timeout" , SWITCH_TRUE, -1))) { |
356 | digit_timeout = switch_atoul(var); |
357 | } |
358 | |
359 | if ((var = switch_channel_get_variable(channel, "bind_digit_input_timeout")switch_channel_get_variable_dup(channel, "bind_digit_input_timeout" , SWITCH_TRUE, -1))) { |
360 | input_timeout = switch_atoul(var); |
361 | } |
362 | |
363 | switch_ivr_dmachine_create(&dmachine, "DPTOOLS", NULL((void*)0), digit_timeout, input_timeout, NULL((void*)0), digit_nomatch_action_callback, session); |
364 | switch_core_session_set_dmachine(session, dmachine, target); |
365 | } |
366 | |
367 | |
368 | act = switch_core_session_alloc(session, sizeof(*act))switch_core_perform_session_alloc(session, sizeof(*act), "mod_dptools.c" , (const char *)__func__, 368); |
369 | act->realm = switch_core_session_strdup(session, arg0)switch_core_perform_session_strdup(session, arg0, "mod_dptools.c" , (const char *)__func__, 369); |
370 | act->input = switch_core_session_strdup(session, arg1)switch_core_perform_session_strdup(session, arg1, "mod_dptools.c" , (const char *)__func__, 370); |
371 | act->string = switch_core_session_strdup(session, arg2)switch_core_perform_session_strdup(session, arg2, "mod_dptools.c" , (const char *)__func__, 371); |
372 | act->value = switch_core_session_strdup(session, arg3)switch_core_perform_session_strdup(session, arg3, "mod_dptools.c" , (const char *)__func__, 372); |
373 | act->target = bind_target; |
374 | act->session = session; |
375 | switch_ivr_dmachine_bind(dmachine, act->realm, act->input, 0, digit_action_callback, act); |
376 | |
377 | if ((terminators = switch_channel_get_variable(channel, "bda_terminators")switch_channel_get_variable_dup(channel, "bda_terminators", SWITCH_TRUE , -1))) { |
378 | switch_ivr_dmachine_set_terminators(dmachine, terminators); |
379 | } |
380 | } |
381 | |
382 | #define BIND_DIGIT_ACTION_USAGE"<realm>,<digits|~regex>,<string>[,<value>][,<dtmf target leg>][,<event target leg>]" "<realm>,<digits|~regex>,<string>[,<value>][,<dtmf target leg>][,<event target leg>]" |
383 | SWITCH_STANDARD_APP(bind_digit_action_function)static void bind_digit_action_function (switch_core_session_t *session, const char *data) |
384 | { |
385 | |
386 | char *mydata; |
387 | int argc = 0; |
388 | char *argv[6] = { 0 }; |
389 | switch_digit_action_target_t target, bind_target; |
390 | char *target_str = "self", *bind_target_str = "self"; |
391 | char *value = ""; |
392 | |
393 | if (zstr(data)_zstr(data)) { |
394 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 394, (const char*)(session), SWITCH_LOG_WARNING, "Syntax Error, USAGE %s\n", BIND_DIGIT_ACTION_USAGE"<realm>,<digits|~regex>,<string>[,<value>][,<dtmf target leg>][,<event target leg>]"); |
395 | return; |
396 | } |
397 | |
398 | mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 398); |
399 | |
400 | argc = switch_separate_string(mydata, ',', argv, (sizeof(argv) / sizeof(argv[0]))); |
401 | |
402 | if (argc < 3 || zstr(argv[0])_zstr(argv[0]) || zstr(argv[1])_zstr(argv[1]) || zstr(argv[2])_zstr(argv[2])) { |
403 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 403, (const char*)(session), SWITCH_LOG_WARNING, "Syntax Error, USAGE %s\n", BIND_DIGIT_ACTION_USAGE"<realm>,<digits|~regex>,<string>[,<value>][,<dtmf target leg>][,<event target leg>]"); |
404 | return; |
405 | } |
406 | |
407 | if (argv[3]) { |
408 | value = argv[3]; |
409 | } |
410 | |
411 | if (argv[4]) { |
412 | target_str = argv[4]; |
413 | } |
414 | |
415 | if (argv[5]) { |
416 | bind_target_str = argv[5]; |
417 | } |
418 | |
419 | target = str2target(target_str); |
420 | bind_target = str2target(bind_target_str); |
421 | |
422 | |
423 | switch(target) { |
424 | case DIGIT_TARGET_PEER: |
425 | bind_to_session(session, argv[0], argv[1], argv[2], value, DIGIT_TARGET_PEER, bind_target); |
426 | break; |
427 | case DIGIT_TARGET_BOTH: |
428 | bind_to_session(session, argv[0], argv[1], argv[2], value, DIGIT_TARGET_PEER, bind_target); |
429 | bind_to_session(session, argv[0], argv[1], argv[2], value, DIGIT_TARGET_SELF, bind_target); |
430 | break; |
431 | default: |
432 | bind_to_session(session, argv[0], argv[1], argv[2], value, DIGIT_TARGET_SELF, bind_target); |
433 | break; |
434 | } |
435 | } |
436 | |
437 | #define DETECT_SPEECH_SYNTAX"<mod_name> <gram_name> <gram_path> [<addr>] OR grammar <gram_name> [<path>] OR nogrammar <gram_name> OR grammaron/grammaroff <gram_name> OR grammarsalloff OR pause OR resume OR start_input_timers OR stop OR param <name> <value>" "<mod_name> <gram_name> <gram_path> [<addr>] OR grammar <gram_name> [<path>] OR nogrammar <gram_name> OR grammaron/grammaroff <gram_name> OR grammarsalloff OR pause OR resume OR start_input_timers OR stop OR param <name> <value>" |
438 | SWITCH_STANDARD_APP(detect_speech_function)static void detect_speech_function (switch_core_session_t *session , const char *data) |
439 | { |
440 | char *argv[4]; |
441 | int argc; |
442 | char *lbuf = NULL((void*)0); |
443 | |
444 | if (!zstr(data)_zstr(data) && (lbuf = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 444)) |
445 | && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { |
446 | if (!strcasecmp(argv[0], "grammar") && argc >= 1) { |
447 | switch_ivr_detect_speech_load_grammar(session, argv[1], argv[2]); |
448 | } else if (!strcasecmp(argv[0], "nogrammar")) { |
449 | switch_ivr_detect_speech_unload_grammar(session, argv[1]); |
450 | } else if (!strcasecmp(argv[0], "grammaron")) { |
451 | switch_ivr_detect_speech_enable_grammar(session, argv[1]); |
452 | } else if (!strcasecmp(argv[0], "grammaroff")) { |
453 | switch_ivr_detect_speech_disable_grammar(session, argv[1]); |
454 | } else if (!strcasecmp(argv[0], "grammarsalloff")) { |
455 | switch_ivr_detect_speech_disable_all_grammars(session); |
456 | } else if (!strcasecmp(argv[0], "init")) { |
457 | switch_ivr_detect_speech_init(session, argv[1], argv[2], NULL((void*)0)); |
458 | } else if (!strcasecmp(argv[0], "pause")) { |
459 | switch_ivr_pause_detect_speech(session); |
460 | } else if (!strcasecmp(argv[0], "resume")) { |
461 | switch_ivr_resume_detect_speech(session); |
462 | } else if (!strcasecmp(argv[0], "stop")) { |
463 | switch_ivr_stop_detect_speech(session); |
464 | } else if (!strcasecmp(argv[0], "param")) { |
465 | switch_ivr_set_param_detect_speech(session, argv[1], argv[2]); |
466 | } else if (!strcasecmp(argv[0], "start_input_timers")) { |
467 | switch_ivr_detect_speech_start_input_timers(session); |
468 | } else if (argc >= 3) { |
469 | switch_ivr_detect_speech(session, argv[0], argv[1], argv[2], argv[3], NULL((void*)0)); |
470 | } |
471 | } else { |
472 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 472, ((void*)0), SWITCH_LOG_ERROR, "Usage: %s\n", DETECT_SPEECH_SYNTAX"<mod_name> <gram_name> <gram_path> [<addr>] OR grammar <gram_name> [<path>] OR nogrammar <gram_name> OR grammaron/grammaroff <gram_name> OR grammarsalloff OR pause OR resume OR start_input_timers OR stop OR param <name> <value>"); |
473 | } |
474 | } |
475 | |
476 | #define PLAY_AND_DETECT_SPEECH_SYNTAX"<file> detect:<engine> {param1=val1,param2=val2}<grammar>" "<file> detect:<engine> {param1=val1,param2=val2}<grammar>" |
477 | SWITCH_STANDARD_APP(play_and_detect_speech_function)static void play_and_detect_speech_function (switch_core_session_t *session, const char *data) |
478 | { |
479 | switch_channel_t *channel = switch_core_session_get_channel(session); |
480 | char *argv[2]; |
481 | char *lbuf = NULL((void*)0); |
482 | const char *response = "DONE"; |
483 | char *detect = NULL((void*)0); |
484 | char *s; |
485 | |
486 | switch_channel_set_variable(channel, "detect_speech_result", "")switch_channel_set_variable_var_check(channel, "detect_speech_result" , "", SWITCH_TRUE); |
487 | |
488 | if (zstr(data)_zstr(data) || !(lbuf = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 488)) || !(detect = strstr(lbuf, "detect:"))) { |
489 | /* bad input */ |
490 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 490, ((void*)0), SWITCH_LOG_ERROR, "Usage: %s\n", PLAY_AND_DETECT_SPEECH_SYNTAX"<file> detect:<engine> {param1=val1,param2=val2}<grammar>"); |
491 | response = "USAGE ERROR"; |
492 | goto done; |
493 | } |
494 | |
495 | /* trim any trailing space */ |
496 | s = detect; |
497 | while (--s >= lbuf && switch_isspace(*s)) { |
498 | *s = '\0'; |
499 | } |
500 | |
501 | /* split input at "detect:" */ |
502 | detect[0] = '\0'; |
503 | detect += 7; |
504 | if (zstr(detect)_zstr(detect)) { |
505 | /* bad input */ |
506 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 506, ((void*)0), SWITCH_LOG_ERROR, "Usage: %s\n", PLAY_AND_DETECT_SPEECH_SYNTAX"<file> detect:<engine> {param1=val1,param2=val2}<grammar>"); |
507 | response = "USAGE ERROR"; |
508 | goto done; |
509 | } |
510 | |
511 | /* need to have at 2 parameters for detect */ |
512 | if (switch_separate_string(detect, ' ', argv, (sizeof(argv) / sizeof(argv[0]))) == 2) { |
513 | char *file = lbuf; |
514 | char *engine = argv[0]; |
515 | char *grammar = argv[1]; |
516 | char *result = NULL((void*)0); |
517 | switch_ivr_play_and_detect_speech(session, file, engine, grammar, &result, 0, NULL((void*)0)); |
518 | switch_channel_set_variable(channel, "detect_speech_result", result)switch_channel_set_variable_var_check(channel, "detect_speech_result" , result, SWITCH_TRUE); |
519 | } else { |
520 | /* bad input */ |
521 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 521, ((void*)0), SWITCH_LOG_ERROR, "Usage: %s\n", PLAY_AND_DETECT_SPEECH_SYNTAX"<file> detect:<engine> {param1=val1,param2=val2}<grammar>"); |
522 | response = "USAGE ERROR"; |
523 | } |
524 | |
525 | done: |
526 | switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, response)switch_channel_set_variable_var_check(channel, "current_application_response" , response, SWITCH_TRUE); |
527 | } |
528 | |
529 | #define SCHED_HEARTBEAT_SYNTAX"[0|<seconds>]" "[0|<seconds>]" |
530 | SWITCH_STANDARD_APP(sched_heartbeat_function)static void sched_heartbeat_function (switch_core_session_t * session, const char *data) |
531 | { |
532 | int seconds = 0; |
533 | |
534 | if (data) { |
535 | seconds = atoi(data); |
536 | if (seconds >= 0) { |
537 | switch_core_session_sched_heartbeat(session, seconds); |
538 | return; |
539 | } |
540 | } |
541 | |
542 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 542, (const char*)(session), SWITCH_LOG_ERROR, "Usage: %s\n", SCHED_HEARTBEAT_SYNTAX"[0|<seconds>]"); |
543 | |
544 | } |
545 | |
546 | |
547 | #define HEARTBEAT_SYNTAX"[0|<seconds>]" "[0|<seconds>]" |
548 | SWITCH_STANDARD_APP(heartbeat_function)static void heartbeat_function (switch_core_session_t *session , const char *data) |
549 | { |
550 | int seconds = 0; |
551 | |
552 | if (data) { |
553 | seconds = atoi(data); |
554 | if (seconds >= 0) { |
555 | |
556 | switch_core_session_enable_heartbeat(session, seconds); |
557 | return; |
558 | } |
559 | } |
560 | |
561 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 561, (const char*)(session), SWITCH_LOG_ERROR, "Usage: %s\n", HEARTBEAT_SYNTAX"[0|<seconds>]"); |
562 | |
563 | } |
564 | |
565 | |
566 | #define KEEPALIVE_SYNTAX"[0|<seconds>]" "[0|<seconds>]" |
567 | SWITCH_STANDARD_APP(keepalive_function)static void keepalive_function (switch_core_session_t *session , const char *data) |
568 | { |
569 | int seconds = 0; |
570 | |
571 | if (data) { |
572 | seconds = atoi(data); |
573 | if (seconds >= 0) { |
574 | switch_core_session_message_t msg = { 0 }; |
575 | |
576 | msg.message_id = SWITCH_MESSAGE_INDICATE_KEEPALIVE; |
577 | msg.numeric_arg = seconds; |
578 | switch_core_session_receive_message(session, &msg)switch_core_session_perform_receive_message(session, &msg , "mod_dptools.c", (const char *)__func__, 578); |
579 | |
580 | switch_core_session_enable_heartbeat(session, seconds); |
581 | return; |
582 | } |
583 | } |
584 | |
585 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 585, (const char*)(session), SWITCH_LOG_ERROR, "Usage: %s\n", HEARTBEAT_SYNTAX"[0|<seconds>]"); |
586 | |
587 | } |
588 | |
589 | #define EXE_SYNTAX"<extension> <dialplan> <context>" "<extension> <dialplan> <context>" |
590 | SWITCH_STANDARD_APP(exe_function)static void exe_function (switch_core_session_t *session, const char *data) |
591 | { |
592 | char *argv[4] = { 0 }; |
593 | int argc; |
594 | char *lbuf = NULL((void*)0); |
595 | |
596 | if (!zstr(data)_zstr(data) && (lbuf = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 596)) |
597 | && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { |
598 | switch_core_session_execute_exten(session, argv[0], argv[1], argv[2]); |
599 | } else { |
600 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 600, (const char*)(session), SWITCH_LOG_ERROR, "Usage: %s\n", EXE_SYNTAX"<extension> <dialplan> <context>"); |
601 | } |
602 | } |
603 | |
604 | #define MKDIR_SYNTAX"<path>" "<path>" |
605 | SWITCH_STANDARD_APP(mkdir_function)static void mkdir_function (switch_core_session_t *session, const char *data) |
606 | { |
607 | switch_dir_make_recursive(data, SWITCH_DEFAULT_DIR_PERMS0x0400 | 0x0200 | 0x0100 | 0x0040 | 0x0010, switch_core_session_get_pool(session)); |
608 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 608, (const char*)(session), SWITCH_LOG_DEBUG, "%s MKDIR: %s\n", |
609 | switch_channel_get_name(switch_core_session_get_channel(session)), data); |
610 | } |
611 | #define RENAME_SYNTAX"<from_path> <to_path>" "<from_path> <to_path>" |
612 | SWITCH_STANDARD_APP(rename_function)static void rename_function (switch_core_session_t *session, const char *data) |
613 | { |
614 | char *argv[2] = { 0 }; |
615 | char *lbuf = NULL((void*)0); |
616 | |
617 | if (!zstr(data)_zstr(data) && (lbuf = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 617)) |
618 | && switch_split(lbuf, ' ', argv)switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof (argv[0]))) == 2) { |
619 | switch_file_rename(argv[0], argv[1], switch_core_session_get_pool(session)); |
620 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 620, (const char*)(session), SWITCH_LOG_DEBUG, "%s RENAME: %s %s\n", |
621 | switch_channel_get_name(switch_core_session_get_channel(session)), argv[0], argv[1]); |
622 | |
623 | } else { |
624 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 624, (const char*)(session), SWITCH_LOG_ERROR, "Usage: %s\n", RENAME_SYNTAX"<from_path> <to_path>"); |
625 | } |
626 | } |
627 | |
628 | #define SOFT_HOLD_SYNTAX"<unhold key> [<moh_a>] [<moh_b>]" "<unhold key> [<moh_a>] [<moh_b>]" |
629 | SWITCH_STANDARD_APP(soft_hold_function)static void soft_hold_function (switch_core_session_t *session , const char *data) |
630 | { |
631 | char *argv[3] = { 0 }; |
632 | int argc; |
633 | char *lbuf = NULL((void*)0); |
634 | |
635 | if (!zstr(data)_zstr(data) && (lbuf = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 635)) |
636 | && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) { |
637 | switch_ivr_soft_hold(session, argv[0], argv[1], argv[2]); |
638 | } else { |
639 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 639, (const char*)(session), SWITCH_LOG_ERROR, "Usage: %s\n", SOFT_HOLD_SYNTAX"<unhold key> [<moh_a>] [<moh_b>]"); |
640 | } |
641 | } |
642 | |
643 | SWITCH_STANDARD_APP(dtmf_unblock_function)static void dtmf_unblock_function (switch_core_session_t *session , const char *data) |
644 | { |
645 | switch_ivr_unblock_dtmf_session(session); |
646 | } |
647 | |
648 | SWITCH_STANDARD_APP(media_reset_function)static void media_reset_function (switch_core_session_t *session , const char *data) |
649 | { |
650 | switch_channel_t *channel = switch_core_session_get_channel(session); |
651 | const char *name = switch_channel_get_name(channel); |
652 | |
653 | if (switch_channel_media_ready(channel)switch_channel_test_ready(channel, SWITCH_TRUE, SWITCH_TRUE)) { |
654 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 654, (const char*)(session), SWITCH_LOG_WARNING, "%s This function does not work once media has been established.\n", name); |
655 | return; |
656 | } |
657 | |
658 | switch_channel_clear_flag(channel, CF_PROXY_MODE); |
659 | switch_channel_clear_flag(channel, CF_PROXY_MEDIA); |
660 | switch_channel_set_variable(channel, "bypass_media", NULL)switch_channel_set_variable_var_check(channel, "bypass_media" , ((void*)0), SWITCH_TRUE); |
661 | switch_channel_set_variable(channel, "proxy_media", NULL)switch_channel_set_variable_var_check(channel, "proxy_media", ((void*)0), SWITCH_TRUE); |
662 | |
663 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 663, (const char*)(session), SWITCH_LOG_INFO, "%sReset MEDIA flags.\n", name); |
664 | } |
665 | |
666 | SWITCH_STANDARD_APP(dtmf_block_function)static void dtmf_block_function (switch_core_session_t *session , const char *data) |
667 | { |
668 | switch_ivr_block_dtmf_session(session); |
669 | } |
670 | |
671 | #define UNBIND_SYNTAX"[<key>]" "[<key>]" |
672 | SWITCH_STANDARD_APP(dtmf_unbind_function)static void dtmf_unbind_function (switch_core_session_t *session , const char *data) |
673 | { |
674 | char *key = (char *) data; |
675 | int kval = 0; |
676 | |
677 | if (key) { |
678 | kval = switch_dtmftoi(key); |
679 | } |
680 | |
681 | switch_ivr_unbind_dtmf_meta_session(session, kval); |
682 | |
683 | } |
684 | |
685 | #define BIND_SYNTAX"<key> [a|b|ab] [a|b|o|s|i|1] <app>" "<key> [a|b|ab] [a|b|o|s|i|1] <app>" |
686 | SWITCH_STANDARD_APP(dtmf_bind_function)static void dtmf_bind_function (switch_core_session_t *session , const char *data) |
687 | { |
688 | char *argv[4] = { 0 }; |
689 | int argc; |
690 | char *lbuf = NULL((void*)0); |
691 | |
692 | if (!zstr(data)_zstr(data) && (lbuf = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 692)) |
693 | && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) { |
694 | int kval = switch_dtmftoi(argv[0]); |
695 | switch_bind_flag_t bind_flags = 0; |
696 | |
697 | if (strchr(argv[1], 'a')(__extension__ (__builtin_constant_p ('a') && !__builtin_constant_p (argv[1]) && ('a') == '\0' ? (char *) __rawmemchr (argv [1], 'a') : __builtin_strchr (argv[1], 'a')))) { |
698 | bind_flags |= SBF_DIAL_ALEG; |
699 | } |
700 | |
701 | if (strchr(argv[1], 'b')(__extension__ (__builtin_constant_p ('b') && !__builtin_constant_p (argv[1]) && ('b') == '\0' ? (char *) __rawmemchr (argv [1], 'b') : __builtin_strchr (argv[1], 'b')))) { |
702 | bind_flags |= SBF_DIAL_BLEG; |
703 | } |
704 | |
705 | if (strchr(argv[2], 'a')(__extension__ (__builtin_constant_p ('a') && !__builtin_constant_p (argv[2]) && ('a') == '\0' ? (char *) __rawmemchr (argv [2], 'a') : __builtin_strchr (argv[2], 'a')))) { |
706 | if ((bind_flags & SBF_EXEC_BLEG)) { |
707 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 707, (const char*)(session), SWITCH_LOG_ERROR, "Cannot bind execute to multiple legs\n"); |
708 | } else { |
709 | bind_flags |= SBF_EXEC_ALEG; |
710 | } |
711 | } |
712 | |
713 | if (strchr(argv[2], 'b')(__extension__ (__builtin_constant_p ('b') && !__builtin_constant_p (argv[2]) && ('b') == '\0' ? (char *) __rawmemchr (argv [2], 'b') : __builtin_strchr (argv[2], 'b')))) { |
714 | if ((bind_flags & SBF_EXEC_ALEG)) { |
715 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 715, (const char*)(session), SWITCH_LOG_ERROR, "Cannot bind execute to multiple legs\n"); |
716 | } else { |
717 | bind_flags |= SBF_EXEC_BLEG; |
718 | } |
719 | } |
720 | |
721 | if (strchr(argv[2], 'a')(__extension__ (__builtin_constant_p ('a') && !__builtin_constant_p (argv[2]) && ('a') == '\0' ? (char *) __rawmemchr (argv [2], 'a') : __builtin_strchr (argv[2], 'a')))) { |
722 | if ((bind_flags & SBF_EXEC_BLEG)) { |
723 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 723, (const char*)(session), SWITCH_LOG_ERROR, "Cannot bind execute to multiple legs\n"); |
724 | } else { |
725 | bind_flags |= SBF_EXEC_ALEG; |
726 | } |
727 | } |
728 | |
729 | if (strchr(argv[2], 'i')(__extension__ (__builtin_constant_p ('i') && !__builtin_constant_p (argv[2]) && ('i') == '\0' ? (char *) __rawmemchr (argv [2], 'i') : __builtin_strchr (argv[2], 'i')))) { |
730 | bind_flags |= SBF_EXEC_INLINE; |
731 | } |
732 | |
733 | if (strchr(argv[2], 'o')(__extension__ (__builtin_constant_p ('o') && !__builtin_constant_p (argv[2]) && ('o') == '\0' ? (char *) __rawmemchr (argv [2], 'o') : __builtin_strchr (argv[2], 'o')))) { |
734 | if ((bind_flags & SBF_EXEC_BLEG) || (bind_flags & SBF_EXEC_ALEG) || (bind_flags & SBF_EXEC_SAME)) { |
735 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 735, (const char*)(session), SWITCH_LOG_ERROR, "Cannot bind execute to multiple legs\n"); |
736 | } else { |
737 | bind_flags |= SBF_EXEC_OPPOSITE; |
738 | } |
739 | } |
740 | |
741 | if (strchr(argv[2], 's')(__extension__ (__builtin_constant_p ('s') && !__builtin_constant_p (argv[2]) && ('s') == '\0' ? (char *) __rawmemchr (argv [2], 's') : __builtin_strchr (argv[2], 's')))) { |
742 | if ((bind_flags & SBF_EXEC_BLEG) || (bind_flags & SBF_EXEC_ALEG) || (bind_flags & SBF_EXEC_SAME)) { |
743 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 743, (const char*)(session), SWITCH_LOG_ERROR, "Cannot bind execute to multiple legs\n"); |
744 | } else { |
745 | bind_flags |= SBF_EXEC_SAME; |
746 | } |
747 | } |
748 | |
749 | if (strchr(argv[2], '1')(__extension__ (__builtin_constant_p ('1') && !__builtin_constant_p (argv[2]) && ('1') == '\0' ? (char *) __rawmemchr (argv [2], '1') : __builtin_strchr (argv[2], '1')))) { |
750 | bind_flags |= SBF_ONCE; |
751 | } |
752 | |
753 | if (switch_ivr_bind_dtmf_meta_session(session, kval, bind_flags, argv[3]) != SWITCH_STATUS_SUCCESS) { |
754 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 754, (const char*)(session), SWITCH_LOG_ERROR, "Bind Error!\n"); |
755 | } |
756 | } else { |
757 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 757, (const char*)(session), SWITCH_LOG_ERROR, "Usage: %s\n", BIND_SYNTAX"<key> [a|b|ab] [a|b|o|s|i|1] <app>"); |
758 | } |
759 | } |
760 | |
761 | #define INTERCEPT_SYNTAX"[-bleg] <uuid>" "[-bleg] <uuid>" |
762 | SWITCH_STANDARD_APP(intercept_function)static void intercept_function (switch_core_session_t *session , const char *data) |
763 | { |
764 | int argc; |
765 | char *argv[4] = { 0 }; |
766 | char *mydata; |
767 | char *uuid; |
768 | switch_bool_t bleg = SWITCH_FALSE; |
769 | |
770 | if (!zstr(data)_zstr(data) && (mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 770))) { |
771 | if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) { |
772 | if (!strcasecmp(argv[0], "-bleg")) { |
773 | if (argv[1]) { |
774 | uuid = argv[1]; |
775 | bleg = SWITCH_TRUE; |
776 | } else { |
777 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 777, (const char*)(session), SWITCH_LOG_ERROR, "Usage: %s\n", INTERCEPT_SYNTAX"[-bleg] <uuid>"); |
778 | return; |
779 | } |
780 | } else { |
781 | uuid = argv[0]; |
782 | } |
783 | |
784 | switch_ivr_intercept_session(session, uuid, bleg); |
785 | } |
786 | return; |
787 | } |
788 | |
789 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 789, (const char*)(session), SWITCH_LOG_ERROR, "Usage: %s\n", INTERCEPT_SYNTAX"[-bleg] <uuid>"); |
790 | } |
791 | |
792 | #define MAX_SPY3000 3000 |
793 | struct e_data { |
794 | char *uuid_list[MAX_SPY3000]; |
795 | int total; |
796 | }; |
797 | |
798 | static int e_callback(void *pArg, int argc, char **argv, char **columnNames) |
799 | { |
800 | char *uuid = argv[0]; |
801 | struct e_data *e_data = (struct e_data *) pArg; |
802 | |
803 | if (uuid && e_data) { |
804 | e_data->uuid_list[e_data->total++] = strdup(uuid)(__extension__ (__builtin_constant_p (uuid) && ((size_t )(const void *)((uuid) + 1) - (size_t)(const void *)(uuid) == 1) ? (((const char *) (uuid))[0] == '\0' ? (char *) calloc ( (size_t) 1, (size_t) 1) : ({ size_t __len = strlen (uuid) + 1 ; char *__retval = (char *) malloc (__len); if (__retval != ( (void*)0)) __retval = (char *) memcpy (__retval, uuid, __len) ; __retval; })) : __strdup (uuid))); |
805 | return 0; |
806 | } |
807 | |
808 | return 1; |
809 | } |
810 | |
811 | #define eavesdrop_SYNTAX"[all | <uuid>]" "[all | <uuid>]" |
812 | SWITCH_STANDARD_APP(eavesdrop_function)static void eavesdrop_function (switch_core_session_t *session , const char *data) |
813 | { |
814 | if (zstr(data)_zstr(data)) { |
815 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 815, (const char*)(session), SWITCH_LOG_ERROR, "Usage: %s\n", eavesdrop_SYNTAX"[all | <uuid>]"); |
816 | } else { |
817 | switch_eavesdrop_flag_t flags = ED_DTMF; |
818 | switch_channel_t *channel = switch_core_session_get_channel(session); |
819 | const char *require_group = switch_channel_get_variable(channel, "eavesdrop_require_group")switch_channel_get_variable_dup(channel, "eavesdrop_require_group" , SWITCH_TRUE, -1); |
820 | const char *enable_dtmf = switch_channel_get_variable(channel, "eavesdrop_enable_dtmf")switch_channel_get_variable_dup(channel, "eavesdrop_enable_dtmf" , SWITCH_TRUE, -1); |
821 | |
822 | if (enable_dtmf) { |
823 | flags = switch_true(enable_dtmf) ? ED_DTMF : ED_NONE; |
824 | } |
825 | |
826 | if (!strcasecmp((char *) data, "all")) { |
827 | switch_cache_db_handle_t *db = NULL((void*)0); |
828 | char *errmsg = NULL((void*)0); |
829 | struct e_data e_data = { {0} }; |
830 | char *sql = switch_mprintf("select uuid from channels where uuid != '%q'", switch_core_session_get_uuid(session)); |
831 | const char *file = NULL((void*)0); |
832 | int x = 0; |
833 | char buf[2] = ""; |
834 | switch_size_t buflen = sizeof(buf); |
835 | char terminator; |
836 | switch_status_t status; |
837 | |
838 | while (switch_channel_ready(channel)switch_channel_test_ready(channel, SWITCH_TRUE, SWITCH_FALSE)) { |
839 | for (x = 0; x < MAX_SPY3000; x++) { |
840 | switch_safe_free(e_data.uuid_list[x])if (e_data.uuid_list[x]) {free(e_data.uuid_list[x]);e_data.uuid_list [x]=((void*)0);}; |
841 | } |
842 | e_data.total = 0; |
843 | |
844 | if (switch_core_db_handle(&db)_switch_core_db_handle(&db, "mod_dptools.c", (const char * )__func__, 844) != SWITCH_STATUS_SUCCESS) { |
845 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 845, (const char*)(session), SWITCH_LOG_ERROR, "Database Error!\n"); |
846 | break; |
847 | } |
848 | switch_cache_db_execute_sql_callback(db, sql, e_callback, &e_data, &errmsg); |
849 | switch_cache_db_release_db_handle(&db); |
850 | if (errmsg) { |
851 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 851, (const char*)(session), SWITCH_LOG_DEBUG, "Error: %s\n", errmsg); |
852 | free(errmsg); |
853 | if ((file = switch_channel_get_variable(channel, "eavesdrop_indicate_failed")switch_channel_get_variable_dup(channel, "eavesdrop_indicate_failed" , SWITCH_TRUE, -1))) { |
854 | switch_ivr_play_file(session, NULL((void*)0), file, NULL((void*)0)); |
855 | } |
856 | switch_ivr_collect_digits_count(session, buf, buflen, 1, "*", &terminator, 5000, 0, 0); |
857 | continue; |
858 | } |
859 | if (e_data.total) { |
860 | for (x = 0; x < e_data.total && switch_channel_ready(channel)switch_channel_test_ready(channel, SWITCH_TRUE, SWITCH_FALSE); x++) { |
861 | if (!switch_ivr_uuid_exists(e_data.uuid_list[x])) continue; |
862 | |
863 | /* If we have a group and 1000 concurrent calls, we will flood the logs. This check avoids this */ |
864 | if (!require_group) |
865 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 865, (const char*)(session), SWITCH_LOG_DEBUG, "Spy: %s\n", e_data.uuid_list[x]); |
866 | if ((file = switch_channel_get_variable(channel, "eavesdrop_indicate_new")switch_channel_get_variable_dup(channel, "eavesdrop_indicate_new" , SWITCH_TRUE, -1))) { |
867 | switch_ivr_play_file(session, NULL((void*)0), file, NULL((void*)0)); |
868 | } |
869 | if ((status = switch_ivr_eavesdrop_session(session, e_data.uuid_list[x], require_group, flags)) != SWITCH_STATUS_SUCCESS) { |
870 | if (status != SWITCH_STATUS_BREAK) { |
871 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 871, (const char*)(session), SWITCH_LOG_ERROR, "Spy: %s Failed\n", e_data.uuid_list[x]); |
872 | if ((file = switch_channel_get_variable(channel, "eavesdrop_indicate_failed")switch_channel_get_variable_dup(channel, "eavesdrop_indicate_failed" , SWITCH_TRUE, -1))) { |
873 | switch_ivr_play_file(session, NULL((void*)0), file, NULL((void*)0)); |
874 | } |
875 | switch_ivr_collect_digits_count(session, buf, buflen, 1, "*", &terminator, 5000, 0, 0); |
876 | } |
877 | } |
878 | } |
879 | } else { |
880 | if ((file = switch_channel_get_variable(channel, "eavesdrop_indicate_idle")switch_channel_get_variable_dup(channel, "eavesdrop_indicate_idle" , SWITCH_TRUE, -1))) { |
881 | switch_ivr_play_file(session, NULL((void*)0), file, NULL((void*)0)); |
882 | } |
883 | switch_ivr_collect_digits_count(session, buf, buflen, 1, "*", &terminator, 2000, 0, 0); |
884 | } |
885 | } |
886 | |
887 | for (x = 0; x < MAX_SPY3000; x++) { |
888 | switch_safe_free(e_data.uuid_list[x])if (e_data.uuid_list[x]) {free(e_data.uuid_list[x]);e_data.uuid_list [x]=((void*)0);}; |
889 | } |
890 | |
891 | free(sql); |
892 | |
893 | } else { |
894 | switch_ivr_eavesdrop_session(session, data, require_group, flags); |
895 | } |
896 | } |
897 | } |
898 | |
899 | #define threeway_SYNTAX"<uuid>" "<uuid>" |
900 | SWITCH_STANDARD_APP(three_way_function)static void three_way_function (switch_core_session_t *session , const char *data) |
901 | { |
902 | if (zstr(data)_zstr(data)) { |
903 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 903, (const char*)(session), SWITCH_LOG_ERROR, "Usage: %s\n", threeway_SYNTAX"<uuid>"); |
904 | } else { |
905 | switch_ivr_eavesdrop_session(session, data, NULL((void*)0), ED_MUX_READ | ED_MUX_WRITE); |
906 | } |
907 | } |
908 | |
909 | #define SET_USER_SYNTAX"<user>@<domain> [prefix]" "<user>@<domain> [prefix]" |
910 | SWITCH_STANDARD_APP(set_user_function)static void set_user_function (switch_core_session_t *session , const char *data) |
911 | { |
912 | switch_ivr_set_user(session, data); |
913 | } |
914 | |
915 | #define SET_AUDIO_LEVEL_SYNTAX"[read|write] <vol>" "[read|write] <vol>" |
916 | SWITCH_STANDARD_APP(set_audio_level_function)static void set_audio_level_function (switch_core_session_t * session, const char *data) |
917 | { |
918 | char *argv[2] = { 0 }; |
919 | int argc = 0; |
920 | char *mydata; |
921 | int level = 0; |
922 | |
923 | mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 923); |
924 | argc = switch_split(mydata, ' ', argv)switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof (argv[0]))); |
925 | |
926 | if (argc != 2) { |
927 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 927, (const char*)(session), SWITCH_LOG_DEBUG, "%s Error. USAGE: %s\n", |
928 | switch_core_session_get_name(session)switch_channel_get_name(switch_core_session_get_channel(session )), SET_AUDIO_LEVEL_SYNTAX"[read|write] <vol>"); |
929 | return; |
930 | } |
931 | |
932 | level = atoi(argv[1]); |
933 | |
934 | switch_ivr_session_audio(session, "level", argv[0], level); |
935 | |
936 | |
937 | } |
938 | |
939 | #define SET_MUTE_SYNTAX"[read|write] [[true|cn level]|false]" "[read|write] [[true|cn level]|false]" |
940 | SWITCH_STANDARD_APP(set_mute_function)static void set_mute_function (switch_core_session_t *session , const char *data) |
941 | { |
942 | char *argv[2] = { 0 }; |
943 | int argc = 0; |
944 | char *mydata; |
945 | int level = 0; |
946 | |
947 | mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 947); |
948 | argc = switch_split(mydata, ' ', argv)switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof (argv[0]))); |
949 | |
950 | if (argc != 2) { |
951 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 951, (const char*)(session), SWITCH_LOG_DEBUG, "%s Error. USAGE: %s\n", |
952 | switch_core_session_get_name(session)switch_channel_get_name(switch_core_session_get_channel(session )), SET_MUTE_SYNTAX"[read|write] [[true|cn level]|false]"); |
953 | return; |
954 | } |
955 | |
956 | if ((level = atoi(argv[1])) <= 0) { |
957 | level = switch_true(argv[1]); |
958 | } |
959 | |
960 | switch_ivr_session_audio(session, "mute", argv[0], level); |
961 | |
962 | } |
963 | |
964 | |
965 | SWITCH_STANDARD_APP(ring_ready_function)static void ring_ready_function (switch_core_session_t *session , const char *data) |
966 | { |
967 | if (!zstr(data)_zstr(data)) { |
968 | if (!strcasecmp(data, "queued")) { |
969 | switch_channel_ring_ready_value(switch_core_session_get_channel(session), SWITCH_RING_READY_QUEUED)switch_channel_perform_ring_ready_value(switch_core_session_get_channel (session), SWITCH_RING_READY_QUEUED, "mod_dptools.c", (const char *)__func__, 969); |
970 | return; |
971 | } |
972 | } |
973 | |
974 | switch_channel_ring_ready(switch_core_session_get_channel(session))switch_channel_perform_ring_ready_value(switch_core_session_get_channel (session), SWITCH_RING_READY_RINGING, "mod_dptools.c", (const char *)__func__, 974); |
975 | } |
976 | |
977 | SWITCH_STANDARD_APP(remove_bugs_function)static void remove_bugs_function (switch_core_session_t *session , const char *data) |
978 | { |
979 | const char *function = NULL((void*)0); |
980 | |
981 | if (!zstr((char *)data)_zstr((char *)data)) { |
982 | function = data; |
983 | } |
984 | |
985 | switch_core_media_bug_remove_all_function(session, function); |
986 | } |
987 | |
988 | SWITCH_STANDARD_APP(break_function)static void break_function (switch_core_session_t *session, const char *data) |
989 | { |
990 | switch_channel_t *channel; |
991 | |
992 | channel = switch_core_session_get_channel(session); |
993 | |
994 | if (data && strcasecmp(data, "all")) { |
995 | switch_core_session_flush_private_events(session); |
996 | } |
997 | |
998 | if (switch_channel_test_flag(channel, CF_BROADCAST)) { |
999 | switch_channel_stop_broadcast(channel)for(;;) {if (switch_channel_test_flag(channel, CF_BROADCAST)) {switch_channel_set_flag_value(channel, CF_STOP_BROADCAST, 1 ); switch_channel_set_flag_value(channel, CF_BREAK, 1); } break ;}; |
1000 | } else { |
1001 | switch_channel_set_flag(channel, CF_BREAK)switch_channel_set_flag_value(channel, CF_BREAK, 1); |
1002 | } |
1003 | } |
1004 | |
1005 | SWITCH_STANDARD_APP(queue_dtmf_function)static void queue_dtmf_function (switch_core_session_t *session , const char *data) |
1006 | { |
1007 | switch_channel_queue_dtmf_string(switch_core_session_get_channel(session), (const char *) data); |
1008 | } |
1009 | |
1010 | SWITCH_STANDARD_APP(send_dtmf_function)static void send_dtmf_function (switch_core_session_t *session , const char *data) |
1011 | { |
1012 | switch_core_session_send_dtmf_string(session, (const char *) data); |
1013 | } |
1014 | |
1015 | SWITCH_STANDARD_APP(check_acl_function)static void check_acl_function (switch_core_session_t *session , const char *data) |
1016 | { |
1017 | int argc; |
1018 | char *argv[3] = { 0 }; |
1019 | char *mydata; |
1020 | switch_call_cause_t cause = SWITCH_CAUSE_CALL_REJECTED; |
1021 | |
1022 | if (!zstr(data)_zstr(data) && (mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 1022))) { |
1023 | if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) > 1) { |
1024 | if (!switch_check_network_list_ip(argv[0], argv[1])switch_check_network_list_ip_token(argv[0], argv[1], ((void*) 0))) { |
1025 | switch_channel_t *channel = switch_core_session_get_channel(session); |
1026 | if (argc > 2) { |
1027 | cause = switch_channel_str2cause(argv[2]); |
1028 | } |
1029 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1029, (const char*)(session), SWITCH_LOG_DEBUG, "Call failed acl check for ip %s on list %s\n", argv[0], argv[1]); |
1030 | switch_channel_hangup(channel, cause)switch_channel_perform_hangup(channel, "mod_dptools.c", (const char *)__func__, 1030, cause); |
1031 | } |
1032 | } |
1033 | } |
1034 | |
1035 | } |
1036 | |
1037 | SWITCH_STANDARD_APP(flush_dtmf_function)static void flush_dtmf_function (switch_core_session_t *session , const char *data) |
1038 | { |
1039 | switch_channel_flush_dtmf(switch_core_session_get_channel(session)); |
1040 | } |
1041 | |
1042 | SWITCH_STANDARD_APP(transfer_function)static void transfer_function (switch_core_session_t *session , const char *data) |
1043 | { |
1044 | int argc; |
1045 | char *argv[4] = { 0 }; |
1046 | char *mydata; |
1047 | int bleg = 0, both = 0; |
1048 | |
1049 | |
1050 | if (!zstr(data)_zstr(data) && (mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 1050))) { |
1051 | if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) { |
1052 | bleg = !strcasecmp(argv[0], "-bleg"); |
1053 | both = !strcasecmp(argv[0], "-both"); |
1054 | |
1055 | if (bleg || both) { |
1056 | const char *uuid; |
1057 | switch_channel_t *channel = switch_core_session_get_channel(session); |
1058 | if ((uuid = switch_channel_get_partner_uuid(channel))) { |
1059 | switch_core_session_t *b_session; |
1060 | if ((b_session = switch_core_session_locate(uuid)switch_core_session_perform_locate(uuid, "mod_dptools.c", (const char *)__func__, 1060))) { |
1061 | switch_ivr_session_transfer(b_session, argv[1], argv[2], argv[3]); |
1062 | switch_core_session_rwunlock(b_session); |
1063 | } |
1064 | } else { |
1065 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1065, (const char*)(session), SWITCH_LOG_WARNING, "No B-leg present.\n"); |
1066 | } |
1067 | if (both) { |
1068 | switch_ivr_session_transfer(session, argv[1], argv[2], argv[3]); |
1069 | } |
1070 | } else { |
1071 | switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]); |
1072 | } |
1073 | } else { |
1074 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1074, (const char*)(session), SWITCH_LOG_ERROR, "No extension specified.\n"); |
1075 | } |
1076 | } |
1077 | } |
1078 | |
1079 | SWITCH_STANDARD_APP(sched_transfer_function)static void sched_transfer_function (switch_core_session_t *session , const char *data) |
1080 | { |
1081 | int argc; |
1082 | char *argv[4] = { 0 }; |
1083 | char *mydata; |
1084 | |
1085 | if (!zstr(data)_zstr(data) && (mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 1085))) { |
1086 | if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) { |
1087 | time_t when; |
1088 | uint32_t id; |
1089 | char ids[80] = ""; |
1090 | |
1091 | if (*argv[0] == '+') { |
1092 | when = switch_epoch_time_now(NULL((void*)0)) + atol(argv[0] + 1); |
1093 | } else { |
1094 | when = atol(argv[0]); |
1095 | } |
1096 | |
1097 | id = switch_ivr_schedule_transfer(when, switch_core_session_get_uuid(session), argv[1], argv[2], argv[3]); |
1098 | snprintf(ids, sizeof(ids), "%u", id); |
1099 | switch_channel_set_variable(switch_core_session_get_channel(session), "last_sched_id", ids)switch_channel_set_variable_var_check(switch_core_session_get_channel (session), "last_sched_id", ids, SWITCH_TRUE); |
1100 | } else { |
1101 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1101, (const char*)(session), SWITCH_LOG_ERROR, "Invalid Args\n"); |
1102 | } |
1103 | } |
1104 | } |
1105 | |
1106 | SWITCH_STANDARD_APP(sched_hangup_function)static void sched_hangup_function (switch_core_session_t *session , const char *data) |
1107 | { |
1108 | int argc; |
1109 | char *argv[5] = { 0 }; |
1110 | char *mydata; |
1111 | |
1112 | if (!zstr(data)_zstr(data) && (mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 1112))) { |
1113 | if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) { |
1114 | time_t when; |
1115 | switch_call_cause_t cause = SWITCH_CAUSE_ALLOTTED_TIMEOUT; |
1116 | switch_bool_t bleg = SWITCH_FALSE; |
1117 | int sec = atol(argv[0] + 1); |
1118 | |
1119 | if (*argv[0] == '+') { |
1120 | when = switch_epoch_time_now(NULL((void*)0)) + sec; |
1121 | } else { |
1122 | when = atol(argv[0]); |
1123 | } |
1124 | |
1125 | if (argv[1]) { |
1126 | cause = switch_channel_str2cause(argv[1]); |
1127 | } |
1128 | |
1129 | if (argv[2] && !strcasecmp(argv[2], "bleg")) { |
1130 | bleg = SWITCH_TRUE; |
1131 | } |
1132 | |
1133 | if (sec == 0) { |
1134 | switch_channel_hangup(switch_core_session_get_channel(session), cause)switch_channel_perform_hangup(switch_core_session_get_channel (session), "mod_dptools.c", (const char *)__func__, 1134, cause ); |
1135 | } else { |
1136 | switch_ivr_schedule_hangup(when, switch_core_session_get_uuid(session), cause, bleg); |
1137 | } |
1138 | } else { |
1139 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1139, (const char*)(session), SWITCH_LOG_ERROR, "No time specified.\n"); |
1140 | } |
1141 | } |
1142 | } |
1143 | |
1144 | SWITCH_STANDARD_APP(sched_broadcast_function)static void sched_broadcast_function (switch_core_session_t * session, const char *data) |
1145 | { |
1146 | int argc; |
1147 | char *argv[6] = { 0 }; |
1148 | char *mydata; |
1149 | |
1150 | if (!zstr(data)_zstr(data) && (mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 1150))) { |
1151 | if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 2) { |
1152 | time_t when; |
1153 | switch_media_flag_t flags = SMF_NONE; |
1154 | uint32_t id; |
1155 | char ids[80] = ""; |
1156 | |
1157 | if (*argv[0] == '@') { |
1158 | when = atol(argv[0] + 1); |
1159 | } else if (*argv[0] == '+') { |
1160 | when = switch_epoch_time_now(NULL((void*)0)) + atol(argv[0] + 1); |
1161 | } else { |
1162 | when = atol(argv[0]); |
1163 | } |
1164 | |
1165 | if (argv[2]) { |
1166 | if (!strcmp(argv[2], "both")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (argv[2]) && __builtin_constant_p ("both") && (__s1_len = __builtin_strlen (argv[2]), __s2_len = __builtin_strlen ("both"), (!((size_t)(const void *)((argv[2]) + 1) - (size_t )(const void *)(argv[2]) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("both") + 1) - (size_t)(const void *)("both") == 1) || __s2_len >= 4)) ? __builtin_strcmp (argv [2], "both") : (__builtin_constant_p (argv[2]) && ((size_t )(const void *)((argv[2]) + 1) - (size_t)(const void *)(argv[ 2]) == 1) && (__s1_len = __builtin_strlen (argv[2]), __s1_len < 4) ? (__builtin_constant_p ("both") && ((size_t )(const void *)(("both") + 1) - (size_t)(const void *)("both" ) == 1) ? __builtin_strcmp (argv[2], "both") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("both"); int __result = (((const unsigned char *) ( const char *) (argv[2]))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (argv[2]))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (argv[2]))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (argv[2]))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("both") && ((size_t)(const void *)(("both") + 1) - ( size_t)(const void *)("both") == 1) && (__s2_len = __builtin_strlen ("both"), __s2_len < 4) ? (__builtin_constant_p (argv[2]) && ((size_t)(const void *)((argv[2]) + 1) - (size_t) (const void *)(argv[2]) == 1) ? __builtin_strcmp (argv[2], "both" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (argv[2]); int __result = (((const unsigned char *) (const char *) ("both"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("both"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("both"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("both"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (argv[2], "both")))); })) { |
1167 | flags |= (SMF_ECHO_ALEG | SMF_ECHO_BLEG); |
1168 | } else if (!strcmp(argv[2], "aleg")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (argv[2]) && __builtin_constant_p ("aleg") && (__s1_len = __builtin_strlen (argv[2]), __s2_len = __builtin_strlen ("aleg"), (!((size_t)(const void *)((argv[2]) + 1) - (size_t )(const void *)(argv[2]) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("aleg") + 1) - (size_t)(const void *)("aleg") == 1) || __s2_len >= 4)) ? __builtin_strcmp (argv [2], "aleg") : (__builtin_constant_p (argv[2]) && ((size_t )(const void *)((argv[2]) + 1) - (size_t)(const void *)(argv[ 2]) == 1) && (__s1_len = __builtin_strlen (argv[2]), __s1_len < 4) ? (__builtin_constant_p ("aleg") && ((size_t )(const void *)(("aleg") + 1) - (size_t)(const void *)("aleg" ) == 1) ? __builtin_strcmp (argv[2], "aleg") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("aleg"); int __result = (((const unsigned char *) ( const char *) (argv[2]))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (argv[2]))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (argv[2]))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (argv[2]))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("aleg") && ((size_t)(const void *)(("aleg") + 1) - ( size_t)(const void *)("aleg") == 1) && (__s2_len = __builtin_strlen ("aleg"), __s2_len < 4) ? (__builtin_constant_p (argv[2]) && ((size_t)(const void *)((argv[2]) + 1) - (size_t) (const void *)(argv[2]) == 1) ? __builtin_strcmp (argv[2], "aleg" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (argv[2]); int __result = (((const unsigned char *) (const char *) ("aleg"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("aleg"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("aleg"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("aleg"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (argv[2], "aleg")))); })) { |
1169 | flags |= SMF_ECHO_ALEG; |
1170 | } else if (!strcmp(argv[2], "bleg")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (argv[2]) && __builtin_constant_p ("bleg") && (__s1_len = __builtin_strlen (argv[2]), __s2_len = __builtin_strlen ("bleg"), (!((size_t)(const void *)((argv[2]) + 1) - (size_t )(const void *)(argv[2]) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("bleg") + 1) - (size_t)(const void *)("bleg") == 1) || __s2_len >= 4)) ? __builtin_strcmp (argv [2], "bleg") : (__builtin_constant_p (argv[2]) && ((size_t )(const void *)((argv[2]) + 1) - (size_t)(const void *)(argv[ 2]) == 1) && (__s1_len = __builtin_strlen (argv[2]), __s1_len < 4) ? (__builtin_constant_p ("bleg") && ((size_t )(const void *)(("bleg") + 1) - (size_t)(const void *)("bleg" ) == 1) ? __builtin_strcmp (argv[2], "bleg") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("bleg"); int __result = (((const unsigned char *) ( const char *) (argv[2]))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (argv[2]))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (argv[2]))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (argv[2]))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("bleg") && ((size_t)(const void *)(("bleg") + 1) - ( size_t)(const void *)("bleg") == 1) && (__s2_len = __builtin_strlen ("bleg"), __s2_len < 4) ? (__builtin_constant_p (argv[2]) && ((size_t)(const void *)((argv[2]) + 1) - (size_t) (const void *)(argv[2]) == 1) ? __builtin_strcmp (argv[2], "bleg" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (argv[2]); int __result = (((const unsigned char *) (const char *) ("bleg"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("bleg"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("bleg"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("bleg"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (argv[2], "bleg")))); })) { |
1171 | flags |= SMF_ECHO_BLEG; |
1172 | } |
1173 | } else { |
1174 | flags |= SMF_ECHO_ALEG; |
1175 | } |
1176 | |
1177 | id = switch_ivr_schedule_broadcast(when, switch_core_session_get_uuid(session), argv[1], flags); |
1178 | snprintf(ids, sizeof(ids), "%u", id); |
1179 | switch_channel_set_variable(switch_core_session_get_channel(session), "last_sched_id", ids)switch_channel_set_variable_var_check(switch_core_session_get_channel (session), "last_sched_id", ids, SWITCH_TRUE); |
1180 | } else { |
1181 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1181, (const char*)(session), SWITCH_LOG_ERROR, "Invalid Args\n"); |
1182 | } |
1183 | } |
1184 | } |
1185 | |
1186 | SWITCH_STANDARD_APP(delay_function)static void delay_function (switch_core_session_t *session, const char *data) |
1187 | { |
1188 | uint32_t len = 0; |
1189 | |
1190 | if (zstr(data)_zstr(data)) { |
1191 | len = 1000; |
1192 | } else { |
1193 | len = atoi(data); |
1194 | } |
1195 | |
1196 | switch_ivr_delay_echo(session, len); |
1197 | } |
1198 | |
1199 | SWITCH_STANDARD_APP(eval_function)static void eval_function (switch_core_session_t *session, const char *data) |
1200 | { |
1201 | return; |
1202 | } |
1203 | |
1204 | SWITCH_STANDARD_APP(set_media_stats_function)static void set_media_stats_function (switch_core_session_t * session, const char *data) |
1205 | { |
1206 | switch_core_media_set_stats(session); |
1207 | |
1208 | return; |
1209 | } |
1210 | |
1211 | SWITCH_STANDARD_APP(zombie_function)static void zombie_function (switch_core_session_t *session, const char *data) |
1212 | { |
1213 | switch_channel_t *channel = switch_core_session_get_channel(session); |
1214 | |
1215 | if (switch_channel_up(channel)(switch_channel_check_signal(channel, SWITCH_TRUE) || switch_channel_get_state (channel) < CS_HANGUP)) { |
1216 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1216, (const char*)(session), SWITCH_LOG_DEBUG, "%s MMM Brains....\n", switch_channel_get_name(channel)); |
1217 | switch_channel_set_flag(channel, CF_ZOMBIE_EXEC)switch_channel_set_flag_value(channel, CF_ZOMBIE_EXEC, 1); |
1218 | } |
1219 | |
1220 | return; |
1221 | } |
1222 | |
1223 | |
1224 | SWITCH_STANDARD_APP(hangup_function)static void hangup_function (switch_core_session_t *session, const char *data) |
1225 | { |
1226 | switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING; |
1227 | |
1228 | if (!zstr(data)_zstr(data)) { |
1229 | cause = switch_channel_str2cause(data); |
1230 | } |
1231 | |
1232 | switch_channel_hangup(switch_core_session_get_channel(session), cause)switch_channel_perform_hangup(switch_core_session_get_channel (session), "mod_dptools.c", (const char *)__func__, 1232, cause ); |
1233 | } |
1234 | |
1235 | SWITCH_STANDARD_APP(set_name_function)static void set_name_function (switch_core_session_t *session , const char *data) |
1236 | { |
1237 | |
1238 | if (!zstr(data)_zstr(data)) { |
1239 | switch_channel_set_name(switch_core_session_get_channel(session), (char *) data); |
1240 | } |
1241 | } |
1242 | |
1243 | SWITCH_STANDARD_APP(answer_function)static void answer_function (switch_core_session_t *session, const char *data) |
1244 | { |
1245 | switch_channel_t *channel = switch_core_session_get_channel(session); |
1246 | const char *arg = (char *) data; |
1247 | |
1248 | if (zstr(arg)_zstr(arg)) { |
1249 | arg = switch_channel_get_variable(channel, "answer_flags")switch_channel_get_variable_dup(channel, "answer_flags", SWITCH_TRUE , -1); |
1250 | } |
1251 | |
1252 | if (!zstr(arg)_zstr(arg)) { |
1253 | if (switch_stristr("is_conference", arg)) { |
1254 | switch_channel_set_flag(channel, CF_CONFERENCE)switch_channel_set_flag_value(channel, CF_CONFERENCE, 1); |
1255 | } |
1256 | } |
1257 | |
1258 | switch_channel_answer(channel)switch_channel_perform_answer(channel, "mod_dptools.c", (const char *)__func__, 1258); |
1259 | } |
1260 | |
1261 | SWITCH_STANDARD_APP(wait_for_answer_function)static void wait_for_answer_function (switch_core_session_t * session, const char *data) |
1262 | { |
1263 | switch_channel_t *channel = switch_core_session_get_channel(session); |
1264 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1264, (const char*)(session), SWITCH_LOG_DEBUG, "Waiting for answer\n"); |
1265 | while (!switch_channel_test_flag(channel, CF_ANSWERED) && switch_channel_ready(channel)switch_channel_test_ready(channel, SWITCH_TRUE, SWITCH_FALSE)) { |
1266 | switch_ivr_sleep(session, 100, SWITCH_TRUE, NULL((void*)0)); |
1267 | } |
1268 | } |
1269 | |
1270 | SWITCH_STANDARD_APP(presence_function)static void presence_function (switch_core_session_t *session , const char *data) |
1271 | { |
1272 | char *argv[6] = { 0 }; |
1273 | int argc; |
1274 | char *mydata = NULL((void*)0); |
1275 | switch_channel_t *channel = switch_core_session_get_channel(session); |
1276 | |
1277 | if (zstr(data)_zstr(data) || !(mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 1277))) { |
1278 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1278, (const char*)(session), SWITCH_LOG_ERROR, "INVALID ARGS!\n"); |
1279 | return; |
1280 | } |
1281 | |
1282 | if ((argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]))) < 2) { |
1283 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1283, (const char*)(session), SWITCH_LOG_ERROR, "INVALID ARGS!\n"); |
1284 | return; |
1285 | } |
1286 | |
1287 | switch_channel_presence(channel, argv[0], argv[1], argv[2])switch_channel_perform_presence(channel, argv[0], argv[1], argv [2], "mod_dptools.c", (const char *)__func__, 1287); |
1288 | } |
1289 | |
1290 | SWITCH_STANDARD_APP(pre_answer_function)static void pre_answer_function (switch_core_session_t *session , const char *data) |
1291 | { |
1292 | switch_channel_t *channel = switch_core_session_get_channel(session); |
1293 | switch_channel_pre_answer(channel)switch_channel_perform_pre_answer(channel, "mod_dptools.c", ( const char *)__func__, 1293); |
1294 | } |
1295 | |
1296 | SWITCH_STANDARD_APP(redirect_function)static void redirect_function (switch_core_session_t *session , const char *data) |
1297 | { |
1298 | switch_core_session_message_t msg = { 0 }; |
1299 | |
1300 | /* Tell the channel to redirect */ |
1301 | msg.from = __FILE__"mod_dptools.c"; |
1302 | msg.string_arg = data; |
1303 | msg.message_id = SWITCH_MESSAGE_INDICATE_REDIRECT; |
1304 | msg.numeric_arg = 1; |
1305 | switch_core_session_receive_message(session, &msg)switch_core_session_perform_receive_message(session, &msg , "mod_dptools.c", (const char *)__func__, 1305); |
1306 | } |
1307 | |
1308 | SWITCH_STANDARD_APP(video_refresh_function)static void video_refresh_function (switch_core_session_t *session , const char *data) |
1309 | { |
1310 | switch_core_session_message_t msg = { 0 }; |
1311 | |
1312 | /* Tell the channel to refresh video */ |
1313 | msg.from = __FILE__"mod_dptools.c"; |
1314 | msg.string_arg = data; |
1315 | msg.message_id = SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ; |
1316 | switch_core_session_receive_message(session, &msg)switch_core_session_perform_receive_message(session, &msg , "mod_dptools.c", (const char *)__func__, 1316); |
1317 | } |
1318 | |
1319 | SWITCH_STANDARD_APP(send_info_function)static void send_info_function (switch_core_session_t *session , const char *data) |
1320 | { |
1321 | switch_core_session_message_t msg = { 0 }; |
1322 | |
1323 | /* Tell the channel to send info */ |
1324 | msg.from = __FILE__"mod_dptools.c"; |
1325 | msg.string_arg = data; |
1326 | msg.message_id = SWITCH_MESSAGE_INDICATE_INFO; |
1327 | msg.string_array_arg[2] = data; |
1328 | |
1329 | switch_core_session_receive_message(session, &msg)switch_core_session_perform_receive_message(session, &msg , "mod_dptools.c", (const char *)__func__, 1329); |
1330 | } |
1331 | |
1332 | SWITCH_STANDARD_APP(jitterbuffer_function)static void jitterbuffer_function (switch_core_session_t *session , const char *data) |
1333 | { |
1334 | switch_core_session_message_t msg = { 0 }; |
1335 | |
1336 | /* Tell the channel to change the jitter buffer */ |
1337 | msg.from = __FILE__"mod_dptools.c"; |
1338 | msg.string_arg = data; |
1339 | msg.message_id = SWITCH_MESSAGE_INDICATE_JITTER_BUFFER; |
1340 | switch_core_session_receive_message(session, &msg)switch_core_session_perform_receive_message(session, &msg , "mod_dptools.c", (const char *)__func__, 1340); |
1341 | } |
1342 | |
1343 | SWITCH_STANDARD_APP(display_function)static void display_function (switch_core_session_t *session, const char *data) |
1344 | { |
1345 | switch_core_session_message_t msg = { 0 }; |
1346 | |
1347 | /* Tell the channel to change display */ |
1348 | msg.from = __FILE__"mod_dptools.c"; |
1349 | msg.string_arg = data; |
1350 | msg.message_id = SWITCH_MESSAGE_INDICATE_DISPLAY; |
1351 | switch_core_session_receive_message(session, &msg)switch_core_session_perform_receive_message(session, &msg , "mod_dptools.c", (const char *)__func__, 1351); |
1352 | } |
1353 | |
1354 | SWITCH_STANDARD_APP(respond_function)static void respond_function (switch_core_session_t *session, const char *data) |
1355 | { |
1356 | switch_core_session_message_t msg = { 0 }; |
1357 | |
1358 | /* Tell the channel to respond the call */ |
1359 | msg.from = __FILE__"mod_dptools.c"; |
1360 | msg.string_arg = data; |
1361 | msg.message_id = SWITCH_MESSAGE_INDICATE_RESPOND; |
1362 | msg.numeric_arg = -1; |
1363 | switch_core_session_receive_message(session, &msg)switch_core_session_perform_receive_message(session, &msg , "mod_dptools.c", (const char *)__func__, 1363); |
1364 | } |
1365 | |
1366 | SWITCH_STANDARD_APP(deflect_function)static void deflect_function (switch_core_session_t *session, const char *data) |
1367 | { |
1368 | switch_core_session_message_t msg = { 0 }; |
1369 | |
1370 | /* Tell the channel to deflect the call */ |
1371 | msg.from = __FILE__"mod_dptools.c"; |
1372 | msg.string_arg = data; |
1373 | msg.message_id = SWITCH_MESSAGE_INDICATE_DEFLECT; |
1374 | switch_core_session_receive_message(session, &msg)switch_core_session_perform_receive_message(session, &msg , "mod_dptools.c", (const char *)__func__, 1374); |
1375 | } |
1376 | |
1377 | SWITCH_STANDARD_APP(recovery_refresh_function)static void recovery_refresh_function (switch_core_session_t * session, const char *data) |
1378 | { |
1379 | switch_core_session_message_t msg = { 0 }; |
1380 | |
1381 | /* Tell the channel to recovery_refresh the call */ |
1382 | msg.from = __FILE__"mod_dptools.c"; |
1383 | msg.string_arg = data; |
1384 | msg.message_id = SWITCH_MESSAGE_INDICATE_RECOVERY_REFRESH; |
1385 | switch_core_session_receive_message(session, &msg)switch_core_session_perform_receive_message(session, &msg , "mod_dptools.c", (const char *)__func__, 1385); |
1386 | } |
1387 | |
1388 | |
1389 | SWITCH_STANDARD_APP(sched_cancel_function)static void sched_cancel_function (switch_core_session_t *session , const char *data) |
1390 | { |
1391 | const char *group = data; |
1392 | |
1393 | if (zstr(group)_zstr(group)) { |
1394 | group = switch_core_session_get_uuid(session); |
1395 | } |
1396 | |
1397 | if (switch_is_digit_string(group)) { |
1398 | int64_t tmp; |
1399 | tmp = (uint32_t) atoi(group); |
1400 | if (tmp > 0) { |
1401 | switch_scheduler_del_task_id((uint32_t) tmp); |
1402 | } |
1403 | } else { |
1404 | switch_scheduler_del_task_group(group); |
1405 | } |
1406 | } |
1407 | |
1408 | static void base_set (switch_core_session_t *session, const char *data, switch_stack_t stack) |
1409 | { |
1410 | char *var, *val = NULL((void*)0); |
1411 | |
1412 | if (zstr(data)_zstr(data)) { |
1413 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1413, (const char*)(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); |
1414 | } else { |
1415 | switch_channel_t *channel = switch_core_session_get_channel(session); |
1416 | char *expanded = NULL((void*)0); |
1417 | |
1418 | var = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 1418); |
1419 | |
1420 | if (!(val = strchr(var, '=')(__extension__ (__builtin_constant_p ('=') && !__builtin_constant_p (var) && ('=') == '\0' ? (char *) __rawmemchr (var, '=' ) : __builtin_strchr (var, '='))))) { |
1421 | val = strchr(var, ',')(__extension__ (__builtin_constant_p (',') && !__builtin_constant_p (var) && (',') == '\0' ? (char *) __rawmemchr (var, ',' ) : __builtin_strchr (var, ','))); |
1422 | } |
1423 | |
1424 | if (val) { |
1425 | *val++ = '\0'; |
1426 | if (zstr(val)_zstr(val)) { |
1427 | val = NULL((void*)0); |
1428 | } |
1429 | } |
1430 | |
1431 | if (val) { |
1432 | expanded = switch_channel_expand_variables(channel, val)switch_channel_expand_variables_check(channel, val, ((void*)0 ), ((void*)0), 0); |
1433 | } |
1434 | |
1435 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1435, (const char*)(session), SWITCH_LOG_DEBUG, "%s SET [%s]=[%s]\n", switch_channel_get_name(channel), var, |
1436 | expanded ? expanded : "UNDEF"); |
1437 | switch_channel_add_variable_var_check(channel, var, expanded, SWITCH_FALSE, stack); |
1438 | |
1439 | if (expanded && expanded != val) { |
1440 | switch_safe_free(expanded)if (expanded) {free(expanded);expanded=((void*)0);}; |
1441 | } |
1442 | } |
1443 | } |
1444 | |
1445 | SWITCH_STANDARD_APP(multiset_function)static void multiset_function (switch_core_session_t *session , const char *data) |
1446 | { |
1447 | char delim = ' '; |
1448 | char *arg = (char *) data; |
1449 | |
1450 | if (!zstr(arg)_zstr(arg) && *arg == '^' && *(arg+1) == '^') { |
1451 | arg += 2; |
1452 | delim = *arg++; |
1453 | } |
1454 | |
1455 | if (arg) { |
1456 | char *array[256] = {0}; |
1457 | int i, argc; |
1458 | |
1459 | arg = switch_core_session_strdup(session, arg)switch_core_perform_session_strdup(session, arg, "mod_dptools.c" , (const char *)__func__, 1459); |
1460 | argc = switch_split(arg, delim, array)switch_separate_string(arg, delim, array, (sizeof(array) / sizeof (array[0]))); |
1461 | |
1462 | for(i = 0; i < argc; i++) { |
1463 | base_set(session, array[i], SWITCH_STACK_BOTTOM); |
1464 | } |
1465 | |
1466 | |
1467 | } else { |
1468 | base_set(session, data, SWITCH_STACK_BOTTOM); |
1469 | } |
1470 | } |
1471 | |
1472 | SWITCH_STANDARD_APP(set_function)static void set_function (switch_core_session_t *session, const char *data) |
1473 | { |
1474 | base_set(session, data, SWITCH_STACK_BOTTOM); |
1475 | } |
1476 | |
1477 | SWITCH_STANDARD_APP(push_function)static void push_function (switch_core_session_t *session, const char *data) |
1478 | { |
1479 | base_set(session, data, SWITCH_STACK_PUSH); |
1480 | } |
1481 | |
1482 | SWITCH_STANDARD_APP(unshift_function)static void unshift_function (switch_core_session_t *session, const char *data) |
1483 | { |
1484 | base_set(session, data, SWITCH_STACK_UNSHIFT); |
1485 | } |
1486 | |
1487 | SWITCH_STANDARD_APP(set_global_function)static void set_global_function (switch_core_session_t *session , const char *data) |
1488 | { |
1489 | char *var, *val = NULL((void*)0); |
1490 | |
1491 | if (zstr(data)_zstr(data)) { |
1492 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1492, (const char*)(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); |
1493 | } else { |
1494 | var = strdup(data)(__extension__ (__builtin_constant_p (data) && ((size_t )(const void *)((data) + 1) - (size_t)(const void *)(data) == 1) ? (((const char *) (data))[0] == '\0' ? (char *) calloc ( (size_t) 1, (size_t) 1) : ({ size_t __len = strlen (data) + 1 ; char *__retval = (char *) malloc (__len); if (__retval != ( (void*)0)) __retval = (char *) memcpy (__retval, data, __len) ; __retval; })) : __strdup (data))); |
1495 | switch_assert(var)((var) ? (void) (0) : __assert_fail ("var", "mod_dptools.c", 1495 , __PRETTY_FUNCTION__)); |
1496 | val = strchr(var, '=')(__extension__ (__builtin_constant_p ('=') && !__builtin_constant_p (var) && ('=') == '\0' ? (char *) __rawmemchr (var, '=' ) : __builtin_strchr (var, '='))); |
1497 | |
1498 | if (val) { |
1499 | *val++ = '\0'; |
1500 | if (zstr(val)_zstr(val)) { |
1501 | val = NULL((void*)0); |
1502 | } |
1503 | } |
1504 | |
1505 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1505, (const char*)(session), SWITCH_LOG_DEBUG, "SET GLOBAL [%s]=[%s]\n", var, val ? val : "UNDEF"); |
1506 | switch_core_set_variable(var, val); |
1507 | free(var); |
1508 | } |
1509 | } |
1510 | |
1511 | SWITCH_STANDARD_APP(set_profile_var_function)static void set_profile_var_function (switch_core_session_t * session, const char *data) |
1512 | { |
1513 | char *name, *val = NULL((void*)0); |
1514 | |
1515 | if (zstr(data)_zstr(data)) { |
1516 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1516, (const char*)(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); |
1517 | } else { |
1518 | name = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 1518); |
1519 | val = strchr(name, '=')(__extension__ (__builtin_constant_p ('=') && !__builtin_constant_p (name) && ('=') == '\0' ? (char *) __rawmemchr (name , '=') : __builtin_strchr (name, '='))); |
1520 | |
1521 | if (val) { |
1522 | *val++ = '\0'; |
1523 | if (zstr(val)_zstr(val)) { |
1524 | val = NULL((void*)0); |
1525 | } |
1526 | } |
1527 | |
1528 | switch_channel_set_profile_var(switch_core_session_get_channel(session), name, val); |
1529 | } |
1530 | } |
1531 | |
1532 | SWITCH_STANDARD_APP(export_function)static void export_function (switch_core_session_t *session, const char *data) |
1533 | { |
1534 | switch_channel_t *channel = switch_core_session_get_channel(session); |
1535 | char *var, *val = NULL((void*)0); |
1536 | |
1537 | if (zstr(data)_zstr(data)) { |
1538 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1538, (const char*)(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); |
1539 | } else { |
1540 | var = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 1540); |
1541 | |
1542 | if ((val = strchr(var, '=')(__extension__ (__builtin_constant_p ('=') && !__builtin_constant_p (var) && ('=') == '\0' ? (char *) __rawmemchr (var, '=' ) : __builtin_strchr (var, '='))))) { |
1543 | *val++ = '\0'; |
1544 | if (zstr(val)_zstr(val)) { |
1545 | val = NULL((void*)0); |
1546 | } |
1547 | } |
1548 | |
1549 | switch_channel_export_variable_var_check(channel, var, val, SWITCH_EXPORT_VARS_VARIABLE"export_vars", SWITCH_FALSE); |
1550 | } |
1551 | } |
1552 | |
1553 | SWITCH_STANDARD_APP(bridge_export_function)static void bridge_export_function (switch_core_session_t *session , const char *data) |
1554 | { |
1555 | switch_channel_t *channel = switch_core_session_get_channel(session); |
1556 | char *var, *val = NULL((void*)0); |
1557 | |
1558 | if (zstr(data)_zstr(data)) { |
1559 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1559, (const char*)(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); |
1560 | } else { |
1561 | var = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 1561); |
1562 | |
1563 | if ((val = strchr(var, '=')(__extension__ (__builtin_constant_p ('=') && !__builtin_constant_p (var) && ('=') == '\0' ? (char *) __rawmemchr (var, '=' ) : __builtin_strchr (var, '='))))) { |
1564 | *val++ = '\0'; |
1565 | if (zstr(val)_zstr(val)) { |
1566 | val = NULL((void*)0); |
1567 | } |
1568 | } |
1569 | |
1570 | switch_channel_export_variable(channel, var, val, SWITCH_BRIDGE_EXPORT_VARS_VARIABLE)switch_channel_export_variable_var_check(channel, var, val, "bridge_export_vars" , SWITCH_TRUE); |
1571 | } |
1572 | } |
1573 | |
1574 | SWITCH_STANDARD_APP(unset_function)static void unset_function (switch_core_session_t *session, const char *data) |
1575 | { |
1576 | if (zstr(data)_zstr(data)) { |
1577 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1577, (const char*)(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); |
1578 | } else { |
1579 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1579, (const char*)(session), SWITCH_LOG_DEBUG, "UNSET [%s]\n", (char *) data); |
1580 | switch_channel_set_variable(switch_core_session_get_channel(session), data, NULL)switch_channel_set_variable_var_check(switch_core_session_get_channel (session), data, ((void*)0), SWITCH_TRUE); |
1581 | } |
1582 | } |
1583 | |
1584 | SWITCH_STANDARD_APP(multiunset_function)static void multiunset_function (switch_core_session_t *session , const char *data) |
1585 | { |
1586 | char delim = ' '; |
1587 | char *arg = (char *) data; |
1588 | |
1589 | if (!zstr(arg)_zstr(arg) && *arg == '^' && *(arg+1) == '^') { |
1590 | arg += 2; |
1591 | delim = *arg++; |
1592 | } |
1593 | |
1594 | if (arg) { |
1595 | char *array[256] = {0}; |
1596 | int i, argc; |
1597 | |
1598 | arg = switch_core_session_strdup(session, arg)switch_core_perform_session_strdup(session, arg, "mod_dptools.c" , (const char *)__func__, 1598); |
1599 | argc = switch_split(arg, delim, array)switch_separate_string(arg, delim, array, (sizeof(array) / sizeof (array[0]))); |
1600 | |
1601 | for(i = 0; i < argc; i++) { |
1602 | switch_channel_set_variable(switch_core_session_get_channel(session), array[i], NULL)switch_channel_set_variable_var_check(switch_core_session_get_channel (session), array[i], ((void*)0), SWITCH_TRUE); |
1603 | } |
1604 | |
1605 | } else { |
1606 | switch_channel_set_variable(switch_core_session_get_channel(session), arg, NULL)switch_channel_set_variable_var_check(switch_core_session_get_channel (session), arg, ((void*)0), SWITCH_TRUE); |
1607 | } |
1608 | } |
1609 | |
1610 | |
1611 | SWITCH_STANDARD_APP(log_function)static void log_function (switch_core_session_t *session, const char *data) |
1612 | { |
1613 | char *level, *log_str; |
1614 | |
1615 | if (data && (level = strdup(data)(__extension__ (__builtin_constant_p (data) && ((size_t )(const void *)((data) + 1) - (size_t)(const void *)(data) == 1) ? (((const char *) (data))[0] == '\0' ? (char *) calloc ( (size_t) 1, (size_t) 1) : ({ size_t __len = strlen (data) + 1 ; char *__retval = (char *) malloc (__len); if (__retval != ( (void*)0)) __retval = (char *) memcpy (__retval, data, __len) ; __retval; })) : __strdup (data))))) { |
1616 | switch_log_level_t ltype = SWITCH_LOG_DEBUG; |
1617 | |
1618 | if ((log_str = strchr(level, ' ')(__extension__ (__builtin_constant_p (' ') && !__builtin_constant_p (level) && (' ') == '\0' ? (char *) __rawmemchr (level , ' ') : __builtin_strchr (level, ' '))))) { |
1619 | *log_str++ = '\0'; |
1620 | ltype = switch_log_str2level(level); |
1621 | } else { |
1622 | log_str = level; |
1623 | } |
1624 | if (ltype == SWITCH_LOG_INVALID) { |
1625 | ltype = SWITCH_LOG_DEBUG; |
1626 | } |
1627 | |
1628 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1628, (const char*)(session), ltype, "%s\n", log_str); |
1629 | switch_safe_free(level)if (level) {free(level);level=((void*)0);}; |
1630 | } |
1631 | } |
1632 | |
1633 | SWITCH_STANDARD_APP(info_function)static void info_function (switch_core_session_t *session, const char *data) |
1634 | { |
1635 | switch_event_t *event; |
1636 | char *buf; |
1637 | int level = SWITCH_LOG_INFO; |
1638 | |
1639 | if (!zstr(data)_zstr(data)) { |
1640 | level = switch_log_str2level(data); |
1641 | } |
1642 | |
1643 | if (switch_event_create_plain(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) { |
1644 | switch_channel_event_set_data(switch_core_session_get_channel(session), event); |
1645 | switch_event_serialize(event, &buf, SWITCH_FALSE); |
1646 | switch_assert(buf)((buf) ? (void) (0) : __assert_fail ("buf", "mod_dptools.c", 1646 , __PRETTY_FUNCTION__)); |
1647 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1647, (const char*)(session), level, "CHANNEL_DATA:\n%s\n", buf); |
1648 | switch_event_destroy(&event); |
1649 | free(buf); |
1650 | } |
1651 | } |
1652 | |
1653 | SWITCH_STANDARD_APP(sound_test_function)static void sound_test_function (switch_core_session_t *session , const char *data) |
1654 | { |
1655 | switch_ivr_sound_test(session); |
1656 | } |
1657 | |
1658 | SWITCH_STANDARD_APP(event_function)static void event_function (switch_core_session_t *session, const char *data) |
1659 | { |
1660 | switch_event_t *event; |
1661 | char *argv[25] = { 0 }; |
1662 | int argc = 0; |
1663 | char *lbuf; |
1664 | |
1665 | if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_APPLICATION)switch_event_create_subclass_detailed("mod_dptools.c", (const char * )(const char *)__func__, 1665, &event, SWITCH_EVENT_CHANNEL_APPLICATION , ((void*)0)) == SWITCH_STATUS_SUCCESS) { |
1666 | if (!zstr(data)_zstr(data) && (lbuf = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 1666)) |
1667 | && (argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) { |
1668 | int x = 0; |
1669 | |
1670 | for (x = 0; x < argc; x++) { |
1671 | char *p, *this = argv[x]; |
1672 | if (this) { |
1673 | char *var, *val; |
1674 | p = this; |
1675 | while (*p == ' ') |
1676 | *p++ = '\0'; |
1677 | this = p; |
1678 | |
1679 | var = this; |
1680 | val = NULL((void*)0); |
1681 | if ((val = strchr(var, '=')(__extension__ (__builtin_constant_p ('=') && !__builtin_constant_p (var) && ('=') == '\0' ? (char *) __rawmemchr (var, '=' ) : __builtin_strchr (var, '='))))) { |
1682 | p = val - 1; |
1683 | *val++ = '\0'; |
1684 | while (*p == ' ') |
1685 | *p-- = '\0'; |
1686 | p = val; |
1687 | while (*p == ' ') |
1688 | *p++ = '\0'; |
1689 | val = p; |
1690 | if (!strcasecmp(var, "Event-Name")) { |
1691 | switch_name_event(val, &event->event_id); |
1692 | switch_event_del_header(event, var)switch_event_del_header_val(event, var, ((void*)0)); |
1693 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, var, val); |
1694 | } else if (!strcasecmp(var, "Event-Subclass")) { |
1695 | size_t len = strlen(val) + 1; |
1696 | void *new = malloc(len); |
1697 | switch_assert(new)((new) ? (void) (0) : __assert_fail ("new", "mod_dptools.c", 1697 , __PRETTY_FUNCTION__)); |
1698 | memcpy(new, val, len); |
1699 | event->subclass_name = new; |
1700 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, var, val); |
1701 | } else { |
1702 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, var, val); |
1703 | } |
1704 | } |
1705 | } |
1706 | } |
1707 | } |
1708 | switch_channel_event_set_data(switch_core_session_get_channel(session), event); |
1709 | switch_event_fire(&event)switch_event_fire_detailed("mod_dptools.c", (const char * )(const char *)__func__, 1709, &event, ((void*)0)); |
1710 | } |
1711 | } |
1712 | |
1713 | SWITCH_STANDARD_APP(privacy_function)static void privacy_function (switch_core_session_t *session, const char *data) |
1714 | { |
1715 | switch_caller_profile_t *caller_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(session)); |
1716 | |
1717 | if (zstr(data)_zstr(data)) { |
1718 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1718, (const char*)(session), SWITCH_LOG_ERROR, "No privacy mode specified.\n"); |
1719 | } else { |
1720 | switch_set_flag(caller_profile, SWITCH_CPF_SCREEN)(caller_profile)->flags |= (SWITCH_CPF_SCREEN); |
1721 | |
1722 | |
1723 | if (!strcasecmp(data, "full")) { |
1724 | switch_set_flag(caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER)(caller_profile)->flags |= (SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER ); |
1725 | } else if (!strcasecmp(data, "name")) { |
1726 | switch_set_flag(caller_profile, SWITCH_CPF_HIDE_NAME)(caller_profile)->flags |= (SWITCH_CPF_HIDE_NAME); |
1727 | } else if (!strcasecmp(data, "number")) { |
1728 | switch_set_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)(caller_profile)->flags |= (SWITCH_CPF_HIDE_NUMBER); |
1729 | } else if (switch_true(data)) { |
1730 | switch_set_flag(caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER)(caller_profile)->flags |= (SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER ); |
1731 | } else if (switch_false(data)) { |
1732 | switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NAME)(caller_profile)->flags &= ~(SWITCH_CPF_HIDE_NAME); |
1733 | switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)(caller_profile)->flags &= ~(SWITCH_CPF_HIDE_NUMBER); |
1734 | } else { |
1735 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1735, (const char*)(session), SWITCH_LOG_ERROR, |
1736 | "INVALID privacy mode specified. Use a valid mode [no|yes|name|full|number].\n"); |
1737 | } |
1738 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1738, (const char*)(session), SWITCH_LOG_DEBUG, "Set Privacy to %s [%d]\n", data, caller_profile->flags); |
1739 | } |
1740 | } |
1741 | |
1742 | SWITCH_STANDARD_APP(strftime_function)static void strftime_function (switch_core_session_t *session , const char *data) |
1743 | { |
1744 | char *argv[2] = { 0 }; |
1745 | int argc; |
1746 | char *lbuf; |
1747 | |
1748 | if (!zstr(data)_zstr(data) && (lbuf = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 1748)) |
1749 | && (argc = switch_separate_string(lbuf, '=', argv, (sizeof(argv) / sizeof(argv[0])))) > 1) { |
1750 | switch_size_t retsize; |
1751 | switch_time_exp_t tm; |
1752 | char date[80] = ""; |
1753 | |
1754 | switch_time_exp_lt(&tm, switch_micro_time_now()); |
1755 | switch_strftime(date, &retsize, sizeof(date), argv[1], &tm); |
1756 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1756, (const char*)(session), SWITCH_LOG_DEBUG, "SET [%s]=[%s]\n", argv[0], date); |
1757 | switch_channel_set_variable(switch_core_session_get_channel(session), argv[0], date)switch_channel_set_variable_var_check(switch_core_session_get_channel (session), argv[0], date, SWITCH_TRUE); |
1758 | } |
1759 | } |
1760 | |
1761 | SWITCH_STANDARD_API(strepoch_api_function)static switch_status_t strepoch_api_function ( const char *cmd , switch_core_session_t *session, switch_stream_handle_t *stream ) |
1762 | { |
1763 | switch_time_t out; |
1764 | |
1765 | if (zstr(cmd)_zstr(cmd)) { |
1766 | out = switch_micro_time_now(); |
1767 | } else { |
1768 | out = switch_str_time(cmd); |
1769 | } |
1770 | |
1771 | stream->write_function(stream, "%d", (uint32_t) ((out) / (int64_t) (1000000))); |
1772 | |
1773 | return SWITCH_STATUS_SUCCESS; |
1774 | } |
1775 | |
1776 | |
1777 | SWITCH_STANDARD_API(strmicroepoch_api_function)static switch_status_t strmicroepoch_api_function ( const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream) |
1778 | { |
1779 | switch_time_t out; |
1780 | |
1781 | if (zstr(cmd)_zstr(cmd)) { |
1782 | out = switch_micro_time_now(); |
1783 | } else { |
1784 | out = switch_str_time(cmd); |
1785 | } |
1786 | |
1787 | stream->write_function(stream, "%"SWITCH_TIME_T_FMT"ld", out); |
1788 | |
1789 | return SWITCH_STATUS_SUCCESS; |
1790 | } |
1791 | |
1792 | SWITCH_STANDARD_API(strftime_api_function)static switch_status_t strftime_api_function ( const char *cmd , switch_core_session_t *session, switch_stream_handle_t *stream ) |
1793 | { |
1794 | switch_size_t retsize; |
1795 | switch_time_exp_t tm; |
1796 | char date[80] = ""; |
1797 | switch_time_t thetime; |
1798 | char *p, *q = NULL((void*)0); |
1799 | char *mycmd = NULL((void*)0); |
1800 | |
1801 | if (!zstr(cmd)_zstr(cmd)) { |
1802 | mycmd = strdup(cmd)(__extension__ (__builtin_constant_p (cmd) && ((size_t )(const void *)((cmd) + 1) - (size_t)(const void *)(cmd) == 1 ) ? (((const char *) (cmd))[0] == '\0' ? (char *) calloc ((size_t ) 1, (size_t) 1) : ({ size_t __len = strlen (cmd) + 1; char * __retval = (char *) malloc (__len); if (__retval != ((void*)0 )) __retval = (char *) memcpy (__retval, cmd, __len); __retval ; })) : __strdup (cmd))); |
1803 | q = mycmd; |
1804 | } |
1805 | |
1806 | if (!zstr(q)_zstr(q) && (p = strchr(q, '|')(__extension__ (__builtin_constant_p ('|') && !__builtin_constant_p (q) && ('|') == '\0' ? (char *) __rawmemchr (q, '|') : __builtin_strchr (q, '|'))))) { |
1807 | *p++ = '\0'; |
1808 | |
1809 | thetime = switch_time_make(atol(q), 0); |
1810 | q = p + 1; |
1811 | } else { |
1812 | thetime = switch_micro_time_now(); |
1813 | } |
1814 | switch_time_exp_lt(&tm, thetime); |
1815 | |
1816 | if (zstr(q)_zstr(q)) { |
1817 | switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm); |
1818 | } else { |
1819 | switch_strftime(date, &retsize, sizeof(date), q, &tm); |
1820 | } |
1821 | stream->write_function(stream, "%s", date); |
1822 | switch_safe_free(mycmd)if (mycmd) {free(mycmd);mycmd=((void*)0);}; |
1823 | |
1824 | return SWITCH_STATUS_SUCCESS; |
1825 | } |
1826 | |
1827 | |
1828 | #define PRESENCE_USAGE"[in|out] <user> <rpid> <message>" "[in|out] <user> <rpid> <message>" |
1829 | SWITCH_STANDARD_API(presence_api_function)static switch_status_t presence_api_function ( const char *cmd , switch_core_session_t *session, switch_stream_handle_t *stream ) |
1830 | { |
1831 | switch_event_t *event; |
1832 | char *lbuf = NULL((void*)0), *argv[4]; |
1833 | int argc = 0; |
1834 | switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN; |
1835 | int need = 4; |
1836 | |
1837 | if (!zstr(cmd)_zstr(cmd) && (lbuf = strdup(cmd)(__extension__ (__builtin_constant_p (cmd) && ((size_t )(const void *)((cmd) + 1) - (size_t)(const void *)(cmd) == 1 ) ? (((const char *) (cmd))[0] == '\0' ? (char *) calloc ((size_t ) 1, (size_t) 1) : ({ size_t __len = strlen (cmd) + 1; char * __retval = (char *) malloc (__len); if (__retval != ((void*)0 )) __retval = (char *) memcpy (__retval, cmd, __len); __retval ; })) : __strdup (cmd)))) |
1838 | && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) > 0) { |
1839 | |
1840 | if (!strcasecmp(argv[0], "out")) { |
1841 | type = SWITCH_EVENT_PRESENCE_OUT; |
1842 | need = 2; |
1843 | } else if (strcasecmp(argv[0], "in")) { |
1844 | goto error; |
1845 | } |
1846 | |
1847 | if (argc < need) { |
1848 | goto error; |
1849 | } |
1850 | |
1851 | if (switch_event_create(&event, type)switch_event_create_subclass_detailed("mod_dptools.c", (const char * )(const char *)__func__, 1851, &event, type, ((void *)0)) == SWITCH_STATUS_SUCCESS) { |
1852 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", "dp"); |
1853 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", __FILE__"mod_dptools.c"); |
1854 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", argv[1]); |
1855 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", argv[2]); |
1856 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "status", argv[3]); |
1857 | if (type == SWITCH_EVENT_PRESENCE_IN) { |
1858 | if (!strncasecmp(argv[3], "cs_", 3) || switch_stristr("hangup", argv[3])) { |
1859 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_HANGUP"); |
1860 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "status", "CS_HANGUP"); |
1861 | } |
1862 | } else { |
1863 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "status", "CS_HANGUP"); |
1864 | } |
1865 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); |
1866 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog"); |
1867 | switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", 0); |
1868 | switch_event_fire(&event)switch_event_fire_detailed("mod_dptools.c", (const char * )(const char *)__func__, 1868, &event, ((void*)0)); |
1869 | } |
1870 | stream->write_function(stream, "Event Sent"); |
1871 | } else { |
1872 | goto error; |
1873 | } |
1874 | |
1875 | switch_safe_free(lbuf)if (lbuf) {free(lbuf);lbuf=((void*)0);}; |
1876 | return SWITCH_STATUS_SUCCESS; |
1877 | |
1878 | error: |
1879 | |
1880 | switch_safe_free(lbuf)if (lbuf) {free(lbuf);lbuf=((void*)0);}; |
1881 | stream->write_function(stream, "Invalid: presence %s", PRESENCE_USAGE"[in|out] <user> <rpid> <message>"); |
1882 | return SWITCH_STATUS_SUCCESS; |
1883 | } |
1884 | |
1885 | SWITCH_STANDARD_API(chat_api_function)static switch_status_t chat_api_function ( const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream) |
1886 | { |
1887 | char *lbuf = NULL((void*)0), *argv[5]; |
1888 | int argc = 0; |
1889 | |
1890 | if (!zstr(cmd)_zstr(cmd) && (lbuf = strdup(cmd)(__extension__ (__builtin_constant_p (cmd) && ((size_t )(const void *)((cmd) + 1) - (size_t)(const void *)(cmd) == 1 ) ? (((const char *) (cmd))[0] == '\0' ? (char *) calloc ((size_t ) 1, (size_t) 1) : ({ size_t __len = strlen (cmd) + 1; char * __retval = (char *) malloc (__len); if (__retval != ((void*)0 )) __retval = (char *) memcpy (__retval, cmd, __len); __retval ; })) : __strdup (cmd)))) |
1891 | && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) >= 4) { |
1892 | |
1893 | if (switch_core_chat_send_args(argv[0], "global", argv[1], argv[2], "", argv[3], !zstr(argv[4])_zstr(argv[4]) ? argv[4] : NULL((void*)0), "", SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) { |
1894 | stream->write_function(stream, "Sent"); |
1895 | } else { |
1896 | stream->write_function(stream, "Error! Message Not Sent"); |
1897 | } |
1898 | } else { |
1899 | stream->write_function(stream, "Invalid"); |
1900 | } |
1901 | |
1902 | switch_safe_free(lbuf)if (lbuf) {free(lbuf);lbuf=((void*)0);}; |
1903 | return SWITCH_STATUS_SUCCESS; |
1904 | } |
1905 | |
1906 | static char *ivr_cf_name = "ivr.conf"; |
1907 | |
1908 | #ifdef _TEST_CALLBACK_ |
1909 | static switch_ivr_action_t menu_handler(switch_ivr_menu_t *menu, char *param, char *buf, size_t buflen, void *obj) |
1910 | { |
1911 | switch_ivr_action_t action = SWITCH_IVR_ACTION_NOOP; |
1912 | |
1913 | if (param != NULL((void*)0)) { |
1914 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1914, (const char*)(session), SWITCH_LOG_DEBUG, "menu_handler '%s'\n", param); |
1915 | } |
1916 | |
1917 | return action; |
1918 | } |
1919 | #endif |
1920 | |
1921 | SWITCH_STANDARD_APP(ivr_application_function)static void ivr_application_function (switch_core_session_t * session, const char *data) |
1922 | { |
1923 | switch_channel_t *channel = switch_core_session_get_channel(session); |
1924 | switch_event_t *params; |
1925 | const char *name = (const char *) data; |
1926 | |
1927 | if (channel) { |
1928 | switch_xml_t cxml = NULL((void*)0), cfg = NULL((void*)0), xml_menus = NULL((void*)0), xml_menu = NULL((void*)0); |
1929 | |
1930 | /* Open the config from the xml registry */ |
1931 | switch_event_create(¶ms, SWITCH_EVENT_REQUEST_PARAMS)switch_event_create_subclass_detailed("mod_dptools.c", (const char * )(const char *)__func__, 1931, ¶ms, SWITCH_EVENT_REQUEST_PARAMS , ((void*)0)); |
1932 | switch_assert(params)((params) ? (void) (0) : __assert_fail ("params", "mod_dptools.c" , 1932, __PRETTY_FUNCTION__)); |
1933 | switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "Menu-Name", name); |
1934 | switch_channel_event_set_data(channel, params); |
1935 | |
1936 | if ((cxml = switch_xml_open_cfg(ivr_cf_name, &cfg, params)) != NULL((void*)0)) { |
1937 | if ((xml_menus = switch_xml_child(cfg, "menus"))) { |
1938 | xml_menu = switch_xml_find_child(xml_menus, "menu", "name", name); |
1939 | |
1940 | /* if the menu was found */ |
1941 | if (xml_menu != NULL((void*)0)) { |
1942 | switch_ivr_menu_xml_ctx_t *xml_ctx = NULL((void*)0); |
1943 | switch_ivr_menu_t *menu_stack = NULL((void*)0); |
1944 | |
1945 | /* build a menu tree and execute it */ |
1946 | if (switch_ivr_menu_stack_xml_init(&xml_ctx, NULL((void*)0)) == SWITCH_STATUS_SUCCESS |
1947 | #ifdef _TEST_CALLBACK_ |
1948 | && switch_ivr_menu_stack_xml_add_custom(xml_ctx, "custom", &menu_handler) == SWITCH_STATUS_SUCCESS |
1949 | #endif |
1950 | && switch_ivr_menu_stack_xml_build(xml_ctx, &menu_stack, xml_menus, xml_menu) == SWITCH_STATUS_SUCCESS) { |
1951 | switch_xml_free(cxml); |
1952 | cxml = NULL((void*)0); |
1953 | switch_ivr_menu_execute(session, menu_stack, (char *) name, NULL((void*)0)); |
1954 | switch_ivr_menu_stack_free(menu_stack); |
1955 | } else { |
1956 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1956, (const char*)(session), SWITCH_LOG_ERROR, "Unable to create menu\n"); |
1957 | } |
1958 | } else { |
1959 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1959, (const char*)(session), SWITCH_LOG_ERROR, "Unable to find menu\n"); |
1960 | } |
1961 | } else { |
1962 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1962, (const char*)(session), SWITCH_LOG_ERROR, "No menus configured\n"); |
1963 | } |
1964 | switch_xml_free(cxml); |
1965 | } else { |
1966 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 1966, (const char*)(session), SWITCH_LOG_ERROR, "Open of %s failed\n", ivr_cf_name); |
1967 | } |
1968 | switch_event_destroy(¶ms); |
1969 | } |
1970 | } |
1971 | |
1972 | SWITCH_STANDARD_APP(dtmf_session_function)static void dtmf_session_function (switch_core_session_t *session , const char *data) |
1973 | { |
1974 | switch_ivr_inband_dtmf_session(session); |
1975 | } |
1976 | |
1977 | SWITCH_STANDARD_APP(stop_dtmf_session_function)static void stop_dtmf_session_function (switch_core_session_t *session, const char *data) |
1978 | { |
1979 | switch_ivr_stop_inband_dtmf_session(session); |
1980 | } |
1981 | |
1982 | SWITCH_STANDARD_APP(dtmf_session_generate_function)static void dtmf_session_generate_function (switch_core_session_t *session, const char *data) |
1983 | { |
1984 | switch_bool_t do_read = SWITCH_TRUE; |
1985 | |
1986 | if (!zstr(data)_zstr(data)) { |
1987 | if (!strcasecmp(data, "write")) { |
1988 | do_read = SWITCH_FALSE; |
1989 | } |
1990 | } |
1991 | switch_ivr_inband_dtmf_generate_session(session, do_read); |
1992 | } |
1993 | |
1994 | SWITCH_STANDARD_APP(stop_dtmf_session_generate_function)static void stop_dtmf_session_generate_function (switch_core_session_t *session, const char *data) |
1995 | { |
1996 | switch_ivr_stop_inband_dtmf_generate_session(session); |
1997 | } |
1998 | |
1999 | SWITCH_STANDARD_APP(fax_detect_session_function)static void fax_detect_session_function (switch_core_session_t *session, const char *data) |
2000 | { |
2001 | switch_ivr_tone_detect_session(session, "fax", "1100.0", "r", 0, 1, NULL((void*)0), NULL((void*)0), NULL((void*)0)); |
2002 | } |
2003 | |
2004 | SWITCH_STANDARD_APP(system_session_function)static void system_session_function (switch_core_session_t *session , const char *data) |
2005 | { |
2006 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2006, (const char*)(session), SWITCH_LOG_NOTICE, "Executing command: %s\n", data); |
2007 | if (switch_system(data, SWITCH_TRUE) < 0) { |
2008 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2008, (const char*)(session), SWITCH_LOG_NOTICE, "Failed to execute command: %s\n", data); |
2009 | } |
2010 | } |
2011 | |
2012 | SWITCH_STANDARD_APP(bgsystem_session_function)static void bgsystem_session_function (switch_core_session_t * session, const char *data) |
2013 | { |
2014 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2014, (const char*)(session), SWITCH_LOG_NOTICE, "Executing command: %s\n", data); |
2015 | if (switch_system(data, SWITCH_FALSE) < 0) { |
2016 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2016, (const char*)(session), SWITCH_LOG_NOTICE, "Failed to execute command: %s\n", data); |
2017 | } |
2018 | } |
2019 | |
2020 | SWITCH_STANDARD_APP(tone_detect_session_function)static void tone_detect_session_function (switch_core_session_t *session, const char *data) |
2021 | { |
2022 | char *argv[7] = { 0 }; |
2023 | int argc; |
2024 | char *mydata = NULL((void*)0); |
2025 | time_t to = 0; |
2026 | int hits = 0; |
2027 | const char *hp = NULL((void*)0); |
2028 | |
2029 | if (zstr(data)_zstr(data) || !(mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 2029))) { |
2030 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2030, (const char*)(session), SWITCH_LOG_ERROR, "INVALID ARGS!\n"); |
2031 | return; |
2032 | } |
2033 | |
2034 | if ((argc = switch_separate_string(mydata, ' ', argv, sizeof(argv) / sizeof(argv[0]))) < 2) { |
2035 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2035, (const char*)(session), SWITCH_LOG_ERROR, "INVALID ARGS!\n"); |
2036 | return; |
2037 | } |
2038 | |
2039 | if (argv[3]) { |
2040 | uint32_t mto; |
2041 | if (*argv[3] == '+') { |
2042 | if ((mto = atol(argv[3] + 1)) > 0) { |
2043 | to = switch_epoch_time_now(NULL((void*)0)) + mto; |
2044 | } else { |
2045 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2045, (const char*)(session), SWITCH_LOG_ERROR, "INVALID Timeout!\n"); |
2046 | } |
2047 | } else { |
2048 | if ((to = atol(argv[3])) < switch_epoch_time_now(NULL((void*)0))) { |
2049 | if (to >= 1) { |
2050 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2050, (const char*)(session), SWITCH_LOG_ERROR, "INVALID Timeout!\n"); |
2051 | } |
2052 | to = 0; |
2053 | } |
2054 | } |
2055 | } |
2056 | |
2057 | if (argv[4] && argv[5]) { |
2058 | hp = argv[6]; |
2059 | } else if (argv[4] && !argv[6]) { |
2060 | hp = argv[4]; |
2061 | } |
2062 | |
2063 | if (hp) { |
2064 | hits = atoi(hp); |
2065 | if (hits < 0) { |
2066 | hits = 0; |
2067 | } |
2068 | } |
2069 | |
2070 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2070, (const char*)(session), SWITCH_LOG_NOTICE, "Enabling tone detection '%s' '%s'\n", argv[0], argv[1]); |
2071 | |
2072 | switch_ivr_tone_detect_session(session, argv[0], argv[1], argv[2], to, hits, argv[4], argv[5], NULL((void*)0)); |
2073 | } |
2074 | |
2075 | SWITCH_STANDARD_APP(stop_fax_detect_session_function)static void stop_fax_detect_session_function (switch_core_session_t *session, const char *data) |
2076 | { |
2077 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2077, (const char*)(session), SWITCH_LOG_NOTICE, "Disabling tone detection\n"); |
2078 | switch_ivr_stop_tone_detect_session(session); |
2079 | } |
2080 | |
2081 | SWITCH_STANDARD_APP(echo_function)static void echo_function (switch_core_session_t *session, const char *data) |
2082 | { |
2083 | switch_ivr_session_echo(session, NULL((void*)0)); |
2084 | } |
2085 | |
2086 | SWITCH_STANDARD_APP(park_function)static void park_function (switch_core_session_t *session, const char *data) |
2087 | { |
2088 | switch_ivr_park(session, NULL((void*)0)); |
2089 | } |
2090 | |
2091 | SWITCH_STANDARD_APP(park_state_function)static void park_state_function (switch_core_session_t *session , const char *data) |
2092 | { |
2093 | switch_ivr_park_session(session); |
2094 | } |
2095 | |
2096 | /********************************************************************************/ |
2097 | /* Playback/Record Functions */ |
2098 | /********************************************************************************/ |
2099 | |
2100 | /* |
2101 | dtmf handler function you can hook up to be executed when a digit is dialed during playback |
2102 | if you return anything but SWITCH_STATUS_SUCCESS the playback will stop. |
2103 | */ |
2104 | static switch_status_t bridge_on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen) |
2105 | { |
2106 | char *str = (char *) buf; |
2107 | |
2108 | if (str && input && itype == SWITCH_INPUT_TYPE_DTMF) { |
2109 | switch_dtmf_t *dtmf = (switch_dtmf_t *) input; |
2110 | if (strchr(str, dtmf->digit)(__extension__ (__builtin_constant_p (dtmf->digit) && !__builtin_constant_p (str) && (dtmf->digit) == '\0' ? (char *) __rawmemchr (str, dtmf->digit) : __builtin_strchr (str, dtmf->digit)))) { |
2111 | return SWITCH_STATUS_BREAK; |
2112 | } |
2113 | } |
2114 | return SWITCH_STATUS_SUCCESS; |
2115 | } |
2116 | |
2117 | static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen) |
2118 | { |
2119 | char sbuf[3]; |
2120 | |
2121 | switch (itype) { |
2122 | case SWITCH_INPUT_TYPE_DTMF: |
2123 | { |
2124 | switch_dtmf_t *dtmf = (switch_dtmf_t *) input; |
2125 | const char *terminators; |
2126 | switch_channel_t *channel = switch_core_session_get_channel(session); |
2127 | const char *p; |
2128 | |
2129 | if (!(terminators = switch_channel_get_variable(channel, SWITCH_PLAYBACK_TERMINATORS_VARIABLE)switch_channel_get_variable_dup(channel, "playback_terminators" , SWITCH_TRUE, -1))) { |
2130 | terminators = "*"; |
2131 | } |
2132 | if (!strcasecmp(terminators, "any")) { |
2133 | terminators = "1234567890*#"; |
2134 | } |
2135 | if (!strcasecmp(terminators, "none")) { |
2136 | terminators = NULL((void*)0); |
2137 | } |
2138 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2138, (const char*)(session), SWITCH_LOG_DEBUG, "Digit %c\n", dtmf->digit); |
2139 | |
2140 | for (p = terminators; p && *p; p++) { |
2141 | if (*p == dtmf->digit) { |
2142 | switch_snprintf(sbuf, sizeof(sbuf), "%c", *p); |
2143 | switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, sbuf)switch_channel_set_variable_var_check(channel, "playback_terminator_used" , sbuf, SWITCH_TRUE); |
2144 | return SWITCH_STATUS_BREAK; |
2145 | } |
2146 | } |
2147 | } |
2148 | break; |
2149 | default: |
2150 | break; |
2151 | } |
2152 | |
2153 | return SWITCH_STATUS_SUCCESS; |
2154 | } |
2155 | |
2156 | SWITCH_STANDARD_APP(sleep_function)static void sleep_function (switch_core_session_t *session, const char *data) |
2157 | { |
2158 | switch_channel_t *channel = switch_core_session_get_channel(session); |
2159 | |
2160 | if (zstr(data)_zstr(data)) { |
2161 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2161, (const char*)(session), SWITCH_LOG_ERROR, "No timeout specified.\n"); |
2162 | } else { |
2163 | uint32_t ms = atoi(data); |
2164 | char buf[10]; |
2165 | switch_input_args_t args = { 0 }; |
2166 | |
2167 | if (switch_true(switch_channel_get_variable(channel, "sleep_eat_digits")switch_channel_get_variable_dup(channel, "sleep_eat_digits", SWITCH_TRUE , -1))) { |
2168 | args.input_callback = on_dtmf; |
2169 | args.buf = buf; |
2170 | args.buflen = sizeof(buf); |
2171 | switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "")switch_channel_set_variable_var_check(channel, "playback_terminator_used" , "", SWITCH_TRUE); |
2172 | } |
2173 | |
2174 | switch_ivr_sleep(session, ms, SWITCH_TRUE, &args); |
2175 | } |
2176 | } |
2177 | |
2178 | SWITCH_STANDARD_APP(clear_speech_cache_function)static void clear_speech_cache_function (switch_core_session_t *session, const char *data) |
2179 | { |
2180 | switch_ivr_clear_speech_cache(session); |
2181 | } |
2182 | |
2183 | SWITCH_STANDARD_APP(speak_function)static void speak_function (switch_core_session_t *session, const char *data) |
2184 | { |
2185 | switch_channel_t *channel = switch_core_session_get_channel(session); |
2186 | char buf[10]; |
2187 | char *argv[3] = { 0 }; |
2188 | int argc; |
2189 | const char *engine = NULL((void*)0); |
2190 | const char *voice = NULL((void*)0); |
2191 | char *text = NULL((void*)0); |
2192 | char *mydata = NULL((void*)0); |
2193 | switch_input_args_t args = { 0 }; |
2194 | |
2195 | if (zstr(data)_zstr(data) || !(mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 2195))) { |
2196 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2196, (const char*)(session), SWITCH_LOG_ERROR, "Invalid Params!\n"); |
2197 | return; |
2198 | } |
2199 | |
2200 | argc = switch_separate_string(mydata, '|', argv, sizeof(argv) / sizeof(argv[0])); |
2201 | |
2202 | if (argc == 0) { |
2203 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2203, (const char*)(session), SWITCH_LOG_ERROR, "Invalid Params!\n"); |
2204 | return; |
2205 | } else if (argc == 1) { |
2206 | text = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 2206); /* unstripped text */ |
2207 | } else if (argc == 2) { |
2208 | voice = argv[0]; |
2209 | text = switch_core_session_strdup(session, data + (argv[1] - argv[0]))switch_core_perform_session_strdup(session, data + (argv[1] - argv[0]), "mod_dptools.c", (const char *)__func__, 2209); /* unstripped text */ |
2210 | } else { |
2211 | engine = argv[0]; |
2212 | voice = argv[1]; |
2213 | text = switch_core_session_strdup(session, data + (argv[2] - argv[0]))switch_core_perform_session_strdup(session, data + (argv[2] - argv[0]), "mod_dptools.c", (const char *)__func__, 2213); /* unstripped text */ |
2214 | } |
2215 | |
2216 | if (!engine) { |
2217 | engine = switch_channel_get_variable(channel, "tts_engine")switch_channel_get_variable_dup(channel, "tts_engine", SWITCH_TRUE , -1); |
2218 | } |
2219 | |
2220 | if (!voice) { |
2221 | voice = switch_channel_get_variable(channel, "tts_voice")switch_channel_get_variable_dup(channel, "tts_voice", SWITCH_TRUE , -1); |
2222 | } |
2223 | |
2224 | if (!(engine && voice && text)) { |
2225 | if (!engine) { |
2226 | engine = "NULL"; |
2227 | } |
2228 | if (!voice) { |
2229 | voice = "NULL"; |
2230 | } |
2231 | if (!text) { |
2232 | text = "NULL"; |
2233 | } |
2234 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2234, (const char*)(session), SWITCH_LOG_ERROR, "Invalid Params! [%s][%s][%s]\n", engine, voice, text); |
2235 | switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER)switch_channel_perform_hangup(channel, "mod_dptools.c", (const char *)__func__, 2235, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER ); |
2236 | } |
2237 | |
2238 | args.input_callback = on_dtmf; |
2239 | args.buf = buf; |
2240 | args.buflen = sizeof(buf); |
2241 | |
2242 | switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "")switch_channel_set_variable_var_check(channel, "playback_terminator_used" , "", SWITCH_TRUE); |
2243 | |
2244 | switch_ivr_speak_text(session, engine, voice, text, &args); |
2245 | } |
2246 | |
2247 | static switch_status_t xfer_on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen) |
2248 | { |
2249 | switch_core_session_t *peer_session = (switch_core_session_t *) buf; |
2250 | |
2251 | if (!buf || !peer_session) { |
2252 | return SWITCH_STATUS_SUCCESS; |
2253 | } |
2254 | |
2255 | switch (itype) { |
2256 | case SWITCH_INPUT_TYPE_DTMF: |
2257 | { |
2258 | switch_dtmf_t *dtmf = (switch_dtmf_t *) input; |
2259 | switch_channel_t *channel = switch_core_session_get_channel(session); |
2260 | switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session); |
2261 | |
2262 | if (dtmf->digit == '*') { |
2263 | switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING)switch_channel_perform_hangup(channel, "mod_dptools.c", (const char *)__func__, 2263, SWITCH_CAUSE_NORMAL_CLEARING); |
2264 | return SWITCH_STATUS_FALSE; |
2265 | } |
2266 | |
2267 | if (dtmf->digit == '#') { |
2268 | switch_channel_hangup(peer_channel, SWITCH_CAUSE_NORMAL_CLEARING)switch_channel_perform_hangup(peer_channel, "mod_dptools.c", ( const char *)__func__, 2268, SWITCH_CAUSE_NORMAL_CLEARING); |
2269 | return SWITCH_STATUS_FALSE; |
2270 | } |
2271 | |
2272 | if (dtmf->digit == '0') { |
2273 | switch_caller_extension_t *extension = NULL((void*)0); |
2274 | const char *app = "three_way"; |
2275 | const char *app_arg = switch_core_session_get_uuid(session); |
2276 | const char *holding = switch_channel_get_variable(channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE)switch_channel_get_variable_dup(channel, "soft_holding_uuid", SWITCH_TRUE, -1); |
2277 | switch_core_session_t *b_session; |
2278 | |
2279 | if (holding && (b_session = switch_core_session_locate(holding)switch_core_session_perform_locate(holding, "mod_dptools.c", ( const char *)__func__, 2279))) { |
2280 | switch_channel_t *b_channel = switch_core_session_get_channel(b_session); |
2281 | if (!switch_channel_ready(b_channel)switch_channel_test_ready(b_channel, SWITCH_TRUE, SWITCH_FALSE )) { |
2282 | app = "intercept"; |
2283 | } |
2284 | switch_core_session_rwunlock(b_session); |
2285 | } |
2286 | |
2287 | if ((extension = switch_caller_extension_new(peer_session, app, app_arg)) == 0) { |
2288 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2288, (const char*)(session), SWITCH_LOG_CRIT, "Memory Error!\n"); |
2289 | abort(); |
2290 | } |
2291 | |
2292 | switch_caller_extension_add_application(peer_session, extension, app, app_arg); |
2293 | switch_channel_set_caller_extension(peer_channel, extension); |
2294 | switch_channel_set_state(peer_channel, CS_RESET)switch_channel_perform_set_state(peer_channel, "mod_dptools.c" , (const char *)__func__, 2294, CS_RESET); |
2295 | switch_channel_wait_for_state(peer_channel, channel, CS_RESET); |
2296 | switch_channel_set_state(peer_channel, CS_EXECUTE)switch_channel_perform_set_state(peer_channel, "mod_dptools.c" , (const char *)__func__, 2296, CS_EXECUTE); |
2297 | switch_channel_set_variable(channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE, NULL)switch_channel_set_variable_var_check(channel, "hangup_after_bridge" , ((void*)0), SWITCH_TRUE); |
2298 | return SWITCH_STATUS_FALSE; |
2299 | } |
2300 | |
2301 | } |
2302 | break; |
2303 | default: |
2304 | break; |
2305 | } |
2306 | |
2307 | return SWITCH_STATUS_SUCCESS; |
2308 | } |
2309 | |
2310 | static switch_status_t tmp_hanguphook(switch_core_session_t *session) |
2311 | { |
2312 | switch_channel_t *channel = switch_core_session_get_channel(session); |
2313 | switch_channel_state_t state = switch_channel_get_state(channel); |
2314 | |
2315 | if (state == CS_HANGUP || state == CS_ROUTING) { |
2316 | const char *bond = switch_channel_get_variable(channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE)switch_channel_get_variable_dup(channel, "soft_holding_uuid", SWITCH_TRUE, -1); |
2317 | |
2318 | if (!zstr(bond)_zstr(bond)) { |
2319 | switch_core_session_t *b_session; |
2320 | |
2321 | if ((b_session = switch_core_session_locate(bond)switch_core_session_perform_locate(bond, "mod_dptools.c", (const char *)__func__, 2321))) { |
2322 | switch_channel_t *b_channel = switch_core_session_get_channel(b_session); |
2323 | if (switch_channel_up(b_channel)(switch_channel_check_signal(b_channel, SWITCH_TRUE) || switch_channel_get_state (b_channel) < CS_HANGUP)) { |
2324 | switch_channel_set_flag(b_channel, CF_REDIRECT)switch_channel_set_flag_value(b_channel, CF_REDIRECT, 1); |
2325 | } |
2326 | switch_core_session_rwunlock(b_session); |
2327 | } |
2328 | } |
2329 | |
2330 | switch_core_event_hook_remove_state_change(session, tmp_hanguphook); |
2331 | } |
2332 | |
2333 | return SWITCH_STATUS_SUCCESS; |
2334 | } |
2335 | |
2336 | static switch_status_t hanguphook(switch_core_session_t *session) |
2337 | { |
2338 | switch_channel_t *channel = switch_core_session_get_channel(session); |
2339 | switch_channel_state_t state = switch_channel_get_state(channel); |
2340 | const char *id = NULL((void*)0); |
2341 | |
2342 | if (state == CS_HANGUP || state == CS_ROUTING) { |
2343 | if ((id = switch_channel_get_variable(channel, "xfer_uuids")switch_channel_get_variable_dup(channel, "xfer_uuids", SWITCH_TRUE , -1))) { |
2344 | switch_stream_handle_t stream = { 0 }; |
2345 | SWITCH_STANDARD_STREAM(stream)memset(&stream, 0, sizeof(stream)); stream.data = malloc( 1024); ((stream.data) ? (void) (0) : __assert_fail ("stream.data" , "mod_dptools.c", 2345, __PRETTY_FUNCTION__)); memset(stream .data, 0, 1024); stream.end = stream.data; stream.data_size = 1024; stream.write_function = switch_console_stream_write; stream .raw_write_function = switch_console_stream_raw_write; stream .alloc_len = 1024; stream.alloc_chunk = 1024; |
2346 | switch_api_execute("uuid_bridge", id, NULL((void*)0), &stream); |
2347 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2347, (const char*)(session), SWITCH_LOG_DEBUG, "\nHangup Command uuid_bridge(%s):\n%s\n", id, |
2348 | switch_str_nil((char *) stream.data)((char *) stream.data ? (char *) stream.data : "")); |
2349 | switch_safe_free(stream.data)if (stream.data) {free(stream.data);stream.data=((void*)0);}; |
2350 | } |
2351 | |
2352 | switch_core_event_hook_remove_state_change(session, hanguphook); |
2353 | } |
2354 | return SWITCH_STATUS_SUCCESS; |
2355 | } |
2356 | |
2357 | |
2358 | static void att_xfer_set_result(switch_channel_t *channel, switch_status_t status) |
2359 | { |
2360 | switch_channel_set_variable(channel, SWITCH_ATT_XFER_RESULT_VARIABLE, status == SWITCH_STATUS_SUCCESS ? "success" : "failure")switch_channel_set_variable_var_check(channel, "att_xfer_result" , status == SWITCH_STATUS_SUCCESS ? "success" : "failure", SWITCH_TRUE ); |
2361 | } |
2362 | |
2363 | SWITCH_STANDARD_APP(att_xfer_function)static void att_xfer_function (switch_core_session_t *session , const char *data) |
2364 | { |
2365 | switch_core_session_t *peer_session = NULL((void*)0); |
2366 | switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING; |
2367 | switch_channel_t *channel = switch_core_session_get_channel(session), *peer_channel = NULL((void*)0); |
2368 | const char *bond = NULL((void*)0); |
2369 | switch_core_session_t *b_session = NULL((void*)0); |
2370 | switch_bool_t follow_recording = switch_true(switch_channel_get_variable(channel, "recording_follow_attxfer")switch_channel_get_variable_dup(channel, "recording_follow_attxfer" , SWITCH_TRUE, -1)); |
2371 | |
2372 | bond = switch_channel_get_partner_uuid(channel); |
2373 | switch_channel_set_variable(channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE, bond)switch_channel_set_variable_var_check(channel, "soft_holding_uuid" , bond, SWITCH_TRUE); |
2374 | switch_core_event_hook_add_state_change(session, tmp_hanguphook); |
2375 | |
2376 | if (follow_recording && (b_session = switch_core_session_locate(bond)switch_core_session_perform_locate(bond, "mod_dptools.c", (const char *)__func__, 2376))) { |
2377 | switch_ivr_transfer_recordings(b_session, session); |
2378 | switch_core_session_rwunlock(b_session); |
2379 | } |
2380 | |
2381 | if (switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0), SOF_NONE, NULL((void*)0)) |
2382 | != SWITCH_STATUS_SUCCESS || !peer_session) { |
2383 | switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, bond)switch_channel_set_variable_var_check(channel, "signal_bond", bond, SWITCH_TRUE); |
2384 | goto end; |
2385 | } |
2386 | |
2387 | peer_channel = switch_core_session_get_channel(peer_session); |
2388 | switch_channel_set_flag(peer_channel, CF_INNER_BRIDGE)switch_channel_set_flag_value(peer_channel, CF_INNER_BRIDGE, 1 ); |
2389 | switch_channel_set_flag(channel, CF_INNER_BRIDGE)switch_channel_set_flag_value(channel, CF_INNER_BRIDGE, 1); |
2390 | |
2391 | switch_ivr_multi_threaded_bridge(session, peer_session, xfer_on_dtmf, peer_session, NULL((void*)0)); |
2392 | |
2393 | switch_channel_clear_flag(peer_channel, CF_INNER_BRIDGE); |
2394 | switch_channel_clear_flag(channel, CF_INNER_BRIDGE); |
2395 | |
2396 | if (zstr(bond)_zstr(bond) && switch_channel_down(peer_channel)(switch_channel_check_signal(peer_channel, SWITCH_TRUE) || switch_channel_get_state (peer_channel) >= CS_HANGUP)) { |
2397 | switch_core_session_rwunlock(peer_session); |
2398 | switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, bond)switch_channel_set_variable_var_check(channel, "signal_bond", bond, SWITCH_TRUE); |
2399 | goto end; |
2400 | } |
2401 | |
2402 | if (bond) { |
2403 | int br = 0; |
2404 | |
2405 | switch_channel_set_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE, bond)switch_channel_set_variable_var_check(channel, "signal_bond", bond, SWITCH_TRUE); |
2406 | |
2407 | if (!switch_channel_down(peer_channel)(switch_channel_check_signal(peer_channel, SWITCH_TRUE) || switch_channel_get_state (peer_channel) >= CS_HANGUP)) { |
2408 | if (!switch_channel_ready(channel)switch_channel_test_ready(channel, SWITCH_TRUE, SWITCH_FALSE)) { |
2409 | switch_status_t status; |
2410 | |
2411 | if (follow_recording) { |
2412 | switch_ivr_transfer_recordings(session, peer_session); |
2413 | } |
2414 | status = switch_ivr_uuid_bridge(switch_core_session_get_uuid(peer_session), bond); |
2415 | att_xfer_set_result(peer_channel, status); |
2416 | br++; |
2417 | } else if ((b_session = switch_core_session_locate(bond)switch_core_session_perform_locate(bond, "mod_dptools.c", (const char *)__func__, 2417))) { |
2418 | switch_channel_t *b_channel = switch_core_session_get_channel(b_session); |
2419 | switch_channel_set_variable_printf(b_channel, "xfer_uuids", "%s %s", switch_core_session_get_uuid(peer_session), switch_core_session_get_uuid(session)); |
2420 | switch_channel_set_variable_printf(channel, "xfer_uuids", "%s %s", switch_core_session_get_uuid(peer_session), bond); |
2421 | |
2422 | switch_core_event_hook_add_state_change(session, hanguphook); |
2423 | switch_core_event_hook_add_state_change(b_session, hanguphook); |
2424 | |
2425 | switch_core_session_rwunlock(b_session); |
2426 | } |
2427 | } |
2428 | |
2429 | if (!br) { |
2430 | switch_status_t status = switch_ivr_uuid_bridge(switch_core_session_get_uuid(session), bond); |
2431 | att_xfer_set_result(channel, status); |
2432 | } |
2433 | |
2434 | } |
2435 | |
2436 | switch_core_session_rwunlock(peer_session); |
2437 | |
2438 | end: |
2439 | |
2440 | switch_core_event_hook_remove_state_change(session, tmp_hanguphook); |
2441 | |
2442 | switch_channel_set_variable(channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE, NULL)switch_channel_set_variable_var_check(channel, "soft_holding_uuid" , ((void*)0), SWITCH_TRUE); |
2443 | switch_channel_clear_flag(channel, CF_XFER_ZOMBIE); |
2444 | } |
2445 | |
2446 | SWITCH_STANDARD_APP(read_function)static void read_function (switch_core_session_t *session, const char *data) |
2447 | { |
2448 | char *mydata; |
2449 | char *argv[7] = { 0 }; |
2450 | int argc; |
2451 | int32_t min_digits = 0; |
2452 | int32_t max_digits = 0; |
2453 | uint32_t digit_timeout = 0; |
2454 | int timeout = 1000; |
2455 | char digit_buffer[128] = ""; |
2456 | const char *prompt_audio_file = NULL((void*)0); |
2457 | const char *var_name = NULL((void*)0); |
2458 | const char *valid_terminators = NULL((void*)0); |
2459 | |
2460 | if (!zstr(data)_zstr(data) && (mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 2460))) { |
2461 | argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); |
2462 | } else { |
2463 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2463, (const char*)(session), SWITCH_LOG_ERROR, "No arguments specified.\n"); |
2464 | return; |
2465 | } |
2466 | |
2467 | min_digits = atoi(argv[0]); |
2468 | |
2469 | if (argc > 1) { |
2470 | max_digits = atoi(argv[1]); |
2471 | } |
2472 | |
2473 | if (argc > 2) { |
2474 | prompt_audio_file = argv[2]; |
2475 | } |
2476 | |
2477 | if (argc > 3) { |
2478 | var_name = argv[3]; |
2479 | } |
2480 | |
2481 | if (argc > 4) { |
2482 | timeout = atoi(argv[4]); |
2483 | } |
2484 | |
2485 | if (argc > 5) { |
2486 | valid_terminators = argv[5]; |
2487 | } |
2488 | |
2489 | if (argc > 6) { |
2490 | digit_timeout = switch_atoui(argv[6]); |
2491 | } |
2492 | |
2493 | if (min_digits <= 1) { |
2494 | min_digits = 1; |
2495 | } |
2496 | |
2497 | if (max_digits < min_digits) { |
2498 | max_digits = min_digits; |
2499 | } |
2500 | |
2501 | if (timeout <= 1000) { |
2502 | timeout = 1000; |
2503 | } |
2504 | |
2505 | if (zstr(valid_terminators)_zstr(valid_terminators)) { |
2506 | valid_terminators = "#"; |
2507 | } |
2508 | |
2509 | switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, var_name, digit_buffer, sizeof(digit_buffer), timeout, valid_terminators, |
2510 | digit_timeout); |
2511 | } |
2512 | |
2513 | SWITCH_STANDARD_APP(play_and_get_digits_function)static void play_and_get_digits_function (switch_core_session_t *session, const char *data) |
2514 | { |
2515 | char *mydata; |
2516 | char *argv[11] = { 0 }; |
2517 | int argc; |
2518 | int32_t min_digits = 0; |
2519 | int32_t max_digits = 0; |
2520 | int32_t max_tries = 0; |
2521 | uint32_t digit_timeout = 0; |
2522 | int timeout = 1000; |
2523 | char digit_buffer[128] = ""; |
2524 | const char *prompt_audio_file = NULL((void*)0); |
2525 | const char *bad_input_audio_file = NULL((void*)0); |
2526 | const char *var_name = NULL((void*)0); |
2527 | const char *valid_terminators = NULL((void*)0); |
2528 | const char *digits_regex = NULL((void*)0); |
2529 | const char *transfer_on_failure = NULL((void*)0); |
2530 | |
2531 | if (!zstr(data)_zstr(data) && (mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 2531))) { |
2532 | argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); |
2533 | } else { |
2534 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2534, (const char*)(session), SWITCH_LOG_ERROR, "No arguments specified.\n"); |
2535 | return; |
2536 | } |
2537 | |
2538 | min_digits = atoi(argv[0]); |
2539 | |
2540 | if (argc > 1) { |
2541 | max_digits = atoi(argv[1]); |
2542 | } |
2543 | |
2544 | if (argc > 2) { |
2545 | max_tries = atoi(argv[2]); |
2546 | } |
2547 | |
2548 | if (argc > 3) { |
2549 | timeout = atoi(argv[3]); |
2550 | } |
2551 | |
2552 | if (argc > 4) { |
2553 | valid_terminators = argv[4]; |
2554 | } |
2555 | |
2556 | if (argc > 5) { |
2557 | prompt_audio_file = argv[5]; |
2558 | } |
2559 | |
2560 | if (argc > 6) { |
2561 | bad_input_audio_file = argv[6]; |
2562 | } |
2563 | |
2564 | if (argc > 7) { |
2565 | var_name = argv[7]; |
2566 | } |
2567 | |
2568 | if (argc > 8) { |
2569 | digits_regex = argv[8]; |
2570 | } |
2571 | |
2572 | if (argc > 9) { |
2573 | digit_timeout = switch_atoui(argv[9]); |
2574 | } |
2575 | |
2576 | if (argc > 10) { |
2577 | transfer_on_failure = argv[10]; |
2578 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2578, (const char*)(session), SWITCH_LOG_DEBUG, "Transfer on failure = [%s].\n", transfer_on_failure); |
2579 | } |
2580 | |
2581 | if (min_digits <= 0) { |
2582 | min_digits = 0; |
2583 | } |
2584 | |
2585 | if (max_digits < min_digits) { |
2586 | max_digits = min_digits; |
2587 | } |
2588 | |
2589 | if (timeout <= 1000) { |
2590 | timeout = 1000; |
2591 | } |
2592 | |
2593 | if (zstr(valid_terminators)_zstr(valid_terminators)) { |
2594 | valid_terminators = "#"; |
2595 | } |
2596 | |
2597 | switch_play_and_get_digits(session, min_digits, max_digits, max_tries, timeout, valid_terminators, |
2598 | prompt_audio_file, bad_input_audio_file, var_name, digit_buffer, sizeof(digit_buffer), |
2599 | digits_regex, digit_timeout, transfer_on_failure); |
2600 | } |
2601 | |
2602 | #define SAY_SYNTAX"<module_name>[:<lang>] <say_type> <say_method> [<say_gender>] <text>" "<module_name>[:<lang>] <say_type> <say_method> [<say_gender>] <text>" |
2603 | SWITCH_STANDARD_APP(say_function)static void say_function (switch_core_session_t *session, const char *data) |
2604 | { |
2605 | char *argv[5] = { 0 }; |
2606 | int argc; |
2607 | char *lbuf = NULL((void*)0); |
2608 | switch_input_args_t args = { 0 }; |
2609 | switch_channel_t *channel = switch_core_session_get_channel(session); |
2610 | |
2611 | if (!zstr(data)_zstr(data) && (lbuf = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 2611)) |
2612 | && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) && (argc == 4 || argc == 5)) { |
2613 | |
2614 | args.input_callback = on_dtmf; |
2615 | |
2616 | switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "")switch_channel_set_variable_var_check(channel, "playback_terminator_used" , "", SWITCH_TRUE); |
2617 | |
2618 | /* Set default langauge according to the <module_name> */ |
2619 | if (!strchr(argv[0], ':')(__extension__ (__builtin_constant_p (':') && !__builtin_constant_p (argv[0]) && (':') == '\0' ? (char *) __rawmemchr (argv [0], ':') : __builtin_strchr (argv[0], ':')))) { |
2620 | argv[0] = switch_core_session_sprintf(session, "%s:%s", argv[0], argv[0]); |
2621 | } |
2622 | |
2623 | switch_ivr_say(session, (argc == 4) ? argv[3] : argv[4], argv[0], argv[1], argv[2], (argc == 5) ? argv[3] : NULL((void*)0) ,&args); |
2624 | } else { |
2625 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2625, (const char*)(session), SWITCH_LOG_ERROR, "Usage: %s\n", SAY_SYNTAX"<module_name>[:<lang>] <say_type> <say_method> [<say_gender>] <text>"); |
2626 | } |
2627 | |
2628 | } |
2629 | |
2630 | |
2631 | SWITCH_STANDARD_APP(phrase_function)static void phrase_function (switch_core_session_t *session, const char *data) |
2632 | { |
2633 | char *mydata = NULL((void*)0); |
2634 | switch_input_args_t args = { 0 }; |
2635 | switch_channel_t *channel = switch_core_session_get_channel(session); |
2636 | switch_status_t status; |
2637 | |
2638 | if (!zstr(data)_zstr(data) && (mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 2638))) { |
2639 | const char *lang; |
2640 | char *macro = mydata; |
2641 | char *mdata = NULL((void*)0); |
2642 | |
2643 | if ((mdata = strchr(macro, ',')(__extension__ (__builtin_constant_p (',') && !__builtin_constant_p (macro) && (',') == '\0' ? (char *) __rawmemchr (macro , ',') : __builtin_strchr (macro, ','))))) { |
2644 | *mdata++ = '\0'; |
2645 | } |
2646 | |
2647 | lang = switch_channel_get_variable(channel, "language")switch_channel_get_variable_dup(channel, "language", SWITCH_TRUE , -1); |
2648 | |
2649 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2649, (const char*)(session), SWITCH_LOG_DEBUG, "Execute %s(%s) lang %s\n", macro, switch_str_nil(mdata)(mdata ? mdata : ""), |
2650 | switch_str_nil(lang)(lang ? lang : "")); |
2651 | |
2652 | args.input_callback = on_dtmf; |
2653 | |
2654 | switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "")switch_channel_set_variable_var_check(channel, "playback_terminator_used" , "", SWITCH_TRUE); |
2655 | |
2656 | status = switch_ivr_phrase_macro(session, macro, mdata, lang, &args)switch_ivr_phrase_macro_event(session, macro, mdata, ((void*) 0), lang, &args); |
2657 | } else { |
2658 | status = SWITCH_STATUS_NOOP; |
2659 | } |
2660 | |
2661 | switch (status) { |
2662 | case SWITCH_STATUS_SUCCESS: |
2663 | case SWITCH_STATUS_BREAK: |
2664 | switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "PHRASE PLAYED")switch_channel_set_variable_var_check(channel, "current_application_response" , "PHRASE PLAYED", SWITCH_TRUE); |
2665 | break; |
2666 | case SWITCH_STATUS_NOOP: |
2667 | switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "NOTHING")switch_channel_set_variable_var_check(channel, "current_application_response" , "NOTHING", SWITCH_TRUE); |
2668 | break; |
2669 | default: |
2670 | switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "UNKNOWN ERROR")switch_channel_set_variable_var_check(channel, "current_application_response" , "UNKNOWN ERROR", SWITCH_TRUE); |
2671 | break; |
2672 | } |
2673 | } |
2674 | |
2675 | |
2676 | SWITCH_STANDARD_APP(playback_function)static void playback_function (switch_core_session_t *session , const char *data) |
2677 | { |
2678 | switch_input_args_t args = { 0 }; |
2679 | switch_channel_t *channel = switch_core_session_get_channel(session); |
2680 | switch_status_t status = SWITCH_STATUS_SUCCESS; |
2681 | switch_file_handle_t fh = { 0 }; |
2682 | char *p; |
2683 | const char *file = NULL((void*)0); |
2684 | |
2685 | if (data) { |
2686 | file = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 2686); |
2687 | if ((p = strchr(file, '@')(__extension__ (__builtin_constant_p ('@') && !__builtin_constant_p (file) && ('@') == '\0' ? (char *) __rawmemchr (file , '@') : __builtin_strchr (file, '@')))) && *(p + 1) == '@') { |
2688 | *p = '\0'; |
2689 | p += 2; |
2690 | if (p && *p) { |
2691 | fh.samples = atoi(p); |
2692 | } |
2693 | } |
2694 | } else { |
2695 | file = data; |
2696 | } |
2697 | |
2698 | args.input_callback = on_dtmf; |
2699 | |
2700 | switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "")switch_channel_set_variable_var_check(channel, "playback_terminator_used" , "", SWITCH_TRUE); |
2701 | |
2702 | status = switch_ivr_play_file(session, &fh, file, &args); |
2703 | |
2704 | switch (status) { |
2705 | case SWITCH_STATUS_SUCCESS: |
2706 | case SWITCH_STATUS_BREAK: |
2707 | switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "FILE PLAYED")switch_channel_set_variable_var_check(channel, "current_application_response" , "FILE PLAYED", SWITCH_TRUE); |
2708 | break; |
2709 | case SWITCH_STATUS_NOTFOUND: |
2710 | switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "FILE NOT FOUND")switch_channel_set_variable_var_check(channel, "current_application_response" , "FILE NOT FOUND", SWITCH_TRUE); |
2711 | break; |
2712 | default: |
2713 | switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "PLAYBACK ERROR")switch_channel_set_variable_var_check(channel, "current_application_response" , "PLAYBACK ERROR", SWITCH_TRUE); |
2714 | break; |
2715 | } |
2716 | |
2717 | } |
2718 | |
2719 | |
2720 | |
2721 | SWITCH_STANDARD_APP(endless_playback_function)static void endless_playback_function (switch_core_session_t * session, const char *data) |
2722 | { |
2723 | switch_channel_t *channel = switch_core_session_get_channel(session); |
2724 | switch_status_t status = SWITCH_STATUS_SUCCESS; |
2725 | const char *file = data; |
2726 | |
2727 | while (switch_channel_ready(channel)switch_channel_test_ready(channel, SWITCH_TRUE, SWITCH_FALSE)) { |
2728 | status = switch_ivr_play_file(session, NULL((void*)0), file, NULL((void*)0)); |
2729 | |
2730 | if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) { |
2731 | break; |
2732 | } |
2733 | } |
2734 | |
2735 | switch (status) { |
2736 | case SWITCH_STATUS_SUCCESS: |
2737 | case SWITCH_STATUS_BREAK: |
2738 | switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "FILE PLAYED")switch_channel_set_variable_var_check(channel, "current_application_response" , "FILE PLAYED", SWITCH_TRUE); |
2739 | break; |
2740 | case SWITCH_STATUS_NOTFOUND: |
2741 | switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "FILE NOT FOUND")switch_channel_set_variable_var_check(channel, "current_application_response" , "FILE NOT FOUND", SWITCH_TRUE); |
2742 | break; |
2743 | default: |
2744 | switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "PLAYBACK ERROR")switch_channel_set_variable_var_check(channel, "current_application_response" , "PLAYBACK ERROR", SWITCH_TRUE); |
2745 | break; |
2746 | } |
2747 | |
2748 | } |
2749 | |
2750 | SWITCH_STANDARD_APP(loop_playback_function)static void loop_playback_function (switch_core_session_t *session , const char *data) |
2751 | { |
2752 | switch_channel_t *channel = switch_core_session_get_channel(session); |
2753 | switch_status_t status = SWITCH_STATUS_SUCCESS; |
2754 | const char *file = data; |
2755 | int loop = 1; |
2756 | |
2757 | if (*file == '+') { |
2758 | const char *p = ++file; |
2759 | while(*file && *file++ != ' ') { } |
2760 | |
2761 | if (zstr(p)_zstr(p)) { |
2762 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 2762, ((void*)0), SWITCH_LOG_ERROR, "Missing loop in data [%s]\n", data); |
2763 | switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER)switch_channel_perform_hangup(channel, "mod_dptools.c", (const char *)__func__, 2763, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER ); |
2764 | return; |
2765 | } |
2766 | |
2767 | loop = atoi(p); |
2768 | } |
2769 | |
2770 | if (zstr(file)_zstr(file)) { |
2771 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 2771, ((void*)0), SWITCH_LOG_ERROR, "Missing file arg in data [%s]\n", data); |
2772 | switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER)switch_channel_perform_hangup(channel, "mod_dptools.c", (const char *)__func__, 2772, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER ); |
2773 | return; |
2774 | } |
2775 | |
2776 | while (switch_channel_ready(channel)switch_channel_test_ready(channel, SWITCH_TRUE, SWITCH_FALSE) && (loop < 0 || loop-- > 0)) { |
2777 | status = switch_ivr_play_file(session, NULL((void*)0), file, NULL((void*)0)); |
2778 | |
2779 | if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) { |
2780 | break; |
2781 | } |
2782 | } |
2783 | |
2784 | switch (status) { |
2785 | case SWITCH_STATUS_SUCCESS: |
2786 | case SWITCH_STATUS_BREAK: |
2787 | switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "FILE PLAYED")switch_channel_set_variable_var_check(channel, "current_application_response" , "FILE PLAYED", SWITCH_TRUE); |
2788 | break; |
2789 | case SWITCH_STATUS_NOTFOUND: |
2790 | switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "FILE NOT FOUND")switch_channel_set_variable_var_check(channel, "current_application_response" , "FILE NOT FOUND", SWITCH_TRUE); |
2791 | break; |
2792 | default: |
2793 | switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "PLAYBACK ERROR")switch_channel_set_variable_var_check(channel, "current_application_response" , "PLAYBACK ERROR", SWITCH_TRUE); |
2794 | break; |
2795 | } |
2796 | |
2797 | } |
2798 | |
2799 | SWITCH_STANDARD_APP(gentones_function)static void gentones_function (switch_core_session_t *session , const char *data) |
2800 | { |
2801 | char *tone_script = NULL((void*)0); |
2802 | switch_input_args_t args = { 0 }; |
2803 | char *l; |
2804 | int32_t loops = 0; |
2805 | switch_channel_t *channel = switch_core_session_get_channel(session); |
2806 | |
2807 | if (zstr(data)_zstr(data) || !(tone_script = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 2807))) { |
2808 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2808, (const char*)(session), SWITCH_LOG_ERROR, "Invalid Params!\n"); |
2809 | return; |
2810 | } |
2811 | |
2812 | if ((l = strchr(tone_script, '|')(__extension__ (__builtin_constant_p ('|') && !__builtin_constant_p (tone_script) && ('|') == '\0' ? (char *) __rawmemchr (tone_script, '|') : __builtin_strchr (tone_script, '|'))))) { |
2813 | *l++ = '\0'; |
2814 | loops = atoi(l); |
2815 | |
2816 | if (loops < 0) { |
2817 | loops = -1; |
2818 | } |
2819 | } |
2820 | |
2821 | args.input_callback = on_dtmf; |
2822 | |
2823 | switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "")switch_channel_set_variable_var_check(channel, "playback_terminator_used" , "", SWITCH_TRUE); |
2824 | |
2825 | switch_ivr_gentones(session, tone_script, loops, &args); |
2826 | } |
2827 | |
2828 | SWITCH_STANDARD_APP(displace_session_function)static void displace_session_function (switch_core_session_t * session, const char *data) |
2829 | { |
2830 | char *path = NULL((void*)0); |
2831 | uint32_t limit = 0; |
2832 | char *argv[6] = { 0 }; |
2833 | int x, argc; |
2834 | char *lbuf = NULL((void*)0); |
2835 | char *flags = NULL((void*)0); |
2836 | |
2837 | if (!zstr(data)_zstr(data) && (lbuf = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 2837)) |
2838 | && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { |
2839 | path = argv[0]; |
2840 | for (x = 1; x < argc; x++) { |
2841 | if (strchr(argv[x], '+')(__extension__ (__builtin_constant_p ('+') && !__builtin_constant_p (argv[x]) && ('+') == '\0' ? (char *) __rawmemchr (argv [x], '+') : __builtin_strchr (argv[x], '+')))) { |
2842 | limit = atoi(argv[x]); |
2843 | } else if (!zstr(argv[x])_zstr(argv[x])) { |
2844 | flags = argv[x]; |
2845 | } |
2846 | } |
2847 | switch_ivr_displace_session(session, path, limit, flags); |
2848 | } |
2849 | } |
2850 | |
2851 | SWITCH_STANDARD_APP(stop_displace_session_function)static void stop_displace_session_function (switch_core_session_t *session, const char *data) |
2852 | { |
2853 | switch_ivr_stop_displace_session(session, data); |
2854 | } |
2855 | |
2856 | SWITCH_STANDARD_APP(capture_function)static void capture_function (switch_core_session_t *session, const char *data) |
2857 | { |
2858 | char *argv[3] = { 0 }; |
2859 | int argc; |
2860 | switch_regex_t *re = NULL((void*)0); |
2861 | int ovector[30] = {0}; |
2862 | char *lbuf; |
2863 | int proceed; |
2864 | |
2865 | if (!zstr(data)_zstr(data) && (lbuf = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 2865)) |
2866 | && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) == 3) { |
2867 | if ((proceed = switch_regex_perform(argv[1], argv[2], &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) { |
2868 | switch_capture_regex(re, proceed, argv[1], ovector, argv[0], switch_regex_set_var_callback, session); |
2869 | } |
2870 | switch_regex_safe_free(re)if (re) { switch_regex_free(re); re = ((void*)0); }; |
2871 | } else { |
2872 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2872, (const char*)(session), SWITCH_LOG_ERROR, "No data specified.\n"); |
2873 | } |
2874 | } |
2875 | |
2876 | SWITCH_STANDARD_APP(record_function)static void record_function (switch_core_session_t *session, const char *data) |
2877 | { |
2878 | switch_channel_t *channel = switch_core_session_get_channel(session); |
2879 | switch_status_t status; |
2880 | uint32_t limit = 0; |
2881 | char *path; |
2882 | switch_input_args_t args = { 0 }; |
2883 | switch_file_handle_t fh = { 0 }; |
2884 | //int argc; |
2885 | char *mydata, *argv[4] = { 0 }; |
2886 | char *l = NULL((void*)0); |
2887 | const char *tmp; |
2888 | int rate; |
2889 | |
2890 | if (!zstr(data)_zstr(data) && (mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 2890))) { |
2891 | switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); |
2892 | } else { |
2893 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 2893, (const char*)(session), SWITCH_LOG_ERROR, "No file specified.\n"); |
2894 | return; |
2895 | } |
2896 | |
2897 | path = argv[0]; |
2898 | l = argv[1]; |
2899 | |
2900 | if (l) { |
2901 | if (*l == '+') { |
2902 | l++; |
2903 | } |
2904 | if (l) { |
2905 | limit = switch_atoui(l); |
2906 | } |
2907 | } |
2908 | |
2909 | if (argv[2]) { |
2910 | fh.thresh = switch_atoui(argv[2]); |
2911 | } |
2912 | |
2913 | if (argv[3]) { |
2914 | fh.silence_hits = switch_atoui(argv[3]); |
2915 | } |
2916 | |
2917 | if ((tmp = switch_channel_get_variable(channel, "record_rate")switch_channel_get_variable_dup(channel, "record_rate", SWITCH_TRUE , -1))) { |
2918 | rate = atoi(tmp); |
2919 | if (rate > 0) { |
2920 | fh.samplerate = rate; |
2921 | } |
2922 | } |
2923 | |
2924 | args.input_callback = on_dtmf; |
2925 | |
2926 | switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "")switch_channel_set_variable_var_check(channel, "playback_terminator_used" , "", SWITCH_TRUE); |
2927 | |
2928 | status = switch_ivr_record_file(session, &fh, path, &args, limit); |
2929 | |
2930 | if (!switch_channel_ready(channel)switch_channel_test_ready(channel, SWITCH_TRUE, SWITCH_FALSE) || (status != SWITCH_STATUS_SUCCESS && !SWITCH_STATUS_IS_BREAK(status)(status == SWITCH_STATUS_BREAK || status == 730035 || status == 35 || status == SWITCH_STATUS_INTR))) { |
2931 | switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER)switch_channel_perform_hangup(channel, "mod_dptools.c", (const char *)__func__, 2931, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER ); |
2932 | } |
2933 | } |
2934 | |
2935 | SWITCH_STANDARD_APP(preprocess_session_function)static void preprocess_session_function (switch_core_session_t *session, const char *data) |
2936 | { |
2937 | switch_ivr_preprocess_session(session, (char *) data); |
2938 | } |
2939 | |
2940 | SWITCH_STANDARD_APP(record_session_mask_function)static void record_session_mask_function (switch_core_session_t *session, const char *data) |
2941 | { |
2942 | switch_ivr_record_session_mask(session, (char *) data, SWITCH_TRUE); |
2943 | } |
2944 | |
2945 | SWITCH_STANDARD_APP(record_session_unmask_function)static void record_session_unmask_function (switch_core_session_t *session, const char *data) |
2946 | { |
2947 | switch_ivr_record_session_mask(session, (char *) data, SWITCH_FALSE); |
2948 | } |
2949 | |
2950 | SWITCH_STANDARD_APP(record_session_function)static void record_session_function (switch_core_session_t *session , const char *data) |
2951 | { |
2952 | char *path = NULL((void*)0); |
2953 | char *path_end; |
2954 | uint32_t limit = 0; |
2955 | |
2956 | if (zstr(data)_zstr(data)) { |
2957 | return; |
2958 | } |
2959 | |
2960 | path = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 2960); |
2961 | |
2962 | /* Search for a space then a plus followed by only numbers at the end of the path, |
2963 | if found trim any spaces to the left/right of the plus use the left side as the |
2964 | path and right side as a time limit on the recording |
2965 | */ |
2966 | |
2967 | /* if we find a + and the character before it is a space */ |
2968 | if ((path_end = strrchr(path, '+')) && path_end > path && *(path_end - 1) == ' ') { |
2969 | char *limit_start = path_end + 1; |
2970 | |
2971 | /* not at the end and the rest is numbers lets parse out the limit and fix up the path */ |
2972 | if (*limit_start != '\0' && switch_is_number(limit_start) == SWITCH_TRUE) { |
2973 | limit = atoi(limit_start); |
2974 | /* back it off by one character to the char before the + */ |
2975 | path_end--; |
2976 | |
2977 | /* trim spaces to the left of the plus */ |
2978 | while (path_end > path && *path_end == ' ') { |
2979 | path_end--; |
2980 | } |
2981 | |
2982 | *(path_end + 1) = '\0'; |
2983 | } |
2984 | } |
2985 | switch_ivr_record_session(session, path, limit, NULL((void*)0)); |
2986 | } |
2987 | |
2988 | SWITCH_STANDARD_APP(stop_record_session_function)static void stop_record_session_function (switch_core_session_t *session, const char *data) |
2989 | { |
2990 | switch_ivr_stop_record_session(session, data); |
2991 | } |
2992 | |
2993 | /********************************************************************************/ |
2994 | /* Bridge Functions */ |
2995 | /********************************************************************************/ |
2996 | |
2997 | static switch_status_t camp_fire(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen) |
2998 | { |
2999 | switch (itype) { |
3000 | case SWITCH_INPUT_TYPE_DTMF: |
3001 | { |
3002 | switch_dtmf_t *dtmf = (switch_dtmf_t *) input; |
3003 | char *key = (char *) buf; |
3004 | |
3005 | if (dtmf->digit == *key) { |
3006 | return SWITCH_STATUS_BREAK; |
3007 | } |
3008 | } |
3009 | default: |
3010 | break; |
3011 | } |
3012 | |
3013 | return SWITCH_STATUS_SUCCESS; |
3014 | } |
3015 | |
3016 | struct camping_stake { |
3017 | switch_core_session_t *session; |
3018 | int running; |
3019 | int do_xfer; |
3020 | const char *moh; |
3021 | }; |
3022 | |
3023 | static void *SWITCH_THREAD_FUNC camp_music_thread(switch_thread_t *thread, void *obj) |
3024 | { |
3025 | struct camping_stake *stake = (struct camping_stake *) obj; |
3026 | switch_core_session_t *session = stake->session; |
3027 | switch_channel_t *channel = switch_core_session_get_channel(stake->session); |
3028 | const char *moh = stake->moh, *greet = NULL((void*)0); |
3029 | switch_input_args_t args = { 0 }; |
3030 | char dbuf[2] = ""; |
3031 | switch_status_t status = SWITCH_STATUS_FALSE; |
3032 | const char *stop; |
3033 | |
3034 | if ((stop = switch_channel_get_variable(channel, "campon_stop_key")switch_channel_get_variable_dup(channel, "campon_stop_key", SWITCH_TRUE , -1))) { |
3035 | *dbuf = *stop; |
3036 | } |
3037 | |
3038 | args.input_callback = camp_fire; |
3039 | args.buf = dbuf; |
3040 | args.buflen = sizeof(dbuf); |
3041 | |
3042 | switch_core_session_read_lock(session); |
3043 | |
3044 | /* don't set this to a local_stream:// or you will not be happy */ |
3045 | if ((greet = switch_channel_get_variable(channel, "campon_announce_sound")switch_channel_get_variable_dup(channel, "campon_announce_sound" , SWITCH_TRUE, -1))) { |
3046 | status = switch_ivr_play_file(session, NULL((void*)0), greet, &args); |
3047 | } |
3048 | |
3049 | while (stake->running && switch_channel_ready(channel)switch_channel_test_ready(channel, SWITCH_TRUE, SWITCH_FALSE)) { |
3050 | if (status != SWITCH_STATUS_BREAK) { |
3051 | if (!strcasecmp(moh, "silence")) { |
3052 | status = switch_ivr_collect_digits_callback(session, &args, 0, 0); |
3053 | } else { |
3054 | status = switch_ivr_play_file(session, NULL((void*)0), stake->moh, &args); |
3055 | } |
3056 | } |
3057 | |
3058 | if (status == SWITCH_STATUS_BREAK) { |
3059 | switch_channel_set_flag(channel, CF_NOT_READY)switch_channel_set_flag_value(channel, CF_NOT_READY, 1); |
3060 | stake->do_xfer = 1; |
3061 | } |
3062 | } |
3063 | switch_core_session_rwunlock(session); |
3064 | |
3065 | stake->running = 0; |
3066 | |
3067 | return NULL((void*)0); |
3068 | } |
3069 | |
3070 | SWITCH_STANDARD_APP(audio_bridge_function)static void audio_bridge_function (switch_core_session_t *session , const char *data) |
3071 | { |
3072 | switch_channel_t *caller_channel = switch_core_session_get_channel(session); |
3073 | switch_core_session_t *peer_session = NULL((void*)0); |
3074 | const char *v_campon = NULL((void*)0), *v_campon_retries, *v_campon_sleep, *v_campon_timeout, *v_campon_fallback_exten = NULL((void*)0); |
3075 | switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING; |
3076 | int campon_retries = 100, campon_timeout = 10, campon_sleep = 10, tmp, camping = 0, fail = 0, thread_started = 0; |
3077 | struct camping_stake stake = { 0 }; |
3078 | const char *moh = NULL((void*)0); |
3079 | switch_thread_t *thread = NULL((void*)0); |
3080 | switch_threadattr_t *thd_attr = NULL((void*)0); |
3081 | char *camp_data = NULL((void*)0); |
3082 | switch_status_t status = SWITCH_STATUS_FALSE; |
3083 | int camp_loops = 0; |
3084 | |
3085 | if (zstr(data)_zstr(data)) { |
3086 | return; |
3087 | } |
3088 | |
3089 | if ((v_campon = switch_channel_get_variable(caller_channel, "campon")switch_channel_get_variable_dup(caller_channel, "campon", SWITCH_TRUE , -1)) && switch_true(v_campon)) { |
3090 | const char *cid_name = NULL((void*)0); |
3091 | const char *cid_number = NULL((void*)0); |
3092 | |
3093 | if (!(cid_name = switch_channel_get_variable(caller_channel, "effective_caller_id_name")switch_channel_get_variable_dup(caller_channel, "effective_caller_id_name" , SWITCH_TRUE, -1))) { |
3094 | cid_name = switch_channel_get_variable(caller_channel, "caller_id_name")switch_channel_get_variable_dup(caller_channel, "caller_id_name" , SWITCH_TRUE, -1); |
3095 | } |
3096 | |
3097 | if (!(cid_number = switch_channel_get_variable(caller_channel, "effective_caller_id_number")switch_channel_get_variable_dup(caller_channel, "effective_caller_id_number" , SWITCH_TRUE, -1))) { |
3098 | cid_number = switch_channel_get_variable(caller_channel, "caller_id_number")switch_channel_get_variable_dup(caller_channel, "caller_id_number" , SWITCH_TRUE, -1); |
3099 | } |
3100 | |
3101 | if (cid_name && !cid_number) { |
3102 | cid_number = cid_name; |
3103 | } |
3104 | |
3105 | if (cid_number && !cid_name) { |
3106 | cid_name = cid_number; |
3107 | } |
3108 | |
3109 | v_campon_retries = switch_channel_get_variable(caller_channel, "campon_retries")switch_channel_get_variable_dup(caller_channel, "campon_retries" , SWITCH_TRUE, -1); |
3110 | v_campon_timeout = switch_channel_get_variable(caller_channel, "campon_timeout")switch_channel_get_variable_dup(caller_channel, "campon_timeout" , SWITCH_TRUE, -1); |
3111 | v_campon_sleep = switch_channel_get_variable(caller_channel, "campon_sleep")switch_channel_get_variable_dup(caller_channel, "campon_sleep" , SWITCH_TRUE, -1); |
3112 | v_campon_fallback_exten = switch_channel_get_variable(caller_channel, "campon_fallback_exten")switch_channel_get_variable_dup(caller_channel, "campon_fallback_exten" , SWITCH_TRUE, -1); |
3113 | |
3114 | if (v_campon_retries) { |
3115 | if ((tmp = atoi(v_campon_retries)) > 0) { |
3116 | campon_retries = tmp; |
3117 | } |
3118 | } |
3119 | |
3120 | if (v_campon_timeout) { |
3121 | if ((tmp = atoi(v_campon_timeout)) > 0) { |
3122 | campon_timeout = tmp; |
3123 | } |
3124 | } |
3125 | |
3126 | if (v_campon_sleep) { |
3127 | if ((tmp = atoi(v_campon_sleep)) > 0) { |
3128 | campon_sleep = tmp; |
3129 | } |
3130 | } |
3131 | |
3132 | switch_channel_answer(caller_channel)switch_channel_perform_answer(caller_channel, "mod_dptools.c" , (const char *)__func__, 3132); |
3133 | camping = 1; |
3134 | |
3135 | if (cid_name && cid_number) { |
3136 | camp_data = switch_core_session_sprintf(session, "{origination_caller_id_name='%s',origination_caller_id_number='%s'}%s", |
3137 | cid_name, cid_number, data); |
3138 | } else { |
3139 | camp_data = (char *) data; |
3140 | } |
3141 | |
3142 | if (!(moh = switch_channel_get_variable(caller_channel, "campon_hold_music")switch_channel_get_variable_dup(caller_channel, "campon_hold_music" , SWITCH_TRUE, -1))) { |
3143 | moh = switch_channel_get_hold_music(caller_channel); |
3144 | } |
3145 | |
3146 | if (!zstr(moh)_zstr(moh) && !strcasecmp(moh, "silence")) { |
3147 | moh = NULL((void*)0); |
3148 | } |
3149 | |
3150 | do { |
3151 | fail = 0; |
3152 | |
3153 | if (!switch_channel_ready(caller_channel)switch_channel_test_ready(caller_channel, SWITCH_TRUE, SWITCH_FALSE )) { |
3154 | fail = 1; |
3155 | break; |
3156 | } |
3157 | |
3158 | if (status == SWITCH_STATUS_SUCCESS) { |
3159 | camping = 0; |
3160 | break; |
3161 | } else { |
3162 | fail = 1; |
3163 | } |
3164 | |
3165 | if (camping) { |
3166 | |
3167 | if (!thread_started && fail && moh && !switch_channel_test_flag(caller_channel, CF_PROXY_MODE) && |
3168 | !switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA) && |
3169 | !switch_true(switch_channel_get_variable(caller_channel, "bypass_media")switch_channel_get_variable_dup(caller_channel, "bypass_media" , SWITCH_TRUE, -1))) { |
3170 | switch_threadattr_create(&thd_attr, switch_core_session_get_pool(session)); |
3171 | switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE240 * 1024); |
3172 | stake.running = 1; |
3173 | stake.moh = moh; |
3174 | stake.session = session; |
3175 | switch_thread_create(&thread, thd_attr, camp_music_thread, &stake, switch_core_session_get_pool(session)); |
3176 | thread_started = 1; |
3177 | } |
3178 | |
3179 | if (camp_loops++) { |
3180 | if (--campon_retries <= 0 || stake.do_xfer) { |
3181 | camping = 0; |
3182 | stake.do_xfer = 1; |
3183 | break; |
3184 | } |
3185 | |
3186 | if (fail) { |
3187 | int64_t wait = (int64_t)campon_sleep * 1000000; |
3188 | |
3189 | while (stake.running && wait > 0 && switch_channel_ready(caller_channel)switch_channel_test_ready(caller_channel, SWITCH_TRUE, SWITCH_FALSE )) { |
3190 | switch_yield(100000)switch_sleep(100000);; |
3191 | wait -= 100000; |
3192 | } |
3193 | } |
3194 | } |
3195 | } |
3196 | |
3197 | status = switch_ivr_originate(NULL((void*)0), &peer_session, |
3198 | &cause, camp_data, campon_timeout, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0), SOF_NONE, |
3199 | switch_channel_get_cause_ptr(caller_channel)); |
3200 | |
3201 | |
3202 | } while (camping && switch_channel_ready(caller_channel)switch_channel_test_ready(caller_channel, SWITCH_TRUE, SWITCH_FALSE )); |
3203 | |
3204 | if (thread) { |
3205 | stake.running = 0; |
3206 | switch_channel_set_flag(caller_channel, CF_NOT_READY)switch_channel_set_flag_value(caller_channel, CF_NOT_READY, 1 ); |
3207 | switch_thread_join(&status, thread); |
3208 | } |
3209 | |
3210 | switch_channel_clear_flag(caller_channel, CF_NOT_READY); |
3211 | |
3212 | if (stake.do_xfer && !zstr(v_campon_fallback_exten)_zstr(v_campon_fallback_exten)) { |
3213 | switch_ivr_session_transfer(session, |
3214 | v_campon_fallback_exten, |
3215 | switch_channel_get_variable(caller_channel, "campon_fallback_dialplan")switch_channel_get_variable_dup(caller_channel, "campon_fallback_dialplan" , SWITCH_TRUE, -1), |
3216 | switch_channel_get_variable(caller_channel, "campon_fallback_context")switch_channel_get_variable_dup(caller_channel, "campon_fallback_context" , SWITCH_TRUE, -1)); |
3217 | |
3218 | if (peer_session) { |
3219 | switch_channel_hangup(switch_core_session_get_channel(peer_session), SWITCH_CAUSE_ORIGINATOR_CANCEL)switch_channel_perform_hangup(switch_core_session_get_channel (peer_session), "mod_dptools.c", (const char *)__func__, 3219 , SWITCH_CAUSE_ORIGINATOR_CANCEL); |
3220 | switch_core_session_rwunlock(peer_session); |
3221 | } |
3222 | |
3223 | return; |
3224 | } |
3225 | |
3226 | } else { |
3227 | if ((status = |
3228 | switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0), SOF_NONE, NULL((void*)0))) != SWITCH_STATUS_SUCCESS) { |
3229 | fail = 1; |
3230 | } |
3231 | } |
3232 | |
3233 | if (fail) { |
3234 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 3234, (const char*)(session), SWITCH_LOG_INFO, "Originate Failed. Cause: %s\n", switch_channel_cause2str(cause)); |
3235 | |
3236 | switch_channel_handle_cause(caller_channel, cause); |
3237 | return; |
3238 | } else { |
3239 | |
3240 | switch_channel_t *peer_channel = switch_core_session_get_channel(peer_session); |
3241 | if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE)switch_channel_get_variable_dup(caller_channel, "bypass_media_after_bridge" , SWITCH_TRUE, -1)) || |
3242 | switch_true(switch_channel_get_variable(peer_channel, SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE)switch_channel_get_variable_dup(peer_channel, "bypass_media_after_bridge" , SWITCH_TRUE, -1))) { |
3243 | switch_channel_set_flag(caller_channel, CF_BYPASS_MEDIA_AFTER_BRIDGE)switch_channel_set_flag_value(caller_channel, CF_BYPASS_MEDIA_AFTER_BRIDGE , 1); |
3244 | } |
3245 | |
3246 | if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE)) { |
3247 | switch_ivr_signal_bridge(session, peer_session); |
3248 | } else { |
3249 | char *a_key = (char *) switch_channel_get_variable(caller_channel, "bridge_terminate_key")switch_channel_get_variable_dup(caller_channel, "bridge_terminate_key" , SWITCH_TRUE, -1); |
3250 | char *b_key = (char *) switch_channel_get_variable(peer_channel, "bridge_terminate_key")switch_channel_get_variable_dup(peer_channel, "bridge_terminate_key" , SWITCH_TRUE, -1); |
3251 | int ok = 0; |
3252 | switch_input_callback_function_t func = NULL((void*)0); |
3253 | |
3254 | if (a_key) { |
3255 | a_key = switch_core_session_strdup(session, a_key)switch_core_perform_session_strdup(session, a_key, "mod_dptools.c" , (const char *)__func__, 3255); |
3256 | ok++; |
3257 | } |
3258 | if (b_key) { |
3259 | b_key = switch_core_session_strdup(session, b_key)switch_core_perform_session_strdup(session, b_key, "mod_dptools.c" , (const char *)__func__, 3259); |
3260 | ok++; |
3261 | } |
3262 | if (ok) { |
3263 | func = bridge_on_dtmf; |
3264 | } else { |
3265 | a_key = NULL((void*)0); |
3266 | b_key = NULL((void*)0); |
3267 | } |
3268 | |
3269 | switch_ivr_multi_threaded_bridge(session, peer_session, func, a_key, b_key); |
3270 | } |
3271 | |
3272 | if (peer_session) { |
3273 | switch_core_session_rwunlock(peer_session); |
3274 | } |
3275 | } |
3276 | } |
3277 | |
3278 | static struct { |
3279 | switch_memory_pool_t *pool; |
3280 | switch_hash_t *pickup_hash; |
3281 | switch_mutex_t *pickup_mutex; |
3282 | switch_hash_t *mutex_hash; |
3283 | switch_mutex_t *mutex_mutex; |
3284 | } globals; |
3285 | |
3286 | /* pickup channel */ |
3287 | |
3288 | |
3289 | |
3290 | typedef struct pickup_node_s { |
3291 | char *key; |
3292 | char *uuid; |
3293 | struct pickup_node_s *next; |
3294 | } pickup_node_t; |
3295 | |
3296 | |
3297 | #define PICKUP_PROTO"pickup" "pickup" |
3298 | static int EC = 0; |
3299 | |
3300 | static int pickup_count(const char *key_name) |
3301 | { |
3302 | int count = 0; |
3303 | pickup_node_t *head, *np; |
3304 | |
3305 | switch_mutex_lock(globals.pickup_mutex); |
3306 | if ((head = switch_core_hash_find(globals.pickup_hash, key_name))) { |
3307 | for (np = head; np; np = np->next) count++; |
3308 | } |
3309 | switch_mutex_unlock(globals.pickup_mutex); |
3310 | |
3311 | return count; |
3312 | |
3313 | } |
3314 | |
3315 | static void pickup_send_presence(const char *key_name) |
3316 | { |
3317 | |
3318 | char *domain_name, *dup_key_name = NULL((void*)0), *dup_domain_name = NULL((void*)0), *dup_id = NULL((void*)0); |
3319 | switch_event_t *event; |
3320 | int count; |
3321 | |
3322 | |
3323 | dup_key_name = strdup(key_name)(__extension__ (__builtin_constant_p (key_name) && (( size_t)(const void *)((key_name) + 1) - (size_t)(const void * )(key_name) == 1) ? (((const char *) (key_name))[0] == '\0' ? (char *) calloc ((size_t) 1, (size_t) 1) : ({ size_t __len = strlen (key_name) + 1; char *__retval = (char *) malloc (__len ); if (__retval != ((void*)0)) __retval = (char *) memcpy (__retval , key_name, __len); __retval; })) : __strdup (key_name))); |
3324 | key_name = dup_key_name; |
3325 | |
3326 | if ((domain_name = strchr(dup_key_name, '@')(__extension__ (__builtin_constant_p ('@') && !__builtin_constant_p (dup_key_name) && ('@') == '\0' ? (char *) __rawmemchr (dup_key_name, '@') : __builtin_strchr (dup_key_name, '@'))))) { |
3327 | *domain_name++ = '\0'; |
3328 | } |
3329 | |
3330 | if (zstr(domain_name)_zstr(domain_name)) { |
3331 | dup_domain_name = switch_core_get_domain(SWITCH_TRUE); |
3332 | domain_name = dup_domain_name; |
3333 | } |
3334 | |
3335 | if (zstr(domain_name)_zstr(domain_name)) { |
3336 | domain_name = "cluecon.com"; |
3337 | } |
3338 | |
3339 | dup_id = switch_mprintf("%s@%s", key_name, domain_name); |
3340 | |
3341 | count = pickup_count(dup_id); |
3342 | |
3343 | if (count > 0) { |
3344 | if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN)switch_event_create_subclass_detailed("mod_dptools.c", (const char * )(const char *)__func__, 3344, &event, SWITCH_EVENT_PRESENCE_IN , ((void*)0)) == SWITCH_STATUS_SUCCESS) { |
3345 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", PICKUP_PROTO"pickup"); |
3346 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", dup_id); |
3347 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", dup_id); |
3348 | |
3349 | |
3350 | switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d call%s)", count, count == 1 ? "" : "s"); |
3351 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "active"); |
3352 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); |
3353 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog"); |
3354 | switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++); |
3355 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", key_name); |
3356 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_ROUTING"); |
3357 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "confirmed"); |
3358 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound"); |
3359 | switch_event_fire(&event)switch_event_fire_detailed("mod_dptools.c", (const char * )(const char *)__func__, 3359, &event, ((void*)0)); |
3360 | } |
3361 | } else { |
3362 | if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN)switch_event_create_subclass_detailed("mod_dptools.c", (const char * )(const char *)__func__, 3362, &event, SWITCH_EVENT_PRESENCE_IN , ((void*)0)) == SWITCH_STATUS_SUCCESS) { |
3363 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", PICKUP_PROTO"pickup"); |
3364 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", dup_id); |
3365 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", dup_id); |
3366 | |
3367 | |
3368 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Idle"); |
3369 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "unknown"); |
3370 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); |
3371 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog"); |
3372 | switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++); |
3373 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", dup_id); |
3374 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_HANGUP"); |
3375 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated"); |
3376 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound"); |
3377 | switch_event_fire(&event)switch_event_fire_detailed("mod_dptools.c", (const char * )(const char *)__func__, 3377, &event, ((void*)0)); |
3378 | } |
3379 | } |
3380 | |
3381 | switch_safe_free(dup_domain_name)if (dup_domain_name) {free(dup_domain_name);dup_domain_name=( (void*)0);}; |
3382 | switch_safe_free(dup_key_name)if (dup_key_name) {free(dup_key_name);dup_key_name=((void*)0) ;}; |
3383 | switch_safe_free(dup_id)if (dup_id) {free(dup_id);dup_id=((void*)0);}; |
3384 | |
3385 | } |
3386 | |
3387 | static void pickup_pres_event_handler(switch_event_t *event) |
3388 | { |
3389 | char *to = switch_event_get_header(event, "to")switch_event_get_header_idx(event, "to", -1); |
3390 | char *dup_to = NULL((void*)0), *key_name, *dup_key_name = NULL((void*)0), *domain_name, *dup_domain_name = NULL((void*)0); |
3391 | int count = 0; |
3392 | |
3393 | if (!to || strncasecmp(to, "pickup+", 7) || !strchr(to, '@')(__extension__ (__builtin_constant_p ('@') && !__builtin_constant_p (to) && ('@') == '\0' ? (char *) __rawmemchr (to, '@' ) : __builtin_strchr (to, '@')))) { |
3394 | return; |
3395 | } |
3396 | |
3397 | if (!(dup_to = strdup(to)(__extension__ (__builtin_constant_p (to) && ((size_t )(const void *)((to) + 1) - (size_t)(const void *)(to) == 1) ? (((const char *) (to))[0] == '\0' ? (char *) calloc ((size_t ) 1, (size_t) 1) : ({ size_t __len = strlen (to) + 1; char *__retval = (char *) malloc (__len); if (__retval != ((void*)0)) __retval = (char *) memcpy (__retval, to, __len); __retval; })) : __strdup (to))))) { |
3398 | return; |
3399 | } |
3400 | |
3401 | key_name = dup_to + 7; |
3402 | |
3403 | if ((domain_name = strchr(key_name, '@')(__extension__ (__builtin_constant_p ('@') && !__builtin_constant_p (key_name) && ('@') == '\0' ? (char *) __rawmemchr ( key_name, '@') : __builtin_strchr (key_name, '@'))))) { |
3404 | *domain_name++ = '\0'; |
3405 | } else { |
3406 | dup_domain_name = switch_core_get_domain(SWITCH_TRUE); |
3407 | domain_name = dup_domain_name; |
3408 | } |
3409 | |
3410 | if (zstr(domain_name)_zstr(domain_name)) { |
3411 | switch_safe_free(dup_to)if (dup_to) {free(dup_to);dup_to=((void*)0);}; |
3412 | switch_safe_free(dup_domain_name)if (dup_domain_name) {free(dup_domain_name);dup_domain_name=( (void*)0);}; |
3413 | return; |
3414 | } |
3415 | |
3416 | dup_key_name = switch_mprintf("%q@%q", key_name, domain_name); |
3417 | count = pickup_count(dup_key_name); |
3418 | |
3419 | switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN)switch_event_create_subclass_detailed("mod_dptools.c", (const char * )(const char *)__func__, 3419, &event, SWITCH_EVENT_PRESENCE_IN , ((void*)0)); |
3420 | |
3421 | if (count) { |
3422 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", PICKUP_PROTO"pickup"); |
3423 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", key_name); |
3424 | switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", key_name, domain_name); |
3425 | |
3426 | switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d call%s)", count, count == 1 ? "" : "s"); |
3427 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "active"); |
3428 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); |
3429 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog"); |
3430 | switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++); |
3431 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", key_name); |
3432 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_ROUTING"); |
3433 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "confirmed"); |
3434 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound"); |
3435 | } else { |
3436 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", PICKUP_PROTO"pickup"); |
3437 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", key_name); |
3438 | switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", key_name, domain_name); |
3439 | |
3440 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Idle"); |
3441 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "unknown"); |
3442 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); |
3443 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog"); |
3444 | switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++); |
3445 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", key_name); |
3446 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_HANGUP"); |
3447 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated"); |
3448 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound"); |
3449 | |
3450 | } |
3451 | |
3452 | switch_event_fire(&event)switch_event_fire_detailed("mod_dptools.c", (const char * )(const char *)__func__, 3452, &event, ((void*)0)); |
3453 | switch_safe_free(dup_to)if (dup_to) {free(dup_to);dup_to=((void*)0);}; |
3454 | switch_safe_free(dup_key_name)if (dup_key_name) {free(dup_key_name);dup_key_name=((void*)0) ;}; |
3455 | switch_safe_free(dup_domain_name)if (dup_domain_name) {free(dup_domain_name);dup_domain_name=( (void*)0);}; |
3456 | } |
3457 | |
3458 | |
3459 | |
3460 | static void pickup_add_session(switch_core_session_t *session, const char *key) |
3461 | { |
3462 | pickup_node_t *head, *node, *np; |
3463 | char *dup_key = NULL((void*)0); |
3464 | |
3465 | if (!strchr(key, '@')(__extension__ (__builtin_constant_p ('@') && !__builtin_constant_p (key) && ('@') == '\0' ? (char *) __rawmemchr (key, '@' ) : __builtin_strchr (key, '@')))) { |
3466 | dup_key = switch_mprintf("%s@%s", key, switch_core_get_domain(SWITCH_FALSE)); |
3467 | key = dup_key; |
3468 | } |
3469 | |
3470 | node = malloc(sizeof(*node)); |
3471 | node->key = strdup(key)(__extension__ (__builtin_constant_p (key) && ((size_t )(const void *)((key) + 1) - (size_t)(const void *)(key) == 1 ) ? (((const char *) (key))[0] == '\0' ? (char *) calloc ((size_t ) 1, (size_t) 1) : ({ size_t __len = strlen (key) + 1; char * __retval = (char *) malloc (__len); if (__retval != ((void*)0 )) __retval = (char *) memcpy (__retval, key, __len); __retval ; })) : __strdup (key))); |
3472 | node->uuid = strdup(switch_core_session_get_uuid(session))(__extension__ (__builtin_constant_p (switch_core_session_get_uuid (session)) && ((size_t)(const void *)((switch_core_session_get_uuid (session)) + 1) - (size_t)(const void *)(switch_core_session_get_uuid (session)) == 1) ? (((const char *) (switch_core_session_get_uuid (session)))[0] == '\0' ? (char *) calloc ((size_t) 1, (size_t ) 1) : ({ size_t __len = strlen (switch_core_session_get_uuid (session)) + 1; char *__retval = (char *) malloc (__len); if ( __retval != ((void*)0)) __retval = (char *) memcpy (__retval, switch_core_session_get_uuid(session), __len); __retval; })) : __strdup (switch_core_session_get_uuid(session)))); |
3473 | node->next = NULL((void*)0); |
3474 | |
3475 | switch_mutex_lock(globals.pickup_mutex); |
3476 | head = switch_core_hash_find(globals.pickup_hash, key); |
3477 | |
3478 | if (head) { |
3479 | for (np = head; np && np->next; np = np->next); |
3480 | np->next = node; |
3481 | } else { |
3482 | head = node; |
3483 | switch_core_hash_insert(globals.pickup_hash, key, head)switch_core_hash_insert_destructor(globals.pickup_hash, key, head , ((void*)0)); |
3484 | } |
3485 | |
3486 | switch_mutex_unlock(globals.pickup_mutex); |
3487 | |
3488 | pickup_send_presence(key); |
3489 | |
3490 | switch_safe_free(dup_key)if (dup_key) {free(dup_key);dup_key=((void*)0);}; |
3491 | } |
3492 | |
3493 | static char *pickup_pop_uuid(const char *key, const char *uuid) |
3494 | { |
3495 | pickup_node_t *node = NULL((void*)0), *head; |
3496 | char *r = NULL((void*)0); |
3497 | char *dup_key = NULL((void*)0); |
3498 | |
3499 | if (!strchr(key, '@')(__extension__ (__builtin_constant_p ('@') && !__builtin_constant_p (key) && ('@') == '\0' ? (char *) __rawmemchr (key, '@' ) : __builtin_strchr (key, '@')))) { |
3500 | dup_key = switch_mprintf("%s@%s", key, switch_core_get_domain(SWITCH_FALSE)); |
3501 | key = dup_key; |
3502 | } |
3503 | |
3504 | switch_mutex_lock(globals.pickup_mutex); |
3505 | |
3506 | if ((head = switch_core_hash_find(globals.pickup_hash, key))) { |
3507 | |
3508 | switch_core_hash_delete(globals.pickup_hash, key); |
3509 | |
3510 | if (uuid) { |
3511 | pickup_node_t *np, *lp = NULL((void*)0); |
3512 | |
3513 | for(np = head; np; np = np->next) { |
3514 | if (!strcmp(np->uuid, uuid)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (np->uuid) && __builtin_constant_p (uuid) && (__s1_len = __builtin_strlen (np->uuid), __s2_len = __builtin_strlen (uuid), (!((size_t)(const void *)((np->uuid) + 1) - (size_t )(const void *)(np->uuid) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((uuid) + 1) - (size_t)(const void * )(uuid) == 1) || __s2_len >= 4)) ? __builtin_strcmp (np-> uuid, uuid) : (__builtin_constant_p (np->uuid) && ( (size_t)(const void *)((np->uuid) + 1) - (size_t)(const void *)(np->uuid) == 1) && (__s1_len = __builtin_strlen (np->uuid), __s1_len < 4) ? (__builtin_constant_p (uuid ) && ((size_t)(const void *)((uuid) + 1) - (size_t)(const void *)(uuid) == 1) ? __builtin_strcmp (np->uuid, uuid) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (uuid); int __result = (((const unsigned char *) (const char *) (np->uuid))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (np->uuid))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (np->uuid))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (np->uuid))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p (uuid) && ((size_t)(const void *)((uuid) + 1) - (size_t)(const void *)(uuid) == 1) && (__s2_len = __builtin_strlen (uuid), __s2_len < 4) ? (__builtin_constant_p (np->uuid) && ((size_t)(const void *)((np->uuid ) + 1) - (size_t)(const void *)(np->uuid) == 1) ? __builtin_strcmp (np->uuid, uuid) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (np->uuid) ; int __result = (((const unsigned char *) (const char *) (uuid ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (uuid ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (uuid ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (uuid)) [3] - __s2[3]); } } __result; })))) : __builtin_strcmp (np-> uuid, uuid)))); })) { |
3515 | if (lp) { |
3516 | lp->next = np->next; |
3517 | } else { |
3518 | head = np->next; |
3519 | } |
3520 | |
3521 | node = np; |
3522 | break; |
3523 | } |
3524 | |
3525 | lp = np; |
3526 | } |
3527 | |
3528 | } else { |
3529 | node = head; |
3530 | head = head->next; |
3531 | } |
3532 | |
3533 | |
3534 | if (head) { |
3535 | switch_core_hash_insert(globals.pickup_hash, key, head)switch_core_hash_insert_destructor(globals.pickup_hash, key, head , ((void*)0)); |
3536 | } |
3537 | } |
3538 | |
3539 | if (node) { |
3540 | r = node->uuid; |
3541 | free(node->key); |
3542 | free(node); |
3543 | } |
3544 | |
3545 | switch_mutex_unlock(globals.pickup_mutex); |
3546 | |
3547 | if (r) pickup_send_presence(key); |
3548 | |
3549 | switch_safe_free(dup_key)if (dup_key) {free(dup_key);dup_key=((void*)0);}; |
3550 | |
3551 | return r; |
3552 | } |
3553 | |
3554 | |
3555 | typedef struct pickup_pvt_s { |
3556 | char *key; |
3557 | switch_event_t *vars; |
3558 | } pickup_pvt_t; |
3559 | |
3560 | switch_endpoint_interface_t *pickup_endpoint_interface; |
3561 | static switch_call_cause_t pickup_outgoing_channel(switch_core_session_t *session, |
3562 | switch_event_t *var_event, |
3563 | switch_caller_profile_t *outbound_profile, |
3564 | switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, |
3565 | switch_call_cause_t *cancel_cause); |
3566 | switch_io_routines_t pickup_io_routines = { |
3567 | /*.outgoing_channel */ pickup_outgoing_channel |
3568 | }; |
3569 | |
3570 | static switch_status_t pickup_event_handler(switch_core_session_t *session) |
3571 | { |
3572 | switch_channel_t *channel = switch_core_session_get_channel(session); |
3573 | switch_channel_state_t state = switch_channel_get_running_state(channel); |
3574 | pickup_pvt_t *tech_pvt = switch_core_session_get_private(session)switch_core_session_get_private_class(session, SWITCH_PVT_PRIMARY ); |
3575 | char *uuid = NULL((void*)0); |
3576 | |
3577 | switch(state) { |
3578 | case CS_DESTROY: |
3579 | if (tech_pvt->vars) { |
3580 | switch_event_destroy(&tech_pvt->vars); |
3581 | } |
3582 | break; |
3583 | case CS_REPORTING: |
3584 | return SWITCH_STATUS_FALSE; |
3585 | case CS_HANGUP: |
3586 | { |
3587 | |
3588 | if (switch_channel_test_flag(channel, CF_CHANNEL_SWAP)) { |
3589 | const char *key = switch_channel_get_variable(channel, "channel_swap_uuid")switch_channel_get_variable_dup(channel, "channel_swap_uuid", SWITCH_TRUE, -1); |
3590 | switch_core_session_t *swap_session; |
3591 | |
3592 | if ((swap_session = switch_core_session_locate(key)switch_core_session_perform_locate(key, "mod_dptools.c", (const char *)__func__, 3592))) { |
3593 | switch_channel_t *swap_channel = switch_core_session_get_channel(swap_session); |
3594 | switch_channel_hangup(swap_channel, SWITCH_CAUSE_PICKED_OFF)switch_channel_perform_hangup(swap_channel, "mod_dptools.c", ( const char *)__func__, 3594, SWITCH_CAUSE_PICKED_OFF); |
3595 | switch_core_session_rwunlock(swap_session); |
3596 | } |
3597 | switch_channel_clear_flag(channel, CF_CHANNEL_SWAP); |
3598 | } |
3599 | |
3600 | uuid = pickup_pop_uuid(tech_pvt->key, switch_core_session_get_uuid(session)); |
3601 | switch_safe_free(uuid)if (uuid) {free(uuid);uuid=((void*)0);}; |
3602 | } |
3603 | break; |
3604 | default: |
3605 | break; |
3606 | } |
3607 | |
3608 | |
3609 | return SWITCH_STATUS_SUCCESS; |
3610 | } |
3611 | |
3612 | switch_state_handler_table_t pickup_event_handlers = { |
3613 | /*.on_init */ pickup_event_handler, |
3614 | /*.on_routing */ pickup_event_handler, |
3615 | /*.on_execute */ pickup_event_handler, |
3616 | /*.on_hangup */ pickup_event_handler, |
3617 | /*.on_exchange_media */ pickup_event_handler, |
3618 | /*.on_soft_execute */ pickup_event_handler, |
3619 | /*.on_consume_media */ pickup_event_handler, |
3620 | /*.on_hibernate */ pickup_event_handler, |
3621 | /*.on_reset */ pickup_event_handler, |
3622 | /*.on_park */ pickup_event_handler, |
3623 | /*.on_reporting */ pickup_event_handler, |
3624 | /*.on_destroy */ pickup_event_handler |
3625 | }; |
3626 | |
3627 | static switch_call_cause_t pickup_outgoing_channel(switch_core_session_t *session, |
3628 | switch_event_t *var_event, |
3629 | switch_caller_profile_t *outbound_profile, |
3630 | switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, |
3631 | switch_call_cause_t *cancel_cause) |
3632 | { |
3633 | char *pickup; |
3634 | switch_call_cause_t cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; |
3635 | switch_core_session_t *nsession; |
3636 | switch_channel_t *nchannel; |
3637 | char *name; |
3638 | pickup_pvt_t *tech_pvt; |
3639 | switch_caller_profile_t *caller_profile; |
3640 | |
3641 | if (zstr(outbound_profile->destination_number)_zstr(outbound_profile->destination_number)) { |
3642 | goto done; |
3643 | } |
3644 | |
3645 | pickup = outbound_profile->destination_number; |
3646 | |
3647 | flags |= SOF_NO_LIMITS; |
3648 | |
3649 | if (!(nsession = switch_core_session_request(pickup_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool)switch_core_session_request_uuid(pickup_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND , flags, pool, ((void*)0)))) { |
3650 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 3650, ((void*)0), SWITCH_LOG_CRIT, "Error Creating Session\n"); |
3651 | goto error; |
3652 | } |
3653 | |
3654 | tech_pvt = switch_core_session_alloc(nsession, sizeof(*tech_pvt))switch_core_perform_session_alloc(nsession, sizeof(*tech_pvt) , "mod_dptools.c", (const char *)__func__, 3654); |
3655 | tech_pvt->key = switch_core_session_strdup(nsession, pickup)switch_core_perform_session_strdup(nsession, pickup, "mod_dptools.c" , (const char *)__func__, 3655); |
3656 | |
3657 | |
3658 | switch_core_session_set_private(nsession, tech_pvt)switch_core_session_set_private_class(nsession, tech_pvt, SWITCH_PVT_PRIMARY ); |
3659 | |
3660 | nchannel = switch_core_session_get_channel(nsession); |
3661 | switch_channel_set_cap(nchannel, CC_PROXY_MEDIA)switch_channel_set_cap_value(nchannel, CC_PROXY_MEDIA, 1); |
3662 | switch_channel_set_cap(nchannel, CC_BYPASS_MEDIA)switch_channel_set_cap_value(nchannel, CC_BYPASS_MEDIA, 1); |
3663 | |
3664 | caller_profile = switch_caller_profile_clone(nsession, outbound_profile); |
3665 | switch_channel_set_caller_profile(nchannel, caller_profile); |
3666 | |
3667 | switch_channel_set_state(nchannel, CS_ROUTING)switch_channel_perform_set_state(nchannel, "mod_dptools.c", ( const char *)__func__, 3667, CS_ROUTING); |
3668 | |
3669 | |
3670 | |
3671 | *new_session = nsession; |
3672 | cause = SWITCH_CAUSE_SUCCESS; |
3673 | name = switch_core_session_sprintf(nsession, "pickup/%s", pickup); |
3674 | switch_channel_set_name(nchannel, name); |
3675 | switch_channel_set_variable(nchannel, "process_cdr", "false")switch_channel_set_variable_var_check(nchannel, "process_cdr" , "false", SWITCH_TRUE); |
3676 | switch_channel_set_variable(nchannel, "presence_id", NULL)switch_channel_set_variable_var_check(nchannel, "presence_id" , ((void*)0), SWITCH_TRUE); |
3677 | |
3678 | switch_event_del_header(var_event, "presence_id")switch_event_del_header_val(var_event, "presence_id", ((void* )0)); |
3679 | |
3680 | pickup_add_session(nsession, pickup); |
3681 | switch_channel_set_flag(nchannel, CF_PICKUP)switch_channel_set_flag_value(nchannel, CF_PICKUP, 1); |
3682 | switch_channel_set_flag(nchannel, CF_NO_PRESENCE)switch_channel_set_flag_value(nchannel, CF_NO_PRESENCE, 1); |
3683 | |
3684 | switch_event_dup(&tech_pvt->vars, var_event); |
3685 | |
3686 | goto done; |
3687 | |
3688 | error: |
3689 | |
3690 | if (nsession) { |
3691 | switch_core_session_destroy(&nsession)switch_core_session_perform_destroy(&nsession, "mod_dptools.c" , (const char *)__func__, 3691); |
3692 | } |
3693 | |
3694 | if (pool) { |
3695 | *pool = NULL((void*)0); |
3696 | } |
3697 | |
3698 | done: |
3699 | |
3700 | |
3701 | return cause; |
3702 | } |
3703 | |
3704 | #define PICKUP_SYNTAX"[<key>]" "[<key>]" |
3705 | SWITCH_STANDARD_APP(pickup_function)static void pickup_function (switch_core_session_t *session, const char *data) |
3706 | { |
3707 | char *uuid = NULL((void*)0); |
3708 | switch_core_session_t *pickup_session; |
3709 | switch_channel_t *channel = switch_core_session_get_channel(session); |
3710 | |
3711 | if (zstr(data)_zstr(data)) { |
3712 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 3712, ((void*)0), SWITCH_LOG_WARNING, "Missing data. Usage: pickup %s\n", PICKUP_SYNTAX"[<key>]"); |
3713 | return; |
3714 | } |
3715 | |
3716 | if ((uuid = pickup_pop_uuid((char *)data, NULL((void*)0)))) { |
3717 | if ((pickup_session = switch_core_session_locate(uuid)switch_core_session_perform_locate(uuid, "mod_dptools.c", (const char *)__func__, 3717))) { |
3718 | switch_channel_t *pickup_channel = switch_core_session_get_channel(pickup_session); |
3719 | switch_caller_profile_t *pickup_caller_profile = switch_channel_get_caller_profile(pickup_channel), |
3720 | *caller_profile = switch_channel_get_caller_profile(channel); |
3721 | const char *name, *num; |
3722 | switch_event_t *event; |
3723 | switch_event_header_t *hp; |
3724 | pickup_pvt_t *tech_pvt = switch_core_session_get_private(pickup_session)switch_core_session_get_private_class(pickup_session, SWITCH_PVT_PRIMARY ); |
3725 | |
3726 | for(hp = tech_pvt->vars->headers; hp; hp = hp->next) { |
3727 | switch_channel_set_variable(channel, hp->name, hp->value)switch_channel_set_variable_var_check(channel, hp->name, hp ->value, SWITCH_TRUE); |
3728 | } |
3729 | |
3730 | |
3731 | switch_channel_set_flag(pickup_channel, CF_CHANNEL_SWAP)switch_channel_set_flag_value(pickup_channel, CF_CHANNEL_SWAP , 1); |
3732 | switch_channel_set_variable(pickup_channel, "channel_swap_uuid", switch_core_session_get_uuid(session))switch_channel_set_variable_var_check(pickup_channel, "channel_swap_uuid" , switch_core_session_get_uuid(session), SWITCH_TRUE); |
3733 | |
3734 | name = caller_profile->caller_id_name; |
3735 | num = caller_profile->caller_id_number; |
3736 | |
3737 | caller_profile->caller_id_name = switch_core_strdup(caller_profile->pool, pickup_caller_profile->caller_id_name)switch_core_perform_strdup(caller_profile->pool, pickup_caller_profile ->caller_id_name, "mod_dptools.c", (const char *)__func__, 3737); |
3738 | caller_profile->caller_id_number = switch_core_strdup(caller_profile->pool, pickup_caller_profile->caller_id_number)switch_core_perform_strdup(caller_profile->pool, pickup_caller_profile ->caller_id_number, "mod_dptools.c", (const char *)__func__ , 3738); |
3739 | |
3740 | caller_profile->callee_id_name = name; |
3741 | caller_profile->callee_id_number = num; |
3742 | |
3743 | if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE)switch_event_create_subclass_detailed("mod_dptools.c", (const char * )(const char *)__func__, 3743, &event, SWITCH_EVENT_CALL_UPDATE , ((void*)0)) == SWITCH_STATUS_SUCCESS) { |
3744 | const char *uuid = switch_channel_get_partner_uuid(channel); |
3745 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "RECV"); |
3746 | |
3747 | if (uuid) { |
3748 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridged-To", uuid); |
3749 | } |
3750 | switch_channel_event_set_data(channel, event); |
3751 | switch_event_fire(&event)switch_event_fire_detailed("mod_dptools.c", (const char * )(const char *)__func__, 3751, &event, ((void*)0)); |
3752 | } |
3753 | |
3754 | |
3755 | switch_channel_set_state(channel, CS_HIBERNATE)switch_channel_perform_set_state(channel, "mod_dptools.c", (const char *)__func__, 3755, CS_HIBERNATE); |
3756 | |
3757 | switch_channel_mark_answered(pickup_channel)switch_channel_perform_mark_answered(pickup_channel, "mod_dptools.c" , (const char *)__func__, 3757); |
3758 | switch_core_session_rwunlock(pickup_session); |
3759 | } |
3760 | free(uuid); |
3761 | } |
3762 | } |
3763 | |
3764 | |
3765 | |
3766 | |
3767 | |
3768 | /* fake chan_error */ |
3769 | switch_endpoint_interface_t *error_endpoint_interface; |
3770 | static switch_call_cause_t error_outgoing_channel(switch_core_session_t *session, |
3771 | switch_event_t *var_event, |
3772 | switch_caller_profile_t *outbound_profile, |
3773 | switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, |
3774 | switch_call_cause_t *cancel_cause); |
3775 | switch_io_routines_t error_io_routines = { |
3776 | /*.outgoing_channel */ error_outgoing_channel |
3777 | }; |
3778 | |
3779 | static switch_call_cause_t error_outgoing_channel(switch_core_session_t *session, |
3780 | switch_event_t *var_event, |
3781 | switch_caller_profile_t *outbound_profile, |
3782 | switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, |
3783 | switch_call_cause_t *cancel_cause) |
3784 | { |
3785 | switch_call_cause_t cause = switch_channel_str2cause(outbound_profile->destination_number); |
3786 | if (cause == SWITCH_CAUSE_NONE) { |
3787 | cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; |
3788 | } |
3789 | |
3790 | return cause; |
3791 | } |
3792 | |
3793 | |
3794 | /* fake chan_group */ |
3795 | switch_endpoint_interface_t *group_endpoint_interface; |
3796 | static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session, |
3797 | switch_event_t *var_event, |
3798 | switch_caller_profile_t *outbound_profile, |
3799 | switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, |
3800 | switch_call_cause_t *cancel_cause); |
3801 | switch_io_routines_t group_io_routines = { |
3802 | /*.outgoing_channel */ group_outgoing_channel |
3803 | }; |
3804 | |
3805 | static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session, |
3806 | switch_event_t *var_event, |
3807 | switch_caller_profile_t *outbound_profile, |
3808 | switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, |
3809 | switch_call_cause_t *cancel_cause) |
3810 | { |
3811 | char *group = NULL((void*)0); |
3812 | switch_call_cause_t cause = SWITCH_CAUSE_NONE; |
3813 | char *template = NULL((void*)0), *dest = NULL((void*)0); |
3814 | switch_originate_flag_t myflags = SOF_NONE; |
3815 | char *cid_name_override = NULL((void*)0); |
3816 | char *cid_num_override = NULL((void*)0); |
3817 | char *domain = NULL((void*)0), *dup_domain = NULL((void*)0); |
3818 | switch_channel_t *new_channel = NULL((void*)0); |
3819 | unsigned int timelimit = 60; |
3820 | const char *skip, *var; |
3821 | |
3822 | group = strdup(outbound_profile->destination_number)(__extension__ (__builtin_constant_p (outbound_profile->destination_number ) && ((size_t)(const void *)((outbound_profile->destination_number ) + 1) - (size_t)(const void *)(outbound_profile->destination_number ) == 1) ? (((const char *) (outbound_profile->destination_number ))[0] == '\0' ? (char *) calloc ((size_t) 1, (size_t) 1) : ({ size_t __len = strlen (outbound_profile->destination_number ) + 1; char *__retval = (char *) malloc (__len); if (__retval != ((void*)0)) __retval = (char *) memcpy (__retval, outbound_profile ->destination_number, __len); __retval; })) : __strdup (outbound_profile ->destination_number))); |
3823 | |
3824 | if (!group) |
3825 | goto done; |
3826 | |
3827 | if ((domain = strchr(group, '@')(__extension__ (__builtin_constant_p ('@') && !__builtin_constant_p (group) && ('@') == '\0' ? (char *) __rawmemchr (group , '@') : __builtin_strchr (group, '@'))))) { |
3828 | *domain++ = '\0'; |
3829 | } else { |
3830 | domain = switch_core_get_domain(SWITCH_TRUE); |
3831 | dup_domain = domain; |
3832 | } |
3833 | |
3834 | if (!domain) { |
3835 | goto done; |
3836 | } |
3837 | |
3838 | if (var_event && (skip = switch_event_get_header(var_event, "group_recurse_variables")switch_event_get_header_idx(var_event, "group_recurse_variables" , -1)) && switch_false(skip)) { |
3839 | if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)switch_event_get_header_idx(var_event, "call_timeout", -1)) || (var = switch_event_get_header(var_event, "leg_timeout")switch_event_get_header_idx(var_event, "leg_timeout", -1))) { |
3840 | timelimit = atoi(var); |
3841 | } |
3842 | var_event = NULL((void*)0); |
3843 | } |
3844 | |
3845 | template = switch_mprintf("${group_call(%s@%s)}", group, domain); |
3846 | |
3847 | if (session) { |
3848 | switch_channel_t *channel = switch_core_session_get_channel(session); |
3849 | dest = switch_channel_expand_variables(channel, template)switch_channel_expand_variables_check(channel, template, ((void *)0), ((void*)0), 0); |
3850 | if ((var = switch_channel_get_variable(channel, SWITCH_CALL_TIMEOUT_VARIABLE)switch_channel_get_variable_dup(channel, "call_timeout", SWITCH_TRUE , -1)) || (var = switch_event_get_header(var_event, "leg_timeout")switch_event_get_header_idx(var_event, "leg_timeout", -1))) { |
3851 | timelimit = atoi(var); |
3852 | } |
3853 | } else if (var_event) { |
3854 | dest = switch_event_expand_headers(var_event, template)switch_event_expand_headers_check(var_event, template, ((void *)0), ((void*)0), 0); |
3855 | } else { |
3856 | switch_event_t *event = NULL((void*)0); |
3857 | switch_event_create(&event, SWITCH_EVENT_REQUEST_PARAMS)switch_event_create_subclass_detailed("mod_dptools.c", (const char * )(const char *)__func__, 3857, &event, SWITCH_EVENT_REQUEST_PARAMS , ((void*)0)); |
3858 | dest = switch_event_expand_headers(event, template)switch_event_expand_headers_check(event, template, ((void*)0) , ((void*)0), 0); |
3859 | switch_event_destroy(&event); |
3860 | } |
3861 | |
3862 | if (!dest) { |
3863 | goto done; |
3864 | } |
3865 | |
3866 | if (var_event) { |
3867 | cid_name_override = switch_event_get_header(var_event, "origination_caller_id_name")switch_event_get_header_idx(var_event, "origination_caller_id_name" , -1); |
3868 | cid_num_override = switch_event_get_header(var_event, "origination_caller_id_number")switch_event_get_header_idx(var_event, "origination_caller_id_number" , -1); |
3869 | if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)switch_event_get_header_idx(var_event, "call_timeout", -1)) || (var = switch_event_get_header(var_event, "leg_timeout")switch_event_get_header_idx(var_event, "leg_timeout", -1))) { |
3870 | timelimit = atoi(var); |
3871 | } |
3872 | } |
3873 | |
3874 | if ((flags & SOF_FORKED_DIAL)) { |
3875 | myflags |= SOF_NOBLOCK; |
3876 | } |
3877 | |
3878 | |
3879 | if (switch_ivr_originate(session, new_session, &cause, dest, timelimit, NULL((void*)0), |
3880 | cid_name_override, cid_num_override, NULL((void*)0), var_event, myflags, cancel_cause) == SWITCH_STATUS_SUCCESS) { |
3881 | const char *context; |
3882 | switch_caller_profile_t *cp; |
3883 | |
3884 | new_channel = switch_core_session_get_channel(*new_session); |
3885 | |
3886 | if ((context = switch_channel_get_variable(new_channel, "group_context")switch_channel_get_variable_dup(new_channel, "group_context", SWITCH_TRUE, -1))) { |
3887 | if ((cp = switch_channel_get_caller_profile(new_channel))) { |
3888 | cp->context = switch_core_strdup(cp->pool, context)switch_core_perform_strdup(cp->pool, context, "mod_dptools.c" , (const char *)__func__, 3888); |
3889 | } |
3890 | } |
3891 | switch_core_session_rwunlock(*new_session); |
3892 | } |
3893 | |
3894 | |
3895 | done: |
3896 | |
3897 | if (dest && dest != template) { |
3898 | switch_safe_free(dest)if (dest) {free(dest);dest=((void*)0);}; |
3899 | } |
3900 | |
3901 | switch_safe_free(template)if (template) {free(template);template=((void*)0);}; |
3902 | switch_safe_free(group)if (group) {free(group);group=((void*)0);}; |
3903 | switch_safe_free(dup_domain)if (dup_domain) {free(dup_domain);dup_domain=((void*)0);}; |
3904 | |
3905 | if (cause == SWITCH_CAUSE_NONE) { |
3906 | cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; |
3907 | } |
3908 | |
3909 | return cause; |
3910 | } |
3911 | |
3912 | |
3913 | |
3914 | /* fake chan_user */ |
3915 | switch_endpoint_interface_t *user_endpoint_interface; |
3916 | static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session, |
3917 | switch_event_t *var_event, |
3918 | switch_caller_profile_t *outbound_profile, |
3919 | switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, |
3920 | switch_call_cause_t *cancel_cause); |
3921 | switch_io_routines_t user_io_routines = { |
3922 | /*.outgoing_channel */ user_outgoing_channel |
3923 | }; |
3924 | |
3925 | static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session, |
3926 | switch_event_t *var_event, |
3927 | switch_caller_profile_t *outbound_profile, |
3928 | switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, |
3929 | switch_call_cause_t *cancel_cause) |
3930 | { |
3931 | switch_xml_t x_user = NULL((void*)0), x_param, x_params; |
3932 | char *user = NULL((void*)0), *domain = NULL((void*)0), *dup_domain = NULL((void*)0), *dialed_user = NULL((void*)0); |
3933 | const char *dest = NULL((void*)0); |
3934 | switch_call_cause_t cause = SWITCH_CAUSE_NONE; |
3935 | unsigned int timelimit = 60; |
3936 | switch_channel_t *new_channel = NULL((void*)0); |
3937 | switch_event_t *params = NULL((void*)0), *var_event_orig = var_event; |
3938 | char stupid[128] = ""; |
3939 | const char *skip = NULL((void*)0), *var = NULL((void*)0); |
3940 | |
3941 | if (zstr(outbound_profile->destination_number)_zstr(outbound_profile->destination_number)) { |
3942 | goto done; |
3943 | } |
3944 | |
3945 | user = strdup(outbound_profile->destination_number)(__extension__ (__builtin_constant_p (outbound_profile->destination_number ) && ((size_t)(const void *)((outbound_profile->destination_number ) + 1) - (size_t)(const void *)(outbound_profile->destination_number ) == 1) ? (((const char *) (outbound_profile->destination_number ))[0] == '\0' ? (char *) calloc ((size_t) 1, (size_t) 1) : ({ size_t __len = strlen (outbound_profile->destination_number ) + 1; char *__retval = (char *) malloc (__len); if (__retval != ((void*)0)) __retval = (char *) memcpy (__retval, outbound_profile ->destination_number, __len); __retval; })) : __strdup (outbound_profile ->destination_number))); |
3946 | |
3947 | if (!user) |
3948 | goto done; |
3949 | |
3950 | if ((domain = strchr(user, '@')(__extension__ (__builtin_constant_p ('@') && !__builtin_constant_p (user) && ('@') == '\0' ? (char *) __rawmemchr (user , '@') : __builtin_strchr (user, '@'))))) { |
3951 | *domain++ = '\0'; |
3952 | } else { |
3953 | domain = switch_core_get_domain(SWITCH_TRUE); |
3954 | dup_domain = domain; |
3955 | } |
3956 | |
3957 | if (!domain) { |
3958 | goto done; |
3959 | } |
3960 | |
3961 | |
3962 | switch_event_create(¶ms, SWITCH_EVENT_REQUEST_PARAMS)switch_event_create_subclass_detailed("mod_dptools.c", (const char * )(const char *)__func__, 3962, ¶ms, SWITCH_EVENT_REQUEST_PARAMS , ((void*)0)); |
3963 | switch_assert(params)((params) ? (void) (0) : __assert_fail ("params", "mod_dptools.c" , 3963, __PRETTY_FUNCTION__)); |
3964 | switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "as_channel", "true"); |
3965 | switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "action", "user_call"); |
3966 | |
3967 | if (var_event) { |
3968 | switch_event_merge(params, var_event); |
3969 | } |
3970 | |
3971 | if (var_event && (skip = switch_event_get_header(var_event, "user_recurse_variables")switch_event_get_header_idx(var_event, "user_recurse_variables" , -1)) && switch_false(skip)) { |
3972 | if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)switch_event_get_header_idx(var_event, "call_timeout", -1)) || (var = switch_event_get_header(var_event, "leg_timeout")switch_event_get_header_idx(var_event, "leg_timeout", -1))) { |
3973 | timelimit = atoi(var); |
3974 | } |
3975 | var_event = NULL((void*)0); |
3976 | } |
3977 | |
3978 | if (switch_xml_locate_user_merged("id", user, domain, NULL((void*)0), &x_user, params) != SWITCH_STATUS_SUCCESS) { |
3979 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 3979, (const char*)(session), SWITCH_LOG_WARNING, "Can't find user [%s@%s]\n", user, domain); |
3980 | cause = SWITCH_CAUSE_SUBSCRIBER_ABSENT; |
3981 | goto done; |
3982 | } |
3983 | |
3984 | if ((x_params = switch_xml_child(x_user, "params"))) { |
3985 | for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) { |
3986 | const char *pvar = switch_xml_attr_soft(x_param, "name"); |
3987 | const char *val = switch_xml_attr(x_param, "value"); |
3988 | |
3989 | if (!strcasecmp(pvar, "dial-string")) { |
3990 | dest = val; |
3991 | } else if (!strncasecmp(pvar, "dial-var-", 9)) { |
3992 | if (!var_event) { |
3993 | switch_event_create(&var_event, SWITCH_EVENT_GENERAL)switch_event_create_subclass_detailed("mod_dptools.c", (const char * )(const char *)__func__, 3993, &var_event, SWITCH_EVENT_GENERAL , ((void*)0)); |
3994 | } else { |
3995 | switch_event_del_header(var_event, pvar + 9)switch_event_del_header_val(var_event, pvar + 9, ((void*)0)); |
3996 | } |
3997 | switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, pvar + 9, val); |
3998 | } |
3999 | } |
4000 | } |
4001 | |
4002 | dialed_user = (char *)switch_xml_attr(x_user, "id"); |
4003 | |
4004 | if (var_event) { |
4005 | switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "dialed_user", dialed_user); |
4006 | switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "dialed_domain", domain); |
4007 | if (!zstr(dest)_zstr(dest) && !strstr(dest, "presence_id=")) { |
4008 | switch_event_add_header(var_event, SWITCH_STACK_BOTTOM, "presence_id", "%s@%s", dialed_user, domain); |
4009 | } |
4010 | } |
4011 | |
4012 | if (!dest) { |
4013 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 4013, (const char*)(session), SWITCH_LOG_ERROR, "No dial-string available, please check your user directory.\n"); |
4014 | cause = SWITCH_CAUSE_MANDATORY_IE_MISSING; |
4015 | } else { |
4016 | const char *varval; |
4017 | char *d_dest = NULL((void*)0); |
4018 | switch_channel_t *channel; |
4019 | switch_originate_flag_t myflags = SOF_NONE; |
4020 | char *cid_name_override = NULL((void*)0); |
4021 | char *cid_num_override = NULL((void*)0); |
4022 | |
4023 | if (var_event) { |
4024 | cid_name_override = switch_event_get_header(var_event, "origination_caller_id_name")switch_event_get_header_idx(var_event, "origination_caller_id_name" , -1); |
4025 | cid_num_override = switch_event_get_header(var_event, "origination_caller_id_number")switch_event_get_header_idx(var_event, "origination_caller_id_number" , -1); |
4026 | } |
4027 | |
4028 | if (session) { |
4029 | channel = switch_core_session_get_channel(session); |
4030 | if ((varval = switch_channel_get_variable(channel, SWITCH_CALL_TIMEOUT_VARIABLE)switch_channel_get_variable_dup(channel, "call_timeout", SWITCH_TRUE , -1)) |
4031 | || (var_event && (varval = switch_event_get_header(var_event, "leg_timeout")switch_event_get_header_idx(var_event, "leg_timeout", -1)))) { |
4032 | timelimit = atoi(varval); |
4033 | } |
4034 | |
4035 | switch_channel_set_variable(channel, "dialed_user", dialed_user)switch_channel_set_variable_var_check(channel, "dialed_user", dialed_user, SWITCH_TRUE); |
4036 | switch_channel_set_variable(channel, "dialed_domain", domain)switch_channel_set_variable_var_check(channel, "dialed_domain" , domain, SWITCH_TRUE); |
4037 | |
4038 | d_dest = switch_channel_expand_variables(channel, dest)switch_channel_expand_variables_check(channel, dest, ((void*) 0), ((void*)0), 0); |
4039 | |
4040 | } else { |
4041 | switch_event_t *event = NULL((void*)0); |
4042 | |
4043 | if (var_event) { |
4044 | switch_event_dup(&event, var_event); |
4045 | switch_event_del_header(event, "dialed_user")switch_event_del_header_val(event, "dialed_user", ((void*)0)); |
4046 | switch_event_del_header(event, "dialed_domain")switch_event_del_header_val(event, "dialed_domain", ((void*)0 )); |
4047 | if ((varval = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)switch_event_get_header_idx(var_event, "call_timeout", -1)) || |
4048 | (varval = switch_event_get_header(var_event, "leg_timeout")switch_event_get_header_idx(var_event, "leg_timeout", -1))) { |
4049 | timelimit = atoi(varval); |
4050 | } |
4051 | } else { |
4052 | switch_event_create(&event, SWITCH_EVENT_REQUEST_PARAMS)switch_event_create_subclass_detailed("mod_dptools.c", (const char * )(const char *)__func__, 4052, &event, SWITCH_EVENT_REQUEST_PARAMS , ((void*)0)); |
4053 | switch_assert(event)((event) ? (void) (0) : __assert_fail ("event", "mod_dptools.c" , 4053, __PRETTY_FUNCTION__)); |
4054 | } |
4055 | |
4056 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "dialed_user", dialed_user); |
4057 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "dialed_domain", domain); |
4058 | d_dest = switch_event_expand_headers(event, dest)switch_event_expand_headers_check(event, dest, ((void*)0), (( void*)0), 0); |
4059 | switch_event_destroy(&event); |
4060 | } |
4061 | |
4062 | if ((flags & SOF_NO_LIMITS)) { |
4063 | myflags |= SOF_NO_LIMITS; |
4064 | } |
4065 | |
4066 | if ((flags & SOF_FORKED_DIAL)) { |
4067 | myflags |= SOF_NOBLOCK; |
4068 | } |
4069 | |
4070 | |
4071 | switch_snprintf(stupid, sizeof(stupid), "user/%s", dialed_user); |
4072 | if (switch_stristr(stupid, d_dest)) { |
4073 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 4073, (const char*)(session), SWITCH_LOG_WARNING, "Waddya Daft? You almost called '%s' in an infinate loop!\n", |
4074 | stupid); |
4075 | cause = SWITCH_CAUSE_INVALID_IE_CONTENTS; |
4076 | } else if (switch_ivr_originate(session, new_session, &cause, d_dest, timelimit, NULL((void*)0), |
4077 | cid_name_override, cid_num_override, outbound_profile, var_event, myflags, |
4078 | cancel_cause) == SWITCH_STATUS_SUCCESS) { |
4079 | const char *context; |
4080 | switch_caller_profile_t *cp; |
4081 | |
4082 | if (var_event) { |
4083 | switch_event_del_header(var_event, "origination_uuid")switch_event_del_header_val(var_event, "origination_uuid", (( void*)0)); |
4084 | } |
4085 | |
4086 | |
4087 | new_channel = switch_core_session_get_channel(*new_session); |
4088 | |
4089 | if ((context = switch_channel_get_variable(new_channel, "user_context")switch_channel_get_variable_dup(new_channel, "user_context", SWITCH_TRUE , -1))) { |
4090 | if ((cp = switch_channel_get_caller_profile(new_channel))) { |
4091 | cp->context = switch_core_strdup(cp->pool, context)switch_core_perform_strdup(cp->pool, context, "mod_dptools.c" , (const char *)__func__, 4091); |
4092 | } |
4093 | } |
4094 | switch_core_session_rwunlock(*new_session); |
4095 | } |
4096 | |
4097 | if (d_dest != dest) { |
4098 | switch_safe_free(d_dest)if (d_dest) {free(d_dest);d_dest=((void*)0);}; |
4099 | } |
4100 | } |
4101 | |
4102 | if (new_channel && x_user) { |
4103 | if ((x_params = switch_xml_child(x_user, "variables"))) { |
4104 | for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) { |
4105 | const char *pvar = switch_xml_attr(x_param, "name"); |
4106 | const char *val = switch_xml_attr(x_param, "value"); |
4107 | switch_channel_set_variable(new_channel, pvar, val)switch_channel_set_variable_var_check(new_channel, pvar, val, SWITCH_TRUE); |
4108 | } |
4109 | } |
4110 | } |
4111 | |
4112 | done: |
4113 | |
4114 | if (x_user) { |
4115 | switch_xml_free(x_user); |
4116 | } |
4117 | |
4118 | if (params) { |
4119 | switch_event_destroy(¶ms); |
4120 | } |
4121 | |
4122 | if (var_event && var_event_orig != var_event) { |
4123 | switch_event_destroy(&var_event); |
4124 | } |
4125 | |
4126 | switch_safe_free(user)if (user) {free(user);user=((void*)0);}; |
4127 | switch_safe_free(dup_domain)if (dup_domain) {free(dup_domain);dup_domain=((void*)0);}; |
4128 | |
4129 | return cause; |
4130 | } |
4131 | |
4132 | #define HOLD_SYNTAX"[<display message>]" "[<display message>]" |
4133 | SWITCH_STANDARD_APP(hold_function)static void hold_function (switch_core_session_t *session, const char *data) |
4134 | { |
4135 | switch_ivr_hold_uuid(switch_core_session_get_uuid(session), data, 1); |
4136 | } |
4137 | |
4138 | #define UNHOLD_SYNTAX"" "" |
4139 | SWITCH_STANDARD_APP(unhold_function)static void unhold_function (switch_core_session_t *session, const char *data) |
4140 | { |
4141 | switch_ivr_unhold_uuid(switch_core_session_get_uuid(session)); |
4142 | } |
4143 | |
4144 | SWITCH_STANDARD_APP(novideo_function)static void novideo_function (switch_core_session_t *session, const char *data) |
4145 | { |
4146 | switch_channel_set_flag(switch_core_session_get_channel(session), CF_NOVIDEO)switch_channel_set_flag_value(switch_core_session_get_channel (session), CF_NOVIDEO, 1); |
4147 | } |
4148 | |
4149 | SWITCH_STANDARD_APP(verbose_events_function)static void verbose_events_function (switch_core_session_t *session , const char *data) |
4150 | { |
4151 | switch_channel_set_flag(switch_core_session_get_channel(session), CF_VERBOSE_EVENTS)switch_channel_set_flag_value(switch_core_session_get_channel (session), CF_VERBOSE_EVENTS, 1); |
4152 | } |
4153 | |
4154 | SWITCH_STANDARD_APP(cng_plc_function)static void cng_plc_function (switch_core_session_t *session, const char *data) |
4155 | { |
4156 | switch_channel_set_flag(switch_core_session_get_channel(session), CF_CNG_PLC)switch_channel_set_flag_value(switch_core_session_get_channel (session), CF_CNG_PLC, 1); |
4157 | } |
4158 | |
4159 | SWITCH_STANDARD_APP(early_hangup_function)static void early_hangup_function (switch_core_session_t *session , const char *data) |
4160 | { |
4161 | switch_channel_set_flag(switch_core_session_get_channel(session), CF_EARLY_HANGUP)switch_channel_set_flag_value(switch_core_session_get_channel (session), CF_EARLY_HANGUP, 1); |
4162 | } |
4163 | |
4164 | #define WAIT_FOR_SILENCE_SYNTAX"<silence_thresh> <silence_hits> <listen_hits> <timeout_ms> [<file>]" "<silence_thresh> <silence_hits> <listen_hits> <timeout_ms> [<file>]" |
4165 | SWITCH_STANDARD_APP(wait_for_silence_function)static void wait_for_silence_function (switch_core_session_t * session, const char *data) |
4166 | { |
4167 | char *argv[5] = { 0 }; |
4168 | uint32_t thresh, silence_hits, listen_hits, timeout_ms = 0; |
4169 | int argc; |
4170 | char *lbuf = NULL((void*)0); |
4171 | |
4172 | if (!zstr(data)_zstr(data) && (lbuf = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 4172)) |
4173 | && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 3) { |
4174 | thresh = atoi(argv[0]); |
4175 | silence_hits = atoi(argv[1]); |
4176 | listen_hits = atoi(argv[2]); |
4177 | |
4178 | if (argv[3]) { |
4179 | timeout_ms = switch_atoui(argv[3]); |
4180 | } |
4181 | |
4182 | if (thresh > 0 && silence_hits > 0 && listen_hits > 0) { |
4183 | switch_ivr_wait_for_silence(session, thresh, silence_hits, listen_hits, timeout_ms, argv[4]); |
4184 | return; |
4185 | } |
4186 | |
4187 | } |
4188 | |
4189 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 4189, (const char*)(session), SWITCH_LOG_ERROR, "Usage: %s\n", WAIT_FOR_SILENCE_SYNTAX"<silence_thresh> <silence_hits> <listen_hits> <timeout_ms> [<file>]"); |
4190 | } |
4191 | |
4192 | static switch_status_t event_chat_send(switch_event_t *message_event) |
4193 | |
4194 | { |
4195 | switch_event_t *event; |
4196 | const char *to; |
4197 | |
4198 | switch_event_dup(&event, message_event); |
4199 | event->event_id = SWITCH_EVENT_RECV_MESSAGE; |
4200 | |
4201 | if ((to = switch_event_get_header(event, "to")switch_event_get_header_idx(event, "to", -1))) { |
4202 | char *v; |
4203 | if ((v = switch_core_get_variable_dup(to))) { |
4204 | switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Command", v); |
4205 | free(v); |
4206 | } |
4207 | } |
4208 | |
4209 | if (switch_event_fire(&event)switch_event_fire_detailed("mod_dptools.c", (const char * )(const char *)__func__, 4209, &event, ((void*)0)) == SWITCH_STATUS_SUCCESS) { |
4210 | return SWITCH_STATUS_SUCCESS; |
4211 | } |
4212 | |
4213 | switch_event_destroy(&event); |
4214 | |
4215 | return SWITCH_STATUS_MEMERR; |
4216 | } |
4217 | |
4218 | static switch_status_t api_chat_send(switch_event_t *message_event) |
4219 | { |
4220 | const char *proto; |
4221 | const char *from; |
4222 | const char *to; |
4223 | //const char *subject; |
4224 | //const char *body; |
4225 | const char *type; |
4226 | const char *hint; |
4227 | |
4228 | proto = switch_event_get_header(message_event, "proto")switch_event_get_header_idx(message_event, "proto", -1); |
4229 | from = switch_event_get_header(message_event, "from")switch_event_get_header_idx(message_event, "from", -1); |
4230 | to = switch_event_get_header(message_event, "to")switch_event_get_header_idx(message_event, "to", -1); |
4231 | //subject = switch_event_get_header(message_event, "subject"); |
4232 | //body = switch_event_get_body(message_event); |
4233 | type = switch_event_get_header(message_event, "type")switch_event_get_header_idx(message_event, "type", -1); |
4234 | hint = switch_event_get_header(message_event, "hint")switch_event_get_header_idx(message_event, "hint", -1); |
4235 | |
4236 | |
4237 | if (to) { |
4238 | char *v = NULL((void*)0); |
4239 | switch_stream_handle_t stream = { 0 }; |
4240 | char *cmd = NULL((void*)0), *arg; |
4241 | |
4242 | if (!(v = switch_core_get_variable_dup(to))) { |
4243 | v = strdup(to)(__extension__ (__builtin_constant_p (to) && ((size_t )(const void *)((to) + 1) - (size_t)(const void *)(to) == 1) ? (((const char *) (to))[0] == '\0' ? (char *) calloc ((size_t ) 1, (size_t) 1) : ({ size_t __len = strlen (to) + 1; char *__retval = (char *) malloc (__len); if (__retval != ((void*)0)) __retval = (char *) memcpy (__retval, to, __len); __retval; })) : __strdup (to))); |
4244 | } |
4245 | |
4246 | cmd = v; |
4247 | switch_assert(cmd)((cmd) ? (void) (0) : __assert_fail ("cmd", "mod_dptools.c", 4247 , __PRETTY_FUNCTION__)); |
4248 | |
4249 | switch_url_decode(cmd); |
4250 | |
4251 | if ((arg = strchr(cmd, ' ')(__extension__ (__builtin_constant_p (' ') && !__builtin_constant_p (cmd) && (' ') == '\0' ? (char *) __rawmemchr (cmd, ' ' ) : __builtin_strchr (cmd, ' '))))) { |
4252 | *arg++ = '\0'; |
4253 | } |
4254 | |
4255 | SWITCH_STANDARD_STREAM(stream)memset(&stream, 0, sizeof(stream)); stream.data = malloc( 1024); ((stream.data) ? (void) (0) : __assert_fail ("stream.data" , "mod_dptools.c", 4255, __PRETTY_FUNCTION__)); memset(stream .data, 0, 1024); stream.end = stream.data; stream.data_size = 1024; stream.write_function = switch_console_stream_write; stream .raw_write_function = switch_console_stream_raw_write; stream .alloc_len = 1024; stream.alloc_chunk = 1024; |
4256 | switch_api_execute(cmd, arg, NULL((void*)0), &stream); |
4257 | |
4258 | if (proto) { |
4259 | switch_core_chat_send_args(proto, "api", to, hint && strchr(hint, '/')(__extension__ (__builtin_constant_p ('/') && !__builtin_constant_p (hint) && ('/') == '\0' ? (char *) __rawmemchr (hint , '/') : __builtin_strchr (hint, '/'))) ? hint : from, !zstr(type)_zstr(type) ? type : NULL((void*)0), (char *) stream.data, NULL((void*)0), NULL((void*)0), SWITCH_TRUE); |
4260 | } |
4261 | |
4262 | switch_safe_free(stream.data)if (stream.data) {free(stream.data);stream.data=((void*)0);}; |
4263 | |
4264 | free(cmd); |
4265 | |
4266 | } |
4267 | |
4268 | return SWITCH_STATUS_SUCCESS; |
4269 | } |
4270 | |
4271 | |
4272 | #define SESSION_LOGLEVEL_SYNTAX"<level>" "<level>" |
4273 | SWITCH_STANDARD_APP(session_loglevel_function)static void session_loglevel_function (switch_core_session_t * session, const char *data) |
4274 | { |
4275 | if (!zstr(data)_zstr(data)) { |
4276 | switch_log_level_t level = switch_log_str2level(data); |
4277 | |
4278 | if (level == SWITCH_LOG_INVALID) { |
4279 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 4279, (const char*)(session), SWITCH_LOG_ERROR, "Invalid log level: %s\n", data); |
4280 | } else { |
4281 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 4281, (const char*)(session), SWITCH_LOG_DEBUG, "Setting log level \"%s\" on session\n", switch_log_level2str(level)); |
4282 | switch_core_session_set_loglevel(session, level); |
4283 | } |
4284 | } else { |
4285 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 4285, (const char*)(session), SWITCH_LOG_ERROR, "No log level specified\n"); |
4286 | } |
4287 | } |
4288 | |
4289 | /* LIMIT STUFF */ |
4290 | #define LIMIT_USAGE"<backend> <realm> <id> [<max>[/interval]] [number [dialplan [context]]]" "<backend> <realm> <id> [<max>[/interval]] [number [dialplan [context]]]" |
4291 | #define LIMIT_DESC"limit access to a resource and transfer to an extension if the limit is exceeded" "limit access to a resource and transfer to an extension if the limit is exceeded" |
4292 | SWITCH_STANDARD_APP(limit_function)static void limit_function (switch_core_session_t *session, const char *data) |
4293 | { |
4294 | int argc = 0; |
4295 | char *argv[7] = { 0 }; |
4296 | char *mydata = NULL((void*)0); |
4297 | char *backend = NULL((void*)0); |
4298 | char *realm = NULL((void*)0); |
4299 | char *id = NULL((void*)0); |
4300 | char *xfer_exten = NULL((void*)0); |
4301 | int max = -1; |
4302 | int interval = 0; |
4303 | switch_channel_t *channel = switch_core_session_get_channel(session); |
4304 | |
4305 | /* Parse application data */ |
4306 | if (!zstr(data)_zstr(data)) { |
4307 | mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 4307); |
4308 | argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); |
4309 | } |
4310 | |
4311 | backend = argv[0]; |
4312 | |
4313 | /* must have at least one item */ |
4314 | if (argc < 1) { |
4315 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 4315, (const char*)(session), SWITCH_LOG_ERROR, "USAGE: limit %s\n", LIMIT_USAGE"<backend> <realm> <id> [<max>[/interval]] [number [dialplan [context]]]"); |
4316 | return; |
4317 | } |
4318 | |
4319 | /* if this is an invalid backend, fallback to db backend */ |
4320 | /* TODO: remove this when we can! */ |
4321 | if (switch_true(switch_channel_get_variable(channel, "switch_limit_backwards_compat_flag")switch_channel_get_variable_dup(channel, "switch_limit_backwards_compat_flag" , SWITCH_TRUE, -1)) && |
4322 | !switch_loadable_module_get_limit_interface(backend)) { |
4323 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 4323, ((void*)0), SWITCH_LOG_WARNING, "Unknown backend '%s'. To maintain backwards compatability, falling back on db backend and shifting argumens. Either update your diaplan to include the backend, fix the typo, or load the appropriate limit implementation module.\n", backend); |
4324 | mydata = switch_core_session_sprintf(session, "db %s", data); |
4325 | argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); |
4326 | backend = argv[0]; |
4327 | } |
4328 | |
4329 | if (argc < 3) { |
4330 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 4330, (const char*)(session), SWITCH_LOG_ERROR, "USAGE: limit %s\n", LIMIT_USAGE"<backend> <realm> <id> [<max>[/interval]] [number [dialplan [context]]]"); |
4331 | return; |
4332 | } |
4333 | |
4334 | realm = argv[1]; |
4335 | id = argv[2]; |
4336 | |
4337 | /* If max is omitted or negative, only act as a counter and skip maximum checks */ |
4338 | if (argc > 3) { |
4339 | if (argv[3][0] == '-') { |
4340 | max = -1; |
4341 | } else { |
4342 | char *szinterval = NULL((void*)0); |
4343 | if ((szinterval = strchr(argv[3], '/')(__extension__ (__builtin_constant_p ('/') && !__builtin_constant_p (argv[3]) && ('/') == '\0' ? (char *) __rawmemchr (argv [3], '/') : __builtin_strchr (argv[3], '/'))))) { |
4344 | *szinterval++ = '\0'; |
4345 | interval = atoi(szinterval); |
4346 | } |
4347 | |
4348 | max = atoi(argv[3]); |
4349 | |
4350 | if (max < 0) { |
4351 | max = 0; |
4352 | } |
4353 | } |
4354 | } |
4355 | |
4356 | if (argc > 4) { |
4357 | xfer_exten = argv[4]; |
4358 | } else { |
4359 | xfer_exten = LIMIT_DEF_XFER_EXTEN"limit_exceeded"; |
4360 | } |
4361 | |
4362 | if (switch_limit_incr(backend, session, realm, id, max, interval) != SWITCH_STATUS_SUCCESS) { |
4363 | /* Limit exceeded */ |
4364 | if (*xfer_exten == '!') { |
4365 | switch_channel_hangup(channel, switch_channel_str2cause(xfer_exten + 1))switch_channel_perform_hangup(channel, "mod_dptools.c", (const char *)__func__, 4365, switch_channel_str2cause(xfer_exten + 1)); |
4366 | } else { |
4367 | switch_ivr_session_transfer(session, xfer_exten, argv[5], argv[6]); |
4368 | } |
4369 | } |
4370 | } |
4371 | |
4372 | #define LIMIT_HASH_USAGE"<realm> <id> [<max>[/interval]] [number [dialplan [context]]]" "<realm> <id> [<max>[/interval]] [number [dialplan [context]]]" |
4373 | #define LIMIT_HASH_DESC"DEPRECATED: limit access to a resource and transfer to an extension if the limit is exceeded" "DEPRECATED: limit access to a resource and transfer to an extension if the limit is exceeded" |
4374 | SWITCH_STANDARD_APP(limit_hash_function)static void limit_hash_function (switch_core_session_t *session , const char *data) |
4375 | { |
4376 | char *mydata = NULL((void*)0); |
4377 | switch_channel_t *channel = switch_core_session_get_channel(session); |
4378 | |
4379 | if (switch_true(switch_channel_get_variable(channel, "switch_limit_backwards_compat_flag")switch_channel_get_variable_dup(channel, "switch_limit_backwards_compat_flag" , SWITCH_TRUE, -1))) { |
4380 | mydata = switch_core_session_sprintf(session, "hash %s", data); |
4381 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 4381, ((void*)0), SWITCH_LOG_WARNING, "Using deprecated 'limit_hash' api: Please use 'limit hash'.\n"); |
4382 | limit_function(session, mydata); |
4383 | } else { |
4384 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 4384, ((void*)0), SWITCH_LOG_ERROR, "'limit_hash' (deprecated) is only available after loading mod_limit.\n"); |
4385 | } |
4386 | } |
4387 | |
4388 | #define LIMITEXECUTE_USAGE"<backend> <realm> <id> <max>[/interval] <application> [application arguments]" "<backend> <realm> <id> <max>[/interval] <application> [application arguments]" |
4389 | #define LIMITEXECUTE_DESC"limit access to a resource. the specified application will only be executed if the resource is available" "limit access to a resource. the specified application will only be executed if the resource is available" |
4390 | SWITCH_STANDARD_APP(limit_execute_function)static void limit_execute_function (switch_core_session_t *session , const char *data) |
4391 | { |
4392 | int argc = 0; |
4393 | char *argv[6] = { 0 }; |
4394 | char *mydata = NULL((void*)0); |
4395 | char *backend = NULL((void*)0); |
4396 | char *realm = NULL((void*)0); |
4397 | char *id = NULL((void*)0); |
4398 | char *app = NULL((void*)0); |
4399 | char *app_arg = NULL((void*)0); |
4400 | int max = -1; |
4401 | int interval = 0; |
4402 | switch_channel_t *channel = switch_core_session_get_channel(session); |
4403 | |
4404 | /* Parse application data */ |
4405 | if (!zstr(data)_zstr(data)) { |
4406 | mydata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_dptools.c" , (const char *)__func__, 4406); |
4407 | argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); |
4408 | } |
4409 | |
4410 | /* backwards compat version, if we have 5, just prepend with db and reparse */ |
4411 | if (switch_true(switch_channel_get_variable(channel, "switch_limit_backwards_compat_flag")switch_channel_get_variable_dup(channel, "switch_limit_backwards_compat_flag" , SWITCH_TRUE, -1)) && |
4412 | argc == 5) { |
4413 | mydata = switch_core_session_sprintf(session, "db %s", data); |
4414 | argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); |
4415 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 4415, ((void*)0), SWITCH_LOG_WARNING, "Using deprecated limit api: Please specify backend. Defaulting to 'db' backend.\n"); |
4416 | } |
4417 | |
4418 | if (argc < 6) { |
4419 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 4419, (const char*)(session), SWITCH_LOG_ERROR, "USAGE: limit_execute %s\n", LIMITEXECUTE_USAGE"<backend> <realm> <id> <max>[/interval] <application> [application arguments]"); |
4420 | return; |
4421 | } |
4422 | |
4423 | backend = argv[0]; |
4424 | realm = argv[1]; |
4425 | id = argv[2]; |
4426 | |
4427 | /* Accept '-' as unlimited (act as counter) */ |
4428 | if (argv[3][0] == '-') { |
4429 | max = -1; |
4430 | } else { |
4431 | char *szinterval = NULL((void*)0); |
4432 | |
4433 | if ((szinterval = strchr(argv[3], '/')(__extension__ (__builtin_constant_p ('/') && !__builtin_constant_p (argv[3]) && ('/') == '\0' ? (char *) __rawmemchr (argv [3], '/') : __builtin_strchr (argv[3], '/'))))) { |
4434 | *szinterval++ = '\0'; |
4435 | interval = atoi(szinterval); |
4436 | } |
4437 | |
4438 | max = atoi(argv[3]); |
4439 | |
4440 | if (max < 0) { |
4441 | max = 0; |
4442 | } |
4443 | } |
4444 | |
4445 | app = argv[4]; |
4446 | app_arg = argv[5]; |
4447 | |
4448 | if (zstr(app)_zstr(app)) { |
4449 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 4449, (const char*)(session), SWITCH_LOG_ERROR, "Missing application\n"); |
4450 | return; |
4451 | } |
4452 | |
4453 | if (switch_limit_incr(backend, session, realm, id, max, interval) == SWITCH_STATUS_SUCCESS) { |
4454 | switch_core_session_execute_application(session, app, app_arg)switch_core_session_execute_application_get_flags(session, app , app_arg, ((void*)0)); |
4455 | /* Only release the resource if we are still in CS_EXECUTE */ |
4456 | if (switch_channel_get_state(switch_core_session_get_channel(session)) == CS_EXECUTE) { |
4457 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 4457, (const char*)(session), SWITCH_LOG_INFO, "immediately releasing\n"); |
4458 | switch_limit_release(backend, session, realm, id); |
4459 | } |
4460 | } |
4461 | } |
4462 | |
4463 | #define LIMITHASHEXECUTE_USAGE"<realm> <id> <max>[/interval] <application> [application arguments]" "<realm> <id> <max>[/interval] <application> [application arguments]" |
4464 | #define LIMITHASHEXECUTE_DESC"DEPRECATED: limit access to a resource. the specified application will only be executed if the resource is available" "DEPRECATED: limit access to a resource. the specified application will only be executed if the resource is available" |
4465 | SWITCH_STANDARD_APP(limit_hash_execute_function)static void limit_hash_execute_function (switch_core_session_t *session, const char *data) |
4466 | { |
4467 | char *mydata = NULL((void*)0); |
4468 | switch_channel_t *channel = switch_core_session_get_channel(session); |
4469 | |
4470 | if (switch_true(switch_channel_get_variable(channel, "switch_limit_backwards_compat_flag")switch_channel_get_variable_dup(channel, "switch_limit_backwards_compat_flag" , SWITCH_TRUE, -1))) { |
4471 | mydata = switch_core_session_sprintf(session, "hash %s", data); |
4472 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 4472, ((void*)0), SWITCH_LOG_WARNING, "Using deprecated 'limit_hash_execute' api: Please use 'limit_execute hash'.\n"); |
4473 | limit_execute_function(session, mydata); |
4474 | } else { |
4475 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 4475, ((void*)0), SWITCH_LOG_ERROR, "'limit_hash_execute' (deprecated) is only available after loading mod_limit.\n"); |
4476 | } |
4477 | } |
4478 | |
4479 | |
4480 | |
4481 | /* FILE STRING INTERFACE */ |
4482 | |
4483 | /* for apr_pstrcat */ |
4484 | #define DEFAULT_PREBUFFER_SIZE1024 * 64 1024 * 64 |
4485 | |
4486 | struct file_string_audio_col { |
4487 | switch_audio_col_t col; |
4488 | char *value; |
4489 | struct file_string_audio_col *next; |
4490 | }; |
4491 | |
4492 | typedef struct file_string_audio_col file_string_audio_col_t; |
4493 | |
4494 | struct file_string_context { |
4495 | char *file; |
4496 | char *argv[128]; |
4497 | int argc; |
4498 | int index; |
4499 | int samples; |
4500 | switch_file_handle_t fh; |
4501 | file_string_audio_col_t *audio_cols; |
4502 | }; |
4503 | |
4504 | typedef struct file_string_context file_string_context_t; |
4505 | |
4506 | static switch_status_t next_file(switch_file_handle_t *handle) |
4507 | { |
4508 | file_string_context_t *context = handle->private_info; |
4509 | char *file; |
4510 | const char *prefix = handle->prefix; |
4511 | switch_status_t status = SWITCH_STATUS_SUCCESS; |
4512 | |
4513 | top: |
4514 | |
4515 | context->index++; |
4516 | |
4517 | if (switch_test_flag((&context->fh), SWITCH_FILE_OPEN)(((&context->fh))->flags & SWITCH_FILE_OPEN)) { |
4518 | switch_core_file_close(&context->fh); |
4519 | } |
4520 | |
4521 | if (context->index >= context->argc) { |
4522 | return SWITCH_STATUS_FALSE; |
4523 | } |
4524 | |
4525 | |
4526 | if (!prefix) { |
4527 | if (!(prefix = switch_core_get_variable_pdup("sound_prefix", handle->memory_pool))) { |
4528 | prefix = SWITCH_GLOBAL_dirs.sounds_dir; |
4529 | } |
4530 | } |
4531 | |
4532 | if (!prefix || switch_is_file_path(context->argv[context->index])) { |
4533 | file = context->argv[context->index]; |
4534 | } else { |
4535 | file = switch_core_sprintf(handle->memory_pool, "%s%s%s", prefix, SWITCH_PATH_SEPARATOR"/", context->argv[context->index]); |
4536 | } |
4537 | |
4538 | if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)((handle)->flags & SWITCH_FILE_FLAG_WRITE)) { |
4539 | char *path = switch_core_strdup(handle->memory_pool, file)switch_core_perform_strdup(handle->memory_pool, file, "mod_dptools.c" , (const char *)__func__, 4539); |
4540 | char *p; |
4541 | |
4542 | if ((p = strrchr(path, *SWITCH_PATH_SEPARATOR"/"))) { |
4543 | *p = '\0'; |
4544 | if (switch_dir_make_recursive(path, SWITCH_DEFAULT_DIR_PERMS0x0400 | 0x0200 | 0x0100 | 0x0040 | 0x0010, handle->memory_pool) != SWITCH_STATUS_SUCCESS) { |
4545 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 4545, ((void*)0), SWITCH_LOG_ERROR, "Error creating %s\n", path); |
4546 | return SWITCH_STATUS_FALSE; |
4547 | } |
4548 | |
4549 | } else { |
4550 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 4550, ((void*)0), SWITCH_LOG_ERROR, "Error finding the folder path section in '%s'\n", path); |
4551 | } |
4552 | } |
4553 | |
4554 | if (switch_core_file_open(&context->fh, file, handle->channels, handle->samplerate, handle->flags, NULL)switch_core_perform_file_open("mod_dptools.c", (const char *) __func__, 4554, &context->fh, file, handle->channels , handle->samplerate, handle->flags, ((void*)0)) != SWITCH_STATUS_SUCCESS) { |
4555 | |
4556 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 4556, ((void*)0), SWITCH_LOG_ERROR, "Can't open file %s\n", file); |
4557 | if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)((handle)->flags & SWITCH_FILE_FLAG_WRITE)) { |
4558 | switch_file_remove(file, handle->memory_pool); |
4559 | } |
4560 | goto top; |
4561 | } |
4562 | |
4563 | if (handle->dbuflen) { |
4564 | free(handle->dbuf); |
4565 | handle->dbuflen = 0; |
4566 | handle->dbuf = NULL((void*)0); |
4567 | } |
4568 | |
4569 | if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)((handle)->flags & SWITCH_FILE_FLAG_WRITE)) { |
4570 | file_string_audio_col_t *col_ptr = context->audio_cols; |
4571 | |
4572 | while (col_ptr) { |
4573 | switch_core_file_set_string(&context->fh, col_ptr->col, col_ptr->value); |
4574 | col_ptr = col_ptr->next; |
4575 | } |
4576 | |
4577 | if (context->file && switch_test_flag(handle, SWITCH_FILE_DATA_SHORT)((handle)->flags & SWITCH_FILE_DATA_SHORT)) { /* TODO handle other data type flags */ |
4578 | switch_size_t len; |
4579 | uint16_t buf[SWITCH_RECOMMENDED_BUFFER_SIZE8192] = { 0 }; |
4580 | switch_status_t status; |
4581 | switch_file_handle_t fh = { 0 }; |
4582 | |
4583 | if ((status = switch_core_file_open(&fh, context->file, handle->channels, handle->samplerate,switch_core_perform_file_open("mod_dptools.c", (const char *) __func__, 4584, &fh, context->file, handle->channels , handle->samplerate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT , ((void*)0)) |
4584 | SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL)switch_core_perform_file_open("mod_dptools.c", (const char *) __func__, 4584, &fh, context->file, handle->channels , handle->samplerate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT , ((void*)0))) == SWITCH_STATUS_SUCCESS) { |
4585 | do { |
4586 | len = SWITCH_RECOMMENDED_BUFFER_SIZE8192 / handle->channels; |
4587 | if ((status = switch_core_file_read(&fh, buf, &len)) == SWITCH_STATUS_SUCCESS) { |
4588 | status = switch_core_file_write(&context->fh, buf, &len); |
4589 | } |
4590 | } while (status == SWITCH_STATUS_SUCCESS); |
4591 | |
4592 | switch_core_file_close(&fh); |
4593 | switch_file_remove(context->file, handle->memory_pool); |
4594 | |
4595 | } else { |
4596 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 4596, ((void*)0), SWITCH_LOG_ERROR, "Can't open %s\n", context->file); |
4597 | } |
4598 | } |
4599 | } |
4600 | context->file = file; |
4601 | |
4602 | handle->samples = context->fh.samples; |
4603 | handle->cur_samplerate = context->fh.samplerate; |
4604 | handle->cur_channels = context->fh.real_channels; |
4605 | handle->format = context->fh.format; |
4606 | handle->sections = context->fh.sections; |
4607 | handle->seekable = context->fh.seekable; |
4608 | handle->speed = context->fh.speed; |
4609 | handle->interval = context->fh.interval; |
4610 | handle->max_samples = 0; |
4611 | |
4612 | |
4613 | if (switch_test_flag((&context->fh), SWITCH_FILE_NATIVE)(((&context->fh))->flags & SWITCH_FILE_NATIVE)) { |
4614 | switch_set_flag(handle, SWITCH_FILE_NATIVE)(handle)->flags |= (SWITCH_FILE_NATIVE); |
4615 | } else { |
4616 | switch_clear_flag(handle, SWITCH_FILE_NATIVE)(handle)->flags &= ~(SWITCH_FILE_NATIVE); |
4617 | } |
4618 | |
4619 | |
4620 | if (!switch_test_flag(handle, SWITCH_FILE_NATIVE)((handle)->flags & SWITCH_FILE_NATIVE)) { |
4621 | if (context->index == 0) { |
4622 | context->samples = (handle->samplerate / 1000) * 250; |
4623 | } |
4624 | } |
4625 | |
4626 | return status; |
4627 | } |
4628 | |
4629 | |
4630 | static switch_status_t file_string_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence) |
4631 | { |
4632 | file_string_context_t *context = handle->private_info; |
4633 | |
4634 | if (samples == 0 && whence == SEEK_SET0) { |
4635 | context->index = -1; |
4636 | return SWITCH_STATUS_SUCCESS; |
4637 | } |
4638 | |
4639 | if (!handle->seekable) { |
4640 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 4640, ((void*)0), SWITCH_LOG_WARNING, "File is not seekable\n"); |
4641 | return SWITCH_STATUS_NOTIMPL; |
4642 | } |
4643 | |
4644 | return switch_core_file_seek(&context->fh, cur_sample, samples, whence); |
4645 | } |
4646 | |
4647 | static switch_status_t file_string_file_open(switch_file_handle_t *handle, const char *path) |
4648 | { |
4649 | file_string_context_t *context; |
4650 | char *file_dup; |
4651 | |
4652 | context = switch_core_alloc(handle->memory_pool, sizeof(*context))switch_core_perform_alloc(handle->memory_pool, sizeof(*context ), "mod_dptools.c", (const char *)__func__, 4652); |
4653 | |
4654 | file_dup = switch_core_strdup(handle->memory_pool, path)switch_core_perform_strdup(handle->memory_pool, path, "mod_dptools.c" , (const char *)__func__, 4654); |
4655 | context->argc = switch_separate_string(file_dup, '!', context->argv, (sizeof(context->argv) / sizeof(context->argv[0]))); |
4656 | context->index = -1; |
4657 | |
4658 | handle->private_info = context; |
4659 | handle->pre_buffer_datalen = 0; |
4660 | |
4661 | return next_file(handle); |
4662 | } |
4663 | |
4664 | static switch_status_t file_string_file_close(switch_file_handle_t *handle) |
4665 | { |
4666 | file_string_context_t *context = handle->private_info; |
4667 | |
4668 | if (switch_test_flag((&context->fh), SWITCH_FILE_OPEN)(((&context->fh))->flags & SWITCH_FILE_OPEN)) { |
4669 | switch_core_file_close(&context->fh); |
4670 | } |
4671 | |
4672 | return SWITCH_STATUS_SUCCESS; |
4673 | } |
4674 | |
4675 | static switch_status_t file_string_file_set_string(switch_file_handle_t *handle, switch_audio_col_t col, const char *string) |
4676 | { |
4677 | file_string_context_t *context = handle->private_info; |
4678 | file_string_audio_col_t *col_ptr = context->audio_cols; |
4679 | |
4680 | while (col_ptr && col != col_ptr->col) { |
4681 | col_ptr = col_ptr->next; |
4682 | } |
4683 | |
4684 | if (col_ptr) { |
4685 | col_ptr->value = switch_core_strdup(handle->memory_pool, string)switch_core_perform_strdup(handle->memory_pool, string, "mod_dptools.c" , (const char *)__func__, 4685); |
4686 | } else { |
4687 | col_ptr = switch_core_alloc(handle->memory_pool, sizeof(*col_ptr))switch_core_perform_alloc(handle->memory_pool, sizeof(*col_ptr ), "mod_dptools.c", (const char *)__func__, 4687); |
4688 | col_ptr->value = switch_core_strdup(handle->memory_pool, string)switch_core_perform_strdup(handle->memory_pool, string, "mod_dptools.c" , (const char *)__func__, 4688); |
4689 | col_ptr->col = col; |
4690 | col_ptr->next = context->audio_cols; |
4691 | context->audio_cols = col_ptr; |
4692 | } |
4693 | |
4694 | return switch_core_file_set_string(&context->fh, col, string); |
4695 | } |
4696 | |
4697 | static switch_status_t file_string_file_get_string(switch_file_handle_t *handle, switch_audio_col_t col, const char **string) |
4698 | { |
4699 | file_string_context_t *context = handle->private_info; |
4700 | |
4701 | return switch_core_file_get_string(&context->fh, col, string); |
4702 | } |
4703 | |
4704 | |
4705 | static switch_status_t file_string_file_read(switch_file_handle_t *handle, void *data, size_t *len) |
4706 | { |
4707 | file_string_context_t *context = handle->private_info; |
4708 | switch_status_t status; |
4709 | size_t llen = *len; |
4710 | |
4711 | if (context->samples > 0) { |
4712 | if (*len > (size_t) context->samples) { |
4713 | *len = context->samples; |
4714 | } |
4715 | |
4716 | context->samples -= (int) *len; |
4717 | memset(data, 255, *len *2); |
4718 | status = SWITCH_STATUS_SUCCESS; |
4719 | } else { |
4720 | status = switch_core_file_read(&context->fh, data, len); |
4721 | } |
4722 | |
4723 | if (status != SWITCH_STATUS_SUCCESS) { |
4724 | if ((status = next_file(handle)) != SWITCH_STATUS_SUCCESS) { |
4725 | return status; |
4726 | } |
4727 | if (switch_test_flag(handle, SWITCH_FILE_BREAK_ON_CHANGE)((handle)->flags & SWITCH_FILE_BREAK_ON_CHANGE)) { |
4728 | *len = 0; |
4729 | status = SWITCH_STATUS_BREAK; |
4730 | } else { |
4731 | *len = llen; |
4732 | status = switch_core_file_read(&context->fh, data, len); |
4733 | } |
4734 | } |
4735 | |
4736 | return status; |
4737 | } |
4738 | |
4739 | |
4740 | static switch_status_t file_string_file_write(switch_file_handle_t *handle, void *data, size_t *len) |
4741 | { |
4742 | file_string_context_t *context = handle->private_info; |
4743 | switch_status_t status; |
4744 | size_t llen = *len; |
4745 | |
4746 | status = switch_core_file_write(&context->fh, data, len); |
4747 | |
4748 | if (status != SWITCH_STATUS_SUCCESS) { |
4749 | if ((status = next_file(handle)) != SWITCH_STATUS_SUCCESS) { |
4750 | return status; |
4751 | } |
4752 | *len = llen; |
4753 | status = switch_core_file_write(&context->fh, data, len); |
4754 | } |
4755 | return status; |
4756 | } |
4757 | |
4758 | static switch_status_t file_url_file_seek(switch_file_handle_t *handle, unsigned int *cur_sample, int64_t samples, int whence) |
4759 | { |
4760 | switch_file_handle_t *fh = handle->private_info; |
4761 | return switch_core_file_seek(fh, cur_sample, samples, whence); |
4762 | } |
4763 | |
4764 | static switch_status_t file_url_file_close(switch_file_handle_t *handle) |
4765 | { |
4766 | switch_file_handle_t *fh = handle->private_info; |
4767 | if (switch_test_flag(fh, SWITCH_FILE_OPEN)((fh)->flags & SWITCH_FILE_OPEN)) { |
4768 | switch_core_file_close(fh); |
4769 | } |
4770 | |
4771 | return SWITCH_STATUS_SUCCESS; |
4772 | } |
4773 | |
4774 | static switch_status_t file_url_file_read(switch_file_handle_t *handle, void *data, size_t *len) |
4775 | { |
4776 | switch_file_handle_t *fh = handle->private_info; |
4777 | return switch_core_file_read(fh, data, len); |
4778 | } |
4779 | |
4780 | static switch_status_t file_url_file_open(switch_file_handle_t *handle, const char *path) |
4781 | { |
4782 | switch_file_handle_t *fh = switch_core_alloc(handle->memory_pool, sizeof(*fh))switch_core_perform_alloc(handle->memory_pool, sizeof(*fh) , "mod_dptools.c", (const char *)__func__, 4782); |
4783 | switch_status_t status; |
4784 | char *url_host; |
4785 | char *url_path; |
4786 | |
4787 | if (zstr(path)_zstr(path)) { |
4788 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 4788, ((void*)0), SWITCH_LOG_ERROR, "NULL path\n"); |
4789 | return SWITCH_STATUS_FALSE; |
4790 | } |
4791 | |
4792 | /* parse and check host */ |
4793 | url_host = switch_core_strdup(handle->memory_pool, path)switch_core_perform_strdup(handle->memory_pool, path, "mod_dptools.c" , (const char *)__func__, 4793); |
4794 | if (!(url_path = strchr(url_host, '/')(__extension__ (__builtin_constant_p ('/') && !__builtin_constant_p (url_host) && ('/') == '\0' ? (char *) __rawmemchr ( url_host, '/') : __builtin_strchr (url_host, '/'))))) { |
4795 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 4795, ((void*)0), SWITCH_LOG_ERROR, "missing path\n"); |
4796 | return SWITCH_STATUS_FALSE; |
4797 | } |
4798 | *url_path = '\0'; |
4799 | /* TODO allow this host */ |
4800 | if (!zstr(url_host)_zstr(url_host) && strcasecmp(url_host, "localhost")) { |
4801 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 4801, ((void*)0), SWITCH_LOG_ERROR, "not localhost\n"); |
4802 | return SWITCH_STATUS_FALSE; |
4803 | } |
4804 | |
4805 | /* decode and check path */ |
4806 | url_path++; |
4807 | if (zstr(url_path)_zstr(url_path)) { |
4808 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 4808, ((void*)0), SWITCH_LOG_ERROR, "empty path\n"); |
4809 | return SWITCH_STATUS_FALSE; |
4810 | } |
4811 | if (strstr(url_path, "%2f") || strstr(url_path, "%2F")) { |
4812 | /* don't allow %2f or %2F encoding (/) */ |
4813 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 4813, ((void*)0), SWITCH_LOG_ERROR, "encoded slash is not allowed\n"); |
4814 | return SWITCH_STATUS_FALSE; |
4815 | } |
4816 | url_path = switch_core_sprintf(handle->memory_pool, "/%s", url_path); |
4817 | switch_url_decode(url_path); |
4818 | |
4819 | /* TODO convert to native file separators? */ |
4820 | |
4821 | handle->private_info = fh; |
4822 | status = switch_core_file_open(fh, url_path, handle->channels, handle->samplerate, handle->flags, NULL)switch_core_perform_file_open("mod_dptools.c", (const char *) __func__, 4822, fh, url_path, handle->channels, handle-> samplerate, handle->flags, ((void*)0)); |
4823 | if (status == SWITCH_STATUS_SUCCESS) { |
4824 | handle->samples = fh->samples; |
4825 | handle->cur_samplerate = fh->samplerate; |
4826 | handle->cur_channels = fh->real_channels; |
4827 | handle->format = fh->format; |
4828 | handle->sections = fh->sections; |
4829 | handle->seekable = fh->seekable; |
4830 | handle->speed = fh->speed; |
4831 | handle->interval = fh->interval; |
4832 | handle->max_samples = 0; |
4833 | |
4834 | if (switch_test_flag(fh, SWITCH_FILE_NATIVE)((fh)->flags & SWITCH_FILE_NATIVE)) { |
4835 | switch_set_flag(handle, SWITCH_FILE_NATIVE)(handle)->flags |= (SWITCH_FILE_NATIVE); |
4836 | } else { |
4837 | switch_clear_flag(handle, SWITCH_FILE_NATIVE)(handle)->flags &= ~(SWITCH_FILE_NATIVE); |
4838 | } |
4839 | } |
4840 | return status; |
4841 | } |
4842 | |
4843 | static switch_status_t file_url_file_write(switch_file_handle_t *handle, void *data, size_t *len) |
4844 | { |
4845 | switch_file_handle_t *fh = handle->private_info; |
4846 | return switch_core_file_write(fh, data, len); |
4847 | } |
4848 | |
4849 | /* Registration */ |
4850 | |
4851 | static char *file_string_supported_formats[SWITCH_MAX_CODECS50] = { 0 }; |
4852 | static char *file_url_supported_formats[SWITCH_MAX_CODECS50] = { 0 }; |
4853 | |
4854 | |
4855 | /* /FILE STRING INTERFACE */ |
4856 | |
4857 | |
4858 | SWITCH_STANDARD_APP(blind_transfer_ack_function)static void blind_transfer_ack_function (switch_core_session_t *session, const char *data) |
4859 | { |
4860 | switch_bool_t val = 0; |
4861 | |
4862 | if (data) { |
4863 | val = (switch_bool_t)switch_true((char *) data); |
4864 | } |
4865 | |
4866 | switch_ivr_blind_transfer_ack(session, val); |
4867 | } |
4868 | |
4869 | /* /// mutex /// */ |
4870 | |
4871 | typedef struct mutex_node_s { |
4872 | char *uuid; |
4873 | struct mutex_node_s *next; |
4874 | } mutex_node_t; |
4875 | |
4876 | typedef enum { |
4877 | MUTEX_FLAG_WAIT = (1 << 0), |
4878 | MUTEX_FLAG_SET = (1 << 1) |
4879 | } mutex_flag_t; |
4880 | |
4881 | struct read_frame_data { |
4882 | const char *dp; |
4883 | const char *exten; |
4884 | const char *context; |
4885 | const char *key; |
4886 | long to; |
4887 | }; |
4888 | |
4889 | typedef struct master_mutex_s { |
4890 | mutex_node_t *list; |
4891 | char *key; |
4892 | } master_mutex_t; |
4893 | |
4894 | static switch_status_t mutex_hanguphook(switch_core_session_t *session); |
4895 | static void advance(master_mutex_t *master, switch_bool_t pop_current); |
4896 | |
4897 | static switch_status_t read_frame_callback(switch_core_session_t *session, switch_frame_t *frame, void *user_data) |
4898 | { |
4899 | switch_channel_t *channel = switch_core_session_get_channel(session); |
4900 | struct read_frame_data *rf = (struct read_frame_data *) user_data; |
4901 | |
4902 | if (rf->to && --rf->to <= 0) { |
4903 | rf->to = -1; |
4904 | return SWITCH_STATUS_FALSE; |
4905 | } |
4906 | |
4907 | return switch_channel_test_app_flag_key(rf->key, channel, MUTEX_FLAG_WAIT) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE; |
4908 | |
4909 | } |
4910 | |
4911 | static void free_node(mutex_node_t **npp) |
4912 | { |
4913 | mutex_node_t *np; |
4914 | |
4915 | if (npp) { |
4916 | np = *npp; |
4917 | *npp = NULL((void*)0); |
4918 | switch_safe_free(np->uuid)if (np->uuid) {free(np->uuid);np->uuid=((void*)0);}; |
4919 | free(np); |
4920 | } |
4921 | } |
4922 | |
4923 | static void cancel(switch_core_session_t *session, master_mutex_t *master) |
4924 | { |
4925 | mutex_node_t *np, *lp = NULL((void*)0); |
4926 | const char *uuid = switch_core_session_get_uuid(session); |
4927 | |
4928 | switch_mutex_lock(globals.mutex_mutex); |
4929 | for (np = master->list; np; np = np->next) { |
4930 | if (np && !strcmp(np->uuid, uuid)__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (np->uuid) && __builtin_constant_p (uuid) && (__s1_len = __builtin_strlen (np->uuid), __s2_len = __builtin_strlen (uuid), (!((size_t)(const void *)((np->uuid) + 1) - (size_t )(const void *)(np->uuid) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((uuid) + 1) - (size_t)(const void * )(uuid) == 1) || __s2_len >= 4)) ? __builtin_strcmp (np-> uuid, uuid) : (__builtin_constant_p (np->uuid) && ( (size_t)(const void *)((np->uuid) + 1) - (size_t)(const void *)(np->uuid) == 1) && (__s1_len = __builtin_strlen (np->uuid), __s1_len < 4) ? (__builtin_constant_p (uuid ) && ((size_t)(const void *)((uuid) + 1) - (size_t)(const void *)(uuid) == 1) ? __builtin_strcmp (np->uuid, uuid) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (uuid); int __result = (((const unsigned char *) (const char *) (np->uuid))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (np->uuid))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (np->uuid))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (np->uuid))[3] - __s2[3]); } } __result ; }))) : (__builtin_constant_p (uuid) && ((size_t)(const void *)((uuid) + 1) - (size_t)(const void *)(uuid) == 1) && (__s2_len = __builtin_strlen (uuid), __s2_len < 4) ? (__builtin_constant_p (np->uuid) && ((size_t)(const void *)((np->uuid ) + 1) - (size_t)(const void *)(np->uuid) == 1) ? __builtin_strcmp (np->uuid, uuid) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (np->uuid) ; int __result = (((const unsigned char *) (const char *) (uuid ))[0] - __s2[0]); if (__s2_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (uuid ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (uuid ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (uuid)) [3] - __s2[3]); } } __result; })))) : __builtin_strcmp (np-> uuid, uuid)))); })) { |
4931 | switch_core_event_hook_remove_state_change(session, mutex_hanguphook); |
4932 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 4932, (const char*)(session), SWITCH_LOG_DEBUG, "%s %s mutex %s canceled\n", |
4933 | switch_core_session_get_uuid(session), |
4934 | switch_core_session_get_name(session)switch_channel_get_name(switch_core_session_get_channel(session )), master->key); |
4935 | |
4936 | if (lp) { |
4937 | lp->next = np->next; |
4938 | } else { |
4939 | if ((master->list = np->next)) { |
4940 | advance(master, SWITCH_FALSE); |
4941 | } |
4942 | } |
4943 | |
4944 | free_node(&np); |
4945 | |
4946 | break; |
4947 | } |
4948 | |
4949 | lp = np; |
4950 | } |
4951 | |
4952 | switch_mutex_unlock(globals.mutex_mutex); |
4953 | |
4954 | } |
4955 | |
4956 | static void advance(master_mutex_t *master, switch_bool_t pop_current) |
4957 | { |
4958 | |
4959 | switch_mutex_lock(globals.mutex_mutex); |
4960 | |
4961 | if (!master || !master->list) { |
4962 | goto end; |
4963 | } |
4964 | |
4965 | while (master->list) { |
4966 | mutex_node_t *np; |
4967 | |
4968 | |
4969 | if (!pop_current) { |
4970 | pop_current++; |
4971 | } else { |
4972 | np = master->list; |
4973 | master->list = master->list->next; |
4974 | |
4975 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 4975, ((void*)0), SWITCH_LOG_DEBUG, "ADVANCE POP %p\n", (void *)np); |
4976 | free_node(&np); |
4977 | } |
4978 | |
4979 | |
4980 | if (master->list) { |
4981 | switch_core_session_t *session; |
4982 | |
4983 | if ((session = switch_core_session_locate(master->list->uuid)switch_core_session_perform_locate(master->list->uuid, "mod_dptools.c" , (const char *)__func__, 4983))) { |
4984 | switch_channel_t *channel = switch_core_session_get_channel(session); |
4985 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 4985, (const char*)(session), SWITCH_LOG_DEBUG, |
4986 | "%s mutex %s advanced\n", switch_channel_get_name(channel), master->key); |
4987 | switch_channel_set_app_flag_key(master->key, channel, MUTEX_FLAG_SET); |
4988 | switch_channel_clear_app_flag_key(master->key, channel, MUTEX_FLAG_WAIT); |
4989 | switch_core_event_hook_add_state_change(session, mutex_hanguphook); |
4990 | switch_core_session_rwunlock(session); |
4991 | break; |
4992 | } else { |
4993 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 4993, (const char*)(session), SWITCH_LOG_DEBUG, "uuid %s already gone\n", master->list->uuid); |
4994 | } |
4995 | } |
4996 | } |
4997 | |
4998 | |
4999 | end: |
5000 | |
5001 | switch_mutex_unlock(globals.mutex_mutex); |
5002 | |
5003 | |
5004 | } |
5005 | |
5006 | static void confirm(switch_core_session_t *session, master_mutex_t *master) |
5007 | { |
5008 | switch_channel_t *channel = switch_core_session_get_channel(session); |
5009 | |
5010 | if (!master) { |
5011 | if (!(master = switch_channel_get_private(channel, "_mutex_master"))) { |
5012 | return; |
5013 | } |
5014 | } |
5015 | |
5016 | switch_mutex_lock(globals.mutex_mutex); |
5017 | |
5018 | if (master->list) { |
5019 | if (!strcmp(master->list->uuid, switch_core_session_get_uuid(session))__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (master->list->uuid) && __builtin_constant_p ( switch_core_session_get_uuid(session)) && (__s1_len = __builtin_strlen (master->list->uuid), __s2_len = __builtin_strlen (switch_core_session_get_uuid(session)), (!((size_t)(const void *)((master->list->uuid) + 1) - (size_t)(const void *)( master->list->uuid) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((switch_core_session_get_uuid(session )) + 1) - (size_t)(const void *)(switch_core_session_get_uuid (session)) == 1) || __s2_len >= 4)) ? __builtin_strcmp (master ->list->uuid, switch_core_session_get_uuid(session)) : ( __builtin_constant_p (master->list->uuid) && (( size_t)(const void *)((master->list->uuid) + 1) - (size_t )(const void *)(master->list->uuid) == 1) && (__s1_len = __builtin_strlen (master->list->uuid), __s1_len < 4) ? (__builtin_constant_p (switch_core_session_get_uuid(session )) && ((size_t)(const void *)((switch_core_session_get_uuid (session)) + 1) - (size_t)(const void *)(switch_core_session_get_uuid (session)) == 1) ? __builtin_strcmp (master->list->uuid , switch_core_session_get_uuid(session)) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (switch_core_session_get_uuid(session)); int __result = (((const unsigned char *) (const char *) (master->list->uuid))[ 0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (master-> list->uuid))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (master->list->uuid))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (master->list->uuid))[3] - __s2 [3]); } } __result; }))) : (__builtin_constant_p (switch_core_session_get_uuid (session)) && ((size_t)(const void *)((switch_core_session_get_uuid (session)) + 1) - (size_t)(const void *)(switch_core_session_get_uuid (session)) == 1) && (__s2_len = __builtin_strlen (switch_core_session_get_uuid (session)), __s2_len < 4) ? (__builtin_constant_p (master-> list->uuid) && ((size_t)(const void *)((master-> list->uuid) + 1) - (size_t)(const void *)(master->list-> uuid) == 1) ? __builtin_strcmp (master->list->uuid, switch_core_session_get_uuid (session)) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (master->list-> uuid); int __result = (((const unsigned char *) (const char * ) (switch_core_session_get_uuid(session)))[0] - __s2[0]); if ( __s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (switch_core_session_get_uuid (session)))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ( switch_core_session_get_uuid(session)))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (switch_core_session_get_uuid(session )))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (master ->list->uuid, switch_core_session_get_uuid(session))))) ; })) { |
5020 | switch_channel_clear_app_flag_key(master->key, channel, MUTEX_FLAG_SET); |
5021 | switch_core_event_hook_remove_state_change(session, mutex_hanguphook); |
5022 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 5022, (const char*)(session), SWITCH_LOG_DEBUG, "%s %s mutex %s cleared\n", |
5023 | switch_core_session_get_uuid(session), |
5024 | switch_channel_get_name(channel), master->key); |
5025 | advance(master, SWITCH_TRUE); |
5026 | } else { |
5027 | cancel(session, master); |
5028 | } |
5029 | } |
5030 | |
5031 | switch_mutex_unlock(globals.mutex_mutex); |
5032 | } |
5033 | |
5034 | |
5035 | |
5036 | static switch_status_t mutex_hanguphook(switch_core_session_t *session) |
5037 | { |
5038 | switch_channel_t *channel = switch_core_session_get_channel(session); |
5039 | switch_channel_state_t state = switch_channel_get_state(channel); |
5040 | |
5041 | if (state != CS_HANGUP) { |
5042 | return SWITCH_STATUS_SUCCESS; |
5043 | } |
5044 | |
5045 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 5045, (const char*)(session), SWITCH_LOG_DEBUG, "%s mutex hangup hook\n", switch_channel_get_name(channel)); |
5046 | |
5047 | confirm(session, NULL((void*)0)); |
5048 | switch_core_event_hook_remove_state_change(session, mutex_hanguphook); |
5049 | |
5050 | return SWITCH_STATUS_SUCCESS; |
5051 | } |
5052 | |
5053 | static switch_bool_t do_mutex(switch_core_session_t *session, const char *key, switch_bool_t on) |
5054 | { |
5055 | switch_channel_t *channel = switch_core_session_get_channel(session); |
5056 | const char *feedback, *var; |
5057 | switch_input_args_t args = { 0 }; |
5058 | master_mutex_t *master = NULL((void*)0); |
5059 | mutex_node_t *node, *np; |
5060 | int used; |
5061 | struct read_frame_data rf = { 0 }; |
5062 | long to_val = 0; |
5063 | |
5064 | switch_mutex_lock(globals.mutex_mutex); |
5065 | used = switch_channel_test_app_flag_key(key, channel, MUTEX_FLAG_WAIT) || switch_channel_test_app_flag_key(key, channel, MUTEX_FLAG_SET); |
5066 | |
5067 | if ((on && used) || (!on && !used)) { |
5068 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 5068, (const char*)(session), SWITCH_LOG_ERROR, "INVALID STATE\n"); |
5069 | switch_mutex_unlock(globals.mutex_mutex); |
5070 | return SWITCH_FALSE; |
5071 | } |
5072 | |
5073 | if (!(master = switch_core_hash_find(globals.mutex_hash, key))) { |
5074 | master = switch_core_alloc(globals.pool, sizeof(*master))switch_core_perform_alloc(globals.pool, sizeof(*master), "mod_dptools.c" , (const char *)__func__, 5074); |
5075 | master->key = switch_core_strdup(globals.pool, key)switch_core_perform_strdup(globals.pool, key, "mod_dptools.c" , (const char *)__func__, 5075); |
5076 | master->list = NULL((void*)0); |
5077 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 5077, (const char*)(session), SWITCH_LOG_DEBUG, "NEW MASTER %s %p\n", key, (void *) master); |
5078 | switch_core_hash_insert(globals.mutex_hash, key, master)switch_core_hash_insert_destructor(globals.mutex_hash, key, master , ((void*)0)); |
5079 | } else { |
5080 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 5080, (const char*)(session), SWITCH_LOG_DEBUG, "EXIST MASTER %s %p\n", key, (void *) master); |
5081 | } |
5082 | |
5083 | if (on) { |
5084 | |
5085 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 5085, (const char*)(session), SWITCH_LOG_DEBUG, "HIT ON\n"); |
5086 | |
5087 | switch_zmalloc(node, sizeof(*node))(void)((((node = calloc(1, (sizeof(*node))))) ? (void) (0) : __assert_fail ("(node = calloc(1, (sizeof(*node))))", "mod_dptools.c", 5087 , __PRETTY_FUNCTION__)),node); |
5088 | node->uuid = strdup(switch_core_session_get_uuid(session))(__extension__ (__builtin_constant_p (switch_core_session_get_uuid (session)) && ((size_t)(const void *)((switch_core_session_get_uuid (session)) + 1) - (size_t)(const void *)(switch_core_session_get_uuid (session)) == 1) ? (((const char *) (switch_core_session_get_uuid (session)))[0] == '\0' ? (char *) calloc ((size_t) 1, (size_t ) 1) : ({ size_t __len = strlen (switch_core_session_get_uuid (session)) + 1; char *__retval = (char *) malloc (__len); if ( __retval != ((void*)0)) __retval = (char *) memcpy (__retval, switch_core_session_get_uuid(session), __len); __retval; })) : __strdup (switch_core_session_get_uuid(session)))); |
5089 | node->next = NULL((void*)0); |
5090 | |
5091 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 5091, (const char*)(session), SWITCH_LOG_DEBUG, "CHECK MASTER LIST %p\n", (void *) master->list); |
5092 | |
5093 | for (np = master->list; np && np->next; np = np->next); |
5094 | |
5095 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 5095, (const char*)(session), SWITCH_LOG_DEBUG, "HIT ON np %p\n", (void *) np); |
5096 | |
5097 | if (np) { |
5098 | np->next = node; |
5099 | switch_channel_set_app_flag_key(key, channel, MUTEX_FLAG_WAIT); |
5100 | } else { |
5101 | master->list = node; |
5102 | switch_channel_set_app_flag_key(key, channel, MUTEX_FLAG_SET); |
5103 | switch_channel_clear_app_flag_key(key, channel, MUTEX_FLAG_WAIT); |
5104 | switch_channel_set_private(channel, "_mutex_master", master); |
5105 | switch_core_event_hook_add_state_change(session, mutex_hanguphook); |
5106 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 5106, (const char*)(session), SWITCH_LOG_DEBUG, "%s %s mutex %s acquired\n", |
5107 | switch_core_session_get_uuid(session), |
5108 | switch_channel_get_name(channel), key); |
5109 | switch_mutex_unlock(globals.mutex_mutex); |
5110 | return SWITCH_TRUE; |
5111 | } |
5112 | } else { |
5113 | confirm(session, master); |
5114 | |
5115 | switch_mutex_unlock(globals.mutex_mutex); |
5116 | return SWITCH_TRUE; |
5117 | } |
5118 | |
5119 | switch_mutex_unlock(globals.mutex_mutex); |
5120 | |
5121 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 5121, (const char*)(session), SWITCH_LOG_DEBUG, "%s mutex %s is busy, waiting...\n", switch_channel_get_name(channel), key); |
5122 | |
5123 | if ((feedback = switch_channel_get_variable(channel, "mutex_feedback")switch_channel_get_variable_dup(channel, "mutex_feedback", SWITCH_TRUE , -1))) { |
5124 | if (!strcasecmp(feedback, "silence")) { |
5125 | feedback = "silence_stream://-1"; |
5126 | } |
5127 | } |
5128 | |
5129 | if ((rf.exten = switch_channel_get_variable(channel, "mutex_orbit_exten")switch_channel_get_variable_dup(channel, "mutex_orbit_exten", SWITCH_TRUE, -1))) { |
5130 | to_val = 60; |
5131 | } |
5132 | |
5133 | if ((var = switch_channel_get_variable(channel, "mutex_timeout")switch_channel_get_variable_dup(channel, "mutex_timeout", SWITCH_TRUE , -1))) { |
5134 | long tmp = atol(var); |
5135 | |
5136 | if (tmp > 0) { |
5137 | to_val = tmp; |
5138 | } |
5139 | } |
5140 | |
5141 | if (to_val) { |
5142 | switch_codec_implementation_t read_impl; |
5143 | switch_core_session_get_read_impl(session, &read_impl); |
5144 | |
5145 | rf.to = (1000 / (read_impl.microseconds_per_packet / 1000)) * to_val; |
5146 | rf.dp = switch_channel_get_variable(channel, "mutex_orbit_dialplan")switch_channel_get_variable_dup(channel, "mutex_orbit_dialplan" , SWITCH_TRUE, -1); |
5147 | rf.context = switch_channel_get_variable(channel, "mutex_orbit_context")switch_channel_get_variable_dup(channel, "mutex_orbit_context" , SWITCH_TRUE, -1); |
5148 | } |
5149 | |
5150 | rf.key = key; |
5151 | |
5152 | args.read_frame_callback = read_frame_callback; |
5153 | args.user_data = &rf; |
5154 | |
5155 | while(switch_channel_ready(channel)switch_channel_test_ready(channel, SWITCH_TRUE, SWITCH_FALSE) && switch_channel_test_app_flag_key(key, channel, MUTEX_FLAG_WAIT)) { |
5156 | switch_status_t st; |
5157 | |
5158 | if (feedback) { |
5159 | switch_channel_pre_answer(channel)switch_channel_perform_pre_answer(channel, "mod_dptools.c", ( const char *)__func__, 5159); |
5160 | st = switch_ivr_play_file(session, NULL((void*)0), feedback, &args); |
5161 | } else { |
5162 | if ((st = switch_ivr_sleep(session, 20, SWITCH_FALSE, NULL((void*)0))) == SWITCH_STATUS_SUCCESS) { |
5163 | st = read_frame_callback(session, NULL((void*)0), &rf); |
5164 | } |
5165 | } |
5166 | |
5167 | if (st != SWITCH_STATUS_SUCCESS) { |
5168 | break; |
5169 | } |
5170 | } |
5171 | |
5172 | switch_mutex_lock(globals.mutex_mutex); |
5173 | if (switch_channel_test_app_flag_key(key, channel, MUTEX_FLAG_WAIT) || !switch_channel_up(channel)(switch_channel_check_signal(channel, SWITCH_TRUE) || switch_channel_get_state (channel) < CS_HANGUP)) { |
5174 | cancel(session, master); |
5175 | } else { |
5176 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 5176, (const char*)(session), SWITCH_LOG_DEBUG, "%s %s mutex %s acquired\n", |
5177 | switch_core_session_get_uuid(session), |
5178 | switch_channel_get_name(channel), key); |
5179 | switch_core_event_hook_add_state_change(session, mutex_hanguphook); |
5180 | switch_channel_set_private(channel, "_mutex_master", master); |
5181 | } |
5182 | switch_mutex_unlock(globals.mutex_mutex); |
5183 | |
5184 | return SWITCH_TRUE; |
5185 | } |
5186 | |
5187 | #define MUTEX_SYNTAX"<keyname>[ on|off]" "<keyname>[ on|off]" |
5188 | SWITCH_STANDARD_APP(mutex_function)static void mutex_function (switch_core_session_t *session, const char *data) |
5189 | { |
5190 | char *key; |
5191 | char *arg; |
5192 | switch_bool_t on = SWITCH_TRUE; |
5193 | |
5194 | if (zstr(data)_zstr(data)) { |
5195 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 5195, (const char*)(session), SWITCH_LOG_ERROR, "Missing keyname\n"); |
5196 | return; |
5197 | } |
5198 | |
5199 | key = switch_core_session_sprintf(session, "_mutex_key_%s", (char *)data); |
5200 | |
5201 | if ((arg = strchr(key, ' ')(__extension__ (__builtin_constant_p (' ') && !__builtin_constant_p (key) && (' ') == '\0' ? (char *) __rawmemchr (key, ' ' ) : __builtin_strchr (key, ' '))))) { |
5202 | *arg++ = '\0'; |
5203 | |
5204 | if (!strcasecmp(arg, "off")) { |
5205 | on = SWITCH_FALSE; |
5206 | } |
5207 | } |
5208 | |
5209 | do_mutex(session, key, on); |
5210 | |
5211 | |
5212 | } |
5213 | |
5214 | /* /// mutex /// */ |
5215 | |
5216 | typedef struct page_data_s { |
5217 | uint32_t *counter; |
5218 | const char *dial_str; |
5219 | const char *dp; |
5220 | const char *context; |
5221 | const char *exten; |
5222 | const char *path; |
5223 | switch_event_t *var_event; |
5224 | switch_memory_pool_t *pool; |
5225 | switch_mutex_t *mutex; |
5226 | } page_data_t; |
5227 | |
5228 | static switch_status_t page_hanguphook(switch_core_session_t *session) |
5229 | { |
5230 | switch_channel_t *channel = switch_core_session_get_channel(session); |
5231 | switch_channel_state_t state = switch_channel_get_state(channel); |
5232 | |
5233 | if (state == CS_HANGUP) { |
5234 | page_data_t *pd; |
5235 | |
5236 | if ((pd = (page_data_t *) switch_channel_get_private(channel, "__PAGE_DATA"))) { |
5237 | uint32_t *counter = pd->counter; |
5238 | |
5239 | switch_mutex_lock(pd->mutex); |
5240 | (*counter)--; |
5241 | switch_mutex_unlock(pd->mutex); |
5242 | |
5243 | |
5244 | } |
5245 | |
5246 | switch_core_event_hook_remove_state_change(session, page_hanguphook); |
5247 | } |
5248 | |
5249 | return SWITCH_STATUS_SUCCESS; |
5250 | } |
5251 | |
5252 | void *SWITCH_THREAD_FUNC page_thread(switch_thread_t *thread, void *obj) |
5253 | { |
5254 | page_data_t *mypd, *pd = (page_data_t *) obj; |
5255 | switch_core_session_t *session; |
5256 | switch_call_cause_t cause = SWITCH_CAUSE_NONE; |
5257 | uint32_t *counter = pd->counter; |
5258 | switch_memory_pool_t *pool = pd->pool; |
5259 | |
5260 | |
5261 | if (switch_ivr_originate(NULL((void*)0), &session, &cause, pd->dial_str, 60, NULL((void*)0), NULL((void*)0), NULL((void*)0), NULL((void*)0), pd->var_event, SOF_NONE, NULL((void*)0)) == SWITCH_STATUS_SUCCESS) { |
5262 | switch_channel_t *channel = switch_core_session_get_channel(session); |
5263 | |
5264 | switch_channel_set_variable(channel, "page_file", pd->path)switch_channel_set_variable_var_check(channel, "page_file", pd ->path, SWITCH_TRUE); |
5265 | |
5266 | mypd = switch_core_session_alloc(session, sizeof(*mypd))switch_core_perform_session_alloc(session, sizeof(*mypd), "mod_dptools.c" , (const char *)__func__, 5266); |
5267 | mypd->counter = pd->counter; |
5268 | mypd->mutex = pd->mutex; |
5269 | switch_core_event_hook_add_state_change(session, page_hanguphook); |
5270 | switch_channel_set_private(channel, "__PAGE_DATA", mypd); |
5271 | switch_ivr_session_transfer(session, pd->exten, pd->dp, pd->context); |
5272 | switch_core_session_rwunlock(session); |
5273 | } else { |
5274 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 5274, ((void*)0), SWITCH_LOG_WARNING, "originate failed: %s [%s]\n", switch_channel_cause2str(cause), pd->dial_str); |
5275 | switch_mutex_lock(pd->mutex); |
5276 | (*counter)--; |
5277 | switch_mutex_unlock(pd->mutex); |
5278 | } |
5279 | |
5280 | switch_event_safe_destroy(&pd->var_event)if (&pd->var_event) switch_event_destroy(&pd->var_event ); |
5281 | |
5282 | if (pool) { |
5283 | switch_core_destroy_memory_pool(&pool)switch_core_perform_destroy_memory_pool(&pool, "mod_dptools.c" , (const char *)__func__, 5283); |
5284 | } |
5285 | |
5286 | return NULL((void*)0); |
5287 | } |
5288 | |
5289 | static void launch_call(const char *dial_str, |
5290 | const char *path, const char *exten, const char *context, const char *dp, |
5291 | switch_mutex_t *mutex, uint32_t *counter, switch_event_t **var_event) |
5292 | { |
5293 | switch_thread_data_t *td; |
5294 | switch_memory_pool_t *pool; |
5295 | page_data_t *pd; |
5296 | |
5297 | switch_core_new_memory_pool(&pool)switch_core_perform_new_memory_pool(&pool, "mod_dptools.c" , (const char *)__func__, 5297); |
5298 | |
5299 | pd = switch_core_alloc(pool, sizeof(*pd))switch_core_perform_alloc(pool, sizeof(*pd), "mod_dptools.c", (const char *)__func__, 5299); |
5300 | pd->pool = pool; |
5301 | pd->exten = switch_core_strdup(pool, exten)switch_core_perform_strdup(pool, exten, "mod_dptools.c", (const char *)__func__, 5301); |
5302 | pd->context = switch_core_strdup(pool, context)switch_core_perform_strdup(pool, context, "mod_dptools.c", (const char *)__func__, 5302); |
5303 | pd->dp = switch_core_strdup(pool, dp)switch_core_perform_strdup(pool, dp, "mod_dptools.c", (const char *)__func__, 5303); |
5304 | pd->dial_str = switch_core_strdup(pool, dial_str)switch_core_perform_strdup(pool, dial_str, "mod_dptools.c", ( const char *)__func__, 5304); |
5305 | pd->path = switch_core_strdup(pool, path)switch_core_perform_strdup(pool, path, "mod_dptools.c", (const char *)__func__, 5305); |
5306 | pd->mutex = mutex; |
5307 | |
5308 | if (var_event && *var_event) { |
5309 | switch_event_dup(&pd->var_event, *var_event); |
5310 | switch_event_destroy(var_event); |
5311 | } |
5312 | |
5313 | switch_mutex_lock(pd->mutex); |
5314 | (*counter)++; |
5315 | switch_mutex_unlock(pd->mutex); |
5316 | |
5317 | pd->counter = counter; |
5318 | |
5319 | td = switch_core_alloc(pool, sizeof(*td))switch_core_perform_alloc(pool, sizeof(*td), "mod_dptools.c", (const char *)__func__, 5319); |
5320 | td->func = page_thread; |
5321 | td->obj = pd; |
5322 | |
5323 | switch_thread_pool_launch_thread(&td); |
5324 | |
5325 | } |
5326 | |
5327 | typedef struct call_monitor_s { |
5328 | switch_memory_pool_t *pool; |
5329 | const char *path; |
5330 | char *data; |
5331 | const char *context; |
5332 | const char *exten; |
5333 | const char *dp; |
5334 | uint32_t chunk_size; |
5335 | int nuke; |
5336 | } call_monitor_t; |
5337 | |
5338 | |
5339 | |
5340 | void *SWITCH_THREAD_FUNC call_monitor_thread(switch_thread_t *thread, void *obj) |
5341 | { |
5342 | call_monitor_t *cm = (call_monitor_t *) obj; |
5343 | uint32_t sent = 0; |
5344 | switch_mutex_t *mutex; |
5345 | uint32_t counter = 0; |
5346 | switch_memory_pool_t *pool = cm->pool; |
5347 | unsigned int size; |
5348 | char *argv[512] = { 0 }; |
5349 | int busy = 0; |
5350 | switch_event_t *var_event = NULL((void*)0); |
5351 | char *data; |
5352 | |
5353 | switch_mutex_init(&mutex, SWITCH_MUTEX_NESTED0x1, cm->pool); |
5354 | |
5355 | if (switch_file_exists(cm->path, cm->pool) != SWITCH_STATUS_SUCCESS) { |
5356 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 5356, ((void*)0), SWITCH_LOG_ERROR, "File %s does not exist!\n", cm->path); |
5357 | goto end; |
5358 | } |
5359 | |
5360 | data = cm->data; |
5361 | |
5362 | while (data && *data && *data == ' ') { |
5363 | data++; |
5364 | } |
5365 | |
5366 | while (*data == '<') { |
5367 | char *parsed = NULL((void*)0); |
5368 | |
5369 | if (switch_event_create_brackets(data, '<', '>', ',', &var_event, &parsed, SWITCH_FALSE) != SWITCH_STATUS_SUCCESS || !parsed) { |
5370 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 5370, ((void*)0), SWITCH_LOG_ERROR, "Parse Error!\n"); |
5371 | goto end; |
5372 | } |
5373 | |
5374 | data = parsed; |
5375 | } |
5376 | |
5377 | while (data && *data && *data == ' ') { |
5378 | data++; |
5379 | } |
5380 | |
5381 | if (!(size = switch_separate_string_string(data, SWITCH_ENT_ORIGINATE_DELIM":_:", argv, (sizeof(argv) / sizeof(argv[0]))))) { |
5382 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 5382, ((void*)0), SWITCH_LOG_ERROR, "No channels specified.\n"); |
5383 | goto end; |
5384 | } |
5385 | |
5386 | |
5387 | if (cm->chunk_size > size) { |
5388 | cm->chunk_size = size; |
5389 | } |
5390 | |
5391 | while (sent < size) { |
5392 | do { |
5393 | switch_mutex_lock(mutex); |
5394 | busy = (counter >= cm->chunk_size); |
5395 | switch_mutex_unlock(mutex); |
5396 | |
5397 | if (busy) { |
5398 | switch_yield(100000)switch_sleep(100000);; |
5399 | } |
5400 | |
5401 | } while (busy); |
5402 | |
5403 | launch_call(argv[sent++], cm->path, cm->exten, cm->context, cm->dp, mutex, &counter, &var_event); |
5404 | } |
5405 | |
5406 | |
5407 | end: |
5408 | |
5409 | while(counter) { |
5410 | switch_mutex_lock(mutex); |
5411 | switch_mutex_unlock(mutex); |
5412 | switch_yield(100000)switch_sleep(100000);; |
5413 | } |
5414 | |
5415 | if (cm->nuke && !zstr(cm->path)_zstr(cm->path)) { |
5416 | unlink(cm->path); |
5417 | } |
5418 | |
5419 | if (pool) { |
5420 | switch_core_destroy_memory_pool(&pool)switch_core_perform_destroy_memory_pool(&pool, "mod_dptools.c" , (const char *)__func__, 5420); |
5421 | } |
5422 | |
5423 | return NULL((void*)0); |
5424 | } |
5425 | |
5426 | static void launch_call_monitor(const char *path, int del, const char *data, uint32_t chunk_size, const char *exten, const char *context, const char *dp) |
5427 | { |
5428 | switch_thread_data_t *td; |
5429 | switch_memory_pool_t *pool; |
5430 | call_monitor_t *cm; |
5431 | |
5432 | switch_core_new_memory_pool(&pool)switch_core_perform_new_memory_pool(&pool, "mod_dptools.c" , (const char *)__func__, 5432); |
5433 | |
5434 | cm = switch_core_alloc(pool, sizeof(*cm))switch_core_perform_alloc(pool, sizeof(*cm), "mod_dptools.c", (const char *)__func__, 5434); |
5435 | |
5436 | if (del) { |
5437 | cm->nuke = 1; |
5438 | } |
5439 | |
5440 | cm->pool = pool; |
5441 | cm->path = switch_core_strdup(pool, path)switch_core_perform_strdup(pool, path, "mod_dptools.c", (const char *)__func__, 5441); |
5442 | cm->data = switch_core_strdup(pool, data)switch_core_perform_strdup(pool, data, "mod_dptools.c", (const char *)__func__, 5442); |
5443 | cm->exten = switch_core_strdup(pool, exten)switch_core_perform_strdup(pool, exten, "mod_dptools.c", (const char *)__func__, 5443); |
5444 | cm->context = switch_core_strdup(pool, context)switch_core_perform_strdup(pool, context, "mod_dptools.c", (const char *)__func__, 5444); |
5445 | cm->dp = switch_core_strdup(pool, dp)switch_core_perform_strdup(pool, dp, "mod_dptools.c", (const char *)__func__, 5445); |
5446 | cm->chunk_size = chunk_size; |
5447 | |
5448 | td = switch_core_alloc(pool, sizeof(*td))switch_core_perform_alloc(pool, sizeof(*td), "mod_dptools.c", (const char *)__func__, 5448); |
5449 | td->func = call_monitor_thread; |
5450 | td->obj = cm; |
5451 | |
5452 | switch_thread_pool_launch_thread(&td); |
5453 | |
5454 | } |
5455 | |
5456 | |
5457 | #define PAGE_SYNTAX"<var1=val1,var2=val2><chan1>[:_:<chanN>]" "<var1=val1,var2=val2><chan1>[:_:<chanN>]" |
5458 | SWITCH_STANDARD_APP(page_function)static void page_function (switch_core_session_t *session, const char *data) |
5459 | { |
5460 | switch_channel_t *channel = switch_core_session_get_channel(session); |
5461 | uint32_t limit = 0; |
5462 | const char *path = NULL((void*)0); |
5463 | switch_input_args_t args = { 0 }; |
5464 | switch_file_handle_t fh = { 0 }; |
5465 | uint32_t chunk_size = 10; |
5466 | const char *l = NULL((void*)0); |
5467 | const char *tmp; |
5468 | int del = 0, rate; |
5469 | const char *exten; |
5470 | const char *context = NULL((void*)0); |
5471 | const char *dp = "inline"; |
5472 | const char *pdata = data; |
5473 | |
5474 | if (zstr(pdata)_zstr(pdata)) { |
5475 | pdata = switch_channel_get_variable(channel, "page_data")switch_channel_get_variable_dup(channel, "page_data", SWITCH_TRUE , -1); |
5476 | } |
5477 | |
5478 | if (zstr(pdata)_zstr(pdata)) { |
5479 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 5479, (const char*)(session), SWITCH_LOG_ERROR, "No channels specified.\n"); |
5480 | return; |
5481 | } |
5482 | |
5483 | |
5484 | exten = switch_channel_get_variable(channel, "page_exten")switch_channel_get_variable_dup(channel, "page_exten", SWITCH_TRUE , -1); |
5485 | context = switch_channel_get_variable(channel, "page_context")switch_channel_get_variable_dup(channel, "page_context", SWITCH_TRUE , -1); |
5486 | |
5487 | if ((l = switch_channel_get_variable(channel, "page_dp")switch_channel_get_variable_dup(channel, "page_dp", SWITCH_TRUE , -1))) { |
5488 | dp = l; |
5489 | } |
5490 | |
5491 | |
5492 | l = switch_channel_get_variable(channel, "page_record_limit")switch_channel_get_variable_dup(channel, "page_record_limit", SWITCH_TRUE, -1); |
5493 | |
5494 | if (l) { |
5495 | if (*l == '+') { |
5496 | l++; |
5497 | } |
5498 | if (l) { |
5499 | limit = switch_atoui(l); |
5500 | } |
5501 | } |
5502 | |
5503 | if ((l = switch_channel_get_variable(channel, "page_record_thresh")switch_channel_get_variable_dup(channel, "page_record_thresh" , SWITCH_TRUE, -1))) { |
5504 | fh.thresh = switch_atoui(l); |
5505 | } |
5506 | |
5507 | if ((l = switch_channel_get_variable(channel, "page_chunk_size")switch_channel_get_variable_dup(channel, "page_chunk_size", SWITCH_TRUE , -1))) { |
5508 | uint32_t tmp = switch_atoui(l); |
5509 | |
5510 | if (tmp > 0) { |
5511 | chunk_size = tmp; |
5512 | } |
5513 | } |
5514 | |
5515 | if ((l = switch_channel_get_variable(channel, "page_record_silence_hits")switch_channel_get_variable_dup(channel, "page_record_silence_hits" , SWITCH_TRUE, -1))) { |
5516 | fh.silence_hits = switch_atoui(l); |
5517 | } |
5518 | |
5519 | if ((tmp = switch_channel_get_variable(channel, "record_rate")switch_channel_get_variable_dup(channel, "record_rate", SWITCH_TRUE , -1))) { |
5520 | rate = atoi(tmp); |
5521 | if (rate > 0) { |
5522 | fh.samplerate = rate; |
5523 | } |
5524 | } |
5525 | |
5526 | args.input_callback = on_dtmf; |
5527 | |
5528 | switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "")switch_channel_set_variable_var_check(channel, "playback_terminator_used" , "", SWITCH_TRUE); |
5529 | |
5530 | |
5531 | if (!(path = switch_channel_get_variable(channel, "page_path")switch_channel_get_variable_dup(channel, "page_path", SWITCH_TRUE , -1))) { |
5532 | const char *beep; |
5533 | |
5534 | path = switch_core_session_sprintf(session, "%s%s%s.wav", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR"/", switch_core_session_get_uuid(session)); |
5535 | del = 1; |
5536 | |
5537 | if (!(beep = switch_channel_get_variable(channel, "page_beep")switch_channel_get_variable_dup(channel, "page_beep", SWITCH_TRUE , -1))) { |
5538 | beep = "tone_stream://%(500,0, 620)"; |
5539 | } |
5540 | |
5541 | switch_ivr_play_file(session, NULL((void*)0), beep, NULL((void*)0)); |
5542 | |
5543 | |
5544 | switch_ivr_record_file(session, &fh, path, &args, limit); |
5545 | } |
5546 | |
5547 | if (zstr(exten)_zstr(exten)) { |
5548 | exten = switch_core_session_sprintf(session, "playback:%s", path); |
5549 | } |
5550 | |
5551 | if (switch_file_exists(path, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) { |
5552 | launch_call_monitor(path, del, pdata, chunk_size, exten, context, dp); |
5553 | } else { |
5554 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_dptools.c", (const char *)__func__ , 5554, (const char*)(session), SWITCH_LOG_ERROR, "File %s does not exist\n", path); |
5555 | } |
5556 | |
5557 | } |
5558 | |
5559 | |
5560 | SWITCH_STANDARD_API(page_api_function)static switch_status_t page_api_function ( const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream) |
5561 | { |
5562 | char *odata = NULL((void*)0), *data = NULL((void*)0); |
5563 | switch_event_t *var_event = NULL((void*)0); |
5564 | const char *exten; |
5565 | char *oexten = NULL((void*)0); |
5566 | const char *context = NULL((void*)0); |
5567 | const char *dp = "inline"; |
5568 | const char *pdata = data; |
5569 | const char *l; |
5570 | uint32_t chunk_size = 10; |
5571 | const char *path; |
5572 | |
5573 | |
5574 | if (zstr(cmd)_zstr(cmd)) { |
5575 | stream->write_function(stream, "-ERR no data"); |
5576 | goto end; |
5577 | } |
5578 | |
5579 | odata = strdup(cmd)(__extension__ (__builtin_constant_p (cmd) && ((size_t )(const void *)((cmd) + 1) - (size_t)(const void *)(cmd) == 1 ) ? (((const char *) (cmd))[0] == '\0' ? (char *) calloc ((size_t ) 1, (size_t) 1) : ({ size_t __len = strlen (cmd) + 1; char * __retval = (char *) malloc (__len); if (__retval != ((void*)0 )) __retval = (char *) memcpy (__retval, cmd, __len); __retval ; })) : __strdup (cmd))); |
5580 | data = odata; |
5581 | |
5582 | while (data && *data && *data == ' ') { |
5583 | data++; |
5584 | } |
5585 | |
5586 | while (*data == '(') { |
5587 | char *parsed = NULL((void*)0); |
5588 | |
5589 | if (switch_event_create_brackets(data, '(', ')', ',', &var_event, &parsed, SWITCH_FALSE) != SWITCH_STATUS_SUCCESS || !parsed) { |
5590 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 5590, ((void*)0), SWITCH_LOG_ERROR, "Parse Error!\n"); |
5591 | goto end; |
5592 | } |
5593 | |
5594 | data = parsed; |
5595 | } |
5596 | |
5597 | while (data && *data && *data == ' ') { |
5598 | data++; |
5599 | } |
5600 | |
5601 | if (!var_event) { |
5602 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 5602, ((void*)0), SWITCH_LOG_ERROR, "Parse Error!\n"); |
5603 | goto end; |
5604 | } |
5605 | |
5606 | pdata = data; |
5607 | |
5608 | if (zstr(pdata)_zstr(pdata)) { |
5609 | pdata = switch_event_get_header(var_event, "page_data")switch_event_get_header_idx(var_event, "page_data", -1); |
5610 | } |
5611 | |
5612 | if (zstr(pdata)_zstr(pdata)) { |
5613 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 5613, ((void*)0), SWITCH_LOG_ERROR, "No channels specified.\n"); |
5614 | goto end; |
5615 | } |
5616 | |
5617 | |
5618 | exten = switch_event_get_header(var_event, "page_exten")switch_event_get_header_idx(var_event, "page_exten", -1); |
5619 | context = switch_event_get_header(var_event, "page_context")switch_event_get_header_idx(var_event, "page_context", -1); |
5620 | |
5621 | if ((l = switch_event_get_header(var_event, "page_dp")switch_event_get_header_idx(var_event, "page_dp", -1))) { |
5622 | dp = l; |
5623 | } |
5624 | |
5625 | |
5626 | if ((l = switch_event_get_header(var_event, "page_chunk_size")switch_event_get_header_idx(var_event, "page_chunk_size", -1))) { |
5627 | uint32_t tmp = switch_atoui(l); |
5628 | |
5629 | if (tmp > 0) { |
5630 | chunk_size = tmp; |
5631 | } |
5632 | } |
5633 | |
5634 | if (!(path = switch_event_get_header(var_event, "page_path")switch_event_get_header_idx(var_event, "page_path", -1))) { |
5635 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 5635, ((void*)0), SWITCH_LOG_ERROR, "No file specified.\n"); |
5636 | goto end; |
5637 | } |
5638 | |
5639 | if (zstr(exten)_zstr(exten)) { |
5640 | oexten = switch_mprintf("playback:%s", path); |
5641 | exten = oexten; |
5642 | } |
5643 | |
5644 | if (switch_file_exists(path, NULL((void*)0)) == SWITCH_STATUS_SUCCESS) { |
5645 | launch_call_monitor(path, 0, pdata, chunk_size, exten, context, dp); |
5646 | } else { |
5647 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_dptools.c", (const char *)__func__ , 5647, ((void*)0), SWITCH_LOG_ERROR, "File %s does not exist\n", path); |
5648 | } |
5649 | |
5650 | |
5651 | end: |
5652 | |
5653 | |
5654 | switch_safe_free(odata)if (odata) {free(odata);odata=((void*)0);}; |
5655 | switch_safe_free(oexten)if (oexten) {free(oexten);oexten=((void*)0);}; |
5656 | |
5657 | return SWITCH_STATUS_SUCCESS; |
5658 | } |
5659 | |
5660 | |
5661 | |
5662 | #define SPEAK_DESC"Speak text to a channel via the tts interface" "Speak text to a channel via the tts interface" |
5663 | #define DISPLACE_DESC"Displace audio from a file to the channels input" "Displace audio from a file to the channels input" |
5664 | #define SESS_REC_DESC"Starts a background recording of the entire session" "Starts a background recording of the entire session" |
5665 | |
5666 | #define SESS_REC_MASK_DESC"Replace audio in a recording with blank data to mask critical voice sections" "Replace audio in a recording with blank data to mask critical voice sections" |
5667 | #define SESS_REC_UNMASK_DESC"Resume normal operation after calling mask" "Resume normal operation after calling mask" |
5668 | |
5669 | #define STOP_SESS_REC_DESC"Stops a background recording of the entire session" "Stops a background recording of the entire session" |
5670 | #define SCHED_TRANSF_DESCR"Schedule a transfer in the future" "Schedule a transfer in the future" |
5671 | #define SCHED_BROADCAST_DESCR"Schedule a broadcast in the future" "Schedule a broadcast in the future" |
5672 | #define SCHED_HANGUP_DESCR"Schedule a hangup in the future" "Schedule a hangup in the future" |
5673 | #define UNSET_LONG_DESC"Unset a channel variable for the channel calling the application." "Unset a channel variable for the channel calling the application." |
5674 | #define SET_LONG_DESC"Set a channel variable for the channel calling the application." "Set a channel variable for the channel calling the application." |
5675 | #define SET_GLOBAL_LONG_DESC"Set a global variable." "Set a global variable." |
5676 | #define SET_PROFILE_VAR_LONG_DESC"Set a caller profile variable for the channel calling the application." "Set a caller profile variable for the channel calling the application." |
5677 | #define EXPORT_LONG_DESC"Set and export a channel variable for the channel calling the application." "Set and export a channel variable for the channel calling the application." |
5678 | #define LOG_LONG_DESC"Logs a channel variable for the channel calling the application." "Logs a channel variable for the channel calling the application." |
5679 | #define TRANSFER_LONG_DESC"Immediately transfer the calling channel to a new extension" "Immediately transfer the calling channel to a new extension" |
5680 | #define SLEEP_LONG_DESC"Pause the channel for a given number of milliseconds, consuming the audio for that period of time." "Pause the channel for a given number of milliseconds, consuming the audio for that period of time." |
5681 | |
5682 | SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_dptools_shutdown)switch_status_t mod_dptools_shutdown (void) |
5683 | { |
5684 | switch_event_unbind_callback(pickup_pres_event_handler); |
5685 | switch_mutex_destroy(globals.pickup_mutex); |
5686 | switch_core_hash_destroy(&globals.pickup_hash); |
5687 | switch_mutex_destroy(globals.mutex_mutex); |
5688 | switch_core_hash_destroy(&globals.mutex_hash); |
5689 | |
5690 | return SWITCH_STATUS_SUCCESS; |
5691 | } |
5692 | |
5693 | SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)switch_status_t mod_dptools_load (switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) |
5694 | { |
5695 | switch_api_interface_t *api_interface; |
5696 | switch_application_interface_t *app_interface; |
5697 | switch_dialplan_interface_t *dp_interface; |
5698 | switch_chat_interface_t *chat_interface; |
5699 | switch_file_interface_t *file_interface; |
5700 | |
5701 | globals.pool = pool; |
5702 | switch_core_hash_init(&globals.pickup_hash)switch_core_hash_init_case(&globals.pickup_hash, SWITCH_TRUE ); |
5703 | switch_mutex_init(&globals.pickup_mutex, SWITCH_MUTEX_NESTED0x1, globals.pool); |
5704 | switch_core_hash_init(&globals.mutex_hash)switch_core_hash_init_case(&globals.mutex_hash, SWITCH_TRUE ); |
5705 | switch_mutex_init(&globals.mutex_mutex, SWITCH_MUTEX_NESTED0x1, globals.pool); |
5706 | |
5707 | /* connect my internal structure to the blank pointer passed to me */ |
5708 | *module_interface = switch_loadable_module_create_module_interface(pool, modname); |
5709 | |
5710 | switch_event_bind(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY((void*)0), pickup_pres_event_handler, NULL((void*)0)); |
5711 | |
5712 | |
5713 | file_string_supported_formats[0] = "file_string"; |
5714 | |
5715 | file_interface = (switch_file_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_FILE_INTERFACE); |
5716 | file_interface->interface_name = modname; |
5717 | file_interface->extens = file_string_supported_formats; |
5718 | file_interface->file_open = file_string_file_open; |
5719 | file_interface->file_close = file_string_file_close; |
5720 | file_interface->file_read = file_string_file_read; |
5721 | file_interface->file_write = file_string_file_write; |
5722 | file_interface->file_seek = file_string_file_seek; |
5723 | file_interface->file_set_string = file_string_file_set_string; |
5724 | file_interface->file_get_string = file_string_file_get_string; |
5725 | |
5726 | file_url_supported_formats[0] = "file"; |
5727 | |
5728 | file_interface = (switch_file_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_FILE_INTERFACE); |
5729 | file_interface->interface_name = modname; |
5730 | file_interface->extens = file_url_supported_formats; |
5731 | file_interface->file_open = file_url_file_open; |
5732 | file_interface->file_close = file_url_file_close; |
5733 | file_interface->file_read = file_url_file_read; |
5734 | file_interface->file_write = file_url_file_write; |
5735 | file_interface->file_seek = file_url_file_seek; |
5736 | |
5737 | |
5738 | error_endpoint_interface = (switch_endpoint_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); |
5739 | error_endpoint_interface->interface_name = "error"; |
5740 | error_endpoint_interface->io_routines = &error_io_routines; |
5741 | |
5742 | group_endpoint_interface = (switch_endpoint_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); |
5743 | group_endpoint_interface->interface_name = "group"; |
5744 | group_endpoint_interface->io_routines = &group_io_routines; |
5745 | |
5746 | user_endpoint_interface = (switch_endpoint_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); |
5747 | user_endpoint_interface->interface_name = "user"; |
5748 | user_endpoint_interface->io_routines = &user_io_routines; |
5749 | |
5750 | pickup_endpoint_interface = (switch_endpoint_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); |
5751 | pickup_endpoint_interface->interface_name = "pickup"; |
5752 | pickup_endpoint_interface->io_routines = &pickup_io_routines; |
5753 | pickup_endpoint_interface->state_handler = &pickup_event_handlers; |
5754 | |
5755 | SWITCH_ADD_CHAT(chat_interface, "event", event_chat_send)for (;;) { chat_interface = (switch_chat_interface_t *)switch_loadable_module_create_interface (*module_interface, SWITCH_CHAT_INTERFACE); chat_interface-> chat_send = event_chat_send; chat_interface->interface_name = "event"; break; }; |
5756 | SWITCH_ADD_CHAT(chat_interface, "api", api_chat_send)for (;;) { chat_interface = (switch_chat_interface_t *)switch_loadable_module_create_interface (*module_interface, SWITCH_CHAT_INTERFACE); chat_interface-> chat_send = api_chat_send; chat_interface->interface_name = "api"; break; }; |
5757 | |
5758 | SWITCH_ADD_API(api_interface, "strepoch", "Convert a date string into epoch time", strepoch_api_function, "<string>")for (;;) { api_interface = (switch_api_interface_t *)switch_loadable_module_create_interface (*module_interface, SWITCH_API_INTERFACE); api_interface-> interface_name = "strepoch"; api_interface->desc = "Convert a date string into epoch time" ; api_interface->function = strepoch_api_function; api_interface ->syntax = "<string>"; break; }; |
5759 | SWITCH_ADD_API(api_interface, "page", "Send a file as a page", page_api_function, "(var1=val1,var2=val2)<var1=val1,var2=val2><chan1>[:_:<chanN>]")for (;;) { api_interface = (switch_api_interface_t *)switch_loadable_module_create_interface (*module_interface, SWITCH_API_INTERFACE); api_interface-> interface_name = "page"; api_interface->desc = "Send a file as a page" ; api_interface->function = page_api_function; api_interface ->syntax = "(var1=val1,var2=val2)<var1=val1,var2=val2><chan1>[:_:<chanN>]" ; break; }; |
5760 | SWITCH_ADD_API(api_interface, "strmicroepoch", "Convert a date string into micoepoch time", strmicroepoch_api_function, "<string>")for (;;) { api_interface = (switch_api_interface_t *)switch_loadable_module_create_interface (*module_interface, SWITCH_API_INTERFACE); api_interface-> interface_name = "strmicroepoch"; api_interface->desc = "Convert a date string into micoepoch time" ; api_interface->function = strmicroepoch_api_function; api_interface ->syntax = "<string>"; break; }; |
5761 | SWITCH_ADD_API(api_interface, "chat", "chat", chat_api_function, "<proto>|<from>|<to>|<message>|[<content-type>]")for (;;) { api_interface = (switch_api_interface_t *)switch_loadable_module_create_interface (*module_interface, SWITCH_API_INTERFACE); api_interface-> interface_name = "chat"; api_interface->desc = "chat"; api_interface ->function = chat_api_function; api_interface->syntax = "<proto>|<from>|<to>|<message>|[<content-type>]" ; break; }; |
5762 | SWITCH_ADD_API(api_interface, "strftime", "strftime", strftime_api_function, "<format_string>")for (;;) { api_interface = (switch_api_interface_t *)switch_loadable_module_create_interface (*module_interface, SWITCH_API_INTERFACE); api_interface-> interface_name = "strftime"; api_interface->desc = "strftime" ; api_interface->function = strftime_api_function; api_interface ->syntax = "<format_string>"; break; }; |
5763 | SWITCH_ADD_API(api_interface, "presence", "presence", presence_api_function, PRESENCE_USAGE)for (;;) { api_interface = (switch_api_interface_t *)switch_loadable_module_create_interface (*module_interface, SWITCH_API_INTERFACE); api_interface-> interface_name = "presence"; api_interface->desc = "presence" ; api_interface->function = presence_api_function; api_interface ->syntax = "[in|out] <user> <rpid> <message>" ; break; }; |
5764 | |
5765 | SWITCH_ADD_APP(app_interface, "blind_transfer_ack", "", "", blind_transfer_ack_function, "[true|false]", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "blind_transfer_ack"; app_interface ->application_function = blind_transfer_ack_function; app_interface ->short_desc = ""; app_interface->long_desc = ""; app_interface ->syntax = "[true|false]"; app_interface->flags = SAF_NONE ; break; }; |
5766 | |
5767 | SWITCH_ADD_APP(app_interface, "bind_digit_action", "bind a key sequence or regex to an action",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "bind_digit_action"; app_interface ->application_function = bind_digit_action_function; app_interface ->short_desc = "bind a key sequence or regex to an action" ; app_interface->long_desc = "bind a key sequence or regex to an action" ; app_interface->syntax = "<realm>,<digits|~regex>,<string>[,<value>][,<dtmf target leg>][,<event target leg>]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; } |
5768 | "bind a key sequence or regex to an action", bind_digit_action_function, BIND_DIGIT_ACTION_USAGE, SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "bind_digit_action"; app_interface ->application_function = bind_digit_action_function; app_interface ->short_desc = "bind a key sequence or regex to an action" ; app_interface->long_desc = "bind a key sequence or regex to an action" ; app_interface->syntax = "<realm>,<digits|~regex>,<string>[,<value>][,<dtmf target leg>][,<event target leg>]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5769 | |
5770 | SWITCH_ADD_APP(app_interface, "capture", "capture data into a var", "capture data into a var",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "capture"; app_interface ->application_function = capture_function; app_interface-> short_desc = "capture data into a var"; app_interface->long_desc = "capture data into a var"; app_interface->syntax = "<varname>|<data>|<regex>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; } |
5771 | capture_function, "<varname>|<data>|<regex>", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "capture"; app_interface ->application_function = capture_function; app_interface-> short_desc = "capture data into a var"; app_interface->long_desc = "capture data into a var"; app_interface->syntax = "<varname>|<data>|<regex>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5772 | |
5773 | SWITCH_ADD_APP(app_interface, "clear_digit_action", "clear all digit bindings", "",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "clear_digit_action"; app_interface ->application_function = clear_digit_action_function; app_interface ->short_desc = "clear all digit bindings"; app_interface-> long_desc = ""; app_interface->syntax = "<realm>|all[,target]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; } |
5774 | clear_digit_action_function, CLEAR_DIGIT_ACTION_USAGE, SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "clear_digit_action"; app_interface ->application_function = clear_digit_action_function; app_interface ->short_desc = "clear all digit bindings"; app_interface-> long_desc = ""; app_interface->syntax = "<realm>|all[,target]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5775 | |
5776 | SWITCH_ADD_APP(app_interface, "digit_action_set_realm", "change binding realm", "",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "digit_action_set_realm" ; app_interface->application_function = digit_action_set_realm_function ; app_interface->short_desc = "change binding realm"; app_interface ->long_desc = ""; app_interface->syntax = "<realm>[,<target>]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; } |
5777 | digit_action_set_realm_function, DIGIT_ACTION_SET_REALM_USAGE, SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "digit_action_set_realm" ; app_interface->application_function = digit_action_set_realm_function ; app_interface->short_desc = "change binding realm"; app_interface ->long_desc = ""; app_interface->syntax = "<realm>[,<target>]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5778 | |
5779 | SWITCH_ADD_APP(app_interface, "privacy", "Set privacy on calls", "Set caller privacy on calls.", privacy_function, "off|on|name|full|number",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "privacy"; app_interface ->application_function = privacy_function; app_interface-> short_desc = "Set privacy on calls"; app_interface->long_desc = "Set caller privacy on calls."; app_interface->syntax = "off|on|name|full|number"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; } |
5780 | SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "privacy"; app_interface ->application_function = privacy_function; app_interface-> short_desc = "Set privacy on calls"; app_interface->long_desc = "Set caller privacy on calls."; app_interface->syntax = "off|on|name|full|number"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; }; |
5781 | |
5782 | SWITCH_ADD_APP(app_interface, "set_audio_level", "set volume", "set volume", set_audio_level_function, "", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "set_audio_level"; app_interface ->application_function = set_audio_level_function; app_interface ->short_desc = "set volume"; app_interface->long_desc = "set volume"; app_interface->syntax = ""; app_interface-> flags = SAF_NONE; break; }; |
5783 | SWITCH_ADD_APP(app_interface, "set_mute", "set mute", "set mute", set_mute_function, "", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "set_mute"; app_interface ->application_function = set_mute_function; app_interface-> short_desc = "set mute"; app_interface->long_desc = "set mute" ; app_interface->syntax = ""; app_interface->flags = SAF_NONE ; break; }; |
5784 | |
5785 | SWITCH_ADD_APP(app_interface, "flush_dtmf", "flush any queued dtmf", "flush any queued dtmf", flush_dtmf_function, "", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "flush_dtmf"; app_interface ->application_function = flush_dtmf_function; app_interface ->short_desc = "flush any queued dtmf"; app_interface-> long_desc = "flush any queued dtmf"; app_interface->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5786 | SWITCH_ADD_APP(app_interface, "hold", "Send a hold message", "Send a hold message", hold_function, HOLD_SYNTAX, SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "hold"; app_interface-> application_function = hold_function; app_interface->short_desc = "Send a hold message"; app_interface->long_desc = "Send a hold message" ; app_interface->syntax = "[<display message>]"; app_interface ->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5787 | SWITCH_ADD_APP(app_interface, "unhold", "Send a un-hold message", "Send a un-hold message", unhold_function, UNHOLD_SYNTAX, SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "unhold"; app_interface ->application_function = unhold_function; app_interface-> short_desc = "Send a un-hold message"; app_interface->long_desc = "Send a un-hold message"; app_interface->syntax = ""; app_interface ->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5788 | SWITCH_ADD_APP(app_interface, "mutex", "block on a call flow only allowing one at a time", "", mutex_function, MUTEX_SYNTAX, SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "mutex"; app_interface-> application_function = mutex_function; app_interface->short_desc = "block on a call flow only allowing one at a time"; app_interface ->long_desc = ""; app_interface->syntax = "<keyname>[ on|off]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5789 | SWITCH_ADD_APP(app_interface, "page", "", "", page_function, PAGE_SYNTAX, SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "page"; app_interface-> application_function = page_function; app_interface->short_desc = ""; app_interface->long_desc = ""; app_interface->syntax = "<var1=val1,var2=val2><chan1>[:_:<chanN>]" ; app_interface->flags = SAF_NONE; break; }; |
5790 | SWITCH_ADD_APP(app_interface, "transfer", "Transfer a channel", TRANSFER_LONG_DESC, transfer_function, "<exten> [<dialplan> <context>]",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "transfer"; app_interface ->application_function = transfer_function; app_interface-> short_desc = "Transfer a channel"; app_interface->long_desc = "Immediately transfer the calling channel to a new extension" ; app_interface->syntax = "<exten> [<dialplan> <context>]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; } |
5791 | SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "transfer"; app_interface ->application_function = transfer_function; app_interface-> short_desc = "Transfer a channel"; app_interface->long_desc = "Immediately transfer the calling channel to a new extension" ; app_interface->syntax = "<exten> [<dialplan> <context>]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5792 | SWITCH_ADD_APP(app_interface, "check_acl", "Check an ip against an ACL list", "Check an ip against an ACL list", check_acl_function,for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "check_acl"; app_interface ->application_function = check_acl_function; app_interface ->short_desc = "Check an ip against an ACL list"; app_interface ->long_desc = "Check an ip against an ACL list"; app_interface ->syntax = "<ip> <acl | cidr> [<hangup_cause>]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC ; break; } |
5793 | "<ip> <acl | cidr> [<hangup_cause>]", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "check_acl"; app_interface ->application_function = check_acl_function; app_interface ->short_desc = "Check an ip against an ACL list"; app_interface ->long_desc = "Check an ip against an ACL list"; app_interface ->syntax = "<ip> <acl | cidr> [<hangup_cause>]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC ; break; }; |
5794 | SWITCH_ADD_APP(app_interface, "verbose_events", "Make ALL Events verbose.", "Make ALL Events verbose.", verbose_events_function, "",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "verbose_events"; app_interface ->application_function = verbose_events_function; app_interface ->short_desc = "Make ALL Events verbose."; app_interface-> long_desc = "Make ALL Events verbose."; app_interface->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC ; break; } |
5795 | SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "verbose_events"; app_interface ->application_function = verbose_events_function; app_interface ->short_desc = "Make ALL Events verbose."; app_interface-> long_desc = "Make ALL Events verbose."; app_interface->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC ; break; }; |
5796 | SWITCH_ADD_APP(app_interface, "novideo", "Refuse Inbound Video", "Refuse Inbound Video", novideo_function, "",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "novideo"; app_interface ->application_function = novideo_function; app_interface-> short_desc = "Refuse Inbound Video"; app_interface->long_desc = "Refuse Inbound Video"; app_interface->syntax = ""; app_interface ->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC; break; } |
5797 | SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "novideo"; app_interface ->application_function = novideo_function; app_interface-> short_desc = "Refuse Inbound Video"; app_interface->long_desc = "Refuse Inbound Video"; app_interface->syntax = ""; app_interface ->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC; break; }; |
5798 | SWITCH_ADD_APP(app_interface, "cng_plc", "Do PLC on CNG frames", "", cng_plc_function, "",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "cng_plc"; app_interface ->application_function = cng_plc_function; app_interface-> short_desc = "Do PLC on CNG frames"; app_interface->long_desc = ""; app_interface->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC; break; } |
5799 | SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "cng_plc"; app_interface ->application_function = cng_plc_function; app_interface-> short_desc = "Do PLC on CNG frames"; app_interface->long_desc = ""; app_interface->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC; break; }; |
5800 | SWITCH_ADD_APP(app_interface, "early_hangup", "Enable early hangup", "", early_hangup_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "early_hangup"; app_interface ->application_function = early_hangup_function; app_interface ->short_desc = "Enable early hangup"; app_interface->long_desc = ""; app_interface->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC; break; }; |
5801 | SWITCH_ADD_APP(app_interface, "sleep", "Pause a channel", SLEEP_LONG_DESC, sleep_function, "<pausemilliseconds>", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "sleep"; app_interface-> application_function = sleep_function; app_interface->short_desc = "Pause a channel"; app_interface->long_desc = "Pause the channel for a given number of milliseconds, consuming the audio for that period of time." ; app_interface->syntax = "<pausemilliseconds>"; app_interface ->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5802 | SWITCH_ADD_APP(app_interface, "delay_echo", "echo audio at a specified delay", "Delay n ms", delay_function, "<delay ms>", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "delay_echo"; app_interface ->application_function = delay_function; app_interface-> short_desc = "echo audio at a specified delay"; app_interface ->long_desc = "Delay n ms"; app_interface->syntax = "<delay ms>" ; app_interface->flags = SAF_NONE; break; }; |
5803 | SWITCH_ADD_APP(app_interface, "strftime", "strftime", "strftime", strftime_function, "[<epoch>|]<format string>", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "strftime"; app_interface ->application_function = strftime_function; app_interface-> short_desc = "strftime"; app_interface->long_desc = "strftime" ; app_interface->syntax = "[<epoch>|]<format string>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5804 | SWITCH_ADD_APP(app_interface, "phrase", "Say a Phrase", "Say a Phrase", phrase_function, "<macro_name>,<data>", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "phrase"; app_interface ->application_function = phrase_function; app_interface-> short_desc = "Say a Phrase"; app_interface->long_desc = "Say a Phrase" ; app_interface->syntax = "<macro_name>,<data>" ; app_interface->flags = SAF_NONE; break; }; |
5805 | SWITCH_ADD_APP(app_interface, "eval", "Do Nothing", "Do Nothing", eval_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "eval"; app_interface-> application_function = eval_function; app_interface->short_desc = "Do Nothing"; app_interface->long_desc = "Do Nothing"; app_interface ->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; }; |
5806 | SWITCH_ADD_APP(app_interface, "set_media_stats", "Set Media Stats", "Set Media Stats", set_media_stats_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "set_media_stats"; app_interface ->application_function = set_media_stats_function; app_interface ->short_desc = "Set Media Stats"; app_interface->long_desc = "Set Media Stats"; app_interface->syntax = ""; app_interface ->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC ; break; }; |
5807 | SWITCH_ADD_APP(app_interface, "stop", "Do Nothing", "Do Nothing", eval_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "stop"; app_interface-> application_function = eval_function; app_interface->short_desc = "Do Nothing"; app_interface->long_desc = "Do Nothing"; app_interface ->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC; break; }; |
5808 | SWITCH_ADD_APP(app_interface, "set_zombie_exec", "Enable Zombie Execution", "Enable Zombie Execution",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "set_zombie_exec"; app_interface ->application_function = zombie_function; app_interface-> short_desc = "Enable Zombie Execution"; app_interface->long_desc = "Enable Zombie Execution"; app_interface->syntax = ""; app_interface ->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC; break; } |
5809 | zombie_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "set_zombie_exec"; app_interface ->application_function = zombie_function; app_interface-> short_desc = "Enable Zombie Execution"; app_interface->long_desc = "Enable Zombie Execution"; app_interface->syntax = ""; app_interface ->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC; break; }; |
5810 | SWITCH_ADD_APP(app_interface, "pre_answer", "Pre-Answer the call", "Pre-Answer the call for a channel.", pre_answer_function, "", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "pre_answer"; app_interface ->application_function = pre_answer_function; app_interface ->short_desc = "Pre-Answer the call"; app_interface->long_desc = "Pre-Answer the call for a channel."; app_interface->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5811 | SWITCH_ADD_APP(app_interface, "answer", "Answer the call", "Answer the call for a channel.", answer_function, "", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "answer"; app_interface ->application_function = answer_function; app_interface-> short_desc = "Answer the call"; app_interface->long_desc = "Answer the call for a channel."; app_interface->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5812 | SWITCH_ADD_APP(app_interface, "wait_for_answer", "Wait for call to be answered", "Wait for call to be answered.", wait_for_answer_function, "", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "wait_for_answer"; app_interface ->application_function = wait_for_answer_function; app_interface ->short_desc = "Wait for call to be answered"; app_interface ->long_desc = "Wait for call to be answered."; app_interface ->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; }; |
5813 | SWITCH_ADD_APP(app_interface, "hangup", "Hangup the call", "Hangup the call for a channel.", hangup_function, "[<cause>]", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "hangup"; app_interface ->application_function = hangup_function; app_interface-> short_desc = "Hangup the call"; app_interface->long_desc = "Hangup the call for a channel."; app_interface->syntax = "[<cause>]"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; }; |
5814 | SWITCH_ADD_APP(app_interface, "set_name", "Name the channel", "Name the channel", set_name_function, "<name>", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "set_name"; app_interface ->application_function = set_name_function; app_interface-> short_desc = "Name the channel"; app_interface->long_desc = "Name the channel"; app_interface->syntax = "<name>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5815 | SWITCH_ADD_APP(app_interface, "presence", "Send Presence", "Send Presence.", presence_function, "<rpid> <status> [<id>]",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "presence"; app_interface ->application_function = presence_function; app_interface-> short_desc = "Send Presence"; app_interface->long_desc = "Send Presence." ; app_interface->syntax = "<rpid> <status> [<id>]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC ; break; } |
5816 | SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "presence"; app_interface ->application_function = presence_function; app_interface-> short_desc = "Send Presence"; app_interface->long_desc = "Send Presence." ; app_interface->syntax = "<rpid> <status> [<id>]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC ; break; }; |
5817 | SWITCH_ADD_APP(app_interface, "log", "Logs to the logger", LOG_LONG_DESC, log_function, "<log_level> <log_string>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "log"; app_interface-> application_function = log_function; app_interface->short_desc = "Logs to the logger"; app_interface->long_desc = "Logs a channel variable for the channel calling the application." ; app_interface->syntax = "<log_level> <log_string>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; } |
5818 | SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "log"; app_interface-> application_function = log_function; app_interface->short_desc = "Logs to the logger"; app_interface->long_desc = "Logs a channel variable for the channel calling the application." ; app_interface->syntax = "<log_level> <log_string>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; }; |
5819 | SWITCH_ADD_APP(app_interface, "info", "Display Call Info", "Display Call Info", info_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "info"; app_interface-> application_function = info_function; app_interface->short_desc = "Display Call Info"; app_interface->long_desc = "Display Call Info" ; app_interface->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; }; |
5820 | SWITCH_ADD_APP(app_interface, "event", "Fire an event", "Fire an event", event_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "event"; app_interface-> application_function = event_function; app_interface->short_desc = "Fire an event"; app_interface->long_desc = "Fire an event" ; app_interface->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; }; |
5821 | SWITCH_ADD_APP(app_interface, "sound_test", "Analyze Audio", "Analyze Audio", sound_test_function, "", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "sound_test"; app_interface ->application_function = sound_test_function; app_interface ->short_desc = "Analyze Audio"; app_interface->long_desc = "Analyze Audio"; app_interface->syntax = ""; app_interface ->flags = SAF_NONE; break; }; |
5822 | SWITCH_ADD_APP(app_interface, "export", "Export a channel variable across a bridge", EXPORT_LONG_DESC, export_function, "<varname>=<value>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "export"; app_interface ->application_function = export_function; app_interface-> short_desc = "Export a channel variable across a bridge"; app_interface ->long_desc = "Set and export a channel variable for the channel calling the application." ; app_interface->syntax = "<varname>=<value>"; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; } |
5823 | SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "export"; app_interface ->application_function = export_function; app_interface-> short_desc = "Export a channel variable across a bridge"; app_interface ->long_desc = "Set and export a channel variable for the channel calling the application." ; app_interface->syntax = "<varname>=<value>"; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; }; |
5824 | SWITCH_ADD_APP(app_interface, "bridge_export", "Export a channel variable across a bridge", EXPORT_LONG_DESC, bridge_export_function, "<varname>=<value>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "bridge_export"; app_interface ->application_function = bridge_export_function; app_interface ->short_desc = "Export a channel variable across a bridge" ; app_interface->long_desc = "Set and export a channel variable for the channel calling the application." ; app_interface->syntax = "<varname>=<value>"; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; } |
5825 | SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "bridge_export"; app_interface ->application_function = bridge_export_function; app_interface ->short_desc = "Export a channel variable across a bridge" ; app_interface->long_desc = "Set and export a channel variable for the channel calling the application." ; app_interface->syntax = "<varname>=<value>"; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; }; |
5826 | SWITCH_ADD_APP(app_interface, "set", "Set a channel variable", SET_LONG_DESC, set_function, "<varname>=<value>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "set"; app_interface-> application_function = set_function; app_interface->short_desc = "Set a channel variable"; app_interface->long_desc = "Set a channel variable for the channel calling the application." ; app_interface->syntax = "<varname>=<value>"; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; } |
5827 | SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "set"; app_interface-> application_function = set_function; app_interface->short_desc = "Set a channel variable"; app_interface->long_desc = "Set a channel variable for the channel calling the application." ; app_interface->syntax = "<varname>=<value>"; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; }; |
5828 | |
5829 | SWITCH_ADD_APP(app_interface, "multiset", "Set many channel variables", SET_LONG_DESC, multiset_function, "[^^<delim>]<varname>=<value> <var2>=<val2>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "multiset"; app_interface ->application_function = multiset_function; app_interface-> short_desc = "Set many channel variables"; app_interface-> long_desc = "Set a channel variable for the channel calling the application." ; app_interface->syntax = "[^^<delim>]<varname>=<value> <var2>=<val2>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; } |
5830 | SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "multiset"; app_interface ->application_function = multiset_function; app_interface-> short_desc = "Set many channel variables"; app_interface-> long_desc = "Set a channel variable for the channel calling the application." ; app_interface->syntax = "[^^<delim>]<varname>=<value> <var2>=<val2>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; }; |
5831 | |
5832 | SWITCH_ADD_APP(app_interface, "push", "Set a channel variable", SET_LONG_DESC, push_function, "<varname>=<value>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "push"; app_interface-> application_function = push_function; app_interface->short_desc = "Set a channel variable"; app_interface->long_desc = "Set a channel variable for the channel calling the application." ; app_interface->syntax = "<varname>=<value>"; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; } |
5833 | SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "push"; app_interface-> application_function = push_function; app_interface->short_desc = "Set a channel variable"; app_interface->long_desc = "Set a channel variable for the channel calling the application." ; app_interface->syntax = "<varname>=<value>"; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; }; |
5834 | |
5835 | SWITCH_ADD_APP(app_interface, "unshift", "Set a channel variable", SET_LONG_DESC, unshift_function, "<varname>=<value>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "unshift"; app_interface ->application_function = unshift_function; app_interface-> short_desc = "Set a channel variable"; app_interface->long_desc = "Set a channel variable for the channel calling the application." ; app_interface->syntax = "<varname>=<value>"; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; } |
5836 | SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "unshift"; app_interface ->application_function = unshift_function; app_interface-> short_desc = "Set a channel variable"; app_interface->long_desc = "Set a channel variable for the channel calling the application." ; app_interface->syntax = "<varname>=<value>"; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; }; |
5837 | |
5838 | SWITCH_ADD_APP(app_interface, "set_global", "Set a global variable", SET_GLOBAL_LONG_DESC, set_global_function, "<varname>=<value>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "set_global"; app_interface ->application_function = set_global_function; app_interface ->short_desc = "Set a global variable"; app_interface-> long_desc = "Set a global variable."; app_interface->syntax = "<varname>=<value>"; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break ; } |
5839 | SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "set_global"; app_interface ->application_function = set_global_function; app_interface ->short_desc = "Set a global variable"; app_interface-> long_desc = "Set a global variable."; app_interface->syntax = "<varname>=<value>"; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break ; }; |
5840 | SWITCH_ADD_APP(app_interface, "set_profile_var", "Set a caller profile variable", SET_PROFILE_VAR_LONG_DESC, set_profile_var_function,for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "set_profile_var"; app_interface ->application_function = set_profile_var_function; app_interface ->short_desc = "Set a caller profile variable"; app_interface ->long_desc = "Set a caller profile variable for the channel calling the application." ; app_interface->syntax = "<varname>=<value>"; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; } |
5841 | "<varname>=<value>", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "set_profile_var"; app_interface ->application_function = set_profile_var_function; app_interface ->short_desc = "Set a caller profile variable"; app_interface ->long_desc = "Set a caller profile variable for the channel calling the application." ; app_interface->syntax = "<varname>=<value>"; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; }; |
5842 | SWITCH_ADD_APP(app_interface, "unset", "Unset a channel variable", UNSET_LONG_DESC, unset_function, "<varname>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "unset"; app_interface-> application_function = unset_function; app_interface->short_desc = "Unset a channel variable"; app_interface->long_desc = "Unset a channel variable for the channel calling the application." ; app_interface->syntax = "<varname>"; app_interface ->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC ; break; } |
5843 | SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "unset"; app_interface-> application_function = unset_function; app_interface->short_desc = "Unset a channel variable"; app_interface->long_desc = "Unset a channel variable for the channel calling the application." ; app_interface->syntax = "<varname>"; app_interface ->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC ; break; }; |
5844 | SWITCH_ADD_APP(app_interface, "multiunset", "Unset many channel variables", SET_LONG_DESC, multiunset_function, "[^^<delim>]<varname> <var2> <var3>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "multiunset"; app_interface ->application_function = multiunset_function; app_interface ->short_desc = "Unset many channel variables"; app_interface ->long_desc = "Set a channel variable for the channel calling the application." ; app_interface->syntax = "[^^<delim>]<varname> <var2> <var3>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; } |
5845 | SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "multiunset"; app_interface ->application_function = multiunset_function; app_interface ->short_desc = "Unset many channel variables"; app_interface ->long_desc = "Set a channel variable for the channel calling the application." ; app_interface->syntax = "[^^<delim>]<varname> <var2> <var3>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC; break; }; |
5846 | |
5847 | SWITCH_ADD_APP(app_interface, "ring_ready", "Indicate Ring_Ready", "Indicate Ring_Ready on a channel.", ring_ready_function, "", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "ring_ready"; app_interface ->application_function = ring_ready_function; app_interface ->short_desc = "Indicate Ring_Ready"; app_interface->long_desc = "Indicate Ring_Ready on a channel."; app_interface->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5848 | SWITCH_ADD_APP(app_interface, "remove_bugs", "Remove media bugs", "Remove all media bugs from a channel.", remove_bugs_function, "[<function>]", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "remove_bugs"; app_interface ->application_function = remove_bugs_function; app_interface ->short_desc = "Remove media bugs"; app_interface->long_desc = "Remove all media bugs from a channel."; app_interface-> syntax = "[<function>]"; app_interface->flags = SAF_NONE ; break; }; |
5849 | SWITCH_ADD_APP(app_interface, "break", "Break", "Set the break flag.", break_function, "", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "break"; app_interface-> application_function = break_function; app_interface->short_desc = "Break"; app_interface->long_desc = "Set the break flag." ; app_interface->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; }; |
5850 | SWITCH_ADD_APP(app_interface, "detect_speech", "Detect speech", "Detect speech on a channel.", detect_speech_function, DETECT_SPEECH_SYNTAX, SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "detect_speech"; app_interface ->application_function = detect_speech_function; app_interface ->short_desc = "Detect speech"; app_interface->long_desc = "Detect speech on a channel."; app_interface->syntax = "<mod_name> <gram_name> <gram_path> [<addr>] OR grammar <gram_name> [<path>] OR nogrammar <gram_name> OR grammaron/grammaroff <gram_name> OR grammarsalloff OR pause OR resume OR start_input_timers OR stop OR param <name> <value>" ; app_interface->flags = SAF_NONE; break; }; |
5851 | SWITCH_ADD_APP(app_interface, "play_and_detect_speech", "Play and do speech recognition", "Play and do speech recognition", play_and_detect_speech_function, PLAY_AND_DETECT_SPEECH_SYNTAX, SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "play_and_detect_speech" ; app_interface->application_function = play_and_detect_speech_function ; app_interface->short_desc = "Play and do speech recognition" ; app_interface->long_desc = "Play and do speech recognition" ; app_interface->syntax = "<file> detect:<engine> {param1=val1,param2=val2}<grammar>" ; app_interface->flags = SAF_NONE; break; }; |
5852 | SWITCH_ADD_APP(app_interface, "ivr", "Run an ivr menu", "Run an ivr menu.", ivr_application_function, "<menu_name>", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "ivr"; app_interface-> application_function = ivr_application_function; app_interface ->short_desc = "Run an ivr menu"; app_interface->long_desc = "Run an ivr menu."; app_interface->syntax = "<menu_name>" ; app_interface->flags = SAF_NONE; break; }; |
5853 | SWITCH_ADD_APP(app_interface, "redirect", "Send session redirect", "Send a redirect message to a session.", redirect_function, "<redirect_data>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "redirect"; app_interface ->application_function = redirect_function; app_interface-> short_desc = "Send session redirect"; app_interface->long_desc = "Send a redirect message to a session."; app_interface-> syntax = "<redirect_data>"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; } |
5854 | SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "redirect"; app_interface ->application_function = redirect_function; app_interface-> short_desc = "Send session redirect"; app_interface->long_desc = "Send a redirect message to a session."; app_interface-> syntax = "<redirect_data>"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; }; |
5855 | SWITCH_ADD_APP(app_interface, "video_refresh", "Send video refresh.", "Send video refresh.", video_refresh_function, "",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "video_refresh"; app_interface ->application_function = video_refresh_function; app_interface ->short_desc = "Send video refresh."; app_interface->long_desc = "Send video refresh."; app_interface->syntax = ""; app_interface ->flags = SAF_SUPPORT_NOMEDIA; break; } |
5856 | SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "video_refresh"; app_interface ->application_function = video_refresh_function; app_interface ->short_desc = "Send video refresh."; app_interface->long_desc = "Send video refresh."; app_interface->syntax = ""; app_interface ->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5857 | SWITCH_ADD_APP(app_interface, "send_info", "Send info", "Send info", send_info_function, "<info>", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "send_info"; app_interface ->application_function = send_info_function; app_interface ->short_desc = "Send info"; app_interface->long_desc = "Send info" ; app_interface->syntax = "<info>"; app_interface-> flags = SAF_SUPPORT_NOMEDIA; break; }; |
5858 | SWITCH_ADD_APP(app_interface, "jitterbuffer", "Send session jitterbuffer", "Send a jitterbuffer message to a session.",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "jitterbuffer"; app_interface ->application_function = jitterbuffer_function; app_interface ->short_desc = "Send session jitterbuffer"; app_interface-> long_desc = "Send a jitterbuffer message to a session."; app_interface ->syntax = "<jitterbuffer_data>"; app_interface-> flags = SAF_SUPPORT_NOMEDIA; break; } |
5859 | jitterbuffer_function, "<jitterbuffer_data>", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "jitterbuffer"; app_interface ->application_function = jitterbuffer_function; app_interface ->short_desc = "Send session jitterbuffer"; app_interface-> long_desc = "Send a jitterbuffer message to a session."; app_interface ->syntax = "<jitterbuffer_data>"; app_interface-> flags = SAF_SUPPORT_NOMEDIA; break; }; |
5860 | SWITCH_ADD_APP(app_interface, "send_display", "Send session a new display", "Send session a new display.", display_function, "<text>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "send_display"; app_interface ->application_function = display_function; app_interface-> short_desc = "Send session a new display"; app_interface-> long_desc = "Send session a new display."; app_interface-> syntax = "<text>"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; } |
5861 | SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "send_display"; app_interface ->application_function = display_function; app_interface-> short_desc = "Send session a new display"; app_interface-> long_desc = "Send session a new display."; app_interface-> syntax = "<text>"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; }; |
5862 | SWITCH_ADD_APP(app_interface, "respond", "Send session respond", "Send a respond message to a session.", respond_function, "<respond_data>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "respond"; app_interface ->application_function = respond_function; app_interface-> short_desc = "Send session respond"; app_interface->long_desc = "Send a respond message to a session."; app_interface-> syntax = "<respond_data>"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; } |
5863 | SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "respond"; app_interface ->application_function = respond_function; app_interface-> short_desc = "Send session respond"; app_interface->long_desc = "Send a respond message to a session."; app_interface-> syntax = "<respond_data>"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; }; |
5864 | SWITCH_ADD_APP(app_interface, "deflect", "Send call deflect", "Send a call deflect.", deflect_function, "<deflect_data>", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "deflect"; app_interface ->application_function = deflect_function; app_interface-> short_desc = "Send call deflect"; app_interface->long_desc = "Send a call deflect."; app_interface->syntax = "<deflect_data>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5865 | SWITCH_ADD_APP(app_interface, "recovery_refresh", "Send call recovery_refresh", "Send a call recovery_refresh.", recovery_refresh_function, "", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "recovery_refresh"; app_interface ->application_function = recovery_refresh_function; app_interface ->short_desc = "Send call recovery_refresh"; app_interface ->long_desc = "Send a call recovery_refresh."; app_interface ->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; }; |
5866 | SWITCH_ADD_APP(app_interface, "queue_dtmf", "Queue dtmf to be sent", "Queue dtmf to be sent from a session", queue_dtmf_function, "<dtmf_data>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "queue_dtmf"; app_interface ->application_function = queue_dtmf_function; app_interface ->short_desc = "Queue dtmf to be sent"; app_interface-> long_desc = "Queue dtmf to be sent from a session"; app_interface ->syntax = "<dtmf_data>"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; } |
5867 | SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "queue_dtmf"; app_interface ->application_function = queue_dtmf_function; app_interface ->short_desc = "Queue dtmf to be sent"; app_interface-> long_desc = "Queue dtmf to be sent from a session"; app_interface ->syntax = "<dtmf_data>"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; }; |
5868 | SWITCH_ADD_APP(app_interface, "send_dtmf", "Send dtmf to be sent", "Send dtmf to be sent from a session", send_dtmf_function, "<dtmf_data>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "send_dtmf"; app_interface ->application_function = send_dtmf_function; app_interface ->short_desc = "Send dtmf to be sent"; app_interface->long_desc = "Send dtmf to be sent from a session"; app_interface->syntax = "<dtmf_data>"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; } |
5869 | SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "send_dtmf"; app_interface ->application_function = send_dtmf_function; app_interface ->short_desc = "Send dtmf to be sent"; app_interface->long_desc = "Send dtmf to be sent from a session"; app_interface->syntax = "<dtmf_data>"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; }; |
5870 | SWITCH_ADD_APP(app_interface, "sched_cancel", "cancel scheduled tasks", "cancel scheduled tasks", sched_cancel_function, "[group]",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "sched_cancel"; app_interface ->application_function = sched_cancel_function; app_interface ->short_desc = "cancel scheduled tasks"; app_interface-> long_desc = "cancel scheduled tasks"; app_interface->syntax = "[group]"; app_interface->flags = SAF_SUPPORT_NOMEDIA; break ; } |
5871 | SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "sched_cancel"; app_interface ->application_function = sched_cancel_function; app_interface ->short_desc = "cancel scheduled tasks"; app_interface-> long_desc = "cancel scheduled tasks"; app_interface->syntax = "[group]"; app_interface->flags = SAF_SUPPORT_NOMEDIA; break ; }; |
5872 | SWITCH_ADD_APP(app_interface, "sched_hangup", SCHED_HANGUP_DESCR, SCHED_HANGUP_DESCR, sched_hangup_function, "[+]<time> [<cause>]",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "sched_hangup"; app_interface ->application_function = sched_hangup_function; app_interface ->short_desc = "Schedule a hangup in the future"; app_interface ->long_desc = "Schedule a hangup in the future"; app_interface ->syntax = "[+]<time> [<cause>]"; app_interface ->flags = SAF_SUPPORT_NOMEDIA; break; } |
5873 | SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "sched_hangup"; app_interface ->application_function = sched_hangup_function; app_interface ->short_desc = "Schedule a hangup in the future"; app_interface ->long_desc = "Schedule a hangup in the future"; app_interface ->syntax = "[+]<time> [<cause>]"; app_interface ->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5874 | SWITCH_ADD_APP(app_interface, "sched_broadcast", SCHED_BROADCAST_DESCR, SCHED_BROADCAST_DESCR, sched_broadcast_function,for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "sched_broadcast"; app_interface ->application_function = sched_broadcast_function; app_interface ->short_desc = "Schedule a broadcast in the future"; app_interface ->long_desc = "Schedule a broadcast in the future"; app_interface ->syntax = "[+]<time> <path> [aleg|bleg|both]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; } |
5875 | "[+]<time> <path> [aleg|bleg|both]", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "sched_broadcast"; app_interface ->application_function = sched_broadcast_function; app_interface ->short_desc = "Schedule a broadcast in the future"; app_interface ->long_desc = "Schedule a broadcast in the future"; app_interface ->syntax = "[+]<time> <path> [aleg|bleg|both]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5876 | SWITCH_ADD_APP(app_interface, "sched_transfer", SCHED_TRANSF_DESCR, SCHED_TRANSF_DESCR, sched_transfer_function,for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "sched_transfer"; app_interface ->application_function = sched_transfer_function; app_interface ->short_desc = "Schedule a transfer in the future"; app_interface ->long_desc = "Schedule a transfer in the future"; app_interface ->syntax = "[+]<time> <extension> <dialplan> <context>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; } |
5877 | "[+]<time> <extension> <dialplan> <context>", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "sched_transfer"; app_interface ->application_function = sched_transfer_function; app_interface ->short_desc = "Schedule a transfer in the future"; app_interface ->long_desc = "Schedule a transfer in the future"; app_interface ->syntax = "[+]<time> <extension> <dialplan> <context>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5878 | SWITCH_ADD_APP(app_interface, "execute_extension", "Execute an extension", "Execute an extension", exe_function, EXE_SYNTAX, SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "execute_extension"; app_interface ->application_function = exe_function; app_interface->short_desc = "Execute an extension"; app_interface->long_desc = "Execute an extension" ; app_interface->syntax = "<extension> <dialplan> <context>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5879 | SWITCH_ADD_APP(app_interface, "sched_heartbeat", "Enable Scheduled Heartbeat", "Enable Scheduled Heartbeat",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "sched_heartbeat"; app_interface ->application_function = sched_heartbeat_function; app_interface ->short_desc = "Enable Scheduled Heartbeat"; app_interface ->long_desc = "Enable Scheduled Heartbeat"; app_interface-> syntax = "[0|<seconds>]"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; } |
5880 | sched_heartbeat_function, SCHED_HEARTBEAT_SYNTAX, SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "sched_heartbeat"; app_interface ->application_function = sched_heartbeat_function; app_interface ->short_desc = "Enable Scheduled Heartbeat"; app_interface ->long_desc = "Enable Scheduled Heartbeat"; app_interface-> syntax = "[0|<seconds>]"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; }; |
5881 | SWITCH_ADD_APP(app_interface, "enable_heartbeat", "Enable Media Heartbeat", "Enable Media Heartbeat",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "enable_heartbeat"; app_interface ->application_function = heartbeat_function; app_interface ->short_desc = "Enable Media Heartbeat"; app_interface-> long_desc = "Enable Media Heartbeat"; app_interface->syntax = "[0|<seconds>]"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; } |
5882 | heartbeat_function, HEARTBEAT_SYNTAX, SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "enable_heartbeat"; app_interface ->application_function = heartbeat_function; app_interface ->short_desc = "Enable Media Heartbeat"; app_interface-> long_desc = "Enable Media Heartbeat"; app_interface->syntax = "[0|<seconds>]"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; }; |
5883 | |
5884 | SWITCH_ADD_APP(app_interface, "enable_keepalive", "Enable Keepalive", "Enable Keepalive",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "enable_keepalive"; app_interface ->application_function = keepalive_function; app_interface ->short_desc = "Enable Keepalive"; app_interface->long_desc = "Enable Keepalive"; app_interface->syntax = "[0|<seconds>]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; } |
5885 | keepalive_function, KEEPALIVE_SYNTAX, SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "enable_keepalive"; app_interface ->application_function = keepalive_function; app_interface ->short_desc = "Enable Keepalive"; app_interface->long_desc = "Enable Keepalive"; app_interface->syntax = "[0|<seconds>]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5886 | |
5887 | SWITCH_ADD_APP(app_interface, "media_reset", "Reset all bypass/proxy media flags", "Reset all bypass/proxy media flags", media_reset_function, "", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "media_reset"; app_interface ->application_function = media_reset_function; app_interface ->short_desc = "Reset all bypass/proxy media flags"; app_interface ->long_desc = "Reset all bypass/proxy media flags"; app_interface ->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; }; |
5888 | SWITCH_ADD_APP(app_interface, "mkdir", "Create a directory", "Create a directory", mkdir_function, MKDIR_SYNTAX, SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "mkdir"; app_interface-> application_function = mkdir_function; app_interface->short_desc = "Create a directory"; app_interface->long_desc = "Create a directory" ; app_interface->syntax = "<path>"; app_interface-> flags = SAF_SUPPORT_NOMEDIA; break; }; |
5889 | SWITCH_ADD_APP(app_interface, "rename", "Rename file", "Rename file", rename_function, RENAME_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "rename"; app_interface ->application_function = rename_function; app_interface-> short_desc = "Rename file"; app_interface->long_desc = "Rename file" ; app_interface->syntax = "<from_path> <to_path>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC ; break; }; |
5890 | SWITCH_ADD_APP(app_interface, "soft_hold", "Put a bridged channel on hold", "Put a bridged channel on hold", soft_hold_function, SOFT_HOLD_SYNTAX,for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "soft_hold"; app_interface ->application_function = soft_hold_function; app_interface ->short_desc = "Put a bridged channel on hold"; app_interface ->long_desc = "Put a bridged channel on hold"; app_interface ->syntax = "<unhold key> [<moh_a>] [<moh_b>]" ; app_interface->flags = SAF_NONE; break; } |
5891 | SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "soft_hold"; app_interface ->application_function = soft_hold_function; app_interface ->short_desc = "Put a bridged channel on hold"; app_interface ->long_desc = "Put a bridged channel on hold"; app_interface ->syntax = "<unhold key> [<moh_a>] [<moh_b>]" ; app_interface->flags = SAF_NONE; break; }; |
5892 | SWITCH_ADD_APP(app_interface, "bind_meta_app", "Bind a key to an application", "Bind a key to an application", dtmf_bind_function, BIND_SYNTAX,for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "bind_meta_app"; app_interface ->application_function = dtmf_bind_function; app_interface ->short_desc = "Bind a key to an application"; app_interface ->long_desc = "Bind a key to an application"; app_interface ->syntax = "<key> [a|b|ab] [a|b|o|s|i|1] <app>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; } |
5893 | SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "bind_meta_app"; app_interface ->application_function = dtmf_bind_function; app_interface ->short_desc = "Bind a key to an application"; app_interface ->long_desc = "Bind a key to an application"; app_interface ->syntax = "<key> [a|b|ab] [a|b|o|s|i|1] <app>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5894 | SWITCH_ADD_APP(app_interface, "unbind_meta_app", "Unbind a key from an application", "Unbind a key from an application", dtmf_unbind_function,for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "unbind_meta_app"; app_interface ->application_function = dtmf_unbind_function; app_interface ->short_desc = "Unbind a key from an application"; app_interface ->long_desc = "Unbind a key from an application"; app_interface ->syntax = "[<key>]"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; } |
5895 | UNBIND_SYNTAX, SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "unbind_meta_app"; app_interface ->application_function = dtmf_unbind_function; app_interface ->short_desc = "Unbind a key from an application"; app_interface ->long_desc = "Unbind a key from an application"; app_interface ->syntax = "[<key>]"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; }; |
5896 | SWITCH_ADD_APP(app_interface, "block_dtmf", "Block DTMF", "Block DTMF", dtmf_block_function, "", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "block_dtmf"; app_interface ->application_function = dtmf_block_function; app_interface ->short_desc = "Block DTMF"; app_interface->long_desc = "Block DTMF"; app_interface->syntax = ""; app_interface-> flags = SAF_SUPPORT_NOMEDIA; break; }; |
5897 | SWITCH_ADD_APP(app_interface, "unblock_dtmf", "Stop blocking DTMF", "Stop blocking DTMF", dtmf_unblock_function, "", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "unblock_dtmf"; app_interface ->application_function = dtmf_unblock_function; app_interface ->short_desc = "Stop blocking DTMF"; app_interface->long_desc = "Stop blocking DTMF"; app_interface->syntax = ""; app_interface ->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5898 | SWITCH_ADD_APP(app_interface, "intercept", "intercept", "intercept", intercept_function, INTERCEPT_SYNTAX, SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "intercept"; app_interface ->application_function = intercept_function; app_interface ->short_desc = "intercept"; app_interface->long_desc = "intercept" ; app_interface->syntax = "[-bleg] <uuid>"; app_interface ->flags = SAF_NONE; break; }; |
5899 | SWITCH_ADD_APP(app_interface, "eavesdrop", "eavesdrop on a uuid", "eavesdrop on a uuid", eavesdrop_function, eavesdrop_SYNTAX, SAF_MEDIA_TAP)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "eavesdrop"; app_interface ->application_function = eavesdrop_function; app_interface ->short_desc = "eavesdrop on a uuid"; app_interface->long_desc = "eavesdrop on a uuid"; app_interface->syntax = "[all | <uuid>]" ; app_interface->flags = SAF_MEDIA_TAP; break; }; |
5900 | SWITCH_ADD_APP(app_interface, "three_way", "three way call with a uuid", "three way call with a uuid", three_way_function, threeway_SYNTAX,for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "three_way"; app_interface ->application_function = three_way_function; app_interface ->short_desc = "three way call with a uuid"; app_interface ->long_desc = "three way call with a uuid"; app_interface-> syntax = "<uuid>"; app_interface->flags = SAF_MEDIA_TAP ; break; } |
5901 | SAF_MEDIA_TAP)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "three_way"; app_interface ->application_function = three_way_function; app_interface ->short_desc = "three way call with a uuid"; app_interface ->long_desc = "three way call with a uuid"; app_interface-> syntax = "<uuid>"; app_interface->flags = SAF_MEDIA_TAP ; break; }; |
5902 | SWITCH_ADD_APP(app_interface, "set_user", "Set a User", "Set a User", set_user_function, SET_USER_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "set_user"; app_interface ->application_function = set_user_function; app_interface-> short_desc = "Set a User"; app_interface->long_desc = "Set a User" ; app_interface->syntax = "<user>@<domain> [prefix]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC ; break; }; |
5903 | SWITCH_ADD_APP(app_interface, "stop_dtmf", "stop inband dtmf", "Stop detecting inband dtmf.", stop_dtmf_session_function, "", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "stop_dtmf"; app_interface ->application_function = stop_dtmf_session_function; app_interface ->short_desc = "stop inband dtmf"; app_interface->long_desc = "Stop detecting inband dtmf."; app_interface->syntax = "" ; app_interface->flags = SAF_NONE; break; }; |
5904 | SWITCH_ADD_APP(app_interface, "start_dtmf", "Detect dtmf", "Detect inband dtmf on the session", dtmf_session_function, "", SAF_MEDIA_TAP)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "start_dtmf"; app_interface ->application_function = dtmf_session_function; app_interface ->short_desc = "Detect dtmf"; app_interface->long_desc = "Detect inband dtmf on the session"; app_interface->syntax = ""; app_interface->flags = SAF_MEDIA_TAP; break; }; |
5905 | SWITCH_ADD_APP(app_interface, "stop_dtmf_generate", "stop inband dtmf generation", "Stop generating inband dtmf.",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "stop_dtmf_generate"; app_interface ->application_function = stop_dtmf_session_generate_function ; app_interface->short_desc = "stop inband dtmf generation" ; app_interface->long_desc = "Stop generating inband dtmf." ; app_interface->syntax = "[write]"; app_interface->flags = SAF_NONE; break; } |
5906 | stop_dtmf_session_generate_function, "[write]", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "stop_dtmf_generate"; app_interface ->application_function = stop_dtmf_session_generate_function ; app_interface->short_desc = "stop inband dtmf generation" ; app_interface->long_desc = "Stop generating inband dtmf." ; app_interface->syntax = "[write]"; app_interface->flags = SAF_NONE; break; }; |
5907 | SWITCH_ADD_APP(app_interface, "start_dtmf_generate", "Generate dtmf", "Generate inband dtmf on the session", dtmf_session_generate_function, "",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "start_dtmf_generate"; app_interface ->application_function = dtmf_session_generate_function; app_interface ->short_desc = "Generate dtmf"; app_interface->long_desc = "Generate inband dtmf on the session"; app_interface->syntax = ""; app_interface->flags = SAF_NONE; break; } |
5908 | SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "start_dtmf_generate"; app_interface ->application_function = dtmf_session_generate_function; app_interface ->short_desc = "Generate dtmf"; app_interface->long_desc = "Generate inband dtmf on the session"; app_interface->syntax = ""; app_interface->flags = SAF_NONE; break; }; |
5909 | SWITCH_ADD_APP(app_interface, "stop_tone_detect", "stop detecting tones", "Stop detecting tones", stop_fax_detect_session_function, "", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "stop_tone_detect"; app_interface ->application_function = stop_fax_detect_session_function; app_interface->short_desc = "stop detecting tones"; app_interface ->long_desc = "Stop detecting tones"; app_interface->syntax = ""; app_interface->flags = SAF_NONE; break; }; |
5910 | SWITCH_ADD_APP(app_interface, "fax_detect", "Detect faxes", "Detect fax send tone", fax_detect_session_function, "", SAF_MEDIA_TAP)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "fax_detect"; app_interface ->application_function = fax_detect_session_function; app_interface ->short_desc = "Detect faxes"; app_interface->long_desc = "Detect fax send tone"; app_interface->syntax = ""; app_interface ->flags = SAF_MEDIA_TAP; break; }; |
5911 | SWITCH_ADD_APP(app_interface, "tone_detect", "Detect tones", "Detect tones", tone_detect_session_function, "", SAF_MEDIA_TAP)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "tone_detect"; app_interface ->application_function = tone_detect_session_function; app_interface ->short_desc = "Detect tones"; app_interface->long_desc = "Detect tones"; app_interface->syntax = ""; app_interface ->flags = SAF_MEDIA_TAP; break; }; |
5912 | SWITCH_ADD_APP(app_interface, "echo", "Echo", "Perform an echo test against the calling channel", echo_function, "", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "echo"; app_interface-> application_function = echo_function; app_interface->short_desc = "Echo"; app_interface->long_desc = "Perform an echo test against the calling channel" ; app_interface->syntax = ""; app_interface->flags = SAF_NONE ; break; }; |
5913 | SWITCH_ADD_APP(app_interface, "park", "Park", "Park", park_function, "", SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "park"; app_interface-> application_function = park_function; app_interface->short_desc = "Park"; app_interface->long_desc = "Park"; app_interface ->syntax = ""; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; }; |
5914 | SWITCH_ADD_APP(app_interface, "park_state", "Park State", "Park State", park_state_function, "", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "park_state"; app_interface ->application_function = park_state_function; app_interface ->short_desc = "Park State"; app_interface->long_desc = "Park State"; app_interface->syntax = ""; app_interface-> flags = SAF_NONE; break; }; |
5915 | SWITCH_ADD_APP(app_interface, "gentones", "Generate Tones", "Generate tones to the channel", gentones_function, "<tgml_script>[|<loops>]", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "gentones"; app_interface ->application_function = gentones_function; app_interface-> short_desc = "Generate Tones"; app_interface->long_desc = "Generate tones to the channel" ; app_interface->syntax = "<tgml_script>[|<loops>]" ; app_interface->flags = SAF_NONE; break; }; |
5916 | SWITCH_ADD_APP(app_interface, "playback", "Playback File", "Playback a file to the channel", playback_function, "<path>", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "playback"; app_interface ->application_function = playback_function; app_interface-> short_desc = "Playback File"; app_interface->long_desc = "Playback a file to the channel" ; app_interface->syntax = "<path>"; app_interface-> flags = SAF_NONE; break; }; |
5917 | SWITCH_ADD_APP(app_interface, "endless_playback", "Playback File Endlessly", "Endlessly Playback a file to the channel",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "endless_playback"; app_interface ->application_function = endless_playback_function; app_interface ->short_desc = "Playback File Endlessly"; app_interface-> long_desc = "Endlessly Playback a file to the channel"; app_interface ->syntax = "<path>"; app_interface->flags = SAF_NONE ; break; } |
5918 | endless_playback_function, "<path>", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "endless_playback"; app_interface ->application_function = endless_playback_function; app_interface ->short_desc = "Playback File Endlessly"; app_interface-> long_desc = "Endlessly Playback a file to the channel"; app_interface ->syntax = "<path>"; app_interface->flags = SAF_NONE ; break; }; |
5919 | SWITCH_ADD_APP(app_interface, "loop_playback", "Playback File looply", "Playback a file to the channel looply for limted times",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "loop_playback"; app_interface ->application_function = loop_playback_function; app_interface ->short_desc = "Playback File looply"; app_interface->long_desc = "Playback a file to the channel looply for limted times"; app_interface ->syntax = "[+loops] <path>"; app_interface->flags = SAF_NONE; break; } |
5920 | loop_playback_function, "[+loops] <path>", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "loop_playback"; app_interface ->application_function = loop_playback_function; app_interface ->short_desc = "Playback File looply"; app_interface->long_desc = "Playback a file to the channel looply for limted times"; app_interface ->syntax = "[+loops] <path>"; app_interface->flags = SAF_NONE; break; }; |
5921 | SWITCH_ADD_APP(app_interface, "att_xfer", "Attended Transfer", "Attended Transfer", att_xfer_function, "<channel_url>", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "att_xfer"; app_interface ->application_function = att_xfer_function; app_interface-> short_desc = "Attended Transfer"; app_interface->long_desc = "Attended Transfer"; app_interface->syntax = "<channel_url>" ; app_interface->flags = SAF_NONE; break; }; |
5922 | SWITCH_ADD_APP(app_interface, "read", "Read Digits", "Read Digits", read_function,for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "read"; app_interface-> application_function = read_function; app_interface->short_desc = "Read Digits"; app_interface->long_desc = "Read Digits" ; app_interface->syntax = "<min> <max> <file> <var_name> <timeout> <terminators> <digit_timeout>" ; app_interface->flags = SAF_NONE; break; } |
5923 | "<min> <max> <file> <var_name> <timeout> <terminators> <digit_timeout>", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "read"; app_interface-> application_function = read_function; app_interface->short_desc = "Read Digits"; app_interface->long_desc = "Read Digits" ; app_interface->syntax = "<min> <max> <file> <var_name> <timeout> <terminators> <digit_timeout>" ; app_interface->flags = SAF_NONE; break; }; |
5924 | SWITCH_ADD_APP(app_interface, "play_and_get_digits", "Play and get Digits", "Play and get Digits",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "play_and_get_digits"; app_interface ->application_function = play_and_get_digits_function; app_interface ->short_desc = "Play and get Digits"; app_interface->long_desc = "Play and get Digits"; app_interface->syntax = "\n\t<min> <max> <tries> <timeout> <terminators> <file> <invalid_file> <var_name> <regexp> [<digit_timeout>] ['<failure_ext> [failure_dp [failure_context]]']" ; app_interface->flags = SAF_NONE; break; } |
5925 | play_and_get_digits_function,for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "play_and_get_digits"; app_interface ->application_function = play_and_get_digits_function; app_interface ->short_desc = "Play and get Digits"; app_interface->long_desc = "Play and get Digits"; app_interface->syntax = "\n\t<min> <max> <tries> <timeout> <terminators> <file> <invalid_file> <var_name> <regexp> [<digit_timeout>] ['<failure_ext> [failure_dp [failure_context]]']" ; app_interface->flags = SAF_NONE; break; } |
5926 | "\n\t<min> <max> <tries> <timeout> <terminators> <file> <invalid_file> <var_name> <regexp> [<digit_timeout>] ['<failure_ext> [failure_dp [failure_context]]']", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "play_and_get_digits"; app_interface ->application_function = play_and_get_digits_function; app_interface ->short_desc = "Play and get Digits"; app_interface->long_desc = "Play and get Digits"; app_interface->syntax = "\n\t<min> <max> <tries> <timeout> <terminators> <file> <invalid_file> <var_name> <regexp> [<digit_timeout>] ['<failure_ext> [failure_dp [failure_context]]']" ; app_interface->flags = SAF_NONE; break; }; |
5927 | SWITCH_ADD_APP(app_interface, "stop_record_session", "Stop Record Session", STOP_SESS_REC_DESC, stop_record_session_function, "<path>", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "stop_record_session"; app_interface ->application_function = stop_record_session_function; app_interface ->short_desc = "Stop Record Session"; app_interface->long_desc = "Stops a background recording of the entire session"; app_interface ->syntax = "<path>"; app_interface->flags = SAF_NONE ; break; }; |
5928 | SWITCH_ADD_APP(app_interface, "record_session", "Record Session", SESS_REC_DESC, record_session_function, "<path> [+<timeout>]", SAF_MEDIA_TAP)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "record_session"; app_interface ->application_function = record_session_function; app_interface ->short_desc = "Record Session"; app_interface->long_desc = "Starts a background recording of the entire session"; app_interface ->syntax = "<path> [+<timeout>]"; app_interface ->flags = SAF_MEDIA_TAP; break; }; |
5929 | SWITCH_ADD_APP(app_interface, "record_session_mask", "Mask audio in recording", SESS_REC_MASK_DESC, record_session_mask_function, "<path>", SAF_MEDIA_TAP)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "record_session_mask"; app_interface ->application_function = record_session_mask_function; app_interface ->short_desc = "Mask audio in recording"; app_interface-> long_desc = "Replace audio in a recording with blank data to mask critical voice sections" ; app_interface->syntax = "<path>"; app_interface-> flags = SAF_MEDIA_TAP; break; }; |
5930 | SWITCH_ADD_APP(app_interface, "record_session_unmask", "Resume recording", SESS_REC_UNMASK_DESC, record_session_unmask_function, "<path>", SAF_MEDIA_TAP)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "record_session_unmask" ; app_interface->application_function = record_session_unmask_function ; app_interface->short_desc = "Resume recording"; app_interface ->long_desc = "Resume normal operation after calling mask" ; app_interface->syntax = "<path>"; app_interface-> flags = SAF_MEDIA_TAP; break; }; |
5931 | SWITCH_ADD_APP(app_interface, "record", "Record File", "Record a file from the channels input", record_function,for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "record"; app_interface ->application_function = record_function; app_interface-> short_desc = "Record File"; app_interface->long_desc = "Record a file from the channels input" ; app_interface->syntax = "<path> [<time_limit_secs>] [<silence_thresh>] [<silence_hits>]" ; app_interface->flags = SAF_NONE; break; } |
5932 | "<path> [<time_limit_secs>] [<silence_thresh>] [<silence_hits>]", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "record"; app_interface ->application_function = record_function; app_interface-> short_desc = "Record File"; app_interface->long_desc = "Record a file from the channels input" ; app_interface->syntax = "<path> [<time_limit_secs>] [<silence_thresh>] [<silence_hits>]" ; app_interface->flags = SAF_NONE; break; }; |
5933 | SWITCH_ADD_APP(app_interface, "preprocess", "pre-process", "pre-process", preprocess_session_function, "", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "preprocess"; app_interface ->application_function = preprocess_session_function; app_interface ->short_desc = "pre-process"; app_interface->long_desc = "pre-process"; app_interface->syntax = ""; app_interface-> flags = SAF_NONE; break; }; |
5934 | SWITCH_ADD_APP(app_interface, "stop_displace_session", "Stop Displace File", "Stop Displacing to a file", stop_displace_session_function, "<path>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "stop_displace_session" ; app_interface->application_function = stop_displace_session_function ; app_interface->short_desc = "Stop Displace File"; app_interface ->long_desc = "Stop Displacing to a file"; app_interface-> syntax = "<path>"; app_interface->flags = SAF_NONE; break ; } |
5935 | SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "stop_displace_session" ; app_interface->application_function = stop_displace_session_function ; app_interface->short_desc = "Stop Displace File"; app_interface ->long_desc = "Stop Displacing to a file"; app_interface-> syntax = "<path>"; app_interface->flags = SAF_NONE; break ; }; |
5936 | SWITCH_ADD_APP(app_interface, "displace_session", "Displace File", DISPLACE_DESC, displace_session_function, "<path> [<flags>] [+time_limit_ms]",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "displace_session"; app_interface ->application_function = displace_session_function; app_interface ->short_desc = "Displace File"; app_interface->long_desc = "Displace audio from a file to the channels input"; app_interface ->syntax = "<path> [<flags>] [+time_limit_ms]" ; app_interface->flags = SAF_MEDIA_TAP; break; } |
5937 | SAF_MEDIA_TAP)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "displace_session"; app_interface ->application_function = displace_session_function; app_interface ->short_desc = "Displace File"; app_interface->long_desc = "Displace audio from a file to the channels input"; app_interface ->syntax = "<path> [<flags>] [+time_limit_ms]" ; app_interface->flags = SAF_MEDIA_TAP; break; }; |
5938 | SWITCH_ADD_APP(app_interface, "speak", "Speak text", SPEAK_DESC, speak_function, "<engine>|<voice>|<text>", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "speak"; app_interface-> application_function = speak_function; app_interface->short_desc = "Speak text"; app_interface->long_desc = "Speak text to a channel via the tts interface" ; app_interface->syntax = "<engine>|<voice>|<text>" ; app_interface->flags = SAF_NONE; break; }; |
5939 | SWITCH_ADD_APP(app_interface, "clear_speech_cache", "Clear Speech Handle Cache", "Clear Speech Handle Cache", clear_speech_cache_function, "",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "clear_speech_cache"; app_interface ->application_function = clear_speech_cache_function; app_interface ->short_desc = "Clear Speech Handle Cache"; app_interface-> long_desc = "Clear Speech Handle Cache"; app_interface->syntax = ""; app_interface->flags = SAF_NONE; break; } |
5940 | SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "clear_speech_cache"; app_interface ->application_function = clear_speech_cache_function; app_interface ->short_desc = "Clear Speech Handle Cache"; app_interface-> long_desc = "Clear Speech Handle Cache"; app_interface->syntax = ""; app_interface->flags = SAF_NONE; break; }; |
5941 | SWITCH_ADD_APP(app_interface, "bridge", "Bridge Audio", "Bridge the audio between two sessions", audio_bridge_function, "<channel_url>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "bridge"; app_interface ->application_function = audio_bridge_function; app_interface ->short_desc = "Bridge Audio"; app_interface->long_desc = "Bridge the audio between two sessions"; app_interface-> syntax = "<channel_url>"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; } |
5942 | SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "bridge"; app_interface ->application_function = audio_bridge_function; app_interface ->short_desc = "Bridge Audio"; app_interface->long_desc = "Bridge the audio between two sessions"; app_interface-> syntax = "<channel_url>"; app_interface->flags = SAF_SUPPORT_NOMEDIA ; break; }; |
5943 | SWITCH_ADD_APP(app_interface, "system", "Execute a system command", "Execute a system command", system_session_function, "<command>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "system"; app_interface ->application_function = system_session_function; app_interface ->short_desc = "Execute a system command"; app_interface-> long_desc = "Execute a system command"; app_interface->syntax = "<command>"; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC; break; } |
5944 | SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "system"; app_interface ->application_function = system_session_function; app_interface ->short_desc = "Execute a system command"; app_interface-> long_desc = "Execute a system command"; app_interface->syntax = "<command>"; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC; break; }; |
5945 | SWITCH_ADD_APP(app_interface, "bgsystem", "Execute a system command in the background", "Execute a background system command", bgsystem_session_function, "<command>",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "bgsystem"; app_interface ->application_function = bgsystem_session_function; app_interface ->short_desc = "Execute a system command in the background" ; app_interface->long_desc = "Execute a background system command" ; app_interface->syntax = "<command>"; app_interface ->flags = SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC; break; } |
5946 | SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "bgsystem"; app_interface ->application_function = bgsystem_session_function; app_interface ->short_desc = "Execute a system command in the background" ; app_interface->long_desc = "Execute a background system command" ; app_interface->syntax = "<command>"; app_interface ->flags = SAF_SUPPORT_NOMEDIA | SAF_ZOMBIE_EXEC; break; }; |
5947 | SWITCH_ADD_APP(app_interface, "say", "say", "say", say_function, SAY_SYNTAX, SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "say"; app_interface-> application_function = say_function; app_interface->short_desc = "say"; app_interface->long_desc = "say"; app_interface-> syntax = "<module_name>[:<lang>] <say_type> <say_method> [<say_gender>] <text>" ; app_interface->flags = SAF_NONE; break; }; |
5948 | |
5949 | SWITCH_ADD_APP(app_interface, "wait_for_silence", "wait_for_silence", "wait_for_silence", wait_for_silence_function, WAIT_FOR_SILENCE_SYNTAX,for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "wait_for_silence"; app_interface ->application_function = wait_for_silence_function; app_interface ->short_desc = "wait_for_silence"; app_interface->long_desc = "wait_for_silence"; app_interface->syntax = "<silence_thresh> <silence_hits> <listen_hits> <timeout_ms> [<file>]" ; app_interface->flags = SAF_NONE; break; } |
5950 | SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "wait_for_silence"; app_interface ->application_function = wait_for_silence_function; app_interface ->short_desc = "wait_for_silence"; app_interface->long_desc = "wait_for_silence"; app_interface->syntax = "<silence_thresh> <silence_hits> <listen_hits> <timeout_ms> [<file>]" ; app_interface->flags = SAF_NONE; break; }; |
5951 | SWITCH_ADD_APP(app_interface, "session_loglevel", "session_loglevel", "session_loglevel", session_loglevel_function, SESSION_LOGLEVEL_SYNTAX,for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "session_loglevel"; app_interface ->application_function = session_loglevel_function; app_interface ->short_desc = "session_loglevel"; app_interface->long_desc = "session_loglevel"; app_interface->syntax = "<level>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; } |
5952 | SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "session_loglevel"; app_interface ->application_function = session_loglevel_function; app_interface ->short_desc = "session_loglevel"; app_interface->long_desc = "session_loglevel"; app_interface->syntax = "<level>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5953 | SWITCH_ADD_APP(app_interface, "limit", "Limit", LIMIT_DESC, limit_function, LIMIT_USAGE, SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "limit"; app_interface-> application_function = limit_function; app_interface->short_desc = "Limit"; app_interface->long_desc = "limit access to a resource and transfer to an extension if the limit is exceeded" ; app_interface->syntax = "<backend> <realm> <id> [<max>[/interval]] [number [dialplan [context]]]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5954 | SWITCH_ADD_APP(app_interface, "limit_hash", "Limit", LIMIT_HASH_DESC, limit_hash_function, LIMIT_HASH_USAGE, SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "limit_hash"; app_interface ->application_function = limit_hash_function; app_interface ->short_desc = "Limit"; app_interface->long_desc = "DEPRECATED: limit access to a resource and transfer to an extension if the limit is exceeded" ; app_interface->syntax = "<realm> <id> [<max>[/interval]] [number [dialplan [context]]]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5955 | SWITCH_ADD_APP(app_interface, "limit_execute", "Limit", LIMITEXECUTE_DESC, limit_execute_function, LIMITEXECUTE_USAGE, SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "limit_execute"; app_interface ->application_function = limit_execute_function; app_interface ->short_desc = "Limit"; app_interface->long_desc = "limit access to a resource. the specified application will only be executed if the resource is available" ; app_interface->syntax = "<backend> <realm> <id> <max>[/interval] <application> [application arguments]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5956 | SWITCH_ADD_APP(app_interface, "limit_hash_execute", "Limit", LIMITHASHEXECUTE_DESC, limit_hash_execute_function, LIMITHASHEXECUTE_USAGE, SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "limit_hash_execute"; app_interface ->application_function = limit_hash_execute_function; app_interface ->short_desc = "Limit"; app_interface->long_desc = "DEPRECATED: limit access to a resource. the specified application will only be executed if the resource is available" ; app_interface->syntax = "<realm> <id> <max>[/interval] <application> [application arguments]" ; app_interface->flags = SAF_SUPPORT_NOMEDIA; break; }; |
5957 | |
5958 | SWITCH_ADD_APP(app_interface, "pickup", "Pickup", "Pickup a call", pickup_function, PICKUP_SYNTAX, SAF_SUPPORT_NOMEDIA)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "pickup"; app_interface ->application_function = pickup_function; app_interface-> short_desc = "Pickup"; app_interface->long_desc = "Pickup a call" ; app_interface->syntax = "[<key>]"; app_interface-> flags = SAF_SUPPORT_NOMEDIA; break; }; |
5959 | |
5960 | |
5961 | SWITCH_ADD_DIALPLAN(dp_interface, "inline", inline_dialplan_hunt)for (;;) { dp_interface = (switch_dialplan_interface_t *)switch_loadable_module_create_interface (*module_interface, SWITCH_DIALPLAN_INTERFACE); dp_interface-> hunt_function = inline_dialplan_hunt; dp_interface->interface_name = "inline"; break; }; |
5962 | |
5963 | /* indicate that the module should continue to be loaded */ |
5964 | return SWITCH_STATUS_SUCCESS; |
5965 | } |
5966 | |
5967 | /* For Emacs: |
5968 | * Local Variables: |
5969 | * mode:c |
5970 | * indent-tabs-mode:t |
5971 | * tab-width:4 |
5972 | * c-basic-offset:4 |
5973 | * End: |
5974 | * For VIM: |
5975 | * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: |
5976 | */ |