From f4147f10d0657f86e23efd83a1185a09af7fb0a3 Mon Sep 17 00:00:00 2001 From: "dbaron%fas.harvard.edu" Date: Fri, 13 Jul 2001 18:34:42 +0000 Subject: [PATCH] Changing CRLF line endings to LF to fix IRIX bustage. --- mailnews/imap/src/nsImapMailFolder.cpp | 14 +- mailnews/imap/src/nsImapMailFolder.h | 2 +- mailnews/imap/src/nsImapOfflineSync.cpp | 86 ++++----- mailnews/imap/src/nsImapOfflineSync.h | 4 +- mailnews/imap/src/nsImapProtocol.cpp | 12 +- mailnews/imap/src/nsImapService.cpp | 240 ++++++++++++------------ 6 files changed, 179 insertions(+), 179 deletions(-) diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index e1d048ddd35..ff57e21b863 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -2050,7 +2050,7 @@ NS_IMETHODIMP nsImapMailFolder::GetNewMessages(nsIMsgWindow *aWindow, nsIUrlList if (NS_SUCCEEDED(rv) && imapServer) imapServer->GetDownloadBodiesOnGetNewMail(&m_downloadingFolderForOfflineUse); - inbox->SetGettingNewMessages(PR_TRUE); + inbox->SetGettingNewMessages(PR_TRUE); m_urlListener = aListener; rv = imapService->SelectFolder(eventQ, inbox, this, aWindow, nsnull); @@ -3944,12 +3944,12 @@ nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode) // Only send the OnStopCopy notification if we have no copy state (which means we're doing an online // move/copy, and have cleared the copy state above) or if we've finished the move/copy // of multiple imap messages, one msg at a time (i.e., moving to a local folder). - if (listener && sendEndCopyNotification) - listener->OnStopCopy(aExitCode); - if (m_urlListener) - { - m_urlListener->OnStopRunningUrl(aUrl, aExitCode); - m_urlListener = nsnull; + if (listener && sendEndCopyNotification) + listener->OnStopCopy(aExitCode); + if (m_urlListener) + { + m_urlListener->OnStopRunningUrl(aUrl, aExitCode); + m_urlListener = nsnull; } return rv; } diff --git a/mailnews/imap/src/nsImapMailFolder.h b/mailnews/imap/src/nsImapMailFolder.h index 6d407b4a3a6..517796c1cef 100644 --- a/mailnews/imap/src/nsImapMailFolder.h +++ b/mailnews/imap/src/nsImapMailFolder.h @@ -358,7 +358,7 @@ protected: nsMsgKey m_curMsgUid; PRUint32 m_uidValidity; PRInt32 m_nextMessageByteLength; - nsCOMPtr m_eventQueue; + nsCOMPtr m_eventQueue; nsCOMPtr m_urlListener; PRBool m_urlRunning; diff --git a/mailnews/imap/src/nsImapOfflineSync.cpp b/mailnews/imap/src/nsImapOfflineSync.cpp index 2cddb19b69f..5e6bb4308bd 100644 --- a/mailnews/imap/src/nsImapOfflineSync.cpp +++ b/mailnews/imap/src/nsImapOfflineSync.cpp @@ -47,7 +47,7 @@ nsImapOfflineSync::nsImapOfflineSync(nsIMsgWindow *window, nsIUrlListener *liste m_window->SetStopped(PR_FALSE); mCurrentPlaybackOpType = nsIMsgOfflineImapOperation::kFlagsChanged; - m_mailboxupdatesStarted = PR_FALSE; + m_mailboxupdatesStarted = PR_FALSE; m_mailboxupdatesFinished = PR_FALSE; m_createdOfflineFolders = PR_FALSE; m_pseudoOffline = PR_FALSE; @@ -859,48 +859,48 @@ nsImapOfflineDownloader::~nsImapOfflineDownloader() nsresult nsImapOfflineDownloader::ProcessNextOperation() { nsresult rv = NS_OK; - if (!m_mailboxupdatesStarted) - { - m_mailboxupdatesStarted = PR_TRUE; - // Update the INBOX first so the updates on the remaining - // folders pickup the results of any filter moves. - NS_WITH_SERVICE(nsIMsgAccountManager, accountManager, kMsgAccountManagerCID, &rv); - if (NS_FAILED(rv)) return rv; - nsCOMPtr servers; - - rv = accountManager->GetAllServers(getter_AddRefs(servers)); - if (NS_FAILED(rv)) return rv; - } - if (!m_mailboxupdatesFinished) - { - AdvanceToNextServer(); - if (m_currentServer) - { - nsCOMPtr rootFolder; - m_currentServer->GetRootFolder(getter_AddRefs(rootFolder)); - nsCOMPtr inbox; - if (rootFolder) - { - nsCOMPtr rootMsgFolder = do_QueryInterface(rootFolder, &rv); - if (rootMsgFolder) - { - PRUint32 numFolders; - rootMsgFolder->GetFoldersWithFlag(MSG_FOLDER_FLAG_INBOX, 1, &numFolders, getter_AddRefs(inbox)); - if (inbox) - return inbox->GetNewMessages(m_window, this); - } - } - else - return ProcessNextOperation(); // recurse and do next server. - } - else - { - m_allServers = nsnull; - m_mailboxupdatesFinished = PR_TRUE; - } - } - AdvanceToNextFolder(); - + if (!m_mailboxupdatesStarted) + { + m_mailboxupdatesStarted = PR_TRUE; + // Update the INBOX first so the updates on the remaining + // folders pickup the results of any filter moves. + NS_WITH_SERVICE(nsIMsgAccountManager, accountManager, kMsgAccountManagerCID, &rv); + if (NS_FAILED(rv)) return rv; + nsCOMPtr servers; + + rv = accountManager->GetAllServers(getter_AddRefs(servers)); + if (NS_FAILED(rv)) return rv; + } + if (!m_mailboxupdatesFinished) + { + AdvanceToNextServer(); + if (m_currentServer) + { + nsCOMPtr rootFolder; + m_currentServer->GetRootFolder(getter_AddRefs(rootFolder)); + nsCOMPtr inbox; + if (rootFolder) + { + nsCOMPtr rootMsgFolder = do_QueryInterface(rootFolder, &rv); + if (rootMsgFolder) + { + PRUint32 numFolders; + rootMsgFolder->GetFoldersWithFlag(MSG_FOLDER_FLAG_INBOX, 1, &numFolders, getter_AddRefs(inbox)); + if (inbox) + return inbox->GetNewMessages(m_window, this); + } + } + else + return ProcessNextOperation(); // recurse and do next server. + } + else + { + m_allServers = nsnull; + m_mailboxupdatesFinished = PR_TRUE; + } + } + AdvanceToNextFolder(); + while (m_currentFolder) { PRUint32 folderFlags; diff --git a/mailnews/imap/src/nsImapOfflineSync.h b/mailnews/imap/src/nsImapOfflineSync.h index 321d590e942..8d9cc889fdf 100644 --- a/mailnews/imap/src/nsImapOfflineSync.h +++ b/mailnews/imap/src/nsImapOfflineSync.h @@ -69,7 +69,7 @@ protected: nsCOMPtr m_allFolders; nsCOMPtr m_currentServer; nsCOMPtr m_serverEnumerator; - nsCOMPtr m_curTempFile; + nsCOMPtr m_curTempFile; nsMsgKeyArray m_CurrentKeys; PRUint32 m_KeyIndex; @@ -77,7 +77,7 @@ protected: nsCOMPtr m_listener; PRInt32 mCurrentUIDValidity; PRInt32 mCurrentPlaybackOpType; // kFlagsChanged -> kMsgCopy -> kMsgMoved - PRBool m_mailboxupdatesStarted; + PRBool m_mailboxupdatesStarted; PRBool m_mailboxupdatesFinished; PRBool m_pseudoOffline; // for queueing online events in offline db PRBool m_createdOfflineFolders; diff --git a/mailnews/imap/src/nsImapProtocol.cpp b/mailnews/imap/src/nsImapProtocol.cpp index e1581d0ca12..4e3e5f68d59 100644 --- a/mailnews/imap/src/nsImapProtocol.cpp +++ b/mailnews/imap/src/nsImapProtocol.cpp @@ -4706,7 +4706,7 @@ void nsImapProtocol::UploadMessageFromFile (nsIFileSpec* fileSpec, IncrementCommandTagNumber(); PRUint32 fileSize = 0; - PRInt32 totalSize; + PRInt32 totalSize; PRUint32 readCount; char *dataBuffer = nsnull; nsCString command(GetServerCommandTag()); @@ -4718,10 +4718,10 @@ void nsImapProtocol::UploadMessageFromFile (nsIFileSpec* fileSpec, PRBool hasLiteralPlus = (GetServerStateParser().GetCapabilityFlag() & kLiteralPlusCapability); - nsCOMPtr fileInputStream; - + nsCOMPtr fileInputStream; + if (escapedName) - { + { command.Append(" append \""); command.Append(escapedName); command.Append("\" ("); @@ -4834,8 +4834,8 @@ void nsImapProtocol::UploadMessageFromFile (nsIFileSpec* fileSpec, } } done: - PR_FREEIF(dataBuffer); - fileSpec->CloseStream(); + PR_FREEIF(dataBuffer); + fileSpec->CloseStream(); nsMemory::Free(escapedName); } diff --git a/mailnews/imap/src/nsImapService.cpp b/mailnews/imap/src/nsImapService.cpp index f449121630c..e452e1848eb 100644 --- a/mailnews/imap/src/nsImapService.cpp +++ b/mailnews/imap/src/nsImapService.cpp @@ -62,13 +62,13 @@ #include "nsICacheService.h" #include "nsNetCID.h" #include "nsMsgUtf7Utils.h" -#include "nsIOutputStream.h" -#include "nsIInputStream.h" -#include "nsICopyMsgStreamListener.h" -#include "nsIFileStream.h" -#include "nsIMsgParseMailMsgState.h" -#include "nsMsgLineBuffer.h" -#include "nsMsgLocalCID.h" +#include "nsIOutputStream.h" +#include "nsIInputStream.h" +#include "nsICopyMsgStreamListener.h" +#include "nsIFileStream.h" +#include "nsIMsgParseMailMsgState.h" +#include "nsMsgLineBuffer.h" +#include "nsMsgLocalCID.h" #define PREF_MAIL_ROOT_IMAP "mail.root.imap" @@ -1888,114 +1888,114 @@ nsImapService::OnlineMessageCopy(nsIEventQueue* aClientEventQueue, } return rv; } - -nsresult nsImapService::OfflineAppendFromFile(nsIFileSpec* aFileSpec, - nsIURI *aUrl, - nsIMsgFolder* aDstFolder, - const char* messageId, // te be replaced - PRBool inSelectedState, // needs to be in - nsIUrlListener* aListener, - nsIURI** aURL, - nsISupports* aCopyState) -{ - nsCOMPtr destDB; - nsresult rv = aDstFolder->GetMsgDatabase(nsnull, getter_AddRefs(destDB)); - // ### might need to send some notifications instead of just returning - - if (NS_SUCCEEDED(rv) && destDB) - { - nsMsgKey fakeKey; - destDB->GetNextFakeOfflineMsgKey(&fakeKey); - - nsCOMPtr op; - rv = destDB->GetOfflineOpForKey(fakeKey, PR_TRUE, getter_AddRefs(op)); - if (NS_SUCCEEDED(rv) && op) - { - nsXPIDLCString destFolderUri; - - aDstFolder->GetURI(getter_Copies(destFolderUri)); - op->SetOperation(nsIMsgOfflineImapOperation::kAppendDraft); // ### do we care if it's a template? - op->SetDestinationFolderURI(destFolderUri); - nsCOMPtr offlineStore; - rv = aDstFolder->GetOfflineStoreOutputStream(getter_AddRefs(offlineStore)); - - if (NS_SUCCEEDED(rv) && offlineStore) - { - PRInt32 curOfflineStorePos = 0; - nsCOMPtr randomStore = do_QueryInterface(offlineStore); - if (randomStore) - randomStore->Tell(&curOfflineStorePos); - else - { - NS_ASSERTION(PR_FALSE, "needs to be a random store!"); - return NS_ERROR_FAILURE; - } - - - nsCOMPtr inputStream; - nsCOMPtr msgParser = do_CreateInstance(NS_PARSEMAILMSGSTATE_CONTRACTID, &rv); - msgParser->SetMailDB(destDB); - - if (NS_SUCCEEDED(rv)) - rv = aFileSpec->GetInputStream(getter_AddRefs(inputStream)); - if (NS_SUCCEEDED(rv) && inputStream) - { - // now, copy the temp file to the offline store for the dest folder. - PRInt32 inputBufferSize = 10240; - nsMsgLineStreamBuffer *inputStreamBuffer = new nsMsgLineStreamBuffer(inputBufferSize, CRLF, PR_TRUE /* allocate new lines */, PR_FALSE /* leave CRLFs on the returned string */); - PRUint32 fileSize; - aFileSpec->GetFileSize(&fileSize); - PRUint32 bytesWritten; - rv = NS_OK; -// rv = inputStream->Read(inputBuffer, inputBufferSize, &bytesRead); -// if (NS_SUCCEEDED(rv) && bytesRead > 0) - msgParser->SetState(nsIMsgParseMailMsgState::ParseHeadersState); - // set the env pos to fake key so the msg hdr will have that for a key - msgParser->SetEnvelopePos(fakeKey); - PRBool needMoreData = PR_FALSE; - char * newLine = nsnull; - PRUint32 numBytesInLine = 0; - do - { - newLine = inputStreamBuffer->ReadNextLine(inputStream, numBytesInLine, needMoreData); - if (newLine) - { - msgParser->ParseAFolderLine(newLine, numBytesInLine); - rv = offlineStore->Write(newLine, numBytesInLine, &bytesWritten); - nsCRT::free(newLine); - } - } - while (newLine); - nsCOMPtr fakeHdr; - - msgParser->FinishHeader(); - msgParser->GetNewMsgHdr(getter_AddRefs(fakeHdr)); - if (fakeHdr) - { - if (NS_SUCCEEDED(rv) && fakeHdr) - { - PRUint32 resultFlags; - fakeHdr->SetMessageOffset(curOfflineStorePos); - fakeHdr->OrFlags(MSG_FLAG_OFFLINE | MSG_FLAG_READ, &resultFlags); - fakeHdr->SetOfflineMessageSize(fileSize); - destDB->AddNewHdrToDB(fakeHdr, PR_TRUE /* notify */); - aDstFolder->SetFlag(MSG_FOLDER_FLAG_OFFLINEEVENTS); - } - } - // tell the listener we're done. - aListener->OnStopRunningUrl(aUrl, NS_OK); - delete inputStreamBuffer; - } - } - } - } - - - if (destDB) - destDB->Close(PR_TRUE); - return rv; -} - + +nsresult nsImapService::OfflineAppendFromFile(nsIFileSpec* aFileSpec, + nsIURI *aUrl, + nsIMsgFolder* aDstFolder, + const char* messageId, // te be replaced + PRBool inSelectedState, // needs to be in + nsIUrlListener* aListener, + nsIURI** aURL, + nsISupports* aCopyState) +{ + nsCOMPtr destDB; + nsresult rv = aDstFolder->GetMsgDatabase(nsnull, getter_AddRefs(destDB)); + // ### might need to send some notifications instead of just returning + + if (NS_SUCCEEDED(rv) && destDB) + { + nsMsgKey fakeKey; + destDB->GetNextFakeOfflineMsgKey(&fakeKey); + + nsCOMPtr op; + rv = destDB->GetOfflineOpForKey(fakeKey, PR_TRUE, getter_AddRefs(op)); + if (NS_SUCCEEDED(rv) && op) + { + nsXPIDLCString destFolderUri; + + aDstFolder->GetURI(getter_Copies(destFolderUri)); + op->SetOperation(nsIMsgOfflineImapOperation::kAppendDraft); // ### do we care if it's a template? + op->SetDestinationFolderURI(destFolderUri); + nsCOMPtr offlineStore; + rv = aDstFolder->GetOfflineStoreOutputStream(getter_AddRefs(offlineStore)); + + if (NS_SUCCEEDED(rv) && offlineStore) + { + PRInt32 curOfflineStorePos = 0; + nsCOMPtr randomStore = do_QueryInterface(offlineStore); + if (randomStore) + randomStore->Tell(&curOfflineStorePos); + else + { + NS_ASSERTION(PR_FALSE, "needs to be a random store!"); + return NS_ERROR_FAILURE; + } + + + nsCOMPtr inputStream; + nsCOMPtr msgParser = do_CreateInstance(NS_PARSEMAILMSGSTATE_CONTRACTID, &rv); + msgParser->SetMailDB(destDB); + + if (NS_SUCCEEDED(rv)) + rv = aFileSpec->GetInputStream(getter_AddRefs(inputStream)); + if (NS_SUCCEEDED(rv) && inputStream) + { + // now, copy the temp file to the offline store for the dest folder. + PRInt32 inputBufferSize = 10240; + nsMsgLineStreamBuffer *inputStreamBuffer = new nsMsgLineStreamBuffer(inputBufferSize, CRLF, PR_TRUE /* allocate new lines */, PR_FALSE /* leave CRLFs on the returned string */); + PRUint32 fileSize; + aFileSpec->GetFileSize(&fileSize); + PRUint32 bytesWritten; + rv = NS_OK; +// rv = inputStream->Read(inputBuffer, inputBufferSize, &bytesRead); +// if (NS_SUCCEEDED(rv) && bytesRead > 0) + msgParser->SetState(nsIMsgParseMailMsgState::ParseHeadersState); + // set the env pos to fake key so the msg hdr will have that for a key + msgParser->SetEnvelopePos(fakeKey); + PRBool needMoreData = PR_FALSE; + char * newLine = nsnull; + PRUint32 numBytesInLine = 0; + do + { + newLine = inputStreamBuffer->ReadNextLine(inputStream, numBytesInLine, needMoreData); + if (newLine) + { + msgParser->ParseAFolderLine(newLine, numBytesInLine); + rv = offlineStore->Write(newLine, numBytesInLine, &bytesWritten); + nsCRT::free(newLine); + } + } + while (newLine); + nsCOMPtr fakeHdr; + + msgParser->FinishHeader(); + msgParser->GetNewMsgHdr(getter_AddRefs(fakeHdr)); + if (fakeHdr) + { + if (NS_SUCCEEDED(rv) && fakeHdr) + { + PRUint32 resultFlags; + fakeHdr->SetMessageOffset(curOfflineStorePos); + fakeHdr->OrFlags(MSG_FLAG_OFFLINE | MSG_FLAG_READ, &resultFlags); + fakeHdr->SetOfflineMessageSize(fileSize); + destDB->AddNewHdrToDB(fakeHdr, PR_TRUE /* notify */); + aDstFolder->SetFlag(MSG_FOLDER_FLAG_OFFLINEEVENTS); + } + } + // tell the listener we're done. + aListener->OnStopRunningUrl(aUrl, NS_OK); + delete inputStreamBuffer; + } + } + } + } + + + if (destDB) + destDB->Close(PR_TRUE); + return rv; +} + /* append message from file url */ /* imap://HOST>appendmsgfromfile>DESTINATIONMAILBOXPATH */ /* imap://HOST>appenddraftfromfile>DESTINATIONMAILBOXPATH>UID>messageId */ @@ -2051,11 +2051,11 @@ nsImapService::AppendMessageFromFile(nsIEventQueue* aClientEventQueue, } rv = uri->SetSpec(urlSpec.get()); - if (WeAreOffline()) - { - return OfflineAppendFromFile(aFileSpec, uri, aDstFolder, messageId, inSelectedState, aListener, aURL, aCopyState); - // handle offline append to drafts or templates folder here. - } + if (WeAreOffline()) + { + return OfflineAppendFromFile(aFileSpec, uri, aDstFolder, messageId, inSelectedState, aListener, aURL, aCopyState); + // handle offline append to drafts or templates folder here. + } if (NS_SUCCEEDED(rv)) rv = GetImapConnectionAndLoadUrl(aClientEventQueue, imapUrl, nsnull, aURL);