Fix for bug 22090. Implement Appledouble (encoding & decoding). R=sspitzer, R=sfraser, SR=bienvenu.
This commit is contained in:
Родитель
d298691348
Коммит
5d2c02072f
Двоичные данные
mailnews/base/macbuild/msgCore.mcp
Двоичные данные
mailnews/base/macbuild/msgCore.mcp
Двоичный файл не отображается.
Двоичные данные
mailnews/base/macbuild/msgCoreIDL.mcp
Двоичные данные
mailnews/base/macbuild/msgCoreIDL.mcp
Двоичный файл не отображается.
|
@ -78,6 +78,7 @@ XPIDLSRCS = \
|
|||
nsIMsgViewNavigationService.idl \
|
||||
nsIMsgPrintEngine.idl \
|
||||
nsISubscribableServer.idl \
|
||||
nsISaveMsgListener.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
|
@ -63,6 +63,7 @@ XPIDLSRCS = \
|
|||
.\nsIMsgViewNavigationService.idl \
|
||||
.\nsIMsgPrintEngine.idl \
|
||||
.\nsISubscribableServer.idl \
|
||||
.\nsISaveMsgListener.idl \
|
||||
$(NULL)
|
||||
|
||||
################################################################################
|
||||
|
|
|
@ -76,6 +76,11 @@
|
|||
#include "nsIMsgStatusFeedback.h"
|
||||
#include "nsMsgRDFUtils.h"
|
||||
|
||||
#include "nsISaveMsgListener.h"
|
||||
#ifdef XP_MAC
|
||||
#include "nsDecodeAppleFile.h"
|
||||
#endif
|
||||
|
||||
// compose
|
||||
#include "nsMsgCompCID.h"
|
||||
#include "nsMsgI18N.h"
|
||||
|
@ -184,16 +189,18 @@ ConvertBufToPlainText(nsString &aConBuf)
|
|||
//
|
||||
class nsSaveAllAttachmentsState;
|
||||
|
||||
class nsSaveAsListener : public nsIUrlListener,
|
||||
public nsIMsgCopyServiceListener,
|
||||
public nsIStreamListener
|
||||
class nsSaveMsgListener : public nsISaveMsgListener,
|
||||
public nsIUrlListener,
|
||||
public nsIMsgCopyServiceListener,
|
||||
public nsIStreamListener
|
||||
{
|
||||
public:
|
||||
nsSaveAsListener(nsIFileSpec* fileSpec, nsMessenger* aMessenger);
|
||||
virtual ~nsSaveAsListener();
|
||||
nsSaveMsgListener(nsIFileSpec* fileSpec, nsMessenger* aMessenger);
|
||||
virtual ~nsSaveMsgListener();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSISAVEMSGLISTENER
|
||||
NS_DECL_NSIURLLISTENER
|
||||
NS_DECL_NSIMSGCOPYSERVICELISTENER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
|
@ -212,6 +219,12 @@ public:
|
|||
nsString m_charset;
|
||||
nsString m_outputFormat;
|
||||
nsString m_msgBuffer;
|
||||
|
||||
private:
|
||||
#ifdef XP_MAC
|
||||
//For Mac attachment handling
|
||||
ProcessAppleDoubleResourceFork *m_processADRsrcFk;
|
||||
#endif
|
||||
};
|
||||
|
||||
class nsSaveAllAttachmentsState
|
||||
|
@ -536,7 +549,7 @@ nsMessenger::SaveAttachment(nsIFileSpec * fileSpec,
|
|||
void *closure)
|
||||
{
|
||||
nsIMsgMessageService * messageService = nsnull;
|
||||
nsSaveAsListener *aListener = nsnull;
|
||||
nsSaveMsgListener *aListener = nsnull;
|
||||
nsSaveAllAttachmentsState *saveState= (nsSaveAllAttachmentsState*) closure;
|
||||
nsAutoString from, to;
|
||||
nsCOMPtr<nsISupports> channelSupport;
|
||||
|
@ -553,7 +566,7 @@ nsMessenger::SaveAttachment(nsIFileSpec * fileSpec,
|
|||
kIStreamConverterServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
aListener = new nsSaveAsListener(fileSpec, this);
|
||||
aListener = new nsSaveMsgListener(fileSpec, this);
|
||||
if (!aListener)
|
||||
{
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -784,7 +797,7 @@ nsMessenger::SaveAs(const char* url, PRBool asFile, nsIMsgIdentity* identity, ns
|
|||
nsIMsgMessageService* messageService = nsnull;
|
||||
nsAutoString defaultFile(NS_ConvertASCIItoUCS2("mail"));
|
||||
nsCOMPtr<nsIUrlListener> urlListener;
|
||||
nsSaveAsListener *aListener = nsnull;
|
||||
nsSaveMsgListener *aListener = nsnull;
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
nsAutoString urlString;
|
||||
char *urlCString = nsnull;
|
||||
|
@ -858,7 +871,7 @@ nsMessenger::SaveAs(const char* url, PRBool asFile, nsIMsgIdentity* identity, ns
|
|||
if (NS_FAILED(rv)) goto done;
|
||||
fileSpec->SetNativePath(path);
|
||||
|
||||
aListener = new nsSaveAsListener(fileSpec, this);
|
||||
aListener = new nsSaveMsgListener(fileSpec, this);
|
||||
if (!aListener) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
goto done;
|
||||
|
@ -934,7 +947,7 @@ nsMessenger::SaveAs(const char* url, PRBool asFile, nsIMsgIdentity* identity, ns
|
|||
rv = NS_NewFileSpecWithSpec(tmpFileSpec, getter_AddRefs(fileSpec));
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
aListener = new nsSaveAsListener(fileSpec, this);
|
||||
aListener = new nsSaveMsgListener(fileSpec, this);
|
||||
if (!aListener) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
goto done;
|
||||
|
@ -1455,7 +1468,7 @@ NS_IMETHODIMP nsMessenger::DoPrintPreview()
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsSaveAsListener::nsSaveAsListener(nsIFileSpec* aSpec, nsMessenger *aMessenger)
|
||||
nsSaveMsgListener::nsSaveMsgListener(nsIFileSpec* aSpec, nsMessenger *aMessenger)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
if (aSpec)
|
||||
|
@ -1466,29 +1479,33 @@ nsSaveAsListener::nsSaveAsListener(nsIFileSpec* aSpec, nsMessenger *aMessenger)
|
|||
// rhp: for charset handling
|
||||
m_doCharsetConversion = PR_FALSE;
|
||||
m_saveAllAttachmentsState = nsnull;
|
||||
|
||||
#ifdef XP_MAC
|
||||
m_processADRsrcFk = nsnull;
|
||||
#endif
|
||||
}
|
||||
|
||||
nsSaveAsListener::~nsSaveAsListener()
|
||||
nsSaveMsgListener::~nsSaveMsgListener()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// nsISupports
|
||||
//
|
||||
NS_IMPL_ISUPPORTS3(nsSaveAsListener, nsIUrlListener,
|
||||
NS_IMPL_ISUPPORTS4(nsSaveMsgListener, nsISaveMsgListener, nsIUrlListener,
|
||||
nsIMsgCopyServiceListener, nsIStreamListener)
|
||||
|
||||
//
|
||||
// nsIUrlListener
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsSaveAsListener::OnStartRunningUrl(nsIURI* url)
|
||||
nsSaveMsgListener::OnStartRunningUrl(nsIURI* url)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSaveAsListener::OnStopRunningUrl(nsIURI* url, nsresult exitCode)
|
||||
nsSaveMsgListener::OnStopRunningUrl(nsIURI* url, nsresult exitCode)
|
||||
{
|
||||
nsresult rv = exitCode;
|
||||
PRBool killSelf = PR_TRUE;
|
||||
|
@ -1536,31 +1553,31 @@ done:
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSaveAsListener::OnStartCopy(void)
|
||||
nsSaveMsgListener::OnStartCopy(void)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSaveAsListener::OnProgress(PRUint32 aProgress, PRUint32 aProgressMax)
|
||||
nsSaveMsgListener::OnProgress(PRUint32 aProgress, PRUint32 aProgressMax)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSaveAsListener::SetMessageKey(PRUint32 aKey)
|
||||
nsSaveMsgListener::SetMessageKey(PRUint32 aKey)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSaveAsListener::GetMessageId(nsCString* aMessageId)
|
||||
nsSaveMsgListener::GetMessageId(nsCString* aMessageId)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSaveAsListener::OnStopCopy(nsresult aStatus)
|
||||
nsSaveMsgListener::OnStopCopy(nsresult aStatus)
|
||||
{
|
||||
if (m_fileSpec)
|
||||
{
|
||||
|
@ -1573,7 +1590,7 @@ nsSaveAsListener::OnStopCopy(nsresult aStatus)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSaveAsListener::OnStartRequest(nsIChannel* aChannel, nsISupports* aSupport)
|
||||
nsSaveMsgListener::OnStartRequest(nsIChannel* aChannel, nsISupports* aSupport)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (m_fileSpec)
|
||||
|
@ -1590,7 +1607,7 @@ nsSaveAsListener::OnStartRequest(nsIChannel* aChannel, nsISupports* aSupport)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSaveAsListener::OnStopRequest(nsIChannel* aChannel, nsISupports* aSupport,
|
||||
nsSaveMsgListener::OnStopRequest(nsIChannel* aChannel, nsISupports* aSupport,
|
||||
nsresult status, const PRUnichar* aMsg)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
@ -1618,6 +1635,16 @@ nsSaveAsListener::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;
|
||||
|
@ -1627,6 +1654,13 @@ nsSaveAsListener::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();
|
||||
|
@ -1688,7 +1722,7 @@ nsSaveAsListener::OnStopRequest(nsIChannel* aChannel, nsISupports* aSupport,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSaveAsListener::OnDataAvailable(nsIChannel* aChannel,
|
||||
nsSaveMsgListener::OnDataAvailable(nsIChannel* aChannel,
|
||||
nsISupports* aSupport,
|
||||
nsIInputStream* inStream,
|
||||
PRUint32 srcOffset,
|
||||
|
@ -1733,6 +1767,16 @@ nsSaveAsListener::OnDataAvailable(nsIChannel* aChannel,
|
|||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1743,6 +1787,61 @@ nsSaveAsListener::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
|
||||
|
|
Двоичные данные
mailnews/compose/macbuild/msgCompose.mcp
Двоичные данные
mailnews/compose/macbuild/msgCompose.mcp
Двоичный файл не отображается.
|
@ -30,10 +30,10 @@
|
|||
#ifndef AppleDouble_h
|
||||
#define AppleDouble_h
|
||||
|
||||
#include "xp.h"
|
||||
#include "msgCore.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "nsMsgComposeStringBundle.h"
|
||||
|
||||
|
||||
#define NOERR 0
|
||||
|
@ -45,16 +45,11 @@
|
|||
/* End of a Part. */
|
||||
|
||||
|
||||
#define errMemoryAlloc MK_OUT_OF_MEMORY
|
||||
#define errDataCrupt -1
|
||||
#define errDiskFull MK_DISK_FULL
|
||||
#define errFileOpen MK_UNABLE_TO_OPEN_TMP_FILE
|
||||
|
||||
#define errVersion -1
|
||||
#define errFileWrite MK_MIME_ERROR_WRITING_FILE
|
||||
#define errFileOpen NS_MSG_UNABLE_TO_OPEN_TMP_FILE
|
||||
#define errFileWrite -202 /*Error writing temporary file.*/
|
||||
#define errUsrCancel -2 /*MK_INTERRUPTED */
|
||||
#define errDecoding -1
|
||||
|
||||
#define errUsrCancel MK_INTERRUPTED
|
||||
/*
|
||||
** The envirment block data type.
|
||||
*/
|
||||
|
@ -165,11 +160,6 @@ typedef struct _appledouble_decode_object
|
|||
#endif
|
||||
nsIOFileStream *fileSpec; /* the stream for data fork work. */
|
||||
|
||||
// RICHIE - REMOVE THIS OLD STUFF!!!
|
||||
MWContext *context;
|
||||
NET_StreamClass* binhex_stream; /* the stream to output as binhex output.*/
|
||||
// RICHIE - REMOVE THIS OLD STUFF!!!
|
||||
|
||||
int state;
|
||||
|
||||
int rksize; /* the resource fork size count. */
|
||||
|
|
|
@ -38,11 +38,11 @@
|
|||
#include "nsCExternalHandlerService.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#include "nsIMIMEInfo.h"
|
||||
#include "nsMimeTypes.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
|
||||
#pragma warn_unusedarg off
|
||||
#include "m_cvstrm.h"
|
||||
|
||||
#pragma cplusplus on
|
||||
|
||||
|
@ -59,11 +59,15 @@ nsMsgIsMacFile(char *aUrlString)
|
|||
{
|
||||
Boolean returnValue = PR_FALSE;
|
||||
|
||||
char *ext = nsMsgGetExtensionFromFileURL(nsString(aUrlString));
|
||||
nsAutoString urlStr; urlStr.AssignWithConversion(aUrlString);
|
||||
char *ext = nsMsgGetExtensionFromFileURL(urlStr);
|
||||
if ( (!ext) || (!*ext) )
|
||||
{
|
||||
PR_FREEIF(ext);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
if (
|
||||
PRBool isMacFile =
|
||||
(!PL_strcasecmp(ext, "JPG")) ||
|
||||
(!PL_strcasecmp(ext, "GIF")) ||
|
||||
(!PL_strcasecmp(ext, "TIF")) ||
|
||||
|
@ -72,11 +76,11 @@ nsMsgIsMacFile(char *aUrlString)
|
|||
(!PL_strcasecmp(ext, "ART")) ||
|
||||
(!PL_strcasecmp(ext, "XUL")) ||
|
||||
(!PL_strcasecmp(ext, "XML")) ||
|
||||
(!PL_strcasecmp(ext, "XUL"))
|
||||
)
|
||||
return PR_FALSE;
|
||||
else
|
||||
return PR_TRUE;
|
||||
(!PL_strcasecmp(ext, "CSS")) ||
|
||||
(!PL_strcasecmp(ext, "JS"));
|
||||
|
||||
PR_Free(ext);
|
||||
return isMacFile;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -29,15 +29,13 @@
|
|||
|
||||
#include "nscore.h"
|
||||
#include "msgCore.h"
|
||||
#include "nsMimeTypes.h"
|
||||
|
||||
#include "nsMsgAppleDouble.h"
|
||||
#include "nsMsgAppleCodes.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
|
||||
extern int MK_UNABLE_TO_OPEN_TMP_FILE;
|
||||
extern int MK_MIME_ERROR_WRITING_FILE;
|
||||
|
||||
#include <Errors.h>
|
||||
|
||||
/*
|
||||
|
@ -471,6 +469,9 @@ int ap_encode_data(
|
|||
|
||||
/* don't forget to rewind the index to start point. */
|
||||
SetFPos(fileId, fsFromStart, 0L);
|
||||
/* and reset retVal just in case... */
|
||||
if (retval == eofErr)
|
||||
retval = noErr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
// RICHIE - MAKE SURE THIS IS REMOVED BEFORE CHECKIN!
|
||||
//#define RICHIE_XP_MAC 1
|
||||
|
||||
#include "nsMsgCopy.h"
|
||||
#include "nsIPref.h"
|
||||
|
@ -47,30 +44,14 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// Mac Specific Attachment Handling for AppleDouble Encoded Files
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// The implementation for this (below) is #ifdef RICHIE_XP_MAC.
|
||||
// It is not functional, but we are keeping the code here as a base for
|
||||
// bringing back the functionality.
|
||||
#if 0
|
||||
#include "xp.h" // mac only
|
||||
#include "errors.h"
|
||||
#include "m_cvstrm.h"
|
||||
#include "nsFileStream.h"
|
||||
#ifdef XP_MAC
|
||||
|
||||
#define AD_WORKING_BUFF_SIZE 8192
|
||||
|
||||
|
||||
#ifdef RICHIE_XP_MAC
|
||||
|
||||
extern PRBool nsMsgIsMacFile(char *aUrlString);
|
||||
extern void MacGetFileType(nsFileSpec *fs, PRBool *useDefault, char **type, char **encoding);
|
||||
|
||||
#else
|
||||
|
||||
PRBool nsMsgIsMacFile(char *aUrlString) { return PR_FALSE; }
|
||||
void MacGetFileType(nsFileSpec *fs, PRBool *useDefault, char **type, char **encoding) { *useDefault = PR_TRUE;}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* XP_MAC */
|
||||
|
||||
//
|
||||
|
@ -418,11 +399,17 @@ FetcherURLDoneCallback(nsIURI* aURL, nsresult aStatus,
|
|||
if (ma != nsnull)
|
||||
{
|
||||
ma->m_size = totalSize;
|
||||
#ifdef XP_MAC
|
||||
if (aContentType)
|
||||
{
|
||||
PR_FREEIF(ma->m_type);
|
||||
ma->m_type = PL_strdup(aContentType);
|
||||
//Do not change the type if we are dealing with an apple double file
|
||||
if (!ma->mAppleFileSpec || PL_strcasecmp(aContentType, APPLICATION_BINHEX))
|
||||
{
|
||||
PR_FREEIF(ma->m_type);
|
||||
ma->m_type = PL_strdup(aContentType);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (aCharset)
|
||||
{
|
||||
|
@ -562,26 +549,42 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
|
|||
|
||||
mURL->GetSpec(getter_Copies(url_string));
|
||||
|
||||
#ifdef RICHIE_XP_MAC
|
||||
#ifdef XP_MAC
|
||||
// do we need to add IMAP: to this list? nsMsgIsLocalFileURL returns PR_FALSE always for IMAP
|
||||
if ( (nsMsgIsLocalFile(url_string) &&
|
||||
(PL_strncasecmp(url_string, "mailbox:", 8) != 0)) )
|
||||
{
|
||||
// convert the apple file to AppleDouble first, and then patch the
|
||||
// address in the url.
|
||||
char *src_filename = nsMsgGetLocalFileFromURL (url_string);
|
||||
const char *src_filename = nsMsgGetLocalFileFromURL (url_string);
|
||||
if (!src_filename)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
PRBool isAMacFile = nsMsgIsMacFile(src_filename);
|
||||
//We need to retrieve the file type and creator...
|
||||
nsFileSpec scr_fileSpec(src_filename);
|
||||
FSSpec fsSpec = scr_fileSpec.GetFSSpec();;
|
||||
FInfo info;
|
||||
if (FSpGetFInfo (&fsSpec, &info) == noErr)
|
||||
{
|
||||
char filetype[32];
|
||||
PR_snprintf(filetype, sizeof(filetype), "%X", info.fdType);
|
||||
PR_FREEIF(m_x_mac_type);
|
||||
m_x_mac_type = PL_strdup(filetype);
|
||||
|
||||
PR_snprintf(filetype, sizeof(filetype), "%X", info.fdCreator);
|
||||
PR_FREEIF(m_x_mac_creator);
|
||||
m_x_mac_creator = PL_strdup(filetype);
|
||||
}
|
||||
|
||||
PRBool isAMacFile = nsMsgIsMacFile(url_string);
|
||||
|
||||
// Only use appledouble if we aren't uuencoding.
|
||||
if( isAMacFile && (! UseUUEncode_p()) )
|
||||
{
|
||||
char *separator;
|
||||
nsInputFileStream *myInputFile = new nsInputFileStream(nsFileSpec(src_filename));
|
||||
nsInputFileStream *myInputFile = new nsInputFileStream(scr_fileSpec);
|
||||
|
||||
if ((myInputFile) || (!myInputFile->is_open()))
|
||||
if ((!myInputFile) || (!myInputFile->is_open()))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
separator = mime_make_separator("ad");
|
||||
|
@ -618,7 +621,7 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
|
|||
}
|
||||
|
||||
obj->fileStream = new nsIOFileStream(*mAppleFileSpec, (PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE));
|
||||
if ( (!obj->fileStream) || (obj->fileStream->is_open()) )
|
||||
if ( (!obj->fileStream) || (!obj->fileStream->is_open()) )
|
||||
{
|
||||
delete myInputFile;
|
||||
PR_FREEIF(src_filename);
|
||||
|
@ -656,10 +659,10 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
|
|||
PRInt32 size, count;
|
||||
|
||||
status = noErr;
|
||||
while ( (myInputFile->read(obj->buff, obj->s_buff, &size) > 0) &&
|
||||
(status == noErr || status == errDone) )
|
||||
m_size = 0;
|
||||
while (status == noErr)
|
||||
{
|
||||
status = ap_encode_next(&(obj->ap_encode_obj), obj->buff, size, &count);
|
||||
status = ap_encode_next(&(obj->ap_encode_obj), obj->buff, bSize, &count);
|
||||
if (status == noErr || status == errDone)
|
||||
{
|
||||
//
|
||||
|
@ -711,7 +714,7 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
|
|||
PR_FREEIF(separator);
|
||||
PR_FREEIF (m_type);
|
||||
m_type = PL_strdup(tmp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isAMacFile )
|
||||
|
@ -725,42 +728,24 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
|
|||
printf("...we could ask the user about this conversion, but for now, nahh..\n");
|
||||
}
|
||||
|
||||
/* make sure the file type and create are set. */
|
||||
char filetype[32];
|
||||
FSSpec fsSpec;
|
||||
FInfo info;
|
||||
PRBool useDefault;
|
||||
char *macType, *macEncoding;
|
||||
|
||||
fsSpec = mAppleFileSpec->GetFSSpec();
|
||||
if (FSpGetFInfo (&fsSpec, &info) == noErr)
|
||||
if (m_type == NULL || !PL_strcasecmp (m_type, TEXT_PLAIN))
|
||||
{
|
||||
PR_snprintf(filetype, sizeof(filetype), "%X", info.fdType);
|
||||
PR_FREEIF(m_x_mac_type);
|
||||
m_x_mac_type = PL_strdup(filetype);
|
||||
|
||||
PR_snprintf(filetype, sizeof(filetype), "%X", info.fdCreator);
|
||||
PR_FREEIF(m_x_mac_creator);
|
||||
m_x_mac_creator = PL_strdup(filetype);
|
||||
if (m_type == NULL || !PL_strcasecmp (m_type, TEXT_PLAIN))
|
||||
{
|
||||
# define TEXT_TYPE 0x54455854 /* the characters 'T' 'E' 'X' 'T' */
|
||||
# define text_TYPE 0x74657874 /* the characters 't' 'e' 'x' 't' */
|
||||
|
||||
if (info.fdType != TEXT_TYPE && info.fdType != text_TYPE)
|
||||
{
|
||||
MacGetFileType(mAppleFileSpec, &useDefault, &macType, &macEncoding);
|
||||
PR_FREEIF(m_type);
|
||||
m_type = macType;
|
||||
}
|
||||
if (info.fdType != TEXT_TYPE && info.fdType != text_TYPE)
|
||||
{
|
||||
MacGetFileType(&scr_fileSpec, &useDefault, &macType, &macEncoding);
|
||||
PR_FREEIF(m_type);
|
||||
m_type = macType;
|
||||
}
|
||||
}
|
||||
// don't bother to set the types if we failed in getting the file info.
|
||||
}
|
||||
|
||||
PR_FREEIF(src_filename);
|
||||
PR_FREEIF(src_filename);
|
||||
src_filename = 0;
|
||||
}
|
||||
#endif /* XP_MAC */
|
||||
|
||||
|
|
|
@ -32,9 +32,8 @@
|
|||
// Forward declarations...
|
||||
class nsMsgComposeAndSend;
|
||||
|
||||
#ifdef RICHIE_XP_MAC
|
||||
#ifdef XP_MAC
|
||||
|
||||
#include "nsFileStream.h"
|
||||
#include "nsMsgAppleDouble.h"
|
||||
|
||||
typedef struct _AppledoubleEncodeObject
|
||||
|
|
|
@ -43,12 +43,6 @@
|
|||
#pragma warn_unusedarg off
|
||||
#endif
|
||||
|
||||
extern int MK_MSG_SAVE_DECODED_AS;
|
||||
|
||||
extern int MK_UNABLE_TO_OPEN_TMP_FILE;
|
||||
extern int MK_MIME_ERROR_WRITING_FILE;
|
||||
extern int MK_MIME_DATA_CORRUPTED;
|
||||
|
||||
static char BinHexTable[64] =
|
||||
{
|
||||
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
|
||||
|
@ -504,24 +498,16 @@ static char binhex_decode[256] =
|
|||
** the decode for bin hex format.
|
||||
*/
|
||||
int binhex_decode_init (
|
||||
binhex_decode_object *p_bh_decode_obj,
|
||||
MWContext *context)
|
||||
binhex_decode_object *p_bh_decode_obj)
|
||||
{
|
||||
nsCRT::memset(p_bh_decode_obj, 0, sizeof(binhex_decode_object));
|
||||
|
||||
p_bh_decode_obj->octetin = 26;
|
||||
p_bh_decode_obj->donepos = 3;
|
||||
p_bh_decode_obj->context = context;
|
||||
|
||||
return NOERR;
|
||||
}
|
||||
|
||||
static void
|
||||
simple_copy(MWContext* context, char* newFile, void* closure)
|
||||
{
|
||||
PL_strcpy((char *)closure, newFile);
|
||||
}
|
||||
|
||||
PRIVATE void binhex_process(
|
||||
binhex_decode_object *p_bh_decode_obj)
|
||||
{
|
||||
|
@ -753,14 +739,18 @@ PRIVATE void binhex_process(
|
|||
char* filename;
|
||||
|
||||
filename = XP_ALLOC(1024);
|
||||
if (filename == NULL ||
|
||||
if (filename == NULL
|
||||
/*JFD Do we still need this?
|
||||
||
|
||||
FE_PromptForFileName(p_bh_decode_obj->context,
|
||||
XP_GetString(MK_MSG_SAVE_DECODED_AS),
|
||||
0,
|
||||
FALSE,
|
||||
FALSE,
|
||||
simple_copy,
|
||||
filename) == -1)
|
||||
filename) == -1
|
||||
*/
|
||||
)
|
||||
{
|
||||
FREEIF(filename);
|
||||
p_bh_decode_obj->state = errUsrCancel;
|
||||
|
|
|
@ -128,8 +128,6 @@ typedef struct _binhex_decode_object
|
|||
nsFileSpec *name; /* file spec for the output file in non-mac OS */
|
||||
nsIOFileStream *fileId; /* the file if for the outpur file. non-mac OS */
|
||||
#endif
|
||||
|
||||
MWContext* context; /* context for call back function. */
|
||||
|
||||
int32 s_inbuff; /* the valid size of the inbuff */
|
||||
int32 pos_inbuff; /* the index of the inbuff. */
|
||||
|
@ -167,8 +165,7 @@ int binhex_reencode_head(
|
|||
** The binhex stream decode prototypes.
|
||||
*/
|
||||
|
||||
int binhex_decode_init(binhex_decode_object *p_bh_decode_env,
|
||||
MWContext *context);
|
||||
int binhex_decode_init(binhex_decode_object *p_bh_decode_env);
|
||||
|
||||
int binhex_decode_next(binhex_decode_object *p_bh_decode_env,
|
||||
const char *in_buff,
|
||||
|
|
|
@ -1675,13 +1675,19 @@ nsMsgIsLocalFile(const char *url)
|
|||
char
|
||||
*nsMsgGetLocalFileFromURL(char *url)
|
||||
{
|
||||
char * finalPath;
|
||||
NS_ASSERTION(PL_strncasecmp(url, "file://", 7) == 0, "invalid url");
|
||||
finalPath = (char*)PR_Malloc(strlen(url));
|
||||
if (finalPath == NULL)
|
||||
return NULL;
|
||||
strcpy(finalPath, url+6+1);
|
||||
return finalPath;
|
||||
#ifdef XP_MAC
|
||||
nsFileURL fileURL(url);
|
||||
char * nativePath = fileURL.GetFileSpec().GetNativePathCString();
|
||||
return nsCRT::strdup (nativePath);
|
||||
#else
|
||||
char * finalPath;
|
||||
NS_ASSERTION(PL_strncasecmp(url, "file://", 7) == 0, "invalid url");
|
||||
finalPath = (char*)PR_Malloc(strlen(url));
|
||||
if (finalPath == NULL)
|
||||
return NULL;
|
||||
strcpy(finalPath, url+6+1);
|
||||
return finalPath;
|
||||
#endif
|
||||
}
|
||||
|
||||
char *
|
||||
|
|
|
@ -355,6 +355,7 @@ nsMsgComposeAndSend::Clear()
|
|||
{
|
||||
m_attachments[i].mAppleFileSpec->Delete(PR_FALSE);
|
||||
delete m_attachments[i].mAppleFileSpec;
|
||||
m_attachments[i].mAppleFileSpec = nsnull;
|
||||
}
|
||||
#endif /* XP_MAC */
|
||||
}
|
||||
|
@ -1844,7 +1845,12 @@ nsMsgComposeAndSend::AddCompFieldLocalAttachments()
|
|||
m_attachments[newLoc].m_mime_delivery_state = this;
|
||||
|
||||
// These attachments are already "snarfed"...
|
||||
#ifdef XP_MAC
|
||||
//We need to snarf the file to figure out how to send it...
|
||||
m_attachments[newLoc].m_done = PR_FALSE;
|
||||
#else
|
||||
m_attachments[newLoc].m_done = PR_TRUE;
|
||||
#endif
|
||||
|
||||
if (m_attachments[newLoc].mURL)
|
||||
NS_RELEASE(m_attachments[newLoc].mURL);
|
||||
|
@ -2223,9 +2229,12 @@ nsMsgComposeAndSend::HackAttachments(const nsMsgAttachmentData *attachments,
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if ( (attachments && attachments[0].url) ||
|
||||
(mMultipartRelatedAttachmentCount > 0) ||
|
||||
(mCompFieldRemoteAttachments > 0) )
|
||||
*/
|
||||
if (m_attachment_count > 0)
|
||||
{
|
||||
// If there is more than one mailbox URL, or more than one NNTP url,
|
||||
// do the load in serial rather than parallel, for efficiency.
|
||||
|
|
|
@ -324,6 +324,18 @@ nsMimeBaseEmitter::SetOutputListener(nsIStreamListener *listener)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMimeBaseEmitter::GetOutputListener(nsIStreamListener **listener)
|
||||
{
|
||||
if (listener)
|
||||
{
|
||||
*listener = mOutListener;
|
||||
NS_IF_ADDREF(*listener);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// Attachment handling routines
|
||||
nsresult
|
||||
nsMimeBaseEmitter::StartAttachment(const char *name, const char *contentType, const char *url,
|
||||
|
|
|
@ -41,16 +41,6 @@
|
|||
|
||||
static NS_DEFINE_CID(kCMimeConverterCID, NS_MIME_CONVERTER_CID);
|
||||
|
||||
nsresult NS_NewMimeHtmlDisplayEmitter(const nsIID& iid, void **result)
|
||||
{
|
||||
nsMimeHtmlDisplayEmitter *obj = new nsMimeHtmlDisplayEmitter();
|
||||
if (obj)
|
||||
return obj->QueryInterface(iid, result);
|
||||
else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nsMimeHtmlEmitter definitions....
|
||||
*/
|
||||
|
|
|
@ -72,8 +72,4 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
/* this function will be used by the factory to generate an class access object....*/
|
||||
extern nsresult NS_NewMimeHtmlEmitter(const nsIID& iid, void **result);
|
||||
extern nsresult NS_NewMimeHtmlDisplayEmitter(const nsIID& iid, void **result);
|
||||
|
||||
#endif /* _nsMimeHtmlEmitter_h_ */
|
||||
|
|
|
@ -31,15 +31,6 @@
|
|||
#include "prmem.h"
|
||||
#include "nsEmitterUtils.h"
|
||||
|
||||
nsresult NS_NewMimeRawEmitter(const nsIID& iid, void **result)
|
||||
{
|
||||
nsMimeRawEmitter *obj = new nsMimeRawEmitter();
|
||||
if (obj)
|
||||
return obj->QueryInterface(iid, result);
|
||||
else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/*
|
||||
* nsMimeRawEmitter definitions....
|
||||
*/
|
||||
|
@ -59,5 +50,3 @@ nsMimeRawEmitter::WriteBody(const char *buf, PRUint32 size, PRUint32 *amountWrit
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -41,7 +41,5 @@ public:
|
|||
protected:
|
||||
};
|
||||
|
||||
/* this function will be used by the factory to generate an class access object....*/
|
||||
extern nsresult NS_NewMimeRawEmitter(const nsIID& iid, void **result);
|
||||
|
||||
#endif /* _nsMimeRawEmitter_h_ */
|
||||
|
|
|
@ -51,15 +51,6 @@ static NS_DEFINE_CID(kMsgHeaderParserCID, NS_MSGHEADERPARSER_CID);
|
|||
static NS_DEFINE_CID(kCAddressCollecter, NS_ABADDRESSCOLLECTER_CID);
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
|
||||
nsresult NS_NewMimeXULEmitter(const nsIID& iid, void **result)
|
||||
{
|
||||
nsMimeXULEmitter *obj = new nsMimeXULEmitter();
|
||||
if (obj)
|
||||
return obj->QueryInterface(iid, result);
|
||||
else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/*
|
||||
* nsMimeXULEmitter definitions....
|
||||
*/
|
||||
|
|
|
@ -98,7 +98,4 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
/* this function will be used by the factory to generate an class access object....*/
|
||||
extern nsresult NS_NewMimeXULEmitter(const nsIID& iid, void **result);
|
||||
|
||||
#endif /* _nsMimeXULEmitter_h_ */
|
||||
|
|
|
@ -31,15 +31,6 @@
|
|||
#include "nsEmitterUtils.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
nsresult NS_NewMimeXmlEmitter(const nsIID& iid, void **result)
|
||||
{
|
||||
nsMimeXmlEmitter *obj = new nsMimeXmlEmitter();
|
||||
if (obj)
|
||||
return obj->QueryInterface(iid, result);
|
||||
else
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
/*
|
||||
* nsMimeXmlEmitter definitions....
|
||||
*/
|
||||
|
|
|
@ -60,7 +60,4 @@ protected:
|
|||
PRInt32 mAttachCount;
|
||||
};
|
||||
|
||||
/* this function will be used by the factory to generate an class access object....*/
|
||||
extern nsresult NS_NewMimeXmlEmitter(const nsIID& iid, void **result);
|
||||
|
||||
#endif /* _nsMimeXmlEmitter_h_ */
|
||||
|
|
|
@ -51,6 +51,9 @@ interface nsIMimeEmitter : nsISupports{
|
|||
// Set the output stream/listener for processed data.
|
||||
void SetPipe(in nsIInputStream inputStream, in nsIOutputStream outStream);
|
||||
void SetOutputListener(in nsIStreamListener listener);
|
||||
|
||||
//Get the output listener to allow access to it from mime
|
||||
nsIStreamListener GetOutputListener();
|
||||
|
||||
// Header handling routines.
|
||||
void StartHeader(in PRBool rootMailHeader, in PRBool headerOnly,
|
||||
|
|
|
@ -28,15 +28,14 @@
|
|||
#include "nsMimeStringResources.h"
|
||||
#include "mimemoz2.h"
|
||||
#include "nsCRT.h"
|
||||
#include "mimemapl.h"
|
||||
#include "nsMimeTypes.h"
|
||||
|
||||
|
||||
#define MIME_SUPERCLASS mimeLeafClass
|
||||
MimeDefClass(MimeExternalObject, MimeExternalObjectClass,
|
||||
mimeExternalObjectClass, &MIME_SUPERCLASS);
|
||||
|
||||
#ifdef XP_MAC
|
||||
extern MimeObjectClass mimeMultipartAppleDoubleClass;
|
||||
#endif
|
||||
|
||||
static int MimeExternalObject_initialize (MimeObject *);
|
||||
static void MimeExternalObject_finalize (MimeObject *);
|
||||
static int MimeExternalObject_parse_begin (MimeObject *);
|
||||
|
@ -85,12 +84,6 @@ MimeExternalObject_parse_begin (MimeObject *obj)
|
|||
status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_begin(obj);
|
||||
if (status < 0) return status;
|
||||
|
||||
#ifdef XP_MAC
|
||||
if (obj->parent && mime_typep(obj->parent,
|
||||
(MimeObjectClass *) &mimeMultipartAppleDoubleClass))
|
||||
goto done;
|
||||
#endif /* XP_MAC */
|
||||
|
||||
// If we're writing this object, and we're doing it in raw form, then
|
||||
// now is the time to inform the backend what the type of this data is.
|
||||
//
|
||||
|
@ -200,10 +193,6 @@ GOTTA STILL DO THIS FOR QUOTING!
|
|||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
done:
|
||||
#endif /* XP_MAC */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -699,7 +699,7 @@ mime_typep(MimeObject *obj, MimeObjectClass *clazz)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* URL munging
|
||||
*/
|
||||
|
||||
|
@ -1214,7 +1214,7 @@ mime_parse_url_options(const char *url, MimeDisplayOptions *options)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Some output-generation utility functions...
|
||||
*/
|
||||
|
||||
|
@ -1308,8 +1308,20 @@ MimeObject_output_init(MimeObject *obj, const char *content_type)
|
|||
PR_FALSE, PR_FALSE);
|
||||
if (ct)
|
||||
{
|
||||
x_mac_type = MimeHeaders_get_parameter(ct,PARAM_X_MAC_TYPE, NULL, NULL);
|
||||
x_mac_creator= MimeHeaders_get_parameter(ct,PARAM_X_MAC_CREATOR, NULL, NULL);
|
||||
x_mac_type = MimeHeaders_get_parameter(ct, PARAM_X_MAC_TYPE, NULL, NULL);
|
||||
x_mac_creator= MimeHeaders_get_parameter(ct, PARAM_X_MAC_CREATOR, NULL, NULL);
|
||||
/* if don't have a x_mac_type and x_mac_creator, we need to try to get it from its parent */
|
||||
if (!x_mac_type && !x_mac_creator && obj->parent && obj->parent->headers)
|
||||
{
|
||||
char * ctp = MimeHeaders_get(obj->parent->headers, HEADER_CONTENT_TYPE, PR_FALSE, PR_FALSE);
|
||||
if (ctp)
|
||||
{
|
||||
x_mac_type = MimeHeaders_get_parameter(ctp, PARAM_X_MAC_TYPE, NULL, NULL);
|
||||
x_mac_creator= MimeHeaders_get_parameter(ctp, PARAM_X_MAC_CREATOR, NULL, NULL);
|
||||
PR_Free(ctp);
|
||||
}
|
||||
}
|
||||
|
||||
PR_FREEIF(obj->options->default_charset);
|
||||
obj->options->default_charset = MimeHeaders_get_parameter(ct, "charset", NULL, NULL);
|
||||
PR_Free(ct);
|
||||
|
|
|
@ -76,7 +76,7 @@ MimeMultipartAppleDouble_parse_begin (MimeObject *obj)
|
|||
#ifdef XP_MAC
|
||||
if (obj->options && obj->options->state)
|
||||
{
|
||||
obj->options->state->separator_suppressed_p = PR_TRUE;
|
||||
// obj->options->state->separator_suppressed_p = PR_TRUE;
|
||||
goto done;
|
||||
}
|
||||
/*
|
||||
|
@ -192,14 +192,17 @@ MimeMultipartAppleDouble_output_child_p(MimeObject *obj, MimeObject *child)
|
|||
the first one should always be an application/applefile.)
|
||||
*/
|
||||
|
||||
if (obj->output_p &&
|
||||
obj->options &&
|
||||
obj->options->write_html_p &&
|
||||
cont->nchildren >= 1 &&
|
||||
cont->children[0] == child &&
|
||||
child->content_type &&
|
||||
!nsCRT::strcasecmp(child->content_type, APPLICATION_APPLEFILE))
|
||||
return PR_FALSE;
|
||||
else
|
||||
return PR_TRUE;
|
||||
if (cont->nchildren >= 1 && cont->children[0] == child && child->content_type &&
|
||||
!nsCRT::strcasecmp(child->content_type, APPLICATION_APPLEFILE))
|
||||
{
|
||||
#ifdef XP_MAC
|
||||
if (obj->output_p && obj->options && obj->options->write_html_p) //output HTML
|
||||
return PR_FALSE;
|
||||
#else
|
||||
/* if we are not on a Macintosh, don't emitte the resources fork at all. */
|
||||
return PR_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -66,6 +66,9 @@
|
|||
|
||||
#include "mimeebod.h"
|
||||
|
||||
#include "nsISaveMsgListener.h"
|
||||
|
||||
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
|
@ -976,6 +979,33 @@ mime_insert_html_convert_charset (const PRBool input_autodetect, const char *inp
|
|||
stream_closure, decoder, encoder);
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
static PRUint32
|
||||
mime_convert_chars_to_ostype(const char *osTypeStr)
|
||||
{
|
||||
if (!osTypeStr)
|
||||
return '????';
|
||||
|
||||
PRUint32 result;
|
||||
char *p = osTypeStr;
|
||||
PRInt32 i;
|
||||
|
||||
for (result = 0; *p; p++)
|
||||
{
|
||||
char C = *p;
|
||||
|
||||
PRInt8 unhex = ((C >= '0' && C <= '9') ? C - '0' :
|
||||
((C >= 'A' && C <= 'F') ? C - 'A' + 10 :
|
||||
((C >= 'a' && C <= 'f') ? C - 'a' + 10 : -1)));
|
||||
if (unhex < 0)
|
||||
break;
|
||||
result = (result << 4) | unhex;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
mime_output_init_fn (const char *type,
|
||||
const char *charset,
|
||||
|
@ -986,6 +1016,20 @@ 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,6 +29,11 @@
|
|||
#include "prio.h"
|
||||
#include "nsMimeStringResources.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsISaveMsgListener.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
extern MimeObjectClass mimeMultipartAppleDoubleClass;
|
||||
#endif
|
||||
|
||||
#define MIME_SUPERCLASS mimeContainerClass
|
||||
MimeDefClass(MimeMultipart, MimeMultipartClass,
|
||||
|
@ -376,8 +381,37 @@ MimeMultipart_create_child(MimeObject *obj)
|
|||
*/
|
||||
body->output_p = (((MimeMultipartClass *) obj->clazz)->output_child_p(obj, body));
|
||||
if (body->output_p)
|
||||
{
|
||||
{
|
||||
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 (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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (status < 0) return status;
|
||||
}
|
||||
|
||||
|
@ -388,7 +422,8 @@ MimeMultipart_create_child(MimeObject *obj)
|
|||
static PRBool
|
||||
MimeMultipart_output_child_p(MimeObject *obj, MimeObject *child)
|
||||
{
|
||||
return PR_TRUE;
|
||||
/* if we are saving an apple double attachment, ignore the appledouble wrapper part */
|
||||
return obj->options->write_html_p || nsCRT::strcasecmp(child->content_type, MULTIPART_APPLEDOUBLE);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "nsCRT.h"
|
||||
#include "nsMimeStringResources.h"
|
||||
#include "mimemsg.h"
|
||||
#include "mimemapl.h"
|
||||
|
||||
/* Way to destroy any notions of modularity or class hierarchy, Terry! */
|
||||
# include "mimetpla.h"
|
||||
|
@ -211,12 +212,13 @@ MimeObject_parse_begin (MimeObject *obj)
|
|||
{
|
||||
if (obj->options->format_out == nsMimeOutput::nsMimeMessageRaw)
|
||||
{
|
||||
if ( (obj->parent) &&
|
||||
(mime_typep(obj->parent, (MimeObjectClass*) &mimeMessageClass)) )
|
||||
{
|
||||
obj->output_p = !nsCRT::strncmp(id, obj->options->part_to_load,
|
||||
nsCRT::strlen(obj->options->part_to_load));
|
||||
}
|
||||
if (obj->parent)
|
||||
if (mime_typep(obj->parent, (MimeObjectClass*) &mimeMessageClass) ||
|
||||
mime_typep(obj->parent, (MimeObjectClass*) &mimeMultipartAppleDoubleClass))
|
||||
{
|
||||
obj->output_p = !nsCRT::strncmp(id, obj->options->part_to_load,
|
||||
nsCRT::strlen(obj->options->part_to_load));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче