#include "asterisk.h"
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/utils.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
#include "asterisk/image.h"
#include "asterisk/callerid.h"
#include "asterisk/app.h"
#include "asterisk/config.h"
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 | privacy_exec (struct ast_channel *chan, void *data) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Require phone number to be entered, if no CallerID sent" , .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 = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } |
static char * | app = "PrivacyManager" |
static struct ast_module_info * | ast_module_info = &__mod_info |
static char * | descrip |
static char * | synopsis = "Require phone number to be entered, if no CallerID sent" |
Definition in file app_privacy.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 184 of file app_privacy.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 184 of file app_privacy.c.
static int load_module | ( | void | ) | [static] |
Definition at line 179 of file app_privacy.c.
References ast_register_application, and privacy_exec().
00180 { 00181 return ast_register_application(app, privacy_exec, synopsis, descrip); 00182 }
static int privacy_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 64 of file app_privacy.c.
References ast_channel::_state, ast_answer(), AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_exists_extension(), ast_log(), ast_readstring(), ast_safe_sleep(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_strdupa, ast_streamfile(), ast_strlen_zero(), ast_verb, ast_waitstream(), chan, ast_channel::cid, ast_callerid::cid_num, ast_channel::language, LOG_WARNING, maxretries, parse(), and phone.
Referenced by load_module().
00065 { 00066 int res=0; 00067 int retries; 00068 int maxretries = 3; 00069 int minlength = 10; 00070 int x = 0; 00071 char phone[30]; 00072 char *parse = NULL; 00073 AST_DECLARE_APP_ARGS(args, 00074 AST_APP_ARG(maxretries); 00075 AST_APP_ARG(minlength); 00076 AST_APP_ARG(options); 00077 AST_APP_ARG(checkcontext); 00078 ); 00079 00080 if (!ast_strlen_zero(chan->cid.cid_num)) { 00081 ast_verb(3, "CallerID Present: Skipping\n"); 00082 } else { 00083 /*Answer the channel if it is not already*/ 00084 if (chan->_state != AST_STATE_UP) { 00085 if ((res = ast_answer(chan))) 00086 return -1; 00087 } 00088 00089 if (!ast_strlen_zero(data)) { 00090 parse = ast_strdupa(data); 00091 00092 AST_STANDARD_APP_ARGS(args, parse); 00093 00094 if (args.maxretries) { 00095 if (sscanf(args.maxretries, "%d", &x) == 1) 00096 maxretries = x; 00097 else 00098 ast_log(LOG_WARNING, "Invalid max retries argument\n"); 00099 } 00100 if (args.minlength) { 00101 if (sscanf(args.minlength, "%d", &x) == 1) 00102 minlength = x; 00103 else 00104 ast_log(LOG_WARNING, "Invalid min length argument\n"); 00105 } 00106 } 00107 00108 /* Play unidentified call */ 00109 res = ast_safe_sleep(chan, 1000); 00110 if (!res) 00111 res = ast_streamfile(chan, "privacy-unident", chan->language); 00112 if (!res) 00113 res = ast_waitstream(chan, ""); 00114 00115 /* Ask for 10 digit number, give 3 attempts */ 00116 for (retries = 0; retries < maxretries; retries++) { 00117 if (!res) 00118 res = ast_streamfile(chan, "privacy-prompt", chan->language); 00119 if (!res) 00120 res = ast_waitstream(chan, ""); 00121 00122 if (!res ) 00123 res = ast_readstring(chan, phone, sizeof(phone) - 1, /* digit timeout ms */ 3200, /* first digit timeout */ 5000, "#"); 00124 00125 if (res < 0) 00126 break; 00127 00128 /* Make sure we get at least digits */ 00129 if (strlen(phone) >= minlength ) { 00130 /* if we have a checkcontext argument, do pattern matching */ 00131 if (!ast_strlen_zero(args.checkcontext)) { 00132 if (!ast_exists_extension(NULL, args.checkcontext, phone, 1, NULL)) { 00133 res = ast_streamfile(chan, "privacy-incorrect", chan->language); 00134 if (!res) { 00135 res = ast_waitstream(chan, ""); 00136 } 00137 } else { 00138 break; 00139 } 00140 } else { 00141 break; 00142 } 00143 } else { 00144 res = ast_streamfile(chan, "privacy-incorrect", chan->language); 00145 if (!res) 00146 res = ast_waitstream(chan, ""); 00147 } 00148 } 00149 00150 /* Got a number, play sounds and send them on their way */ 00151 if ((retries < maxretries) && res >= 0 ) { 00152 res = ast_streamfile(chan, "privacy-thankyou", chan->language); 00153 if (!res) 00154 res = ast_waitstream(chan, ""); 00155 00156 ast_set_callerid (chan, phone, "Privacy Manager", NULL); 00157 00158 /* Clear the unavailable presence bit so if it came in on PRI 00159 * the caller id will now be passed out to other channels 00160 */ 00161 chan->cid.cid_pres &= (AST_PRES_UNAVAILABLE ^ 0xFF); 00162 00163 ast_verb(3, "Changed Caller*ID to %s, callerpres to %d\n",phone,chan->cid.cid_pres); 00164 00165 pbx_builtin_setvar_helper(chan, "PRIVACYMGRSTATUS", "SUCCESS"); 00166 } else { 00167 pbx_builtin_setvar_helper(chan, "PRIVACYMGRSTATUS", "FAILED"); 00168 } 00169 } 00170 00171 return 0; 00172 }
static int unload_module | ( | void | ) | [static] |
Definition at line 174 of file app_privacy.c.
References ast_unregister_application().
00175 { 00176 return ast_unregister_application (app); 00177 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Require phone number to be entered, if no CallerID sent" , .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 = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 184 of file app_privacy.c.
char* app = "PrivacyManager" [static] |
Definition at line 44 of file app_privacy.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 184 of file app_privacy.c.
char* descrip [static] |
Definition at line 48 of file app_privacy.c.
Definition at line 46 of file app_privacy.c.