mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-19 00:00:09 +00:00
Remove use of privacy.conf by the Privacy app.
Reported by: eliel Patch by: eliel (Closes issue #11344) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@93066 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -237,6 +237,8 @@ Other Dialplan Application Changes
|
|||||||
READSTATUS to ERROR, which you can catch and handle separately.
|
READSTATUS to ERROR, which you can catch and handle separately.
|
||||||
* Added 'm' option to Directory, which lists out names, 8 at a time, instead
|
* Added 'm' option to Directory, which lists out names, 8 at a time, instead
|
||||||
of asking for verification of each name, one at a time.
|
of asking for verification of each name, one at a time.
|
||||||
|
* Privacy() no longer uses privacy.conf, as all options are specifyable as
|
||||||
|
direct options to the app.
|
||||||
|
|
||||||
Music On Hold Changes
|
Music On Hold Changes
|
||||||
---------------------
|
---------------------
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ Applications:
|
|||||||
* Read() now sets a READSTATUS variable on exit. It does NOT automatically
|
* Read() now sets a READSTATUS variable on exit. It does NOT automatically
|
||||||
return -1 (and hangup) anymore on error. If you want to hangup on error,
|
return -1 (and hangup) anymore on error. If you want to hangup on error,
|
||||||
you need to do so explicitly in your dialplan.
|
you need to do so explicitly in your dialplan.
|
||||||
|
* Privacy() no longer uses privacy.conf, so any options must be specified
|
||||||
|
directly in the application arguments.
|
||||||
|
|
||||||
Dialplan Functions:
|
Dialplan Functions:
|
||||||
|
|
||||||
|
|||||||
@@ -41,24 +41,18 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include "asterisk/app.h"
|
#include "asterisk/app.h"
|
||||||
#include "asterisk/config.h"
|
#include "asterisk/config.h"
|
||||||
|
|
||||||
#define PRIV_CONFIG "privacy.conf"
|
|
||||||
|
|
||||||
static char *app = "PrivacyManager";
|
static char *app = "PrivacyManager";
|
||||||
|
|
||||||
static char *synopsis = "Require phone number to be entered, if no CallerID sent";
|
static char *synopsis = "Require phone number to be entered, if no CallerID sent";
|
||||||
|
|
||||||
static char *descrip =
|
static char *descrip =
|
||||||
" PrivacyManager([maxretries[,minlength[,options]]]): If no Caller*ID \n"
|
" PrivacyManager([maxretries][,minlength]): If no Caller*ID \n"
|
||||||
"is sent, PrivacyManager answers the channel and asks the caller to\n"
|
"is sent, PrivacyManager answers the channel and asks the caller to\n"
|
||||||
"enter their phone number. The caller is given 3 attempts to do so.\n"
|
"enter their phone number. The caller is given 'maxretries' attempts to do so.\n"
|
||||||
"The application does nothing if Caller*ID was received on the channel.\n"
|
"The application does nothing if Caller*ID was received on the channel.\n"
|
||||||
" Configuration file privacy.conf contains two variables:\n"
|
|
||||||
" maxretries default 3 -maximum number of attempts the caller is allowed \n"
|
" maxretries default 3 -maximum number of attempts the caller is allowed \n"
|
||||||
" to input a callerid.\n"
|
" to input a callerid.\n"
|
||||||
" minlength default 10 -minimum allowable digits in the input callerid number.\n"
|
" minlength default 10 -minimum allowable digits in the input callerid number.\n"
|
||||||
"If you don't want to use the config file and have an i/o operation with\n"
|
|
||||||
"every call, you can also specify maxretries and minlength as application\n"
|
|
||||||
"parameters. Doing so supercedes any values set in privacy.conf.\n"
|
|
||||||
"The application sets the following channel variable upon completion: \n"
|
"The application sets the following channel variable upon completion: \n"
|
||||||
"PRIVACYMGRSTATUS The status of the privacy manager's attempt to collect \n"
|
"PRIVACYMGRSTATUS The status of the privacy manager's attempt to collect \n"
|
||||||
" a phone number from the user. A text string that is either:\n"
|
" a phone number from the user. A text string that is either:\n"
|
||||||
@@ -73,11 +67,8 @@ static int privacy_exec (struct ast_channel *chan, void *data)
|
|||||||
int maxretries = 3;
|
int maxretries = 3;
|
||||||
int minlength = 10;
|
int minlength = 10;
|
||||||
int x = 0;
|
int x = 0;
|
||||||
const char *s;
|
|
||||||
char phone[30];
|
char phone[30];
|
||||||
struct ast_config *cfg = NULL;
|
|
||||||
char *parse = NULL;
|
char *parse = NULL;
|
||||||
struct ast_flags config_flags = { 0 };
|
|
||||||
AST_DECLARE_APP_ARGS(args,
|
AST_DECLARE_APP_ARGS(args,
|
||||||
AST_APP_ARG(maxretries);
|
AST_APP_ARG(maxretries);
|
||||||
AST_APP_ARG(minlength);
|
AST_APP_ARG(minlength);
|
||||||
@@ -114,34 +105,14 @@ static int privacy_exec (struct ast_channel *chan, void *data)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!x)
|
/* Play unidentified call */
|
||||||
{
|
|
||||||
/*Read in the config file*/
|
|
||||||
cfg = ast_config_load(PRIV_CONFIG, config_flags);
|
|
||||||
|
|
||||||
if (cfg && (s = ast_variable_retrieve(cfg, "general", "maxretries"))) {
|
|
||||||
if (sscanf(s, "%d", &x) == 1)
|
|
||||||
maxretries = x;
|
|
||||||
else
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*Play unidentified call*/
|
|
||||||
res = ast_safe_sleep(chan, 1000);
|
res = ast_safe_sleep(chan, 1000);
|
||||||
if (!res)
|
if (!res)
|
||||||
res = ast_streamfile(chan, "privacy-unident", chan->language);
|
res = ast_streamfile(chan, "privacy-unident", chan->language);
|
||||||
if (!res)
|
if (!res)
|
||||||
res = ast_waitstream(chan, "");
|
res = ast_waitstream(chan, "");
|
||||||
|
|
||||||
/*Ask for 10 digit number, give 3 attempts*/
|
/* Ask for 10 digit number, give 3 attempts */
|
||||||
for (retries = 0; retries < maxretries; retries++) {
|
for (retries = 0; retries < maxretries; retries++) {
|
||||||
if (!res)
|
if (!res)
|
||||||
res = ast_streamfile(chan, "privacy-prompt", chan->language);
|
res = ast_streamfile(chan, "privacy-prompt", chan->language);
|
||||||
@@ -154,7 +125,7 @@ static int privacy_exec (struct ast_channel *chan, void *data)
|
|||||||
if (res < 0)
|
if (res < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*Make sure we get at least digits*/
|
/* Make sure we get at least digits */
|
||||||
if (strlen(phone) >= minlength )
|
if (strlen(phone) >= minlength )
|
||||||
break;
|
break;
|
||||||
else {
|
else {
|
||||||
@@ -164,7 +135,7 @@ static int privacy_exec (struct ast_channel *chan, void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Got a number, play sounds and send them on their way*/
|
/* Got a number, play sounds and send them on their way */
|
||||||
if ((retries < maxretries) && res >= 0 ) {
|
if ((retries < maxretries) && res >= 0 ) {
|
||||||
res = ast_streamfile(chan, "privacy-thankyou", chan->language);
|
res = ast_streamfile(chan, "privacy-thankyou", chan->language);
|
||||||
if (!res)
|
if (!res)
|
||||||
@@ -184,8 +155,6 @@ static int privacy_exec (struct ast_channel *chan, void *data)
|
|||||||
} else {
|
} else {
|
||||||
pbx_builtin_setvar_helper(chan, "PRIVACYMGRSTATUS", "FAILED");
|
pbx_builtin_setvar_helper(chan, "PRIVACYMGRSTATUS", "FAILED");
|
||||||
}
|
}
|
||||||
if (cfg)
|
|
||||||
ast_config_destroy(cfg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
[general]
|
|
||||||
|
|
||||||
maxretries = 2 ;How many chances the caller has to enter their number
|
|
||||||
Reference in New Issue
Block a user