Bug 444932 - "nsMsgMessageFlags.h should be an idl file" [r+sr=Standard8]
authorSiddharth Agarwal <sid.bugzilla@gmail.com>
Mon, 26 Jan 2009 14:14:32 +0000
changeset 1757 0e339aad00cf357d0a609e0a857bae05ca83c0f5
parent 1756 d4ff0342ca4eb1630a3c889fa0c45c7c8099a485
child 1758 0ce79e592a21b9e4da574968d64d49a7541a4d30
push id1411
push userbugzilla@standard8.plus.com
push dateMon, 26 Jan 2009 14:15:23 +0000
treeherdercomm-central@0e339aad00cf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs444932
Bug 444932 - "nsMsgMessageFlags.h should be an idl file" [r+sr=Standard8]
mailnews/base/public/nsMsgMessageFlags.idl
mailnews/base/search/src/nsMsgFilterService.cpp
mailnews/base/search/src/nsMsgLocalSearch.cpp
mailnews/base/search/src/nsMsgSearchAdapter.cpp
mailnews/base/search/src/nsMsgSearchTerm.cpp
mailnews/base/src/nsMessenger.cpp
mailnews/base/src/nsMsgAccountManager.cpp
mailnews/base/src/nsMsgDBView.cpp
mailnews/base/src/nsMsgFolderCompactor.cpp
mailnews/base/src/nsMsgGroupThread.cpp
mailnews/base/src/nsMsgGroupView.cpp
mailnews/base/src/nsMsgQuickSearchDBView.cpp
mailnews/base/src/nsMsgSearchDBView.cpp
mailnews/base/src/nsMsgSpecialViews.cpp
mailnews/base/src/nsMsgThreadedDBView.cpp
mailnews/base/src/nsMsgXFViewThread.cpp
mailnews/base/src/nsMsgXFVirtualFolderDBView.cpp
mailnews/base/util/nsMsgDBFolder.cpp
mailnews/base/util/nsMsgDBFolder.h
mailnews/base/util/nsMsgTxn.cpp
mailnews/compose/src/nsMsgCompose.cpp
mailnews/compose/src/nsMsgCopy.cpp
mailnews/compose/src/nsMsgSend.cpp
mailnews/db/msgdb/public/nsImapMailDatabase.h
mailnews/db/msgdb/public/nsMailDatabase.h
mailnews/db/msgdb/public/nsMsgDatabase.h
mailnews/db/msgdb/src/nsImapMailDatabase.cpp
mailnews/db/msgdb/src/nsMailDatabase.cpp
mailnews/db/msgdb/src/nsMsgDatabase.cpp
mailnews/db/msgdb/src/nsMsgHdr.cpp
mailnews/db/msgdb/src/nsMsgThread.cpp
mailnews/db/msgdb/src/nsNewsDatabase.cpp
mailnews/imap/src/nsAutoSyncManager.cpp
mailnews/imap/src/nsAutoSyncState.cpp
mailnews/imap/src/nsImapMailFolder.cpp
mailnews/imap/src/nsImapOfflineSync.cpp
mailnews/imap/src/nsImapProtocol.cpp
mailnews/imap/src/nsImapService.cpp
mailnews/import/applemail/src/nsEmlxHelperUtils.mm
mailnews/import/eudora/src/nsEudoraMailbox.cpp
mailnews/local/src/nsLocalMailFolder.cpp
mailnews/local/src/nsParseMailbox.cpp
mailnews/local/src/nsPop3Protocol.cpp
mailnews/local/src/nsPop3Sink.cpp
mailnews/mapi/mapihook/src/msgMapiImp.cpp
mailnews/mime/src/mimemsg.cpp
mailnews/news/src/nsNNTPNewsgroupList.cpp
mailnews/news/src/nsNewsDownloader.cpp
--- a/mailnews/base/public/nsMsgMessageFlags.idl
+++ b/mailnews/base/public/nsMsgMessageFlags.idl
@@ -165,41 +165,8 @@ interface nsMsgProcessingFlags
   const nsMsgProcessingFlagType ClassifyJunk   = 0x00000001;
 
   /// This message needs traits classification
   const nsMsgProcessingFlagType ClassifyTraits = 0x00000002;
 
   /// Number of processing flags
   const nsMsgProcessingFlagType NumberOfFlags  = 2;
 };
-
-%{C++
-
-typedef PRInt32 MsgFlags;
-
-#define MSG_FLAG_READ              nsMsgMessageFlags::Read
-#define MSG_FLAG_REPLIED           nsMsgMessageFlags::Replied
-#define MSG_FLAG_MARKED            nsMsgMessageFlags::Marked
-#define MSG_FLAG_EXPUNGED          nsMsgMessageFlags::Expunged
-#define MSG_FLAG_HAS_RE            nsMsgMessageFlags::HasRe
-#define MSG_FLAG_ELIDED            nsMsgMessageFlags::Elided
-#define MSG_FLAG_OFFLINE           nsMsgMessageFlags::Offline
-#define MSG_FLAG_WATCHED           nsMsgMessageFlags::Watched
-#define MSG_FLAG_SENDER_AUTHED     nsMsgMessageFlags::SenderAuthed
-#define MSG_FLAG_PARTIAL           nsMsgMessageFlags::Partial
-#define MSG_FLAG_QUEUED            nsMsgMessageFlags::Queued
-#define MSG_FLAG_FORWARDED         nsMsgMessageFlags::Forwarded
-#define MSG_FLAG_PRIORITIES        nsMsgMessageFlags::Priorities
-#define MSG_FLAG_NEW               nsMsgMessageFlags::New
-#define MSG_FLAG_IGNORED           nsMsgMessageFlags::Ignored
-#define MSG_FLAG_IMAP_DELETED      nsMsgMessageFlags::IMAPDeleted
-#define MSG_FLAG_MDN_REPORT_NEEDED nsMsgMessageFlags::MDNReportNeeded
-#define MSG_FLAG_MDN_REPORT_SENT   nsMsgMessageFlags::MDNReportSent
-#define MSG_FLAG_TEMPLATE          nsMsgMessageFlags::Template
-#define MSG_FLAG_ATTACHMENT        nsMsgMessageFlags::Attachment
-#define MSG_FLAG_LABELS            nsMsgMessageFlags::Labels
-#define MSG_FLAG_RUNTIME_ONLY      nsMsgMessageFlags::RuntimeOnly
-
-#define MSG_PROCESSING_FLAG_CLASSIFY_JUNK   nsMsgProcessingFlags::ClassifyJunk
-#define MSG_PROCESSING_FLAG_CLASSIFY_TRAITS nsMsgProcessingFlags::ClassifyTraits
-#define MSG_NUMBER_OF_PROCESSING_FLAGS      nsMsgProcessingFlags::NumberOfFlags
-
-%}
--- a/mailnews/base/search/src/nsMsgFilterService.cpp
+++ b/mailnews/base/search/src/nsMsgFilterService.cpp
@@ -702,17 +702,17 @@ nsresult nsMsgFilterAfterTheFact::ApplyF
             for (PRUint32 msgIndex = 0; msgIndex < m_searchHits.Length(); msgIndex++)
             {
               nsCOMPtr <nsIMsgDBHdr> msgHdr;
               m_searchHitHdrs->QueryElementAt(msgIndex, NS_GET_IID(nsIMsgDBHdr), getter_AddRefs(msgHdr));
               if (msgHdr)
               {
                 PRUint32 flags;
                 msgHdr->GetFlags(&flags);
-                if (flags & MSG_FLAG_PARTIAL)
+                if (flags & nsMsgMessageFlags::Partial)
                 {
                   if (!partialMsgs)
                     partialMsgs = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
                   NS_ENSURE_SUCCESS(rv, rv);
                   partialMsgs->AppendElement(msgHdr, PR_FALSE);
                 }
               }
             }
@@ -731,17 +731,17 @@ nsresult nsMsgFilterAfterTheFact::ApplyF
             for (PRUint32 msgIndex = 0; msgIndex < m_searchHits.Length(); msgIndex++)
             {
               nsCOMPtr <nsIMsgDBHdr> msgHdr;
               m_searchHitHdrs->QueryElementAt(msgIndex, NS_GET_IID(nsIMsgDBHdr), getter_AddRefs(msgHdr));
               if (msgHdr)
               {
                 PRUint32 flags = 0;
                 msgHdr->GetFlags(&flags);
-                if (flags & MSG_FLAG_PARTIAL)
+                if (flags & nsMsgMessageFlags::Partial)
                   messages->AppendElement(msgHdr, PR_FALSE);
               }
             }
             PRUint32 msgsToFetch;
             messages->GetLength(&msgsToFetch);
             if (msgsToFetch > 0)
               m_curFolder->DownloadMessagesForOffline(messages, m_msgWindow);
           }
--- a/mailnews/base/search/src/nsMsgLocalSearch.cpp
+++ b/mailnews/base/search/src/nsMsgLocalSearch.cpp
@@ -465,17 +465,17 @@ nsresult nsMsgSearchOfflineMail::Process
     {
       case nsMsgSearchAttrib::Sender:
         msgToMatch->GetAuthor(getter_Copies(matchString));
         err = aTerm->MatchRfc822String (matchString.get(), charset, charsetOverride, &result);
         break;
       case nsMsgSearchAttrib::Subject:
       {
         msgToMatch->GetSubject(getter_Copies(matchString) /* , PR_TRUE */);
-        if (msgFlags & MSG_FLAG_HAS_RE)
+        if (msgFlags & nsMsgMessageFlags::HasRe)
         {
           // Make sure we pass along the "Re: " part of the subject if this is a reply.
           nsCString reString;
           reString.Assign("Re: ");
           reString.Append(matchString);
           err = aTerm->MatchRfc2047String(reString.get(), charset, charsetOverride, &result);
         }
         else
--- a/mailnews/base/search/src/nsMsgSearchAdapter.cpp
+++ b/mailnews/base/search/src/nsMsgSearchAdapter.cpp
@@ -436,26 +436,26 @@ nsresult nsMsgSearchAdapter::EncodeImapT
     case nsMsgSearchAttrib::MsgStatus:
       useNot = PR_FALSE; // bizarrely, NOT SEEN is wrong, but UNSEEN is right.
       ignoreValue = PR_TRUE; // the mnemonic is all we need
       PRUint32 status;
       searchValue->GetStatus(&status);
 
       switch (status)
       {
-      case MSG_FLAG_READ:
+      case nsMsgMessageFlags::Read:
         whichMnemonic = op == nsMsgSearchOp::Is ? m_kImapSeen : m_kImapNotSeen;
         break;
-      case MSG_FLAG_REPLIED:
+      case nsMsgMessageFlags::Replied:
         whichMnemonic = op == nsMsgSearchOp::Is ? m_kImapAnswered : m_kImapNotAnswered;
         break;
-      case MSG_FLAG_NEW:
+      case nsMsgMessageFlags::New:
         whichMnemonic = op == nsMsgSearchOp::Is ? m_kImapNew : m_kImapNotNew;
         break;
-      case MSG_FLAG_MARKED:
+      case nsMsgMessageFlags::Marked:
         whichMnemonic = op == nsMsgSearchOp::Is ? m_kImapFlagged : m_kImapNotFlagged;
         break;
       default:
         NS_ASSERTION(PR_FALSE, "invalid search operator");
         return NS_ERROR_INVALID_ARG;
       }
       break;
     default:
--- a/mailnews/base/search/src/nsMsgSearchTerm.cpp
+++ b/mailnews/base/search/src/nsMsgSearchTerm.cpp
@@ -284,75 +284,76 @@ nsresult NS_MsgGetStringForOperator(PRIn
   }
 
   return (found) ? NS_OK : NS_ERROR_INVALID_ARG;
 }
 
 void NS_MsgGetUntranslatedStatusName (uint32 s, nsCString *outName)
 {
   const char *tmpOutName = NULL;
-#define MSG_STATUS_MASK (MSG_FLAG_READ | MSG_FLAG_REPLIED | MSG_FLAG_FORWARDED | MSG_FLAG_NEW | MSG_FLAG_MARKED)
+#define MSG_STATUS_MASK (nsMsgMessageFlags::Read | nsMsgMessageFlags::Replied |\
+  nsMsgMessageFlags::Forwarded | nsMsgMessageFlags::New | nsMsgMessageFlags::Marked)
   PRUint32 maskOut = (s & MSG_STATUS_MASK);
 
   // diddle the flags to pay attention to the most important ones first, if multiple
   // flags are set. Should remove this code from the winfe.
-  if (maskOut & MSG_FLAG_NEW)
-    maskOut = MSG_FLAG_NEW;
-  if ( maskOut & MSG_FLAG_REPLIED &&
-     maskOut & MSG_FLAG_FORWARDED )
-    maskOut = MSG_FLAG_REPLIED|MSG_FLAG_FORWARDED;
-  else if ( maskOut & MSG_FLAG_FORWARDED )
-    maskOut = MSG_FLAG_FORWARDED;
-  else if ( maskOut & MSG_FLAG_REPLIED )
-    maskOut = MSG_FLAG_REPLIED;
+  if (maskOut & nsMsgMessageFlags::New)
+    maskOut = nsMsgMessageFlags::New;
+  if (maskOut & nsMsgMessageFlags::Replied &&
+      maskOut & nsMsgMessageFlags::Forwarded)
+    maskOut = nsMsgMessageFlags::Replied | nsMsgMessageFlags::Forwarded;
+  else if (maskOut & nsMsgMessageFlags::Forwarded)
+    maskOut = nsMsgMessageFlags::Forwarded;
+  else if (maskOut & nsMsgMessageFlags::Replied)
+    maskOut = nsMsgMessageFlags::Replied;
 
   switch (maskOut)
   {
-  case MSG_FLAG_READ:
+  case nsMsgMessageFlags::Read:
     tmpOutName = "read";
     break;
-  case MSG_FLAG_REPLIED:
+  case nsMsgMessageFlags::Replied:
     tmpOutName = "replied";
     break;
-  case MSG_FLAG_FORWARDED:
+  case nsMsgMessageFlags::Forwarded:
     tmpOutName = "forwarded";
     break;
-  case MSG_FLAG_FORWARDED|MSG_FLAG_REPLIED:
+  case nsMsgMessageFlags::Forwarded | nsMsgMessageFlags::Replied:
     tmpOutName = "replied and forwarded";
     break;
-  case MSG_FLAG_NEW:
+  case nsMsgMessageFlags::New:
     tmpOutName = "new";
     break;
-        case MSG_FLAG_MARKED:
-                tmpOutName = "flagged";
-                break;
+  case nsMsgMessageFlags::Marked:
+    tmpOutName = "flagged";
+    break;
   default:
     // This is fine, status may be "unread" for example
-        break;
+    break;
   }
 
   if (tmpOutName)
     *outName = tmpOutName;
 }
 
 
 PRInt32 NS_MsgGetStatusValueFromName(char *name)
 {
   if (!strcmp("read", name))
-    return MSG_FLAG_READ;
+    return nsMsgMessageFlags::Read;
   if (!strcmp("replied", name))
-    return MSG_FLAG_REPLIED;
+    return nsMsgMessageFlags::Replied;
   if (!strcmp("forwarded", name))
-    return MSG_FLAG_FORWARDED;
+    return nsMsgMessageFlags::Forwarded;
   if (!strcmp("replied and forwarded", name))
-    return MSG_FLAG_FORWARDED|MSG_FLAG_REPLIED;
+    return nsMsgMessageFlags::Forwarded | nsMsgMessageFlags::Replied;
   if (!strcmp("new", name))
-    return MSG_FLAG_NEW;
+    return nsMsgMessageFlags::New;
   if (!strcmp("flagged", name))
-    return MSG_FLAG_MARKED;
+    return nsMsgMessageFlags::Marked;
   return 0;
 }
 
 
 // Needed for DeStream method.
 nsMsgSearchTerm::nsMsgSearchTerm()
 {
     // initialize this to zero
@@ -601,17 +602,17 @@ nsresult nsMsgSearchTerm::ParseValue(cha
       break;
     case nsMsgSearchAttrib::JunkStatus:
       m_value.u.junkStatus = atoi(inStream); // only if we read from disk, right?
       break;
     case nsMsgSearchAttrib::JunkPercent:
       m_value.u.junkPercent = atoi(inStream);
       break;
     case nsMsgSearchAttrib::HasAttachmentStatus:
-      m_value.u.msgStatus = MSG_FLAG_ATTACHMENT;
+      m_value.u.msgStatus = nsMsgMessageFlags::Attachment;
       break; // this should always be true.
     case nsMsgSearchAttrib::Size:
       m_value.u.size = atoi(inStream);
       break;
     default:
       NS_ASSERTION(PR_FALSE, "invalid attribute parsing search term value");
       break;
     }
--- a/mailnews/base/src/nsMessenger.cpp
+++ b/mailnews/base/src/nsMessenger.cpp
@@ -1516,17 +1516,18 @@ nsSaveMsgListener::OnStopRunningUrl(nsIU
       templateFolder = do_QueryInterface(res, &rv);
       if (NS_FAILED(rv)) goto done;
       nsCOMPtr<nsIMsgCopyService> copyService = do_GetService(NS_MSGCOPYSERVICE_CONTRACTID);
       if (copyService)
       {
         nsCOMPtr <nsIFile> clone;
         m_file->Clone(getter_AddRefs(clone));
         rv = copyService->CopyFileMessage(clone, templateFolder, nsnull,
-                                          PR_TRUE, MSG_FLAG_READ, EmptyCString(), this, nsnull);
+                                          PR_TRUE, nsMsgMessageFlags::Read,
+                                          EmptyCString(), this, nsnull);
       }
       killSelf = PR_FALSE;
     }
   }
 
 done:
   if (NS_FAILED(rv))
   {
--- a/mailnews/base/src/nsMsgAccountManager.cpp
+++ b/mailnews/base/src/nsMsgAccountManager.cpp
@@ -2438,35 +2438,37 @@ VirtualFolderChangeListener::OnHdrProper
   NS_ENSURE_SUCCESS(rv, rv);
   aHdrChanged->GetFlags(&flags);
   
   if (aPreChange) // We're looking at the old header, save status
   {
     *aStatus = 0;
     if (match)
       *aStatus |= kMatch;
-    if (flags & MSG_FLAG_READ)
+    if (flags & nsMsgMessageFlags::Read)
       *aStatus |= kRead;
-    if (flags & MSG_FLAG_NEW)
+    if (flags & nsMsgMessageFlags::New)
       *aStatus |= kNew;
     return NS_OK;
   }
   
   // This is the post change section where changes are detected
 
   PRBool wasMatch = *aStatus & kMatch;
   if (!match && !wasMatch) // header not in virtual folder
     return NS_OK;
 
   PRInt32 totalDelta = 0, unreadDelta = 0, newDelta = 0;
 
   if (match) {
     totalDelta++;
-    if (!(flags & MSG_FLAG_READ)) unreadDelta++;
-    if (flags & MSG_FLAG_NEW) newDelta++;
+    if (!(flags & nsMsgMessageFlags::Read))
+      unreadDelta++;
+    if (flags & nsMsgMessageFlags::New)
+      newDelta++;
   }
 
   if (wasMatch) {
     totalDelta--;
     if (!(*aStatus & kRead)) unreadDelta--;
     if (*aStatus & kNew) newDelta--;
   }
 
@@ -2528,17 +2530,17 @@ NS_IMETHODIMP VirtualFolderChangeListene
   NS_ENSURE_SUCCESS(rv, rv);
   // we don't want to change the total counts if this virtual folder is open in a view,
   // because we won't remove the header from view while it's open. On the other hand,
   // it's hard to fix the count when the user clicks away to another folder, w/o re-running
   // the search, or setting some sort of pending count change.
   // Maybe this needs to be handled in the view code...the view could do the same calculation
   // and also keep track of the counts changed. Then, when the view was closed, if it's a virtual
   // folder, it could update the counts for the db.
-  if (oldMatch != newMatch || (oldMatch && (aOldFlags & MSG_FLAG_READ) != (aNewFlags & MSG_FLAG_READ)))
+  if (oldMatch != newMatch || (oldMatch && (aOldFlags & nsMsgMessageFlags::Read) != (aNewFlags & nsMsgMessageFlags::Read)))
   {
     nsCOMPtr <nsIMsgDatabase> virtDatabase;
     nsCOMPtr <nsIDBFolderInfo> dbFolderInfo;
 
     rv = m_virtualFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo), getter_AddRefs(virtDatabase));
     NS_ENSURE_SUCCESS(rv, rv);
     PRInt32 totalDelta = 0,  unreadDelta = 0;
     if (oldMatch != newMatch)
@@ -2551,24 +2553,24 @@ NS_IMETHODIMP VirtualFolderChangeListene
 //      if (!isOpen)
         totalDelta = (oldMatch) ? -1 : 1;
     }
     PRBool msgHdrIsRead;
     aHdrChanged->GetIsRead(&msgHdrIsRead);
     if (oldMatch == newMatch) // read flag changed state
       unreadDelta = (msgHdrIsRead) ? -1 : 1;
     else if (oldMatch) // else header should removed
-      unreadDelta = (aOldFlags & MSG_FLAG_READ) ? 0 : -1;
+      unreadDelta = (aOldFlags & nsMsgMessageFlags::Read) ? 0 : -1;
     else               // header should be added
-      unreadDelta = (aNewFlags & MSG_FLAG_READ) ? 0 : 1;
+      unreadDelta = (aNewFlags & nsMsgMessageFlags::Read) ? 0 : 1;
     if (unreadDelta)
       dbFolderInfo->ChangeNumUnreadMessages(unreadDelta);
     if (totalDelta)
       dbFolderInfo->ChangeNumMessages(totalDelta);
-    if (unreadDelta == -1 && aOldFlags & MSG_FLAG_NEW)
+    if (unreadDelta == -1 && aOldFlags & nsMsgMessageFlags::New)
     {
       PRInt32 numNewMessages;
       m_virtualFolder->GetNumNewMessages(PR_FALSE, &numNewMessages);
       m_virtualFolder->SetNumNewMessages(numNewMessages - 1);
       if (numNewMessages == 1)
         m_virtualFolder->SetHasNewMessages(PR_FALSE);
     }
     if (totalDelta)
@@ -2601,17 +2603,17 @@ NS_IMETHODIMP VirtualFolderChangeListene
 
     rv = m_virtualFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo), getter_AddRefs(virtDatabase));
     NS_ENSURE_SUCCESS(rv, rv);
     PRBool msgHdrIsRead;
     aHdrDeleted->GetIsRead(&msgHdrIsRead);
     if (!msgHdrIsRead)
       dbFolderInfo->ChangeNumUnreadMessages(-1);
     dbFolderInfo->ChangeNumMessages(-1);
-    if (aFlags & MSG_FLAG_NEW)
+    if (aFlags & nsMsgMessageFlags::New)
     {
       PRInt32 numNewMessages;
       m_virtualFolder->GetNumNewMessages(PR_FALSE, &numNewMessages);
       m_virtualFolder->SetNumNewMessages(numNewMessages - 1);
       if (numNewMessages == 1)
         m_virtualFolder->SetHasNewMessages(PR_FALSE);
     }
     
@@ -2643,17 +2645,17 @@ NS_IMETHODIMP VirtualFolderChangeListene
     rv = m_virtualFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo), getter_AddRefs(virtDatabase));
     NS_ENSURE_SUCCESS(rv, rv);
     PRBool msgHdrIsRead;
     PRUint32 msgFlags;
     aNewHdr->GetIsRead(&msgHdrIsRead);
     aNewHdr->GetFlags(&msgFlags);
     if (!msgHdrIsRead)
       dbFolderInfo->ChangeNumUnreadMessages(1);
-    if (msgFlags & MSG_FLAG_NEW)
+    if (msgFlags & nsMsgMessageFlags::New)
     {
       PRInt32 numNewMessages;
       m_virtualFolder->GetNumNewMessages(PR_FALSE, &numNewMessages);
       m_virtualFolder->SetHasNewMessages(PR_TRUE);
       m_virtualFolder->SetNumNewMessages(numNewMessages + 1);
     }
     nsCString searchUri;
     m_virtualFolder->GetURI(searchUri);
--- a/mailnews/base/src/nsMsgDBView.cpp
+++ b/mailnews/base/src/nsMsgDBView.cpp
@@ -451,17 +451,17 @@ nsresult nsMsgDBView::FetchRecipients(ns
   }
 
   aRecipientsString = unparsedRecipients;
   return NS_OK;
 }
 
 nsresult nsMsgDBView::FetchSubject(nsIMsgDBHdr * aMsgHdr, PRUint32 aFlags, nsAString &aValue)
 {
-  if (aFlags & MSG_FLAG_HAS_RE)
+  if (aFlags & nsMsgMessageFlags::HasRe)
   {
     nsString subject;
     aMsgHdr->GetMime2DecodedSubject(subject);
     aValue.AssignLiteral("Re: ");
     aValue.Append(subject);
   }
   else
     aMsgHdr->GetMime2DecodedSubject(aValue);
@@ -565,23 +565,23 @@ nsresult nsMsgDBView::FetchDate(nsIMsgDB
                                       dateOfMsg,
                                       aDateString);
 
   return rv;
 }
 
 nsresult nsMsgDBView::FetchStatus(PRUint32 aFlags, nsAString &aStatusString)
 {
-  if(aFlags & MSG_FLAG_REPLIED)
+  if (aFlags & nsMsgMessageFlags::Replied)
     aStatusString = kRepliedString;
-  else if(aFlags & MSG_FLAG_FORWARDED)
+  else if (aFlags & nsMsgMessageFlags::Forwarded)
     aStatusString = kForwardedString;
-  else if(aFlags & MSG_FLAG_NEW)
+  else if (aFlags & nsMsgMessageFlags::New)
     aStatusString = kNewString;
-  else if(aFlags & MSG_FLAG_READ)
+  else if (aFlags & nsMsgMessageFlags::Read)
     aStatusString = kReadString;
 
   return NS_OK;
 }
 
 nsresult nsMsgDBView::FetchSize(nsIMsgDBHdr * aHdr, nsAString &aSizeString)
 {
   nsAutoString formattedSizeString;
@@ -593,17 +593,17 @@ nsresult nsMsgDBView::FetchSize(nsIMsgDB
     aHdr->GetLineCount(&msgSize);
     formattedSizeString.AppendInt(msgSize);
   }
   else
   {
     PRUint32 flags = 0;
 
     aHdr->GetFlags(&flags);
-    if (flags & MSG_FLAG_PARTIAL)
+    if (flags & nsMsgMessageFlags::Partial)
       aHdr->GetUint32Property("onlineSize", &msgSize);
 
     if (msgSize == 0)
       aHdr->GetMessageSize(&msgSize);
 
     if(msgSize < 1024)
       msgSize = 1024;
 
@@ -1207,42 +1207,42 @@ NS_IMETHODIMP nsMsgDBView::GetCellProper
   {
     ClearHdrCache();
     return NS_MSG_INVALID_DBVIEW_INDEX;
   }
 
   PRUint32 flags;
   msgHdr->GetFlags(&flags);
 
-  if (!(flags & MSG_FLAG_READ))
+  if (!(flags & nsMsgMessageFlags::Read))
     properties->AppendElement(kUnreadMsgAtom);
   else
     properties->AppendElement(kReadMsgAtom);
 
-  if (flags & MSG_FLAG_REPLIED)
+  if (flags & nsMsgMessageFlags::Replied)
     properties->AppendElement(kRepliedMsgAtom);
 
-  if (flags & MSG_FLAG_FORWARDED)
+  if (flags & nsMsgMessageFlags::Forwarded)
     properties->AppendElement(kForwardedMsgAtom);
 
-  if (flags & MSG_FLAG_NEW)
+  if (flags & nsMsgMessageFlags::New)
     properties->AppendElement(kNewMsgAtom);
 
-  if (flags & MSG_FLAG_IGNORED)
+  if (flags & nsMsgMessageFlags::Ignored)
     properties->AppendElement(kIgnoreSubthreadAtom);
 
   nsCOMPtr <nsIMsgLocalMailFolder> localFolder = do_QueryInterface(m_folder);
 
-  if ((flags & MSG_FLAG_OFFLINE) || (localFolder && !(flags & MSG_FLAG_PARTIAL)))
+  if ((flags & nsMsgMessageFlags::Offline) || (localFolder && !(flags & nsMsgMessageFlags::Partial)))
     properties->AppendElement(kOfflineMsgAtom);
 
-  if (flags & MSG_FLAG_ATTACHMENT)
+  if (flags & nsMsgMessageFlags::Attachment)
     properties->AppendElement(kAttachMsgAtom);
 
-  if ((mDeleteModel == nsMsgImapDeleteModels::IMAPDelete) && (flags & MSG_FLAG_IMAP_DELETED))
+  if ((mDeleteModel == nsMsgImapDeleteModels::IMAPDelete) && (flags & nsMsgMessageFlags::IMAPDeleted))
     properties->AppendElement(kImapDeletedMsgAtom);
 
   if (mMessageTypeAtom)
     properties->AppendElement(mMessageTypeAtom);
 
   nsCString imageSize;
   msgHdr->GetStringProperty("imageSize", getter_Copies(imageSize));
   if (!imageSize.IsEmpty())
@@ -1310,17 +1310,17 @@ NS_IMETHODIMP nsMsgDBView::GetCellProper
     break;
   }
 #endif
 
   const PRUnichar* colID;
   col->GetIdConst(&colID);
   if (colID[0] == 'f')
   {
-    if (m_flags[aRow] & MSG_FLAG_MARKED)
+    if (m_flags[aRow] & nsMsgMessageFlags::Marked)
     {
       properties->AppendElement(kFlaggedMsgAtom);
     }
   }
 
   if (m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay)
   {
     if (m_flags[aRow] & MSG_VIEW_FLAG_ISTHREAD)
@@ -1329,19 +1329,19 @@ NS_IMETHODIMP nsMsgDBView::GetCellProper
       rv = GetThreadContainingIndex(aRow, getter_AddRefs(thread));
       if (NS_SUCCEEDED(rv) && thread)
       {
         PRUint32 numUnreadChildren;
         thread->GetNumUnreadChildren(&numUnreadChildren);
         if (numUnreadChildren > 0)
           properties->AppendElement(kHasUnreadAtom);
         thread->GetFlags(&flags);
-        if (flags & MSG_FLAG_WATCHED)
+        if (flags & nsMsgMessageFlags::Watched)
           properties->AppendElement(kWatchThreadAtom);
-        if (flags & MSG_FLAG_IGNORED)
+        if (flags & nsMsgMessageFlags::Ignored)
           properties->AppendElement(kIgnoreThreadAtom);
       }
     }
   }
 
   //custom column handlers are called at the end of getCellProperties
   //to make life easier for extension writers
   nsIMsgCustomColumnHandler* colHandler = GetColumnHandler(colID);
