Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 47867) +++ apps/app_voicemail.c (working copy) @@ -7056,6 +7056,42 @@ voicemail_show_zones_help, NULL, NULL }, }; +static int manager_list_voicemail_users(struct mansession *s, struct message *m) +{ + struct ast_vm_user *vmu; + char *output_format = "context: %s\nmailbox: %s\nfullname: %s\nemail: %s\npager: %s\nserveremail: %s\nmailcmd: %s\nlanguage: %s\nzontag: %s\ncallback: %s\ndialout: %s\nuniqueid: %s\nexit: %s\nattachfmt: %s\nsaydurationm: %i\nmaxmsg: %i\nmsg count: %s\r\n\r\n"; + + AST_LIST_LOCK(&users); + if (!AST_LIST_EMPTY(&users)) { + astman_send_ack(s, m, "Results follows:"); + AST_LIST_TRAVERSE(&users, vmu, list) { + char dirname[256]; + DIR *vmdir; + struct dirent *vment; + int vmcount = 0; + char count[12]; + + make_dir(dirname, 255, vmu->context, vmu->mailbox, "INBOX"); + if ((vmdir = opendir(dirname))) { + /* No matter what the format of VM, there will always be a .txt file for each message. */ + while ((vment = readdir(vmdir))) + if (strlen(vment->d_name) > 7 && !strncmp(vment->d_name + 7,".txt",4)) + vmcount++; + closedir(vmdir); + } + snprintf(count,sizeof(count),"%d",vmcount); + astman_append(s, output_format, vmu->context, vmu->mailbox, vmu->fullname, vmu->email, vmu->pager, vmu->serveremail, vmu->mailcmd, vmu->language, vmu->zonetag, vmu->callback, vmu->dialout, vmu->uniqueid, vmu->exit, vmu->attachfmt, vmu->saydurationm, vmu->maxmsg, count); + } + } else { + astman_send_ack(s, m, "There are no voicemail users currently defined."); + ast_log(LOG_NOTICE, "There are no voicemail users currently defined.\n"); + AST_LIST_UNLOCK(&users); + return RESULT_FAILURE; + } + AST_LIST_UNLOCK(&users); + return RESULT_SUCCESS; +} + static int load_config(void) { struct ast_vm_user *cur; @@ -7639,6 +7675,7 @@ res |= ast_unregister_application(app3); res |= ast_unregister_application(app4); res |= ast_custom_function_unregister(&mailbox_exists_acf); + res |= ast_manager_unregister("ListAllVoicemailUsers"); ast_cli_unregister_multiple(cli_voicemail, sizeof(cli_voicemail) / sizeof(struct ast_cli_entry)); ast_uninstall_vm_functions(); @@ -7655,6 +7692,7 @@ 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); + res |= ast_manager_register("ListAllVoicemailUsers", EVENT_FLAG_CALL, manager_list_voicemail_users, "List All Voicemail User Information"); if (res) return(res);