Bug 806760: Update message size in DB on all successful whole message downloads r=rkent sr=Standard8 a=Standard8
authorIrving Reid <irving@mozilla.com>
Mon, 12 Nov 2012 11:32:26 -0500
changeset 13553 9e078e25d4751c4e7b5e15dab42bff6c0015b327
parent 13552 6ac7d8c3e2f02eaa6ac2f1dd2b804b4945f83c7a
child 13554 c1fdb2e0b3242d8472112b99c802960185bd1146
child 13556 588b5b98f12c088fef1e2d85f40e184de24ee383
push id3
push userbugzilla@standard8.plus.com
push dateFri, 16 Nov 2012 10:54:06 +0000
reviewersrkent, Standard8, Standard8
bugs806760
Bug 806760: Update message size in DB on all successful whole message downloads r=rkent sr=Standard8 a=Standard8
mailnews/base/util/nsMsgDBFolder.cpp
mailnews/imap/src/nsImapProtocol.cpp
mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp
--- a/mailnews/base/util/nsMsgDBFolder.cpp
+++ b/mailnews/base/util/nsMsgDBFolder.cpp
@@ -1727,16 +1727,18 @@ nsresult nsMsgDBFolder::EndNewOfflineMes
        m_tempMessageStream = nullptr;
 #ifdef _DEBUG
        nsCAutoString message("Offline message too small: messageSize=");
        message.AppendInt(messageSize);
        message.Append(" curStorePos=");
        message.AppendInt(curStorePos);
        message.Append(" numOfflineMsgLines=");
        message.AppendInt(m_numOfflineMsgLines);
