Fix for 202355. Turn on apple single/double code for MacOSX. r=ccarlen, sr=sfraser.

This commit is contained in:
cavin%netscape.com 2003-04-25 21:18:10 +00:00
Родитель 97260a727d
Коммит a58b5ef4fa
16 изменённых файлов: 126 добавлений и 44 удалений

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

@ -109,6 +109,11 @@ CPPSRCS = \
nsCidProtocolHandler.cpp \
$(NULL)
# MacOSX requires the MoreFiles module
ifneq (,$(filter cocoa mac, $(MOZ_WIDGET_TOOLKIT)))
REQUIRES += macmorefiles
endif
ifeq ($(OS_ARCH),WINNT)
CPPSRCS += nsMessengerWinIntegration.cpp
endif

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

@ -54,6 +54,10 @@
#include "nsISupportsObsolete.h"
#if defined(XP_MAC) || defined(XP_MACOSX)
#include "nsIAppleFileDecoder.h"
#if defined(XP_MACOSX)
#include "nsILocalFileMac.h"
#include "MoreFilesX.h"
#endif
#endif
// necko
@ -207,7 +211,7 @@ nsresult ConvertAndSanitizeFileName(const char * displayName, PRUnichar ** unico
NS_ConvertUTF8toUCS2 ucs2Str(unescapedName);
nsresult rv = NS_OK;
#if defined(XP_MAC)
#if defined(XP_MAC) /* reviewed for 1.4, XP_MACOSX not needed */
/* We need to truncate the name to 31 characters, this even on MacOS X until the file API
correctly support long file name. Using a nsILocalFile will do the trick...
*/
@ -1755,19 +1759,20 @@ nsSaveMsgListener::OnStartRequest(nsIRequest* request, nsISupports* aSupport)
m_dataBuffer = (char*) PR_CALLOC(FOUR_K+1);
}
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
if (!m_contentType.IsEmpty())
{
nsFileSpec realSpec;
m_fileSpec->GetFileSpec(&realSpec);
// Create nsILocalFile from a nsFileSpec.
nsCOMPtr<nsILocalFile> outputFile;
NS_FileSpecToIFile(&realSpec, getter_AddRefs(outputFile));
/* if we are saving an appledouble or applesingle attachment, we need to use an Apple File Decoder */
if ((nsCRT::strcasecmp(m_contentType.get(), APPLICATION_APPLEFILE) == 0) ||
(nsCRT::strcasecmp(m_contentType.get(), MULTIPART_APPLEDOUBLE) == 0))
{
/* ggrrrrr, I have a nsFileSpec but I need a nsILocalFile... */
nsCOMPtr<nsILocalFile> outputFile;
NS_FileSpecToIFile(&realSpec, getter_AddRefs(outputFile));
nsCOMPtr<nsIAppleFileDecoder> appleFileDecoder = do_CreateInstance(NS_IAPPLEFILEDECODER_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && appleFileDecoder)
@ -1789,7 +1794,14 @@ nsSaveMsgListener::OnStartRequest(nsIRequest* request, nsISupports* aSupport)
PRUint32 aMacType;
PRUint32 aMacCreator;
if (NS_SUCCEEDED(mimeinfo->GetMacType(&aMacType)) && NS_SUCCEEDED(mimeinfo->GetMacCreator(&aMacCreator)))
realSpec.SetFileTypeAndCreator((OSType)aMacType, (OSType)aMacCreator);
{
nsCOMPtr<nsILocalFileMac> macFile = do_QueryInterface(outputFile, &rv);
if (NS_SUCCEEDED(rv) && macFile)
{
macFile->SetFileCreator((OSType)aMacCreator);
macFile->SetFileCreator((OSType)aMacType);
}
}
}
}

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

@ -78,5 +78,9 @@ EXTRA_DSO_LDOPTS = \
$(MOZ_XPCOM_OBSOLETE_LIBS) \
$(NULL)
ifneq (,$(filter cocoa mac, $(MOZ_WIDGET_TOOLKIT)))
EXTRA_DSO_LDOPTS += $(TK_LIBS)
endif
include $(topsrcdir)/config/rules.mk

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

