#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 193 of file app_privacy.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 193 of file app_privacy.c.
static int load_module | ( | void | ) | [static] |
Definition at line 188 of file app_privacy.c.
References ast_register_application, and privacy_exec().
00189 { 00190 return ast_register_application(app, privacy_exec, synopsis, descrip); 00191 }
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(), phone, and S_OR.
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 00090 parse = ast_strdupa(S_OR(data, "")); 00091 00092 AST_STANDARD_APP_ARGS(args, parse); 00093 00094 if (!ast_strlen_zero(args.maxretries)) { 00095 if (sscanf(args.maxretries, "%30d", &x) == 1 && x > 0) { 00096 maxretries = x; 00097 } else { 00098 ast_log(LOG_WARNING, "Invalid max retries argument: '%s'\n", args.maxretries); 00099 } 00100 } 00101 if (!ast_strlen_zero(args.minlength)) { 00102 if (sscanf(args.minlength, "%30d", &x) == 1 && x > 0) { 00103 minlength = x; 00104 } else { 00105 ast_log(LOG_WARNING, "Invalid min length argument: '%s'\n", args.minlength); 00106 } 00107 } 00108 00109 /* Play unidentified call */ 00110 res = ast_safe_sleep(chan, 1000); 00111 if (!res) { 00112 res = ast_streamfile(chan, "privacy-unident", chan->language); 00113 } 00114 if (!res) { 00115 res = ast_waitstream(chan, ""); 00116 } 00117 00118 /* Ask for 10 digit number, give 3 attempts */ 00119 for (retries = 0; retries < maxretries; retries++) { 00120 if (!res) { 00121 res = ast_streamfile(chan, "privacy-prompt", chan->language); 00122 } 00123 if (!res) { 00124 res = ast_waitstream(chan, ""); 00125 } 00126 00127 if (!res) { 00128 res = ast_readstring(chan, phone, sizeof(phone) - 1, /* digit timeout ms */ 3200, /* first digit timeout */ 5000, "#"); 00129 } 00130 00131 if (res < 0) { 00132 break; 00133 } 00134 00135 /* Make sure we get at least digits */ 00136 if (strlen(phone) >= minlength ) { 00137 /* if we have a checkcontext argument, do pattern matching */ 00138 if (!ast_strlen_zero(args.checkcontext)) { 00139 if (!ast_exists_extension(NULL, args.checkcontext, phone, 1, NULL)) { 00140 res = ast_streamfile(chan, "privacy-incorrect", chan->language); 00141 if (!res) { 00142 res = ast_waitstream(chan, ""); 00143 } 00144 } else { 00145 break; 00146 } 00147 } else { 00148 break; 00149 } 00150 } else { 00151 res = ast_streamfile(chan, "privacy-incorrect", chan->language); 00152 if (!res) { 00153 res = ast_waitstream(chan, ""); 00154 } 00155 } 00156 } 00157 00158 /* Got a number, play sounds and send them on their way */ 00159 if ((retries < maxretries) && res >= 0) { 00160 res = ast_streamfile(chan, "privacy-thankyou", chan->language); 00161 if (!res) { 00162 res = ast_waitstream(chan, ""); 00163 } 00164 00165 ast_set_callerid(chan, phone, "Privacy Manager", NULL); 00166 00167 /* Clear the unavailable presence bit so if it came in on PRI 00168 * the caller id will now be passed out to other channels 00169 */ 00170 chan->cid.cid_pres &= (AST_PRES_UNAVAILABLE ^ 0xFF); 00171 00172 ast_verb(3, "Changed Caller*ID to '%s', callerpres to %d\n", phone, chan->cid.cid_pres); 00173 00174 pbx_builtin_setvar_helper(chan, "PRIVACYMGRSTATUS", "SUCCESS"); 00175 } else { 00176 pbx_builtin_setvar_helper(chan, "PRIVACYMGRSTATUS", "FAILED"); 00177 } 00178 } 00179 00180 return 0; 00181 }
static int unload_module | ( | void | ) | [static] |
Definition at line 183 of file app_privacy.c.
References ast_unregister_application().
00184 { 00185 return ast_unregister_application(app); 00186 }
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 193 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 193 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.