+       message.Append(" bytesAdded=");
+       message.AppendInt(m_bytesAddedToLocalMsg);
        NS_ERROR(message.get());
 #endif
        m_offlineHeader = nullptr;
        return NS_ERROR_FAILURE;
     }
     else
       m_offlineHeader->SetLineCount(m_numOfflineMsgLines);
 #ifdef _DEBUG
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -1598,20 +1598,20 @@ bool nsImapProtocol::ProcessCurrentURL()
       {
         if (!DeathSignalReceived() && NS_SUCCEEDED(GetConnectionStatus()))
           AlertUserEventUsingId(IMAP_SERVER_NOT_IMAP4);
 
         SetConnectionStatus(NS_ERROR_FAILURE);        // stop netlib
       }
       else
       {
-        if (m_connectionType.Equals("starttls")
-            && (m_socketType == nsMsgSocketType::trySTARTTLS
-            && (GetServerStateParser().GetCapabilityFlag() & kHasStartTLSCapability))
-          || m_socketType == nsMsgSocketType::alwaysSTARTTLS)
+        if ((m_connectionType.Equals("starttls")
+             && (m_socketType == nsMsgSocketType::trySTARTTLS
+             && (GetServerStateParser().GetCapabilityFlag() & kHasStartTLSCapability)))
+            || m_socketType == nsMsgSocketType::alwaysSTARTTLS)
         {
           StartTLS();
           if (GetServerStateParser().LastCommandSuccessful())
           {
             nsCOMPtr<nsISupports> secInfo;
             nsCOMPtr<nsISocketTransport> strans = do_QueryInterface(m_transport, &rv);
             if (NS_FAILED(rv))
               return false;
@@ -2573,16 +2573,29 @@ void nsImapProtocol::ProcessSelectedStat
               // Some times when we're NOT allowed:  when forwarding a message, saving it, moving it, etc.
               // need to set a flag in the url, I guess, equiv to allow_content_changed.
               bool allowedToBreakApart = true; // (ce  && !DeathSignalReceived()) ? ce->URL_s->allow_content_change : false;
               bool mimePartSelectorDetected;
               bool urlOKToFetchByParts = false;
               m_runningUrl->GetMimePartSelectorDetected(&mimePartSelectorDetected);
               m_runningUrl->GetFetchPartsOnDemand(&urlOKToFetchByParts);
 
+#ifdef PR_LOGGING
+              {
+                nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningUrl);
+                nsCAutoString urlSpec;
+                if (mailnewsurl)
+                  mailnewsurl->GetSpec(urlSpec);
+                PR_LOG(IMAP, PR_LOG_DEBUG,
+                       ("SHELL: URL %s, OKToFetchByParts %d, allowedToBreakApart %d, ShouldFetchAllParts %d",
+                        urlSpec.get(), urlOKToFetchByParts, allowedToBreakApart,
+                        GetShouldFetchAllParts()));
+              }
+#endif
+
               if (urlOKToFetchByParts &&
                   allowedToBreakApart &&
                   !GetShouldFetchAllParts() &&
                   GetServerStateParser().ServerHasIMAP4Rev1Capability() /* &&
                 !mimePartSelectorDetected */)  // if a ?part=, don't do BS.
               {
                 // OK, we're doing bodystructure
 
@@ -3791,23 +3804,23 @@ void nsImapProtocol::HandleMessageDownLo
       {
         endOfLine[0] = MSG_LINEBREAK[0]; // CR or LF
         endOfLine[1] = '\0';
         lineLength++;
       }
     }
     else  // enforce canonical CRLF linebreaks
     {
-      if (lineLength==0 || lineLength == 1 && cEndOfLine[-1] == '\n')
+      if (lineLength==0 || (lineLength == 1 && cEndOfLine[-1] == '\n'))
       {
         messageLine = CRLF;
         lineLength = 2;
       }
       else if (cEndOfLine[-1] != '\n' || cEndOfLine[-2] != '\r' ||
-               lineLength >=3 && cEndOfLine[-3] == '\r')
+               (lineLength >=3 && cEndOfLine[-3] == '\r'))
       {
         // The line does not end in CRLF (or it ends in CRCRLF).
         // Copy line and leave enough room for two more chars (CR and LF).
         localMessageLine = (char *) PR_MALLOC(lineLength + 3);
         if (!localMessageLine) // memory failure
             return;
         PL_strcpy(localMessageLine, line);
         char *endOfLine = localMessageLine + lineLength;
@@ -3913,26 +3926,25 @@ void nsImapProtocol::NormalMessageEndDow
       m_hdrDownloadCache->ResetAll();
     }
   }
   FlushDownloadCache();
 
   if (!GetServerStateParser().GetDownloadingHeaders())
   {
     int32_t updatedMessageSize = -1;
-    if (m_fetchingWholeMessage &&
-        (m_bytesToChannel != GetServerStateParser().SizeOfMostRecentMessage()))
+    if (m_fetchingWholeMessage)
     {
       updatedMessageSize = m_bytesToChannel;
-#ifdef DEBUG
-      nsCAutoString message("Server's RFC822.SIZE ");
-      message.AppendInt(GetServerStateParser().SizeOfMostRecentMessage());
-      message += " actual size ";
-      message.AppendInt(m_bytesToChannel);
-      NS_WARNING(message.get());
+#ifdef PR_LOGGING
+      if (m_bytesToChannel != GetServerStateParser().SizeOfMostRecentMessage()) {
+        PR_LOG(IMAP, PR_LOG_DEBUG, ("STREAM:CLOSE Server's RFC822.SIZE %u, actual size %u",
+                                    GetServerStateParser().SizeOfMostRecentMessage(),
+                                    m_bytesToChannel));
+      }
 #endif
     }
     // need to know if we're downloading for display or not. We'll use action == nsImapMsgFetch for now
     nsImapAction imapAction = nsIImapUrl::nsImapSelectFolder; // just set it to some legal value
     if (m_runningUrl)
       m_runningUrl->GetImapAction(&imapAction);
 
     if (m_imapMessageSink)
--- a/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp
+++ b/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp
@@ -433,17 +433,17 @@ nsMimeBaseEmitter::Write(const nsACStrin
   nsresult rv = NS_OK;
   uint32_t            needToWrite;
 
 #ifdef DEBUG_BenB
   // If you want to see libmime output...
   printf("%s", buf);
 #endif
 
-  PR_LOG(gMimeEmitterLogModule, PR_LOG_ALWAYS, (PromiseFlatCString(buf).get()));
+  PR_LOG(gMimeEmitterLogModule, PR_LOG_ALWAYS, ("%s", PromiseFlatCString(buf).get()));
   //
   // Make sure that the buffer we are "pushing" into has enough room
   // for the write operation. If not, we have to buffer, return, and get
   // it on the next time through
   //
   *amountWritten = 0;
 
   needToWrite = mBufferMgr->GetSize();