Bug #9593 --> make the old display code turn into save msg to disk code

This commit is contained in:
mscott%netscape.com 1999-09-14 05:34:54 +00:00
Родитель 36e025a0cd
Коммит 1b540788e4
3 изменённых файлов: 38 добавлений и 28 удалений

Просмотреть файл

@ -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<nsISupports> 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<nsISupports> aSupport;
m_tempMessageStream->Close();
}
nsCOMPtr<nsIMsgDBHdr> msgHdr;
m_curMsgUid = uidOfMessage;

Просмотреть файл

@ -326,7 +326,6 @@ protected:
// part of temporary libmime converstion trick......these should go away once MIME uses a new stream
// converter interface...
nsCOMPtr<nsIOutputStream> m_tempMessageStream;
nsFileSpec m_tempMsgFileSpec;
// *** jt - undo move/copy trasaction support
nsCOMPtr<nsITransactionManager> m_transactionManager;

Просмотреть файл

@ -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<nsIFileSpec> fileSpec;
PRBool addDummyEnvelope = PR_TRUE;
nsCOMPtr<nsIMsgMessageUrl> 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());