--- asterisk-1.8.7.0/apps/app_voicemail.c 2011-09-06 14:48:03.000000000 +0100
+++ asterisk-1.8.7.0.vmi/apps/app_voicemail.c 2011-10-22 00:53:47.358347000 +0100
@@ -356,6 +356,50 @@
context.
+
+
+ Returns the selected attribute from a mailbox.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ If not specified, INBOX is assumed.
+
+
+
+ Returns the selected attribute from the specified mailbox.
+ If context is not specified, defaults to the default
+ context. Where the folder can be specified, common folders
+ include INBOX, Old, Work,
+ Family and Friends.
+
+
List All Voicemail User Information.
@@ -11013,11 +11057,79 @@
return 0;
}
+static int acf_vm_info(struct ast_channel *chan, const char *cmd, char *args, char *buf, size_t len)
+{
+ struct ast_vm_user *vmu = NULL;
+ char *tmp, *mbox, *context, *mbxfolder;
+ int res = 0;
+
+ AST_DECLARE_APP_ARGS(arg,
+ AST_APP_ARG(mailbox_context);
+ AST_APP_ARG(attribute);
+ AST_APP_ARG(folder);
+ );
+
+ buf[0] = '\0';
+
+ AST_STANDARD_APP_ARGS(arg, args);
+
+ if (ast_strlen_zero(arg.mailbox_context) || ast_strlen_zero(arg.attribute)) {
+ ast_log(LOG_ERROR, "VM_INFO requires an argument ([@],attribute[,folder])\n");
+ return -1;
+ }
+
+ tmp = ast_strdupa(arg.mailbox_context);
+ mbox = strsep(&tmp, "@");
+ context = strsep(&tmp, "");
+
+ if (ast_strlen_zero(context)) {
+ context = "default";
+ }
+
+ vmu = find_user(NULL, context, mbox);
+
+ if (!strncasecmp(arg.attribute, "exists", 5)) {
+ ast_copy_string(buf, vmu ? "1" : "0", len);
+ return 0;
+ }
+
+ if (vmu) {
+ if (!strncasecmp(arg.attribute, "password", 8)) {
+ ast_copy_string(buf, vmu->password, len);
+ } else if (!strncasecmp(arg.attribute, "fullname", 8)) {
+ ast_copy_string(buf, vmu->fullname, len);
+ } else if (!strncasecmp(arg.attribute, "email", 5)) {
+ ast_copy_string(buf, vmu->email, len);
+ } else if (!strncasecmp(arg.attribute, "pager", 5)) {
+ ast_copy_string(buf, vmu->pager, len);
+ } else if (!strncasecmp(arg.attribute, "count", 5)) {
+ /* If mbxfolder is empty messagecount will default to INBOX */
+ mbxfolder = ast_strdupa(S_OR(arg.folder, ""));
+ res = messagecount(context, mbox, mbxfolder);
+ if (res < 0) {
+ ast_log(LOG_ERROR, "Unable to retrieve message count for mailbox %s\n", arg.mailbox_context);
+ return -1;
+ }
+ snprintf(buf, len, "%d", res);
+ } else {
+ ast_log(LOG_ERROR, "Unknown attribute '%s' for VM_INFO\n", arg.attribute);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
static struct ast_custom_function mailbox_exists_acf = {
.name = "MAILBOX_EXISTS",
.read = acf_mailbox_exists,
};
+static struct ast_custom_function vm_info_acf = {
+ .name = "VM_INFO",
+ .read = acf_vm_info,
+};
+
static int vmauthenticate(struct ast_channel *chan, const char *data)
{
char *s, *user = NULL, *context = NULL, mailbox[AST_MAX_EXTENSION] = "";
@@ -12925,6 +13037,7 @@
res |= ast_unregister_application(app4);
res |= ast_unregister_application(sayname_app);
res |= ast_custom_function_unregister(&mailbox_exists_acf);
+ res |= ast_custom_function_unregister(&vm_info_acf);
res |= ast_manager_unregister("VoicemailUsersList");
res |= ast_data_unregister(NULL);
#ifdef TEST_FRAMEWORK
@@ -12975,6 +13088,7 @@
res |= ast_register_application_xml(app4, vmauthenticate);
res |= ast_register_application_xml(sayname_app, vmsayname_exec);
res |= ast_custom_function_register(&mailbox_exists_acf);
+ res |= ast_custom_function_register(&vm_info_acf);
res |= ast_manager_register_xml("VoicemailUsersList", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, manager_list_voicemail_users);
#ifdef TEST_FRAMEWORK
res |= AST_TEST_REGISTER(test_voicemail_vmsayname);