Part of fix for bug 45225. Due to new AppleDouble implementation, remove old code. SR=mscott

This commit is contained in:
ducarroz%netscape.com 2001-02-07 06:52:30 +00:00
Родитель b95556a906
Коммит b02cf25223
11 изменённых файлов: 39 добавлений и 152 удалений

Двоичные данные
mailnews/base/macbuild/msgCore.mcp

Двоичный файл не отображается.

Двоичные данные
mailnews/base/macbuild/msgCoreIDL.mcp

Двоичный файл не отображается.

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

@ -78,7 +78,6 @@ XPIDLSRCS = \
nsIMsgViewNavigationService.idl \
nsIMsgPrintEngine.idl \
nsISubscribableServer.idl \
nsISaveMsgListener.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

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

@ -63,7 +63,6 @@ XPIDLSRCS = \
.\nsIMsgViewNavigationService.idl \
.\nsIMsgPrintEngine.idl \
.\nsISubscribableServer.idl \
.\nsISaveMsgListener.idl \
$(NULL)
################################################################################

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

@ -76,11 +76,6 @@
#include "nsIMsgStatusFeedback.h"
#include "nsMsgRDFUtils.h"
#include "nsISaveMsgListener.h"
#ifdef XP_MAC
#include "nsDecodeAppleFile.h"
#endif
// compose
#include "nsMsgCompCID.h"
#include "nsMsgI18N.h"
@ -189,8 +184,7 @@ ConvertBufToPlainText(nsString &aConBuf)
//
class nsSaveAllAttachmentsState;
class nsSaveMsgListener : public nsISaveMsgListener,
public nsIUrlListener,
class nsSaveMsgListener : public nsIUrlListener,
public nsIMsgCopyServiceListener,
public nsIStreamListener
{
@ -200,7 +194,6 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_NSISAVEMSGLISTENER
NS_DECL_NSIURLLISTENER
NS_DECL_NSIMSGCOPYSERVICELISTENER
NS_DECL_NSISTREAMLISTENER
@ -219,12 +212,6 @@ public:
nsString m_charset;
nsString m_outputFormat;
nsString m_msgBuffer;
private:
#ifdef XP_MAC
//For Mac attachment handling
ProcessAppleDoubleResourceFork *m_processADRsrcFk;
#endif
};
class nsSaveAllAttachmentsState
@ -1502,10 +1489,6 @@ nsSaveMsgListener::nsSaveMsgListener(nsIFileSpec* aSpec, nsMessenger *aMessenger
// rhp: for charset handling
m_doCharsetConversion = PR_FALSE;
m_saveAllAttachmentsState = nsnull;
#ifdef XP_MAC
m_processADRsrcFk = nsnull;
#endif
}
nsSaveMsgListener::~nsSaveMsgListener()
@ -1515,8 +1498,7 @@ nsSaveMsgListener::~nsSaveMsgListener()
//
// nsISupports
//
NS_IMPL_ISUPPORTS4(nsSaveMsgListener, nsISaveMsgListener, nsIUrlListener,
nsIMsgCopyServiceListener, nsIStreamListener)
NS_IMPL_ISUPPORTS3(nsSaveMsgListener, nsIUrlListener, nsIMsgCopyServiceListener, nsIStreamListener)
//
// nsIUrlListener
@ -1658,16 +1640,6 @@ nsSaveMsgListener::OnStopRequest(nsIChannel* aChannel, nsISupports* aSupport,
if ( (NS_SUCCEEDED(rv)) && (conBuf) )
{
PRUint32 writeCount;
#ifdef XP_MAC
if (m_processADRsrcFk)
{
if (noErr == m_processADRsrcFk->Write((unsigned char *)conBuf, conLength, &writeCount))
rv = NS_OK;
else
rv = NS_ERROR_FAILURE;
}
else
#endif
rv = m_outputStream->Write(conBuf, conLength, &writeCount);
if (conLength != writeCount)
rv = NS_ERROR_FAILURE;
@ -1677,13 +1649,6 @@ nsSaveMsgListener::OnStopRequest(nsIChannel* aChannel, nsISupports* aSupport,
}
// close down the file stream and release ourself
#ifdef XP_MAC
if (m_processADRsrcFk)
{
delete m_processADRsrcFk;
m_processADRsrcFk = nsnull;
}
#endif
if (m_fileSpec)
{
m_fileSpec->Flush();
@ -1789,19 +1754,7 @@ nsSaveMsgListener::OnDataAvailable(nsIChannel* aChannel,
m_msgBuffer.AppendWithConversion(m_dataBuffer, readCount);
}
else
{
#ifdef XP_MAC
if (m_processADRsrcFk)
{
if (noErr == m_processADRsrcFk->Write((unsigned char *)m_dataBuffer, readCount, &writeCount))
rv = NS_OK;
else
rv = NS_ERROR_FAILURE;
}
else
#endif
rv = m_outputStream->Write(m_dataBuffer, readCount, &writeCount);
}
available -= readCount;
}
@ -1810,61 +1763,6 @@ nsSaveMsgListener::OnDataAvailable(nsIChannel* aChannel,
return rv;
}
NS_IMETHODIMP
nsSaveMsgListener::SetMacTypeAndCreator(PRUint32 type, PRUint32 creator)
{
#ifdef XP_MAC
if (m_fileSpec)
{
nsFileSpec realSpec;
m_fileSpec->GetFileSpec(&realSpec);
realSpec.SetFileTypeAndCreator((OSType)type, (OSType)creator);
}
#endif
return NS_OK;
}
NS_IMETHODIMP
nsSaveMsgListener::OnStartAppleDoubleDataFork()
{
#ifdef XP_MAC
if (m_processADRsrcFk)
{
delete m_processADRsrcFk;
m_processADRsrcFk = nsnull;
}
#endif
return NS_OK;
}
NS_IMETHODIMP
nsSaveMsgListener::OnStartAppleDoubleResourceFork()
{
#ifdef XP_MAC
if (m_fileSpec)
{
nsFileSpec realSpec;
m_fileSpec->GetFileSpec(&realSpec);
if (m_processADRsrcFk)
return NS_ERROR_FAILURE;
OSErr anErr = -1;
m_processADRsrcFk = new ProcessAppleDoubleResourceFork;
if (m_processADRsrcFk)
anErr = m_processADRsrcFk->Initialize(realSpec);
if (anErr != noErr)
return NS_ERROR_FAILURE;
}
#endif
return NS_OK;
}
#define MESSENGER_STRING_URL "chrome://messenger/locale/messenger.properties"
nsresult

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

@ -57,8 +57,6 @@
PRBool
nsMsgIsMacFile(char *aUrlString)
{
Boolean returnValue = PR_FALSE;
nsAutoString urlStr; urlStr.AssignWithConversion(aUrlString);
char *ext = nsMsgGetExtensionFromFileURL(urlStr);
if ( (!ext) || (!*ext) )

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

@ -403,7 +403,7 @@ FetcherURLDoneCallback(nsIURI* aURL, nsresult aStatus,
if (aContentType)
{
//Do not change the type if we are dealing with an apple double file
if (!ma->mAppleFileSpec || PL_strcasecmp(aContentType, APPLICATION_BINHEX))
if (!ma->mAppleFileSpec)
{
PR_FREEIF(ma->m_type);
ma->m_type = PL_strdup(aContentType);

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

@ -66,8 +66,6 @@
#include "mimeebod.h"
#include "nsISaveMsgListener.h"
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
@ -776,6 +774,10 @@ mime_output_fn(char *buf, PRInt32 size, void *stream_closure)
if ( (!msd->pluginObj2) && (!msd->output_emitter) )
return -1;
// Fire pending start request
((nsStreamConverter*)msd->pluginObj2)->FirePendingStartRequest();
// Now, write to the WriteBody method if this is a message body and not
// a part retrevial
if (!msd->options->part_to_load)
@ -1016,20 +1018,6 @@ mime_output_init_fn (const char *type,
{
struct mime_stream_data *msd = (struct mime_stream_data *) stream_closure;
#ifdef XP_MAC
if (msd && msd->output_emitter)
{
nsCOMPtr<nsIStreamListener> outputListener;
msd->output_emitter->GetOutputListener(getter_AddRefs(outputListener));
nsCOMPtr<nsISaveMsgListener> saveListener(do_QueryInterface(outputListener));
if (saveListener)
{
saveListener->SetMacTypeAndCreator(mime_convert_chars_to_ostype(x_mac_type),
mime_convert_chars_to_ostype(x_mac_creator));
}
}
#endif
// Now, all of this stream creation is done outside of libmime, so this
// is just a check of the pluginObj member and returning accordingly.
if (!msd->pluginObj2)

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

@ -29,7 +29,6 @@
#include "prio.h"
#include "nsMimeStringResources.h"
#include "nsMimeTypes.h"
#include "nsISaveMsgListener.h"
#ifdef XP_MAC
extern MimeObjectClass mimeMultipartAppleDoubleClass;
@ -385,30 +384,12 @@ MimeMultipart_create_child(MimeObject *obj)
status = body->clazz->parse_begin(body);
#ifdef XP_MAC
/* if we are saving an apple double attachment, we need to inform the output stream listener
which fork we are currently processing
*/
/* if we are saving an apple double attachment, we need to set correctly the conten type of the channel */
if (mime_typep(obj, (MimeObjectClass *) &mimeMultipartAppleDoubleClass))
{
struct mime_stream_data *msd = (struct mime_stream_data *)body->options->stream_closure;
if (msd && msd->output_emitter)
{
nsCOMPtr<nsIStreamListener> outputListener;
msd->output_emitter->GetOutputListener(getter_AddRefs(outputListener));
nsCOMPtr<nsISaveMsgListener> saveListener(do_QueryInterface(outputListener));
if (saveListener)
{
if (body->content_type && !nsCRT::strcasecmp(body->content_type, APPLICATION_APPLEFILE))
saveListener->OnStartAppleDoubleResourceFork();
else
{
/* before start writting the data fork, we mush flush the emitter buffer */
msd->output_emitter->Complete();
saveListener->OnStartAppleDoubleDataFork();
}
}
}
if (!body->options->write_html_p && body->content_type && !nsCRT::strcasecmp(body->content_type, APPLICATION_APPLEFILE))
msd->channel->SetContentType(APPLICATION_APPLEFILE);
}
#endif

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

@ -512,6 +512,9 @@ nsStreamConverter::nsStreamConverter()
mMimeStreamConverterListener = nsnull;
mForwardInline = PR_FALSE;
mDesiredOutputType = nsnull;
mPendingChannel = nsnull;
mPendingContext = nsnull;
}
nsStreamConverter::~nsStreamConverter()
@ -841,6 +844,7 @@ char *output = "\
PR_snprintf(outBuf, sizeof(outBuf), output, url, url);
PR_FREEIF(url);
if (mEmitter)
mEmitter->Write(outBuf, nsCRT::strlen(outBuf), &written);
mTotalRead += written;
@ -904,9 +908,17 @@ nsStreamConverter::OnStartRequest(nsIChannel * aChannel, nsISupports *ctxt)
aChannel->SetContentType(contentType);
}
// forward the start rquest to any listeners
// forward the start request to any listeners
if (mOutListener)
mOutListener->OnStartRequest(aChannel, ctxt);
if (mOutputType == nsMimeOutput::nsMimeMessageRaw)
{
//we need to delay the on start request until we have figure out the real content type
mPendingChannel = aChannel;
mPendingContext = ctxt;
}
else
mOutListener->OnStartRequest(aChannel, ctxt);
return NS_OK;
}
@ -1062,3 +1074,12 @@ NS_IMETHODIMP nsStreamConverter::AsyncConvertData(const PRUnichar *aFromType, co
return Init(aUri, aListener, aChannel);
}
NS_IMETHODIMP nsStreamConverter::FirePendingStartRequest()
{
if (mPendingChannel && mOutListener)
{
mOutListener->OnStartRequest(mPendingChannel, mPendingContext);
mPendingChannel = nsnull;
mPendingContext = nsnull;
}
}

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

@ -60,6 +60,7 @@ public:
NS_IMETHOD GetContentType(char **aOutputContentType);
NS_IMETHOD InternalCleanup(void);
NS_IMETHOD DetermineOutputFormat(const char *url, nsMimeOutputType *newType);
NS_IMETHOD FirePendingStartRequest(void);
private:
nsresult Close();
@ -69,7 +70,7 @@ private:
nsCOMPtr<nsIInputStream> mInputStream;
nsCOMPtr<nsIStreamListener> mOutListener; // output stream listener
nsCOMPtr<nsIChannel> mOutgoingChannel;
nsCOMPtr<nsIChannel> mOutgoingChannel;
nsCOMPtr<nsIMimeEmitter> mEmitter; // emitter being used...
nsCOMPtr<nsIURI> mURI; // URI being processed
@ -89,11 +90,13 @@ private:
PRBool mDoneParsing; // If this is true, we've already been told by libmime to stop sending
// data so don't feed the parser any more!
nsIMimeStreamConverterListener* mMimeStreamConverterListener;
PRBool mForwardInline;
nsCOMPtr<nsIMsgIdentity> mIdentity;
PRBool mForwardInline;
nsCOMPtr<nsIMsgIdentity> mIdentity;
#ifdef DEBUG_mscott
PRTime mConvertContentTime;
#endif
nsIChannel * mPendingChannel; //Will be use whenn we need to delay to fire onStartRequest
nsISupports * mPendingContext; //Will be use whenn we need to delay to fire onStartRequest
};
#endif /* nsStreamConverter_h_ */