<p>Kevin Harwell <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/8442">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Jenkins2: Verified
Joshua Colp: Looks good to me, approved
Kevin Harwell: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">voicemail: Fixed wrong voicemail message count<br><br>Fixed wrong voicemail mailbox reference for Action: VoicemailUsersList.<br><br>ASTERISK-27703<br><br>Change-Id: Ie6578ad80bba2bfaf34b84f0be978f59045ce6cd<br>---<br>M apps/app_voicemail.c<br>1 file changed, 57 insertions(+), 17 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c<br>index 72e3e59..1e7d091 100644<br>--- a/apps/app_voicemail.c<br>+++ b/apps/app_voicemail.c<br>@@ -6089,22 +6089,33 @@<br> return 0;<br> }<br> <br>-<br>+/*!<br>+ * \brief Check the given mailbox's message count.<br>+ * \param mailbox The @ delimited string for user@context. If no context is found, uses 'default' for the context.<br>+ * \param urgentmsgs urgent message count.<br>+ * \param newmsgs new message count.<br>+ * \param oldmsgs old message count pointer<br>+ * \return -1 if error occurred, 0 otherwise.<br>+ */<br> static int inboxcount2(const char *mailbox, int *urgentmsgs, int *newmsgs, int *oldmsgs)<br> {<br> char tmp[256];<br> char *context;<br> <br> /* If no mailbox, return immediately */<br>- if (ast_strlen_zero(mailbox))<br>+ if (ast_strlen_zero(mailbox)) {<br> return 0;<br>+ }<br> <br>- if (newmsgs)<br>+ if (newmsgs) {<br> *newmsgs = 0;<br>- if (oldmsgs)<br>+ }<br>+ if (oldmsgs) {<br> *oldmsgs = 0;<br>- if (urgentmsgs)<br>+ }<br>+ if (urgentmsgs) {<br> *urgentmsgs = 0;<br>+ }<br> <br> if (strchr(mailbox, ',')) {<br> int tmpnew, tmpold, tmpurgent;<br>@@ -6114,15 +6125,18 @@<br> mb = tmp;<br> while ((cur = strsep(&mb, ", "))) {<br> if (!ast_strlen_zero(cur)) {<br>- if (inboxcount2(cur, urgentmsgs ? &tmpurgent : NULL, newmsgs ? &tmpnew : NULL, oldmsgs ? &tmpold : NULL))<br>+ if (inboxcount2(cur, urgentmsgs ? &tmpurgent : NULL, newmsgs ? &tmpnew : NULL, oldmsgs ? &tmpold : NULL)) {<br> return -1;<br>- else {<br>- if (newmsgs)<br>+ } else {<br>+ if (newmsgs) {<br> *newmsgs += tmpnew;<br>- if (oldmsgs)<br>+ }<br>+ if (oldmsgs) {<br> *oldmsgs += tmpold;<br>- if (urgentmsgs)<br>+ }<br>+ if (urgentmsgs) {<br> *urgentmsgs += tmpurgent;<br>+ }<br> }<br> }<br> }<br>@@ -6131,17 +6145,21 @@<br> <br> ast_copy_string(tmp, mailbox, sizeof(tmp));<br> <br>- if ((context = strchr(tmp, '@')))<br>+ if ((context = strchr(tmp, '@'))) {<br> *context++ = '\0';<br>- else<br>+ } else {<br> context = "default";<br>+ }<br> <br>- if (newmsgs)<br>+ if (newmsgs) {<br> *newmsgs = __has_voicemail(context, tmp, "INBOX", 0);<br>- if (oldmsgs)<br>+ }<br>+ if (oldmsgs) {<br> *oldmsgs = __has_voicemail(context, tmp, "Old", 0);<br>- if (urgentmsgs)<br>+ }<br>+ if (urgentmsgs) {<br> *urgentmsgs = __has_voicemail(context, tmp, "Urgent", 0);<br>+ }<br> <br> return 0;<br> }<br>@@ -13241,7 +13259,10 @@<br> poll_thread = AST_PTHREADT_NULL;<br> }<br> <br>-/*! \brief Append vmu info string into given astman with event_name. */<br>+/*!<br>+ * \brief Append vmu info string into given astman with event_name.<br>+ * \return 0 failed. 1 otherwise.<br>+*/<br> static int append_vmu_info_astman(<br> struct mansession *s,<br> struct ast_vm_user *vmu,<br>@@ -13251,14 +13272,33 @@<br> {<br> int new;<br> int old;<br>+ char *mailbox;<br>+ int ret;<br> <br> if((s == NULL) || (vmu == NULL) || (event_name == NULL) || (actionid == NULL)) {<br> ast_log(LOG_ERROR, "Wrong input parameter.");<br> return 0;<br> }<br> <br>+ /* create mailbox string */<br>+ if (!ast_strlen_zero(vmu->context)) {<br>+ ret = ast_asprintf(&mailbox, "%s@%s", vmu->mailbox, vmu->context);<br>+ } else {<br>+ ret = ast_asprintf(&mailbox, "%s", vmu->mailbox);<br>+ }<br>+ if (ret == -1) {<br>+ ast_log(LOG_ERROR, "Could not create mailbox string. err[%s]\n", strerror(errno));<br>+ return 0;<br>+ }<br>+<br> /* get mailbox count */<br>- inboxcount(vmu->mailbox, &new, &old);<br>+ ret = inboxcount(mailbox, &new, &old);<br>+ ast_free(mailbox);<br>+ if (ret == -1) {<br>+ ast_log(LOG_ERROR, "Could not get mailbox count. user[%s], context[%s]\n",<br>+ vmu->mailbox ?: "", vmu->context ?: "");<br>+ return 0;<br>+ }<br> <br> astman_append(s,<br> "Event: %s\r\n"<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8442">change 8442</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/8442"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ie6578ad80bba2bfaf34b84f0be978f59045ce6cd </div>
<div style="display:none"> Gerrit-Change-Number: 8442 </div>
<div style="display:none"> Gerrit-PatchSet: 5 </div>
<div style="display:none"> Gerrit-Owner: sungtae kim <pchero21@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: sungtae kim <pchero21@gmail.com> </div>