Bug #74783 --> don't read the mac file creator and type values from our hard coded table of content types. Always use the values from internet config.

r=sspitzer
sr=sfraser


git-svn-id: svn://10.0.0.236/trunk@92142 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
mscott%netscape.com
2001-04-13 00:44:55 +00:00
parent 61ccf241e1
commit 032cc5948d
2 changed files with 54 additions and 16 deletions

View File

@@ -96,7 +96,11 @@ NS_IMETHODIMP nsOSHelperAppService::GetFromExtension(const char * aFileExt, nsIM
{
// first, ask our base class. We may already have this information cached....
nsresult rv = nsExternalHelperAppService::GetFromExtension(aFileExt, aMIMEInfo);
if (NS_SUCCEEDED(rv) && *aMIMEInfo) return rv;
if (NS_SUCCEEDED(rv) && *aMIMEInfo)
{
UpdateCreatorInfo(*aMIMEInfo);
return rv;
}
// oops, we didn't find an entry....ask the internet config service to look it up for us...
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
@@ -117,7 +121,11 @@ NS_IMETHODIMP nsOSHelperAppService::GetFromMIMEType(const char * aMIMEType, nsIM
{
// first, ask our base class. We may already have this information cached....
nsresult rv = nsExternalHelperAppService::GetFromMIMEType(aMIMEType, aMIMEInfo);
if (NS_SUCCEEDED(rv) && *aMIMEInfo) return rv;
if (NS_SUCCEEDED(rv) && *aMIMEInfo)
{
UpdateCreatorInfo(*aMIMEInfo);
return rv;
}
// oops, we didn't find an entry....ask the internet config service to look it up for us...
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
@@ -133,3 +141,33 @@ NS_IMETHODIMP nsOSHelperAppService::GetFromMIMEType(const char * aMIMEType, nsIM
if (!*aMIMEInfo) rv = NS_ERROR_FAILURE;
return rv;
}
// we never want to use a hard coded value for the creator and file type for the mac. always look these values up
// from internet config.
void nsOSHelperAppService::UpdateCreatorInfo(nsIMIMEInfo * aMIMEInfo)
{
PRUint32 macCreatorType;
PRUint32 macFileType;
aMIMEInfo->GetMacType(&macFileType);
aMIMEInfo->GetMacCreator(&macCreatorType);
if (macFileType == 0 || macCreatorType == 0)
{
// okay these values haven't been initialized yet so fetch a mime object from internet config.
nsXPIDLCString mimeType;
aMIMEInfo->GetMIMEType(getter_Copies(mimeType));
nsCOMPtr<nsIInternetConfigService> icService (do_GetService(NS_INTERNETCONFIGSERVICE_CONTRACTID));
if (icService)
{
nsCOMPtr<nsIMIMEInfo> osMimeObject;
icService->FillInMIMEInfo(mimeType, nsnull, getter_AddRefs(osMimeObject));
if (osMimeObject)
{
osMimeObject->GetMacType(&macFileType);
osMimeObject->GetMacCreator(&macCreatorType);
aMIMEInfo->SetMacCreator(macCreatorType);
aMIMEInfo->SetMacType(macFileType);
} // if we got an os object
} // if we got the ic service
} // if the creator or file type hasn't been initialized yet
}

View File

@@ -75,31 +75,31 @@ static nsDefaultMimeTypeEntry defaultMimeEntries [] =
{
{ TEXT_PLAIN, "txt,text", "Text File", 'TEXT', 'ttxt' },
#if defined(VMS)
{ APPLICATION_OCTET_STREAM, "exe,bin,sav,bck,pcsi,dcx_axpexe,dcx_vaxexe,sfx_axpexe,sfx_vaxexe", "Binary Executable", PRUint32(0x3F3F3F3F), PRUint32(0x3F3F3F3F) },
{ APPLICATION_OCTET_STREAM, "exe,bin,sav,bck,pcsi,dcx_axpexe,dcx_vaxexe,sfx_axpexe,sfx_vaxexe", "Binary Executable", 0, 0 },
#elif defined(XP_MAC) // don't define .bin on the mac...use internet config to look that up...
{ APPLICATION_OCTET_STREAM, "exe", "Binary Executable", PRUint32(0x3F3F3F3F), PRUint32(0x3F3F3F3F) },
{ APPLICATION_OCTET_STREAM, "exe", "Binary Executable", 0, 0 },
#else
{ APPLICATION_OCTET_STREAM, "exe,bin", "Binary Executable", PRUint32(0x3F3F3F3F), PRUint32(0x3F3F3F3F) },
{ APPLICATION_OCTET_STREAM, "exe,bin", "Binary Executable", 0, 0 },
#endif
{ TEXT_HTML, "htm,html,shtml,ehtml", "Hyper Text Markup Language", PRUint32(0x3F3F3F3F), PRUint32(0x3F3F3F3F) },
{ TEXT_HTML, "htm,html,shtml,ehtml", "Hyper Text Markup Language", 'TEXT', 'MOSS' },
{ TEXT_RDF, "rdf", "Resource Description Framework", 'TEXT','ttxt' },
{ TEXT_XUL, "xul", "XML-Based User Interface Language", 'TEXT', 'ttxt' },
{ TEXT_XML, "xml,xsl", "Extensible Markup Language", 'TEXT', 'ttxt' },
{ TEXT_CSS, "css", "Style Sheet", 'TEXT', 'ttxt' },
{ APPLICATION_JAVASCRIPT, "js", "Javascript Source File", 'TEXT', 'ttxt' },
{ MESSAGE_RFC822, "eml", "RFC-822 data", PRUint32(0x3F3F3F3F), PRUint32(0x3F3F3F3F) },
{ APPLICATION_GZIP2, "gz", "gzip", PRUint32(0x3F3F3F3F), PRUint32(0x3F3F3F3F) },
{ IMAGE_GIF, "gif", "GIF Image", 'GIFf','GCon' },
{ IMAGE_JPG, "jpeg,jpg", "JPEG Image", 'JPEG', 'GCon' },
{ IMAGE_PNG, "png", "PNG Image", PRUint32(0x3F3F3F3F), PRUint32(0x3F3F3F3F) },
{ IMAGE_ART, "art", "ART Image", PRUint32(0x3F3F3F3F), PRUint32(0x3F3F3F3F) },
{ IMAGE_TIFF, "tiff,tif", "TIFF Image", PRUint32(0x3F3F3F3F), PRUint32(0x3F3F3F3F) },
{ APPLICATION_POSTSCRIPT, "ps,eps,ai", "Postscript File", PRUint32(0x3F3F3F3F), PRUint32(0x3F3F3F3F) },
{ TEXT_RTF, "rtf", "Rich Text Format", PRUint32(0x3F3F3F3F), PRUint32(0x3F3F3F3F) },
{ MESSAGE_RFC822, "eml", "RFC-822 data", 'TEXT', 'MOSS' },
{ APPLICATION_GZIP2, "gz", "gzip", 0, 0 },
{ IMAGE_GIF, "gif", "GIF Image", 0,0 },
{ IMAGE_JPG, "jpeg,jpg", "JPEG Image", 0, 0 },
{ IMAGE_PNG, "png", "PNG Image", 0, 0 },
{ IMAGE_ART, "art", "ART Image", 0, 0 },
{ IMAGE_TIFF, "tiff,tif", "TIFF Image", 0, 0 },
{ APPLICATION_POSTSCRIPT, "ps,eps,ai", "Postscript File",0, 0 },
{ TEXT_RTF, "rtf", "Rich Text Format", 0, 0 },
{ TEXT_CPP, "cpp", "CPP file", 'TEXT','CWIE' },
{ "application/x-arj", "arj", "ARJ file", PRUint32(0x3F3F3F3F), PRUint32(0x3F3F3F3F) },
{ "application/x-arj", "arj", "ARJ file", 0,0 },
{ APPLICATION_XPINSTALL, "xpi", "XPInstall Install", 'xpi*','MOSS' },
};