@@ -1373,17 +1373,17 @@ NS_IMETHODIMP nsMsgDBView::IsContainer(P
 NS_IMETHODIMP nsMsgDBView::IsContainerOpen(PRInt32 index, PRBool *_retval)
 {
   if (!IsValidIndex(index))
       return NS_MSG_INVALID_DBVIEW_INDEX;
 
   if (m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay)
   {
     PRUint32 flags = m_flags[index];
-    *_retval = (flags & MSG_VIEW_FLAG_HASCHILDREN) && !(flags & MSG_FLAG_ELIDED);
+    *_retval = (flags & MSG_VIEW_FLAG_HASCHILDREN) && !(flags & nsMsgMessageFlags::Elided);
   }
   else
     *_retval = PR_FALSE;
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgDBView::IsContainerEmpty(PRInt32 index, PRBool *_retval)
 {
@@ -1568,22 +1568,22 @@ NS_IMETHODIMP nsMsgDBView::GetCellValue(
   PRUint32 flags;
   msgHdr->GetFlags(&flags);
 
   // provide a string "value" for cells that do not normally have text.
   // use empty string for the normal states "Read", "Not Starred", "No Attachment" and "Not Junk"
   switch (colID[0])
   {
     case 'a': // attachment column
-      aValue.Assign(GetString ((flags & MSG_FLAG_ATTACHMENT) ?
+      aValue.Assign(GetString ((flags & nsMsgMessageFlags::Attachment) ?
       NS_LITERAL_STRING("messageHasAttachment").get()
       : EmptyString().get()));
       break;
     case 'f': // flagged (starred) column
-      aValue.Assign(GetString ((flags & MSG_FLAG_MARKED) ?
+      aValue.Assign(GetString ((flags & nsMsgMessageFlags::Marked) ?
       NS_LITERAL_STRING("messageHasFlag").get()
       : EmptyString().get()));
       break;
     case 'j': // junk column
       if (!mIsNews)
       {
         nsCString junkScoreStr;
         msgHdr->GetStringProperty("junkscore", getter_Copies(junkScoreStr));
@@ -1610,17 +1610,17 @@ NS_IMETHODIMP nsMsgDBView::GetCellValue(
             aValue.Assign(GetString (isContainerOpen ?
              NS_LITERAL_STRING("messageExpanded").get()
              : NS_LITERAL_STRING("messageCollapsed").get()));
           }
         }
       }
       break;
     case 'u': // read/unread column
-      aValue.Assign(GetString ((flags & MSG_FLAG_READ) ?
+      aValue.Assign(GetString ((flags & nsMsgMessageFlags::Read) ?
       EmptyString().get() : NS_LITERAL_STRING("messageUnread").get()));
       break;
     default:
       aValue.Assign(colID);
       break;
   }
 
   return rv;
@@ -1932,17 +1932,17 @@ NS_IMETHODIMP nsMsgDBView::CycleCell(PRI
       // ### Do we want to keep this behaviour but switch it to tags?
       // We could enumerate over the tags and go to the next one - it looks
       // to me like this wasn't working before tags landed, so maybe not
       // worth bothering with.
     }
     break;
   case 'f': // flagged column
     // toggle the flagged status of the element at row.
-    if (m_flags[row] & MSG_FLAG_MARKED)
+    if (m_flags[row] & nsMsgMessageFlags::Marked)
       ApplyCommandToIndices(nsMsgViewCommandType::unflagMessages, (nsMsgViewIndex *) &row, 1);
     else
       ApplyCommandToIndices(nsMsgViewCommandType::flagMessages, (nsMsgViewIndex *) &row, 1);
     break;
   case 'j': // junkStatus column
     {
       if (mIsNews) // junk not supported for news yet.
         return NS_OK;
@@ -2300,17 +2300,17 @@ NS_IMETHODIMP nsMsgDBView::DoCommand(nsM
     else
     {
       mTreeSelection->SetSelectEventsSuppressed(PR_TRUE);
       mTreeSelection->ClearSelection();
       // XXX ExpandAll?
       nsMsgViewIndex numIndices = GetSize();
       for (nsMsgViewIndex curIndex = 0; curIndex < numIndices; curIndex++)
       {
-        if (m_flags[curIndex] & MSG_FLAG_MARKED)
+        if (m_flags[curIndex] & nsMsgMessageFlags::Marked)
           mTreeSelection->ToggleSelect(curIndex);
       }
       mTreeSelection->SetSelectEventsSuppressed(PR_FALSE);
     }
     break;
   case nsMsgViewCommandType::markAllRead:
     if (m_folder)
       rv = m_folder->MarkAllMessagesRead(msgWindow);
@@ -2637,17 +2637,17 @@ nsMsgDBView::ApplyCommandToIndices(nsMsg
       addFlags = PR_TRUE;
       break;
     case nsMsgViewCommandType::markMessagesUnread:
       flags |= kImapMsgSeenFlag;
       addFlags = PR_FALSE;
       break;
     case nsMsgViewCommandType::toggleMessageRead:
       flags |= kImapMsgSeenFlag;
-      addFlags = m_flags[indices[0]] & MSG_FLAG_READ;
+      addFlags = m_flags[indices[0]] & nsMsgMessageFlags::Read;
       break;
     case nsMsgViewCommandType::flagMessages:
       flags |= kImapMsgFlaggedFlag;
       addFlags = PR_TRUE;
       break;
     case nsMsgViewCommandType::unflagMessages:
       flags |= kImapMsgFlaggedFlag;
       addFlags = PR_FALSE;
@@ -2744,17 +2744,17 @@ nsresult nsMsgDBView::DownloadForOffline
     nsMsgKey key = m_keys[indices[index]];
     nsCOMPtr <nsIMsgDBHdr> msgHdr;
     rv = m_db->GetMsgHdrForKey(key, getter_AddRefs(msgHdr));
     NS_ENSURE_SUCCESS(rv,rv);
     if (msgHdr)
     {
       PRUint32 flags;
       msgHdr->GetFlags(&flags);
-      if (!(flags & MSG_FLAG_OFFLINE))
+      if (!(flags & nsMsgMessageFlags::Offline))
         messageArray->AppendElement(msgHdr, PR_FALSE);
     }
   }
   m_folder->DownloadMessagesForOffline(messageArray, window);
   return rv;
 }
 
 nsresult nsMsgDBView::DownloadFlaggedForOffline(nsIMsgWindow *window)
@@ -2771,54 +2771,54 @@ nsresult nsMsgDBView::DownloadFlaggedFor
     {
       nsCOMPtr <nsIMsgDBHdr> pHeader;
       rv = enumerator->GetNext(getter_AddRefs(pHeader));
       NS_ASSERTION(NS_SUCCEEDED(rv), "nsMsgDBEnumerator broken");
       if (pHeader && NS_SUCCEEDED(rv))
       {
         PRUint32 flags;
         pHeader->GetFlags(&flags);
-        if ((flags & MSG_FLAG_MARKED) && !(flags & MSG_FLAG_OFFLINE))
+        if ((flags & nsMsgMessageFlags::Marked) && !(flags & nsMsgMessageFlags::Offline))
           messageArray->AppendElement(pHeader, PR_FALSE);
       }
     }
   }
   m_folder->DownloadMessagesForOffline(messageArray, window);
   return rv;
 }
 
 // read/unread handling.
 nsresult nsMsgDBView::ToggleReadByIndex(nsMsgViewIndex index)
 {
   if (!IsValidIndex(index))
     return NS_MSG_INVALID_DBVIEW_INDEX;
-  return SetReadByIndex(index, !(m_flags[index] & MSG_FLAG_READ));
+  return SetReadByIndex(index, !(m_flags[index] & nsMsgMessageFlags::Read));
 }
 
 nsresult nsMsgDBView::SetReadByIndex(nsMsgViewIndex index, PRBool read)
 {
   nsresult rv;
 
   if (!IsValidIndex(index))
     return NS_MSG_INVALID_DBVIEW_INDEX;
   if (read)
   {
-    OrExtraFlag(index, MSG_FLAG_READ);
+    OrExtraFlag(index, nsMsgMessageFlags::Read);
     // MarkRead() will clear this flag in the db
     // and then call OnKeyChange(), but
     // because we are the instigator of the change
     // we'll ignore the change.
     //
     // so we need to clear it in m_flags
     // to keep the db and m_flags in sync
-    AndExtraFlag(index, ~MSG_FLAG_NEW);
+    AndExtraFlag(index, ~nsMsgMessageFlags::New);
   }
   else
   {
-    AndExtraFlag(index, ~MSG_FLAG_READ);
+    AndExtraFlag(index, ~nsMsgMessageFlags::Read);
   }
 
   nsCOMPtr <nsIMsgDatabase> dbToUse;
   rv = GetDBForViewIndex(index, getter_AddRefs(dbToUse));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = dbToUse->MarkRead(m_keys[index], read, this);
   NoteChange(index, 1, nsMsgViewNotificationCode::changed);
@@ -2848,19 +2848,19 @@ nsresult nsMsgDBView::SetFlaggedByIndex(
   if (!IsValidIndex(index))
     return NS_MSG_INVALID_DBVIEW_INDEX;
 
   nsCOMPtr <nsIMsgDatabase> dbToUse;
   rv = GetDBForViewIndex(index, getter_AddRefs(dbToUse));
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (mark)
-    OrExtraFlag(index, MSG_FLAG_MARKED);
+    OrExtraFlag(index, nsMsgMessageFlags::Marked);
   else
-    AndExtraFlag(index, ~MSG_FLAG_MARKED);
+    AndExtraFlag(index, ~nsMsgMessageFlags::Marked);
 
   rv = dbToUse->MarkMarked(m_keys[index], mark, this);
   NoteChange(index, 1, nsMsgViewNotificationCode::changed);
   return rv;
 }
 
 nsresult nsMsgDBView::SetStringPropertyByIndex(nsMsgViewIndex index, const char *aProperty, const char *aValue)
 {
@@ -3374,47 +3374,47 @@ nsresult nsMsgDBView::GetFieldTypeAndLen
         }
         default:
             return NS_ERROR_UNEXPECTED;
     }
 
     return NS_OK;
 }
 
-#define MSG_STATUS_MASK (MSG_FLAG_REPLIED | MSG_FLAG_FORWARDED)
+#define MSG_STATUS_MASK (nsMsgMessageFlags::Replied | nsMsgMessageFlags::Forwarded)
 
 nsresult nsMsgDBView::GetStatusSortValue(nsIMsgDBHdr *msgHdr, PRUint32 *result)
 {
   NS_ENSURE_ARG_POINTER(msgHdr);
   NS_ENSURE_ARG_POINTER(result);
 
   PRUint32 messageFlags;
   nsresult rv = msgHdr->GetFlags(&messageFlags);
   NS_ENSURE_SUCCESS(rv,rv);
 
-  if (messageFlags & MSG_FLAG_NEW)
+  if (messageFlags & nsMsgMessageFlags::New)
   {
     // happily, new by definition stands alone
     *result = 0;
     return NS_OK;
   }
 
   switch (messageFlags & MSG_STATUS_MASK)
   {
-    case MSG_FLAG_REPLIED:
+    case nsMsgMessageFlags::Replied:
         *result = 2;
         break;
-    case MSG_FLAG_FORWARDED|MSG_FLAG_REPLIED:
+    case nsMsgMessageFlags::Forwarded | nsMsgMessageFlags::Replied:
         *result = 1;
         break;
-    case MSG_FLAG_FORWARDED:
+    case nsMsgMessageFlags::Forwarded:
         *result = 3;
         break;
     default:
-        *result = (messageFlags & MSG_FLAG_READ) ? 4 : 5;
+        *result = (messageFlags & nsMsgMessageFlags::Read) ? 4 : 5;
         break;
     }
 
     return NS_OK;
 }
 
 nsresult nsMsgDBView::GetLongField(nsIMsgDBHdr *msgHdr, nsMsgViewSortTypeValue sortType, PRUint32 *result, nsIMsgCustomColumnHandler* colHandler)
 {
@@ -3443,17 +3443,17 @@ nsresult nsMsgDBView::GetLongField(nsIMs
         *result = nsMsgPriority::highest - priority;
         break;
     case nsMsgViewSortType::byStatus:
         rv = GetStatusSortValue(msgHdr,result);
         break;
     case nsMsgViewSortType::byFlagged:
         bits = 0;
         rv = msgHdr->GetFlags(&bits);
-        *result = !(bits & MSG_FLAG_MARKED);  //make flagged come out on top.
+        *result = !(bits & nsMsgMessageFlags::Marked);  //make flagged come out on top.
         break;
     case nsMsgViewSortType::byUnread:
         rv = msgHdr->GetIsRead(&isRead);
         if (NS_SUCCEEDED(rv))
             *result = !isRead;
         break;
     case nsMsgViewSortType::byJunkStatus:
       {
@@ -3463,17 +3463,17 @@ nsresult nsMsgDBView::GetLongField(nsIMs
         // junkScoreStr is "", and "0" - "100"
         // normalize to 0 - 101
         *result = junkScoreStr.IsEmpty() ? (0) : atoi(junkScoreStr.get()) + 1;
       }
       break;
      case nsMsgViewSortType::byAttachments:
         bits = 0;
         rv = msgHdr->GetFlags(&bits);
-        *result = !(bits & MSG_FLAG_ATTACHMENT);
+        *result = !(bits & nsMsgMessageFlags::Attachment);
       break;
     case nsMsgViewSortType::byDate:
       // when sorting threads by date, we want the date of the newest msg
       // in the thread
       if (m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay
         && ! (m_viewFlags & nsMsgViewFlagsType::kGroupBySort))
       {
         nsCOMPtr <nsIMsgThread> thread;
@@ -4165,29 +4165,29 @@ nsMsgViewIndex nsMsgDBView::FindHdr(nsIM
 }
 
 nsMsgViewIndex  nsMsgDBView::FindKey(nsMsgKey key, PRBool expand)
 {
   nsMsgViewIndex retIndex = nsMsgViewIndex_None;
   retIndex = (nsMsgViewIndex) (m_keys.IndexOf(key));
   // for dummy headers, try to expand if the caller says so. And if the thread is
   // expanded, ignore the dummy header and return the real header index.
-  if (retIndex != nsMsgViewIndex_None && m_flags[retIndex] & MSG_VIEW_FLAG_DUMMY &&  !(m_flags[retIndex] & MSG_FLAG_ELIDED))
+  if (retIndex != nsMsgViewIndex_None && m_flags[retIndex] & MSG_VIEW_FLAG_DUMMY &&  !(m_flags[retIndex] & nsMsgMessageFlags::Elided))
     return (nsMsgViewIndex) m_keys.IndexOf(key, retIndex + 1);
   if (key != nsMsgKey_None && (retIndex == nsMsgViewIndex_None || m_flags[retIndex] & MSG_VIEW_FLAG_DUMMY)
     && expand && m_db)
   {
     nsMsgKey threadKey = GetKeyOfFirstMsgInThread(key);
     if (threadKey != nsMsgKey_None)
     {
       nsMsgViewIndex threadIndex = FindKey(threadKey, PR_FALSE);
       if (threadIndex != nsMsgViewIndex_None)
       {
         PRUint32 flags = m_flags[threadIndex];
-        if ((flags & MSG_FLAG_ELIDED) && NS_SUCCEEDED(ExpandByIndex(threadIndex, nsnull))
+        if ((flags & nsMsgMessageFlags::Elided) && NS_SUCCEEDED(ExpandByIndex(threadIndex, nsnull))
           || (flags & MSG_VIEW_FLAG_DUMMY))
           retIndex = (nsMsgViewIndex) m_keys.IndexOf(key, threadIndex + 1);
       }
     }
   }
   return retIndex;
 }
 
@@ -4245,17 +4245,17 @@ nsresult nsMsgDBView::ExpansionDelta(nsM
     rv = GetThreadCount(index, &numChildren);
     NS_ENSURE_SUCCESS(rv, rv);
   }
   else
   {
     numChildren = CountExpandedThread(index);
   }
 
-  if (flags & MSG_FLAG_ELIDED)
+  if (flags & nsMsgMessageFlags::Elided)
     *expansionDelta = numChildren - 1;
   else
     *expansionDelta = - (PRInt32) (numChildren - 1);
 
   return NS_OK;
 }
 
 nsresult nsMsgDBView::ToggleExpansion(nsMsgViewIndex index, PRUint32 *numChanged)
@@ -4269,17 +4269,17 @@ nsresult nsMsgDBView::ToggleExpansion(ns
     return NS_MSG_MESSAGE_NOT_FOUND;
   }
   PRInt32  flags = m_flags[threadIndex];
 
   // if not a thread, or doesn't have children, no expand/collapse
   // If we add sub-thread expand collapse, this will need to be relaxed
   if (!(flags & MSG_VIEW_FLAG_ISTHREAD) || !(flags & MSG_VIEW_FLAG_HASCHILDREN))
     return NS_MSG_MESSAGE_NOT_FOUND;
-  if (flags & MSG_FLAG_ELIDED)
+  if (flags & nsMsgMessageFlags::Elided)
     return ExpandByIndex(threadIndex, numChanged);
   else
     return CollapseByIndex(threadIndex, numChanged);
 
 }
 
 nsresult nsMsgDBView::ExpandAndSelectThread()
 {
@@ -4321,17 +4321,17 @@ nsresult nsMsgDBView::ExpandAndSelectThr
   }
 
   PRInt32 flags = m_flags[threadIndex];
   PRInt32 count = 0;
 
   if (inThreadedMode && (flags & MSG_VIEW_FLAG_ISTHREAD) && (flags & MSG_VIEW_FLAG_HASCHILDREN))
   {
     // if closed, expand this thread.
-    if (flags & MSG_FLAG_ELIDED)
+    if (flags & nsMsgMessageFlags::Elided)
     {
       PRUint32 numExpanded;
       rv = ExpandByIndex(threadIndex, &numExpanded);
       NS_ENSURE_SUCCESS(rv,rv);
     }
 
     // get the number of messages in the expanded thread
     // so we know how many to select
@@ -4357,17 +4357,17 @@ nsresult nsMsgDBView::ExpandAndSelectThr
 nsresult nsMsgDBView::ExpandAll()
 {
   if (mTree)
     mTree->BeginUpdateBatch();
   for (PRInt32 i = GetSize() - 1; i >= 0; i--)
   {
     PRUint32 numExpanded;
     PRUint32 flags = m_flags[i];
-    if (flags & MSG_FLAG_ELIDED)
+    if (flags & nsMsgMessageFlags::Elided)
       ExpandByIndex(i, &numExpanded);
   }
   if (mTree)
     mTree->EndUpdateBatch();
   return NS_OK;
 }
 
 nsresult nsMsgDBView::GetThreadContainingMsgHdr(nsIMsgDBHdr *msgHdr, nsIMsgThread **pThread)
@@ -4375,31 +4375,31 @@ nsresult nsMsgDBView::GetThreadContainin
   return m_db->GetThreadContainingMsgHdr(msgHdr, pThread);
 }
 
 nsresult nsMsgDBView::ExpandByIndex(nsMsgViewIndex index, PRUint32 *pNumExpanded)
 {
   PRUint32      flags = m_flags[index];
   PRUint32      numExpanded = 0;
 
-  NS_ASSERTION(flags & MSG_FLAG_ELIDED, "can't expand an already expanded thread");
-  flags &= ~MSG_FLAG_ELIDED;
+  NS_ASSERTION(flags & nsMsgMessageFlags::Elided, "can't expand an already expanded thread");
+  flags &= ~nsMsgMessageFlags::Elided;
 
   if ((PRUint32) index > m_keys.Length())
     return NS_MSG_MESSAGE_NOT_FOUND;
 
   nsCOMPtr <nsIMsgDBHdr> msgHdr;
   nsCOMPtr <nsIMsgThread> pThread;
   nsresult rv = GetThreadContainingIndex(index, getter_AddRefs(pThread));
   NS_ENSURE_SUCCESS(rv, rv);
   m_flags[index] = flags;
   NoteChange(index, 1, nsMsgViewNotificationCode::changed);
   if (m_viewFlags & nsMsgViewFlagsType::kUnreadOnly)
   {
-    if (flags & MSG_FLAG_READ)
+    if (flags & nsMsgMessageFlags::Read)
       m_levels.AppendElement(0);  // keep top level hdr in thread, even though read.
     rv = ListUnreadIdsInThread(pThread,  index, &numExpanded);
   }
   else
     rv = ListIdsInThread(pThread,  index, &numExpanded);
 
   NoteStartChange(index + 1, numExpanded, nsMsgViewNotificationCode::insertOrDelete);
   NoteEndChange(index + 1, numExpanded, nsMsgViewNotificationCode::insertOrDelete);
@@ -4409,31 +4409,31 @@ nsresult nsMsgDBView::ExpandByIndex(nsMs
 }
 
 nsresult nsMsgDBView::CollapseAll()
 {
   for (PRInt32 i = 0; i < GetSize(); i++)
   {
     PRUint32 numExpanded;
     PRUint32 flags = m_flags[i];
-    if (!(flags & MSG_FLAG_ELIDED) && (flags & MSG_VIEW_FLAG_HASCHILDREN))
+    if (!(flags & nsMsgMessageFlags::Elided) && (flags & MSG_VIEW_FLAG_HASCHILDREN))
       CollapseByIndex(i, &numExpanded);
   }
   return NS_OK;
 }
 
 nsresult nsMsgDBView::CollapseByIndex(nsMsgViewIndex index, PRUint32 *pNumCollapsed)
 {
   nsresult  rv;
   PRInt32  flags = m_flags[index];
   PRInt32  threadCount = 0;
 
-  if (flags & MSG_FLAG_ELIDED || !(m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay) || !(flags & MSG_VIEW_FLAG_HASCHILDREN))
+  if (flags & nsMsgMessageFlags::Elided || !(m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay) || !(flags & MSG_VIEW_FLAG_HASCHILDREN))
     return NS_OK;
-  flags  |= MSG_FLAG_ELIDED;
+  flags |= nsMsgMessageFlags::Elided;
 
   if (index > m_keys.Length())
     return NS_MSG_MESSAGE_NOT_FOUND;
 
   m_flags[index] = flags;
   NoteChange(index, 1, nsMsgViewNotificationCode::changed);
 
   rv = ExpansionDelta(index, &threadCount);
@@ -4706,17 +4706,17 @@ nsresult  nsMsgDBView::AddHdr(nsIMsgDBHd
 
   if (!GetShowingIgnored())
   {
     nsCOMPtr <nsIMsgThread> thread;
     GetThreadContainingMsgHdr(msgHdr, getter_AddRefs(thread));
     if (thread)
     {
       thread->GetFlags(&flags);
-      if (flags & MSG_FLAG_IGNORED)
+      if (flags & nsMsgMessageFlags::Ignored)
         return NS_OK;
     }
 
     PRBool ignored;
     msgHdr->GetIsKilled(&ignored);
     if (ignored)
        return NS_OK;
   }
@@ -4842,17 +4842,17 @@ nsresult nsMsgDBView::ListIdsInThreadOrd
 
       nsMsgKey msgKey;
       PRUint32 msgFlags, newFlags;
       msgHdr->GetMessageKey(&msgKey);
       msgHdr->GetFlags(&msgFlags);
       AdjustReadFlag(msgHdr, &msgFlags);
       SetMsgHdrAt(msgHdr, *viewIndex, msgKey, msgFlags & ~MSG_VIEW_FLAGS, level);
       // turn off thread or elided bit if they got turned on (maybe from new only view?)
-      msgHdr->AndFlags(~(MSG_VIEW_FLAG_ISTHREAD | MSG_FLAG_ELIDED), &newFlags);
+      msgHdr->AndFlags(~(MSG_VIEW_FLAG_ISTHREAD | nsMsgMessageFlags::Elided), &newFlags);
       (*pNumListed)++;
       (*viewIndex)++;
       rv = ListIdsInThreadOrder(threadHdr, msgKey, level + 1, viewIndex, pNumListed);
     }
   }
   return rv; // we don't want to return the rv from the enumerator when it reaches the end, do we?
 }
 
@@ -4921,17 +4921,17 @@ nsresult nsMsgDBView::ListIdsInThread(ns
         PRUint32 msgFlags, newFlags;
         msgHdr->GetMessageKey(&msgKey);
         msgHdr->GetFlags(&msgFlags);
         AdjustReadFlag(msgHdr, &msgFlags);
         SetMsgHdrAt(msgHdr, viewIndex, msgKey, msgFlags & ~MSG_VIEW_FLAGS, 1);
         // here, we're either flat, or we're grouped - in either case, level is 1
         // turn off thread or elided bit if they got turned on (maybe from new only view?)
         if (i > 0)
-          msgHdr->AndFlags(~(MSG_VIEW_FLAG_ISTHREAD | MSG_FLAG_ELIDED), &newFlags);
+          msgHdr->AndFlags(~(MSG_VIEW_FLAG_ISTHREAD | nsMsgMessageFlags::Elided), &newFlags);
         (*pNumListed)++;
         viewIndex++;
       }
     }
     if (ignoredHeaders + *pNumListed < numChildren)
     {
       NS_NOTREACHED("thread corrupt in db");
       // if we've listed fewer messages than are in the thread, then the db
@@ -5273,29 +5273,29 @@ NS_IMETHODIMP nsMsgDBView::OnHdrFlagsCha
   if (aInstigator != this)
   {
     NS_ENSURE_ARG_POINTER(aHdrChanged);
     nsMsgKey msgKey;
     aHdrChanged->GetMessageKey(&msgKey);
     nsMsgViewIndex index = FindHdr(aHdrChanged);
     if (index != nsMsgViewIndex_None)
     {
-      PRUint32 viewOnlyFlags = m_flags[index] & (MSG_VIEW_FLAGS | MSG_FLAG_ELIDED);
+      PRUint32 viewOnlyFlags = m_flags[index] & (MSG_VIEW_FLAGS | nsMsgMessageFlags::Elided);
 
       // ### what about saving the old view only flags, like IsThread and HasChildren?
       // I think we'll want to save those away.
       m_flags[index] = aNewFlags | viewOnlyFlags;
       // tell the view the extra flag changed, so it can
       // update the previous view, if any.
       OnExtraFlagChanged(index, aNewFlags);
       NoteChange(index, 1, nsMsgViewNotificationCode::changed);
     }
 
     PRUint32 deltaFlags = (aOldFlags ^ aNewFlags);
-    if (deltaFlags & (MSG_FLAG_READ | MSG_FLAG_NEW))
+    if (deltaFlags & (nsMsgMessageFlags::Read | nsMsgMessageFlags::New))
     {
       nsMsgViewIndex threadIndex = GetThreadIndex(index);
       // may need to fix thread counts
       if (threadIndex != nsMsgViewIndex_None && threadIndex != index)
         NoteChange(threadIndex, 1, nsMsgViewNotificationCode::changed);
     }
  }
   // don't need to propagate notifications, right?
@@ -5522,17 +5522,17 @@ nsresult nsMsgDBView::MarkThreadOfMsgRea
         threadIndex = msgIndex;
     return MarkThreadRead(threadHdr, threadIndex, idsMarkedRead, bRead);
 }
 
 nsresult nsMsgDBView::MarkThreadRead(nsIMsgThread *threadHdr, nsMsgViewIndex threadIndex, nsTArray<nsMsgKey> &idsMarkedRead, PRBool bRead)
 {
     PRBool threadElided = PR_TRUE;
     if (threadIndex != nsMsgViewIndex_None)
-        threadElided = (m_flags[threadIndex] & MSG_FLAG_ELIDED);
+        threadElided = (m_flags[threadIndex] & nsMsgMessageFlags::Elided);
 
     PRUint32 numChildren;
     threadHdr->GetNumChildren(&numChildren);
     idsMarkedRead.SetCapacity(numChildren);
     for (PRInt32 childIndex = 0; childIndex < (PRInt32) numChildren ; childIndex++)
     {
         nsCOMPtr <nsIMsgDBHdr> msgHdr;
         threadHdr->GetChildHdrAt(childIndex, getter_AddRefs(msgHdr));
@@ -5557,29 +5557,29 @@ nsresult nsMsgDBView::MarkThreadRead(nsI
 
     return NS_OK;
 }
 
 PRBool nsMsgDBView::AdjustReadFlag(nsIMsgDBHdr *msgHdr, PRUint32 *msgFlags)
 {
   // if we're a cross-folder view, just bail on this.
   if (GetFolders())
-    return *msgFlags & MSG_FLAG_READ;
+    return *msgFlags & nsMsgMessageFlags::Read;
   PRBool isRead = PR_FALSE;
   nsMsgKey msgKey;
   msgHdr->GetMessageKey(&msgKey);
   m_db->IsRead(msgKey, &isRead);
     // just make sure flag is right in db.
 #ifdef DEBUG_David_Bienvenu
-  NS_ASSERTION(isRead == ((*msgFlags & MSG_FLAG_READ) != 0), "msgFlags out of sync");
+  NS_ASSERTION(isRead == ((*msgFlags & nsMsgMessageFlags::Read) != 0), "msgFlags out of sync");
 #endif
   if (isRead)
-    *msgFlags |= MSG_FLAG_READ;
+    *msgFlags |= nsMsgMessageFlags::Read;
   else
-    *msgFlags &= ~MSG_FLAG_READ;
+    *msgFlags &= ~nsMsgMessageFlags::Read;
   m_db->MarkHdrRead(msgHdr, isRead, nsnull);
   return isRead;
 }
 
 // Starting from startIndex, performs the passed in navigation, including
 // any marking read needed, and returns the resultId and resultIndex of the
 // destination of the navigation.  If no message is found in the view,
 // it returns a resultId of nsMsgKey_None and an resultIndex of nsMsgViewIndex_None.
@@ -5662,24 +5662,24 @@ nsresult nsMsgDBView::NavigateFromPos(ns
             break;
         case nsMsgNavigationType::firstUnreadMessage:
             startIndex = nsMsgViewIndex_None;        // note fall thru - is this motion ever used?
         case nsMsgNavigationType::nextUnreadMessage:
             for (curIndex = (startIndex == nsMsgViewIndex_None) ? 0 : startIndex; curIndex <= lastIndex && lastIndex != nsMsgViewIndex_None; curIndex++) {
                 PRUint32 flags = m_flags[curIndex];
 
                 // don't return start index since navigate should move
-                if (!(flags & (MSG_FLAG_READ | MSG_VIEW_FLAG_DUMMY)) && (curIndex != startIndex))
+                if (!(flags & (nsMsgMessageFlags::Read | MSG_VIEW_FLAG_DUMMY)) && (curIndex != startIndex))
                 {
                     *pResultIndex = curIndex;
                     *pResultKey = m_keys[*pResultIndex];
                     break;
                 }
                 // check for collapsed thread with new children
-                if ((m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay) && flags & MSG_VIEW_FLAG_ISTHREAD && flags & MSG_FLAG_ELIDED) {
+                if ((m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay) && flags & MSG_VIEW_FLAG_ISTHREAD && flags & nsMsgMessageFlags::Elided) {
                     nsCOMPtr <nsIMsgThread> threadHdr;
                     GetThreadContainingIndex(curIndex, getter_AddRefs(threadHdr));
                     NS_ENSURE_SUCCESS(rv, rv);
 
                     NS_ASSERTION(threadHdr, "threadHdr is null");
                     if (!threadHdr)
                         continue;
                     PRUint32 numUnreadChildren;
@@ -5947,17 +5947,17 @@ nsresult nsMsgDBView::FindNextFlagged(ns
 
     *pResultIndex = nsMsgViewIndex_None;
 
     if (GetSize() > 0)
     {
         for (curIndex = startIndex; curIndex <= lastIndex; curIndex++)
         {
             PRUint32 flags = m_flags[curIndex];
-            if (flags & MSG_FLAG_MARKED)
+            if (flags & nsMsgMessageFlags::Marked)
             {
                 *pResultIndex = curIndex;
                 break;
             }
         }
     }
 
     return NS_OK;
@@ -5988,25 +5988,25 @@ nsresult nsMsgDBView::FindPrevUnread(nsM
     *pResultKey = nsMsgKey_None;
     if (resultThreadId)
         *resultThreadId = nsMsgKey_None;
 
     for (; (int) curIndex >= 0 && (*pResultKey == nsMsgKey_None); curIndex--)
     {
         PRUint32 flags = m_flags[curIndex];
 
-        if (curIndex != startIndex && flags & MSG_VIEW_FLAG_ISTHREAD && flags & MSG_FLAG_ELIDED)
+        if (curIndex != startIndex && flags & MSG_VIEW_FLAG_ISTHREAD && flags & nsMsgMessageFlags::Elided)
         {
             NS_ASSERTION(0,"fix this");
             //nsMsgKey threadId = m_keys[curIndex];
             //rv = m_db->GetUnreadKeyInThread(threadId, pResultKey, resultThreadId);
             if (NS_SUCCEEDED(rv) && (*pResultKey != nsMsgKey_None))
                 break;
         }
-        if (!(flags & (MSG_FLAG_READ | MSG_VIEW_FLAG_DUMMY)) && (curIndex != startIndex))
+        if (!(flags & (nsMsgMessageFlags::Read | MSG_VIEW_FLAG_DUMMY)) && (curIndex != startIndex))
         {
             *pResultKey = m_keys[curIndex];
             rv = NS_OK;
             break;
         }
     }
     // found unread message but we don't know the thread
     NS_ASSERTION(!(*pResultKey != nsMsgKey_None && resultThreadId && *resultThreadId == nsMsgKey_None),
@@ -6029,17 +6029,17 @@ nsresult nsMsgDBView::FindPrevFlagged(ns
     {
         curIndex = startIndex;
         do
         {
             if (curIndex != 0)
                 curIndex--;
 
             PRUint32 flags = m_flags[curIndex];
-            if (flags & MSG_FLAG_MARKED)
+            if (flags & nsMsgMessageFlags::Marked)
             {
                 *pResultIndex = curIndex;
                 break;
             }
         }
         while (curIndex != 0);
     }
     return NS_OK;
@@ -6087,29 +6087,29 @@ nsresult nsMsgDBView::SetExtraFlag(nsMsg
 nsresult nsMsgDBView::ToggleIgnored(nsMsgViewIndex * indices, PRInt32 numIndices, nsMsgViewIndex *resultIndex, PRBool *resultToggleState)
 {
   nsCOMPtr <nsIMsgThread> thread;
 
   // Ignored state is toggled based on the first selected thread
   nsMsgViewIndex threadIndex = GetThreadFromMsgIndex(indices[0], getter_AddRefs(thread));
   PRUint32 threadFlags;
   thread->GetFlags(&threadFlags);
-  PRUint32 ignored = threadFlags & MSG_FLAG_IGNORED;
+  PRUint32 ignored = threadFlags & nsMsgMessageFlags::Ignored;
 
   // Process threads in reverse order
   // Otherwise collapsing the threads will invalidate the indices
   threadIndex = nsMsgViewIndex_None;
   while (numIndices)
   {
     numIndices--;
     if (indices[numIndices] < threadIndex)
     {
       threadIndex = GetThreadFromMsgIndex(indices[numIndices], getter_AddRefs(thread));
       thread->GetFlags(&threadFlags);
-      if ((threadFlags & MSG_FLAG_IGNORED) == ignored)
+      if ((threadFlags & nsMsgMessageFlags::Ignored) == ignored)
         SetThreadIgnored(thread, threadIndex, !ignored);
     }
   }
 
   if (resultIndex)
     *resultIndex = threadIndex;
   if (resultToggleState)
     *resultToggleState = !ignored;
@@ -6121,30 +6121,30 @@ nsresult nsMsgDBView::ToggleMessageKille
 {
   nsCOMPtr <nsIMsgDBHdr> header;
   nsresult rv;
 
   // Ignored state is toggled based on the first selected message
   rv = GetMsgHdrForViewIndex(indices[0], getter_AddRefs(header));
   PRUint32 msgFlags;
   header->GetFlags(&msgFlags);
-  PRUint32 ignored = msgFlags & MSG_FLAG_IGNORED;
+  PRUint32 ignored = msgFlags & nsMsgMessageFlags::Ignored;
 
   // Process messages in reverse order
   // Otherwise the indices may be invalidated...
   nsMsgViewIndex msgIndex = nsMsgViewIndex_None;
   while (numIndices)
   {
     numIndices--;
     if (indices[numIndices] < msgIndex)
     {
       msgIndex = indices[numIndices];
       rv = GetMsgHdrForViewIndex(msgIndex, getter_AddRefs(header));
       header->GetFlags(&msgFlags);
-      if ((msgFlags & MSG_FLAG_IGNORED) == ignored)
+      if ((msgFlags & nsMsgMessageFlags::Ignored) == ignored)
         SetSubthreadKilled(header, msgIndex, !ignored);
     }
   }
 
   if (resultIndex)
     *resultIndex = msgIndex;
   if (resultToggleState)
     *resultToggleState = !ignored;
@@ -6177,29 +6177,29 @@ nsMsgViewIndex  nsMsgDBView::GetThreadFr
 nsresult nsMsgDBView::ToggleWatched( nsMsgViewIndex* indices,  PRInt32 numIndices)
 {
   nsCOMPtr <nsIMsgThread> thread;
 
   // Watched state is toggled based on the first selected thread
   nsMsgViewIndex threadIndex = GetThreadFromMsgIndex(indices[0], getter_AddRefs(thread));
   PRUint32 threadFlags;
   thread->GetFlags(&threadFlags);
-  PRUint32 watched = threadFlags & MSG_FLAG_WATCHED;
+  PRUint32 watched = threadFlags & nsMsgMessageFlags::Watched;
 
   // Process threads in reverse order
   // for consistency with ToggleIgnored
   threadIndex = nsMsgViewIndex_None;
   while (numIndices)
   {
     numIndices--;
     if (indices[numIndices] < threadIndex)
     {
       threadIndex = GetThreadFromMsgIndex(indices[numIndices], getter_AddRefs(thread));
       thread->GetFlags(&threadFlags);
-      if ((threadFlags & MSG_FLAG_WATCHED) == watched)
+      if ((threadFlags & nsMsgMessageFlags::Watched) == watched)
         SetThreadWatched(thread, threadIndex, !watched);
     }
   }
 
   return NS_OK;
 }
 
 nsresult nsMsgDBView::SetThreadIgnored(nsIMsgThread *thread, nsMsgViewIndex threadIndex, PRBool ignored)
@@ -6477,17 +6477,17 @@ PRBool nsMsgDBView::OfflineMsgSelected(n
 {
   nsCOMPtr <nsIMsgLocalMailFolder> localFolder = do_QueryInterface(m_folder);
   if (localFolder)
     return PR_TRUE;
 
   for (nsMsgViewIndex index = 0; index < (nsMsgViewIndex) numIndices; index++)
   {
     PRUint32 flags = m_flags[indices[index]];
-    if ((flags & MSG_FLAG_OFFLINE))
+    if ((flags & nsMsgMessageFlags::Offline))
       return PR_TRUE;
   }
   return PR_FALSE;
 }
 
 PRBool nsMsgDBView::NonDummyMsgSelected(nsMsgViewIndex * indices, PRInt32 numIndices)
 {
   for (nsMsgViewIndex index = 0; index < (nsMsgViewIndex) numIndices; index++)
--- a/mailnews/base/src/nsMsgFolderCompactor.cpp
+++ b/mailnews/base/src/nsMsgFolderCompactor.cpp
@@ -902,17 +902,17 @@ nsOfflineStoreCompactState::OnStopReques
     rv = BuildMessageURI(m_baseMessageUri.get(), m_keyArray[m_curIndex],
                                 m_messageUri);
     if (NS_FAILED(rv)) goto done;
     rv = m_messageService->CopyMessage(m_messageUri.get(), this, PR_FALSE, nsnull,
                                        /* ### should get msg window! */ nsnull, nsnull);
    if (NS_FAILED(rv))
    {
      PRUint32 resultFlags;
-     msgHdr->AndFlags(~MSG_FLAG_OFFLINE, &resultFlags);
+     msgHdr->AndFlags(~nsMsgMessageFlags::Offline, &resultFlags);
    }
   // if this fails, we should clear the offline flag on the source message.
     
   }
 
 done:
   if (NS_FAILED(rv)) {
     m_status = rv; // set the status to rv so the destructor can remove the
--- a/mailnews/base/src/nsMsgGroupThread.cpp
+++ b/mailnews/base/src/nsMsgGroupThread.cpp
@@ -181,27 +181,27 @@ nsresult nsMsgGroupThread::AddChildFromG
   nsMsgKey newHdrKey = 0;
   
   child->GetFlags(&newHdrFlags);
   child->GetMessageKey(&newHdrKey);
   child->GetDateInSeconds(&msgDate);
   if (msgDate > m_newestMsgDate)
     SetNewestMsgDate(msgDate);
 
-  child->AndFlags(~(MSG_FLAG_WATCHED), &newHdrFlags);
+  child->AndFlags(~(nsMsgMessageFlags::Watched), &newHdrFlags);
   PRUint32 numChildren;
   
   // get the num children before we add the new header.
   GetNumChildren(&numChildren);
   
   // if this is an empty thread, set the root key to this header's key
   if (numChildren == 0)
     m_threadRootKey = newHdrKey;
   
-  if (! (newHdrFlags & MSG_FLAG_READ))
+  if (! (newHdrFlags & nsMsgMessageFlags::Read))
     ChangeUnreadChildCount(1);
 
   return AddMsgHdrInDateOrder(child, view);
 }
 
 nsresult nsMsgGroupThread::ReparentNonReferenceChildrenOf(nsIMsgDBHdr *topLevelHdr, nsMsgKey newParentKey,
                                                             nsIDBChangeAnnouncer *announcer)
 {
@@ -267,17 +267,17 @@ NS_IMETHODIMP nsMsgGroupThread::RemoveCh
 //  ReparentChildrenOf(key, threadParent, announcer);
   
   // if this was the newest msg, clear the newest msg date so we'll recalc.
   PRUint32 date;
   child->GetDateInSeconds(&date);
   if (date == m_newestMsgDate)
     SetNewestMsgDate(0);
 
-  if (!(flags & MSG_FLAG_READ))
+  if (!(flags & nsMsgMessageFlags::Read))
     ChangeUnreadChildCount(-1);
   PRBool keyWasFirstKey = (m_keys[0] == key);
   nsresult rv = RemoveChild(key);
  // if we're deleting the root of a dummy thread, need to update the threadKey
  // and the dummy header at position 0
  if (m_dummy && keyWasFirstKey && m_keys.Length() > 1)
     m_keys[0] = m_keys[1];
 
--- a/mailnews/base/src/nsMsgGroupView.cpp
+++ b/mailnews/base/src/nsMsgGroupView.cpp
@@ -94,17 +94,17 @@ void nsMsgGroupView::InternalClose()
     m_db->GetDBFolderInfo(getter_AddRefs(dbFolderInfo));
     if (dbFolderInfo)
     {
       PRUint32 expandFlags = 0;
       PRUint32 num = GetSize();
 
       for (PRUint32 i = 0; i < num; i++)
       {
-        if (m_flags[i] & MSG_VIEW_FLAG_ISTHREAD && ! (m_flags[i] & MSG_FLAG_ELIDED))
+        if (m_flags[i] & MSG_VIEW_FLAG_ISTHREAD && ! (m_flags[i] & nsMsgMessageFlags::Elided))
         {
           nsCOMPtr <nsIMsgDBHdr> msgHdr;
           GetMsgHdrForViewIndex(i, getter_AddRefs(msgHdr));
           if (msgHdr)
           {
             PRUint32 ageBucket;
             nsresult rv = GetAgeBucketValue(msgHdr, &ageBucket, rcvDate);
             if (NS_SUCCEEDED(rv))
@@ -247,24 +247,24 @@ nsresult nsMsgGroupView::HashHdr(nsIMsgD
           ? FetchAccount(msgHdr, aHashKey)
           : FetchTags(msgHdr, aHashKey);
       }
       break;
     case nsMsgViewSortType::byAttachments:
       {
         PRUint32 flags;
         msgHdr->GetFlags(&flags);
-        aHashKey.Assign(flags & MSG_FLAG_ATTACHMENT ? '1' : '0');
+        aHashKey.Assign(flags & nsMsgMessageFlags::Attachment ? '1' : '0');
         break;
       }
     case nsMsgViewSortType::byFlagged:
       {
         PRUint32 flags;
         msgHdr->GetFlags(&flags);
-        aHashKey.Assign(flags & MSG_FLAG_MARKED ? '1' : '0');
+        aHashKey.Assign(flags & nsMsgMessageFlags::Marked ? '1' : '0');
         break;
       }
     case nsMsgViewSortType::byPriority:
       {
         nsMsgPriorityValue priority;
         msgHdr->GetPriority(&priority);
         aHashKey.AppendInt(priority);
       }
@@ -328,17 +328,17 @@ nsMsgGroupThread *nsMsgGroupView::AddHdr
       foundThread->m_dummy = PR_TRUE;
       msgFlags |=  MSG_VIEW_FLAG_DUMMY | MSG_VIEW_FLAG_HASCHILDREN;
     }
 
     nsMsgViewIndex insertIndex = GetInsertIndex(msgHdr);
     if (insertIndex == nsMsgViewIndex_None)
       insertIndex = m_keys.Length();
     InsertMsgHdrAt(insertIndex, msgHdr, msgKey, 
-                  msgFlags | MSG_VIEW_FLAG_ISTHREAD | MSG_FLAG_ELIDED, 0);
+                  msgFlags | MSG_VIEW_FLAG_ISTHREAD | nsMsgMessageFlags::Elided, 0);
     // if grouped by date, insert dummy header for "age"
     if (GroupViewUsesDummyRow())
     {
       // this needs to do something different for xf groups
       foundThread->InsertMsgHdrAt(0, msgHdr);
       // the previous code made it look like hashKey in this case was always an integer
       foundThread->m_threadKey = atoi(NS_LossyConvertUTF16toASCII(hashKey).get());
     }
@@ -525,22 +525,22 @@ nsresult nsMsgGroupView::OnNewHeader(nsI
     nsMsgViewIndex threadIndex = ThreadIndexOfMsgHdr(newHdr);
     PRInt32 numRowsInserted = 1;
     if (newThread && GroupViewUsesDummyRow())
       numRowsInserted++;
     // may need to fix thread counts
     if (threadIndex != nsMsgViewIndex_None)
     {
       if (newThread)
-        m_flags[threadIndex] &= ~MSG_FLAG_ELIDED;
+        m_flags[threadIndex] &= ~nsMsgMessageFlags::Elided;
       else
         m_flags[threadIndex] |= MSG_VIEW_FLAG_HASCHILDREN | MSG_VIEW_FLAG_ISTHREAD;
 
       PRInt32 numRowsToInvalidate = 1;
-      if (! (m_flags[threadIndex] & MSG_FLAG_ELIDED))
+      if (! (m_flags[threadIndex] & nsMsgMessageFlags::Elided))
       {
         PRUint32 msgIndexInThread = thread->m_keys.IndexOf(msgKey);
         PRBool insertedAtThreadRoot = !msgIndexInThread;
         if (!msgIndexInThread && GroupViewUsesDummyRow())
           msgIndexInThread++;
 
         if (!newThread || GroupViewUsesDummyRow())
         {
@@ -591,18 +591,18 @@ NS_IMETHODIMP nsMsgGroupView::OnHdrFlags
   // check if we're adding a header, and the current day has changed. If it has, we're just going to
   // close and re-open the view so things will be correctly categorized.
   if (m_dayChanged)
     return RebuildView(m_viewFlags);
 
   nsresult rv = GetThreadContainingMsgHdr(aHdrChanged, getter_AddRefs(thread));
   NS_ENSURE_SUCCESS(rv, rv);
   PRUint32 deltaFlags = (aOldFlags ^ aNewFlags);
-  if (deltaFlags & MSG_FLAG_READ)
-    thread->MarkChildRead(aNewFlags & MSG_FLAG_READ);
+  if (deltaFlags & nsMsgMessageFlags::Read)
+    thread->MarkChildRead(aNewFlags & nsMsgMessageFlags::Read);
 
   return nsMsgDBView::OnHdrFlagsChanged(aHdrChanged, aOldFlags, aNewFlags, aInstigator);
 }
 
 NS_IMETHODIMP nsMsgGroupView::OnHdrDeleted(nsIMsgDBHdr *aHdrDeleted, nsMsgKey aParentKey, PRInt32 aFlags,
                             nsIDBChangeListener *aInstigator)
 {
   if (!(m_viewFlags & nsMsgViewFlagsType::kGroupBySort))
@@ -762,22 +762,22 @@ NS_IMETHODIMP nsMsgGroupView::GetCellTex
           break;
         case nsMsgViewSortType::byAccount:
           FetchAccount(msgHdr, aValue);
           break;
         case nsMsgViewSortType::byRecipient:
           FetchRecipients(msgHdr, aValue);
           break;
         case nsMsgViewSortType::byAttachments:
-          aValue.Adopt(GetString(flags & MSG_FLAG_ATTACHMENT
+          aValue.Adopt(GetString(flags & nsMsgMessageFlags::Attachment
             ? NS_LITERAL_STRING("attachments").get()
             : NS_LITERAL_STRING("noAttachments").get()));
           break;
         case nsMsgViewSortType::byFlagged:
-          aValue.Adopt(GetString(flags & MSG_FLAG_MARKED 
+          aValue.Adopt(GetString(flags & nsMsgMessageFlags::Marked 
             ? NS_LITERAL_STRING("groupFlagged").get()
             : NS_LITERAL_STRING("notFlagged").get()));
           break;
 
         default:
           NS_ASSERTION(PR_FALSE, "we don't sort by group for this type");
           break;
       }
--- a/mailnews/base/src/nsMsgQuickSearchDBView.cpp
+++ b/mailnews/base/src/nsMsgQuickSearchDBView.cpp
@@ -163,17 +163,17 @@ nsresult nsMsgQuickSearchDBView::OnNewHe
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgQuickSearchDBView::OnHdrFlagsChanged(nsIMsgDBHdr *aHdrChanged, PRUint32 aOldFlags, 
                                        PRUint32 aNewFlags, nsIDBChangeListener *aInstigator)
 {
   nsresult rv = nsMsgGroupView::OnHdrFlagsChanged(aHdrChanged, aOldFlags, aNewFlags, aInstigator);
 
-  if (m_viewFolder && (aOldFlags & MSG_FLAG_READ) != (aNewFlags & MSG_FLAG_READ))
+  if (m_viewFolder && (aOldFlags & nsMsgMessageFlags::Read) != (aNewFlags & nsMsgMessageFlags::Read))
   {
     // if we're displaying a single folder virtual folder for an imap folder,
     // the search criteria might be on message body, and we might not have the
     // message body offline, in which case we can't tell if the message 
     // matched or not. But if the unread flag changed, we need to update the
     // unread counts. Normally, VirtualFolderChangeListener::OnHdrFlagsChanged will
     // handle this, but it won't work for body criteria when we don't have the
     // body offline.
@@ -195,17 +195,17 @@ NS_IMETHODIMP nsMsgQuickSearchDBView::On
           // won't tweak the read/unread counts. So do it here:
           if (!oldMatch && !newMatch)
           {
             nsCOMPtr <nsIMsgDatabase> virtDatabase;
             nsCOMPtr <nsIDBFolderInfo> dbFolderInfo;
 
             rv = m_viewFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo), getter_AddRefs(virtDatabase));
             NS_ENSURE_SUCCESS(rv, rv);
-            dbFolderInfo->ChangeNumUnreadMessages((aOldFlags & MSG_FLAG_READ) ? 1 : -1);
+            dbFolderInfo->ChangeNumUnreadMessages((aOldFlags & nsMsgMessageFlags::Read) ? 1 : -1);
             m_viewFolder->UpdateSummaryTotals(PR_TRUE); // force update from db.
             virtDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
           }
         }
       }
     }
   }
   return rv;
@@ -592,17 +592,17 @@ nsresult nsMsgQuickSearchDBView::Expansi
   if (!(m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay))
     return NS_OK;
 
   // The client can pass in the key of any message
   // in a thread and get the expansion delta for the thread.
 
   PRInt32 numChildren = CountExpandedThread(index);
 
-  *expansionDelta = (flags & MSG_FLAG_ELIDED) ? 
+  *expansionDelta = (flags & nsMsgMessageFlags::Elided) ?
                     numChildren - 1 : - (PRInt32) (numChildren - 1);
   return NS_OK;
 }
 
 NS_IMETHODIMP 
 nsMsgQuickSearchDBView::OpenWithHdrs(nsISimpleEnumerator *aHeaders, 
                                      nsMsgViewSortTypeValue aSortType,
                                      nsMsgViewSortOrderValue aSortOrder, 
--- a/mailnews/base/src/nsMsgSearchDBView.cpp
+++ b/mailnews/base/src/nsMsgSearchDBView.cpp
@@ -221,34 +221,34 @@ nsMsgSearchDBView::OnHdrDeleted(nsIMsgDB
         // and remove the thread flags on it.
         nsCOMPtr<nsIMsgDBHdr> rootHdr;
         thread->GetRootHdr(nsnull, getter_AddRefs(rootHdr));
         if (rootHdr)
         {
           nsMsgViewIndex threadIndex = GetThreadRootIndex(rootHdr);
           if (threadIndex != nsMsgViewIndex_None)
             AndExtraFlag(threadIndex, ~(MSG_VIEW_FLAG_ISTHREAD | 
-                                        MSG_FLAG_ELIDED | 
+                                        nsMsgMessageFlags::Elided | 
                                         MSG_VIEW_FLAG_HASCHILDREN));
         }
       }
       else if (savedFlags & MSG_VIEW_FLAG_HASCHILDREN)
 {
-        if (savedFlags & MSG_FLAG_ELIDED)
+        if (savedFlags & nsMsgMessageFlags::Elided)
         {
           nsCOMPtr<nsIMsgDBHdr> rootHdr;
           nsresult rv = thread->GetRootHdr(nsnull, getter_AddRefs(rootHdr));
           NS_ENSURE_SUCCESS(rv, rv);
           nsMsgKey msgKey;
           PRUint32 msgFlags;
           rootHdr->GetMessageKey(&msgKey);
           rootHdr->GetFlags(&msgFlags);
           // promote the new thread root
           if (viewThread->MsgCount() > 1)
-            msgFlags |= MSG_VIEW_FLAG_ISTHREAD | MSG_FLAG_ELIDED | 
+            msgFlags |= MSG_VIEW_FLAG_ISTHREAD | nsMsgMessageFlags::Elided | 
                         MSG_VIEW_FLAG_HASCHILDREN;
           InsertMsgHdrAt(deletedIndex, rootHdr, msgKey, msgFlags, 0);
           NoteChange(deletedIndex, 1, nsMsgViewNotificationCode::insertOrDelete);
         }
         else if (viewThread->MsgCount() > 1)
         {
           OrExtraFlag(deletedIndex, MSG_VIEW_FLAG_ISTHREAD |
                                     MSG_VIEW_FLAG_HASCHILDREN);
@@ -281,18 +281,18 @@ NS_IMETHODIMP nsMsgSearchDBView::OnHdrFl
   // check that the header is actually in the thread.
   GetXFThreadFromMsgHdr(aHdrChanged, getter_AddRefs(thread), &foundMessageId);
   if (foundMessageId)
   {
     nsMsgXFViewThread *viewThread = static_cast<nsMsgXFViewThread*>(thread.get());
     if (viewThread->HdrIndex(aHdrChanged) != -1)
     {
       PRUint32 deltaFlags = (aOldFlags ^ aNewFlags);
-      if (deltaFlags & MSG_FLAG_READ)
-        thread->MarkChildRead(aNewFlags & MSG_FLAG_READ);
+      if (deltaFlags & nsMsgMessageFlags::Read)
+        thread->MarkChildRead(aNewFlags & nsMsgMessageFlags::Read);
     }
   }
   return nsMsgDBView::OnHdrFlagsChanged(aHdrChanged, aOldFlags,
                                         aNewFlags, aInstigator);
 }
 
 void nsMsgSearchDBView::InsertMsgHdrAt(nsMsgViewIndex index, nsIMsgDBHdr *hdr,
                               nsMsgKey msgKey, PRUint32 flags, PRUint32 level)
@@ -410,17 +410,17 @@ nsresult nsMsgSearchDBView::AddHdrFromFo
       viewThread->AddHdr(msgHdr, PR_FALSE, posInThread,
                          getter_AddRefs(parent));
       nsMsgViewIndex insertIndex = GetIndexForThread(msgHdr);
       NS_ASSERTION(insertIndex == m_levels.Length() || !m_levels[insertIndex],
                     "inserting into middle of thread");
       if (insertIndex == nsMsgViewIndex_None)
         return NS_ERROR_FAILURE;
       if (!(m_viewFlags & nsMsgViewFlagsType::kExpandAll))
-        msgFlags |= MSG_FLAG_ELIDED;
+        msgFlags |= nsMsgMessageFlags::Elided;
       InsertMsgHdrAt(insertIndex, msgHdr, msgKey, msgFlags, 0);
       NoteChange(insertIndex, 1, nsMsgViewNotificationCode::insertOrDelete);
     }
     else
     {
       // get the thread root index before we add the header, because adding
       // the header can change the sort position.
       nsMsgViewIndex threadIndex = GetThreadRootIndex(threadRoot);
@@ -437,17 +437,17 @@ nsresult nsMsgSearchDBView::AddHdrFromFo
       if (m_sortType == nsMsgViewSortType::byDate)
       {
         PRUint32 newestMsgInThread = 0, msgDate = 0;
         viewThread->GetNewestMsgDate(&newestMsgInThread);
         msgHdr->GetDateInSeconds(&msgDate);
         moveThread = (msgDate == newestMsgInThread);
       }
       OrExtraFlag(threadIndex, MSG_VIEW_FLAG_HASCHILDREN | MSG_VIEW_FLAG_ISTHREAD);
-      if (!(m_flags[threadIndex] & MSG_FLAG_ELIDED))
+      if (!(m_flags[threadIndex] & nsMsgMessageFlags::Elided))
       {
         if (parent)
         {
           // since we know posInThread, we just want to insert the new hdr
           // at threadIndex + posInThread, and then rebuild the view until we
           // get to a sibling of the new hdr.
           PRUint8 newMsgLevel = viewThread->ChildLevelAt(posInThread);
           InsertMsgHdrAt(threadIndex + posInThread, msgHdr, msgKey, msgFlags,
@@ -469,32 +469,32 @@ nsresult nsMsgSearchDBView::AddHdrFromFo
 
           NoteChange(threadIndex, 1, nsMsgViewNotificationCode::insertOrDelete);
           nsMsgViewIndex i;
           for (i = threadIndex + 1; 
                i < m_keys.Length() && (i == threadIndex + 1 || m_levels[i]); i++)
             m_levels[i] = m_levels[i] + 1;
           // turn off thread flags on old root.
           AndExtraFlag(threadIndex + 1, ~(MSG_VIEW_FLAG_ISTHREAD | 
-                                          MSG_FLAG_ELIDED | 
+                                          nsMsgMessageFlags::Elided | 
                                           MSG_VIEW_FLAG_HASCHILDREN));
 
           NoteChange(threadIndex + 1, i - threadIndex + 1, 
                      nsMsgViewNotificationCode::changed);
         }
       }
       else if (!parent)
       {
         // new parent came into collapsed thread
         nsCOMPtr<nsIMsgFolder> msgFolder;
         msgHdr->GetFolder(getter_AddRefs(msgFolder));
         m_keys[threadIndex] = msgKey;
         m_folders.ReplaceObjectAt(msgFolder, threadIndex);
         m_flags[threadIndex] = msgFlags | MSG_VIEW_FLAG_ISTHREAD | 
-                                          MSG_FLAG_ELIDED | 
+                                          nsMsgMessageFlags::Elided | 
                                           MSG_VIEW_FLAG_HASCHILDREN;
         NoteChange(threadIndex, 1, nsMsgViewNotificationCode::changed);
 
       }
       if (moveThread)
         MoveThreadAt(threadIndex);
     }
   }
@@ -523,17 +523,17 @@ void nsMsgSearchDBView::MoveThreadAt(nsM
   // Turn off tree notifications so that we don't reload the current message.
   if (!updatesSuppressed)
     DisableChangeUpdates();
 
   nsCOMPtr<nsIMsgDBHdr> threadHdr;
   GetMsgHdrForViewIndex(threadIndex, getter_AddRefs(threadHdr));
 
   PRUint32 saveFlags = m_flags[threadIndex];
-  PRBool threadIsExpanded = !(saveFlags & MSG_FLAG_ELIDED);
+  PRBool threadIsExpanded = !(saveFlags & nsMsgMessageFlags::Elided);
   PRInt32 childCount = 0;
   nsMsgKey preservedKey;
   nsAutoTArray<nsMsgKey, 1> preservedSelection;
 
   SaveAndClearSelection(&preservedKey, preservedSelection);
   if (threadIsExpanded)
   {
     ExpansionDelta(threadIndex, &childCount);
@@ -745,17 +745,17 @@ nsresult nsMsgSearchDBView::RemoveByInde
       nsMsgXFViewThread *viewThread = static_cast<nsMsgXFViewThread*>(thread.get());
       if (viewThread->MsgCount() == 2)
       {
         // if we removed the next to last message in the thread,
         // we need to adjust the flags on the first message in the thread.
         nsMsgViewIndex threadIndex = m_levels[index] ? index -1 : index;
         if (threadIndex != nsMsgViewIndex_None)
         {
-          AndExtraFlag(threadIndex, ~(MSG_VIEW_FLAG_ISTHREAD | MSG_FLAG_ELIDED |
+          AndExtraFlag(threadIndex, ~(MSG_VIEW_FLAG_ISTHREAD | nsMsgMessageFlags::Elided |
                                       MSG_VIEW_FLAG_HASCHILDREN));
           m_levels[threadIndex] = 0;
           NoteChange(threadIndex, 1, nsMsgViewNotificationCode::changed);
         }
       }
       // Bump up the level of all the descendents of the message
       // that was removed, if the thread was expanded.
       PRUint8 removedLevel = m_levels[index];
@@ -1067,17 +1067,17 @@ nsMsgViewIndex nsMsgSearchDBView::FindHd
 {
   nsCOMPtr<nsIMsgDBHdr> curHdr;
   PRInt32 index;
   // it would be nice to take advantage of sorted views when possible.
   for (index = 0; index < GetSize(); index++)
   {
     GetMsgHdrForViewIndex(index, getter_AddRefs(curHdr));
     if (curHdr == msgHdr && (!(m_flags[index] & MSG_VIEW_FLAG_DUMMY) ||
-        (m_flags[index] & MSG_FLAG_ELIDED)))
+        (m_flags[index] & nsMsgMessageFlags::Elided)))
       break;
   }
   return index < GetSize() ? index : nsMsgViewIndex_None;
 }
 
 // This method looks for the XF thread that corresponds to this message hdr,
 // first by looking up the message id, then references, and finally, if subject
 // threading is turned on, the subject.
--- a/mailnews/base/src/nsMsgSpecialViews.cpp
+++ b/mailnews/base/src/nsMsgSpecialViews.cpp
@@ -71,28 +71,28 @@ PRBool nsMsgThreadsWithUnreadDBView::Wan
 nsresult nsMsgThreadsWithUnreadDBView::AddMsgToThreadNotInView(nsIMsgThread *threadHdr, nsIMsgDBHdr *msgHdr, PRBool ensureListed)
 {
   nsresult rv = NS_OK;
 
   nsCOMPtr <nsIMsgDBHdr> parentHdr;
   PRUint32 msgFlags;
   msgHdr->GetFlags(&msgFlags);
   GetFirstMessageHdrToDisplayInThread(threadHdr, getter_AddRefs(parentHdr));
-  if (parentHdr && (ensureListed || !(msgFlags & MSG_FLAG_READ)))
+  if (parentHdr && (ensureListed || !(msgFlags & nsMsgMessageFlags::Read)))
   {
     nsMsgKey key;
     PRUint32 numMsgsInThread;
     rv = AddHdr(parentHdr);
     threadHdr->GetNumChildren(&numMsgsInThread);
     if (numMsgsInThread > 1)
     {
       parentHdr->GetMessageKey(&key);
       nsMsgViewIndex viewIndex = FindViewIndex(key);
       if (viewIndex != nsMsgViewIndex_None)
-        OrExtraFlag(viewIndex, MSG_FLAG_ELIDED | MSG_VIEW_FLAG_HASCHILDREN);
+        OrExtraFlag(viewIndex, nsMsgMessageFlags::Elided | MSG_VIEW_FLAG_HASCHILDREN);
     }
   }
   return rv;
 }
 
 NS_IMETHODIMP
 nsMsgThreadsWithUnreadDBView::CloneDBView(nsIMessenger *aMessengerInstance, nsIMsgWindow *aMsgWindow, nsIMsgDBViewCommandUpdater *aCmdUpdater, nsIMsgDBView **_retval)
 {
@@ -120,45 +120,45 @@ PRBool nsMsgWatchedThreadsWithUnreadDBVi
 {
 	if (threadHdr)
   {
     PRUint32 numNewChildren;
     PRUint32 threadFlags;
 
     threadHdr->GetNumUnreadChildren(&numNewChildren);
     threadHdr->GetFlags(&threadFlags);
-    if (numNewChildren > 0 && (threadFlags & MSG_FLAG_WATCHED) != 0) 
+    if (numNewChildren > 0 && (threadFlags & nsMsgMessageFlags::Watched) != 0) 
       return PR_TRUE;
   }
   return PR_FALSE;
 }
 
 nsresult nsMsgWatchedThreadsWithUnreadDBView::AddMsgToThreadNotInView(nsIMsgThread *threadHdr, nsIMsgDBHdr *msgHdr, PRBool ensureListed)
 {
   nsresult rv = NS_OK;
   PRUint32 threadFlags;
   PRUint32 msgFlags;
   msgHdr->GetFlags(&msgFlags);
   threadHdr->GetFlags(&threadFlags);
-  if (threadFlags & MSG_FLAG_WATCHED)
+  if (threadFlags & nsMsgMessageFlags::Watched)
   {
     nsCOMPtr <nsIMsgDBHdr> parentHdr;
     GetFirstMessageHdrToDisplayInThread(threadHdr, getter_AddRefs(parentHdr));
-    if (parentHdr && (ensureListed || !(msgFlags & MSG_FLAG_READ)))
+    if (parentHdr && (ensureListed || !(msgFlags & nsMsgMessageFlags::Read)))
     {
       PRUint32 numChildren;
       threadHdr->GetNumChildren(&numChildren);
       rv = AddHdr(parentHdr);
       if (numChildren > 1)
       {
         nsMsgKey key;
         parentHdr->GetMessageKey(&key);
         nsMsgViewIndex viewIndex = FindViewIndex(key);
         if (viewIndex != nsMsgViewIndex_None)
-          OrExtraFlag(viewIndex, MSG_FLAG_ELIDED | MSG_VIEW_FLAG_ISTHREAD | MSG_VIEW_FLAG_HASCHILDREN | MSG_FLAG_WATCHED);
+          OrExtraFlag(viewIndex, nsMsgMessageFlags::Elided | MSG_VIEW_FLAG_ISTHREAD | MSG_VIEW_FLAG_HASCHILDREN | nsMsgMessageFlags::Watched);
       }
     }
   }
   return rv;
 }
 
 NS_IMETHODIMP
 nsMsgWatchedThreadsWithUnreadDBView::CloneDBView(nsIMessenger *aMessengerInstance, nsIMsgWindow *aMsgWindow, nsIMsgDBViewCommandUpdater *aCmdUpdater, nsIMsgDBView **_retval)
--- a/mailnews/base/src/nsMsgThreadedDBView.cpp
+++ b/mailnews/base/src/nsMsgThreadedDBView.cpp
@@ -101,17 +101,17 @@ NS_IMETHODIMP nsMsgThreadedDBView::Open(
   // matches what the db totals say. Except ignored threads are
   // going to throw us off...hmm. Unless we just look at the
   // unread counts which is what mostly tweaks people anyway...
   PRInt32 unreadMsgsInView = 0;
   if (!(m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay))
   {
     for (PRInt32 i = 0; i < m_flags.Length(); i++)
     {
-      if (! (m_flags[i] & MSG_FLAG_READ))
+      if (! (m_flags[i] & nsMsgMessageFlags::Read))
         unreadMsgsInView++;
     }
     if (unreadMessages != unreadMsgsInView)
       m_db->SyncCounts();
   }
   m_db->SetMsgHdrCacheSize(MSGHDR_CACHE_DEFAULT_SIZE);
 
   return rv;
@@ -197,20 +197,20 @@ nsresult nsMsgThreadedDBView::SortThread
   DisableChangeUpdates();
   // Loop through the original array, for each thread that's expanded, find it in the new array
   // and expand the thread. We have to update MSG_VIEW_FLAG_HAS_CHILDREN because
   // we may be going from a flat sort, which doesn't maintain that flag,
   // to a threaded sort, which requires that flag.
   for (PRUint32 j = 0; j < m_keys.Length(); j++)
   {
     PRUint32 flags = m_flags[j];
-    if ((flags & (MSG_VIEW_FLAG_HASCHILDREN | MSG_FLAG_ELIDED)) == MSG_VIEW_FLAG_HASCHILDREN)
+    if ((flags & (MSG_VIEW_FLAG_HASCHILDREN | nsMsgMessageFlags::Elided)) == MSG_VIEW_FLAG_HASCHILDREN)
     {
       PRUint32 numExpanded;
-      m_flags[j] = flags | MSG_FLAG_ELIDED;
+      m_flags[j] = flags | nsMsgMessageFlags::Elided;
       ExpandByIndex(j, &numExpanded);
       j += numExpanded;
       if (numExpanded > 0)
         m_flags[j - numExpanded] = flags | MSG_VIEW_FLAG_HASCHILDREN;
     }
     else if (flags & MSG_VIEW_FLAG_ISTHREAD && ! (flags & MSG_VIEW_FLAG_HASCHILDREN))
     {
       nsCOMPtr <nsIMsgDBHdr> msgHdr;
@@ -219,17 +219,17 @@ nsresult nsMsgThreadedDBView::SortThread
       if (msgHdr)
       {
         m_db->GetThreadContainingMsgHdr(msgHdr, getter_AddRefs(pThread));
         if (pThread)
         {
           PRUint32 numChildren;
           pThread->GetNumChildren(&numChildren);
           if (numChildren > 1)
-            m_flags[j] = flags | MSG_VIEW_FLAG_HASCHILDREN | MSG_FLAG_ELIDED;
+            m_flags[j] = flags | MSG_VIEW_FLAG_HASCHILDREN | nsMsgMessageFlags::Elided;
         }
       }
     }
   }
   EnableChangeUpdates();
 
   return NS_OK;
 }
@@ -243,43 +243,43 @@ nsresult nsMsgThreadedDBView::AddKeys(ns
   m_flags.SetCapacity(m_flags.Length() + numKeysToAdd);
   m_levels.SetCapacity(m_levels.Length() + numKeysToAdd);
   for (PRInt32 i = 0; i < numKeysToAdd; i++)
   {
     PRInt32 threadFlag = pFlags[i];
     PRInt32 flag = threadFlag;
     
     // skip ignored threads.
-    if ((threadFlag & MSG_FLAG_IGNORED) && !(m_viewFlags & nsMsgViewFlagsType::kShowIgnored))
+    if ((threadFlag & nsMsgMessageFlags::Ignored) && !(m_viewFlags & nsMsgViewFlagsType::kShowIgnored))
       continue;
     
     // skip ignored subthreads
     nsCOMPtr <nsIMsgDBHdr> msgHdr;
     m_db->GetMsgHdrForKey(pKeys[i], getter_AddRefs(msgHdr));
     if (!(m_viewFlags & nsMsgViewFlagsType::kShowIgnored))
     {
       PRBool killed;
       msgHdr->GetIsKilled(&killed);
       if (killed)
         continue;
     }
 
     // by default, make threads collapsed, unless we're in only viewing new msgs
     
     if (flag & MSG_VIEW_FLAG_HASCHILDREN)
-      flag |= MSG_FLAG_ELIDED;
+      flag |= nsMsgMessageFlags::Elided;
     // should this be persistent? Doesn't seem to need to be.
     flag |= MSG_VIEW_FLAG_ISTHREAD;
     m_keys.AppendElement(pKeys[i]);
     m_flags.AppendElement(flag);
     m_levels.AppendElement(pLevels[i]);
     numAdded++;
     // we expand as we build the view, which allows us to insert at the end of the key array,
     // instead of the middle, and is much faster.
-    if ((!(m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay) || m_viewFlags & nsMsgViewFlagsType::kExpandAll) && flag & MSG_FLAG_ELIDED)
+    if ((!(m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay) || m_viewFlags & nsMsgViewFlagsType::kExpandAll) && flag & nsMsgMessageFlags::Elided)
        ExpandByIndex(m_keys.Length() - 1, NULL);
   }
   return numAdded;
 }
 
 NS_IMETHODIMP nsMsgThreadedDBView::Sort(nsMsgViewSortTypeValue sortType, nsMsgViewSortOrderValue sortOrder)
 {
   nsresult rv;
@@ -461,29 +461,29 @@ nsresult nsMsgThreadedDBView::ListThread
         nsMsgKey msgKey;
         msgHdr->GetMessageKey(&msgKey);
         msgHdr->GetFlags(&msgFlags);
         // turn off high byte of msg flags - used for view flags.
         msgFlags &= ~MSG_VIEW_FLAGS;
         pOutput[numListed] = msgKey;
         pLevels[numListed] = 0;
         // turn off these flags on msg hdr - they belong in thread
-        msgHdr->AndFlags(~(MSG_FLAG_WATCHED), &newMsgFlags);
+        msgHdr->AndFlags(~(nsMsgMessageFlags::Watched), &newMsgFlags);
         AdjustReadFlag(msgHdr, &msgFlags);
         // try adding in MSG_VIEW_FLAG_ISTHREAD flag for unreadonly view.
         pFlags[numListed] = msgFlags | MSG_VIEW_FLAG_ISTHREAD | threadFlags;
         if (numChildren > 1)
           pFlags[numListed] |= MSG_VIEW_FLAG_HASCHILDREN;
         
         numListed++;
       }
       else
         NS_ASSERTION(NS_SUCCEEDED(rv) && msgHdr, "couldn't get header for some reason");
     }
-    else if (threadsRemoved < 10 && !(threadFlags & (MSG_FLAG_WATCHED | MSG_FLAG_IGNORED)))
+    else if (threadsRemoved < 10 && !(threadFlags & (nsMsgMessageFlags::Watched | nsMsgMessageFlags::Ignored)))
     {
       // ### remove thread.
       threadsRemoved++;	// don't want to remove all empty threads first time
       // around as it will choke preformance for upgrade.
 #ifdef DEBUG_bienvenu
       printf("removing empty non-ignored non-watched thread\n");
 #endif
     }
@@ -513,20 +513,20 @@ void	nsMsgThreadedDBView::OnExtraFlagCha
     if (m_havePrevView)
     {
       nsMsgKey keyChanged = m_keys[index];
       nsMsgViewIndex prevViewIndex = m_prevKeys.IndexOf(keyChanged);
       if (prevViewIndex != nsMsgViewIndex_None)
       {
         PRUint32 prevFlag = m_prevFlags[prevViewIndex];
         // don't want to change the elided bit, or has children or is thread
-        if (prevFlag & MSG_FLAG_ELIDED)
-          extraFlag |= MSG_FLAG_ELIDED;
+        if (prevFlag & nsMsgMessageFlags::Elided)
+          extraFlag |= nsMsgMessageFlags::Elided;
         else
-          extraFlag &= ~MSG_FLAG_ELIDED;
+          extraFlag &= ~nsMsgMessageFlags::Elided;
         if (prevFlag & MSG_VIEW_FLAG_ISTHREAD)
           extraFlag |= MSG_VIEW_FLAG_ISTHREAD;
         else
           extraFlag &= ~MSG_VIEW_FLAG_ISTHREAD;
         if (prevFlag & MSG_VIEW_FLAG_HASCHILDREN)
           extraFlag |= MSG_VIEW_FLAG_HASCHILDREN;
         else
           extraFlag &= ~MSG_VIEW_FLAG_HASCHILDREN;
@@ -595,17 +595,17 @@ nsresult nsMsgThreadedDBView::OnNewHeade
 
   // views can override this behaviour, which is to append to view.
   // This is the mail behaviour, but threaded views want
   // to insert in order...
   if (newHdr)
   {
     PRUint32 msgFlags;
     newHdr->GetFlags(&msgFlags);
-    if ((m_viewFlags & nsMsgViewFlagsType::kUnreadOnly) && !ensureListed && (msgFlags & MSG_FLAG_READ))
+    if ((m_viewFlags & nsMsgViewFlagsType::kUnreadOnly) && !ensureListed && (msgFlags & nsMsgMessageFlags::Read))
       return NS_OK;
     // Currently, we only add the header in a threaded view if it's a thread.
     // We used to check if this was the first header in the thread, but that's
     // a bit harder in the unreadOnly view. But we'll catch it below.
 
     // for search view we don't support threaded display so just add it to the view.   
     if (!(m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay)) // || msgHdr->GetMessageKey() == m_messageDB->GetKeyOfFirstMsgInThread(msgHdr->GetMessageKey()))
       rv = AddHdr(newHdr);
@@ -627,20 +627,20 @@ nsresult nsMsgThreadedDBView::OnNewHeade
       }
       if (threadIndex != nsMsgViewIndex_None)
       {
         PRUint32	flags = m_flags[threadIndex];
         if (!(flags & MSG_VIEW_FLAG_HASCHILDREN))
         {
           flags |= MSG_VIEW_FLAG_HASCHILDREN | MSG_VIEW_FLAG_ISTHREAD;
           if (!(m_viewFlags & nsMsgViewFlagsType::kUnreadOnly))
-            flags |= MSG_FLAG_ELIDED;
+            flags |= nsMsgMessageFlags::Elided;
           m_flags[threadIndex] = flags;
         }
-        if (!(flags & MSG_FLAG_ELIDED))	// thread is expanded
+        if (!(flags & nsMsgMessageFlags::Elided))	// thread is expanded
         {								// insert child into thread
           // levels of other hdrs may have changed!
           PRUint32	newFlags = msgFlags;
           PRInt32 level = 0;
           nsMsgViewIndex insertIndex = threadIndex;
           if (aParentKey == nsMsgKey_None)
           {
             newFlags |= MSG_VIEW_FLAG_ISTHREAD | MSG_VIEW_FLAG_HASCHILDREN;
@@ -755,17 +755,17 @@ void nsMsgThreadedDBView::MoveThreadAt(n
 
   GetMsgHdrForViewIndex(threadIndex, getter_AddRefs(threadHdr));
   PRInt32 childCount = 0;
 
   nsMsgKey preservedKey;
   nsAutoTArray<nsMsgKey, 1> preservedSelection;
   SaveAndClearSelection(&preservedKey, preservedSelection);
   PRUint32 saveFlags = m_flags[threadIndex];
-  PRBool threadIsExpanded = !(saveFlags & MSG_FLAG_ELIDED);
+  PRBool threadIsExpanded = !(saveFlags & nsMsgMessageFlags::Elided);
 
   if (threadIsExpanded)
   {
     ExpansionDelta(threadIndex, &childCount);
     childCount = -childCount;
   }
   nsTArray<nsMsgKey> threadKeys;
   nsTArray<PRUint32> threadFlags;
@@ -812,17 +812,17 @@ void nsMsgThreadedDBView::MoveThreadAt(n
   NoteChange(lowIndex, highIndex - lowIndex + childCount, 
               nsMsgViewNotificationCode::changed);
 }
 nsresult nsMsgThreadedDBView::AddMsgToThreadNotInView(nsIMsgThread *threadHdr, nsIMsgDBHdr *msgHdr, PRBool ensureListed)
 {
   nsresult rv = NS_OK;
   PRUint32 threadFlags;
   threadHdr->GetFlags(&threadFlags);
-  if (!(threadFlags & MSG_FLAG_IGNORED))
+  if (!(threadFlags & nsMsgMessageFlags::Ignored))
   {
     PRBool msgKilled;
     msgHdr->GetIsKilled(&msgKilled);
     if (!msgKilled)
       rv = nsMsgDBView::AddHdr(msgHdr);
   }
   return rv;
 }
@@ -846,17 +846,17 @@ nsresult nsMsgThreadedDBView::RemoveByIn
   
   nsCOMPtr <nsIMsgThread> threadHdr; 
   GetThreadContainingIndex(index, getter_AddRefs(threadHdr));
   NS_ENSURE_SUCCESS(rv, rv);
   PRUint32 numThreadChildren = 0; // if we can't get thread, it's already deleted and thus has 0 children
   if (threadHdr)
     threadHdr->GetNumChildren(&numThreadChildren);
   // check if we're the top level msg in the thread, and we're not collapsed.
-  if ((flags & MSG_VIEW_FLAG_ISTHREAD) && !(flags & MSG_FLAG_ELIDED) && (flags & MSG_VIEW_FLAG_HASCHILDREN))
+  if ((flags & MSG_VIEW_FLAG_ISTHREAD) && !(flags & nsMsgMessageFlags::Elided) && (flags & MSG_VIEW_FLAG_HASCHILDREN))
   {
     // fix flags on thread header...Newly promoted message 
     // should have flags set correctly
     if (threadHdr)
     {
       nsMsgDBView::RemoveByIndex(index);
       nsCOMPtr <nsIMsgThread> nextThreadHdr;
       if (numThreadChildren > 0)
@@ -885,17 +885,17 @@ nsresult nsMsgThreadedDBView::RemoveByIn
       nsMsgKey msgKey;
       rv = threadHdr->GetChildKeyAt(0, &msgKey);
       if (NS_SUCCEEDED(rv))
       {
         nsMsgViewIndex threadIndex = FindViewIndex(msgKey);
         if (threadIndex != nsMsgViewIndex_None)
         {
           PRUint32 flags = m_flags[threadIndex];
-          flags &= ~(MSG_VIEW_FLAG_ISTHREAD | MSG_FLAG_ELIDED | MSG_VIEW_FLAG_HASCHILDREN);
+          flags &= ~(MSG_VIEW_FLAG_ISTHREAD | nsMsgMessageFlags::Elided | MSG_VIEW_FLAG_HASCHILDREN);
           m_flags[threadIndex] = flags;
           NoteChange(threadIndex, 1, nsMsgViewNotificationCode::changed);
         }
       }
       
     }
     
     return nsMsgDBView::RemoveByIndex(index);
@@ -918,24 +918,24 @@ nsresult nsMsgThreadedDBView::RemoveByIn
       //			CopyDBFlagsToExtraFlags(msgHdr->GetFlags(), &flag);
       //			if (msgHdr->GetArticleNum() == msgHdr->GetThreadId())
       flag |= MSG_VIEW_FLAG_ISTHREAD;
       
       if (numThreadChildren == 1)	// if only hdr in thread (with one about to be deleted)
         // adjust flags.
       {
         flag &=  ~MSG_VIEW_FLAG_HASCHILDREN;
-        flag &= ~MSG_FLAG_ELIDED;
+        flag &= ~nsMsgMessageFlags::Elided;
         // tell FE that thread header needs to be repainted.
         NoteChange(index, 1, nsMsgViewNotificationCode::changed);	
       }
       else
       {
         flag |= MSG_VIEW_FLAG_HASCHILDREN;
-        flag |= MSG_FLAG_ELIDED;
+        flag |= nsMsgMessageFlags::Elided;
       }
       m_flags[index] = flag;
       mIndicesToNoteChange.RemoveElement(index);
     }
     else
       NS_ASSERTION(PR_FALSE, "couldn't find thread child");	
     NoteChange(index, 1, nsMsgViewNotificationCode::changed);	
   }
--- a/mailnews/base/src/nsMsgXFViewThread.cpp
+++ b/mailnews/base/src/nsMsgXFViewThread.cpp
@@ -131,21 +131,21 @@ nsresult nsMsgXFViewThread::AddHdr(nsIMs
   nsMsgKey newHdrKey = 0;
 
   newHdr->GetMessageKey(&newHdrKey);
   newHdr->GetDateInSeconds(&msgDate);
   newHdr->GetFlags(&newHdrFlags);
   if (msgDate > m_newestMsgDate)
     SetNewestMsgDate(msgDate);
 
-  if (newHdrFlags & MSG_FLAG_WATCHED)
-    SetFlags(m_flags | MSG_FLAG_WATCHED);
+  if (newHdrFlags & nsMsgMessageFlags::Watched)
+    SetFlags(m_flags | nsMsgMessageFlags::Watched);
 
   ChangeChildCount(1);
-  if (! (newHdrFlags & MSG_FLAG_READ))
+  if (! (newHdrFlags & nsMsgMessageFlags::Read))
     ChangeUnreadChildCount(1);
 
   if (m_numChildren == 1)
   {
     m_keys.InsertElementAt(0, newHdrKey);
     m_levels.InsertElementAt(0, 0);
     m_folders.InsertObjectAt(newHdrFolder, 0);
     if (outParent)
@@ -272,17 +272,17 @@ nsresult nsMsgXFViewThread::AddHdr(nsIMs
 
   // ### TODO handle the case where the root header starts 
   // with Re, and the new one doesn't, and is earlier. In that
   // case, we want to promote the new header to root.
 
 //  PRTime newHdrDate;
 //  newHdr->GetDate(&newHdrDate);
 
-//  if (numChildren > 0 && !(newHdrFlags & MSG_FLAG_HAS_RE))
+//  if (numChildren > 0 && !(newHdrFlags & nsMsgMessageFlags::HasRe))
 //  {
 //    PRTime topLevelHdrDate;
 
 //    nsCOMPtr<nsIMsgDBHdr> topLevelHdr;
 //    rv = GetRootHdr(nsnull, getter_AddRefs(topLevelHdr));
 //    if (NS_SUCCEEDED(rv) && topLevelHdr)
 //    {
 //      topLevelHdr->GetDate(&topLevelHdrDate);
@@ -342,17 +342,17 @@ NS_IMETHODIMP nsMsgXFViewThread::RemoveC
                i < m_keys.Length() && m_levels[i] > levelRemoved; i++)
             m_levels[i] = m_levels[i] - 1;
 
       m_view->NoteChange(childIndex + 1, i - childIndex + 1,
                          nsMsgViewNotificationCode::changed);
       m_keys.RemoveElementAt(childIndex);
       m_levels.RemoveElementAt(childIndex);
       m_folders.RemoveObjectAt(childIndex);
-      if (!(msgFlags & MSG_FLAG_READ))
+      if (!(msgFlags & nsMsgMessageFlags::Read))
         ChangeUnreadChildCount(-1);
       ChangeChildCount(-1);
       return NS_OK;
     }
   }
   return NS_ERROR_FAILURE;
 }
 
--- a/mailnews/base/src/nsMsgXFVirtualFolderDBView.cpp
+++ b/mailnews/base/src/nsMsgXFVirtualFolderDBView.cpp
@@ -340,33 +340,33 @@ nsMsgXFVirtualFolderDBView::OnSearchDone
   nsresult rv = m_viewFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo), getter_AddRefs(virtDatabase));
   NS_ENSURE_SUCCESS(rv, rv);
   // count up the number of unread and total messages from the view, and set those in the
   // folder - easier than trying to keep the count up to date in the face of
   // search hits coming in while the user is reading/deleting messages.
   PRUint32 numUnread = 0;
   PRUint32 numTotal = 0;
   for (PRUint32 i = 0; i < m_flags.Length(); i++)
-    if (m_flags[i] & MSG_FLAG_ELIDED)
+    if (m_flags[i] & nsMsgMessageFlags::Elided)
     {
       nsCOMPtr<nsIMsgThread> thread;
       GetThreadContainingIndex(i, getter_AddRefs(thread));
       if (thread)
       {
         PRUint32 totalInThread, unreadInThread;
         thread->GetNumUnreadChildren(&unreadInThread);
         thread->GetNumChildren(&totalInThread);
         numTotal += totalInThread;
         numUnread += unreadInThread;
       }
     }
     else
     {
       numTotal++;
-      if (!(m_flags[i] & MSG_FLAG_READ))
+      if (!(m_flags[i] & nsMsgMessageFlags::Read))
         numUnread++;
     }
   dbFolderInfo->SetNumUnreadMessages(numUnread);
   dbFolderInfo->SetNumMessages(numTotal);
   m_viewFolder->UpdateSummaryTotals(true); // force update from db.
   virtDatabase->Commit(nsMsgDBCommitType::kLargeCommit);
   if (!m_sortValid && m_sortType != nsMsgViewSortType::byThread && 
       !(m_viewFlags & nsMsgViewFlagsType::kThreadedDisplay))
--- a/mailnews/base/util/nsMsgDBFolder.cpp
+++ b/mailnews/base/util/nsMsgDBFolder.cpp
@@ -201,25 +201,25 @@ nsMsgDBFolder::nsMsgDBFolder(void)
     initializeStrings();
     createCollationKeyGenerator();
 #ifdef MSG_FASTER_URI_PARSING
     mParsingURL = do_CreateInstance(NS_STANDARDURL_CONTRACTID);
 #endif
     LL_I2L(gtimeOfLastPurgeCheck, 0);
   }
 
-  mProcessingFlag[0].bit = MSG_PROCESSING_FLAG_CLASSIFY_JUNK;
-  mProcessingFlag[1].bit = MSG_PROCESSING_FLAG_CLASSIFY_TRAITS;
-  for (PRUint32 i = 0; i < MSG_NUMBER_OF_PROCESSING_FLAGS; i++)
+  mProcessingFlag[0].bit = nsMsgProcessingFlags::ClassifyJunk;
+  mProcessingFlag[1].bit = nsMsgProcessingFlags::ClassifyTraits;
+  for (PRUint32 i = 0; i < nsMsgProcessingFlags::NumberOfFlags; i++)
     mProcessingFlag[i].keys = nsMsgKeySetU::Create();
 }
 
 nsMsgDBFolder::~nsMsgDBFolder(void)
 {
-  for (PRUint32 i = 0; i < MSG_NUMBER_OF_PROCESSING_FLAGS; i++)
+  for (PRUint32 i = 0; i < nsMsgProcessingFlags::NumberOfFlags; i++)
     delete mProcessingFlag[i].keys;
 
   if (--mInstanceCount == 0) {
     NS_IF_RELEASE(gCollationKeyGenerator);
     NS_Free(kLocalizedInboxName);
     NS_Free(kLocalizedTrashName);
     NS_Free(kLocalizedSentName);
     NS_Free(kLocalizedDraftsName);
@@ -712,26 +712,26 @@ nsresult nsMsgDBFolder::ReadDBFolderInfo
   }
   return result;
 }
 
 nsresult nsMsgDBFolder::SendFlagNotifications(nsIMsgDBHdr *item, PRUint32 oldFlags, PRUint32 newFlags)
 {
   nsresult rv = NS_OK;
   PRUint32 changedFlags = oldFlags ^ newFlags;
-  if((changedFlags & MSG_FLAG_READ)  && (changedFlags & MSG_FLAG_NEW))
+  if((changedFlags & nsMsgMessageFlags::Read)  && (changedFlags & nsMsgMessageFlags::New))
   {
     //..so..if the msg is read in the folder and the folder has new msgs clear the account level and status bar biffs.
     rv = NotifyPropertyFlagChanged(item, kStatusAtom, oldFlags, newFlags);
     rv = SetBiffState(nsMsgBiffState_NoMail);
   }
-  else if(changedFlags & (MSG_FLAG_READ | MSG_FLAG_REPLIED | MSG_FLAG_FORWARDED
-    | MSG_FLAG_IMAP_DELETED | MSG_FLAG_NEW | MSG_FLAG_OFFLINE))
+  else if(changedFlags & (nsMsgMessageFlags::Read | nsMsgMessageFlags::Replied | nsMsgMessageFlags::Forwarded
+    | nsMsgMessageFlags::IMAPDeleted | nsMsgMessageFlags::New | nsMsgMessageFlags::Offline))
     rv = NotifyPropertyFlagChanged(item, kStatusAtom, oldFlags, newFlags);
-  else if((changedFlags & MSG_FLAG_MARKED))
+  else if((changedFlags & nsMsgMessageFlags::Marked))
     rv = NotifyPropertyFlagChanged(item, kFlaggedAtom, oldFlags, newFlags);
   return rv;
 }
 
 NS_IMETHODIMP nsMsgDBFolder::DownloadMessagesForOffline(nsIArray *messages, nsIMsgWindow *)
 {
   NS_ASSERTION(PR_FALSE, "imap and news need to override this");
   return NS_OK;
@@ -968,20 +968,20 @@ NS_IMETHODIMP nsMsgDBFolder::OnHdrFlagsC
   if(aHdrChanged)
   {
     SendFlagNotifications(aHdrChanged, aOldFlags, aNewFlags);
     UpdateSummaryTotals(PR_TRUE);
   }
 
   // The old state was new message state
   // We check and see if this state has changed
-  if(aOldFlags & MSG_FLAG_NEW)
+  if(aOldFlags & nsMsgMessageFlags::New)
   {
     // state changing from new to something else
-    if (!(aNewFlags  & MSG_FLAG_NEW))
+    if (!(aNewFlags  & nsMsgMessageFlags::New))
       CheckWithNewMessagesStatus(PR_FALSE);
   }
 
   return NS_OK;
 }
 
 nsresult nsMsgDBFolder::CheckWithNewMessagesStatus(PRBool messageAdded)
 {
@@ -1012,17 +1012,17 @@ NS_IMETHODIMP nsMsgDBFolder::OnHdrDelete
   CheckWithNewMessagesStatus(PR_FALSE);
   return OnHdrAddedOrDeleted(aHdrChanged, PR_FALSE);
 }
 
 // 2.  When a new messages gets added, we need to see if it's new.
 NS_IMETHODIMP nsMsgDBFolder::OnHdrAdded(nsIMsgDBHdr *aHdrChanged, nsMsgKey  aParentKey , PRInt32 aFlags,
                         nsIDBChangeListener * aInstigator)
 {
-  if(aFlags & MSG_FLAG_NEW)
+  if(aFlags & nsMsgMessageFlags::New)
     CheckWithNewMessagesStatus(PR_TRUE);
   return OnHdrAddedOrDeleted(aHdrChanged, PR_TRUE);
 }
 
 nsresult nsMsgDBFolder::OnHdrAddedOrDeleted(nsIMsgDBHdr *aHdrChanged, PRBool added)
 {
   if(added)
     NotifyItemAdded(aHdrChanged);
@@ -1087,17 +1087,17 @@ nsresult nsMsgDBFolder::MsgFitsDownloadC
   if(NS_FAILED(rv))
     return rv;
 
   if (hdr)
   {
     PRUint32 msgFlags = 0;
     hdr->GetFlags(&msgFlags);
     // check if we already have this message body offline
-    if (! (msgFlags & MSG_FLAG_OFFLINE))
+    if (! (msgFlags & nsMsgMessageFlags::Offline))
     {
       *result = PR_TRUE;
       // check against the server download size limit .
       nsCOMPtr <nsIMsgIncomingServer> incomingServer;
       rv = GetServer(getter_AddRefs(incomingServer));
       if (NS_SUCCEEDED(rv) && incomingServer)
       {
         PRBool limitDownloadSize = PR_FALSE;
@@ -1165,17 +1165,17 @@ NS_IMETHODIMP nsMsgDBFolder::HasMsgOffli
   if(NS_FAILED(rv))
     return rv;
 
   if (hdr)
   {
     PRUint32 msgFlags = 0;
     hdr->GetFlags(&msgFlags);
     // check if we already have this message body offline
-    if ((msgFlags & MSG_FLAG_OFFLINE))
+    if ((msgFlags & nsMsgMessageFlags::Offline))
       *result = PR_TRUE;
   }
   return NS_OK;
 }
 
 
 NS_IMETHODIMP nsMsgDBFolder::GetFlags(PRUint32 *_retval)
 {
@@ -2180,19 +2180,19 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgW
       }
       filterMessageForJunk = PR_TRUE;
       break;
     }
     if (filterMessageForJunk || filterForOther)
     {
       keysToClassify.AppendElement(newMessageKeys[i]);
       if (filterMessageForJunk)
-        OrProcessingFlags(msgKey, MSG_PROCESSING_FLAG_CLASSIFY_JUNK);
+        OrProcessingFlags(msgKey, nsMsgProcessingFlags::ClassifyJunk);
       if (filterForOther)
-        OrProcessingFlags(msgKey, MSG_PROCESSING_FLAG_CLASSIFY_TRAITS);
+        OrProcessingFlags(msgKey, nsMsgProcessingFlags::ClassifyTraits);
     }
   }
 
   if (!keysToClassify.IsEmpty())
   {
     PRUint32 numMessagesToClassify = keysToClassify.Length();
     char ** messageURIs = (char **) PR_MALLOC(sizeof(const char *) * numMessagesToClassify);
     if (!messageURIs)
@@ -5364,33 +5364,33 @@ NS_IMETHODIMP nsMsgDBFolder::GetCustomId
   *aIdentity = nsnull;
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgDBFolder::GetProcessingFlags(nsMsgKey aKey, PRUint32 *aFlags)
 {
   NS_ENSURE_ARG_POINTER(aFlags);
   *aFlags = 0;
-  for (PRUint32 i = 0; i < MSG_NUMBER_OF_PROCESSING_FLAGS; i++)
+  for (PRUint32 i = 0; i < nsMsgProcessingFlags::NumberOfFlags; i++)
     if (mProcessingFlag[i].keys && mProcessingFlag[i].keys->IsMember(aKey))
       *aFlags |= mProcessingFlag[i].bit;
   return NS_OK;
 }  
 
 NS_IMETHODIMP nsMsgDBFolder::OrProcessingFlags(nsMsgKey aKey, PRUint32 mask)
 {
-  for (PRUint32 i = 0; i < MSG_NUMBER_OF_PROCESSING_FLAGS; i++)
+  for (PRUint32 i = 0; i < nsMsgProcessingFlags::NumberOfFlags; i++)
     if (mProcessingFlag[i].bit & mask && mProcessingFlag[i].keys)
       mProcessingFlag[i].keys->Add(aKey);
   return NS_OK;
 }  
 
 NS_IMETHODIMP nsMsgDBFolder::AndProcessingFlags(nsMsgKey aKey, PRUint32 mask)
 {
-  for (PRUint32 i = 0; i < MSG_NUMBER_OF_PROCESSING_FLAGS; i++)
+  for (PRUint32 i = 0; i < nsMsgProcessingFlags::NumberOfFlags; i++)
     if (!(mProcessingFlag[i].bit & mask) && mProcessingFlag[i].keys)
       mProcessingFlag[i].keys->Remove(aKey);
   return NS_OK;
 }
 
 /* static */ nsMsgKeySetU* nsMsgKeySetU::Create()
 {
   nsMsgKeySetU* set = new nsMsgKeySetU;
--- a/mailnews/base/util/nsMsgDBFolder.h
+++ b/mailnews/base/util/nsMsgDBFolder.h
@@ -153,17 +153,17 @@ protected:
   static PRBool PromptForMasterPasswordIfNecessary();
 
   // offline support methods.
   nsresult StartNewOfflineMessage();
   nsresult WriteStartOfNewLocalMessage();
   nsresult EndNewOfflineMessage();
   nsresult CompactOfflineStore(nsIMsgWindow *inWindow, nsIUrlListener *aUrlListener);
   nsresult AutoCompact(nsIMsgWindow *aWindow);
-  // this is a helper routine that ignores whether MSG_FLAG_OFFLINE is set for the folder
+  // this is a helper routine that ignores whether nsMsgMessageFlags::Offline is set for the folder
   nsresult MsgFitsDownloadCriteria(nsMsgKey msgKey, PRBool *result);
   nsresult GetPromptPurgeThreshold(PRBool *aPrompt);
   nsresult GetPurgeThreshold(PRInt32 *aThreshold);
   nsresult ApplyRetentionSettings(PRBool deleteViaFolder);
 
   nsresult PerformBiffNotifications(void); // if there are new, non spam messages, do biff
   nsresult CloseDBIfFolderNotOpen();
 
@@ -286,17 +286,17 @@ protected:
 
   static const NS_MSG_BASE_STATIC_MEMBER_(nsStaticAtom) folder_atoms[];
 
   // store of keys that have a processing flag set
   struct
   {
     PRUint32 bit;
     nsMsgKeySetU* keys;
-  } mProcessingFlag[MSG_NUMBER_OF_PROCESSING_FLAGS];
+  } mProcessingFlag[nsMsgProcessingFlags::NumberOfFlags];
 };
 
 // This class is a kludge to allow nsMsgKeySet to be used with PRUint32 keys
 class nsMsgKeySetU
 {
 public:
     // Creates an empty set.
   static nsMsgKeySetU* Create();
--- a/mailnews/base/util/nsMsgTxn.cpp
+++ b/mailnews/base/util/nsMsgTxn.cpp
@@ -328,13 +328,13 @@ nsMsgTxn::CheckForToggleDelete(nsIMsgFol
     rv = db->ContainsKey(aMsgKey, &containsKey);
     if (NS_FAILED(rv) || !containsKey)   // the message has been deleted from db, so we cannot do toggle here
       return NS_OK;
     rv = db->GetMsgHdrForKey(aMsgKey, getter_AddRefs(message));
     PRUint32 flags;
     if (NS_SUCCEEDED(rv) && message)
     {
       message->GetFlags(&flags);
-      *aResult = (flags & MSG_FLAG_IMAP_DELETED) != 0;
+      *aResult = (flags & nsMsgMessageFlags::IMAPDeleted) != 0;
     }
   }
   return rv;
 }
--- a/mailnews/compose/src/nsMsgCompose.cpp
+++ b/mailnews/compose/src/nsMsgCompose.cpp
@@ -1986,17 +1986,17 @@ nsresult nsMsgCompose::CreateMessage(con
             mWhatHolder = 1;
             break;
           }
         case nsIMsgCompType::ForwardAsAttachment:
           {
             PRUint32 flags;
 
             msgHdr->GetFlags(&flags);
-            if (flags & MSG_FLAG_HAS_RE)
+            if (flags & nsMsgMessageFlags::HasRe)
               subject.Insert(NS_LITERAL_STRING("Re: "), 0);
 
             // Setup quoting callbacks for later...
             mQuotingToFollow = PR_FALSE;  //We don't need to quote the original message.
             nsCOMPtr<nsIMsgAttachment> attachment = do_CreateInstance(NS_MSGATTACHMENT_CONTRACTID, &rv);
             if (NS_SUCCEEDED(rv) && attachment)
             {
               PRBool addExtension = PR_TRUE;
--- a/mailnews/compose/src/nsMsgCopy.cpp
+++ b/mailnews/compose/src/nsMsgCopy.cpp
@@ -301,17 +301,17 @@ nsMsgCopy::DoCopy(nsIFile *aDiskFile, ns
             copyListener->mCopyInProgress = PR_TRUE;
             NS_GetCurrentThread(getter_AddRefs(thread));
         }
     }
     nsCOMPtr<nsIMsgCopyService> copyService = do_GetService(NS_MSGCOPYSERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = copyService->CopyFileMessage(aDiskFile, dstFolder, aMsgToReplace,
-                                      aIsDraft, MSG_FLAG_READ, EmptyCString(),
+                                      aIsDraft, nsMsgMessageFlags::Read, EmptyCString(),
                                       copyListener, msgWindow);
     // copyListener->mCopyInProgress can only be set when we are in the
     // middle of the shutdown process
     while (copyListener->mCopyInProgress)
     {
         PR_CEnterMonitor(copyListener);
         PR_CWait(copyListener, PR_MicrosecondsToInterval(1000UL));
         PR_CExitMonitor(copyListener);
--- a/mailnews/compose/src/nsMsgSend.cpp
+++ b/mailnews/compose/src/nsMsgSend.cpp
@@ -4681,17 +4681,17 @@ nsMsgComposeAndSend::MimeDoFCC(nsIFile  
       goto FAIL;
     }
   }
 
   //
   // Write out an X-Mozilla-Status header.
   //
   // This is required for the queue file, so that we can overwrite it once
-  // the messages have been delivered, and so that the MSG_FLAG_QUEUED bit
+  // the messages have been delivered, and so that the nsMsgMessageFlags::Queued bit
   // is set.
   //
   // For FCC files, we don't necessarily need one, but we might as well put
   // one in so that it's marked as read already.
   //
   //
   // Need to add these lines for POP3 ONLY! IMAP servers will handle
   // this status information for summary file regeneration for us.
@@ -4700,39 +4700,39 @@ nsMsgComposeAndSend::MimeDoFCC(nsIFile  
         mode == nsMsgSendUnsent) && folderIsLocal)
   {
     char       *buf = 0;
     PRUint16   flags = 0;
 
     // for save as draft and send later, we want to leave the message as unread.
     // See Bug #198087
     if (mode == nsMsgQueueForLater)
-      flags |= MSG_FLAG_QUEUED;
+      flags |= nsMsgMessageFlags::Queued;
     else if (mode != nsMsgSaveAsDraft)
-      flags |= MSG_FLAG_READ;
+      flags |= nsMsgMessageFlags::Read;
     buf = PR_smprintf(X_MOZILLA_STATUS_FORMAT CRLF, flags);
     if (buf)
     {
       PRUint32   len = PL_strlen(buf);
       rv = tempOutfile->Write(buf, len, &n);
       PR_Free(buf);
       if (NS_FAILED(rv) || n != len)
       {
         status = NS_ERROR_FAILURE;
         goto FAIL;
       }
     }
 
     PRUint32 flags2 = 0;
     if (mode == nsMsgSaveAsTemplate)
-      flags2 |= MSG_FLAG_TEMPLATE;
+      flags2 |= nsMsgMessageFlags::Template;
     if (mode == nsMsgDeliverNow || mode == nsMsgSendUnsent)
     {
-      flags2 &= ~MSG_FLAG_MDN_REPORT_NEEDED;
-      flags2 |= MSG_FLAG_MDN_REPORT_SENT;
+      flags2 &= ~nsMsgMessageFlags::MDNReportNeeded;
+      flags2 |= nsMsgMessageFlags::MDNReportSent;
     }
     buf = PR_smprintf(X_MOZILLA_STATUS2_FORMAT CRLF, flags2);
     if (buf)
     {
       PRUint32   len = PL_strlen(buf);
       rv = tempOutfile->Write(buf, len, &n);
       PR_Free(buf);
       if (NS_FAILED(rv) || n != len)
--- a/mailnews/db/msgdb/public/nsImapMailDatabase.h
+++ b/mailnews/db/msgdb/public/nsImapMailDatabase.h
@@ -60,19 +60,19 @@ public:
   NS_IMETHOD    AddNewHdrToDB(nsIMsgDBHdr *newHdr, PRBool notify);
   NS_IMETHOD    SetAttributesOnPendingHdr(nsIMsgDBHdr *pendingHdr, const char *property, 
                                   const char *propertyVal, PRInt32 flags);
   NS_IMETHODIMP DeleteMessages(nsTArray<nsMsgKey>* nsMsgKeys, 
                                nsIDBChangeListener *instigator);
 
 protected:
   // IMAP does not set local file flags, override does nothing
-  virtual void	UpdateFolderFlag(nsIMsgDBHdr *msgHdr, PRBool bSet, 
-                                  MsgFlags flag, nsIOutputStream **ppFileStream);
-  virtual PRBool SetHdrFlag(nsIMsgDBHdr *msgHdr, PRBool bSet, MsgFlags flag);
+  virtual void UpdateFolderFlag(nsIMsgDBHdr *msgHdr, PRBool bSet, 
+                                nsMsgMessageFlagType flag, nsIOutputStream **ppFileStream);
+  virtual PRBool SetHdrFlag(nsIMsgDBHdr *msgHdr, PRBool bSet, nsMsgMessageFlagType flag);
 
    nsresult     GetAllPendingHdrsTable();
    mdb_token    m_pendingHdrsRowScopeToken;
    mdb_token    m_pendingHdrsTableKindToken; 
    nsCOMPtr <nsIMdbTable> m_mdbAllPendingHdrsTable;
 };
 
 
--- a/mailnews/db/msgdb/public/nsMailDatabase.h
+++ b/mailnews/db/msgdb/public/nsMailDatabase.h
@@ -84,19 +84,19 @@ protected:
 
   nsresult        GetAllOfflineOpsTable(); // get this on demand
   PRUint32        GetMailboxModDate(); 
 
   nsCOMPtr <nsIMdbTable>  m_mdbAllOfflineOpsTable;
   mdb_token       m_offlineOpsRowScopeToken;
   mdb_token       m_offlineOpsTableKindToken;
 
-  virtual PRBool  SetHdrFlag(nsIMsgDBHdr *, PRBool bSet, MsgFlags flag);
+  virtual PRBool  SetHdrFlag(nsIMsgDBHdr *, PRBool bSet, nsMsgMessageFlagType flag);
   virtual void    UpdateFolderFlag(nsIMsgDBHdr *msgHdr, PRBool bSet, 
-                                    MsgFlags flag, nsIOutputStream **ppFileStream);
+                                   nsMsgMessageFlagType flag, nsIOutputStream **ppFileStream);
   virtual void    SetReparse(PRBool reparse);
   
 protected:
   virtual void    GetGlobalPrefs();
   
   PRBool          m_reparse;
   nsCOMPtr <nsILocalFile> m_folderFile;
   nsCOMPtr <nsIOutputStream> m_folderStream; 	/* this is a cache for loops which want file left open */
--- a/mailnews/db/msgdb/public/nsMsgDatabase.h
+++ b/mailnews/db/msgdb/public/nsMsgDatabase.h
@@ -201,17 +201,17 @@ protected:
   PRBool  MatchDbName(nsILocalFile *dbName);  // returns TRUE if they match
   
   // Flag handling routines
   virtual nsresult SetKeyFlag(nsMsgKey key, PRBool set, PRUint32 flag,
                               nsIDBChangeListener *instigator = NULL);
   virtual nsresult SetMsgHdrFlag(nsIMsgDBHdr *msgHdr, PRBool set, PRUint32 flag, 
                                  nsIDBChangeListener *instigator);
   
-  virtual PRBool  SetHdrFlag(nsIMsgDBHdr *, PRBool bSet, MsgFlags flag);
+  virtual PRBool  SetHdrFlag(nsIMsgDBHdr *, PRBool bSet, nsMsgMessageFlagType flag);
   virtual PRBool  SetHdrReadFlag(nsIMsgDBHdr *, PRBool pRead);
   virtual PRUint32 GetStatusFlags(nsIMsgDBHdr *msgHdr, PRUint32 origFlags);
   // helper function which doesn't involve thread object
   
   virtual nsresult RemoveHeaderFromDB(nsMsgHdr *msgHdr);
   virtual nsresult RemoveHeaderFromThread(nsMsgHdr *msgHdr);
   virtual nsresult AdjustExpungedBytesOnDelete(nsIMsgDBHdr *msgHdr);
   
--- a/mailnews/db/msgdb/src/nsImapMailDatabase.cpp
+++ b/mailnews/db/msgdb/src/nsImapMailDatabase.cpp
@@ -75,31 +75,31 @@ NS_IMETHODIMP	nsImapMailDatabase::SetSum
   {
     m_dbFolderInfo->SetVersion(valid ? GetCurVersion() : 0);
     Commit(nsMsgDBCommitType::kLargeCommit);
   }
   return NS_OK;
 }
 
 // IMAP does not set local file flags, override does nothing
-void	nsImapMailDatabase::UpdateFolderFlag(nsIMsgDBHdr * /* msgHdr */, PRBool /* bSet */,
-                                              MsgFlags /* flag */, nsIOutputStream ** /* ppFileStream */)
+void nsImapMailDatabase::UpdateFolderFlag(nsIMsgDBHdr * /* msgHdr */, PRBool /* bSet */,
+                                          nsMsgMessageFlagType /* flag */, nsIOutputStream ** /* ppFileStream */)
 {
 }
 
 // We override this to avoid our parent class (nsMailDatabase)'s 
 // grabbing of the folder semaphore, and bailing on failure.
 NS_IMETHODIMP nsImapMailDatabase::DeleteMessages(nsTArray<nsMsgKey>* nsMsgKeys, nsIDBChangeListener *instigator)
 {
   return nsMsgDatabase::DeleteMessages(nsMsgKeys, instigator);
 }
 
 // We override this so we won't try to change the x-mozilla-status flags
 // in the offline store.
-PRBool nsImapMailDatabase::SetHdrFlag(nsIMsgDBHdr *msgHdr, PRBool bSet, MsgFlags flag)
+PRBool nsImapMailDatabase::SetHdrFlag(nsIMsgDBHdr *msgHdr, PRBool bSet, nsMsgMessageFlagType flag)
 {
   return nsMsgDatabase::SetHdrFlag(msgHdr, bSet, flag);
 }
 
 // override so nsMailDatabase methods that deal with m_folderStream are *not* called
 NS_IMETHODIMP nsImapMailDatabase::StartBatch()
 {
   return NS_OK;
@@ -109,17 +109,17 @@ NS_IMETHODIMP nsImapMailDatabase::EndBat
 {
   return NS_OK;
 }
 
 nsresult nsImapMailDatabase::AdjustExpungedBytesOnDelete(nsIMsgDBHdr *msgHdr)
 {
   PRUint32 msgFlags;
   msgHdr->GetFlags(&msgFlags);
-  if (msgFlags & MSG_FLAG_OFFLINE && m_dbFolderInfo)
+  if (msgFlags & nsMsgMessageFlags::Offline && m_dbFolderInfo)
   {
     PRUint32 size = 0;
     (void)msgHdr->GetOfflineMessageSize(&size);
     return m_dbFolderInfo->ChangeExpungedBytes (size);
   }
   return NS_OK;
 }
 
--- a/mailnews/db/msgdb/src/nsMailDatabase.cpp
+++ b/mailnews/db/msgdb/src/nsMailDatabase.cpp
@@ -194,17 +194,17 @@ NS_IMETHODIMP nsMailDatabase::DeleteMess
     m_ownFolderStream = PR_FALSE;
   }
 
   SetFolderInfoValid(m_folderFile, 0, 0);
   return rv;
 }
 
 // Helper routine - lowest level of flag setting
-PRBool nsMailDatabase::SetHdrFlag(nsIMsgDBHdr *msgHdr, PRBool bSet, MsgFlags flag)
+PRBool nsMailDatabase::SetHdrFlag(nsIMsgDBHdr *msgHdr, PRBool bSet, nsMsgMessageFlagType flag)
 {
   nsIOutputStream *fileStream = nsnull;
   PRBool ret = PR_FALSE;
 
   if (!m_folderStream && m_folder)  //we are going to create a stream, bail out if someone else has lock
   {
     PRBool isLocked;
     m_folder->GetLocked(&isLocked);
@@ -239,17 +239,18 @@ int msg_UnHex(char C)
 }
 
 
 // We let the caller close the file in case he's updating a lot of flags
 // and we don't want to open and close the file every time through.
 // As an experiment, try caching the fid in the db as m_folderFile.
 // If this is set, use it but don't return *pFid.
 void nsMailDatabase::UpdateFolderFlag(nsIMsgDBHdr *mailHdr, PRBool bSet, 
-							  MsgFlags flag, nsIOutputStream **ppFileStream)
+                                      nsMsgMessageFlagType flag,
+                                      nsIOutputStream **ppFileStream)
 {
   static char buf[50];
   PRInt64 folderStreamPos = 0; //saves the folderStream pos in case we are sharing the stream with other code
   nsIOutputStream *fileStream = (m_folderStream) ? m_folderStream.get() : *ppFileStream;
   PRUint32 offset;
   (void)mailHdr->GetStatusOffset(&offset);
   nsCOMPtr <nsISeekableStream> seekableStream;
   
@@ -289,34 +290,34 @@ void nsMailDatabase::UpdateFolderFlag(ns
         buf[bytesRead] = '\0';
         if (strncmp(buf, X_MOZILLA_STATUS, X_MOZILLA_STATUS_LEN) == 0 &&
           strncmp(buf + X_MOZILLA_STATUS_LEN, ": ", 2) == 0 &&
           strlen(buf) >= X_MOZILLA_STATUS_LEN + 6) 
         {
           PRUint32 flags;
           PRUint32 bytesWritten;
           (void)mailHdr->GetFlags(&flags);
-          if (!(flags & MSG_FLAG_EXPUNGED))
+          if (!(flags & nsMsgMessageFlags::Expunged))
           {
             int i;
             char *p = buf + X_MOZILLA_STATUS_LEN + 2;
             
             for (i=0, flags = 0; i<4; i++, p++)
             {
               flags = (flags << 4) | msg_UnHex(*p);
             }
             
             PRUint32 curFlags;
             (void)mailHdr->GetFlags(&curFlags);
-            flags = (flags & MSG_FLAG_QUEUED) |
-              (curFlags & ~MSG_FLAG_RUNTIME_ONLY);
+            flags = (flags & nsMsgMessageFlags::Queued) |
+              (curFlags & ~nsMsgMessageFlags::RuntimeOnly);
           }
           else
           {
-            flags &= ~MSG_FLAG_RUNTIME_ONLY;
+            flags &= ~nsMsgMessageFlags::RuntimeOnly;
           }
           seekableStream->Seek(nsISeekableStream::NS_SEEK_SET, statusPos);
           // We are filing out x-mozilla-status flags here
           PR_snprintf(buf, sizeof(buf), X_MOZILLA_STATUS_FORMAT,
             flags & 0x0000FFFF);
           PRInt32 lineLen = PL_strlen(buf);
           PRUint32 status2Pos = statusPos + lineLen + MSG_LINEBREAK_LEN;
           fileStream->Write(buf, lineLen, &bytesWritten);
--- a/mailnews/db/msgdb/src/nsMsgDatabase.cpp
+++ b/mailnews/db/msgdb/src/nsMsgDatabase.cpp
@@ -1734,17 +1734,17 @@ nsresult nsMsgDatabase::AdjustExpungedBy
 }
 
 NS_IMETHODIMP nsMsgDatabase::DeleteHeader(nsIMsgDBHdr *msg, nsIDBChangeListener *instigator, PRBool commit, PRBool notify)
 {
   nsMsgHdr* msgHdr = static_cast<nsMsgHdr*>(msg);  // closed system, so this is ok
   nsMsgKey key;
   (void)msg->GetMessageKey(&key);
   // only need to do this for mail - will this speed up news expiration?
-  SetHdrFlag(msg, PR_TRUE, MSG_FLAG_EXPUNGED);  // tell mailbox (mail)
+  SetHdrFlag(msg, PR_TRUE, nsMsgMessageFlags::Expunged);  // tell mailbox (mail)
 
   PRBool hdrWasNew = m_newSet.BinaryIndexOf(key) != -1;
   m_newSet.RemoveElement(key);
 
   if (m_dbFolderInfo != NULL)
   {
     PRBool isRead;
     m_dbFolderInfo->ChangeNumMessages(-1);
@@ -1765,17 +1765,17 @@ NS_IMETHODIMP nsMsgDatabase::DeleteHeade
   }
 
   RemoveHeaderFromThread(msgHdr);
   if (notify)
   {
     // If deleted hdr was new, restore the new flag on flags 
     // so saved searches will know to reduce their new msg count.
     if (hdrWasNew)
-      flags |= MSG_FLAG_NEW;
+      flags |= nsMsgMessageFlags::New;
     NotifyHdrDeletedAll(msg, threadParent, flags, instigator); // tell listeners
   }
   //  if (!onlyRemoveFromThread)  // to speed up expiration, try this. But really need to do this in RemoveHeaderFromDB
   nsresult ret = RemoveHeaderFromDB(msgHdr);
 
 
   if (commit)
     Commit(nsMsgDBCommitType::kLargeCommit);      // ### dmb is this a good time to commit?
@@ -1784,18 +1784,18 @@ NS_IMETHODIMP nsMsgDatabase::DeleteHeade
 
 NS_IMETHODIMP
 nsMsgDatabase::UndoDelete(nsIMsgDBHdr *aMsgHdr)
 {
     if (aMsgHdr)
     {
         nsMsgHdr* msgHdr = static_cast<nsMsgHdr*>(aMsgHdr);  // closed system, so this is ok
         // force deleted flag, so SetHdrFlag won't bail out because  deleted flag isn't set
-        msgHdr->m_flags |= MSG_FLAG_EXPUNGED;
-        SetHdrFlag(msgHdr, PR_FALSE, MSG_FLAG_EXPUNGED); // clear deleted flag in db
+        msgHdr->m_flags |= nsMsgMessageFlags::Expunged;
+        SetHdrFlag(msgHdr, PR_FALSE, nsMsgMessageFlags::Expunged); // clear deleted flag in db
     }
     return NS_OK;
 }
 
 nsresult nsMsgDatabase::RemoveHeaderFromThread(nsMsgHdr *msgHdr)
 {
   if (!msgHdr)
     return NS_ERROR_NULL_POINTER;
@@ -1851,48 +1851,48 @@ nsresult nsMsgDatabase::IsRead(nsMsgKey 
 PRUint32  nsMsgDatabase::GetStatusFlags(nsIMsgDBHdr *msgHdr, PRUint32 origFlags)
 {
   PRUint32  statusFlags = origFlags;
   PRBool  isRead = PR_TRUE;
 
   nsMsgKey key;
   (void)msgHdr->GetMessageKey(&key);
   if (!m_newSet.IsEmpty() && m_newSet[m_newSet.Length() - 1] == key || m_newSet.BinaryIndexOf(key) != kNotFound)
-    statusFlags |= MSG_FLAG_NEW;
+    statusFlags |= nsMsgMessageFlags::New;
   else
-    statusFlags &= ~MSG_FLAG_NEW;
+    statusFlags &= ~nsMsgMessageFlags::New;
   if (IsHeaderRead(msgHdr, &isRead) == NS_OK && isRead)
-    statusFlags |= MSG_FLAG_READ;
+    statusFlags |= nsMsgMessageFlags::Read;
   return statusFlags;
 }
 
 nsresult nsMsgDatabase::IsHeaderRead(nsIMsgDBHdr *msgHdr, PRBool *pRead)
 {
   if (!msgHdr)
     return NS_MSG_MESSAGE_NOT_FOUND;
 
   nsMsgHdr* hdr = static_cast<nsMsgHdr*>(msgHdr);          // closed system, cast ok
   // can't call GetFlags, because it will be recursive.
   PRUint32 flags;
   hdr->GetRawFlags(&flags);
-  *pRead = (flags & MSG_FLAG_READ) != 0;
+  *pRead = (flags & nsMsgMessageFlags::Read) != 0;
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgDatabase::IsMarked(nsMsgKey key, PRBool *pMarked)
 {
   nsCOMPtr <nsIMsgDBHdr> msgHdr;
 
   nsresult rv = GetMsgHdrForKey(key, getter_AddRefs(msgHdr));
   if (NS_FAILED(rv))
     return NS_MSG_MESSAGE_NOT_FOUND; // XXX return rv?
 
   PRUint32 flags;
   (void)msgHdr->GetFlags(&flags);
-  *pMarked = (flags & MSG_FLAG_MARKED) == MSG_FLAG_MARKED;
+  *pMarked = (flags & nsMsgMessageFlags::Marked) == nsMsgMessageFlags::Marked;
   return rv;
 }
 
 NS_IMETHODIMP nsMsgDatabase::IsIgnored(nsMsgKey key, PRBool *pIgnored)
 {
   PR_ASSERT(pIgnored != NULL);
   if (!pIgnored)
     return NS_ERROR_NULL_POINTER;
@@ -1901,39 +1901,39 @@ NS_IMETHODIMP nsMsgDatabase::IsIgnored(n
   nsresult rv = GetThreadForMsgKey(key, getter_AddRefs(threadHdr));
   // This should be very surprising, but we leave that up to the caller
   // to determine for now.
   if (!threadHdr)
     return NS_MSG_MESSAGE_NOT_FOUND;
 
   PRUint32 threadFlags;
   threadHdr->GetFlags(&threadFlags);
-  *pIgnored = (threadFlags & MSG_FLAG_IGNORED) ? PR_TRUE : PR_FALSE;
+  *pIgnored = (threadFlags & nsMsgMessageFlags::Ignored) ? PR_TRUE : PR_FALSE;
   return rv;
 }
 
 nsresult nsMsgDatabase::HasAttachments(nsMsgKey key, PRBool *pHasThem)
 {
   NS_ENSURE_ARG_POINTER(pHasThem);
 
   nsCOMPtr <nsIMsgDBHdr> msgHdr;
 
   nsresult rv = GetMsgHdrForKey(key, getter_AddRefs(msgHdr));
   if (NS_FAILED(rv))
     return rv;
 
   PRUint32 flags;
   (void)msgHdr->GetFlags(&flags);
-  *pHasThem = (flags & MSG_FLAG_ATTACHMENT) ? PR_TRUE : PR_FALSE;
+  *pHasThem = (flags & nsMsgMessageFlags::Attachment) ? PR_TRUE : PR_FALSE;
   return rv;
 }
 
 PRBool nsMsgDatabase::SetHdrReadFlag(nsIMsgDBHdr *msgHdr, PRBool bRead)
 {
-  return SetHdrFlag(msgHdr, bRead, MSG_FLAG_READ);
+  return SetHdrFlag(msgHdr, bRead, nsMsgMessageFlags::Read);
 }
 
 nsresult nsMsgDatabase::MarkHdrReadInDB(nsIMsgDBHdr *msgHdr, PRBool bRead,
                                              nsIDBChangeListener *instigator)
 {
   nsresult rv;
   nsMsgKey key;
   PRUint32 oldFlags;
@@ -1950,17 +1950,17 @@ nsresult nsMsgDatabase::MarkHdrReadInDB(
     else
       m_dbFolderInfo->ChangeNumUnreadMessages(1);
   }
 
   SetHdrReadFlag(msgHdr, bRead); // this will cause a commit, at least for local mail, so do it after we change
   // the folder counts above, so they will get committed too.
   PRUint32 flags;
   rv = msgHdr->GetFlags(&flags);
-  flags &= ~MSG_FLAG_NEW;
+  flags &= ~nsMsgMessageFlags::New;
   msgHdr->SetFlags(flags);
   if (NS_FAILED(rv)) return rv;
 
   if (oldFlags == flags)
     return NS_OK;
 
   return NotifyHdrChangeAll(msgHdr, oldFlags, flags, instigator);
 }
@@ -1977,29 +1977,29 @@ NS_IMETHODIMP nsMsgDatabase::MarkRead(ns
 
   rv = MarkHdrRead(msgHdr, bRead, instigator);
   return rv;
 }
 
 NS_IMETHODIMP nsMsgDatabase::MarkReplied(nsMsgKey key, PRBool bReplied,
                                          nsIDBChangeListener *instigator /* = NULL */)
 {
-  return SetKeyFlag(key, bReplied, MSG_FLAG_REPLIED, instigator);
+  return SetKeyFlag(key, bReplied, nsMsgMessageFlags::Replied, instigator);
 }
 
 NS_IMETHODIMP nsMsgDatabase::MarkForwarded(nsMsgKey key, PRBool bForwarded,
                                            nsIDBChangeListener *instigator /* = NULL */)
 {
-  return SetKeyFlag(key, bForwarded, MSG_FLAG_FORWARDED, instigator);
+  return SetKeyFlag(key, bForwarded, nsMsgMessageFlags::Forwarded, instigator);
 }
 
 NS_IMETHODIMP nsMsgDatabase::MarkHasAttachments(nsMsgKey key, PRBool bHasAttachments,
                                                 nsIDBChangeListener *instigator)
 {
-  return SetKeyFlag(key, bHasAttachments, MSG_FLAG_ATTACHMENT, instigator);
+  return SetKeyFlag(key, bHasAttachments, nsMsgMessageFlags::Attachment, instigator);
 }
 
 NS_IMETHODIMP
 nsMsgDatabase::MarkThreadRead(nsIMsgThread *thread, nsIDBChangeListener *instigator, nsTArray<nsMsgKey> *thoseMarked)
 {
   if (!thread)
     return NS_ERROR_NULL_POINTER;
   nsresult rv = NS_OK;
@@ -2036,79 +2036,79 @@ nsMsgDatabase::MarkThreadIgnored(nsIMsgT
                                  nsIDBChangeListener *instigator)
 {
   NS_ENSURE_ARG(thread);
   PRUint32 threadFlags;
   thread->GetFlags(&threadFlags);
   PRUint32 oldThreadFlags = threadFlags; // not quite right, since we probably want msg hdr flags.
   if (bIgnored)
   {
-    threadFlags |= MSG_FLAG_IGNORED;
-    threadFlags &= ~MSG_FLAG_WATCHED;  // ignore is implicit un-watch
+    threadFlags |= nsMsgMessageFlags::Ignored;
+    threadFlags &= ~nsMsgMessageFlags::Watched;  // ignore is implicit un-watch
   }
   else
-    threadFlags &= ~MSG_FLAG_IGNORED;
+    threadFlags &= ~nsMsgMessageFlags::Ignored;
   thread->SetFlags(threadFlags);
 
   nsCOMPtr <nsIMsgDBHdr> msg;
   nsresult rv = GetMsgHdrForKey(threadKey, getter_AddRefs(msg));
   NS_ENSURE_SUCCESS(rv, rv);
   return NotifyHdrChangeAll(msg, oldThreadFlags, threadFlags, instigator);
 }
 
 NS_IMETHODIMP
 nsMsgDatabase::MarkHeaderKilled(nsIMsgDBHdr *msg, PRBool bIgnored,
                            nsIDBChangeListener *instigator)
 {
   PRUint32 msgFlags;
   msg->GetFlags(&msgFlags);
   PRUint32 oldFlags = msgFlags;
   if (bIgnored)
-    msgFlags |= MSG_FLAG_IGNORED;
+    msgFlags |= nsMsgMessageFlags::Ignored;
   else
-    msgFlags &= ~MSG_FLAG_IGNORED;
+    msgFlags &= ~nsMsgMessageFlags::Ignored;
   msg->SetFlags(msgFlags);
 
   return NotifyHdrChangeAll(msg, oldFlags, msgFlags, instigator);
 }
 
 NS_IMETHODIMP
 nsMsgDatabase::MarkThreadWatched(nsIMsgThread *thread, nsMsgKey threadKey, PRBool bWatched,
                                  nsIDBChangeListener *instigator)
 {
   NS_ENSURE_ARG(thread);
   PRUint32 threadFlags;
   thread->GetFlags(&threadFlags);
   PRUint32 oldThreadFlags = threadFlags; // not quite right, since we probably want msg hdr flags.
   if (bWatched)
   {
-    threadFlags |= MSG_FLAG_WATCHED;
-    threadFlags &= ~MSG_FLAG_IGNORED;  // watch is implicit un-ignore
+    threadFlags |= nsMsgMessageFlags::Watched;
+    threadFlags &= ~nsMsgMessageFlags::Ignored;  // watch is implicit un-ignore
   }
   else
-    threadFlags &= ~MSG_FLAG_WATCHED;
+    threadFlags &= ~nsMsgMessageFlags::Watched;
 
   nsCOMPtr <nsIMsgDBHdr> msg;
   GetMsgHdrForKey(threadKey, getter_AddRefs(msg));
 
   nsresult rv  = NotifyHdrChangeAll(msg, oldThreadFlags, threadFlags, instigator);
   thread->SetFlags(threadFlags);
   return rv;
 }
 
 NS_IMETHODIMP nsMsgDatabase::MarkMarked(nsMsgKey key, PRBool mark,
                                         nsIDBChangeListener *instigator)
 {
-  return SetKeyFlag(key, mark, MSG_FLAG_MARKED, instigator);
+  return SetKeyFlag(key, mark, nsMsgMessageFlags::Marked, instigator);
 }
 
 NS_IMETHODIMP nsMsgDatabase::MarkOffline(nsMsgKey key, PRBool offline,
                                          nsIDBChangeListener *instigator)
 {
-  return SetKeyFlag(key, offline, MSG_FLAG_OFFLINE, instigator);
+  return SetKeyFlag(key, offline, nsMsgMessageFlags::Offline, instigator);
 }
 
 NS_IMETHODIMP nsMsgDatabase::SetStringProperty(nsMsgKey aKey, const char *aProperty, const char *aValue)
 {
   nsCOMPtr <nsIMsgDBHdr> msgHdr;
   nsresult rv = GetMsgHdrForKey(aKey, getter_AddRefs(msgHdr));
   if (NS_FAILED(rv) || !msgHdr)
     return NS_MSG_MESSAGE_NOT_FOUND; // XXX return rv?
@@ -2193,58 +2193,58 @@ NS_IMETHODIMP nsMsgDatabase::SetLabel(ns
     rv = SetKeyFlag(key, PR_TRUE, label << 25, nsnull);
   }
   return rv;
 }
 
 NS_IMETHODIMP nsMsgDatabase::MarkImapDeleted(nsMsgKey key, PRBool deleted,
                                              nsIDBChangeListener *instigator)
 {
-  return SetKeyFlag(key, deleted, MSG_FLAG_IMAP_DELETED, instigator);
+  return SetKeyFlag(key, deleted, nsMsgMessageFlags::IMAPDeleted, instigator);
 }
 
 NS_IMETHODIMP nsMsgDatabase::MarkMDNNeeded(nsMsgKey key, PRBool bNeeded,
                                            nsIDBChangeListener *instigator /* = NULL */)
 {
-  return SetKeyFlag(key, bNeeded, MSG_FLAG_MDN_REPORT_NEEDED, instigator);
+  return SetKeyFlag(key, bNeeded, nsMsgMessageFlags::MDNReportNeeded, instigator);
 }
 
 NS_IMETHODIMP nsMsgDatabase::IsMDNNeeded(nsMsgKey key, PRBool *pNeeded)
 {
   nsCOMPtr <nsIMsgDBHdr> msgHdr;
 
   nsresult rv = GetMsgHdrForKey(key, getter_AddRefs(msgHdr));
   if (NS_FAILED(rv) || !msgHdr)
     return NS_MSG_MESSAGE_NOT_FOUND; // XXX return rv?
 
   PRUint32 flags;
   (void)msgHdr->GetFlags(&flags);
-  *pNeeded = ((flags & MSG_FLAG_MDN_REPORT_NEEDED) == MSG_FLAG_MDN_REPORT_NEEDED);
+  *pNeeded = ((flags & nsMsgMessageFlags::MDNReportNeeded) == nsMsgMessageFlags::MDNReportNeeded);
   return rv;
 }
 
 
 nsresult nsMsgDatabase::MarkMDNSent(nsMsgKey key, PRBool bSent,
                                     nsIDBChangeListener *instigator /* = NULL */)
 {
-  return SetKeyFlag(key, bSent, MSG_FLAG_MDN_REPORT_SENT, instigator);
+  return SetKeyFlag(key, bSent, nsMsgMessageFlags::MDNReportSent, instigator);
 }
 
 
 nsresult nsMsgDatabase::IsMDNSent(nsMsgKey key, PRBool *pSent)
 {
   nsCOMPtr <nsIMsgDBHdr> msgHdr;
 
   nsresult rv = GetMsgHdrForKey(key, getter_AddRefs(msgHdr));
   if (NS_FAILED(rv) || !msgHdr)
     return NS_MSG_MESSAGE_NOT_FOUND; // XXX return rv?
 
   PRUint32 flags;
   (void)msgHdr->GetFlags(&flags);
-  *pSent = flags & MSG_FLAG_MDN_REPORT_SENT;
+  *pSent = flags & nsMsgMessageFlags::MDNReportSent;
   return rv;
 }
 
 
 nsresult  nsMsgDatabase::SetKeyFlag(nsMsgKey key, PRBool set, PRUint32 flag,
                                      nsIDBChangeListener *instigator)
 {
   nsresult rv;
@@ -2281,17 +2281,17 @@ nsresult nsMsgDatabase::SetMsgHdrFlag(ns
   if (oldFlags == flags)
     return NS_OK;
 
   return NotifyHdrChangeAll(msgHdr, oldFlags, flags, instigator);
 }
 
 // Helper routine - lowest level of flag setting - returns PR_TRUE if flags change,
 // PR_FALSE otherwise.
-PRBool nsMsgDatabase::SetHdrFlag(nsIMsgDBHdr *msgHdr, PRBool bSet, MsgFlags flag)
+PRBool nsMsgDatabase::SetHdrFlag(nsIMsgDBHdr *msgHdr, PRBool bSet, nsMsgMessageFlagType flag)
 {
   PRUint32 statusFlags;
   (void)msgHdr->GetFlags(&statusFlags);
   PRUint32 currentStatusFlags = GetStatusFlags(msgHdr, statusFlags);
   PRBool flagAlreadySet = (currentStatusFlags & flag) != 0;
 
   if ((flagAlreadySet && !bSet) || (!flagAlreadySet && bSet))
   {
@@ -2343,24 +2343,24 @@ NS_IMETHODIMP nsMsgDatabase::MarkHdrRead
     return MarkHdrReadInDB(msgHdr, bRead, instigator);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgDatabase::MarkHdrReplied(nsIMsgDBHdr *msgHdr, PRBool bReplied,
                          nsIDBChangeListener *instigator)
 {
-  return SetMsgHdrFlag(msgHdr, bReplied, MSG_FLAG_REPLIED, instigator);
+  return SetMsgHdrFlag(msgHdr, bReplied, nsMsgMessageFlags::Replied, instigator);
 }
 
 
 NS_IMETHODIMP nsMsgDatabase::MarkHdrMarked(nsIMsgDBHdr *msgHdr, PRBool mark,
                          nsIDBChangeListener *instigator)
 {
-  return SetMsgHdrFlag(msgHdr, mark, MSG_FLAG_MARKED, instigator);
+  return SetMsgHdrFlag(msgHdr, mark, nsMsgMessageFlags::Marked, instigator);
 }
 
 
 NS_IMETHODIMP nsMsgDatabase::MarkAllRead(nsTArray<nsMsgKey> *thoseMarked)
 {
   nsresult    rv;
   nsMsgHdr  *pHeader;
 
@@ -2475,18 +2475,18 @@ NS_IMETHODIMP nsMsgDatabase::ClearNewLis
       nsMsgKey lastNewKey = saveNewSet.ElementAt(elementIndex);
       nsCOMPtr <nsIMsgDBHdr> msgHdr;
       err = GetMsgHdrForKey(lastNewKey, getter_AddRefs(msgHdr));
       if (NS_SUCCEEDED(err))
       {
         PRUint32 flags;
         (void)msgHdr->GetFlags(&flags);
 
-        if ((flags | MSG_FLAG_NEW) != flags)
-          NotifyHdrChangeAll(msgHdr, flags | MSG_FLAG_NEW, flags, nsnull);
+        if ((flags | nsMsgMessageFlags::New) != flags)
+          NotifyHdrChangeAll(msgHdr, flags | nsMsgMessageFlags::New, flags, nsnull);
       }
       if (elementIndex == 0)
         break;
     }
   }
   return err;
 }
 
@@ -2633,17 +2633,17 @@ nsresult nsMsgDBEnumerator::PrefetchNext
     if (NS_FAILED(rv))
       return rv;
 
     if (mResultHdr)
       mResultHdr->GetFlags(&flags);
     else
       flags = 0;
   }
-  while (mFilter && NS_FAILED(mFilter(mResultHdr, mClosure)) && !(flags & MSG_FLAG_EXPUNGED));
+  while (mFilter && NS_FAILED(mFilter(mResultHdr, mClosure)) && !(flags & nsMsgMessageFlags::Expunged));
 
   if (mResultHdr)
   {
     mNextPrefetched = PR_TRUE;
     return NS_OK;
   }
   return NS_ERROR_FAILURE;
 }
@@ -3013,20 +3013,20 @@ NS_IMETHODIMP nsMsgDatabase::AddNewHdrTo
     nsMsgKey key;
     PRUint32 flags;
 
     newHdr->GetMessageKey(&key);
     hdr->GetRawFlags(&flags);
     // use raw flags instead of GetFlags, because GetFlags will
     // pay attention to what's in m_newSet, and this new hdr isn't
     // in m_newSet yet.
-    if (flags & MSG_FLAG_NEW)
+    if (flags & nsMsgMessageFlags::New)
     {
       PRUint32 newFlags;
-      newHdr->AndFlags(~MSG_FLAG_NEW, &newFlags);  // make sure not filed out
+      newHdr->AndFlags(~nsMsgMessageFlags::New, &newFlags);  // make sure not filed out
       AddToNewList(key);
     }
     if (m_dbFolderInfo != NULL)
     {
       m_dbFolderInfo->ChangeNumMessages(1);
       PRBool isRead = PR_TRUE;
       IsHeaderRead(newHdr, &isRead);
       if (!isRead)
@@ -3972,17 +3972,17 @@ nsresult nsMsgDatabase::ThreadNewHdr(nsM
     }
   }
   // if user hasn't said "only thread by ref headers", thread by subject
   if (!thread && !UseStrictThreading())
   {
     // try subject threading if we couldn't find a reference and the subject starts with Re:
     nsCString subject;
     newHdr->GetSubject(getter_Copies(subject));
-    if (ThreadBySubjectWithoutRe() || (newHdrFlags & MSG_FLAG_HAS_RE))
+    if (ThreadBySubjectWithoutRe() || (newHdrFlags & nsMsgMessageFlags::HasRe))
     {
       nsCAutoString cSubject(subject);
       thread = getter_AddRefs(GetThreadForSubject(cSubject));
       if(thread)
       {
         thread->GetThreadKey(&threadId);
         newHdr->SetThreadId(threadId);
         //TRACE("threading based on subject %s\n", (const char *) msgHdr->m_subject);
@@ -4280,17 +4280,17 @@ NS_IMETHODIMP  nsMsgDatabase::RemoveOffl
   NS_ASSERTION(PR_FALSE, "overridden by nsMailDatabase");
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 
 NS_IMETHODIMP nsMsgDatabase::ListAllOfflineMsgs(nsTArray<nsMsgKey> *outputKeys)
 {
   nsCOMPtr <nsISimpleEnumerator> enumerator;
-  PRUint32 flag = MSG_FLAG_OFFLINE;
+  PRUint32 flag = nsMsgMessageFlags::Offline;
   // if we change this routine to return an enumerator that generates the keys
   // one by one, we'll need to somehow make a copy of flag for the enumerator
   // to own, since the enumerator will persist past the life of flag on the stack.
   nsresult rv = EnumerateMessagesWithFlag(getter_AddRefs(enumerator), &flag);
   if (NS_SUCCEEDED(rv) && enumerator)
   {
     PRBool hasMoreElements;
     while(NS_SUCCEEDED(enumerator->HasMoreElements(&hasMoreElements)) && hasMoreElements)
@@ -4703,17 +4703,17 @@ nsresult nsMsgDatabase::PurgeMessagesOld
     NS_ASSERTION(NS_SUCCEEDED(rv), "nsMsgDBEnumerator broken");
     if (NS_FAILED(rv))
       break;
 
     if (!applyToFlaggedMessages)
     {
       PRUint32 flags;
       (void)pHeader->GetFlags(&flags);
-      if (flags & MSG_FLAG_MARKED)
+      if (flags & nsMsgMessageFlags::Marked)
         continue;
     }
 
     if (keepUnreadMessagesOnly)
     {
       PRBool isRead;
       IsHeaderRead(pHeader, &isRead);
       if (isRead)
@@ -4777,17 +4777,17 @@ nsresult nsMsgDatabase::PurgeExcessMessa
     NS_ASSERTION(NS_SUCCEEDED(rv), "nsMsgDBEnumerator broken");
     if (NS_FAILED(rv))
       break;
 
     if (!applyToFlaggedMessages)
     {
       PRUint32 flags;
       (void)pHeader->GetFlags(&flags);
-      if (flags & MSG_FLAG_MARKED)
+      if (flags & nsMsgMessageFlags::Marked)
         continue;
     }
 
     if (keepUnreadMessagesOnly)
     {
       PRBool isRead;
       IsHeaderRead(pHeader, &isRead);
       if (isRead)
--- a/mailnews/db/msgdb/src/nsMsgHdr.cpp
+++ b/mailnews/db/msgdb/src/nsMsgHdr.cpp
@@ -119,17 +119,17 @@ nsresult nsMsgHdr::InitFlags()
   nsresult err = NS_OK;
 
   if (!m_mdb)
     return NS_ERROR_NULL_POINTER;
 
   if(!(m_initedValues & FLAGS_INITED))
   {
     err = GetUInt32Column(m_mdb->m_flagsColumnToken, &m_flags);
-    m_flags &= ~MSG_FLAG_NEW; // don't get new flag from MDB
+    m_flags &= ~nsMsgMessageFlags::New; // don't get new flag from MDB
 
     if(NS_SUCCEEDED(err))
       m_initedValues |= FLAGS_INITED;
   }
 
   return err;
 
 }
@@ -198,30 +198,30 @@ NS_IMETHODIMP nsMsgHdr::GetFlags(PRUint3
 {
   if (!(m_initedValues & FLAGS_INITED))
     InitFlags();
   if (m_mdb)
     *result = m_mdb->GetStatusFlags(this, m_flags);
   else
     *result = m_flags;
 #ifdef DEBUG_bienvenu
-  NS_ASSERTION(! (*result & (MSG_FLAG_ELIDED)), "shouldn't be set in db");
+  NS_ASSERTION(! (*result & (nsMsgMessageFlags::Elided)), "shouldn't be set in db");
 #endif
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgHdr::SetFlags(PRUint32 flags)
 {
 #ifdef DEBUG_bienvenu
-  NS_ASSERTION(! (flags & (MSG_FLAG_ELIDED)), "shouldn't set this flag on db");
+  NS_ASSERTION(! (flags & (nsMsgMessageFlags::Elided)), "shouldn't set this flag on db");
 #endif
   m_initedValues |= FLAGS_INITED;
   m_flags = flags;
-  // don't write out MSG_FLAG_NEW to MDB.
-  return SetUInt32Column(m_flags & ~MSG_FLAG_NEW, m_mdb->m_flagsColumnToken);
+  // don't write out nsMsgMessageFlags::New to MDB.
+  return SetUInt32Column(m_flags & ~nsMsgMessageFlags::New, m_mdb->m_flagsColumnToken);
 }
 
 NS_IMETHODIMP nsMsgHdr::OrFlags(PRUint32 flags, PRUint32 *result)
 {
   if (!(m_initedValues & FLAGS_INITED))
     InitFlags();
   if ((m_flags & flags) != flags)
     SetFlags (m_flags | flags);
@@ -603,17 +603,17 @@ NS_IMETHODIMP nsMsgHdr::GetAccountKey(ch
 NS_IMETHODIMP nsMsgHdr::GetMessageOffset(PRUint32 *result)
 {
   NS_ENSURE_ARG(result);
 
   // if we have the message body offline, then return the message offset column
   // (this will only be true for news and imap messages).
   PRUint32 rawFlags;
   GetRawFlags(&rawFlags);
-  if (rawFlags & MSG_FLAG_OFFLINE)
+  if (rawFlags & nsMsgMessageFlags::Offline)
   {
     return GetUInt32Column(m_mdb->m_offlineMsgOffsetColumnToken, result);
   }
   else
   {
     *result = m_messageKey;
     return NS_OK;
   }
@@ -915,26 +915,26 @@ PRBool nsMsgHdr::IsAncestorOf(nsIMsgDBHd
   return (strstr(references, messageId.get()) != nsnull);
 }
 
 NS_IMETHODIMP nsMsgHdr::GetIsRead(PRBool *isRead)
 {
   NS_ENSURE_ARG_POINTER(isRead);
   if (!(m_initedValues & FLAGS_INITED))
     InitFlags();
-  *isRead = m_flags & MSG_FLAG_READ;
+  *isRead = m_flags & nsMsgMessageFlags::Read;
   return NS_OK;
 }
 
 NS_IMETHODIMP nsMsgHdr::GetIsFlagged(PRBool *isFlagged)
 {
   NS_ENSURE_ARG_POINTER(isFlagged);
   if (!(m_initedValues & FLAGS_INITED))
     InitFlags();
-  *isFlagged = m_flags & MSG_FLAG_MARKED;
+  *isFlagged = m_flags & nsMsgMessageFlags::Marked;
   return NS_OK;
 }
 
 void nsMsgHdr::ReparentInThread(nsIMsgThread *thread)
 {
   NS_WARNING("Borked message header, attempting to fix!");
   PRUint32 numChildren;
   thread->GetNumChildren(&numChildren);
@@ -976,17 +976,17 @@ void nsMsgHdr::ReparentInThread(nsIMsgTh
     }
   }
 }
 
 PRBool nsMsgHdr::IsAncestorKilled(PRUint32 ancestorsToCheck)
 {
   if (!(m_initedValues & FLAGS_INITED))
     InitFlags();
-  PRBool isKilled = m_flags & MSG_FLAG_IGNORED;
+  PRBool isKilled = m_flags & nsMsgMessageFlags::Ignored;
 
   if (!isKilled)
   {
     nsMsgKey threadParent;
     GetThreadParent(&threadParent);
 
     if (threadParent == m_messageKey)
     {
--- a/mailnews/db/msgdb/src/nsMsgThread.cpp
+++ b/mailnews/db/msgdb/src/nsMsgThread.cpp
@@ -231,20 +231,20 @@ NS_IMETHODIMP nsMsgThread::AddChild(nsIM
 
   nsIMdbRow *hdrRow = hdr->GetMDBRow();
   hdr->GetRawFlags(&newHdrFlags);
   hdr->GetMessageKey(&newHdrKey);
   hdr->GetDateInSeconds(&msgDate);
   if (msgDate > m_newestMsgDate)
     SetNewestMsgDate(msgDate);
 
-  if (newHdrFlags & MSG_FLAG_WATCHED)
-    SetFlags(m_flags | MSG_FLAG_WATCHED);
+  if (newHdrFlags & nsMsgMessageFlags::Watched)
+    SetFlags(m_flags | nsMsgMessageFlags::Watched);
 
-  child->AndFlags(~(MSG_FLAG_WATCHED), &newHdrFlags);
+  child->AndFlags(~(nsMsgMessageFlags::Watched), &newHdrFlags);
   
   // These are threading flags that the child may have set before being added
   // to the database.
   PRUint32 protoThreadFlags;
   child->GetUint32Property("ProtoThreadFlags", &protoThreadFlags);
   SetFlags(m_flags | protoThreadFlags);
   // Clear the flag so that it doesn't fudge anywhere else
   child->SetUint32Property("ProtoThreadFlags", 0);
@@ -258,17 +258,17 @@ NS_IMETHODIMP nsMsgThread::AddChild(nsIM
   // if this is an empty thread, set the root key to this header's key
   if (numChildren == 0)
     SetThreadRootKey(newHdrKey);
 
   if (m_mdbTable)
   {
     m_mdbTable->AddRow(m_mdbDB->GetEnv(), hdrRow);
     ChangeChildCount(1);
-    if (! (newHdrFlags & MSG_FLAG_READ))
+    if (! (newHdrFlags & nsMsgMessageFlags::Read))
       ChangeUnreadChildCount(1);
   }
   if (inReplyTo)
   {
     nsMsgKey parentKey;
     inReplyTo->GetMessageKey(&parentKey);
     child->SetThreadParent(parentKey);
     parentKeyNeedsSetting = PR_FALSE;
@@ -354,17 +354,17 @@ NS_IMETHODIMP nsMsgThread::AddChild(nsIM
         }
       }
     }
   }
   // If this header is not a reply to a header in the thread, and isn't a parent
   // check to see if it starts with Re: - if not, and the first header does start
   // with re, should we make this header the top level header?
   // If it's date is less (or it's ID?), then yes.
-  if (numChildren > 0 && !(newHdrFlags & MSG_FLAG_HAS_RE) && !inReplyTo)
+  if (numChildren > 0 && !(newHdrFlags & nsMsgMessageFlags::HasRe) && !inReplyTo)
   {
     PRTime topLevelHdrDate;
 
     nsCOMPtr <nsIMsgDBHdr> topLevelHdr;
     rv = GetRootHdr(nsnull, getter_AddRefs(topLevelHdr));
     if (NS_SUCCEEDED(rv) && topLevelHdr)
     {
       topLevelHdr->GetDate(&topLevelHdrDate);
@@ -397,17 +397,17 @@ NS_IMETHODIMP nsMsgThread::AddChild(nsIM
   {
     mdb_pos outPos;
     m_mdbTable->MoveRow(m_mdbDB->GetEnv(), hdrRow, -1, moveIndex, &outPos);
   }
 
   // do this after we've put the new hdr in the thread
   PRBool isKilled;
   child->GetIsKilled(&isKilled);
-  if ((m_flags & MSG_FLAG_IGNORED || isKilled) && m_mdbDB)
+  if ((m_flags & nsMsgMessageFlags::Ignored || isKilled) && m_mdbDB)
     m_mdbDB->MarkHdrRead(child, PR_TRUE, nsnull);
 
 #ifdef DEBUG_bienvenu1
   nsMsgDatabase *msgDB = static_cast<nsMsgDatabase*>(m_mdbDB);
   msgDB->DumpThread(m_threadRootKey);
 #endif
   return rv;
 }
@@ -585,17 +585,17 @@ NS_IMETHODIMP nsMsgThread::RemoveChildHd
   ReparentChildrenOf(key, threadParent, announcer);
 
   // if this was the newest msg, clear the newest msg date so we'll recalc.
   PRUint32 date;
   child->GetDateInSeconds(&date);
   if (date == m_newestMsgDate)
     SetNewestMsgDate(0);
 
- if (!(flags & MSG_FLAG_READ))
+ if (!(flags & nsMsgMessageFlags::Read))
     ChangeUnreadChildCount(-1);
   ChangeChildCount(-1);
   return RemoveChild(key);
 }
 
 nsresult nsMsgThread::ReparentChildrenOf(nsMsgKey oldParent, nsMsgKey newParent, nsIDBChangeAnnouncer *announcer)
 {
   nsresult rv = NS_OK;
--- a/mailnews/db/msgdb/src/nsNewsDatabase.cpp
+++ b/mailnews/db/msgdb/src/nsNewsDatabase.cpp
@@ -339,17 +339,17 @@ nsresult nsNewsDatabase::SyncWithReadSet
 
   return rv;
 }
 
 nsresult nsNewsDatabase::AdjustExpungedBytesOnDelete(nsIMsgDBHdr *msgHdr)
 {
   PRUint32 msgFlags;
   msgHdr->GetFlags(&msgFlags);
-  if (msgFlags & MSG_FLAG_OFFLINE && m_dbFolderInfo)
+  if (msgFlags & nsMsgMessageFlags::Offline && m_dbFolderInfo)
   {
     PRUint32 size = 0;
     (void)msgHdr->GetOfflineMessageSize(&size);
     return m_dbFolderInfo->ChangeExpungedBytes (size);
   }
   return NS_OK;
 }
 
--- a/mailnews/imap/src/nsAutoSyncManager.cpp
+++ b/mailnews/imap/src/nsAutoSyncManager.cpp
@@ -1046,17 +1046,17 @@ NS_IMETHODIMP
 nsAutoSyncManager::DoesMsgFitDownloadCriteria(nsIMsgDBHdr *aMsgHdr, PRBool *aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
   
   PRUint32 msgFlags = 0;
   aMsgHdr->GetFlags(&msgFlags);
   
   // check whether this message is marked imap deleted or not 
-  *aResult = !(msgFlags & MSG_FLAG_IMAP_DELETED);
+  *aResult = !(msgFlags & nsMsgMessageFlags::IMAPDeleted);
   if (!(*aResult))
     return NS_OK;
     
   PRBool shouldStoreMsgOffline = PR_TRUE;
   nsCOMPtr<nsIMsgFolder> folder;
   aMsgHdr->GetFolder(getter_AddRefs(folder));
   if (folder)
   {
--- a/mailnews/imap/src/nsAutoSyncState.cpp
+++ b/mailnews/imap/src/nsAutoSyncState.cpp
@@ -270,17 +270,17 @@ NS_IMETHODIMP nsAutoSyncState::GetNextGr
         if(!qhdr)
           continue; //maybe deleted, skip it!
         
         // ensure that we don't have this message body offline already,
         // possible if the user explicitly selects this message prior
         // to auto-sync kicks in
         PRUint32 msgFlags = 0;
         qhdr->GetFlags(&msgFlags);
-        if ( msgFlags & MSG_FLAG_OFFLINE )
+        if (msgFlags & nsMsgMessageFlags::Offline)
           continue;
           
         // this check point allows msg strategy function
         // to do last minute decisions based on the current
         // state of TB such as the size of the message store etc..
         if (msgStrategy)
         {
           PRBool excluded = PR_FALSE;
@@ -361,17 +361,17 @@ NS_IMETHODIMP nsAutoSyncState::ProcessEx
   {
     nsCOMPtr<nsIMsgDBHdr> hdr;
     rv = database->GetMsgHdrForKey(mExistingHeadersQ[mProcessPointer], getter_AddRefs(hdr));
     if (hdr)
     {
       PRUint32 msgFlags = 0;
       hdr->GetFlags(&msgFlags);
       
-      if (!(msgFlags & MSG_FLAG_OFFLINE))
+      if (!(msgFlags & nsMsgMessageFlags::Offline))
         msgKeys.AppendElement(mExistingHeadersQ[mProcessPointer]);
     }
   }
   
   #if defined(DEBUG_me) && defined(DEBUG_AutoSyncState_L1)
   nsCString folderName;
   folder->GetURI(folderName);
   printf("%d messages will be added into the download q of folder %s\n", msgKeys.Length(), folderName.get());
--- a/mailnews/imap/src/nsImapMailFolder.cpp
+++ b/mailnews/imap/src/nsImapMailFolder.cpp
@@ -2128,17 +2128,17 @@ NS_IMETHODIMP nsImapMailFolder::DeleteMe
       NS_ENSURE_SUCCESS(rv, rv);
       deleteMsgs = PR_FALSE;
       for (PRUint32 i=0; i <cnt; i++)
       {
         nsCOMPtr <nsIMsgDBHdr> msgHdr = do_QueryElementAt(messages, i);
         if (msgHdr)
         {
           msgHdr->GetFlags(&flags);
-          if (!(flags & MSG_FLAG_IMAP_DELETED))
+          if (!(flags & nsMsgMessageFlags::IMAPDeleted))
           {
             deleteMsgs = PR_TRUE;
             break;
           }
         }
       }
     }
     // if copy service listener is also a url listener, pass that
@@ -2849,17 +2849,17 @@ nsresult nsImapMailFolder::NormalEndHead
   if (NS_SUCCEEDED(newMsgHdr->GetMessageSize(&messageSize)))
     mFolderSize += messageSize;
   m_msgMovedByFilter = PR_FALSE;
   // If this is the inbox, try to apply filters.
   if (mFlags & nsMsgFolderFlags::Inbox)
   {
     PRUint32 msgFlags;
     newMsgHdr->GetFlags(&msgFlags);
-    if (!(msgFlags & (MSG_FLAG_READ | MSG_FLAG_IMAP_DELETED))) // only fire on unread msgs that haven't been deleted
+    if (!(msgFlags & (nsMsgMessageFlags::Read | nsMsgMessageFlags::IMAPDeleted))) // only fire on unread msgs that haven't been deleted
     {
       PRInt32 duplicateAction = nsIMsgIncomingServer::keepDups;
       if (server)
         server->GetIncomingDuplicateAction(&duplicateAction);
       if (duplicateAction != nsIMsgIncomingServer::keepDups)
       {
         PRBool isDup;
         server->IsNewHdrDuplicate(newMsgHdr, &isDup);
@@ -2868,17 +2868,17 @@ nsresult nsImapMailFolder::NormalEndHead
           // we want to do something similar to applying filter hits.
           // if a dup is marked read, it shouldn't trigger biff.
           // Same for deleting it or moving it to trash.
           switch (duplicateAction)
           {
             case nsIMsgIncomingServer::deleteDups:
               {
                 PRUint32 newFlags;
-                newMsgHdr->OrFlags(MSG_FLAG_READ | MSG_FLAG_IMAP_DELETED, &newFlags);
+                newMsgHdr->OrFlags(nsMsgMessageFlags::Read | nsMsgMessageFlags::IMAPDeleted, &newFlags);
                 StoreImapFlags(kImapMsgSeenFlag | kImapMsgDeletedFlag, PR_TRUE,
                                &m_curMsgUid, 1, nsnull);
                 m_msgMovedByFilter = PR_TRUE;
               }
               break;
             case nsIMsgIncomingServer::moveDupsToTrash:
               {
                 nsCOMPtr <nsIMsgFolder> trash;
@@ -2891,17 +2891,17 @@ nsresult nsImapMailFolder::NormalEndHead
                   if (NS_SUCCEEDED(err))
                     m_msgMovedByFilter = PR_TRUE;
                 }
               }
               break;
             case nsIMsgIncomingServer::markDupsRead:
               {
                 PRUint32 newFlags;
-                newMsgHdr->OrFlags(MSG_FLAG_READ, &newFlags);
+                newMsgHdr->OrFlags(nsMsgMessageFlags::Read, &newFlags);
                 StoreImapFlags(kImapMsgSeenFlag, PR_TRUE, &m_curMsgUid, 1, nsnull);
               }
               break;
           }
           PRInt32 numNewMessages;
           GetNumNewMessages(PR_FALSE, &numNewMessages);
           SetNumNewMessages(numNewMessages - 1);
         }
@@ -3169,33 +3169,33 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFil
       }
 
       PRUint32 msgFlags;
       nsMsgKey    msgKey;
       nsCAutoString trashNameVal;
 
       msgHdr->GetFlags(&msgFlags);
       msgHdr->GetMessageKey(&msgKey);
-      PRBool isRead = (msgFlags & MSG_FLAG_READ);
+      PRBool isRead = (msgFlags & nsMsgMessageFlags::Read);
       switch (actionType)
       {
         case nsMsgFilterAction::Delete:
         {
           if (deleteToTrash)
           {
             // set value to trash folder
             nsCOMPtr <nsIMsgFolder> mailTrash;
             rv = GetTrashFolder(getter_AddRefs(mailTrash));
             if (NS_SUCCEEDED(rv) && mailTrash)
               rv = mailTrash->GetURI(actionTargetFolderUri);
-            // msgHdr->OrFlags(MSG_FLAG_READ, &newFlags);  // mark read in trash.
+            // msgHdr->OrFlags(nsMsgMessageFlags::Read, &newFlags);  // mark read in trash.
           }
           else  // (!deleteToTrash)
           {
-            msgHdr->OrFlags(MSG_FLAG_READ | MSG_FLAG_IMAP_DELETED, &newFlags);
+            msgHdr->OrFlags(nsMsgMessageFlags::Read | nsMsgMessageFlags::IMAPDeleted, &newFlags);
             StoreImapFlags(kImapMsgSeenFlag | kImapMsgDeletedFlag, PR_TRUE,
                            &msgKey, 1, nsnull);
             m_msgMovedByFilter = PR_TRUE; // this will prevent us from adding the header to the db.
           }
           msgIsNew = PR_FALSE;
         }
         // note that delete falls through to move.
         case nsMsgFilterAction::MoveToFolder:
@@ -3203,20 +3203,20 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFil
           // if moving to a different file, do it.
           nsCString uri;
           rv = GetURI(uri);
 
           if (!actionTargetFolderUri.Equals(uri))
           {
             msgHdr->GetFlags(&msgFlags);
 
-            if (msgFlags & MSG_FLAG_MDN_REPORT_NEEDED && !isRead)
+            if (msgFlags & nsMsgMessageFlags::MDNReportNeeded && !isRead)
             {
-               msgHdr->SetFlags(msgFlags & ~MSG_FLAG_MDN_REPORT_NEEDED);
-               msgHdr->OrFlags(MSG_FLAG_MDN_REPORT_SENT, &newFlags);
+               msgHdr->SetFlags(msgFlags & ~nsMsgMessageFlags::MDNReportNeeded);
+               msgHdr->OrFlags(nsMsgMessageFlags::MDNReportSent, &newFlags);
             }
             nsresult err = MoveIncorporatedMessage(msgHdr, mDatabase, actionTargetFolderUri, filter, msgWindow);
             if (NS_SUCCEEDED(err))
               m_msgMovedByFilter = PR_TRUE;
           }
           // don't apply any more filters, even if it was a move to the same folder
           *applyMore = PR_FALSE; 
         }
@@ -3227,20 +3227,20 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFil
           rv = GetURI(uri);
 
           if (!actionTargetFolderUri.Equals(uri))
           {
             // XXXshaver I'm not actually 100% what the right semantics are for
             // MDNs and copied messages, but I suspect deep down inside that
             // we probably want to suppress them only on the copies.
             msgHdr->GetFlags(&msgFlags);
-            if (msgFlags & MSG_FLAG_MDN_REPORT_NEEDED && !isRead)
+            if (msgFlags & nsMsgMessageFlags::MDNReportNeeded && !isRead)
             {
-               msgHdr->SetFlags(msgFlags & ~MSG_FLAG_MDN_REPORT_NEEDED);
-               msgHdr->OrFlags(MSG_FLAG_MDN_REPORT_SENT, &newFlags);
+               msgHdr->SetFlags(msgFlags & ~nsMsgMessageFlags::MDNReportNeeded);
+               msgHdr->OrFlags(nsMsgMessageFlags::MDNReportSent, &newFlags);
             }
 
             nsCOMPtr<nsIMutableArray> messageArray(do_CreateInstance(NS_ARRAY_CONTRACTID, &rv));
             NS_ENSURE_TRUE(messageArray, rv);
             messageArray->AppendElement(msgHdr, PR_FALSE);
 
             nsCOMPtr<nsIMsgFolder> dstFolder;
             rv = GetExistingFolder(actionTargetFolderUri, getter_AddRefs(dstFolder));
@@ -3264,23 +3264,23 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFil
         break;
         case nsMsgFilterAction::MarkFlagged:
         {
           mDatabase->MarkHdrMarked(msgHdr, PR_TRUE, nsnull);
           StoreImapFlags(kImapMsgFlaggedFlag, PR_TRUE, &msgKey, 1, nsnull);
         }
         break;
         case nsMsgFilterAction::KillThread:
-          msgHdr->SetUint32Property("ProtoThreadFlags", MSG_FLAG_IGNORED);
+          msgHdr->SetUint32Property("ProtoThreadFlags", nsMsgMessageFlags::Ignored);
           break;
         case nsMsgFilterAction::KillSubthread:
-          msgHdr->OrFlags(MSG_FLAG_IGNORED, &newFlags);
+          msgHdr->OrFlags(nsMsgMessageFlags::Ignored, &newFlags);
           break;
         case nsMsgFilterAction::WatchThread:
-          msgHdr->OrFlags(MSG_FLAG_WATCHED, &newFlags);
+          msgHdr->OrFlags(nsMsgMessageFlags::Watched, &newFlags);
         break;
         case nsMsgFilterAction::ChangePriority:
         {
           nsMsgPriorityValue filterPriority;
           filterAction->GetPriority(&filterPriority);
           msgHdr->SetPriority(filterPriority);
         }
         break;
@@ -3870,58 +3870,60 @@ void nsImapMailFolder::TweakHeaderFlags(
     PRBool foundIt = PR_FALSE;
     imapMessageFlagsType imap_flags;
 
     nsCString customFlags;
     nsresult rv = aProtocol->GetFlagsForUID(m_curMsgUid, &foundIt, &imap_flags, getter_Copies(customFlags));
     if (NS_SUCCEEDED(rv) && foundIt)
     {
       // make a mask and clear these message flags
-      PRUint32 mask = MSG_FLAG_READ | MSG_FLAG_REPLIED | MSG_FLAG_MARKED | MSG_FLAG_IMAP_DELETED | MSG_FLAG_LABELS;
+      PRUint32 mask = nsMsgMessageFlags::Read | nsMsgMessageFlags::Replied |
+                      nsMsgMessageFlags::Marked | nsMsgMessageFlags::IMAPDeleted |
+                      nsMsgMessageFlags::Labels;
       PRUint32 dbHdrFlags;
 
       tweakMe->GetFlags(&dbHdrFlags);
       tweakMe->AndFlags(~mask, &dbHdrFlags);
 
       // set the new value for these flags
       PRUint32 newFlags = 0;
       if (imap_flags & kImapMsgSeenFlag)
-        newFlags |= MSG_FLAG_READ;
+        newFlags |= nsMsgMessageFlags::Read;
       else // if (imap_flags & kImapMsgRecentFlag)
-        newFlags |= MSG_FLAG_NEW;
+        newFlags |= nsMsgMessageFlags::New;
 
       // Okay here is the MDN needed logic (if DNT header seen):
       /* if server support user defined flag:
                     MDNSent flag set => clear kMDNNeeded flag
                     MDNSent flag not set => do nothing, leave kMDNNeeded on
                     else if
-                    not MSG_FLAG_NEW => clear kMDNNeeded flag
-                   MSG_FLAG_NEW => do nothing, leave kMDNNeeded on
+                    not nsMsgMessageFlags::New => clear kMDNNeeded flag
+                   nsMsgMessageFlags::New => do nothing, leave kMDNNeeded on
                */
       PRUint16 userFlags;
       rv = aProtocol->GetSupportedUserFlags(&userFlags);
       if (NS_SUCCEEDED(rv) && (userFlags & (kImapMsgSupportUserFlag |
                             kImapMsgSupportMDNSentFlag)))
       {
         if (imap_flags & kImapMsgMDNSentFlag)
         {
-          newFlags |= MSG_FLAG_MDN_REPORT_SENT;
-          if (dbHdrFlags & MSG_FLAG_MDN_REPORT_NEEDED)
-            tweakMe->AndFlags(~MSG_FLAG_MDN_REPORT_NEEDED, &dbHdrFlags);
+          newFlags |= nsMsgMessageFlags::MDNReportSent;
+          if (dbHdrFlags & nsMsgMessageFlags::MDNReportNeeded)
+            tweakMe->AndFlags(~nsMsgMessageFlags::MDNReportNeeded, &dbHdrFlags);
         }
       }
 
       if (imap_flags & kImapMsgAnsweredFlag)
-        newFlags |= MSG_FLAG_REPLIED;
+        newFlags |= nsMsgMessageFlags::Replied;
       if (imap_flags & kImapMsgFlaggedFlag)
-        newFlags |= MSG_FLAG_MARKED;
+        newFlags |= nsMsgMessageFlags::Marked;
       if (imap_flags & kImapMsgDeletedFlag)
-        newFlags |= MSG_FLAG_IMAP_DELETED;
+        newFlags |= nsMsgMessageFlags::IMAPDeleted;
       if (imap_flags & kImapMsgForwardedFlag)
-        newFlags |= MSG_FLAG_FORWARDED;
+        newFlags |= nsMsgMessageFlags::Forwarded;
 
       // db label flags are 0x0E000000 and imap label flags are 0x0E00
       // so we need to shift 16 bits to the left to convert them.
       if (imap_flags & kImapMsgLabelFlags)
       {
         // we need to set label attribute on header because the dbview code
         // does msgHdr->GetLabel when asked to paint a row
         tweakMe->SetLabel((imap_flags & kImapMsgLabelFlags) >> 9);
@@ -4185,17 +4187,17 @@ nsresult nsImapMailFolder::HandleCustomF
     nsCAutoString msgJunkScore;
     msgJunkScore.AppendInt(nsIJunkMailPlugin::IS_HAM_SCORE);
     mDatabase->SetStringProperty(uidOfMessage, "junkscore", msgJunkScore.get());
   }
   // ### TODO: we really should parse the keywords into space delimited keywords before checking
   else if (keywords.Find("Junk", PR_TRUE /* ignore case */) != -1)
   {
     PRUint32 newFlags;
-    dbHdr->AndFlags(~MSG_FLAG_NEW, &newFlags);
+    dbHdr->AndFlags(~nsMsgMessageFlags::New, &newFlags);
     nsCAutoString msgJunkScore;
     msgJunkScore.AppendInt(nsIJunkMailPlugin::IS_SPAM_SCORE);
     mDatabase->SetStringProperty(uidOfMessage, "junkscore", msgJunkScore.get());
   }
   else
     messageClassified = PR_FALSE;
   if (messageClassified)
   {
@@ -4387,17 +4389,17 @@ nsresult nsImapMailFolder::GetTrashFolde
     rv = rootFolder->GetFolderWithFlags(nsMsgFolderFlags::Trash, pTrashFolder);
     if (!*pTrashFolder)
       rv = NS_ERROR_FAILURE;
   }
   return rv;
 }
 
 
-// store MSG_FLAG_IMAP_DELETED in the specified mailhdr records
+// store nsMsgMessageFlags::IMAPDeleted in the specified mailhdr records
 void nsImapMailFolder::SetIMAPDeletedFlag(nsIMsgDatabase *mailDB, const nsTArray<nsMsgKey> &msgids, PRBool markDeleted)
 {
   nsresult markStatus = 0;
   PRUint32 total = msgids.Length();
 
   for (PRUint32 msgIndex=0; !markStatus && (msgIndex < total); msgIndex++)
     markStatus = mailDB->MarkImapDeleted(msgids[msgIndex], markDeleted, nsnull);
 }
@@ -6220,17 +6222,17 @@ nsresult nsImapMailFolder::CopyOfflineMs
         PR_FREEIF(inputBuffer);
         outputStream->Flush();
       }
     }
   }
   if (NS_SUCCEEDED(rv))
   {
     PRUint32 resultFlags;
-    destHdr->OrFlags(MSG_FLAG_OFFLINE, &resultFlags);
+    destHdr->OrFlags(nsMsgMessageFlags::Offline, &resultFlags);
     destHdr->SetOfflineMessageSize(messageSize);
   }
   return rv;
 }
 
 // this imap folder is the destination of an offline move/copy.
 // We are either offline, or doing a pseudo-offline delete (where we do an offline
 // delete, load the next message, then playback the offline delete).
@@ -6344,17 +6346,17 @@ nsresult nsImapMailFolder::CopyMessagesO
               PRUint32 msgFlags;
               imapMessageFlagsType newImapFlags = 0;
               message->GetMessageSize(&msgSize);
               message->GetFlags(&msgFlags);
               sourceOp->SetDestinationFolderURI(folderURI.get()); // offline move
               sourceOp->SetOperation(nsIMsgOfflineImapOperation::kMsgMoved);
               sourceOp->SetMsgSize(msgSize);
               newImapFlags = msgFlags & 0x7;
-              if (msgFlags & MSG_FLAG_FORWARDED)
+              if (msgFlags & nsMsgMessageFlags::Forwarded)
                 newImapFlags |=  kImapMsgForwardedFlag;
               sourceOp->SetNewFlags(newImapFlags);
             }
             else
               sourceOp->AddMessageCopyOperation(folderURI.get()); // offline copy
 
             nsTArray<nsMsgKey> srcKeyArray;
             nsCOMPtr<nsIUrlListener> urlListener;
@@ -7260,17 +7262,17 @@ nsImapMailFolder::InitCopyState(nsISuppo
         {
           nsCOMPtr<nsIMsgDBHdr> message = do_QueryElementAt(m_copyState->m_messages, keyIndex, &rv);
           // if the key is not there, then assume what the caller tells us to.
           PRBool isRead = PR_FALSE;
           PRUint32 flags;
           if (message )
           {
             message->GetFlags(&flags);
-            isRead = flags & MSG_FLAG_READ;
+            isRead = flags & nsMsgMessageFlags::Read;
           }
           if (!isRead)
             numUnread++;
         }
         m_copyState->m_unreadCount = numUnread;
     }
   }
   else
@@ -7279,17 +7281,17 @@ nsImapMailFolder::InitCopyState(nsISuppo
         do_QueryElementAt(m_copyState->m_messages,
                           m_copyState->m_curIndex, &rv);
       // if the key is not there, then assume what the caller tells us to.
     PRBool isRead = PR_FALSE;
     PRUint32 flags;
     if (message )
     {
       message->GetFlags(&flags);
-      isRead = flags & MSG_FLAG_READ;
+      isRead = flags & nsMsgMessageFlags::Read;
     }
     m_copyState->m_unreadCount = (isRead) ? 0 : 1;
   }
 
   m_copyState->m_isMove = isMove;
   m_copyState->m_newMsgFlags = newMsgFlags;
   m_copyState->m_newMsgKeywords = newMsgKeywords;
   m_copyState->m_allowUndo = allowUndo;
@@ -7989,19 +7991,19 @@ nsImapMailFolder::OnMessageClassified(co
   rv = msgHdr->GetMessageKey(&msgKey);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // check if this message needs junk classification
 
   PRUint32 processingFlags;
   GetProcessingFlags(msgKey, &processingFlags);
 
-  if (processingFlags & MSG_PROCESSING_FLAG_CLASSIFY_JUNK)
-  {
-    AndProcessingFlags(msgKey, ~MSG_PROCESSING_FLAG_CLASSIFY_JUNK);
+  if (processingFlags & nsMsgProcessingFlags::ClassifyJunk)
+  {
+    AndProcessingFlags(msgKey, ~nsMsgProcessingFlags::ClassifyJunk);
     nsCString spamFolderURI;
 
     nsCAutoString msgJunkScore;
     msgJunkScore.AppendInt(aClassification == nsIJunkMailPlugin::JUNK ?
           nsIJunkMailPlugin::IS_SPAM_SCORE:
           nsIJunkMailPlugin::IS_HAM_SCORE);
     mDatabase->SetStringProperty(msgKey, "junkscore", msgJunkScore.get());
     mDatabase->SetStringProperty(msgKey, "junkscoreorigin", "plugin");
@@ -8118,20 +8120,20 @@ nsImapMailFolder::OnMessageTraitsClassif
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsMsgKey msgKey;
   rv = msgHdr->GetMessageKey(&msgKey);
   NS_ENSURE_SUCCESS(rv, rv);
 
   PRUint32 processingFlags;
   GetProcessingFlags(msgKey, &processingFlags);
-  if (!(processingFlags & MSG_PROCESSING_FLAG_CLASSIFY_TRAITS))
+  if (!(processingFlags & nsMsgProcessingFlags::ClassifyTraits))
     return NS_OK;
 
-  AndProcessingFlags(msgKey, ~MSG_PROCESSING_FLAG_CLASSIFY_TRAITS);
+  AndProcessingFlags(msgKey, ~nsMsgProcessingFlags::ClassifyTraits);
 
   nsCOMPtr<nsIMsgTraitService> traitService;
   traitService = do_GetService("@mozilla.org/msg-trait-service;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   for (PRUint32 i = 0; i < aTraitCount; i++)
   {
     if (aTraits[i] == nsIJunkMailPlugin::JUNK_TRAIT)
@@ -8241,17 +8243,17 @@ NS_IMETHODIMP nsImapMailFolder::FetchMsg
       }
     }
     else // lets look in the offline store
     {
       PRUint32 msgFlags;
       msgHdr->GetFlags(&msgFlags);
       nsMsgKey msgKey;
       msgHdr->GetMessageKey(&msgKey);
-      if (msgFlags & MSG_FLAG_OFFLINE)
+      if (msgFlags & nsMsgMessageFlags::Offline)
       {
         nsMsgKey messageOffset;
         PRUint32 messageSize;
         GetOfflineFileStream(msgKey, &messageOffset, &messageSize, getter_AddRefs(inputStream));
         if (inputStream)
           rv = GetMsgPreviewTextFromStream(msgHdr, inputStream);
       }
       else if (!aLocalOnly)
--- a/mailnews/imap/src/nsImapOfflineSync.cpp
+++ b/mailnews/imap/src/nsImapOfflineSync.cpp
@@ -564,17 +564,17 @@ void nsImapOfflineSync::ProcessMoveOpera
           {
             imapMessageFlagsType newImapFlags;
             PRUint32 msgFlags = 0;
             op->GetMsgSize(&msgSize);
             op->GetNewFlags(&newImapFlags);
             // first three bits are the same
             msgFlags |= (newImapFlags & 0x07);
             if (newImapFlags & kImapMsgForwardedFlag)
-              msgFlags |= MSG_FLAG_FORWARDED;
+              msgFlags |= nsMsgMessageFlags::Forwarded;
             mailHdr->SetFlags(msgFlags);
             mailHdr->SetMessageSize(msgSize);
           }
           messages->AppendElement(mailHdr, PR_FALSE);
         }
       }
       nsCOMPtr<nsIMsgCopyService> copyService = do_GetService(NS_MSGCOPYSERVICE_CONTRACTID, &rv);
       if (copyService)
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -3628,17 +3628,17 @@ void nsImapProtocol::HandleMessageDownLo
     {
       m_fromHeaderSeen = PR_TRUE;
       if (PL_strstr(messageLine, xSenderInfo) != NULL)
           // Adding a X-Mozilla-Status line here is not very elegant but it
           // works.  Another X-Mozilla-Status line is added to the message when
           // downloading to a local folder; this new line will also contain the
           // 'authed' flag we are adding here.  (If the message is again
           // uploaded to the server, this flag is lost.)
-          // 0x0200 == MSG_FLAG_SENDER_AUTHED
+          // 0x0200 == nsMsgMessageFlags::SenderAuthed
           HandleMessageDownLoadLine("X-Mozilla-Status: 0200\r\n", PR_FALSE);
       GetServerStateParser().FreeXSenderInfo();
     }
   }
 
   if (GetServerStateParser().GetDownloadingHeaders())
   {
     if (!m_curHdrInfo)
@@ -5499,28 +5499,28 @@ void nsImapProtocol::OnAppendMsgFromFile
       imapMessageFlagsType flagsToSet = 0;
       PRUint32 msgFlags = 0;
       PRTime date = 0;
       nsCString keywords;
       if (m_imapMessageSink)
         m_imapMessageSink->GetCurMoveCopyMessageInfo(m_runningUrl, &date,
                                                     getter_Copies(keywords), &msgFlags);
 
-      if (msgFlags & MSG_FLAG_READ)
+      if (msgFlags & nsMsgMessageFlags::Read)
         flagsToSet |= kImapMsgSeenFlag;
-      if (msgFlags & MSG_FLAG_MDN_REPORT_SENT)
+      if (msgFlags & nsMsgMessageFlags::MDNReportSent)
         flagsToSet |= kImapMsgMDNSentFlag;
       // convert msg flag label (0xE000000) to imap flag label (0x0E00)
-      if (msgFlags & MSG_FLAG_LABELS)
-        flagsToSet |= (msgFlags & MSG_FLAG_LABELS) >> 16;
-      if (msgFlags & MSG_FLAG_MARKED)
+      if (msgFlags & nsMsgMessageFlags::Labels)
+        flagsToSet |= (msgFlags & nsMsgMessageFlags::Labels) >> 16;
+      if (msgFlags & nsMsgMessageFlags::Marked)
         flagsToSet |= kImapMsgFlaggedFlag;
-      if (msgFlags & MSG_FLAG_REPLIED)
+      if (msgFlags & nsMsgMessageFlags::Replied)
         flagsToSet |= kImapMsgAnsweredFlag;
-      if (msgFlags & MSG_FLAG_FORWARDED)
+      if (msgFlags & nsMsgMessageFlags::Forwarded)
         flagsToSet |= kImapMsgForwardedFlag;
 
       // If the message copied was a draft, flag it as such
       nsImapAction imapAction;
       rv = m_runningUrl->GetImapAction(&imapAction);
       if (NS_SUCCEEDED(rv) && (imapAction == nsIImapUrl::nsImapAppendDraftFromFile))
         flagsToSet |= kImapMsgDraftFlag;
       UploadMessageFromFile(file, mailboxName, date, flagsToSet, keywords);
--- a/mailnews/imap/src/nsImapService.cpp
+++ b/mailnews/imap/src/nsImapService.cpp
@@ -2071,17 +2071,17 @@ nsresult nsImapService::OfflineAppendFro
           msgParser->GetNewMsgHdr(getter_AddRefs(fakeHdr));
           if (fakeHdr)
           {
             if (NS_SUCCEEDED(rv) && fakeHdr)
             {
               PRUint32 resultFlags;
               nsInt64 tellPos = curOfflineStorePos;
               fakeHdr->SetMessageOffset((PRUint32) tellPos);
-              fakeHdr->OrFlags(MSG_FLAG_OFFLINE | MSG_FLAG_READ, &resultFlags);
+              fakeHdr->OrFlags(nsMsgMessageFlags::Offline | nsMsgMessageFlags::Read, &resultFlags);
               fakeHdr->SetOfflineMessageSize(fileSize);
               destDB->AddNewHdrToDB(fakeHdr, PR_TRUE /* notify */);
               aDstFolder->SetFlag(nsMsgFolderFlags::OfflineEvents);
             }
           }
           // tell the listener we're done.
           inputStream->Close();
           inputStream = nsnull;
--- a/mailnews/import/applemail/src/nsEmlxHelperUtils.mm
+++ b/mailnews/import/applemail/src/nsEmlxHelperUtils.mm
@@ -72,23 +72,23 @@ nsresult nsEmlxHelperUtils::ConvertToMoz
 
   // find the <flags>...</flags> value and convert to int
   const PRUint32 emlxMessageFlags = [[(NSDictionary *)plist objectForKey:@"flags"] intValue];
 
   if (emlxMessageFlags == 0)
     return NS_ERROR_FAILURE;
 
   if (emlxMessageFlags & nsEmlxHelperUtils::kRead) 
-    *aMozillaStatusFlags |= MSG_FLAG_READ;
+    *aMozillaStatusFlags |= nsMsgMessageFlags::Read;
   if (emlxMessageFlags & nsEmlxHelperUtils::kForwarded)
-    *aMozillaStatusFlags |= MSG_FLAG_FORWARDED;
+    *aMozillaStatusFlags |= nsMsgMessageFlags::Forwarded;
   if (emlxMessageFlags & nsEmlxHelperUtils::kAnswered)
-    *aMozillaStatusFlags |= MSG_FLAG_REPLIED;
+    *aMozillaStatusFlags |= nsMsgMessageFlags::Replied;
   if (emlxMessageFlags & nsEmlxHelperUtils::kFlagged)
-    *aMozillaStatusFlags |= MSG_FLAG_MARKED;
+    *aMozillaStatusFlags |= nsMsgMessageFlags::Marked;
 
   return NS_OK;
 }
 
 nsresult nsEmlxHelperUtils::ConvertToMboxRD(const char *aMessageBufferStart, const char *aMessageBufferEnd, nsCString &aOutBuffer)
 {
   nsTArray<const char *> foundFromLines;
 
--- a/mailnews/import/eudora/src/nsEudoraMailbox.cpp
+++ b/mailnews/import/eudora/src/nsEudoraMailbox.cpp
@@ -120,46 +120,46 @@ PRUint16 EudoraTOCEntry::GetMozillaStatu
 #ifndef XP_MACOSX
   switch (m_State)
   {
     case MS_UNREAD:
       flags = 0;
       break;
 
     case MS_READ:
-      flags = MSG_FLAG_READ;
+      flags = nsMsgMessageFlags::Read;
       break;
 
     case MS_REPLIED:
-      flags = MSG_FLAG_READ | MSG_FLAG_REPLIED;
+      flags = nsMsgMessageFlags::Read | nsMsgMessageFlags::Replied;
       break;
 
     case MS_FORWARDED:
-      flags = MSG_FLAG_READ | MSG_FLAG_FORWARDED;
+      flags = nsMsgMessageFlags::Read | nsMsgMessageFlags::Forwarded;
       break;
 
     case MS_REDIRECT:
       // Redirect doesn't really mean forwarded, but forwarded
       // seems to be the closest equivalent for now.
-      flags = MSG_FLAG_READ | MSG_FLAG_FORWARDED;
+      flags = nsMsgMessageFlags::Read | nsMsgMessageFlags::Forwarded;
       break;
 
     case MS_UNSENDABLE:
     case MS_SENDABLE:
     case MS_QUEUED:
     case MS_SENT:
     case MS_UNSENT:
     case MS_TIME_QUEUED:
     case MS_SPOOLED:
       // To do: Add more sent message flag handling.
       flags = 0;
       break;
 
     case MS_RECOVERED:
-      flags = MSG_FLAG_READ;
+      flags = nsMsgMessageFlags::Read;
       break;
   }
 
   // Range check priority just to be sure
   if (m_Priority < MSP_HIGHEST)
     m_Priority = MSP_HIGHEST;
   if (m_Priority > MSP_LOWEST)
     m_Priority = MSP_LOWEST;
@@ -178,20 +178,20 @@ PRUint32 EudoraTOCEntry::GetMozillaStatu
 #ifdef XP_MACOSX
   return 0;
 #else
 
   // Return the mozilla equivalent of flags that Eudora supports.
   PRUint32  flags = 0;
 
   if (m_Imflags & IMFLAGS_DELETED)
-    flags |= MSG_FLAG_IMAP_DELETED;
+    flags |= nsMsgMessageFlags::IMAPDeleted;
 
   if (m_Flags & MSF_READ_RECEIPT)
-    flags |= MSG_FLAG_MDN_REPORT_NEEDED;
+    flags |= nsMsgMessageFlags::MDNReportNeeded;
 
   return flags;
 #endif
 }
 
 
 nsEudoraMailbox::nsEudoraMailbox()
 {
--- a/mailnews/local/src/nsLocalMailFolder.cpp
+++ b/mailnews/local/src/nsLocalMailFolder.cpp
@@ -2245,19 +2245,19 @@ nsresult nsMsgLocalMailFolder::WriteStar
                                                                 mCopyState->m_curCopyIndex, &rv);
 
     char statusStrBuf[50];
     if (curSourceMessage)
     {
       PRUint32 dbFlags = 0;
       curSourceMessage->GetFlags(&dbFlags);
 
-      // write out x-mozilla-status, but make sure we don't write out MSG_FLAG_OFFLINE
+      // write out x-mozilla-status, but make sure we don't write out nsMsgMessageFlags::Offline
       PR_snprintf(statusStrBuf, sizeof(statusStrBuf), X_MOZILLA_STATUS_FORMAT MSG_LINEBREAK,
-        dbFlags & ~(MSG_FLAG_RUNTIME_ONLY | MSG_FLAG_OFFLINE) & 0x0000FFFF);
+        dbFlags & ~(nsMsgMessageFlags::RuntimeOnly | nsMsgMessageFlags::Offline) & 0x0000FFFF);
     }
     else
       strcpy(statusStrBuf, "X-Mozilla-Status: 0001" MSG_LINEBREAK);
     PRUint32 bytesWritten;
     mCopyState->m_fileStream->Write(result.get(), result.Length(), &bytesWritten);
     if (mCopyState->m_parseMsgState)
         mCopyState->m_parseMsgState->ParseAFolderLine(
           result.get(), result.Length());
@@ -2468,17 +2468,17 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndC
       if(mCopyState->m_destDB)
       {
         rv = mCopyState->m_destDB->CopyHdrFromExistingHdr(mCopyState->m_curDstKey,
           mCopyState->m_message, PR_TRUE,
           getter_AddRefs(newHdr));
         PRUint32 newHdrFlags;
         // turn off offline flag - it's not valid for local mail folders.
         if (newHdr)
-          newHdr->AndFlags(~MSG_FLAG_OFFLINE, &newHdrFlags);
+          newHdr->AndFlags(~nsMsgMessageFlags::Offline, &newHdrFlags);
       }
       // we can do undo with the dest folder db, see bug #198909
       //else
       //  mCopyState->m_undoMsgTxn = nsnull; //null out the transaction because we can't undo w/o the msg db
     }
 
     // if we plan on allowing undo, (if we have a mCopyState->m_parseMsgState or not)
     // we need to save the source and dest keys on the undo txn.
@@ -2525,17 +2525,17 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndC
       if (NS_SUCCEEDED(result) && newHdr)
       {
         // need to copy junk score and label from mCopyState->m_message to newHdr.
         if (mCopyState->m_message)
         {
           // deal with propagating the new flag on an imap to local folder filter action
           PRUint32 msgFlags;
           mCopyState->m_message->GetFlags(&msgFlags);
-          if (!(msgFlags & MSG_FLAG_READ))
+          if (!(msgFlags & nsMsgMessageFlags::Read))
           {
             nsCOMPtr <nsIMsgFolder> srcFolder;
             mCopyState->m_message->GetFolder(getter_AddRefs(srcFolder));
             if (srcFolder)
             {
               PRUint32 folderFlags;
               srcFolder->GetFlags(&folderFlags);
               // check if the src folder is an imap inbox.
@@ -2548,17 +2548,17 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndC
                 {
                   nsMsgKey srcKey;
                   PRBool containsKey;
                   mCopyState->m_message->GetMessageKey(&srcKey);
                   db->ContainsKey(srcKey, &containsKey);
                   // if the db doesn't have the key, it must be a filtered imap
                   // message, getting moved to a local folder.
                   if (!containsKey)
-                    newHdr->OrFlags(MSG_FLAG_NEW, &msgFlags);
+                    newHdr->OrFlags(nsMsgMessageFlags::New, &msgFlags);
                 }
               }
             }
           }
           CopyPropertiesToMsgHdr(newHdr, mCopyState->m_message);
         }
         msgDb->AddNewHdrToDB(newHdr, PR_TRUE);
         if (localUndoTxn)
@@ -2970,17 +2970,17 @@ nsMsgLocalMailFolder::MarkMsgsOnPop3Serv
             msgPop3Server = curMsgPop3MailServer;
             msgPop3Server->GetDeleteMailLeftOnServer(&deleteMailLeftOnServer);
             msgPop3Server->GetLeaveMessagesOnServer(&leaveOnServer);
           }
         }
       }
       // ignore this header if not partial and leaveOnServer not set...
       // or if we can't find the pop3 server.
-      if (!msgPop3Server || (! (flags & MSG_FLAG_PARTIAL) && !leaveOnServer))
+      if (!msgPop3Server || (! (flags & nsMsgMessageFlags::Partial) && !leaveOnServer))
         continue;
       // if marking deleted, ignore header if we're not deleting from
       // server when deleting locally.
       if (aMark == POP3_DELETE && leaveOnServer && !deleteMailLeftOnServer)
         continue;
       if (folderScanState.m_uidl)
       {
         msgPop3Server->AddUidlToMark(folderScanState.m_uidl, mark);
@@ -3092,17 +3092,17 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Down
   NS_NewISupportsArray(getter_AddRefs(mDownloadMessages));
   for (PRUint32 i = 0; i < srcCount; i++)
   {
     nsCOMPtr<nsIMsgDBHdr> msgDBHdr (do_QueryElementAt(aMessages, i, &rv));
     if (NS_SUCCEEDED(rv))
     {
       PRUint32 flags = 0;
       msgDBHdr->GetFlags(&flags);
-      if (flags & MSG_FLAG_PARTIAL)
+      if (flags & nsMsgMessageFlags::Partial)
         mDownloadMessages->AppendElement(msgDBHdr);
     }
   }
   mDownloadWindow = aWindow;
 
   nsCOMPtr<nsIMsgIncomingServer> server;
   rv = GetServer(getter_AddRefs(server));
   NS_ENSURE_SUCCESS(rv, NS_MSG_INVALID_OR_MISSING_SERVER);
@@ -3500,19 +3500,19 @@ nsMsgLocalMailFolder::OnMessageClassifie
   nsCOMPtr<nsISpamSettings> spamSettings;
   rv = server->GetSpamSettings(getter_AddRefs(spamSettings));
   NS_ENSURE_SUCCESS(rv, rv);
 
   // check if this message needs junk classification
   PRUint32 processingFlags;
   GetProcessingFlags(msgKey, &processingFlags);
 
-  if (processingFlags & MSG_PROCESSING_FLAG_CLASSIFY_JUNK)
+  if (processingFlags & nsMsgProcessingFlags::ClassifyJunk)
   {
-    AndProcessingFlags(msgKey, ~MSG_PROCESSING_FLAG_CLASSIFY_JUNK);
+    AndProcessingFlags(msgKey, ~nsMsgProcessingFlags::ClassifyJunk);
 
     nsCAutoString msgJunkScore;
     msgJunkScore.AppendInt(aClassification == nsIJunkMailPlugin::JUNK ?
           nsIJunkMailPlugin::IS_SPAM_SCORE:
           nsIJunkMailPlugin::IS_HAM_SCORE);
     mDatabase->SetStringProperty(msgKey, "junkscore", msgJunkScore.get());
     mDatabase->SetStringProperty(msgKey, "junkscoreorigin", "plugin");
 
@@ -3632,20 +3632,20 @@ nsMsgLocalMailFolder::OnMessageTraitsCla
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsMsgKey msgKey;
   rv = msgHdr->GetMessageKey(&msgKey);
   NS_ENSURE_SUCCESS(rv, rv);
 
   PRUint32 processingFlags;
   GetProcessingFlags(msgKey, &processingFlags);
-  if (!(processingFlags & MSG_PROCESSING_FLAG_CLASSIFY_TRAITS))
+  if (!(processingFlags & nsMsgProcessingFlags::ClassifyTraits))
     return NS_OK;
 
-  AndProcessingFlags(msgKey, ~MSG_PROCESSING_FLAG_CLASSIFY_TRAITS);
+  AndProcessingFlags(msgKey, ~nsMsgProcessingFlags::ClassifyTraits);
 
   nsCOMPtr<nsIMsgTraitService> traitService;
   traitService = do_GetService("@mozilla.org/msg-trait-service;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   for (PRUint32 i = 0; i < aTraitCount; i++)
   {
     if (aTraits[i] == nsIJunkMailPlugin::JUNK_TRAIT)
--- a/mailnews/local/src/nsParseMailbox.cpp
+++ b/mailnews/local/src/nsParseMailbox.cpp
@@ -392,17 +392,17 @@ void nsMsgMailboxParser::UpdateDBFolderI
 // Tell the world about the message header (add to db, and view, if any)
 PRInt32 nsMsgMailboxParser::PublishMsgHeader(nsIMsgWindow *msgWindow)
 {
   FinishHeader();
   if (m_newMsgHdr)
   {
     PRUint32 flags;
     (void)m_newMsgHdr->GetFlags(&flags);
-    if (flags & MSG_FLAG_EXPUNGED)
+    if (flags & nsMsgMessageFlags::Expunged)
     {
       nsCOMPtr<nsIDBFolderInfo> folderInfo;
       m_mailDB->GetDBFolderInfo(getter_AddRefs(folderInfo));
       PRUint32 size;
       (void)m_newMsgHdr->GetMessageSize(&size);
       folderInfo->ChangeExpungedBytes(size);
       m_newMsgHdr = nsnull;
     }
@@ -1173,19 +1173,19 @@ int nsParseMailMessageState::InternSubje
         We trust the X-Mozilla-Status line to be the smartest in almost
         all things.  One exception, however, is the HAS_RE flag.  Since
          we just parsed the subject header anyway, we expect that parsing
          to be smartest.  (After all, what if someone just went in and
         edited the subject line by hand?)
      */
   nsCString modifiedSubject;
   if (NS_MsgStripRE((const char **) &key, &L, getter_Copies(modifiedSubject)))
-    flags |= MSG_FLAG_HAS_RE;
+    flags |= nsMsgMessageFlags::HasRe;
   else
-    flags &= ~MSG_FLAG_HAS_RE;
+    flags &= ~nsMsgMessageFlags::HasRe;
   m_newMsgHdr->SetFlags(flags); // this *does not* update the mozilla-status header in the local folder
 
   //  if (!*key) return 0; /* To catch a subject of "Re:" */
 
   // Condense the subject text into as few MIME-2 encoded words as possible.
 #ifdef WE_CONDENSE_MIME_STRINGS
   char *condensedKey = msg_condense_mime2_string(modifiedSubject.IsEmpty() ? key : modifiedSubject.get());
 #else
@@ -1270,34 +1270,34 @@ int nsParseMailMessageState::FinalizeHea
     if (strlen(mozstatus->value) == 4)
     {
       int i;
       for (i=0,s=mozstatus->value ; i<4 ; i++,s++)
       {
         flags = (flags << 4) | msg_UnHex(*s);
       }
       // strip off and remember priority bits.
-      flags &= ~MSG_FLAG_RUNTIME_ONLY;
-      priorityFlags = (nsMsgPriorityValue) ((flags & MSG_FLAG_PRIORITIES) >> 13);
-      flags &= ~MSG_FLAG_PRIORITIES;
+      flags &= ~nsMsgMessageFlags::RuntimeOnly;
+      priorityFlags = (nsMsgPriorityValue) ((flags & nsMsgMessageFlags::Priorities) >> 13);
+      flags &= ~nsMsgMessageFlags::Priorities;
     }
     delta = (m_headerstartpos +
       (mozstatus->value - m_headers.GetBuffer()) -
       (2 + X_MOZILLA_STATUS_LEN)    /* 2 extra bytes for ": ". */
       ) - m_envelope_pos;
   }
 
   if (mozstatus2)
   {
     PRUint32 flags2 = 0;
     sscanf(mozstatus2->value, " %x ", &flags2);
     flags |= flags2;
   }
 
-  if (!(flags & MSG_FLAG_EXPUNGED))  // message was deleted, don't bother creating a hdr.
+  if (!(flags & nsMsgMessageFlags::Expunged))  // message was deleted, don't bother creating a hdr.
   {
     // We'll need the message id first to recover data from the backup database
     nsCAutoString rawMsgId;
     /* Take off <> around message ID. */
     if (id)
     {
       if (id->value[0] == '<')
         id->value++, id->length--;
@@ -1324,39 +1324,39 @@ int nsParseMailMessageState::FinalizeHea
                 oldHeader, PR_FALSE, getter_AddRefs(m_newMsgHdr));
     else
       ret = m_mailDB->CreateNewHdr(m_envelope_pos, getter_AddRefs(m_newMsgHdr));
 
     if (NS_SUCCEEDED(ret) && m_newMsgHdr)
     {
       PRUint32 origFlags;
       (void)m_newMsgHdr->GetFlags(&origFlags);
-      if (origFlags & MSG_FLAG_HAS_RE)
-        flags |= MSG_FLAG_HAS_RE;
+      if (origFlags & nsMsgMessageFlags::HasRe)
+        flags |= nsMsgMessageFlags::HasRe;
       else
-        flags &= ~MSG_FLAG_HAS_RE;
+        flags &= ~nsMsgMessageFlags::HasRe;
 
-      flags &= ~MSG_FLAG_OFFLINE; // don't keep MSG_FLAG_OFFLINE for local msgs
-      if (mdn_dnt && !(origFlags & MSG_FLAG_READ) &&
-          !(origFlags & MSG_FLAG_MDN_REPORT_SENT) &&
-          !(flags & MSG_FLAG_MDN_REPORT_SENT))
-        flags |= MSG_FLAG_MDN_REPORT_NEEDED;
+      flags &= ~nsMsgMessageFlags::Offline; // don't keep nsMsgMessageFlags::Offline for local msgs
+      if (mdn_dnt && !(origFlags & nsMsgMessageFlags::Read) &&
+          !(origFlags & nsMsgMessageFlags::MDNReportSent) &&
+          !(flags & nsMsgMessageFlags::MDNReportSent))
+        flags |= nsMsgMessageFlags::MDNReportNeeded;
 
       m_newMsgHdr->SetFlags(flags);
       if (priorityFlags != nsMsgPriority::notSet)
         m_newMsgHdr->SetPriority(priorityFlags);
 
       // if we have a reply to header, and it's different from the from: header,
       // set the "replyTo" attribute on the msg hdr.
       if (replyTo && (!sender || replyTo->length != sender->length || strncmp(replyTo->value, sender->value, sender->length)))
         m_newMsgHdr->SetStringProperty("replyTo", replyTo->value);
       // convert the flag values (0xE000000) to label values (0-5)
       if (mozstatus2) // only do this if we have a mozstatus2 header
       {
-        labelFlags = ((flags & MSG_FLAG_LABELS) >> 25);
+        labelFlags = ((flags & nsMsgMessageFlags::Labels) >> 25);
         m_newMsgHdr->SetLabel(labelFlags);
       }
       if (delta < 0xffff)
       {    /* Only use if fits in 16 bits. */
         m_newMsgHdr->SetStatusOffset((PRUint16) delta);
         if (!m_IgnoreXMozillaStatus) {  // imap doesn't care about X-MozillaStatus
           PRUint32 offset;
           (void)m_newMsgHdr->GetStatusOffset(&offset);
@@ -1457,24 +1457,24 @@ int nsParseMailMessageState::FinalizeHea
         {
           /* Parse a little bit of the Berkeley Mail status header. */
           for (s = statush->value; *s; s++) {
             PRUint32 msgFlags = 0;
             (void)m_newMsgHdr->GetFlags(&msgFlags);
             switch (*s)
             {
             case 'R': case 'r':
-              m_newMsgHdr->SetFlags(msgFlags | MSG_FLAG_READ);
+              m_newMsgHdr->SetFlags(msgFlags | nsMsgMessageFlags::Read);
               break;
             case 'D': case 'd':
-              /* msg->flags |= MSG_FLAG_EXPUNGED;  ### Is this reasonable? */
+              /* msg->flags |= nsMsgMessageFlags::Expunged;  ### Is this reasonable? */
               break;
             case 'N': case 'n':
             case 'U': case 'u':
-              m_newMsgHdr->SetFlags(msgFlags & ~MSG_FLAG_READ);
+              m_newMsgHdr->SetFlags(msgFlags & ~nsMsgMessageFlags::Read);
               break;
             }
           }
         }
 
         if (account_key != nsnull)
           m_newMsgHdr->SetAccountKey(account_key->value);
         // use in-reply-to header as references, if there's no references header
@@ -1588,17 +1588,17 @@ int nsParseMailMessageState::FinalizeHea
                 }
               }
             }
           }
           substring = PL_strcasestr(content_type->value, "multipart/mixed");
           if (substring)
           {
             PRUint32 newFlags;
-            m_newMsgHdr->OrFlags(MSG_FLAG_ATTACHMENT, &newFlags);
+            m_newMsgHdr->OrFlags(nsMsgMessageFlags::Attachment, &newFlags);
           }
         }
       }
     }
     else
     {
       NS_ASSERTION(PR_FALSE, "error creating message header");
       status = NS_ERROR_OUT_OF_MEMORY;
@@ -1808,18 +1808,18 @@ PRInt32 nsParseNewMailState::PublishMsgH
       ApplyFilters(&moved, msgWindow, msgOffset);
     }
     if (!moved)
     {
       if (m_mailDB)
       {
         PRUint32 newFlags, oldFlags;
         m_newMsgHdr->GetFlags(&oldFlags);
-        if (!(oldFlags & MSG_FLAG_READ)) // don't mark read messages as new.
-          m_newMsgHdr->OrFlags(MSG_FLAG_NEW, &newFlags);
+        if (!(oldFlags & nsMsgMessageFlags::Read)) // don't mark read messages as new.
+          m_newMsgHdr->OrFlags(nsMsgMessageFlags::New, &newFlags);
 
         m_mailDB->AddNewHdrToDB(m_newMsgHdr, PR_TRUE);
         nsCOMPtr<nsIMsgFolderNotificationService> notifier(do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID));
         if (notifier)
           notifier->NotifyMsgAdded(m_newMsgHdr);
       }
     } // if it was moved by imap filter, m_parseMsgState->m_newMsgHdr == nsnull
     m_newMsgHdr = nsnull;
@@ -1935,17 +1935,17 @@ NS_IMETHODIMP nsParseNewMailState::Apply
       case nsMsgFilterAction::Delete:
         {
           nsCOMPtr <nsIMsgFolder> trash;
           // set value to trash folder
           rv = GetTrashFolder(getter_AddRefs(trash));
           if (NS_SUCCEEDED(rv) && trash)
             rv = trash->GetURI(actionTargetFolderUri);
 
-          msgHdr->OrFlags(MSG_FLAG_READ, &newFlags); // mark read in trash.
+          msgHdr->OrFlags(nsMsgMessageFlags::Read, &newFlags); // mark read in trash.
           msgIsNew = PR_FALSE;
         }
       case nsMsgFilterAction::MoveToFolder:
         // if moving to a different file, do it.
         if (actionTargetFolderUri.get() && !m_inboxUri.Equals(actionTargetFolderUri,
                                                              nsCaseInsensitiveCStringComparator()))
         {
           nsresult err;
@@ -2021,23 +2021,23 @@ NS_IMETHODIMP nsParseNewMailState::Apply
           }
         }
         break;
       case nsMsgFilterAction::MarkRead:
         msgIsNew = PR_FALSE;
         MarkFilteredMessageRead(msgHdr);
         break;
       case nsMsgFilterAction::KillThread:
-        msgHdr->SetUint32Property("ProtoThreadFlags", MSG_FLAG_IGNORED);
+        msgHdr->SetUint32Property("ProtoThreadFlags", nsMsgMessageFlags::Ignored);
         break;
       case nsMsgFilterAction::KillSubthread:
-        msgHdr->OrFlags(MSG_FLAG_IGNORED, &newFlags);
+        msgHdr->OrFlags(nsMsgMessageFlags::Ignored, &newFlags);
         break;
       case nsMsgFilterAction::WatchThread:
-        msgHdr->OrFlags(MSG_FLAG_WATCHED, &newFlags);
+        msgHdr->OrFlags(nsMsgMessageFlags::Watched, &newFlags);
         break;
       case nsMsgFilterAction::MarkFlagged:
         msgHdr->MarkFlagged(PR_TRUE);
         break;
       case nsMsgFilterAction::ChangePriority:
         nsMsgPriorityValue filterPriority;
         filterAction->GetPriority(&filterPriority);
         msgHdr->SetPriority(filterPriority);
@@ -2100,32 +2100,32 @@ NS_IMETHODIMP nsParseNewMailState::Apply
             nsCOMPtr<nsIMutableArray> messages = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
             NS_ENSURE_SUCCESS(rv, rv);
             messages->AppendElement(msgHdr, PR_FALSE);
             // This action ignores the deleteMailLeftOnServer preference
             localFolder->MarkMsgsOnPop3Server(messages, POP3_FORCE_DEL);
 
             // If this is just a header, throw it away. It's useless now
             // that the server copy is being deleted.
-            if (flags & MSG_FLAG_PARTIAL)
+            if (flags & nsMsgMessageFlags::Partial)
             {
               m_msgMovedByFilter = PR_TRUE;
               msgIsNew = PR_FALSE;
             }
           }
         }
         break;
       case nsMsgFilterAction::FetchBodyFromPop3Server:
         {
           PRUint32 flags = 0;
           nsCOMPtr <nsIMsgFolder> downloadFolder;
           msgHdr->GetFolder(getter_AddRefs(downloadFolder));
           nsCOMPtr <nsIMsgLocalMailFolder> localFolder = do_QueryInterface(downloadFolder);
           msgHdr->GetFlags(&flags);
-          if (localFolder && (flags & MSG_FLAG_PARTIAL))
+          if (localFolder && (flags & nsMsgMessageFlags::Partial))
           {
             nsCOMPtr<nsIMutableArray> messages = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
             NS_ENSURE_SUCCESS(rv, rv);
             messages->AppendElement(msgHdr, PR_FALSE);
             localFolder->MarkMsgsOnPop3Server(messages, POP3_FETCH_BODY);
             // Don't add this header to the DB, we're going to replace it
             // with the full message.
             m_msgMovedByFilter = PR_TRUE;
@@ -2228,17 +2228,17 @@ nsresult nsParseNewMailState::ApplyForwa
 
 
 int nsParseNewMailState::MarkFilteredMessageRead(nsIMsgDBHdr *msgHdr)
 {
   PRUint32 newFlags;
   if (m_mailDB)
     m_mailDB->MarkHdrRead(msgHdr, PR_TRUE, nsnull);
   else
-    msgHdr->OrFlags(MSG_FLAG_READ, &newFlags);
+    msgHdr->OrFlags(nsMsgMessageFlags::Read, &newFlags);
   return 0;
 }
 
 nsresult nsParseNewMailState::EndMsgDownload()
 {
   if (m_moveCoalescer)
     m_moveCoalescer->PlaybackMoves();
 
@@ -2440,23 +2440,23 @@ nsresult nsParseNewMailState::MoveIncorp
 
     nsresult msgErr = destMailDB->CopyHdrFromExistingHdr(newMsgPos, mailHdr, PR_FALSE, getter_AddRefs(newHdr));
     if (NS_SUCCEEDED(msgErr) && newHdr)
     {
       PRUint32 newFlags;
       // set new byte offset, since the offset in the old file is certainly wrong
       newHdr->SetMessageKey (newMsgPos);
       newHdr->GetFlags(&newFlags);
-      if (! (newFlags & MSG_FLAG_READ))
+      if (! (newFlags & nsMsgMessageFlags::Read))
       {
         nsCString junkScoreStr;
         (void) newHdr->GetStringProperty("junkscore", getter_Copies(junkScoreStr));
         if (atoi(junkScoreStr.get()) == nsIJunkMailPlugin::IS_HAM_SCORE)
         {
-          newHdr->OrFlags(MSG_FLAG_NEW, &newFlags);
+          newHdr->OrFlags(nsMsgMessageFlags::New, &newFlags);
           destMailDB->AddToNewList(newMsgPos);
           movedMsgIsNew = PR_TRUE;
         }
       }
       destMailDB->AddNewHdrToDB(newHdr, PR_TRUE);
       nsCOMPtr<nsIMsgFolderNotificationService> notifier(do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID));
       if (notifier)
         notifier->NotifyMsgAdded(newHdr);
--- a/mailnews/local/src/nsPop3Protocol.cpp
+++ b/mailnews/local/src/nsPop3Protocol.cpp
@@ -2904,31 +2904,31 @@ nsPop3Protocol::RetrResponse(nsIInputStr
         if(!m_pop3ConData->command_succeeded)
             return Error(POP3_RETR_FAILURE);
 
         /* a successful RETR response looks like: #num_bytes Junk
            from TOP we only get the +OK and data
            */
         if (m_pop3ConData->truncating_cur_msg)
         { /* TOP, truncated message */
-            flags |= MSG_FLAG_PARTIAL;
+            flags |= nsMsgMessageFlags::Partial;
         }
         else
         {
           nsCString cmdResp(m_commandResponse);
           char *newStr = cmdResp.BeginWriting();
           char *num = NS_strtok( " ", &newStr);
           if (num)
             m_pop3ConData->cur_msg_size = atol(num);
           m_commandResponse = newStr;
         }
 
         /* RETR complete message */
         if (!m_senderInfo.IsEmpty())
-            flags |= MSG_FLAG_SENDER_AUTHED;
+            flags |= nsMsgMessageFlags::SenderAuthed;
 
         if(m_pop3ConData->cur_msg_size <= 0)
         {
           if (m_pop3ConData->msg_info)
             m_pop3ConData->cur_msg_size = m_pop3ConData->msg_info[m_pop3ConData->last_accessed_msg].size;
           else
             m_pop3ConData->cur_msg_size = 0;
         }
--- a/mailnews/local/src/nsPop3Sink.cpp
+++ b/mailnews/local/src/nsPop3Sink.cpp
@@ -188,17 +188,17 @@ nsPop3Sink::FindPartialMessages(nsILocal
     messages->HasMoreElements(&hasMore);
   while(hasMore && NS_SUCCEEDED(rv))
   {
     nsCOMPtr<nsISupports> aSupport;
     PRUint32 flags = 0;
     rv = messages->GetNext(getter_AddRefs(aSupport));
     nsCOMPtr<nsIMsgDBHdr> msgDBHdr(do_QueryInterface(aSupport, &rv));
     msgDBHdr->GetFlags(&flags);
-    if (flags & MSG_FLAG_PARTIAL)
+    if (flags & nsMsgMessageFlags::Partial)
     {
       // Open the various streams we need to seek and read from the mailbox
       if (!isOpen)
       {
         folderScanState.m_localFile = folderFile;
         rv = localFolder->GetFolderScanState(&folderScanState);
         if (NS_SUCCEEDED(rv))
           isOpen = PR_TRUE;
@@ -859,23 +859,23 @@ nsPop3Sink::IncorporateComplete(nsIMsgWi
             return HandleTempDownloadFailed(aMsgWindow);
 
           // if we have made it this far then the message has successfully been written to the new folder
           // now add the header to the destMailDB.
           if (NS_SUCCEEDED(rv) && m_newMailParser->m_mailDB)
           {
             PRUint32 newFlags;
             hdr->GetFlags(&newFlags);
-            if (! (newFlags & MSG_FLAG_READ))
+            if (! (newFlags & nsMsgMessageFlags::Read))
             {
               nsCString junkScoreStr;
               (void) hdr->GetStringProperty("junkscore", getter_Copies(junkScoreStr));
               if (atoi(junkScoreStr.get()) < 50)
               {
-                hdr->OrFlags(MSG_FLAG_NEW, &newFlags);
+                hdr->OrFlags(nsMsgMessageFlags::New, &newFlags);
                 m_newMailParser->m_mailDB->AddToNewList(newMsgPos);
               }
             }
             m_newMailParser->m_mailDB->AddNewHdrToDB(hdr, PR_TRUE);
             nsCOMPtr<nsIMsgFolderNotificationService> notifier(do_GetService(NS_MSGNOTIFICATIONSERVICE_CONTRACTID));
             if (notifier)
               notifier->NotifyMsgAdded(hdr);
           }
--- a/mailnews/mapi/mapihook/src/msgMapiImp.cpp
+++ b/mailnews/mapi/mapihook/src/msgMapiImp.cpp
@@ -571,17 +571,17 @@ nsMsgKey MsgMapiListContext::GetNext ()
         if (!IsIMAPHost())
           return key;
         
         // If this is an IMAP message, we have to make sure we have a valid
         // body to work with.
         PRUint32  flags = 0;
         
         (void) msgHdr->GetFlags(&flags);
-        if (flags & MSG_FLAG_OFFLINE) 
+        if (flags & nsMsgMessageFlags::Offline) 
           return key;
         
         // Ok, if we get here, we have an IMAP message without a body!
         // We need to keep trying by calling the GetNext member recursively...
         keepTrying = TRUE;
       }
     } while (keepTrying);
   }
@@ -619,19 +619,19 @@ lpnsMapiMessage MsgMapiListContext::GetM
       PRUint32 date;
       (void) msgHdr->GetDateInSeconds(&date);
       message->lpszDateReceived = ConvertDateToMapiFormat (date);
       
       // Pull out the flags info
       // anything to do with MAPI_SENT? Since we're only reading the Inbox, I guess not
       PRUint32 ourFlags;
       (void) msgHdr->GetFlags(&ourFlags);
-      if (!(ourFlags & MSG_FLAG_READ))
+      if (!(ourFlags & nsMsgMessageFlags::Read))
         message->flFlags |= MAPI_UNREAD;
-      if (ourFlags & (MSG_FLAG_MDN_REPORT_NEEDED | MSG_FLAG_MDN_REPORT_SENT))
+      if (ourFlags & (nsMsgMessageFlags::MDNReportNeeded | nsMsgMessageFlags::MDNReportSent))
         message->flFlags |= MAPI_RECEIPT_REQUESTED;
       
       nsCOMPtr<nsIMsgHeaderParser> parser = do_GetService(NS_MAILNEWS_MIME_HEADER_PARSER_CONTRACTID);
       if (!parser)
         return nsnull;
       // Pull out the author/originator info
       message->lpOriginator = (lpnsMapiRecipDesc) CoTaskMemAlloc (sizeof(nsMapiRecipDesc));
       memset(message->lpOriginator, 0, sizeof(nsMapiRecipDesc));
--- a/mailnews/mime/src/mimemsg.cpp
+++ b/mailnews/mime/src/mimemsg.cpp
@@ -510,17 +510,17 @@ MimeMessage_close_headers (MimeObject *o
   // setting up truncated message html fotter function
   char *xmoz = MimeHeaders_get(msg->hdrs, HEADER_X_MOZILLA_STATUS, PR_FALSE,
                  PR_FALSE);
   if (xmoz)
   {
     PRUint32 flags = 0;
     char dummy = 0;
     if (sscanf(xmoz, " %lx %c", &flags, &dummy) == 1 &&
-      flags & MSG_FLAG_PARTIAL)
+      flags & nsMsgMessageFlags::Partial)
     {
       obj->options->html_closure = obj;
       obj->options->generate_footer_html_fn =
         MimeMessage_partial_message_html;
     }
     PR_FREEIF(xmoz);
   }
   }
--- a/mailnews/news/src/nsNNTPNewsgroupList.cpp
+++ b/mailnews/news/src/nsNNTPNewsgroupList.cpp
@@ -564,21 +564,21 @@ nsNNTPNewsgroupList::ParseLine(char *lin
     const char *subject = line;  /* #### const evilness */
     PRUint32 subjectLen = strlen(line);
 
     PRUint32 flags = 0;
     // ### should call IsHeaderRead here...
     /* strip "Re: " */
     nsCString modifiedSubject;
     if (NS_MsgStripRE(&subject, &subjectLen, getter_Copies(modifiedSubject)))
-      (void) newMsgHdr->OrFlags(MSG_FLAG_HAS_RE, &flags);
+      (void) newMsgHdr->OrFlags(nsMsgMessageFlags::HasRe, &flags);
     
     // this will make sure read flags agree with newsrc
-    if (! (flags & MSG_FLAG_READ))
-      rv = newMsgHdr->OrFlags(MSG_FLAG_NEW, &flags);
+    if (! (flags & nsMsgMessageFlags::Read))
+      rv = newMsgHdr->OrFlags(nsMsgMessageFlags::New, &flags);
 
     rv = newMsgHdr->SetSubject(modifiedSubject.IsEmpty() ? subject : modifiedSubject.get());
 
     if (NS_FAILED(rv))
       return rv;
   }
 
   GET_TOKEN (); /* author */
@@ -686,28 +686,28 @@ NS_IMETHODIMP nsNNTPNewsgroupList::Apply
       {
       case nsMsgFilterAction::Delete:
         m_addHdrToDB = PR_FALSE;
         break;
       case nsMsgFilterAction::MarkRead:
         m_newsDB->MarkHdrRead(m_newMsgHdr, PR_TRUE, nsnull);
         break;
       case nsMsgFilterAction::KillThread:
-        m_newMsgHdr->SetUint32Property("ProtoThreadFlags", MSG_FLAG_IGNORED);
+        m_newMsgHdr->SetUint32Property("ProtoThreadFlags", nsMsgMessageFlags::Ignored);
         break;
       case nsMsgFilterAction::KillSubthread:
         {
           PRUint32 newFlags;
-          m_newMsgHdr->OrFlags(MSG_FLAG_IGNORED, &newFlags);
+          m_newMsgHdr->OrFlags(nsMsgMessageFlags::Ignored, &newFlags);
         }
         break;
       case nsMsgFilterAction::WatchThread:
         {
           PRUint32 newFlags;
-          m_newMsgHdr->OrFlags(MSG_FLAG_WATCHED, &newFlags);
+          m_newMsgHdr->OrFlags(nsMsgMessageFlags::Watched, &newFlags);
         }
         break;
       case nsMsgFilterAction::MarkFlagged:
         m_newMsgHdr->MarkFlagged(PR_TRUE);
         break;
       case nsMsgFilterAction::ChangePriority:
         {
           nsMsgPriorityValue filterPriority;
@@ -1086,20 +1086,20 @@ nsNNTPNewsgroupList::AddHeader(const cha
     PRUint32 subjectLen = strlen(value);
 
     PRUint32 flags = 0;
     // ### should call IsHeaderRead here...
     /* strip "Re: " */
     nsCString modifiedSubject;
     if (NS_MsgStripRE(&subject, &subjectLen, getter_Copies(modifiedSubject)))
       // this will make sure read flags agree with newsrc
-     (void) m_newMsgHdr->OrFlags(MSG_FLAG_HAS_RE, &flags);
+     (void) m_newMsgHdr->OrFlags(nsMsgMessageFlags::HasRe, &flags);
 
-    if (! (flags & MSG_FLAG_READ))
-      rv = m_newMsgHdr->OrFlags(MSG_FLAG_NEW, &flags);
+    if (! (flags & nsMsgMessageFlags::Read))
+      rv = m_newMsgHdr->OrFlags(nsMsgMessageFlags::New, &flags);
 
     rv = m_newMsgHdr->SetSubject(modifiedSubject.IsEmpty() ? subject :
       modifiedSubject.get());
   }
   else if (PL_strcmp(header, "message-id") == 0)
   {
     rv = m_newMsgHdr->SetMessageId(value);
   }
--- a/mailnews/news/src/nsNewsDownloader.cpp
+++ b/mailnews/news/src/nsNewsDownloader.cpp
@@ -162,17 +162,17 @@ PRBool DownloadNewsArticlesToOfflineStor
   while (NS_SUCCEEDED(rv = m_headerEnumerator->HasMoreElements(&hasMore)) && hasMore)
   {
     nsCOMPtr <nsISupports> supports;
     rv = m_headerEnumerator->GetNext(getter_AddRefs(supports));
     m_newsHeader = do_QueryInterface(supports);
     NS_ENSURE_SUCCESS(rv,rv);
     PRUint32 hdrFlags;
     m_newsHeader->GetFlags(&hdrFlags);
-    if (hdrFlags & MSG_FLAG_MARKED)
+    if (hdrFlags & nsMsgMessageFlags::Marked)
     {
       m_newsHeader->GetMessageKey(&m_keyToDownload);
       break;
     }
     else
     {
       m_newsHeader = nsnull;
     }
@@ -290,17 +290,17 @@ int DownloadNewsArticlesToOfflineStore::
 NS_IMETHODIMP nsNewsDownloader::OnSearchHit(nsIMsgDBHdr *header, nsIMsgFolder *folder)
 {
   NS_ENSURE_ARG(header);
 
 
   PRUint32 msgFlags;
   header->GetFlags(&msgFlags);
   // only need to download articles we don't already have...
-  if (! (msgFlags & MSG_FLAG_OFFLINE))
+  if (! (msgFlags & nsMsgMessageFlags::Offline))
   {
     nsMsgKey key;
     header->GetMessageKey(&key);
     m_keysToDownload.AppendElement(key);
   }
   return NS_OK;
 }
 
@@ -583,24 +583,24 @@ nsresult nsMsgDownloadAllNewsgroups::Dow
 
   rv = searchSession->CreateTerm(getter_AddRefs(term));
   NS_ENSURE_SUCCESS(rv, rv);
   term->GetValue(getter_AddRefs(value));
 
   if (downloadUnreadOnly)
   {
     value->SetAttrib(nsMsgSearchAttrib::MsgStatus);
-    value->SetStatus(MSG_FLAG_READ);
+    value->SetStatus(nsMsgMessageFlags::Read);
     searchSession->AddSearchTerm(nsMsgSearchAttrib::MsgStatus, nsMsgSearchOp::Isnt, value, PR_TRUE, nsnull);
   }
   if (downloadByDate)
   {
     value->SetAttrib(nsMsgSearchAttrib::AgeInDays);
     value->SetAge(ageLimitOfMsgsToDownload);
     searchSession->AddSearchTerm(nsMsgSearchAttrib::AgeInDays, nsMsgSearchOp::IsLessThan, value, nsMsgSearchBooleanOp::BooleanAND, nsnull);
   }
   value->SetAttrib(nsMsgSearchAttrib::MsgStatus);
-  value->SetStatus(MSG_FLAG_OFFLINE);
+  value->SetStatus(nsMsgMessageFlags::Offline);
   searchSession->AddSearchTerm(nsMsgSearchAttrib::MsgStatus, nsMsgSearchOp::Isnt, value, nsMsgSearchBooleanOp::BooleanAND, nsnull);
 
   m_downloaderForGroup->RunSearch(m_currentFolder, db, searchSession);
   return rv;
 }