When counting urgent messages when using IMAP storage, take into account that
authorMark Michelson <mmichelson@digium.com>
Thu, 15 May 2008 15:40:29 +0000 (15:40 +0000)
committerMark Michelson <mmichelson@digium.com>
Thu, 15 May 2008 15:40:29 +0000 (15:40 +0000)
the urgent messages are not in their own folder but are actually "flagged" messages
in the INBOX.

(closes issue #12659)
Reported by: jaroth
Patches:
      urgentfolder_v2.patch uploaded by jaroth (license 50)
Tested by: jaroth

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@116594 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_voicemail.c

index 7c2cb9d..4bbcd8d 100644 (file)
@@ -3177,6 +3177,7 @@ static int messagecount(const char *context, const char *mailbox, const char *fo
        struct vm_state *vms_p;
        int ret = 0;
        int fold = folder_int(folder);
+       int urgent = 0;
        
        if (ast_strlen_zero(mailbox))
                return 0;
@@ -3225,6 +3226,12 @@ static int messagecount(const char *context, const char *mailbox, const char *fo
                vms_p = get_vm_state_by_mailbox(mailbox,0);
        }
 
+       /* If URGENT, then look at INBOX */
+       if (fold == 11) {
+               fold = NEW_FOLDER;
+               urgent = 1;
+       }
+
        if (!vms_p) {
                ast_debug(3,"Adding new vmstate for %s\n",vmu->imapuser);
                if (!(vms_p = ast_calloc(1, sizeof(*vms_p)))) {
@@ -3235,7 +3242,6 @@ static int messagecount(const char *context, const char *mailbox, const char *fo
                vms_p->mailstream = NIL; /* save for access from interactive entry point */
                ast_debug(3, "Copied %s to %s\n",vmu->imapuser,vms_p->imapuser);
                vms_p->updated = 1;
-               /* set mailbox to INBOX! */
                ast_copy_string(vms_p->curbox, mbox(fold), sizeof(vms_p->curbox));
                init_vm_state(vms_p);
                vmstate_insert(vms_p);
@@ -3261,7 +3267,7 @@ static int messagecount(const char *context, const char *mailbox, const char *fo
                        pgm->seen = 1;
                }
                /* look for urgent messages */
-               if (fold == 11) {
+               if (urgent == 1) {
                        pgm->flagged = 1;
                        pgm->unflagged = 0;
                }
@@ -3270,11 +3276,11 @@ static int messagecount(const char *context, const char *mailbox, const char *fo
 
                vms_p->vmArrayIndex = 0;
                mail_search_full (vms_p->mailstream, NULL, pgm, NIL);
-               if (fold == 0)
+               if (fold == 0 && urgent == 0)
                        vms_p->newmessages = vms_p->vmArrayIndex;
                if (fold == 1)
                        vms_p->oldmessages = vms_p->vmArrayIndex;
-               if(fold == 11)
+               if (fold == 0 && urgent == 1)
                        vms_p->urgentmessages = vms_p->vmArrayIndex;
                /*Freeing the searchpgm also frees the searchhdr*/
                mail_free_searchpgm(&pgm);