[Asterisk-code-review] Add new AMI action for app voicemail (asterisk[master])
sungtae kim
asteriskteam at digium.com
Fri Dec 8 06:54:37 CST 2017
sungtae kim has uploaded this change for review. ( https://gerrit.asterisk.org/7494
Change subject: Add new AMI action for app_voicemail
......................................................................
Add new AMI action for app_voicemail
Currently, to figure out specified voicemail's status, there's only one
way to do it, which is use a VoicemailUserEntry AMI message.
But it consumed it too much resource(it check everything).
So, added new AMI action.
ASTERISK-27470
Change-Id: Ie4eba1424a142e5fbd1d9fb1821a3fc1a1e238b7
---
M apps/app_voicemail.c
1 file changed, 129 insertions(+), 0 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/94/7494/1
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index d017301..a2c8237 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -13258,6 +13258,133 @@
return RESULT_SUCCESS;
}
+static int manager_status_voicemail_user(struct mansession *s, const struct message *m)
+{
+ struct ast_vm_user *vmu = NULL;
+ const char *id = astman_get_header(m, "ActionID");
+ char actionid[128];
+ struct ast_vm_user svm;
+ int new, old;
+
+ const char *context = astman_get_header(m, "Context");
+ const char *mailbox = astman_get_header(m, "Mailbox");
+
+ if ((ast_strlen_zero(context) || ast_strlen_zero(mailbox))) {
+ astman_send_error(s, m, "Need 'Context' and 'Mailbox' parameters.");
+ return 0;
+ }
+
+ actionid[0] = '\0';
+ if (!ast_strlen_zero(id)) {
+ snprintf(actionid, sizeof(actionid), "ActionID: %s\r\n", id);
+ }
+
+ AST_LIST_LOCK(&users);
+
+ // no any voicemail user
+ if (AST_LIST_EMPTY(&users)) {
+ astman_send_ack(s, m, "There are no voicemail user currently defined.");
+ AST_LIST_UNLOCK(&users);
+ return RESULT_SUCCESS;
+ }
+
+ // find user
+ memset(&svm, 0, sizeof(svm));
+ vmu = find_user(&svm, context, mailbox);
+ if (!vmu) {
+ // could not find it
+ astman_send_ack(s, m, "There are no voicemail user of given info.");
+ AST_LIST_UNLOCK(&users);
+ return RESULT_SUCCESS;
+ }
+
+ astman_send_listack(s, m, "Voicemail user detail will follow", "start");
+
+ // get mailbox count
+ inboxcount(vmu->mailbox, &new, &old);
+
+ astman_append(s,
+ "Event: VoicemailUserDetail\r\n"
+ "%s"
+ "VMContext: %s\r\n"
+ "VoiceMailbox: %s\r\n"
+ "Fullname: %s\r\n"
+ "Email: %s\r\n"
+ "Pager: %s\r\n"
+ "ServerEmail: %s\r\n"
+ "FromString: %s\r\n"
+ "MailCommand: %s\r\n"
+ "Language: %s\r\n"
+ "TimeZone: %s\r\n"
+ "Callback: %s\r\n"
+ "Dialout: %s\r\n"
+ "UniqueID: %s\r\n"
+ "ExitContext: %s\r\n"
+ "SayDurationMinimum: %d\r\n"
+ "SayEnvelope: %s\r\n"
+ "SayCID: %s\r\n"
+ "AttachMessage: %s\r\n"
+ "AttachmentFormat: %s\r\n"
+ "DeleteMessage: %s\r\n"
+ "VolumeGain: %.2f\r\n"
+ "CanReview: %s\r\n"
+ "CallOperator: %s\r\n"
+ "MaxMessageCount: %d\r\n"
+ "MaxMessageLength: %d\r\n"
+ "NewMessageCount: %d\r\n"
+ "OldMessageCount: %d\r\n"
+#ifdef IMAP_STORAGE
+ "IMAPUser: %s\r\n"
+ "IMAPServer: %s\r\n"
+ "IMAPPort: %s\r\n"
+ "IMAPFlags: %s\r\n"
+#endif
+ "\r\n",
+ actionid,
+ vmu->context,
+ vmu->mailbox,
+ vmu->fullname,
+ vmu->email,
+ vmu->pager,
+ ast_strlen_zero(vmu->serveremail) ? serveremail : vmu->serveremail,
+ ast_strlen_zero(vmu->fromstring) ? fromstring : vmu->fromstring,
+ mailcmd,
+ vmu->language,
+ vmu->zonetag,
+ vmu->callback,
+ vmu->dialout,
+ vmu->uniqueid,
+ vmu->exit,
+ vmu->saydurationm,
+ ast_test_flag(vmu, VM_ENVELOPE) ? "Yes" : "No",
+ ast_test_flag(vmu, VM_SAYCID) ? "Yes" : "No",
+ ast_test_flag(vmu, VM_ATTACH) ? "Yes" : "No",
+ vmu->attachfmt,
+ ast_test_flag(vmu, VM_DELETE) ? "Yes" : "No",
+ vmu->volgain,
+ ast_test_flag(vmu, VM_REVIEW) ? "Yes" : "No",
+ ast_test_flag(vmu, VM_OPERATOR) ? "Yes" : "No",
+ vmu->maxmsg,
+ vmu->maxsecs,
+ new,
+ old
+#ifdef IMAP_STORAGE
+ ,
+ vmu->imapuser,
+ vmu->imapserver,
+ vmu->imapport,
+ vmu->imapflags
+#endif
+ );
+
+ astman_send_list_complete_start(s, m, "VoicemailUserDetailComplete", 1);
+ astman_send_list_complete_end(s);
+
+ AST_LIST_UNLOCK(&users);
+
+ return RESULT_SUCCESS;
+}
+
/*! \brief Manager list voicemail users command */
static int manager_list_voicemail_users(struct mansession *s, const struct message *m)
{
@@ -14891,6 +15018,7 @@
res |= ast_custom_function_unregister(&mailbox_exists_acf);
res |= ast_custom_function_unregister(&vm_info_acf);
res |= ast_manager_unregister("VoicemailUsersList");
+ res |= ast_manager_unregister("VoicemailUserStatus");
res |= ast_manager_unregister("VoicemailRefresh");
#ifdef TEST_FRAMEWORK
res |= AST_TEST_UNREGISTER(test_voicemail_vmsayname);
@@ -14968,6 +15096,7 @@
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);
+ res |= ast_manager_register_xml("VoicemailUserStatus", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, manager_status_voicemail_user);
res |= ast_manager_register_xml("VoicemailRefresh", EVENT_FLAG_USER, manager_voicemail_refresh);
#ifdef TEST_FRAMEWORK
res |= AST_TEST_REGISTER(test_voicemail_vmsayname);
--
To view, visit https://gerrit.asterisk.org/7494
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie4eba1424a142e5fbd1d9fb1821a3fc1a1e238b7
Gerrit-Change-Number: 7494
Gerrit-PatchSet: 1
Gerrit-Owner: sungtae kim <pchero21 at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171208/65ffcf74/attachment-0001.html>
More information about the asterisk-code-review
mailing list