diff --recursive --unified asterisk-1.4.24.1.orig/apps/app_voicemail.c asterisk-1.4.24.1.new/apps/app_voicemail.c --- asterisk-1.4.24.1.orig/apps/app_voicemail.c 2009-04-26 23:23:22.000000000 -0400 +++ asterisk-1.4.24.1.new/apps/app_voicemail.c 2009-04-27 05:12:49.000000000 -0400 @@ -518,6 +518,16 @@ " Options:\n" " j - Jump to priority n+101 if the mailbox is found.\n"; +static char *synopsis_play_name_of = +"Play the recorded name of a Voicemail mailbox"; + +static char *descrip_play_name_of = +" PlayNameOf(mailbox[@context]): Play the recorded name of a mailbox.\n" +" This application will set the following channel variable upon completion:\n" +" VMBOXPLAYNAMESTATUS - This will contain the status of the execution of the\n" +" PlayNameOf. Possible values include:\n" +" SUCCESS | NO_SUCH_MAILBOX | NO_NAME_RECORDED \n\n"; + static char *synopsis_vmauthenticate = "Authenticate with Voicemail passwords"; @@ -540,6 +550,8 @@ static char *app3 = "MailboxExists"; static char *app4 = "VMAuthenticate"; +static char *app5 = "PlayNameOf"; + static AST_LIST_HEAD_STATIC(users, ast_vm_user); static AST_LIST_HEAD_STATIC(zones, vm_zone); static char zonetag[80]; @@ -8000,6 +8012,50 @@ return 0; } +static int play_name_of(struct ast_channel *chan, void *data) +{ + int res = 0; + struct ast_module_user *u; + struct ast_vm_user svm; + char *context, *box; + char prefile[PATH_MAX] = ""; + AST_DECLARE_APP_ARGS(args, + AST_APP_ARG(mbox); + ); + + if (ast_strlen_zero(data)) { + ast_log(LOG_ERROR, "PlayNameOf requires an argument: (vmbox[@context])\n"); + return -1; + } + + u = ast_module_user_add(chan); + + box = ast_strdupa(data); + + AST_STANDARD_APP_ARGS(args, box); + + if ((context = strchr(args.mbox, '@'))) { + *context = '\0'; + context++; + } + + if (find_user(&svm, context, args.mbox)) { + snprintf(prefile, sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, context, args.mbox); + if ( (!ast_strlen_zero(prefile)) && (ast_fileexists(prefile, NULL, NULL) > 0) ) { + if (option_verbose > 2) + ast_verbose(VERBOSE_PREFIX_3 "Playing recorded name for mailbox %s\n", args.mbox); + res = ast_stream_and_wait(chan, prefile, chan->language, ""); + pbx_builtin_setvar_helper(chan, "VMBOXPLAYNAMESTATUS", "SUCCESS"); + } else { + pbx_builtin_setvar_helper(chan, "VMBOXPLAYNAMESTATUS", "NO_NAME_RECORDED"); + } + } else + pbx_builtin_setvar_helper(chan, "VMBOXPLAYNAMESTATUS", "NO_SUCH_MAILBOX"); + + ast_module_user_remove(u); + return 0; +} + static int vmauthenticate(struct ast_channel *chan, void *data) { struct ast_module_user *u; @@ -8793,6 +8849,7 @@ res |= ast_register_application(app2, vm_execmain, synopsis_vmain, descrip_vmain); res |= ast_register_application(app3, vm_box_exists, synopsis_vm_box_exists, descrip_vm_box_exists); res |= ast_register_application(app4, vmauthenticate, synopsis_vmauthenticate, descrip_vmauthenticate); + res |= ast_register_application(app5, play_name_of, synopsis_play_name_of, descrip_play_name_of); if (res) return(res);