[Asterisk-code-review] app voicemail: IMAP connection control (asterisk[14])

Jenkins2 asteriskteam at digium.com
Thu Jun 29 09:08:10 CDT 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/5904 )

Change subject: app_voicemail: IMAP connection control
......................................................................

app_voicemail: IMAP connection control

A new global option "imap_poll_logout" was added to specify whether need to
disconnect from the IMAP server after polling of mailboxes.

ASTERISK-27068 #close

Closing IMAP connection after loading mailbox from voicemail.conf

ASTERISK-24052 #close

Change-Id: Ib7558ba04516240a32b65f42e9be64372a0ae12a
---
M CHANGES
M apps/app_voicemail.c
M configs/samples/voicemail.conf.sample
3 files changed, 26 insertions(+), 0 deletions(-)

Approvals:
  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/CHANGES b/CHANGES
index 3107630..7cf3f8a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -12,6 +12,12 @@
 --- Functionality changes from Asterisk 14.5.0 to Asterisk 14.6.0 ------------
 ------------------------------------------------------------------------------
 
+app_voicemail
+------------------
+ * A new global option "imap_poll_logout" was added to specify whether need to
+   disconnect from the IMAP server after polling of mailboxes.
+   Default: no
+
 res_pjsip
 ------------------
  * A new endpoint option "refer_blind_progress" was added to turn off notifying
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 2c14439..13ddb13 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -507,6 +507,7 @@
 
 static int expungeonhangup = 1;
 static int imapgreetings = 0;
+static int imap_poll_logout = 0;
 static char delimiter = '\0';
 
 /* mail_open cannot be protected on a stream basis */
@@ -544,6 +545,8 @@
 static int imap_delete_old_greeting (char *dir, struct vm_state *vms);
 static void check_quota(struct vm_state *vms, char *mailbox);
 static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu, int box);
+static void imap_logout(const char *mailbox_id);
+
 struct vmstate {
 	struct vm_state *vms;
 	AST_LIST_ENTRY(vmstate) list;
@@ -12305,6 +12308,9 @@
 	strcat(mailbox_full, context);
 
 	inboxcount2(mailbox_full, &urgent, &new, &old);
+#ifdef IMAP_STORAGE
+	imap_logout(mailbox_full);
+#endif
 	queue_mwi_event(NULL, mailbox_full, urgent, new, old);
 
 	return 0;
@@ -13057,6 +13063,12 @@
 
 	inboxcount2(mwi_sub->mailbox, &urgent, &new, &old);
 
+#ifdef IMAP_STORAGE
+	if (imap_poll_logout) {
+		imap_logout(mwi_sub->mailbox);
+	}
+#endif
+
 	if (urgent != mwi_sub->old_urgent || new != mwi_sub->old_new || old != mwi_sub->old_old) {
 		mwi_sub->old_urgent = urgent;
 		mwi_sub->old_new = new;
@@ -13777,6 +13789,11 @@
 		} else {
 			ast_copy_string(greetingfolder, imapfolder, sizeof(greetingfolder));
 		}
+		if ((val = ast_variable_retrieve(cfg, "general", "imap_poll_logout"))) {
+			imap_poll_logout = ast_true(val);
+		} else {
+			imap_poll_logout = 0;
+		}
 
 		/* There is some very unorthodox casting done here. This is due
 		 * to the way c-client handles the argument passed in. It expects a 
diff --git a/configs/samples/voicemail.conf.sample b/configs/samples/voicemail.conf.sample
index f8221ee..84e83a3 100644
--- a/configs/samples/voicemail.conf.sample
+++ b/configs/samples/voicemail.conf.sample
@@ -227,6 +227,9 @@
 ;imapclosetimeout=60     ; The TCP close timeout (in seconds)
 ;imapreadtimeout=60      ; The TCP read timeout (in seconds)
 ;imapwritetimeout=60     ; The TCP write timeout (in seconds)
+;imap_poll_logout=no     ; If pollmailboxes=yes, then specify whether need to
+                         ; disconnect from the IMAP server after polling.
+                         ; Default: no
 
 ; -----------------------------------------------------------------------------
 ;

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

Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib7558ba04516240a32b65f42e9be64372a0ae12a
Gerrit-Change-Number: 5904
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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170629/294a10e2/attachment.html>


More information about the asterisk-code-review mailing list