Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 130693) +++ apps/app_voicemail.c (working copy) @@ -141,6 +142,7 @@ static void write_file(char *filename, char *buffer, unsigned long len); static char *get_header_by_tag(char *header, char *tag, char *buf, size_t len); static void vm_imap_delete(int msgnum, struct vm_state *vms); +static void vm_imap_mark_read(int msgnum, struct vm_state *vms, int flag); static char *get_user_by_mailbox(char *mailbox, char *buf, size_t len); static struct vm_state *get_vm_state_by_imapuser(char *user, int interactive); static struct vm_state *get_vm_state_by_mailbox(const char *mailbox, int interactive); @@ -1272,6 +1274,28 @@ mail_setflag (vms->mailstream,arg,"\\DELETED"); } +static void vm_imap_mark_read(int msgnum, struct vm_state *vms, int flag) +{ + unsigned long messageNum = 0; + char arg[10]; + + /* find real message number based on msgnum */ + /* this may be an index into vms->msgArray based on the msgnum. */ + + messageNum = vms->msgArray[msgnum]; + if (messageNum == 0) { + ast_log(AST_LOG_WARNING, "msgnum %d, mailbox message %lu is zero.\n", msgnum, messageNum); + return; + } + /* mark message */ + snprintf (arg, sizeof(arg), "%lu",messageNum); + if (flag == 1) { /* mark seen */ + mail_setflag (vms->mailstream,arg,"\\SEEN"); + } else { + mail_setflag (vms->mailstream,arg,"\\UNSEEN"); + } +} + #endif static int make_file(char *dest, int len, char *dir, int num) { @@ -4244,8 +4268,14 @@ char sequence[10]; char mailbox[256]; - /* if save to Old folder, just leave in INBOX */ - if (box == 1) return 10; + /* if save to Old folder, put in INBOX as read */ + if (box == 1) { + vm_imap_mark_read(msg, vms, 1); /* explicitly mark as seen */ + box = 0; + /* return 10; */ + } else if (box == 0) { /* if save to INBOX, mark it as unread */ + vm_imap_mark_read(msg, vms, 0); /* explicitly mark as unseen */ + } /* get the real IMAP message number for this message */ snprintf(sequence, sizeof(sequence), "%ld", vms->msgArray[msg]); /* Create the folder if it don't exist */