[Asterisk-code-review] app voicemail: IMAP logout on MWI unsubscribe (asterisk[13])

Alexei Gradinari asteriskteam at digium.com
Mon Jun 12 18:10:51 CDT 2017


Alexei Gradinari has uploaded a new change for review. ( https://gerrit.asterisk.org/5803 )

Change subject: app_voicemail: IMAP logout on MWI unsubscribe
......................................................................

app_voicemail: IMAP logout on MWI unsubscribe

Closing IMAP connection on MWI unsubscribe.

ASTERISK-24052 #close

Change-Id: I4ff964026002b2817b48c20fb4239f0a880228fd
---
M apps/app_voicemail.c
1 file changed, 37 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/03/5803/1

diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index f62c7d8..5a8ffe9 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -13029,6 +13029,40 @@
 	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 @@
 			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);
 		}
 	}

-- 
To view, visit https://gerrit.asterisk.org/5803
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4ff964026002b2817b48c20fb4239f0a880228fd
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Alexei Gradinari <alex2grad at gmail.com>



More information about the asterisk-code-review mailing list