aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_voicemail.c
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-19 20:28:41 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-19 20:28:41 +0000
commit05dfef339283636f630036f28b90c02e3f3fc834 (patch)
tree868780b1321c21dccbd89d40623071051f0929d8 /apps/app_voicemail.c
parentd3e21b899dd8469b4b62862573f728a76b3aada3 (diff)
Fix IMAP forwarding so that messages are sent to the proper mailbox.
(closes issue #12897) Reported by: jaroth Patches: destination_forward.patch uploaded by jaroth (license 50) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@124112 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_voicemail.c')
-rw-r--r--apps/app_voicemail.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 57f2fc54d..69fd6bde1 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -131,6 +131,7 @@ static void vm_imap_delete(int msgnum, struct vm_state *vms);
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);
+static struct vm_state *create_vm_state_from_user(struct ast_vm_user *vmu, char *mailbox);
static void vmstate_insert(struct vm_state *vms);
static void vmstate_delete(struct vm_state *vms);
static void set_update(MAILSTREAM * stream);
@@ -4214,6 +4215,9 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
/* get destination mailbox */
dstvms = get_vm_state_by_mailbox(vmtmp->mailbox,0);
+ if (!dstvms) {
+ dstvms = create_vm_state_from_user(vmtmp, vmtmp->mailbox);
+ }
if (dstvms) {
init_mailstream(dstvms, 0);
if (!dstvms->mailstream) {
@@ -8885,6 +8889,27 @@ static char *get_user_by_mailbox(char *mailbox)
}
}
+static struct vm_state *create_vm_state_from_user(struct ast_vm_user *vmu, char *mailbox)
+{
+ struct vm_state *vms_p;
+
+ if (option_debug > 4)
+ ast_log(LOG_DEBUG,"Adding new vmstate for %s\n",vmu->imapuser);
+ if (!(vms_p = ast_calloc(1, sizeof(*vms_p))))
+ return NULL;
+ ast_copy_string(vms_p->imapuser,vmu->imapuser, sizeof(vms_p->imapuser));
+ ast_copy_string(vms_p->username, mailbox, sizeof(vms_p->username)); /* save for access from interactive entry point */
+ vms_p->mailstream = NIL; /* save for access from interactive entry point */
+ if (option_debug > 4)
+ ast_log(LOG_DEBUG,"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));
+ init_vm_state(vms_p);
+ vmstate_insert(vms_p);
+ return vms_p;
+}
+
static struct vm_state *get_vm_state_by_imapuser(char *user, int interactive)
{
struct vmstate *vlist = NULL;