fix perma-orange in gloda indexing, fix unsolicted keyword responses, r=asuth, sr=standard8, a=Standard8, turn tests back on now that issues fixed, bug 723081
authorDavid Bienvenu <bienvenu@nventure.com>
Tue, 21 Feb 2012 09:58:20 -0800
changeset 10591 dd393081fb7308c82e840a8834d68e2be2659fe4
parent 10590 73fa7507f71ef3085224f2e8f1419ad821375f6e
child 10592 958575ce81d007e7b7975388ea98b00155377305
push idunknown
push userunknown
push dateunknown
reviewersasuth, standard8, Standard8, turn
bugs723081
fix perma-orange in gloda indexing, fix unsolicted keyword responses, r=asuth, sr=standard8, a=Standard8, turn tests back on now that issues fixed, bug 723081
mailnews/db/gloda/test/unit/base_index_messages.js
mailnews/db/gloda/test/unit/xpcshell.ini
mailnews/imap/public/nsIImapMessageSink.idl
mailnews/imap/src/nsImapMailFolder.cpp
mailnews/imap/src/nsImapMailFolder.h
mailnews/imap/src/nsImapProtocol.cpp
mailnews/imap/src/nsImapProtocol.h
mailnews/imap/src/nsImapServerResponseParser.cpp
mailnews/imap/src/nsSyncRunnableHelpers.cpp
mailnews/imap/test/unit/test_imapFilterActions.js
--- a/mailnews/db/gloda/test/unit/base_index_messages.js
+++ b/mailnews/db/gloda/test/unit/base_index_messages.js
@@ -529,16 +529,17 @@ function verify_attributes_fundamental(s
  */
 function test_moved_message_attributes() {
   if (!expectFulltextResults)
     return;
 
   // Don't ask me why, let destFolder = make_empty_folder would result in a
   // random error when running test_index_messages_imap_offline.js ...
   let [destFolder, ignoreSet] = make_folder_with_sets([{count: 2}]);
+  fundamentalFolderHandle = destFolder;
   yield wait_for_message_injection();
   yield wait_for_gloda_indexer([ignoreSet]);
 
   // this is a fast move (third parameter set to true)
   yield async_move_messages(fundamentalMsgSet, destFolder, true);
 
   yield wait_for_gloda_indexer(fundamentalMsgSet, {
     verifier: function (newSynMsg, newGlodaMsg) {
@@ -1220,19 +1221,19 @@ var tests = [
   test_pending_commit_tracker_flushes_correctly,
   test_pending_commit_causes_msgdb_commit,
   test_indexing_sweep,
   test_event_driven_indexing_does_not_mess_with_filthy_folders,
 
   test_threading,
   test_attachment_flag,
   test_attributes_fundamental,
+  test_moved_message_attributes,
   test_attributes_fundamental_from_disk,
   test_attributes_explicit,
-  test_moved_message_attributes,
   test_attributes_cant_query,
 
   test_streamed_bodies_are_size_capped,
 
   test_imap_add_unread_to_folder,
   test_message_moving,
 
   test_message_deletion,
--- a/mailnews/db/gloda/test/unit/xpcshell.ini
+++ b/mailnews/db/gloda/test/unit/xpcshell.ini
@@ -10,20 +10,18 @@ tail = tail_gloda.js
 [test_gloda_content_local.js]
 [test_index_addressbook.js]
 [test_index_bad_messages.js]
 [test_index_compaction.js]
 [test_index_junk_imap_offline.js]
 [test_index_junk_imap_online.js]
 [test_index_junk_local.js]
 [test_index_messages_imap_offline.js]
-skip-if = true
 [test_index_messages_imap_online.js]
 [test_index_messages_imap_online_to_offline.js]
-skip-if = true
 [test_index_messages_local.js]
 [test_index_sweep_folder.js]
 [test_intl.js]
 [test_mime_attachments_size.js]
 [test_mime_emitter.js]
 [test_msg_search.js]
 [test_noun_mimetype.js]
 [test_query_core.js]
--- a/mailnews/imap/public/nsIImapMessageSink.idl
+++ b/mailnews/imap/public/nsIImapMessageSink.idl
@@ -36,17 +36,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
 #include "MailNewsTypes2.idl"
 #include "nsIImapUrl.idl"
 
 interface nsIMsgMailNewsUrl;
 
-[scriptable, uuid(b2d287c5-e857-4fa2-9047-351f801fafb2)]
+[scriptable, uuid(6ffb6a92-e43a-405f-92ea-92cf81a5e17b)]
 
 interface nsIImapMessageSink : nsISupports {
   // set up messge download output stream
   void setupMsgWriteStream(in nsIFile aFile, in boolean aAppendDummyEnvelope);
 
   /**
    * Used by the imap protocol code to notify the core backend code about
    * downloaded imap messages.
@@ -66,21 +66,23 @@ interface nsIImapMessageSink : nsISuppor
   void abortMsgWriteStream();
 
   void beginMessageUpload();
 
   /**
    *  Notify the message sink that one or more flags have changed
    *  For Condstore servers, also update the highestMod Sequence
    *  @param   aFlags         - The new flags for the message
+   *  @param   aKeywords        keywords for the message
    *  @param   aMessageKey    - The UID of the message that changed
    *  @param   aHighestModSeq - The highest mod seq the parser has seen
    *                            for this folder
   **/
-  void notifyMessageFlags(in unsigned long aFlags, in nsMsgKey aMessageKey,
+  void notifyMessageFlags(in unsigned long aFlags, in ACString aKeywords,
+                          in nsMsgKey aMessageKey,
                           in unsigned long long aHighestModSeq);
 
   void notifyMessageDeleted(in string aOnlineFolderName,in boolean aDeleteAllMsgs,in string aMsgIdString);
 
   void getMessageSizeFromDB(in string aId, out unsigned long aSize);
 
   void setContentModified(in nsIImapUrl aImapUrl, in nsImapContentModifiedType aModified);
   void setImageCacheSessionForUrl(in nsIMsgMailNewsUrl aMailUrl);
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -4865,17 +4865,19 @@ nsresult nsImapMailFolder::SyncFlags(nsI
     mFolderSize = (PRUint32) newFolderSize;
     NotifyIntPropertyChanged(kFolderSizeAtom, oldFolderSize, mFolderSize);
   }
 
   return NS_OK;
 }
 
 // helper routine to sync the flags on a given header
-nsresult nsImapMailFolder::NotifyMessageFlagsFromHdr(nsIMsgDBHdr *dbHdr, nsMsgKey msgKey, PRUint32 flags)
+nsresult
+nsImapMailFolder::NotifyMessageFlagsFromHdr(nsIMsgDBHdr *dbHdr,
+                                            nsMsgKey msgKey, PRUint32 flags)
 {
   mDatabase->MarkHdrRead(dbHdr, (flags & kImapMsgSeenFlag) != 0, nsnull);
   mDatabase->MarkHdrReplied(dbHdr, (flags & kImapMsgAnsweredFlag) != 0, nsnull);
   mDatabase->MarkHdrMarked(dbHdr, (flags & kImapMsgFlaggedFlag) != 0, nsnull);
   mDatabase->MarkImapDeleted(msgKey, (flags & kImapMsgDeletedFlag) != 0, nsnull);
 
   PRUint32 supportedFlags;
   GetSupportedUserFlags(&supportedFlags);
@@ -4897,17 +4899,19 @@ nsresult nsImapMailFolder::NotifyMessage
     mDatabase->MarkMDNSent(msgKey, (flags & kImapMsgMDNSentFlag) != 0, nsnull);
 
   return NS_OK;
 }
 
 // message flags operation - this is called from the imap protocol,
 // proxied over from the imap thread to the ui thread, when a flag changes
 NS_IMETHODIMP
-nsImapMailFolder::NotifyMessageFlags(PRUint32 aFlags, nsMsgKey aMsgKey, PRUint64 aHighestModSeq)
+nsImapMailFolder::NotifyMessageFlags(PRUint32 aFlags,
+                                     const nsACString &aKeywords,
+                                     nsMsgKey aMsgKey, PRUint64 aHighestModSeq)
 {
   if (NS_SUCCEEDED(GetDatabase()) && mDatabase)
   {
     bool msgDeleted = aFlags & kImapMsgDeletedFlag;
     if (aHighestModSeq || msgDeleted)
     {
       nsCOMPtr <nsIDBFolderInfo> dbFolderInfo;
       mDatabase->GetDBFolderInfo(getter_AddRefs(dbFolderInfo));
@@ -4930,19 +4934,24 @@ nsImapMailFolder::NotifyMessageFlags(PRU
     nsCOMPtr<nsIMsgDBHdr> dbHdr;
     bool containsKey;
     nsresult rv = mDatabase->ContainsKey(aMsgKey , &containsKey);
     // if we don't have the header, don't diddle the flags.
     // GetMsgHdrForKey will create the header if it doesn't exist.
     if (NS_FAILED(rv) || !containsKey)
       return rv;
     rv = mDatabase->GetMsgHdrForKey(aMsgKey, getter_AddRefs(dbHdr));
-    if(NS_SUCCEEDED(rv) && dbHdr)
+    if (NS_SUCCEEDED(rv) && dbHdr)
+    {
+      PRUint32 supportedUserFlags;
+      GetSupportedUserFlags(&supportedUserFlags);
       NotifyMessageFlagsFromHdr(dbHdr, aMsgKey, aFlags);
-
+      nsCString keywords(aKeywords);
+      HandleCustomFlags(aMsgKey, dbHdr, supportedUserFlags, keywords);
+    }
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsImapMailFolder::NotifyMessageDeleted(const char * onlineFolderName, bool deleteAllMsgs, const char * msgIdString)
 {
   if (deleteAllMsgs)
--- a/mailnews/imap/src/nsImapMailFolder.h
+++ b/mailnews/imap/src/nsImapMailFolder.h
@@ -367,17 +367,18 @@ protected:
   void FindKeysToDelete(const nsTArray<nsMsgKey> &existingKeys, nsTArray<nsMsgKey>
     &keysToFetch, nsIImapFlagAndUidState *flagState, PRUint32 boxFlags);
   void PrepareToAddHeadersToMailDB(nsIImapProtocol* aProtocol);
   void TweakHeaderFlags(nsIImapProtocol* aProtocol, nsIMsgDBHdr *tweakMe);
 
   nsresult SyncFlags(nsIImapFlagAndUidState *flagState);
   nsresult HandleCustomFlags(nsMsgKey uidOfMessage, nsIMsgDBHdr *dbHdr,
                              PRUint16 userFlags, nsCString& keywords);
-  nsresult NotifyMessageFlagsFromHdr(nsIMsgDBHdr *dbHdr, nsMsgKey msgKey, PRUint32 flags);
+  nsresult NotifyMessageFlagsFromHdr(nsIMsgDBHdr *dbHdr, nsMsgKey msgKey,
+                                     PRUint32 flags);
 
   nsresult SetupHeaderParseStream(PRUint32 size, const nsACString& content_type, nsIMailboxSpec *boxSpec);
   nsresult  ParseAdoptedHeaderLine(const char *messageLine, PRUint32 msgKey);
   nsresult  NormalEndHeaderParseStream(nsIImapProtocol *aProtocol, nsIImapUrl *imapUrl);
 
   void EndOfflineDownload();
   nsresult CopyFileToOfflineStore(nsILocalFile *srcFile, nsMsgKey msgKey);
 
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -4773,24 +4773,27 @@ nsImapProtocol::GetConnectionStatus()
 
 void
 nsImapProtocol::SetConnectionStatus(nsresult status)
 {
   m_connectionStatus = status;
 }
 
 void
-nsImapProtocol::NotifyMessageFlags(imapMessageFlagsType flags, 
+nsImapProtocol::NotifyMessageFlags(imapMessageFlagsType flags,
+                                   const nsACString &keywords,
                                    nsMsgKey key, PRUint64 highestModSeq)
 {
     if (m_imapMessageSink)
     {
       // if we're selecting the folder, don't need to report the flags; we've already fetched them.
-      if (m_imapAction != nsIImapUrl::nsImapSelectFolder && (m_imapAction != nsIImapUrl::nsImapMsgFetch || (flags & ~kImapMsgRecentFlag) != kImapMsgSeenFlag))
-        m_imapMessageSink->NotifyMessageFlags(flags, key, highestModSeq);
+      if (m_imapAction != nsIImapUrl::nsImapSelectFolder &&
+          (m_imapAction != nsIImapUrl::nsImapMsgFetch ||
+          (flags & ~kImapMsgRecentFlag) != kImapMsgSeenFlag))
+        m_imapMessageSink->NotifyMessageFlags(flags, keywords, key, highestModSeq);
     }
 }
 
 void
 nsImapProtocol::NotifySearchHit(const char * hitLine)
 {
     nsresult rv;
     nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningUrl, &rv);
--- a/mailnews/imap/src/nsImapProtocol.h
+++ b/mailnews/imap/src/nsImapProtocol.h
@@ -257,18 +257,18 @@ public:
   void TellThreadToDie();
 
   const nsCString& GetImapHostName(); // return the host name from the url for the
   // current connection
   const nsCString& GetImapUserName(); // return the user name from the identity
   const char* GetImapServerKey(); // return the user name from the incoming server;
 
   // state set by the imap parser...
-  void NotifyMessageFlags(imapMessageFlagsType flags, nsMsgKey key,
-                          PRUint64 highestModSeq);
+  void NotifyMessageFlags(imapMessageFlagsType flags, const nsACString &keywords,
+                          nsMsgKey key, PRUint64 highestModSeq);
   void NotifySearchHit(const char * hitLine);
 
   // Event handlers for the imap parser.
   void DiscoverMailboxSpec(nsImapMailboxSpec * adoptedBoxSpec);
   void AlertUserEventUsingId(PRUint32 aMessageId);
   void AlertUserEvent(const char * message);
   void AlertUserEventFromServer(const char * aServerEvent);
 
--- a/mailnews/imap/src/nsImapServerResponseParser.cpp
+++ b/mailnews/imap/src/nsImapServerResponseParser.cpp
@@ -761,17 +761,20 @@ void nsImapServerResponseParser::PostPro
   // a fetch response to a 'uid store' command might return the flags
   // before it returns the uid of the message.  So we need both before
   // we report the new flag info to the front end
   
   // also check and be sure that there was a UID in the current response
   if (fCurrentLineContainedFlagInfo && CurrentResponseUID())
   {
     fCurrentLineContainedFlagInfo = false;
-    fServerConnection.NotifyMessageFlags(fSavedFlagInfo, CurrentResponseUID(), fHighestModSeq);
+    nsCString customFlags;
+    fFlagState->GetCustomFlags(CurrentResponseUID(), getter_Copies(customFlags));
+    fServerConnection.NotifyMessageFlags(fSavedFlagInfo, customFlags,
+                                         CurrentResponseUID(), fHighestModSeq);
   }
 }
 
 
 /*
  mailbox_data    ::=  "FLAGS" SPACE flag_list /
                                "LIST" SPACE mailbox_list /
                                "LSUB" SPACE mailbox_list /
--- a/mailnews/imap/src/nsSyncRunnableHelpers.cpp
+++ b/mailnews/imap/src/nsSyncRunnableHelpers.cpp
@@ -435,17 +435,17 @@ NS_SYNCRUNNABLEMETHOD2(ImapMailFolderSin
 NS_SYNCRUNNABLEMETHOD2(ImapMailFolderSink, SetAppendMsgUid, nsMsgKey, nsIImapUrl *)
 NS_SYNCRUNNABLEMETHOD2(ImapMailFolderSink, GetMessageId, nsIImapUrl *, nsACString &)
 
 NS_SYNCRUNNABLEMETHOD2(ImapMessageSink, SetupMsgWriteStream, nsIFile *, bool)
 NS_SYNCRUNNABLEMETHOD4(ImapMessageSink, ParseAdoptedMsgLine, const char *, nsMsgKey, PRInt32, nsIImapUrl *)
 NS_SYNCRUNNABLEMETHOD3(ImapMessageSink, NormalEndMsgWriteStream, nsMsgKey, bool, nsIImapUrl *)
 NS_SYNCRUNNABLEMETHOD0(ImapMessageSink, AbortMsgWriteStream)
 NS_SYNCRUNNABLEMETHOD0(ImapMessageSink, BeginMessageUpload)
-NS_SYNCRUNNABLEMETHOD3(ImapMessageSink, NotifyMessageFlags, PRUint32, nsMsgKey, PRUint64)
+NS_SYNCRUNNABLEMETHOD4(ImapMessageSink, NotifyMessageFlags, PRUint32, const nsACString &, nsMsgKey, PRUint64)
 NS_SYNCRUNNABLEMETHOD3(ImapMessageSink, NotifyMessageDeleted, const char *, bool, const char *)
 NS_SYNCRUNNABLEMETHOD2(ImapMessageSink, GetMessageSizeFromDB, const char *, PRUint32 *)
 NS_SYNCRUNNABLEMETHOD2(ImapMessageSink, SetContentModified, nsIImapUrl *, nsImapContentModifiedType)
 NS_SYNCRUNNABLEMETHOD1(ImapMessageSink, SetImageCacheSessionForUrl, nsIMsgMailNewsUrl *)
 NS_SYNCRUNNABLEMETHOD4(ImapMessageSink, GetCurMoveCopyMessageInfo, nsIImapUrl *, PRTime *, nsACString &, PRUint32 *)
 
 NS_SYNCRUNNABLEMETHOD4(ImapServerSink, PossibleImapMailbox, const nsACString &, char, PRInt32, bool *)
 NS_SYNCRUNNABLEMETHOD2(ImapServerSink, FolderNeedsACLInitialized, const nsACString &, bool *)
--- a/mailnews/imap/test/unit/test_imapFilterActions.js
+++ b/mailnews/imap/test/unit/test_imapFilterActions.js
@@ -258,26 +258,26 @@ const gTestArray =
     }
     setupTest(gBodyFilter, gAction);
   },
   function AddTag() {
     gAction.type = Ci.nsMsgFilterAction.AddTag;
     gAction.strValue = "TheTag";
     gChecks = function checkAddTag() {
       testCounts(true, 1, 1, 1);
-      do_check_eq(gHeader.getStringProperty("keywords"), "TheTag");
+      do_check_eq(gHeader.getStringProperty("keywords"), "thetag");
     }
     setupTest(gFilter, gAction);
   },
   function AddTagBody() {
     gAction.type = Ci.nsMsgFilterAction.AddTag;
     gAction.strValue = "TheTag2";
     gChecks = function checkAddTagBody() {
       testCounts(true, 1, 1, 1);
-      do_check_eq(gHeader.getStringProperty("keywords"), "TheTag2");
+      do_check_eq(gHeader.getStringProperty("keywords"), "thetag2");
     }
     setupTest(gBodyFilter, gAction);
   },
   // this tests for marking message as good
   function JunkScoreAsGood() {
     gAction.type = Ci.nsMsgFilterAction.JunkScore;
     gAction.junkScore = 0;
     gChecks = function checkJunkScore() {