diff --git a/mailnews/imap/src/nsImapMailFolder.cpp b/mailnews/imap/src/nsImapMailFolder.cpp index 37bad0d0383a..151e5c7c5675 100644 --- a/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mailnews/imap/src/nsImapMailFolder.cpp @@ -92,8 +92,6 @@ nsImapMailFolder::nsImapMailFolder() : pEventQService->GetThreadEventQueue(PR_GetCurrentThread(), getter_AddRefs(m_eventQueue)); m_moveCoalescer = nsnull; - m_tempMsgFileSpec = nsSpecialSystemDirectory(nsSpecialSystemDirectory::OS_TemporaryDirectory); - m_tempMsgFileSpec += "tempMessage.eml"; } @@ -2219,16 +2217,17 @@ void nsImapMailFolder::TweakHeaderFlags(nsIImapProtocol* aProtocol, nsIMsgDBHdr } NS_IMETHODIMP -nsImapMailFolder::SetupMsgWriteStream() +//nsImapMailFolder::SetupMsgWriteStream(nsIFileSpec * aFileSpec, PRBool addDummyEnvelope) +nsImapMailFolder::SetupMsgWriteStream(const char * aNativeString, PRBool addDummyEnvelope) { - // create a temp file to write the message into. We need to do this because - // we don't have pluggable converters yet. We want to let mkfile do the work of - // converting the message from RFC-822 to HTML before displaying it... - m_tempMsgFileSpec.Delete(PR_FALSE); - nsISupports * supports; - NS_NewIOFileStream(&supports, m_tempMsgFileSpec, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 00700); +// if (!aFileSpec) +// return NS_ERROR_NULL_POINTER; + nsFileSpec fileSpec (aNativeString); +// aFileSpec->GetFileSpec(&fileSpec); + fileSpec.Delete(PR_FALSE); + nsCOMPtr supports; + NS_NewIOFileStream(getter_AddRefs(supports), fileSpec, PR_WRONLY | PR_CREATE_FILE | PR_TRUNCATE, 00700); m_tempMessageStream = do_QueryInterface(supports); - NS_IF_RELEASE(supports); return NS_OK; } @@ -2250,11 +2249,8 @@ nsImapMailFolder::NormalEndMsgWriteStream(nsMsgKey uidOfMessage) { nsresult res = NS_OK; if (m_tempMessageStream) - { - nsCOMPtr aSupport; m_tempMessageStream->Close(); - } nsCOMPtr msgHdr; m_curMsgUid = uidOfMessage; diff --git a/mailnews/imap/src/nsImapMailFolder.h b/mailnews/imap/src/nsImapMailFolder.h index 17e1c4d43f72..eacb3dce28eb 100644 --- a/mailnews/imap/src/nsImapMailFolder.h +++ b/mailnews/imap/src/nsImapMailFolder.h @@ -326,7 +326,6 @@ protected: // part of temporary libmime converstion trick......these should go away once MIME uses a new stream // converter interface... nsCOMPtr m_tempMessageStream; - nsFileSpec m_tempMsgFileSpec; // *** jt - undo move/copy trasaction support nsCOMPtr m_transactionManager; diff --git a/mailnews/imap/src/nsImapProtocol.cpp b/mailnews/imap/src/nsImapProtocol.cpp index 7b034c77ce3f..ce14832d162d 100644 --- a/mailnews/imap/src/nsImapProtocol.cpp +++ b/mailnews/imap/src/nsImapProtocol.cpp @@ -1366,7 +1366,6 @@ char *nsImapProtocol::GetServerCommandTag() void nsImapProtocol::ProcessSelectedStateURL() { char *mailboxName = nsnull; - nsIImapUrl::nsImapAction imapAction; PRBool bMessageIdsAreUids = PR_TRUE; imapMessageFlagsType msgFlags = 0; const char *hostName = GetImapHostName(); @@ -1374,7 +1373,7 @@ void nsImapProtocol::ProcessSelectedStateURL() // this can't fail, can it? nsresult res; - res = m_runningUrl->GetImapAction(&imapAction); + res = m_runningUrl->GetImapAction(&m_imapAction); m_runningUrl->MessageIdsAreUids(&bMessageIdsAreUids); m_runningUrl->GetMsgFlags(&msgFlags); @@ -1435,7 +1434,7 @@ void nsImapProtocol::ProcessSelectedStateURL() PRBool uidValidityOk = PR_TRUE; if (GetServerStateParser().LastCommandSuccessful() && selectIssued && - (imapAction != nsIImapUrl::nsImapSelectFolder) && (imapAction != nsIImapUrl::nsImapLiteSelectFolder)) + (m_imapAction != nsIImapUrl::nsImapSelectFolder) && (m_imapAction != nsIImapUrl::nsImapLiteSelectFolder)) { uid_validity_info *uidStruct = (uid_validity_info *) PR_Malloc(sizeof(uid_validity_info)); if (uidStruct) @@ -1464,10 +1463,10 @@ void nsImapProtocol::ProcessSelectedStateURL() HandleMemoryFailure(); } - if (GetServerStateParser().LastCommandSuccessful() && !DeathSignalReceived() && (uidValidityOk || imapAction == nsIImapUrl::nsImapDeleteAllMsgs)) + if (GetServerStateParser().LastCommandSuccessful() && !DeathSignalReceived() && (uidValidityOk || m_imapAction == nsIImapUrl::nsImapDeleteAllMsgs)) { - switch (imapAction) + switch (m_imapAction) { case nsIImapUrl::nsImapLiteSelectFolder: if (GetServerStateParser().LastCommandSuccessful() && m_imapMiscellaneousSink) @@ -1479,6 +1478,7 @@ void nsImapProtocol::ProcessSelectedStateURL() ProcessMailboxUpdate(PR_FALSE); // handle uidvalidity change } break; + case nsIImapUrl::nsImapSaveMessageToDisk: case nsIImapUrl::nsImapMsgFetch: { nsCString messageIdString; @@ -1768,7 +1768,7 @@ void nsImapProtocol::ProcessSelectedStateURL() if (destinationMailbox) { - if (imapAction == nsIImapUrl::nsImapOnlineMove) + if (m_imapAction == nsIImapUrl::nsImapOnlineMove) { if (HandlingMultipleMessages(messageIdString)) ProgressEventFunctionUsingIdWithString (IMAP_MOVING_MESSAGES_TO, destinationMailbox); @@ -1794,7 +1794,7 @@ void nsImapProtocol::ProcessSelectedStateURL() m_imapMessageSink->OnlineCopyReport(copyState); if (GetServerStateParser().LastCommandSuccessful() && - (imapAction == nsIImapUrl::nsImapOnlineMove)) + (m_imapAction == nsIImapUrl::nsImapOnlineMove)) { Store(messageIdString, "+FLAGS (\\Deleted)", bMessageIdsAreUids); @@ -1942,9 +1942,20 @@ void nsImapProtocol::BeginMessageDownLoad( // is consuming the message display nsresult rv = NS_NewPipe(getter_AddRefs(m_channelInputStream), getter_AddRefs(m_channelOutputStream)); } - else if (m_imapMessageSink) + // else, if we are saving the message to disk! + else if (m_imapMessageSink /* && m_imapAction == nsIImapUrl::nsImapSaveMessageToDisk */) { - m_imapMessageSink->SetupMsgWriteStream(); + nsCOMPtr fileSpec; + PRBool addDummyEnvelope = PR_TRUE; + nsCOMPtr msgurl = do_QueryInterface(m_runningUrl); + msgurl->GetMessageFile(getter_AddRefs(fileSpec)); + msgurl->GetAddDummyEnvelope(&addDummyEnvelope); + +// m_imapMessageSink->SetupMsgWriteStream(fileSpec, addDummyEnvelope); + nsXPIDLCString nativePath; + fileSpec->GetNativePath(getter_Copies(nativePath)); + m_imapMessageSink->SetupMsgWriteStream(nativePath, addDummyEnvelope); + } PL_strfree(si->content_type); } @@ -2678,12 +2689,16 @@ void nsImapProtocol::NormalMessageEndDownload() if (m_imapMailFolderSink) m_imapMailFolderSink->NormalEndHeaderParseStream(this); } - else if (m_channelListener) + else { - PRUint32 inlength = 0; - m_channelInputStream->Available(&inlength); - if (inlength > 0) // broadcast our batched up ODA changes - m_channelListener->OnDataAvailable(m_mockChannel, m_channelContext, m_channelInputStream, 0, inlength); + if (m_channelListener) + { + PRUint32 inlength = 0; + m_channelInputStream->Available(&inlength); + if (inlength > 0) // broadcast our batched up ODA changes + m_channelListener->OnDataAvailable(m_mockChannel, m_channelContext, m_channelInputStream, 0, inlength); + } + // need to know if we're downloading for display or not. if (m_imapMessageSink) m_imapMessageSink->NormalEndMsgWriteStream(m_downloadLineCache.CurrentUID());