diff options
author | jpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-04-20 17:43:35 +0000 |
---|---|---|
committer | jpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-04-20 17:43:35 +0000 |
commit | c90c956e840af19d7ea2e04ef4953eb2e8e60ee0 (patch) | |
tree | 87094cf1e9b4bd754716c20f5d57ee18c6ba4b8a | |
parent | f27fd86e2799bbc4582b2df9892f0e5e7197666a (diff) |
Merged revisions 258065 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r258065 | jpeeler | 2010-04-20 12:06:19 -0500 (Tue, 20 Apr 2010) | 17 lines
Merged revisions 258029 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r258029 | jpeeler | 2010-04-20 11:16:33 -0500 (Tue, 20 Apr 2010) | 11 lines
Play correct prompt when voicemail store failure occurs after attempted forward.
If a user's mailbox was full and a message was attempted to be forwarded to
said box, warnings on the console would indicate failure. However, the played
prompt was that of success (vm-msgsaved). Now storage failure is taken into
account and the correct prompt (vm-mailboxfull) is played when appropriate.
ABE-2123
SWP-1262
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.0@258104 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | apps/app_voicemail.c | 55 |
1 files changed, 37 insertions, 18 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 2633516a3..2a3b6b851 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -1474,6 +1474,26 @@ static int folder_int(const char *folder) return 0; } +static int imap_check_limits(struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu, int msgnum) +{ + /* Check if mailbox is full */ + check_quota(vms, imapfolder); + if (vms->quota_limit && vms->quota_usage >= vms->quota_limit) { + ast_debug(1, "*** QUOTA EXCEEDED!! %u >= %u\n", vms->quota_usage, vms->quota_limit); + ast_play_and_wait(chan, "vm-mailboxfull"); + return -1; + } + + /* Check if we have exceeded maxmsg */ + if (msgnum >= vmu->maxmsg - inprocess_count(vmu->mailbox, vmu->context, 0)) { + ast_log(LOG_WARNING, "Unable to leave message since we will exceed the maximum number of messages allowed (%u > %u)\n", msgnum, vmu->maxmsg); + ast_play_and_wait(chan, "vm-mailboxfull"); + return -1; + } + + return 0; +} + static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, int msgnum, struct ast_channel *chan, struct ast_vm_user *vmu, char *fmt, int duration, struct vm_state *vms) { char *myserveremail = serveremail; @@ -1486,11 +1506,15 @@ static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, i void *buf; int tempcopy = 0; STRING str; + int msgcount = (messagecount(vmu->context, vmu->mailbox, "INBOX") + messagecount(vmu->context, vmu->mailbox, "Old")); /* Back out early if this is a greeting and we don't want to store greetings in IMAP */ if (msgnum < 0 && !imapgreetings) { return 0; } + if (imap_check_limits(chan, vms, vmu, msgcount)) { + return -1; + } /* Attach only the first format */ fmt = ast_strdupa(fmt); @@ -4223,6 +4247,7 @@ static int has_voicemail(const char *mailbox, const char *folder) char fromdir[PATH_MAX], todir[PATH_MAX], frompath[PATH_MAX], topath[PATH_MAX]; const char *frombox = mbox(imbox); int recipmsgnum; + int res = 0; ast_log(LOG_NOTICE, "Copying message from %s@%s to %s@%s\n", vmu->mailbox, vmu->context, recip->mailbox, recip->context); @@ -4245,11 +4270,12 @@ static int has_voicemail(const char *mailbox, const char *folder) COPY(fromdir, msgnum, todir, recipmsgnum, recip->mailbox, recip->context, frompath, topath); } else { ast_log(LOG_ERROR, "Recipient mailbox %s@%s is full\n", recip->mailbox, recip->context); + res = -1; } ast_unlock_path(todir); 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; + return res; } #endif #if !(defined(IMAP_STORAGE) || defined(ODBC_STORAGE)) @@ -4650,22 +4676,10 @@ transfer: /* set variable for compatibility */ pbx_builtin_setvar_helper(chan, "VM_MESSAGEFILE", "IMAP_STORAGE"); - /* Check if mailbox is full */ - check_quota(vms, imapfolder); - if (vms->quota_limit && vms->quota_usage >= vms->quota_limit) { - ast_debug(1, "*** QUOTA EXCEEDED!! %u >= %u\n", vms->quota_usage, vms->quota_limit); - ast_play_and_wait(chan, "vm-mailboxfull"); - ast_free(tmp); - return -1; + if ((res = imap_check_limits(chan, vms, vmu, msgnum))) { + goto leave_vm_out; } - /* Check if we have exceeded maxmsg */ - if (msgnum >= vmu->maxmsg - inprocess_count(vmu->mailbox, vmu->context, 0)) { - ast_log(LOG_WARNING, "Unable to leave message since we will exceed the maximum number of messages allowed (%u > %u)\n", msgnum, vmu->maxmsg); - ast_play_and_wait(chan, "vm-mailboxfull"); - ast_free(tmp); - return -1; - } #else if (count_messages(vmu, dir) >= vmu->maxmsg - inprocess_count(vmu->mailbox, vmu->context, +1)) { res = ast_streamfile(chan, "vm-mailboxfull", chan->language); @@ -5875,6 +5889,7 @@ leave_vm_out: long duration = 0; char origmsgfile[PATH_MAX], msgfile[PATH_MAX]; struct vm_state vmstmp; + int copy_msg_result = 0; memcpy(&vmstmp, vms, sizeof(vmstmp)); make_file(origmsgfile, sizeof(origmsgfile), dir, curmsg); @@ -5902,7 +5917,7 @@ leave_vm_out: if (!dstvms->mailstream) { ast_log(LOG_ERROR, "IMAP mailstream for %s is NULL\n", vmtmp->mailbox); } else { - STORE(vmstmp.curdir, vmtmp->mailbox, vmtmp->context, dstvms->curmsg, chan, vmtmp, fmt, duration, dstvms); + copy_msg_result = STORE(vmstmp.curdir, vmtmp->mailbox, vmtmp->context, dstvms->curmsg, chan, vmtmp, fmt, duration, dstvms); run_externnotify(vmtmp->context, vmtmp->mailbox); } } else { @@ -5914,7 +5929,7 @@ leave_vm_out: /* NULL category for IMAP storage */ sendmail(myserveremail, vmtmp, todircount, vmtmp->context, vmtmp->mailbox, dstvms->curbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), vms->fn, fmt, duration, attach_user_voicemail, chan, NULL); #else - copy_message(chan, sender, -1, curmsg, duration, vmtmp, fmt, vmstmp.curdir); + copy_msg_result = copy_message(chan, sender, -1, curmsg, duration, vmtmp, fmt, vmstmp.curdir); #endif saved_messages++; AST_LIST_REMOVE_CURRENT(list); @@ -5923,7 +5938,7 @@ leave_vm_out: break; } AST_LIST_TRAVERSE_SAFE_END; - if (saved_messages > 0) { + if (saved_messages > 0 && !copy_msg_result) { /* give confirmation that the message was saved */ /* commented out since we can't forward batches yet if (saved_messages == 1) @@ -5935,6 +5950,10 @@ leave_vm_out: res = ast_play_and_wait(chan, "vm-msgsaved"); } #ifndef IMAP_STORAGE + else { + /* with IMAP, mailbox full warning played by imap_check_limits */ + res = ast_play_and_wait(chan, "vm-mailboxfull"); + } /* Restore original message without prepended message if backup exists */ make_file(msgfile, sizeof(msgfile), dir, curmsg); strcpy(textfile, msgfile); |