app_zapateller.c File Reference

Playback the special information tone to get rid of telemarketers. More...

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

Include dependency graph for app_zapateller.c:

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD_EXTENDED (ASTERISK_GPL_KEY,"Block Telemarketers with Special Information Tone")
static int load_module (void)
static int unload_module (void)
static int zapateller_exec (struct ast_channel *chan, const char *data)

Variables

static char * app = "Zapateller"


Detailed Description

Playback the special information tone to get rid of telemarketers.

Author:
Mark Spencer <markster@digium.com>

Definition in file app_zapateller.c.


Function Documentation

AST_MODULE_INFO_STANDARD_EXTENDED ( ASTERISK_GPL_KEY  ,
"Block Telemarketers with Special Information Tone"   
)

static int load_module ( void   )  [static]

static int unload_module ( void   )  [static]

Definition at line 130 of file app_zapateller.c.

References ast_unregister_application().

00131 {
00132    return ast_unregister_application(app);
00133 }

static int zapateller_exec ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 81 of file app_zapateller.c.

References answer(), args, ast_answer(), AST_APP_ARG, ast_channel_caller(), AST_DECLARE_APP_ARGS, ast_safe_sleep(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_stopstream(), ast_strdupa, ast_strlen_zero, ast_tonepair(), parse(), and pbx_builtin_setvar_helper().

Referenced by load_module().

00082 {
00083    int res = 0;
00084    int i, answer = 0, nocallerid = 0;
00085    char *parse = ast_strdupa((char *)data);
00086    AST_DECLARE_APP_ARGS(args,
00087       AST_APP_ARG(options)[2];
00088    );
00089 
00090    AST_STANDARD_APP_ARGS(args, parse);
00091 
00092    for (i = 0; i < args.argc; i++) {
00093       if (!strcasecmp(args.options[i], "answer"))
00094          answer = 1;
00095       else if (!strcasecmp(args.options[i], "nocallerid"))
00096          nocallerid = 1;
00097    }
00098 
00099    pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "NOTHING");
00100    ast_stopstream(chan);
00101    if (ast_channel_state(chan) != AST_STATE_UP) {
00102       if (answer) {
00103          res = ast_answer(chan);
00104          pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "ANSWERED");
00105       }
00106       if (!res)
00107          res = ast_safe_sleep(chan, 500);
00108    }
00109 
00110    if (nocallerid /* Zap caller if no caller id. */
00111       && ast_channel_caller(chan)->id.number.valid
00112       && !ast_strlen_zero(ast_channel_caller(chan)->id.number.str)) {
00113       /* We have caller id. */
00114       return res;
00115    }
00116 
00117    if (!res) 
00118       res = ast_tonepair(chan, 950, 0, 330, 0);
00119    if (!res) 
00120       res = ast_tonepair(chan, 1400, 0, 330, 0);
00121    if (!res) 
00122       res = ast_tonepair(chan, 1800, 0, 330, 0);
00123    if (!res) 
00124       res = ast_tonepair(chan, 0, 0, 1000, 0);
00125    
00126    pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "ZAPPED");
00127    return res;
00128 }


Variable Documentation

char* app = "Zapateller" [static]

Definition at line 79 of file app_zapateller.c.


Generated on Thu Apr 16 06:28:52 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6