support postfix options in voicemail apps (prefix options still supported using old syntax) (bug #4007)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5461 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming
2005-04-13 05:22:51 +00:00
parent b32b3c1e50
commit 30de08c187

View File

@@ -219,9 +219,9 @@ static char *synopsis_vm =
"Leave a voicemail message"; "Leave a voicemail message";
static char *descrip_vm = static char *descrip_vm =
" VoiceMail([s|u|b]extension[@context][&extension[@context]][...]): Leaves" " VoiceMail(extension[@context][&extension[@context]][...][|options]): Leaves"
"voicemail for a given extension (must be configured in voicemail.conf).\n" "voicemail for a given extension (must be configured in voicemail.conf).\n"
" If the extension is preceded by \n" " If the options contain: \n"
"* 's' then instructions for leaving the message will be skipped.\n" "* 's' then instructions for leaving the message will be skipped.\n"
"* 'u' then the \"unavailable\" message will be played.\n" "* 'u' then the \"unavailable\" message will be played.\n"
" (/var/lib/asterisk/sounds/vm/<exten>/unavail) if it exists.\n" " (/var/lib/asterisk/sounds/vm/<exten>/unavail) if it exists.\n"
@@ -241,11 +241,11 @@ static char *synopsis_vmain =
"Enter voicemail system"; "Enter voicemail system";
static char *descrip_vmain = static char *descrip_vmain =
" VoiceMailMain([[s]mailbox][@context]): Enters the main voicemail system\n" " VoiceMailMain([mailbox][@context][|options]): Enters the main voicemail system\n"
"for the checking of voicemail. The mailbox can be passed as the option,\n" "for the checking of voicemail. The mailbox can be passed in,\n"
"which will stop the voicemail system from prompting the user for the mailbox.\n" "which will stop the voicemail system from prompting the user for the mailbox.\n"
"If the mailbox is preceded by 's' then the password check will be skipped. If\n" "If the options contain 's' then the password check will be skipped. If\n"
"the mailbox is preceded by 'p' then the supplied mailbox is prepended to the\n" "the options contain 'p' then the supplied mailbox is prepended to the\n"
"user's entry and the resulting string is used as the mailbox number. This is\n" "user's entry and the resulting string is used as the mailbox number. This is\n"
"useful for virtual hosting of voicemail boxes. If a context is specified,\n" "useful for virtual hosting of voicemail boxes. If a context is specified,\n"
"logins are considered in that voicemail context only.\n" "logins are considered in that voicemail context only.\n"
@@ -4488,6 +4488,7 @@ static int vm_execmain(struct ast_channel *chan, void *data)
struct ast_vm_user *vmu = NULL, vmus; struct ast_vm_user *vmu = NULL, vmus;
char *context=NULL; char *context=NULL;
int silentexit = 0; int silentexit = 0;
char *options;
LOCAL_USER_ADD(u); LOCAL_USER_ADD(u);
memset(&vms, 0, sizeof(vms)); memset(&vms, 0, sizeof(vms));
@@ -4500,17 +4501,32 @@ static int vm_execmain(struct ast_channel *chan, void *data)
strncpy(tmp, data, sizeof(tmp) - 1); strncpy(tmp, data, sizeof(tmp) - 1);
ext = tmp; ext = tmp;
switch (*ext) { /* option 's': don't request a password */
case 's': /* option 'p': the supplied name is actually a prefix to be added to the mailbox
/* We should skip the user's password */ number entered by the user */
valid++; if ((options = strchr(ext, '|'))) {
ext++; *options++ = '\0';
break; while (*options)
case 'p': switch (*options++) {
/* We should prefix the mailbox with the supplied data */ case 's':
prefix++; valid++;
ext++; break;
break; case 'p':
prefix++;
break;
}
} else {
/* old style options parsing */
while (*ext) {
if (*ext == 's') {
valid++;
ext++;
} else if (*ext == 'p') {
prefix++;
ext++;
} else
break;
}
} }
context = strchr(ext, '@'); context = strchr(ext, '@');
@@ -4852,7 +4868,8 @@ static int vm_exec(struct ast_channel *chan, void *data)
{ {
int res=0, silent=0, busy=0, unavail=0; int res=0, silent=0, busy=0, unavail=0;
struct localuser *u; struct localuser *u;
char tmp[256], *ext; char tmp[256];
char *ext, *options;
LOCAL_USER_ADD(u); LOCAL_USER_ADD(u);
if (chan->_state != AST_STATE_UP) if (chan->_state != AST_STATE_UP)
@@ -4866,20 +4883,41 @@ static int vm_exec(struct ast_channel *chan, void *data)
if (ast_strlen_zero(tmp)) if (ast_strlen_zero(tmp))
return 0; return 0;
} }
ext = tmp;
while (*ext) { ext = tmp;
if (*ext == 's') { /* option 's': skip intro message with instructions */
silent = 2; /* option 'b': play 'busy' greeting */
ext++; /* option 'u': play 'unavailable' greeting */
} else if (*ext == 'b') { if ((options = strchr(ext, '|'))) {
busy=1; *options++ = '\0';
ext++; while (*options)
} else if (*ext == 'u') { switch (*options++) {
unavail=1; case 's':
ext++; silent = 2;
} else break;
break; case 'b':
} busy = 1;
break;
case 'u':
unavail = 1;
break;
}
} else {
/* old style options parsing */
while (*ext) {
if (*ext == 's') {
silent = 2;
ext++;
} else if (*ext == 'b') {
busy = 1;
ext++;
} else if (*ext == 'u') {
unavail = 1;
ext++;
} else
break;
}
}
res = leave_voicemail(chan, ext, silent, busy, unavail); res = leave_voicemail(chan, ext, silent, busy, unavail);
LOCAL_USER_REMOVE(u); LOCAL_USER_REMOVE(u);
return res; return res;
@@ -4925,26 +4963,15 @@ static int vm_box_exists(struct ast_channel *chan, void *data)
struct localuser *u; struct localuser *u;
struct ast_vm_user svm; struct ast_vm_user svm;
char *context, *box; char *context, *box;
char tmp[256];
if (!data || !strlen(data)) { if (!data || !(box = ast_strdupa(data))) {
ast_log(LOG_ERROR, "MailboxExists requires an argument: (vmbox[@context])\n"); ast_log(LOG_ERROR, "MailboxExists requires an argument: (vmbox[@context])\n");
return -1; return -1;
} else {
strncpy(tmp, data, sizeof(tmp) - 1);
} }
LOCAL_USER_ADD(u); LOCAL_USER_ADD(u);
box = tmp;
while (*box) {
if ((*box == 's') || (*box == 'b') || (*box == 'u')) {
box++;
} else
break;
}
context = strchr(tmp, '@'); if ((context = strchr(box, '@'))) {
if (context) {
*context = '\0'; *context = '\0';
context++; context++;
} }