From: Matthew Jordan Date: Wed, 20 Feb 2013 19:10:42 +0000 (+0000) Subject: Let vm_mailbox_snapshot_create's combine option apply to "Urgent" as well X-Git-Tag: certified/1.8.15-cert2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed28f2194f606ed9f8f3fc4f43fa2950c928b2aa;p=thirdparty%2Fasterisk.git Let vm_mailbox_snapshot_create's combine option apply to "Urgent" as well The vm_mailbox_snapshot_create function has an option that combines the contents of INBOX and Old into a single snapshot. The intent of this is that both 'new' messages and 'deleted' messages are given in a single snapshot, as some applications prefer this view of the voicemail world. Unfortunately, the initial implementation ignored the "Urgent" folder. The "Urgent" folder is a pseudo-INBOX, in that new messages left with the 'U' flag will be placed in that folder as opposed to INBOX. Thus, the option failed the intent with which it was added. This patch makes it so that the "Urgent" folder is included in the snapshot when that option is used. git-svn-id: https://origsvn.digium.com/svn/asterisk/certified/branches/1.8.15@381834 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 5d03fb7a17..5ce34edbfd 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -14390,8 +14390,9 @@ static struct ast_vm_mailbox_snapshot *vm_mailbox_snapshot_create(const char *ma int i; int this_index_only = -1; int open = 0; - int inbox_index = 0; - int old_index = 1; + int inbox_index = get_folder_by_name("INBOX"); + int old_index = get_folder_by_name("Old"); + int urgent_index = get_folder_by_name("Urgent"); if (ast_strlen_zero(mailbox)) { ast_log(LOG_WARNING, "Cannot create a mailbox snapshot since no mailbox was specified\n"); @@ -14431,15 +14432,21 @@ static struct ast_vm_mailbox_snapshot *vm_mailbox_snapshot_create(const char *ma for (i = 0; i < mailbox_snapshot->folders; i++) { int combining_old = 0; - if ((i == old_index) && (combine_INBOX_and_OLD)) { + /* Assume we are combining folders if: + * - The current index is the old folder index OR + * - The current index is urgent and we were looking for INBOX OR + * - The current index is INBOX and we were looking for Urgent + */ + if ((i == old_index || (i == urgent_index && this_index_only == inbox_index) || (i == inbox_index && this_index_only == urgent_index)) && (combine_INBOX_and_OLD)) { combining_old = 1; } /* This if statement is confusing looking. Here is what it means in english. * - If a folder is given to the function and that folder's index is not the one we are iterating over, skip it... - * - Unless the folder provided is the INBOX folder and the current index is the OLD folder and we are combining OLD and INBOX msgs. + * - Unless we are combining old and new messages and the current index is one of old, new, or urgent folders */ - if ((this_index_only != -1) && (this_index_only != i) && !(combining_old && i == old_index && this_index_only == inbox_index)) { + if ((this_index_only != -1 && this_index_only != i) && + !(combining_old && (i == old_index || i == urgent_index || i == inbox_index))) { continue; }