aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_voicemail.c
diff options
context:
space:
mode:
authorjpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-15 20:32:52 +0000
committerjpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-15 20:32:52 +0000
commited5723d2b55d3b3e300f6a7bed7727fc69a61b34 (patch)
tree46e5503a192ad01664e597a42e7a0a46b40e9c6f /apps/app_voicemail.c
parent70546b85ab7d34d156bf3107ddc7eb52e016ab69 (diff)
Merged revisions 286998 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2 ................ r286998 | jpeeler | 2010-09-15 15:28:02 -0500 (Wed, 15 Sep 2010) | 14 lines Merged revisions 286941 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r286941 | jpeeler | 2010-09-15 15:08:52 -0500 (Wed, 15 Sep 2010) | 7 lines Ensure mailbox is not filled to capacity before doing message forwarding. Specifically, before prompting to record a prepended message the capacity is checked first. If the mailbox is full the extension will be reprompted. ABE-2517 ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.8@287015 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_voicemail.c')
-rw-r--r--apps/app_voicemail.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 8f0a5bd82..87bfcabfb 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -6906,7 +6906,7 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
AST_LIST_HEAD_NOLOCK_STATIC(extensions, ast_vm_user);
char *stringp;
const char *s;
- int saved_messages = 0, found = 0;
+ int saved_messages = 0;
int valid_extensions = 0;
char *dir;
int curmsg;
@@ -7014,8 +7014,29 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
valid_extensions = 1;
while (s) {
if ((is_new_message == 1 || strcmp(s, sender->mailbox)) && (receiver = find_user(NULL, context, s))) {
+ int oldmsgs;
+ int newmsgs;
+ int capacity;
+ if (inboxcount(s, &newmsgs, &oldmsgs)) {
+ ast_log(LOG_ERROR, "Problem in calculating number of voicemail messages available for extension %s\n", s);
+ /* Shouldn't happen, but allow trying another extension if it does */
+ res = ast_play_and_wait(chan, "pbx-invalid");
+ valid_extensions = 0;
+ break;
+ }
+ capacity = receiver->maxmsg - inprocess_count(receiver->mailbox, receiver->context, +1);
+ if ((newmsgs + oldmsgs) >= capacity) {
+ ast_log(LOG_NOTICE, "Mailbox '%s' is full with capacity of %d, prompting for another extension.\n", s, capacity);
+ res = ast_play_and_wait(chan, "vm-mailboxfull");
+ valid_extensions = 0;
+ while ((vmtmp = AST_LIST_REMOVE_HEAD(&extensions, list))) {
+ inprocess_count(vmtmp->mailbox, vmtmp->context, -1);
+ free_user(vmtmp);
+ }
+ inprocess_count(receiver->mailbox, receiver->context, -1);
+ break;
+ }
AST_LIST_INSERT_HEAD(&extensions, receiver, list);
- found++;
} else {
/* XXX Optimization for the future. When we encounter a single bad extension,
* bailing out on all of the extensions may not be the way to go. We should
@@ -7026,6 +7047,8 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
free_user(receiver);
}
ast_log(LOG_NOTICE, "'%s' is not a valid mailbox\n", s);
+ /* "I am sorry, that's not a valid extension. Please try again." */
+ res = ast_play_and_wait(chan, "pbx-invalid");
valid_extensions = 0;
break;
}
@@ -7049,8 +7072,6 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
/* break from the loop of reading the extensions */
if (valid_extensions)
break;
- /* "I am sorry, that's not a valid extension. Please try again." */
- res = ast_play_and_wait(chan, "pbx-invalid");
}
/* check if we're clear to proceed */
if (AST_LIST_EMPTY(&extensions) || !valid_extensions)
@@ -7111,6 +7132,7 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
#endif
saved_messages++;
AST_LIST_REMOVE_CURRENT(list);
+ inprocess_count(vmtmp->mailbox, vmtmp->context, -1);
free_user(vmtmp);
if (res)
break;
@@ -7154,8 +7176,10 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
}
/* If anything failed above, we still have this list to free */
- while ((vmtmp = AST_LIST_REMOVE_HEAD(&extensions, list)))
+ while ((vmtmp = AST_LIST_REMOVE_HEAD(&extensions, list))) {
+ inprocess_count(vmtmp->mailbox, vmtmp->context, -1);
free_user(vmtmp);
+ }
return res ? res : cmd;
}