Bug #81352 --> when saving an attachment to disk, be sure to apply the bin hex

decoder for windows and unix platforms if appropriate.
r=ducarroz
sr=sspitzer
This commit is contained in:
mscott%netscape.com 2001-06-28 01:20:04 +00:00
Родитель e1c1c8e3c0
Коммит 0813dc8ec2
1 изменённых файлов: 26 добавлений и 12 удалений

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

@ -214,7 +214,7 @@ public:
nsString m_outputFormat; nsString m_outputFormat;
nsString m_msgBuffer; nsString m_msgBuffer;
nsString m_contentType; // used only when saving attachment nsCString m_contentType; // used only when saving attachment
}; };
class nsSaveAllAttachmentsState class nsSaveAllAttachmentsState
@ -559,7 +559,7 @@ nsMessenger::SaveAttachment(nsIFileSpec * fileSpec,
} }
NS_ADDREF(aListener); NS_ADDREF(aListener);
aListener->m_contentType.AssignWithConversion(contentType); aListener->m_contentType = contentType;
if (saveState) if (saveState)
aListener->m_saveAllAttachmentsState = saveState; aListener->m_saveAllAttachmentsState = saveState;
@ -589,13 +589,29 @@ nsMessenger::SaveAttachment(nsIFileSpec * fileSpec,
messageUri = fullMessageUri.get(); messageUri = fullMessageUri.get();
} }
nsCOMPtr<nsISupports> consumer; nsCOMPtr<nsIStreamListener> convertedListener;
aListener->QueryInterface(NS_GET_IID(nsISupports), aListener->QueryInterface(NS_GET_IID(nsIStreamListener),
getter_AddRefs(consumer)); getter_AddRefs(convertedListener));
#ifndef XP_MAC
// if the content type is bin hex we are going to do a hokey hack and make sure we decode the bin hex
// when saving an attachment to disk..
if (contentType && !nsCRT::strcasecmp(APPLICATION_BINHEX, contentType))
{
nsCOMPtr<nsIStreamListener> listener (do_QueryInterface(convertedListener));
nsCOMPtr<nsIStreamConverterService> streamConverterService = do_GetService(kIStreamConverterServiceCID, &rv);
nsCOMPtr<nsISupports> channelSupport = do_QueryInterface(aListener->m_channel);
rv = streamConverterService->AsyncConvertData(NS_ConvertASCIItoUCS2(APPLICATION_BINHEX).GetUnicode(),
NS_LITERAL_STRING("*/*").get(),
listener,
channelSupport,
getter_AddRefs(convertedListener));
}
#endif
if (fetchService) if (fetchService)
rv = fetchService->FetchMimePart(aURL, messageUri, consumer, mMsgWindow, nsnull,nsnull); rv = fetchService->FetchMimePart(aURL, messageUri, convertedListener, mMsgWindow, nsnull,nsnull);
else else
rv = messageService->DisplayMessage(messageUri, consumer, mMsgWindow,nsnull, nsnull, nsnull); rv = messageService->DisplayMessage(messageUri, convertedListener, mMsgWindow,nsnull, nsnull, nsnull);
if (messageService) if (messageService)
ReleaseMessageServiceFromURI(unescapedUrl, messageService); ReleaseMessageServiceFromURI(unescapedUrl, messageService);
@ -1583,10 +1599,9 @@ nsSaveMsgListener::OnStartRequest(nsIRequest* request, nsISupports* aSupport)
#ifdef XP_MAC #ifdef XP_MAC
/* On Mac, if we are saving an appledouble or applesingle attachment, we need to use an Apple File Decoder */ /* On Mac, if we are saving an appledouble or applesingle attachment, we need to use an Apple File Decoder */
char * contentType = m_contentType.ToNewCString(); if (!m_contentType.IsEmpty())
if (contentType && *contentType) if ((nsCRT::strcasecmp(m_contentType.get(), APPLICATION_APPLEFILE) == 0) ||
if ((nsCRT::strcasecmp(contentType, APPLICATION_APPLEFILE) == 0) || (nsCRT::strcasecmp(m_contentType.get(), MULTIPART_APPLEDOUBLE) == 0))
(nsCRT::strcasecmp(contentType, MULTIPART_APPLEDOUBLE) == 0))
{ {
/* ggrrrrr, I have a nsFileSpec but I need a nsILocalFile... */ /* ggrrrrr, I have a nsFileSpec but I need a nsILocalFile... */
nsCOMPtr<nsILocalFile> outputFile; nsCOMPtr<nsILocalFile> outputFile;
@ -1602,7 +1617,6 @@ nsSaveMsgListener::OnStartRequest(nsIRequest* request, nsISupports* aSupport)
m_outputStream = do_QueryInterface(appleFileDecoder, &rv); m_outputStream = do_QueryInterface(appleFileDecoder, &rv);
} }
} }
CRTFREEIF(contentType);
#endif #endif
return rv; return rv;