<p>sungtae kim has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/8442">View Change</a></p><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, 47 insertions(+), 16 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/42/8442/1</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..cc786ba 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.\n<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,19 @@<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>+                           }<br>                             else {<br>-                                       if (newmsgs)<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 +6146,22 @@<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>+ }<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 +13261,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,6 +13274,8 @@<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>@@ -13258,7 +13283,13 @@<br>     }<br> <br>  /* get mailbox count */<br>-      inboxcount(vmu->mailbox, &new, &old);<br>+     ast_asprintf(&mailbox, "%s@%s", vmu->mailbox, vmu->context);<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]", 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: newchange </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: 1 </div>
<div style="display:none"> Gerrit-Owner: sungtae kim <pchero21@gmail.com> </div>