<p>George Joseph <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/16538">View Change</a></p><div style="white-space:pre-wrap">Approvals:
George Joseph: Looks good to me, but someone else must approve; Approved for Submit
Kevin Harwell: Looks good to me, approved
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">func_vmcount: Add support for multiple mailboxes<br><br>Allows multiple mailboxes to be specified for VMCOUNT<br>instead of just one.<br><br>ASTERISK-29661 #close<br><br>Change-Id: I9108528300795fd5b607efa9d4dd7b74be031813<br>---<br>A doc/CHANGES-staging/func_vmcount.txt<br>M funcs/func_vmcount.c<br>2 files changed, 23 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/CHANGES-staging/func_vmcount.txt b/doc/CHANGES-staging/func_vmcount.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..ba2a0a1</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/func_vmcount.txt</span><br><span>@@ -0,0 +1,3 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: func_vmcount</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Multiple mailboxes may now be specified instead of just one.</span><br><span>diff --git a/funcs/func_vmcount.c b/funcs/func_vmcount.c</span><br><span>index cb75110..6600703 100644</span><br><span>--- a/funcs/func_vmcount.c</span><br><span>+++ b/funcs/func_vmcount.c</span><br><span>@@ -44,10 +44,12 @@</span><br><span> /*** DOCUMENTATION</span><br><span> <function name="VMCOUNT" language="en_US"></span><br><span> <synopsis></span><br><span style="color: hsl(0, 100%, 40%);">- Count the voicemails in a specified mailbox.</span><br><span style="color: hsl(120, 100%, 40%);">+ Count the voicemails in a specified mailbox or mailboxes.</span><br><span> </synopsis></span><br><span> <syntax></span><br><span style="color: hsl(0, 100%, 40%);">- <parameter name="vmbox" required="true" /></span><br><span style="color: hsl(120, 100%, 40%);">+ <parameter name="vmbox" required="true" argsep="&"></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>A mailbox or list of mailboxes</para></span><br><span style="color: hsl(120, 100%, 40%);">+ </parameter></span><br><span> <parameter name="folder" required="false"></span><br><span> <para>If not specified, defaults to <literal>INBOX</literal></para></span><br><span> </parameter></span><br><span>@@ -56,12 +58,19 @@</span><br><span> <para>Count the number of voicemails in a specified mailbox, you could also specify</span><br><span> the mailbox <replaceable>folder</replaceable>.</para></span><br><span> <para>Example: <literal>exten => s,1,Set(foo=${VMCOUNT(125@default)})</literal></para></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>An ampersand-separated list of mailboxes may be specified to count voicemails in</span><br><span style="color: hsl(120, 100%, 40%);">+ multiple mailboxes. If a folder is specified, this will apply to all mailboxes specified.</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <example title="Multiple mailbox inbox count"></span><br><span style="color: hsl(120, 100%, 40%);">+ same => n,NoOp(${VMCOUNT(1234@default&1235@default&1236@default,INBOX)})</span><br><span style="color: hsl(120, 100%, 40%);">+ </example></span><br><span> </description></span><br><span> </function></span><br><span> ***/</span><br><span> </span><br><span> static int acf_vmcount_exec(struct ast_channel *chan, const char *cmd, char *argsstr, char *buf, size_t len)</span><br><span> {</span><br><span style="color: hsl(120, 100%, 40%);">+ int total = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ char *mailbox = NULL;</span><br><span> AST_DECLARE_APP_ARGS(args,</span><br><span> AST_APP_ARG(vmbox);</span><br><span> AST_APP_ARG(folder);</span><br><span>@@ -82,7 +91,15 @@</span><br><span> args.folder = "INBOX";</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- snprintf(buf, len, "%d", ast_app_messagecount(args.vmbox, args.folder));</span><br><span style="color: hsl(120, 100%, 40%);">+ while ((mailbox = strsep(&args.vmbox, "&"))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ int c;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_strlen_zero(mailbox)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ continue;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ c = ast_app_messagecount(mailbox, args.folder);</span><br><span style="color: hsl(120, 100%, 40%);">+ total += (c > 0 ? c : 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ snprintf(buf, len, "%d", total);</span><br><span> </span><br><span> return 0;</span><br><span> }</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/16538">change 16538</a>. To unsubscribe, or for help writing mail filters, 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/c/asterisk/+/16538"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 19 </div>
<div style="display:none"> Gerrit-Change-Id: I9108528300795fd5b607efa9d4dd7b74be031813 </div>
<div style="display:none"> Gerrit-Change-Number: 16538 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: N A <mail@interlinked.x10host.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>