mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-15 17:27:02 +00:00
issue #5625
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6985 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
* apps/app_enumlookup.c: Make priority jumping optional
|
* apps/app_enumlookup.c: Make priority jumping optional
|
||||||
* apps/app_groupcount.c: Add an exit status variable, make priority jumping optional, and use new args parsing macros
|
* apps/app_groupcount.c: Add an exit status variable, make priority jumping optional, and use new args parsing macros
|
||||||
* apps/app_image.c: Add an exit status variable, make priority jumping optional, and use new args parsing macros
|
* apps/app_image.c: Add an exit status variable, make priority jumping optional, and use new args parsing macros
|
||||||
|
* apps/app_hasnewvoicemail.c: Add an exit status variable, make priority jumping optional, and use new args parsing macros
|
||||||
|
|
||||||
2005-11-05 Kevin P. Fleming <kpfleming@digium.com>
|
2005-11-05 Kevin P. Fleming <kpfleming@digium.com>
|
||||||
|
|
||||||
|
@@ -44,23 +44,33 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|||||||
#include "asterisk/module.h"
|
#include "asterisk/module.h"
|
||||||
#include "asterisk/lock.h"
|
#include "asterisk/lock.h"
|
||||||
#include "asterisk/utils.h"
|
#include "asterisk/utils.h"
|
||||||
|
#include "asterisk/app.h"
|
||||||
|
#include "asterisk/options.h"
|
||||||
|
|
||||||
static char *tdesc = "Indicator for whether a voice mailbox has messages in a given folder.";
|
static char *tdesc = "Indicator for whether a voice mailbox has messages in a given folder.";
|
||||||
static char *app_hasvoicemail = "HasVoicemail";
|
static char *app_hasvoicemail = "HasVoicemail";
|
||||||
static char *hasvoicemail_synopsis = "Conditionally branches to priority + 101";
|
static char *hasvoicemail_synopsis = "Conditionally branches to priority + 101 with the right options set";
|
||||||
static char *hasvoicemail_descrip =
|
static char *hasvoicemail_descrip =
|
||||||
"HasVoicemail(vmbox[/folder][@context][|varname])\n"
|
"HasVoicemail(vmbox[/folder][@context][|varname[|options]])\n"
|
||||||
" Branches to priority + 101, if there is voicemail in folder indicated."
|
|
||||||
" Optionally sets <varname> to the number of messages in that folder."
|
" Optionally sets <varname> to the number of messages in that folder."
|
||||||
" Assumes folder of INBOX if not specified.\n";
|
" Assumes folder of INBOX if not specified.\n"
|
||||||
|
" The option string may contain zero or the following character:\n"
|
||||||
|
" 'j' -- jump to priority n+101, if there is voicemail in the folder indicated.\n"
|
||||||
|
" This application sets the following channel variable upon completion:\n"
|
||||||
|
" HASVMSTATUS The result of the voicemail check returned as a text string as follows\n"
|
||||||
|
" <# of messages in the folder, 0 for NONE>\n";
|
||||||
|
|
||||||
static char *app_hasnewvoicemail = "HasNewVoicemail";
|
static char *app_hasnewvoicemail = "HasNewVoicemail";
|
||||||
static char *hasnewvoicemail_synopsis = "Conditionally branches to priority + 101";
|
static char *hasnewvoicemail_synopsis = "Conditionally branches to priority + 101 with the right options set";
|
||||||
static char *hasnewvoicemail_descrip =
|
static char *hasnewvoicemail_descrip =
|
||||||
"HasNewVoicemail(vmbox[/folder][@context][|varname])\n"
|
"HasNewVoicemail(vmbox[/folder][@context][|varname[|options]])\n"
|
||||||
" Branches to priority + 101, if there is voicemail in folder 'folder' or INBOX.\n"
|
"Assumes folder 'INBOX' if folder is not specified. Optionally sets <varname> to the number of messages\n"
|
||||||
"if folder is not specified. Optionally sets <varname> to the number of messages\n"
|
"in that folder.\n"
|
||||||
"in that folder.\n";
|
" The option string may contain zero of the following character:\n"
|
||||||
|
" 'j' -- jump to priority n+101, if there is new voicemail in tolder 'folder' or INBOX\n"
|
||||||
|
" This application sets the following channel variable upon completion:\n"
|
||||||
|
" HASVMSTATUS The result of the new voicemail check returned as a text string as follows\n"
|
||||||
|
" <# of messages in the folder, 0 for NONE>\n";
|
||||||
|
|
||||||
STANDARD_LOCAL_USER;
|
STANDARD_LOCAL_USER;
|
||||||
|
|
||||||
@@ -90,10 +100,17 @@ static int hasvoicemail_internal(char *context, char *box, char *folder)
|
|||||||
static int hasvoicemail_exec(struct ast_channel *chan, void *data)
|
static int hasvoicemail_exec(struct ast_channel *chan, void *data)
|
||||||
{
|
{
|
||||||
struct localuser *u;
|
struct localuser *u;
|
||||||
char *temps, *input, *varname = NULL, *vmbox, *context = "default";
|
char *input, *varname = NULL, *vmbox, *context = "default";
|
||||||
char *vmfolder;
|
char *vmfolder;
|
||||||
int vmcount = 0;
|
int vmcount = 0;
|
||||||
static int dep_warning = 0;
|
static int dep_warning = 0;
|
||||||
|
int priority_jump = 0;
|
||||||
|
char tmp[12];
|
||||||
|
AST_DECLARE_APP_ARGS(args,
|
||||||
|
AST_APP_ARG(vmbox);
|
||||||
|
AST_APP_ARG(varname);
|
||||||
|
AST_APP_ARG(options);
|
||||||
|
);
|
||||||
|
|
||||||
if (!dep_warning) {
|
if (!dep_warning) {
|
||||||
ast_log(LOG_WARNING, "The applications HasVoicemail and HasNewVoicemail have been deprecated. Please use the VMCOUNT() function instead.\n");
|
ast_log(LOG_WARNING, "The applications HasVoicemail and HasNewVoicemail have been deprecated. Please use the VMCOUNT() function instead.\n");
|
||||||
@@ -101,7 +118,7 @@ static int hasvoicemail_exec(struct ast_channel *chan, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
ast_log(LOG_WARNING, "HasVoicemail requires an argument (vm-box[/folder][@context]|varname)\n");
|
ast_log(LOG_WARNING, "HasVoicemail requires an argument (vm-box[/folder][@context][|varname[|options]])\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,18 +131,13 @@ static int hasvoicemail_exec(struct ast_channel *chan, void *data)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
temps = input;
|
AST_STANDARD_APP_ARGS(args, input);
|
||||||
if ((temps = strsep(&input, "|"))) {
|
|
||||||
if (!ast_strlen_zero(input))
|
|
||||||
varname = input;
|
|
||||||
input = temps;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((vmbox = strsep(&input, "@")))
|
if ((vmbox = strsep(&args.vmbox, "@")))
|
||||||
if (!ast_strlen_zero(input))
|
if (!ast_strlen_zero(args.vmbox))
|
||||||
context = input;
|
context = args.vmbox;
|
||||||
if (!vmbox)
|
if (!vmbox)
|
||||||
vmbox = input;
|
vmbox = args.vmbox;
|
||||||
|
|
||||||
vmfolder = strchr(vmbox, '/');
|
vmfolder = strchr(vmbox, '/');
|
||||||
if (vmfolder) {
|
if (vmfolder) {
|
||||||
@@ -135,21 +147,31 @@ static int hasvoicemail_exec(struct ast_channel *chan, void *data)
|
|||||||
vmfolder = "INBOX";
|
vmfolder = "INBOX";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.options) {
|
||||||
|
if (strchr(args.options, 'j'))
|
||||||
|
priority_jump = 1;
|
||||||
|
}
|
||||||
|
|
||||||
vmcount = hasvoicemail_internal(context, vmbox, vmfolder);
|
vmcount = hasvoicemail_internal(context, vmbox, vmfolder);
|
||||||
/* Set the count in the channel variable */
|
/* Set the count in the channel variable */
|
||||||
if (varname) {
|
if (varname) {
|
||||||
char tmp[12];
|
|
||||||
snprintf(tmp, sizeof(tmp), "%d", vmcount);
|
snprintf(tmp, sizeof(tmp), "%d", vmcount);
|
||||||
pbx_builtin_setvar_helper(chan, varname, tmp);
|
pbx_builtin_setvar_helper(chan, varname, tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vmcount > 0) {
|
if (vmcount > 0) {
|
||||||
/* Branch to the next extension */
|
/* Branch to the next extension */
|
||||||
|
if (priority_jump || option_priority_jumping) {
|
||||||
if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
|
if (!ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
|
||||||
ast_log(LOG_WARNING, "VM box %s@%s has new voicemail, but extension %s, priority %d doesn't exist\n", vmbox, context, chan->exten, chan->priority + 101);
|
ast_log(LOG_WARNING, "VM box %s@%s has new voicemail, but extension %s, priority %d doesn't exist\n", vmbox, context, chan->exten, chan->priority + 101);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(tmp, sizeof(tmp), "%d", vmcount);
|
||||||
|
pbx_builtin_setvar_helper(chan, "HASVMSTATUS", tmp);
|
||||||
|
|
||||||
LOCAL_USER_REMOVE(u);
|
LOCAL_USER_REMOVE(u);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user