Index: apps/app_privacy.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_privacy.c,v retrieving revision 1.6 diff -u -r1.6 app_privacy.c --- apps/app_privacy.c 22 Jun 2004 19:32:52 -0000 1.6 +++ apps/app_privacy.c 11 Aug 2004 15:45:11 -0000 @@ -36,27 +36,34 @@ static char *descrip = " PrivacyManager: If no Caller*ID is sent, PrivacyManager answers the\n" - "channel and asks the caller to enter their 10 digit phone number.\n" + "channel and asks the caller to enter their phone number.\n" "The caller is given 3 attempts. If after 3 attempts, they do not enter\n" - "their 10 digit phone number, and if there exists a priority n + 101,\n" + "at least a 10 digit phone number, and if there exists a priority n + 101,\n" "where 'n' is the priority of the current instance, then the\n" "channel will be setup to continue at that priority level.\n" "Otherwise, it returns 0. Does nothing if Caller*ID was received on the\n" - "channel.\n"; + "channel.\n" + " Configuration file privacy.conf contains two variables:\n" + " maxretries default 3 -maximum number of attempts the caller is allowed to input a callerid.\n" + " minlength default 10 -minimum allowable digits in the input callerid number.\n" +; STANDARD_LOCAL_USER; LOCAL_USER_DECL; + + static int privacy_exec (struct ast_channel *chan, void *data) { int res=0; int retries; int maxretries = 3; + int minlength = 10; int x; char *s; - char phone[10]; + char phone[30]; char new_cid[144]; struct localuser *u; struct ast_config *cfg; @@ -95,16 +102,29 @@ ast_log(LOG_WARNING, "Invalid max retries argument\n"); } } + if (cfg && (s = ast_variable_retrieve(cfg, "general", "minlength"))) { + if (sscanf(s, "%d", &x) == 1) { + minlength = x; + } else { + ast_log(LOG_WARNING, "Invalid min length argument\n"); + } + } /*Ask for 10 digit number, give 3 attempts*/ for (retries = 0; retries < maxretries; retries++) { if (!res) - res = ast_app_getdata(chan, "privacy-prompt", phone, sizeof(phone), 0); + res = ast_streamfile(chan, "privacy-prompt", chan->language); + if (!res) + res = ast_waitstream(chan, ""); + + if (!res ) + res = ast_readstring(chan, phone, sizeof(phone) - 1, /* digit timeout ms */ 3200, /* first digit timeout */ 5000, "#"); + if (res < 0) break; - /*Make sure we get 10 digits*/ - if (strlen(phone) == 10) + /*Make sure we get at least digits*/ + if (strlen(phone) >= minlength ) break; else { res = ast_streamfile(chan, "privacy-incorrect", chan->language); @@ -114,7 +134,7 @@ } /*Got a number, play sounds and send them on their way*/ - if ((retries < maxretries) && !res) { + if ((retries < maxretries) && res == 1 ) { res = ast_streamfile(chan, "privacy-thankyou", chan->language); if (!res) res = ast_waitstream(chan, ""); Index: configs/privacy.conf.sample =================================================================== RCS file: /usr/cvsroot/asterisk/configs/privacy.conf.sample,v retrieving revision 1.1 diff -u -r1.1 privacy.conf.sample --- configs/privacy.conf.sample 26 Mar 2003 21:52:26 -0000 1.1 +++ configs/privacy.conf.sample 11 Aug 2004 15:45:11 -0000 @@ -1,3 +1,5 @@ [general] maxretries = 2 ;How many chances the caller has to enter their number +minlength = 10 ;How many minimum digits we require the caller to enter. More than this is OK. + ; the maximum number of digits is arbitrarily fixed at 30.