Title: [commits] (bkirsch) [15287] fixes bug 10690 to support search and Chandler foldering interop with Microsoft Exchange IMAP Server.
Revision
15287
Author
bkirsch
Date
2007-08-29 17:47:16 -0700 (Wed, 29 Aug 2007)

Log Message

fixes bug 10690 to support search and Chandler foldering interop with Microsoft Exchange IMAP Server. Two issues were occurring 1. Added support to handle UID's returned that were less than the min specified in the fetch. 2. Added support to handle UID info returned as the last values in a uid fetch body.peek command. r=Grant

Modified Paths

Diff

Modified: trunk/chandler/parcels/osaf/mail/imap.py (15286 => 15287)

--- trunk/chandler/parcels/osaf/mail/imap.py	2007-08-29 23:42:20 UTC (rev 15286)
+++ trunk/chandler/parcels/osaf/mail/imap.py	2007-08-30 00:47:16 UTC (rev 15287)
@@ -642,7 +642,7 @@
             # uid was getting commited but an error or
             # shutdown happened before the action was 
             # completed.
-            imapTuple = (self.vars.folderItem.itsUUID, 
+            imapTuple = (self.vars.folderItem.itsUUID,
                          self.vars.lastSearchUID + 1)
 
             self.mailWorker.queueRequest((mailworker.UID_REQUEST, self,
@@ -733,7 +733,7 @@
 
         if self.vars.folderItem.folderType == "CHANDLER_HEADERS":
             return self.proto.fetchUID(msgSet, uid=1
-                    ).addCallbacks(self._searchForChandlerMessages, 
+                    ).addCallbacks(self._searchForChandlerMessages,
                                    self.catchErrors)
         else:
             return self.proto.fetchFlags(msgSet, uid=True
@@ -745,8 +745,20 @@
             trace("_searchForChandlerHeaders")
 
         for uidDict in msgs.values():
-           self.vars.searchUIDs.append(int(uidDict['UID']))
+           uid = int(uidDict['UID'])
 
+           if uid >= self.vars.lastUID:
+               # Microsoft Exchange Server returnes UID's
+               # less than the value in self.vars.lastUID.
+               # This violates RFC 3501 and results in
+               # Chandler messages being re-downloaded on
+               # each sync.
+               #
+               # Exchange Example:
+               #     >>> C: 0004 UID FETCH 3:* (UID)
+               #     >>> S: * 2 FETCH (UID 2)
+               self.vars.searchUIDs.append(uid)
+
         # Sort the uids since the ordering returned from the
         # dict may not be sequential
         self.vars.searchUIDs.sort()
@@ -1003,14 +1015,30 @@
         if curMessage[0] > self.vars.lastUID:
             self.vars.lastUID = curMessage[0]
 
+
+        # Store in a local variable the returned
+        # server data in the dict for
+        # quicker look up and easy reference.
+        mArray = msgs[msg][0]
+
+        if str(mArray[3]).upper() == 'UID':
+            # The UID information was returned
+            # by the server *after* the RFC822 message.
+            # Example: Microsoft Exchange IMAP Server
+            msg = mArray[2]
+        else:
+            # The UID information was returned
+            # by the server *before* the RFC822 message.
+            # Example: Courier IMAP Server
+            msg = mArray[4]
+
         self.vars.messages.append(
                      # Tuple containing
                      #     0: Mail Request
                      #     1: IMAP UID of message
-                     (message.previewQuickParse(msgs[msg][0][4]), 
-                      curMessage[0])
-                   )
-       
+                     (message.previewQuickParse(msg), curMessage[0])
+                )
+
         # this value is used to determine
         # when to post a MAIL_REQUEST to
         # the MailWorker.
@@ -1035,7 +1063,7 @@
         if self.vars.numDownloaded == self.vars.numToDownload:
             imapFolderInfo = (self.vars.folderItem.itsUUID, 
                               self.vars.lastUID + 1)
-            
+
             args = self._getStatusStats()
             args["folderDisplayName"] = self.vars.folderItem.displayName
 




_______________________________________________
Commits mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/commits

Reply via email to