[evolution-data-server/imap-notify: 19/40] CamelIMAPXServer: Support the NOTIFY capability.



commit bca3ec5bc7be9e0fca3238dfc47236e4216d72d2
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sat Jul 13 18:49:10 2013 -0400

    CamelIMAPXServer: Support the NOTIFY capability.
    
    http://tools.ietf.org/html/rfc5465
    
    NOTIFY replaces IDLE when available.

 camel/camel-imapx-server.c |   29 +++++++++++++++++++++++++++++
 camel/camel-imapx-utils.c  |    3 ++-
 camel/camel-imapx-utils.h  |    3 ++-
 3 files changed, 33 insertions(+), 2 deletions(-)
---
diff --git a/camel/camel-imapx-server.c b/camel/camel-imapx-server.c
index 21073ec..5e5a05d 100644
--- a/camel/camel-imapx-server.c
+++ b/camel/camel-imapx-server.c
@@ -3878,6 +3878,10 @@ imapx_use_idle (CamelIMAPXServer *is)
 {
        gboolean use_idle = FALSE;
 
+       /* No need for IDLE if the server supports NOTIFY. */
+       if (CAMEL_IMAPX_HAVE_CAPABILITY (is->cinfo, NOTIFY))
+               return FALSE;
+
        if (CAMEL_IMAPX_HAVE_CAPABILITY (is->cinfo, IDLE)) {
                CamelIMAPXSettings *settings;
 
@@ -4711,6 +4715,31 @@ preauthed:
                is->use_qresync = FALSE;
        }
 
+       /* Set NOTIFY options after enabling QRESYNC (if supported). */
+       if (CAMEL_IMAPX_HAVE_CAPABILITY (is->cinfo, NOTIFY)) {
+               GError *local_error = NULL;
+
+               /* XXX The list of FETCH attributes is negotiable. */
+               ic = camel_imapx_command_new (
+                       is, "NOTIFY", NULL, "NOTIFY SET "
+                       "(selected "
+                       "(MessageNew (UID RFC822.SIZE RFC822.HEADER FLAGS)"
+                       " MessageExpunge"
+                       " FlagChange)) "
+                       "(personal "
+                       "(MessageNew"
+                       " MessageExpunge"
+                       " MailboxName"
+                       " SubscriptionChange))");
+               imapx_command_run (is, ic, cancellable, &local_error);
+               camel_imapx_command_unref (ic);
+
+               if (local_error != NULL) {
+                       g_propagate_error (error, local_error);
+                       goto exception;
+               }
+       }
+
        if (store->summary->namespaces == NULL) {
                CamelIMAPXNamespaceList *nsl = NULL;
                CamelIMAPXStoreNamespace *ns = NULL;
diff --git a/camel/camel-imapx-utils.c b/camel/camel-imapx-utils.c
index eaacc5d..c49cafb 100644
--- a/camel/camel-imapx-utils.c
+++ b/camel/camel-imapx-utils.c
@@ -422,7 +422,8 @@ struct {
        { "LIST-EXTENDED", IMAPX_CAPABILITY_LIST_EXTENDED },
        { "LIST-STATUS", IMAPX_CAPABILITY_LIST_STATUS },
        { "QUOTA", IMAPX_CAPABILITY_QUOTA },
-       { "MOVE", IMAPX_CAPABILITY_MOVE }
+       { "MOVE", IMAPX_CAPABILITY_MOVE },
+       { "NOTIFY", IMAPX_CAPABILITY_NOTIFY }
 };
 
 static GMutex capa_htable_lock;         /* capabilities lookup table lock */
diff --git a/camel/camel-imapx-utils.h b/camel/camel-imapx-utils.h
index d80faff..15b53d7 100644
--- a/camel/camel-imapx-utils.h
+++ b/camel/camel-imapx-utils.h
@@ -187,7 +187,8 @@ enum {
        IMAPX_CAPABILITY_LIST_STATUS            = (1 << 10),
        IMAPX_CAPABILITY_LIST_EXTENDED          = (1 << 11),
        IMAPX_CAPABILITY_QUOTA                  = (1 << 12),
-       IMAPX_CAPABILITY_MOVE                   = (1 << 13)
+       IMAPX_CAPABILITY_MOVE                   = (1 << 13),
+       IMAPX_CAPABILITY_NOTIFY                 = (1 << 14)
 };
 
 struct _capability_info {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]