Add a support mechanism for server-based quirks.
authorLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Thu, 16 Dec 2010 15:49:43 +0000 (16:49 +0100)
committerLars Magne Ingebrigtsen <larsi@quimbies.gnus.org>
Thu, 16 Dec 2010 15:49:43 +0000 (16:49 +0100)
This makes QRESYNC on Zimbra work again.

lisp/ChangeLog
lisp/nnimap.el

index 91ba319..6120ae5 100644 (file)
@@ -1,3 +1,9 @@
+2010-12-16  Lars Magne Ingebrigtsen  <larsi@gnus.org>
+
+       * nnimap.el (nnimap-quirk): New function.
+       (nnimap-retrieve-group-data-early): Use it.
+       (nnimap-quirks): New alist.
+
 2010-12-16  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * shr.el (shr-insert): Set shr-start after deleting trailing space;
index 1b7db62..6ea2c14 100644 (file)
@@ -139,6 +139,9 @@ textual parts.")
     (download "gnus-download")
     (forward "gnus-forward")))
 
+(defvar nnimap-quirks
+  '(("QRESYNC" "Zimbra" "QRESYNC ")))
+
 (defun nnimap-buffer ()
   (nnimap-find-process-buffer nntp-server-buffer))
 
@@ -1080,8 +1083,9 @@ textual parts.")
                   uidvalidity
                   modseq)
              (push
-              (list (nnimap-send-command "EXAMINE %S (QRESYNC (%s %s))"
+              (list (nnimap-send-command "EXAMINE %S (%s (%s %s))"
                                          (utf7-encode group t)
+                                         (nnimap-quirk "QRESYNC")
                                          uidvalidity modseq)
                     'qresync
                     nil group 'qresync)
@@ -1107,6 +1111,15 @@ textual parts.")
                    sequences))))
        sequences))))
 
+(defun nnimap-quirk (command)
+  (let ((quirk (assoc command nnimap-quirks)))
+    ;; If this server is of a type that matches a quirk, then return
+    ;; the "quirked" command instead of the proper one.
+    (if (or (null quirk)
+           (not (string-match (nth 1 quirk) (nnimap-greeting nnimap-object))))
+       command
+      (nth 2 quirk))))
+
 (deffoo nnimap-finish-retrieve-group-infos (server infos sequences)
   (when (and sequences
             (nnimap-possibly-change-group nil server))