Fri Jul 15 2011 11:59:33

Asterisk developer's documentation


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

static void __reg_module (void)
static void __unreg_module (void)
static int load_module (void)
static int unload_module (void)
static int zapateller_exec (struct ast_channel *chan, void *data)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Block Telemarketers with Special Information Tone" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, }
static char * app = "Zapateller"
static struct ast_module_infoast_module_info = &__mod_info

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

static void __reg_module ( void  ) [static]

Definition at line 132 of file app_zapateller.c.

static void __unreg_module ( void  ) [static]

Definition at line 132 of file app_zapateller.c.

static int unload_module ( void  ) [static]

Definition at line 122 of file app_zapateller.c.

References ast_unregister_application().

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

Definition at line 77 of file app_zapateller.c.

References ast_channel::_state, ast_answer(), AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_safe_sleep(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_stopstream(), ast_strdupa, ast_strlen_zero(), ast_tonepair(), ast_channel::cid, ast_callerid::cid_num, parse(), and pbx_builtin_setvar_helper().

Referenced by load_module().

{
   int res = 0;
   int i, answer = 0, nocallerid = 0;
   char *parse = ast_strdupa((char *)data);
   AST_DECLARE_APP_ARGS(args,
      AST_APP_ARG(options)[2];
   );

   AST_STANDARD_APP_ARGS(args, parse);

   for (i = 0; i < args.argc; i++) {
      if (!strcasecmp(args.options[i], "answer"))
         answer = 1;
      else if (!strcasecmp(args.options[i], "nocallerid"))
         nocallerid = 1;
   }

   pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "NOTHING");
   ast_stopstream(chan);
   if (chan->_state != AST_STATE_UP) {
      if (answer) {
         res = ast_answer(chan);
         pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "ANSWERED");
      }
      if (!res)
         res = ast_safe_sleep(chan, 500);
   }

   if (!ast_strlen_zero(chan->cid.cid_num) && nocallerid)
      return res;

   if (!res) 
      res = ast_tonepair(chan, 950, 0, 330, 0);
   if (!res) 
      res = ast_tonepair(chan, 1400, 0, 330, 0);
   if (!res) 
      res = ast_tonepair(chan, 1800, 0, 330, 0);
   if (!res) 
      res = ast_tonepair(chan, 0, 0, 1000, 0);
   
   pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "ZAPPED");
   return res;
}

Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Block Telemarketers with Special Information Tone" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static]

Definition at line 132 of file app_zapateller.c.

char* app = "Zapateller" [static]

Definition at line 75 of file app_zapateller.c.

Definition at line 132 of file app_zapateller.c.