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