]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
app_voicemail: IMAP connection control
authorAlexei Gradinari <alex2grad@gmail.com>
Mon, 19 Jun 2017 22:21:29 +0000 (18:21 -0400)
committerAlexei Gradinari <alex2grad@gmail.com>
Mon, 19 Jun 2017 22:21:29 +0000 (18:21 -0400)
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

CHANGES
apps/app_voicemail.c
configs/samples/voicemail.conf.sample

diff --git a/CHANGES b/CHANGES
index 1b87dbf0d067d884f44a442fcfd9359a3ded2786..1d1f41b347292ff834b5cf55de1b8bb23c906079 100644 (file)
--- a/CHANGES
+++ b/CHANGES
 --- Functionality changes from Asterisk 13.16.0 to Asterisk 13.17.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
index 2152ccac12812f36e961b6317b0b0ed65a1bf525..fe5657dc8bbb1918c6659c12a53a7b9f0fb0a62c 100644 (file)
@@ -507,6 +507,7 @@ static int imapversion = 1;
 
 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_retrieve_file (const char *dir, const int msgnum, const char *ma
 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;
@@ -12226,6 +12229,9 @@ static int append_mailbox(const char *context, const char *box, const char *data
        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;
@@ -12978,6 +12984,12 @@ static void poll_subscribed_mailbox(struct mwi_sub *mwi_sub)
 
        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;
@@ -13698,6 +13710,11 @@ static int actual_load_config(int reload, struct ast_config *cfg, struct ast_con
                } 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 
index f8221eebe05ed738411166f0be87a081b9c92829..84e83a3447d6fdd18c9abbb12896304a45e83927 100644 (file)
@@ -227,6 +227,9 @@ pagerdateformat=%A, %B %d, %Y at %r
 ;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
 
 ; -----------------------------------------------------------------------------
 ;