[asterisk-commits] mmichelson: branch mmichelson/trunk-vm-imap r72186 - in /team/mmichelson/trun...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 27 14:01:04 CDT 2007


Author: mmichelson
Date: Wed Jun 27 14:01:03 2007
New Revision: 72186

URL: http://svn.digium.com/view/asterisk?view=rev&rev=72186
Log:
enum'd the mailbox folders to make the code more readable


Modified:
    team/mmichelson/trunk-vm-imap/   (props changed)
    team/mmichelson/trunk-vm-imap/apps/app_voicemail.c

Propchange: team/mmichelson/trunk-vm-imap/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/mmichelson/trunk-vm-imap/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Jun 27 14:01:03 2007
@@ -1,1 +1,1 @@
-/trunk:1-71966
+/trunk:1-72149

Modified: team/mmichelson/trunk-vm-imap/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/trunk-vm-imap/apps/app_voicemail.c?view=diff&rev=72186&r1=72185&r2=72186
==============================================================================
--- team/mmichelson/trunk-vm-imap/apps/app_voicemail.c (original)
+++ team/mmichelson/trunk-vm-imap/apps/app_voicemail.c Wed Jun 27 14:01:03 2007
@@ -167,7 +167,6 @@
 
 static AST_LIST_HEAD_STATIC(vmstates, vmstate);
 
-#define GREETING_FOLDER		2
 #endif
 
 #define SMDI_MWI_WAIT_TIMEOUT 1000 /* 1 second */
@@ -216,6 +215,15 @@
 #define VM_TEMPGREETWARN (1 << 15)  /*!< Remind user tempgreeting is set */
 #define ERROR_LOCK_PATH  -100
 
+
+enum {
+	NEW_FOLDER,
+	OLD_FOLDER,
+	WORK_FOLDER,
+	FAMILY_FOLDER,
+	FRIENDS_FOLDER,
+	GREETINGS_FOLDER
+} vm_box;
 
 enum {
 	OPT_SILENT =           (1 << 0),
@@ -2557,7 +2565,7 @@
 	}
 
 	if (msgnum < 0 && imapgreetings) {
-		init_mailstream(vms, GREETING_FOLDER);
+		init_mailstream(vms, GREETINGS_FOLDER);
 		imap_delete_old_greeting(fn, vms);
 	}
 	
@@ -2572,8 +2580,8 @@
 	fread(buf, len, 1, p);
 	((char *)buf)[len] = '\0';
 	INIT(&str, mail_string, buf, len);
-	init_mailstream(vms, 0);
-	imap_mailbox_name(mailbox, vms, 0, 1);
+	init_mailstream(vms, NEW_FOLDER);
+	imap_mailbox_name(mailbox, vms, NEW_FOLDER, 1);
 	if(!mail_append(vms->mailstream, mailbox, &str))
 		ast_log(LOG_ERROR, "Error while sending the message to %s\n", mailbox);
 	fclose(p);
@@ -2676,13 +2684,13 @@
 		ast_debug(3,"Copied %s to %s\n",vmu->imapuser,vms_p->imapuser);
 		vms_p->updated = 1;
 		/* set mailbox to INBOX! */
-		ast_copy_string(vms_p->curbox, mbox(0), sizeof(vms_p->curbox));
+		ast_copy_string(vms_p->curbox, mbox(NEW_FOLDER), sizeof(vms_p->curbox));
  		init_vm_state(vms_p);
  		vmstate_insert(vms_p);
  	}
 
 	/* If no mailstream exists yet and even after attempting to initialize it fails, bail out */
-	ret = init_mailstream(vms_p, 0);
+	ret = init_mailstream(vms_p, NEW_FOLDER);
 	if (!vms_p->mailstream) {
 		ast_log (LOG_ERROR,"Houston we have a problem - IMAP mailstream is NULL\n");
 		free_user(vmu);
@@ -4789,9 +4797,9 @@
 	char tmp[256], *t = tmp;
 	size_t left = sizeof(tmp);
 
-	if (box == 1) {
-		ast_copy_string(vms->curbox, mbox(0), sizeof(vms->curbox));
-		sprintf(vms->vmbox, "vm-%s", mbox(1));
+	if (box == OLD_FOLDER) {
+		ast_copy_string(vms->curbox, mbox(NEW_FOLDER), sizeof(vms->curbox));
+		sprintf(vms->vmbox, "vm-%s", mbox(OLD_FOLDER));
 	} else {
 		ast_copy_string(vms->curbox, mbox(box), sizeof(vms->curbox));
 		snprintf(vms->vmbox, sizeof(vms->vmbox), "vm-%s", vms->curbox);
@@ -4811,9 +4819,9 @@
 	/* End with username */
 	ast_build_string(&t, &left, "/user=%s}", vms->imapuser);
 
-	if(box == 0 || box == 1)
+	if(box == NEW_FOLDER || box == OLD_FOLDER)
 		sprintf(spec, "%s%s", tmp, use_folder? imapfolder: "INBOX");
-	else if (box == GREETING_FOLDER)
+	else if (box == GREETINGS_FOLDER)
 		sprintf(spec, "%s%s", tmp, greetingfolder);
 	else
 		sprintf(spec, "%s%s%c%s", tmp, imapfolder, delimiter, mbox(box));
@@ -4846,7 +4854,7 @@
 #include "linkage.c"
 #endif
 		/* Connect to INBOX first to get folders delimiter */
-		imap_mailbox_name(tmp, vms, 0, 0);
+		imap_mailbox_name(tmp, vms, NEW_FOLDER, 0);
 		stream = mail_open(stream, tmp, debug ? OP_DEBUG : NIL);
 		if (stream == NIL) {
 			ast_log (LOG_ERROR, "Can't connect to imap server %s\n", tmp);
@@ -4898,11 +4906,11 @@
 	pgm->deleted = 0;
 	pgm->undeleted = 1;
 
-	/* if box = 0, check for new, if box = 1, check for read */
-	if (box == 0) {
+	/* if box = NEW_FOLDER, check for new, if box = OLD_FOLDER, check for read */
+	if (box == NEW_FOLDER) {
 		pgm->unseen = 1;
 		pgm->seen = 0;
-	} else if (box == 1) {
+	} else if (box == OLD_FOLDER) {
 		pgm->seen = 1;
 		pgm->unseen = 0;
 	}
@@ -5000,13 +5008,13 @@
 			ast_debug (3,"Copied %s to %s\n",vmu->imapuser,vms_p->imapuser);
 			vms_p->updated = 1;
 			/* set mailbox to INBOX! */
-			ast_copy_string(vms_p->curbox, mbox(0), sizeof(vms_p->curbox));
+			ast_copy_string(vms_p->curbox, mbox(NEW_FOLDER), sizeof(vms_p->curbox));
 			init_vm_state(vms_p);
 			vmstate_insert(vms_p);
 		}
 	}
 	
-	ret = init_mailstream(vms_p, GREETING_FOLDER);
+	ret = init_mailstream(vms_p, GREETINGS_FOLDER);
 	if (!vms_p->mailstream) {
 		ast_log (LOG_ERROR,"IMAP mailstream is NULL\n");
 		free_user(vmu);
@@ -6847,13 +6855,13 @@
 #endif
 	/* Retrieve old and new message counts */
 	ast_debug(1, "Before open_mailbox\n");
-	res = open_mailbox(&vms, vmu, 1);
+	res = open_mailbox(&vms, vmu, OLD_FOLDER);
 	if (res == ERROR_LOCK_PATH)
 		goto out;
 	vms.oldmessages = vms.lastmsg + 1;
 	ast_debug(1, "Number of old messages: %d\n",vms.oldmessages);
 	/* Start in INBOX */
-	res = open_mailbox(&vms, vmu, 0);
+	res = open_mailbox(&vms, vmu, NEW_FOLDER);
 	if (res == ERROR_LOCK_PATH)
 		goto out;
 	vms.newmessages = vms.lastmsg + 1;
@@ -6874,7 +6882,7 @@
 	} else {
 		if (!vms.newmessages && vms.oldmessages) {
 			/* If we only have old messages start here */
-			res = open_mailbox(&vms, vmu, 1);
+			res = open_mailbox(&vms, vmu, OLD_FOLDER);
 			play_folder = 1;
 			if (res == ERROR_LOCK_PATH)
 				goto out;




More information about the asterisk-commits mailing list