[asterisk-commits] mmichelson: trunk r94542 - in /trunk: ./ apps/app_voicemail.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Dec 21 14:18:27 CST 2007


Author: mmichelson
Date: Fri Dec 21 14:18:26 2007
New Revision: 94542

URL: http://svn.digium.com/view/asterisk?view=rev&rev=94542
Log:
Merged revisions 94540 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r94540 | mmichelson | 2007-12-21 14:11:34 -0600 (Fri, 21 Dec 2007) | 8 lines

Better quota support for using IMAP storage voicemail

(closes issue #11415, reported by jaroth)
(closes issue #11152, reported by selsky)

Patch provided by jaroth


........

Modified:
    trunk/   (props changed)
    trunk/apps/app_voicemail.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=94542&r1=94541&r2=94542
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Fri Dec 21 14:18:26 2007
@@ -156,6 +156,8 @@
 static int imap_remove_file (char *dir, int msgnum);
 static int imap_retrieve_file (char *dir, int msgnum, const char *mailbox, char *context);
 static int imap_delete_old_greeting (char *dir, struct vm_state *vms);
+static void check_quota(struct vm_state *vms, char *mailbox);
+static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu,int box);
 struct vmstate {
 	struct vm_state *vms;
 	AST_LIST_ENTRY(vmstate) list;
@@ -3193,13 +3195,19 @@
 		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");
 			return -1;
 		}
-		/* here is a big difference! We add one to it later */
-		ast_debug(3, "Messagecount set to %d\n",msgnum);
+		
+		/* Check if we have exceeded maxmsg */
+		if (msgnum >= vmu->maxmsg) {
+			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;
+		}
 
 #else
 		if (count_messages(vmu, dir) >= vmu->maxmsg) {
@@ -4969,7 +4977,6 @@
 	SEARCHPGM *pgm;
 	SEARCHHEADER *hdr;
 	int ret;
-	char dbox[256];
 
 	ast_copy_string(vms->imapuser,vmu->imapuser, sizeof(vms->imapuser));
 	ast_debug(3,"Before init_mailstream, user is %s\n",vmu->imapuser);
@@ -4983,6 +4990,12 @@
 	mail_parameters(NULL, SET_QUOTA, (void *) mm_parsequota);
 	imap_mailbox_name(dbox, sizeof(dbox), vms, box, 1);
 	imap_getquotaroot(vms->mailstream, dbox);
+
+	/* Check Quota */
+	if  (box == 0)  {
+		ast_debug(3, "Mailbox name set to: %s, about to check quotas\n", mbox(box));
+		check_quota(vms,(char *)mbox(box));
+	}
 
 	pgm = mail_newsearchpgm();
 
@@ -7031,6 +7044,11 @@
 		ast_debug(3, "Checking quotas: comparing %u to %u\n",vms.quota_usage,vms.quota_limit);
 		if (vms.quota_limit && vms.quota_usage >= vms.quota_limit) {
 			ast_debug(1, "*** QUOTA EXCEEDED!!\n");
+			cmd = ast_play_and_wait(chan, "vm-mailboxfull");
+		}
+		ast_debug(3, "Checking quotas: User has %d messages and limit is %d.\n",(vms.newmessages + vms.oldmessages),vmu->maxmsg);
+		if ((vms.newmessages + vms.oldmessages) >= vmu->maxmsg) {
+			ast_log(LOG_WARNING, "No more messages possible.  User has %d messages and limit is %d.\n",(vms.newmessages + vms.oldmessages),vmu->maxmsg);
 			cmd = ast_play_and_wait(chan, "vm-mailboxfull");
 		}
 #endif
@@ -9690,6 +9708,17 @@
 	mail_list(stream, tmp, "*");
 }
 
+/* Check Quota for user */
+static void check_quota(struct vm_state *vms, char *mailbox) {
+	mail_parameters(NULL, SET_QUOTA, (void *) mm_parsequota);
+	ast_debug(3, "Mailbox name set to: %s, about to check quotas\n", mailbox);
+	if (vms && vms->mailstream != NULL) {
+		imap_getquotaroot(vms->mailstream, mailbox);
+	} else {
+		ast_log(LOG_WARNING,"Mailstream not available for mailbox: %s\n",mailbox);
+	}
+}
+
 #endif /* IMAP_STORAGE */
 
 /* This is a workaround so that menuselect displays a proper description




More information about the asterisk-commits mailing list