diff options
author | Jenkins2 <jenkins2@gerrit.asterisk.org> | 2017-06-15 09:23:58 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-06-15 09:23:58 -0500 |
commit | 8b12ad2f61e807f2138d0a80927e1c4859c86c4c (patch) | |
tree | 989d86d15092aaadbba06603332b29ca98682866 | |
parent | a3b142dbe0bbe9b8b7f097c783b6b4ebdab45efa (diff) | |
parent | 08be5e01e8ab72a7e9e80525e20967467a6df99b (diff) |
Merge "app_voicemail: IMAP logout on MWI unsubscribe" into 13
-rw-r--r-- | apps/app_voicemail.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index d8011aed3..0c0e2ba6a 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -13029,6 +13029,40 @@ static void mwi_sub_destroy(struct mwi_sub *mwi_sub) ast_free(mwi_sub); } +#ifdef IMAP_STORAGE +static void imap_logout(const char *mailbox_id) +{ + char *context; + char *mailbox; + struct ast_vm_user vmus; + RAII_VAR(struct ast_vm_user *, vmu, NULL, free_user); + struct vm_state *vms = NULL; + + if (ast_strlen_zero(mailbox_id) + || separate_mailbox(ast_strdupa(mailbox_id), &mailbox, &context)) { + return; + } + + memset(&vmus, 0, sizeof(vmus)); + + if (!(vmu = find_user(&vmus, context, mailbox)) || vmu->imapuser[0] == '\0') { + return; + } + + vms = get_vm_state_by_imapuser(vmu->imapuser, 0); + if (!vms) { + vms = get_vm_state_by_mailbox(mailbox, context, 0); + } + if (!vms) { + return; + } + + vms->mailstream = mail_close(vms->mailstream); + vmstate_delete(vms); +} + +#endif + static int handle_unsubscribe(void *datap) { struct mwi_sub *mwi_sub; @@ -13040,6 +13074,9 @@ static int handle_unsubscribe(void *datap) AST_LIST_REMOVE_CURRENT(entry); /* Don't break here since a duplicate uniqueid * may have been added as a result of a cache dump. */ +#ifdef IMAP_STORAGE + imap_logout(mwi_sub->mailbox); +#endif mwi_sub_destroy(mwi_sub); } } |