| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
#include "asterisk.h" |
| 33 |
|
| 34 |
#include "asterisk/lock.h" |
| 35 |
#include "asterisk/file.h" |
| 36 |
#include "asterisk/channel.h" |
| 37 |
#include "asterisk/pbx.h" |
| 38 |
#include "asterisk/module.h" |
| 39 |
#include "asterisk/translate.h" |
| 40 |
#include "asterisk/app.h" |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
static char *app = "Zapateller"; |
| 81 |
|
| 82 |
static int zapateller_exec(struct ast_channel *chan, const char *data) |
| 83 |
{ |
| 84 |
int res = 0; |
| 85 |
int i, answer = 0, nocallerid = 0; |
| 86 |
char *parse = ast_strdupa((char *)data); |
| 87 |
AST_DECLARE_APP_ARGS(args, |
| 88 |
AST_APP_ARG(options)[2]; |
| 89 |
); |
| 90 |
|
| 91 |
AST_STANDARD_APP_ARGS(args, parse); |
| 92 |
|
| 93 |
for (i = 0; i < args.argc; i++) { |
| 94 |
if (!strcasecmp(args.options[i], "answer")) |
| 95 |
answer = 1; |
| 96 |
else if (!strcasecmp(args.options[i], "nocallerid")) |
| 97 |
nocallerid = 1; |
| 98 |
} |
| 99 |
|
| 100 |
pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "NOTHING"); |
| 101 |
ast_stopstream(chan); |
| 102 |
if (ast_channel_state(chan) != AST_STATE_UP) { |
| 103 |
if (answer) { |
| 104 |
res = ast_answer(chan); |
| 105 |
pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "ANSWERED"); |
| 106 |
} |
| 107 |
if (!res) |
| 108 |
res = ast_safe_sleep(chan, 500); |
| 109 |
} |
| 110 |
|
| 111 |
if (nocallerid |
| 112 |
&& ast_channel_caller(chan)->id.number.valid |
| 113 |
&& !ast_strlen_zero(ast_channel_caller(chan)->id.number.str)) { |
| 114 |
|
| 115 |
return res; |
| 116 |
} |
| 117 |
|
| 118 |
if (!res) |
| 119 |
res = ast_tonepair(chan, 950, 0, 330, 0); |
| 120 |
if (!res) |
| 121 |
res = ast_tonepair(chan, 1400, 0, 330, 0); |
| 122 |
if (!res) |
| 123 |
res = ast_tonepair(chan, 1800, 0, 330, 0); |
| 124 |
if (!res) |
| 125 |
res = ast_tonepair(chan, 0, 0, 1000, 0); |
| 126 |
|
| 127 |
pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "ZAPPED"); |
| 128 |
return res; |
| 129 |
} |
| 130 |
|
| 131 |
static int unload_module(void) |
| 132 |
{ |
| 133 |
return ast_unregister_application(app); |
| 134 |
} |
| 135 |
|
| 136 |
static int load_module(void) |
| 137 |
{ |
| 138 |
return ((ast_register_application_xml(app, zapateller_exec)) ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS); |
| 139 |
} |
| 140 |
|
| 141 |
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Block Telemarketers with Special Information Tone"); |