diff options
author | Alexei Gradinari <alex2grad@gmail.com> | 2017-06-12 18:55:15 -0400 |
---|---|---|
committer | Alexei Gradinari <alex2grad@gmail.com> | 2017-06-14 11:30:34 -0500 |
commit | 023eede2652d95a98b756df1b105ed978e561c81 (patch) | |
tree | d6c6ff4223dcb6ee7edf4cfe064e7e13bc4057ad /apps/app_voicemail.c | |
parent | c33168c14761a38ec8732dbcb6d3be2758a6571a (diff) |
app_voicemail: IMAP logout on MWI unsubscribe
Closing IMAP connection on MWI unsubscribe.
ASTERISK-24052 #close
Change-Id: I4ff964026002b2817b48c20fb4239f0a880228fd
Diffstat (limited to 'apps/app_voicemail.c')
-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 06f4830fa..ba9378380 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -13106,6 +13106,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; @@ -13117,6 +13151,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); } } |