diff options
author | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-02-14 20:55:48 +0000 |
---|---|---|
committer | mmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-02-14 20:55:48 +0000 |
commit | d9ba0d552e1022af1435fb83cc15cf445a7d4b16 (patch) | |
tree | 5d2bb66cc7c1f6396b1350dbf2362c04a4b24e47 /apps | |
parent | 7950914e3a811b6169e0400604a5753c8bb8d1a4 (diff) |
Fix the new message count if delete=yes when using IMAP storage.
(closes issue #11406)
Reported by: jaroth
Patches:
deleteflag_v2.patch uploaded by jaroth (license 50)
Tested by: jaroth
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@103688 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_voicemail.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 79eeb7b51..3d78ef407 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -379,7 +379,7 @@ static int play_record_review(struct ast_channel *chan, char *playfile, char *re signed char record_gain, struct vm_state *vms); static int vm_tempgreeting(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain); static int vm_play_folder_name(struct ast_channel *chan, char *mbox); -static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu, int msgnum, long duration, char *fmt, char *cidnum, char *cidname); +static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int msgnum, long duration, char *fmt, char *cidnum, char *cidname); static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, char *cidnum, char *cidname, char *attach, char *format, int duration, int attach_user_voicemail, struct ast_channel *chan, const char *category, int imap); #if !(defined(ODBC_STORAGE) || defined(IMAP_STORAGE)) static int __has_voicemail(const char *context, const char *mailbox, const char *folder, int shortcircuit); @@ -2643,7 +2643,7 @@ static int copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int i ast_log(LOG_ERROR, "Recipient mailbox %s@%s is full\n", recip->mailbox, recip->context); } ast_unlock_path(todir); - notify_new_message(chan, recip, recipmsgnum, duration, fmt, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL)); + notify_new_message(chan, recip, NULL, recipmsgnum, duration, fmt, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL)); return 0; } @@ -3172,7 +3172,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ } /* Notification and disposal needs to happen after the copy, though. */ if (ast_fileexists(fn, NULL, NULL)) { - notify_new_message(chan, vmu, msgnum, duration, fmt, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL)); + notify_new_message(chan, vmu, vms, msgnum, duration, fmt, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL)); DISPOSE(dir, msgnum); } } @@ -3917,7 +3917,7 @@ static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu, return cmd; } -static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu, int msgnum, long duration, char *fmt, char *cidnum, char *cidname) +static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, int msgnum, long duration, char *fmt, char *cidnum, char *cidname) { char todir[PATH_MAX], fn[PATH_MAX], ext_context[PATH_MAX], *stringp; int newmsgs = 0, oldmsgs = 0; @@ -3968,15 +3968,20 @@ static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu, DELETE(todir, msgnum, fn); } -#ifdef IMAP_STORAGE - DELETE(todir, msgnum, fn); -#endif /* Leave voicemail for someone */ if (ast_app_has_voicemail(ext_context, NULL)) { ast_app_inboxcount(ext_context, &newmsgs, &oldmsgs); } manager_event(EVENT_FLAG_CALL, "MessageWaiting", "Mailbox: %s@%s\r\nWaiting: %d\r\nNew: %d\r\nOld: %d\r\n", vmu->mailbox, vmu->context, ast_app_has_voicemail(ext_context, NULL), newmsgs, oldmsgs); run_externnotify(vmu->context, vmu->mailbox); + +#ifdef IMAP_STORAGE + DELETE(todir, msgnum, fn); /* Delete the file, but not the IMAP message */ + if (ast_test_flag(vmu, VM_DELETE)) { /* Delete the IMAP message if delete = yes */ + IMAP_DELETE(vms->curdir, vms->curmsg, vms->fn, vms); + vms->newmessages--; /* Fix new message count */ + } +#endif return 0; } |