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

Jenkins2 asteriskteam at digium.com
Thu Jun 15 09:23:58 CDT 2017


Jenkins2 has submitted this change and it was merged. ( 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(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit



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-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: I4ff964026002b2817b48c20fb4239f0a880228fd
Gerrit-Change-Number: 5803
Gerrit-PatchSet: 1
Gerrit-Owner: Alexei Gradinari <alex2grad at gmail.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170615/01adb093/attachment.html>


More information about the asterisk-code-review mailing list