Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 37143) +++ apps/app_voicemail.c (working copy) @@ -5949,6 +5949,7 @@ AST_APP_ARG(mbox); AST_APP_ARG(options); ); + static int dep_warning = 0; if (ast_strlen_zero(data)) { ast_log(LOG_ERROR, "MailboxExists requires an argument: (vmbox[@context][|options])\n"); @@ -5957,6 +5958,11 @@ LOCAL_USER_ADD(u); + if (!dep_warning) { + dep_warning = 1; + ast_log(LOG_WARNING, "MailboxExists is deprecated. Please use ${MAILBOX_EXISTS(%s)} instead.\n", (char *)data); + } + box = ast_strdupa(data); AST_STANDARD_APP_ARGS(args, box); @@ -5982,6 +5988,30 @@ return 0; } +int acf_mailbox_exists(struct ast_channel *chan, char *cmd, char *args, char *buf, size_t len) +{ + struct ast_vm_user svm; + AST_DECLARE_APP_ARGS(arg, + AST_APP_ARG(mbox); + AST_APP_ARG(context); + ); + + AST_NONSTANDARD_APP_ARGS(arg, args, '@'); + + ast_copy_string(buf, find_user(&svm, ast_strlen_zero(arg.context) ? "default" : arg.context, arg.mbox) ? "1" : "0", len); + return 0; +} + +static struct ast_custom_function mailbox_exists_acf = { + .name = "MAILBOX_EXISTS", + .synopsis = "Tell if a mailbox is configured", + .desc = +"Returns a boolean of whether the corresponding mailbox exists. If context\n" +"is not specified, defaults to the \"default\" context.\n", + .syntax = "MAILBOX_EXISTS([@])", + .read = acf_mailbox_exists, +}; + static int vmauthenticate(struct ast_channel *chan, void *data) { struct localuser *u; @@ -6610,6 +6640,8 @@ res |= ast_unregister_application(app4); res |= ast_cli_unregister(&show_voicemail_users_cli); res |= ast_cli_unregister(&show_voicemail_zones_cli); + res |= ast_custom_function_unregister(&mailbox_exists_acf); + ast_uninstall_vm_functions(); STANDARD_HANGUP_LOCALUSERS; @@ -6624,6 +6656,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_custom_function_register(&mailbox_exists_acf); if (res) return(res);