@ -128,6 +128,17 @@ EXPORTS = \
nsSmtpDelegateFactory.h \
$(NULL)
# MacOSX requires the MoreFiles module
ifneq (,$(filter cocoa mac, $(MOZ_WIDGET_TOOLKIT)))
REQUIRES += macmorefiles \
$(NULL)
CPPSRCS += nsMsgAppleDoubleEncode.cpp \
nsMsgAppleEncode.cpp \
$(NULL)
EXPORTS += nsMsgAppleDouble.h \
$(NULL)
endif
# we don't want the shared lib, but we want to force the creation of a static lib.
FORCE_STATIC_LIB = 1

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

@ -38,6 +38,10 @@
#endif
#endif /* XP_MAC */
#if defined(XP_MACOSX)
#pragma options align=mac68k
#endif /* XP_MACOSX */
#define APPLESINGLE_MAGIC 0x00051600L
#define APPLEDOUBLE_MAGIC 0x00051607L
#define VERSION 0x00020000
@ -119,4 +123,8 @@ PR_END_EXTERN_C
#endif
#endif /* XP_MAC */
#if defined(XP_MACOSX)
#pragma options align=reset
#endif /* XP_MACOSX */
#endif /* ad_codes_h */

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

@ -41,11 +41,14 @@
#include "nsMimeTypes.h"
#include "prmem.h"
#if defined(XP_MAC) || defined(XP_MACOSX)
#ifdef XP_MAC
#pragma warn_unusedarg off
#pragma cplusplus on
#else
#include "MoreFilesX.h"
#endif
void
MacGetFileType(nsFileSpec *fs,
@ -64,7 +67,14 @@ MacGetFileType(nsFileSpec *fs,
*encoding = NULL;
FInfo fndrInfo;
#if defined(XP_MAC)
OSErr err = FSpGetFInfo( fs->GetFSSpecPtr(), &fndrInfo );
#else
FSSpec fsSpec;
FSPathMakeFSSpec((UInt8 *)fs->GetNativePathCString(), &fsSpec, NULL);
OSErr err = FSpGetFInfo (&fsSpec, &fndrInfo);
#endif
if ( (err != noErr) || (fndrInfo.fdType == 'TEXT') )
*fileType = nsCRT::strdup(APPLICATION_OCTET_STREAM);
else
@ -114,7 +124,11 @@ int ap_encode_init( appledouble_encode_object *p_ap_encode_obj,
if (!mySpec.Exists())
return -1;
#if defined(XP_MAC)
fspec = mySpec.GetFSSpec();
#else
FSPathMakeFSSpec((UInt8 *)fname, &fspec, NULL);
#endif
memset(p_ap_encode_obj, 0, sizeof(appledouble_encode_object));
/*

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

@ -35,7 +35,7 @@
#include "nsMsgAppleDouble.h"
#include "nsMsgAppleCodes.h"
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
#include <Errors.h>

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

@ -72,16 +72,21 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
///////////////////////////////////////////////////////////////////////////
// Mac Specific Attachment Handling for AppleDouble Encoded Files
///////////////////////////////////////////////////////////////////////////
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
#define AD_WORKING_BUFF_SIZE 8192
extern void MacGetFileType(nsFileSpec *fs, PRBool *useDefault, char **type, char **encoding);
#include "MoreFilesExtras.h"
#include "nsIInternetConfigService.h"
#if defined(XP_MAC)
#include "MoreFilesExtras.h"
#else
#include "MoreFilesX.h"
#endif /* XP_MAC */
#endif /* XP_MAC */
//
@ -134,7 +139,7 @@ nsMsgAttachmentHandler::nsMsgAttachmentHandler()
m_x_mac_type = nsnull;
m_x_mac_creator = nsnull;
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
mAppleFileSpec = nsnull;
#endif
@ -147,7 +152,7 @@ nsMsgAttachmentHandler::~nsMsgAttachmentHandler()
#if defined(DEBUG_ducarroz)
printf("DISPOSE nsMsgAttachmentHandler: %x\n", this);
#endif
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
if (mAppleFileSpec)
delete mAppleFileSpec;
#endif
@ -460,7 +465,7 @@ FetcherURLDoneCallback(nsresult aStatus,
ma->m_size = totalSize;
if (aContentType)
{
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
//Do not change the type if we are dealing with an apple double file
if (!ma->mAppleFileSpec)
#endif
@ -605,6 +610,20 @@ done:
return rv;
}
#if defined(XP_MAC) || defined(XP_MACOSX)
PRBool nsMsgAttachmentHandler::HasResourceFork(FSSpec *fsSpec)
{
FSRef fsRef;
if (::FSpMakeFSRef(fsSpec, &fsRef) == noErr)
{
FSCatalogInfo catalogInfo;
OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoDataSizes + kFSCatInfoRsrcSizes, &catalogInfo, nsnull, nsnull, nsnull);
return (err == noErr && catalogInfo.rsrcLogicalSize != 0);
}
return PR_FALSE;
}
#endif
nsresult
nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
{
@ -653,7 +672,7 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
mURL->GetSpec(url_string);
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
if ( !m_bogus_attachment && nsMsgIsLocalFile(url_string))
{
// convert the apple file to AppleDouble first, and then patch the
@ -662,9 +681,19 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
if (!src_filename)
return NS_ERROR_OUT_OF_MEMORY;
// Unescape the name before making FSSpec
nsCAutoString escapedFilename(src_filename);
nsUnescape(NS_CONST_CAST(char*, escapedFilename.get()));
//We need to retrieve the file type and creator...
nsFileSpec scr_fileSpec(src_filename);
FSSpec fsSpec = scr_fileSpec.GetFSSpec();
nsFileSpec scr_fileSpec(escapedFilename.get());
FSSpec fsSpec;
#if defined(XP_MAC)
fsSpec = scr_fileSpec.GetFSSpec();
#elif defined(XP_MACOSX)
Boolean isDir;
FSPathMakeFSSpec((UInt8 *)escapedFilename.get(), &fsSpec, &isDir);
#endif
FInfo info;
if (FSpGetFInfo (&fsSpec, &info) == noErr)
{
@ -678,12 +707,8 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
m_x_mac_creator = PL_strdup(filetype);
}
long dataSize = 0;
long resSize = 0;
PRBool sendResourceFork = PR_TRUE;
PRBool icGaveNeededInfo = PR_FALSE;
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
if (icService)
{
@ -697,8 +722,9 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
{
// before deciding to send the resource fork along the data fork, check if we have one,
// else don't need to use apple double.
if (::FSpGetFileSize(&fsSpec, &dataSize, &resSize) == noErr && resSize == 0)
sendResourceFork = PR_FALSE;
#if defined(XP_MAC) || defined(XP_MACOSX)
sendResourceFork = HasResourceFork(&fsSpec);
#endif
}
icGaveNeededInfo = PR_TRUE;
@ -709,8 +735,7 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
{
// If InternetConfig cannot help us, then just try our best...
// first check if we have a resource fork
if (::FSpGetFileSize(&fsSpec, &dataSize, &resSize) == noErr)
sendResourceFork = (resSize > 0);
sendResourceFork = HasResourceFork(&fsSpec);
// then, if we have a resource fork, check the filename extension, maybe we don't need the resource fork!
if (sendResourceFork)
@ -819,7 +844,7 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
//
// Setup all the need information on the apple double encoder.
//
ap_encode_init(&(obj->ap_encode_obj), src_filename, separator);
ap_encode_init(&(obj->ap_encode_obj), escapedFilename.get(), separator);
PRInt32 count;

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

@ -47,7 +47,7 @@
#include "nsIFileStreams.h"
#include "nsIStreamConverter.h"
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
#include "nsMsgAppleDouble.h"
@ -90,6 +90,9 @@ private:
PRBool UseUUEncode_p(void);
void AnalyzeDataChunk (const char *chunk, PRInt32 chunkSize);
nsresult LoadDataFromFile(nsFileSpec& fSpec, nsString &sigData, PRBool charsetConversion); //A similar function already exist in nsMsgCompose!
#if defined(XP_MAC) || defined(XP_MACOSX)
PRBool HasResourceFork(FSSpec *fsSpec);
#endif
//////////////////////////////////////////////////////////////////////
// Member vars...
@ -103,7 +106,7 @@ public:
nsMsgCompFields *mCompFields; // Message composition fields for the sender
PRBool m_bogus_attachment; // This is to catch problem children...
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
nsFileSpec *mAppleFileSpec; // The temp file holds the appledouble
// encoding of the file we want to send.
#endif

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

@ -483,7 +483,7 @@ nsMsgComposeAndSend::Clear()
m_attachments[i].mFileSpec = nsnull;
}
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
//
// remove the appledoubled intermediate file after we done all.
//
@ -2326,7 +2326,7 @@ nsMsgComposeAndSend::AddCompFieldLocalAttachments()
else
element->GetContentTypeParam(&m_attachments[newLoc].m_type_param);
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
//We always need to snarf the file to figure out how to send it, maybe we need to use apple double...
m_attachments[newLoc].m_done = PR_FALSE;
m_attachments[newLoc].SetMimeDeliveryState(this);

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

@ -963,7 +963,7 @@ PRBool nsIMAPBodypartLeaf::ShouldFetchInline()
return PR_FALSE; // we can leave it on the server
}
}
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
// If it is either applesingle, or a resource fork for appledouble
if (!PL_strcasecmp(m_contentType, "application/applefile"))
{

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

@ -52,7 +52,7 @@
MimeDefClass(MimeExternalBody, MimeExternalBodyClass,
mimeExternalBodyClass, &MIME_SUPERCLASS);
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
extern MimeObjectClass mimeMultipartAppleDoubleClass;
#endif
@ -296,7 +296,7 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p)
status = ((MimeObjectClass*)&MIME_SUPERCLASS)->parse_eof(obj, abort_p);
if (status < 0) return status;
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
if (obj->parent && mime_typep(obj->parent,
(MimeObjectClass*) &mimeMultipartAppleDoubleClass))
goto done;
@ -466,7 +466,7 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p)
PR_FREEIF(subj);
}
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
done:
#endif /* XP_MAC */

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

@ -88,7 +88,7 @@ MimeMultipartAppleDouble_parse_begin (MimeObject *obj)
NS_ASSERTION(obj->options->state->first_data_written_p, "first data not written");
}
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
if (obj->options && obj->options->state)
{
// obj->options->state->separator_suppressed_p = PR_TRUE;
@ -190,7 +190,7 @@ GOTTA STILL DO THIS FOR QUOTING!
if (status < 0) return status;
}
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
done:
#endif
@ -210,7 +210,7 @@ MimeMultipartAppleDouble_output_child_p(MimeObject *obj, MimeObject *child)
if (cont->nchildren >= 1 && cont->children[0] == child && child->content_type &&
!nsCRT::strcasecmp(child->content_type, APPLICATION_APPLEFILE))
{
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
if (obj->output_p && obj->options && obj->options->write_html_p) //output HTML
return PR_FALSE;
#else

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

@ -46,7 +46,7 @@
#include "nsMimeStringResources.h"
#include "nsMimeTypes.h"
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
extern MimeObjectClass mimeMultipartAppleDoubleClass;
#endif
@ -449,14 +449,16 @@ MimeMultipart_create_child(MimeObject *obj)
{
status = body->clazz->parse_begin(body);
#ifdef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
/* 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 (!body->options->write_html_p && body->content_type && !nsCRT::strcasecmp(body->content_type, APPLICATION_APPLEFILE))
{
if (msd && msd->channel)
msd->channel->SetContentType(NS_LITERAL_CSTRING(APPLICATION_APPLEFILE));
}
}
#endif

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

@ -415,7 +415,7 @@ nsresult nsBinHexDecoder::ProcessNextChunk(nsIRequest * aRequest, nsISupports *
/* handle decoded characters -- run length encoding (rle) detection */
#ifndef XP_MAC
#if defined(XP_MAC) || defined(XP_MACOSX)
mOctetBuf.val = PR_ntohl(mOctetBuf.val);
#endif

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

@ -69,10 +69,8 @@
#if defined(XP_MAC) || defined (XP_MACOSX)
#include "nsILocalFileMac.h"
#include "nsIInternetConfigService.h"
#endif // defined(XP_MAC) || defined (XP_MACOSX)
#ifdef XP_MAC
#include "nsIAppleFileDecoder.h"
#endif // XP_MAC
#endif // defined(XP_MAC) || defined (XP_MACOSX)
#include "nsIPluginHost.h"
#include "nsEscape.h"
@ -1255,7 +1253,7 @@ nsresult nsExternalAppHandler::SetUpTempFile(nsIChannel * aChannel)
rv = NS_NewLocalFileOutputStream(getter_AddRefs(mOutStream), mTempFile,
PR_WRONLY | PR_CREATE_FILE, 0600);
#ifdef XP_MAC
#if defined(XP_MAC) || defined (XP_MACOSX)
nsXPIDLCString contentType;
mMimeInfo->GetMIMEType(getter_Copies(contentType));
if (contentType &&