[asterisk-commits] mmichelson: branch mmichelson/imap_consistency r134090 - /team/mmichelson/ima...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jul 28 12:12:05 CDT 2008
Author: mmichelson
Date: Mon Jul 28 12:12:04 2008
New Revision: 134090
URL: http://svn.digium.com/view/asterisk?view=rev&rev=134090
Log:
Fix the "delete" option in voicemail.conf by doing the
following.
1. Change IMAP's DELETE macro to flag the message as
"Deleted." This makes it more parallel with what ODBC
does for its DELETE callback.
2. Remove the IMAP_DELETE macro since it was only used
in one place and should be taken care of by the DELETE
macro instead. (Speaking of IMAP_DELETE, if you're going
to have a macro which is only used by IMAP and only used
in one place, why have the macro take four arguments when
the function called within the macro only takes two?)
Modified:
team/mmichelson/imap_consistency/apps/app_voicemail.c
Modified: team/mmichelson/imap_consistency/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/imap_consistency/apps/app_voicemail.c?view=diff&rev=134090&r1=134089&r2=134090
==============================================================================
--- team/mmichelson/imap_consistency/apps/app_voicemail.c (original)
+++ team/mmichelson/imap_consistency/apps/app_voicemail.c Mon Jul 28 12:12:04 2008
@@ -127,7 +127,7 @@
static void write_file (char *filename, char *buffer, unsigned long len);
/*static void status (MAILSTREAM *stream); */ /* No need for this. */
static char *get_header_by_tag(char *header, char *tag);
-static void vm_imap_delete(int msgnum, struct vm_state *vms);
+static void vm_imap_delete(int msgnum, struct ast_vm_user *vmu);
static char *get_user_by_mailbox(char *mailbox);
static struct vm_state *get_vm_state_by_imapuser(char *user, int interactive);
static struct vm_state *get_vm_state_by_mailbox(const char *mailbox, int interactive);
@@ -406,7 +406,7 @@
#define EXISTS(a,b,c,d) (message_exists(a,b))
#define RENAME(a,b,c,d,e,f,g,h) (rename_file(a,b,c,d,e,f))
#define COPY(a,b,c,d,e,f,g,h) (copy_file(a,b,c,d,e,f))
-#define DELETE(a,b,c) (delete_file(a,b))
+#define DELETE(a,b,c,d) (delete_file(a,b))
#else
#ifdef IMAP_STORAGE
#define RETRIEVE(a,b,c) imap_retrieve_file(a,b,c)
@@ -415,8 +415,7 @@
#define EXISTS(a,b,c,d) (ast_fileexists(c,NULL,d) > 0)
#define RENAME(a,b,c,d,e,f,g,h) (rename_file(g,h));
#define COPY(a,b,c,d,e,f,g,h) (copy_file(g,h));
-#define IMAP_DELETE(a,b,c,d) (vm_imap_delete(b,d))
-#define DELETE(a,b,c) (vm_delete(c))
+#define DELETE(a,b,c,d) (vm_imap_delete(b,d))
#else
#define RETRIEVE(a,b,c)
#define DISPOSE(a,b)
@@ -424,7 +423,7 @@
#define EXISTS(a,b,c,d) (ast_fileexists(c,NULL,d) > 0)
#define RENAME(a,b,c,d,e,f,g,h) (rename_file(g,h));
#define COPY(a,b,c,d,e,f,g,h) (copy_plain_file(g,h));
-#define DELETE(a,b,c) (vm_delete(c))
+#define DELETE(a,b,c,d) (vm_delete(c))
#endif
#endif
@@ -979,14 +978,24 @@
/* All IMAP-specific functions should go in this block. This
* keeps them from being spread out all over the code */
#ifdef IMAP_STORAGE
-static void vm_imap_delete(int msgnum, struct vm_state *vms)
-{
- unsigned long messageNum = 0;
+static void vm_imap_delete(int msgnum, struct ast_vm_user *vmu)
+{
char arg[10];
+ struct vm_state *vms;
+ unsigned long messageNum;
+
+ /* Greetings aren't stored in IMAP, so we can't delete them there */
+ if (msgnum < 0) {
+ return;
+ }
+
+ if (!(vms = get_vm_state_by_mailbox(vmu->mailbox, 1)) && !(vms = get_vm_state_by_mailbox(vmu->mailbox, 0))) {
+ ast_log(LOG_WARNING, "Couldn't find a vm_state for mailbox %s. Unable to set \\DELETED flag for message %d\n", vmu->mailbox, msgnum);
+ return;
+ }
/* find real message number based on msgnum */
/* this may be an index into vms->msgArray based on the msgnum. */
-
messageNum = vms->msgArray[msgnum];
if (messageNum == 0) {
ast_log(LOG_WARNING, "msgnum %d, mailbox message %lu is zero.\n",msgnum,messageNum);
@@ -1058,6 +1067,8 @@
}
mail_fetchstructure (vms->mailstream,vms->msgArray[msgnum],&body);
+ mail_elt(vms->mailstream, vms->msgArray[msgnum]);
+ ast_log(LOG_NOTICE, "DEBUG: vms->mailstream->msgno = %lu; vms->mailstream->body-> = %p;\n", vms->mailstream->msgno, vms->mailstream->body);
/* We have the body, now we extract the file name of the first attachment. */
if (body->nested.part && body->nested.part->next && body->nested.part->next->body.parameter->value) {
@@ -4810,12 +4821,9 @@
}
if (ast_test_flag(vmu, VM_DELETE)) {
- DELETE(todir, msgnum, fn);
- }
-
-#ifdef IMAP_STORAGE
- DELETE(todir, msgnum, fn);
-#endif
+ DELETE(todir, msgnum, fn, vmu);
+ }
+
/* Leave voicemail for someone */
if (ast_app_has_voicemail(ext_context, NULL)) {
ast_app_inboxcount(ext_context, &newmsgs, &oldmsgs);
@@ -5451,7 +5459,7 @@
for (x = vms->curmsg + 1; x <= nummsg; x++) {
make_file(vms->fn, sizeof(vms->fn), vms->curdir, x);
if (EXISTS(vms->curdir, x, vms->fn, NULL))
- DELETE(vms->curdir, x, vms->fn);
+ DELETE(vms->curdir, x, vms->fn, vmu);
}
ast_unlock_path(vms->curdir);
#else
@@ -5460,7 +5468,7 @@
if (vms->deleted[x]) {
if (option_debug > 2)
ast_log(LOG_DEBUG,"IMAP delete of %d\n",x);
- IMAP_DELETE(vms->curdir, x, vms->fn, vms);
+ DELETE(vms->curdir, x, vms->fn, vmu);
}
}
}
@@ -6666,7 +6674,7 @@
cmd = play_record_review(chan, "vm-rec-temp", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, vms);
break;
case '2':
- DELETE(prefile, -1, prefile);
+ DELETE(prefile, -1, prefile, vmu);
ast_play_and_wait(chan, "vm-tempremoved");
cmd = 't';
break;
@@ -8875,7 +8883,7 @@
cmd = '0';
} else {
ast_play_and_wait(chan, "vm-deleted");
- DELETE(recordfile, -1, recordfile);
+ DELETE(recordfile, -1, recordfile, vmu);
cmd = '0';
}
}
More information about the asterisk-commits
mailing list