2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
21 * \brief Playback the special information tone to get rid of telemarketers
23 * \author Mark Spencer <markster@digium.com>
25 * \ingroup applications
30 ASTERISK_FILE_VERSION(__FILE__
, "$Revision$")
36 #include "asterisk/lock.h"
37 #include "asterisk/file.h"
38 #include "asterisk/logger.h"
39 #include "asterisk/channel.h"
40 #include "asterisk/pbx.h"
41 #include "asterisk/module.h"
42 #include "asterisk/translate.h"
44 static char *app
= "Zapateller";
46 static char *synopsis
= "Block telemarketers with SIT";
48 static char *descrip
=
49 " Zapateller(options): Generates special information tone to block\n"
50 "telemarketers from calling you. Options is a pipe-delimited list of\n"
51 "options. The following options are available:\n"
52 "'answer' causes the line to be answered before playing the tone,\n"
53 "'nocallerid' causes Zapateller to only play the tone if there\n"
54 "is no callerid information available. Options should be separated by |\n"
58 static int zapateller_exec(struct ast_channel
*chan
, void *data
)
61 struct ast_module_user
*u
;
62 int answer
= 0, nocallerid
= 0;
66 u
= ast_module_user_add(chan
);
69 c
= strsep(&stringp
, "|");
70 while(!ast_strlen_zero(c
)) {
71 if (!strcasecmp(c
, "answer"))
73 else if (!strcasecmp(c
, "nocallerid"))
76 c
= strsep(&stringp
, "|");
80 if (chan
->_state
!= AST_STATE_UP
) {
83 res
= ast_answer(chan
);
85 res
= ast_safe_sleep(chan
, 500);
88 if (!ast_strlen_zero(chan
->cid
.cid_num
) && nocallerid
) {
89 ast_module_user_remove(u
);
93 res
= ast_tonepair(chan
, 950, 0, 330, 0);
95 res
= ast_tonepair(chan
, 1400, 0, 330, 0);
97 res
= ast_tonepair(chan
, 1800, 0, 330, 0);
99 res
= ast_tonepair(chan
, 0, 0, 1000, 0);
100 ast_module_user_remove(u
);
104 static int unload_module(void)
108 res
= ast_unregister_application(app
);
110 ast_module_user_hangup_all();
115 static int load_module(void)
117 return ast_register_application(app
, zapateller_exec
, synopsis
, descrip
);
120 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY
, "Block Telemarketers with Special Information Tone");