Fix bugs 113745, 113742 and 114811: all regarding "moz-icon:". Fix up XP_MAC code to use Mac OS's Icon Services, and expose platform icons in file:/// display and search panel (and search preferences panel). Mixture of r/srs: sdagley, ben, and smfr

This commit is contained in:
rjc%netscape.com 2001-12-15 01:59:50 +00:00
Родитель 5d103bc09a
Коммит 8557584704
9 изменённых файлов: 418 добавлений и 173 удалений

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

@ -17,7 +17,8 @@
* All Rights Reserved.
*
* Contributor(s):
* Scott MacGregor <mscott@netscape.com>
* Scott MacGregor <mscott@netscape.com>
* Robert John Churchill <rjc@netscape.com>
*/
@ -39,7 +40,10 @@
#include "nsIFileChannel.h"
#include <Files.h>
#include <Folders.h>
#include <Icons.h>
#include <QuickDraw.h>
#include <MacMemory.h>
// nsIconChannel methods
nsIconChannel::nsIconChannel()
@ -144,7 +148,7 @@ nsresult nsIconChannel::ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 *
nsCOMPtr<nsIURI> fileURI;
rv = iconURI->GetIconFile(getter_AddRefs(fileURI));
if (NS_FAILED(rv) || !fileURI) return NS_OK;
if (NS_FAILED(rv) || !fileURI) return NS_OK;
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(fileURI, &rv);
if (NS_FAILED(rv) || !fileURL) return NS_OK;
@ -162,176 +166,343 @@ nsresult nsIconChannel::ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 *
return NS_OK;
}
nsresult
nsIconChannel::GetLockedIconData(IconFamilyHandle iconFamilyH, PRUint32 iconType,
Handle iconDataH, PRUint32 *iconDataSize)
{
*iconDataSize = 0;
if (::GetIconFamilyData(iconFamilyH, iconType, iconDataH) != noErr)
return(NS_ERROR_FAILURE);
*iconDataSize = (PRUint32)::GetHandleSize(iconDataH);
if (*iconDataSize > 0)
{
::HLock(iconDataH);
}
return(NS_OK);
}
nsresult
nsIconChannel::GetLockedIcons(IconFamilyHandle icnFamily, PRUint32 desiredImageSize,
Handle iconH, PRUint32 *dataCount, PRBool *isIndexedData,
Handle iconMaskH, PRUint32 *maskCount)
{
// note: this code could be improved by:
//
// o adding support for icon scaling, i.e. if we want a
// 32x32 icon but can only get a 16x16 icon (or vice versa),
// scale the pixels appropriately
//
// o adding support for Mac OS X "huge" 128x128 icons with alpha
// which is also tricky as the alpha data defines the mask for the icon
*dataCount = *maskCount = 0L;
// make sure icon/mask handles are unlocked
// so that they can move in memory
HUnlock(iconH);
HUnlock(iconMaskH);
// Note: Always try and get 32bit non-indexed icons first
// so that we don't have to worry about color palette issues
nsresult rv = GetLockedIconData(icnFamily, (desiredImageSize > 16) ?
kLarge32BitData : kSmall32BitData,
iconH, dataCount);
if (NS_SUCCEEDED(rv) && (*dataCount > 0))
{
*isIndexedData = PR_FALSE;
}
else
{
// if couldn't get a 32bit non-indexed icon,
// then try getting an 8-bit icon
rv = GetLockedIconData(icnFamily, (desiredImageSize > 16) ?
kLarge8BitData : kSmall8BitData,
iconH, dataCount);
if (NS_SUCCEEDED(rv) && (*dataCount > 0))
{
*isIndexedData = PR_TRUE;
}
}
// if we have an icon, try getting a mask too
if (NS_SUCCEEDED(rv) && (*dataCount > 0))
{
// moz-icons are RGB_A1, so get 1-bit icon mask
rv = GetLockedIconData(icnFamily, (desiredImageSize > 16) ?
kLarge1BitMask : kSmall1BitMask,
iconMaskH, maskCount);
if (NS_FAILED(rv) || (*maskCount == 0))
{
// if we can't get a mask, the file's BNDL might be
// messed up, etc. Let's just fake a 1-bit mask
// which will blit the entire icon... its not perfect,
// but its better than no icon at all
*maskCount = (desiredImageSize > 16) ? 256 : 64;
rv = NS_OK;
}
}
return(rv);
}
NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt)
{
nsXPIDLCString contentType;
nsXPIDLCString fileExtension;
nsCOMPtr<nsIFile> localFile; // file we want an icon for
PRUint32 desiredImageSize;
nsresult rv = ExtractIconInfoFromUrl(getter_AddRefs(localFile), &desiredImageSize, getter_Copies(contentType), getter_Copies(fileExtension));
nsCOMPtr<nsILocalFileMac> localFileMac (do_QueryInterface(localFile, &rv));
nsXPIDLCString contentType;
nsXPIDLCString fileExtension;
PRUint32 desiredImageSize;
nsresult rv = ExtractIconInfoFromUrl(getter_AddRefs(localFile), &desiredImageSize,
getter_Copies(contentType), getter_Copies(fileExtension));
if (NS_FAILED(rv)) return(rv);
// ensure that we DO NOT resolve aliases, very important for file views
nsCOMPtr<nsILocalFile> aFileLocal = do_QueryInterface(localFile);
if (aFileLocal)
{
aFileLocal->SetFollowLinks(PR_FALSE);
}
nsCOMPtr<nsIMIMEService> mimeService (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
// if the file exists, then just go ahead and use the creator and file types for the file.
PRUint32 macType;
PRUint32 macCreator;
PRBool fileExists = PR_FALSE;
if (localFile)
{
localFile->Exists(&fileExists);
if (fileExists)
{
OSType macostype;
OSType macOSCreatorType;
localFileMac->GetFileTypeAndCreator(&macostype, &macOSCreatorType);
macType = macostype;
macCreator = macOSCreatorType;
}
}
if (!fileExists)
IconRef icnRef = nsnull;
if (fileExists)
{
// if the file exists, first try getting icons via Icon Services
nsCOMPtr<nsILocalFileMac> localFileMac (do_QueryInterface(localFile, &rv));
if (NS_FAILED(rv)) return(rv);
FSSpec spec;
if (NS_FAILED(localFileMac->GetResolvedFSSpec(&spec)))
return(NS_ERROR_FAILURE);
SInt16 label;
if (::GetIconRefFromFile (&spec, &icnRef, &label) != noErr)
return(NS_ERROR_FAILURE);
}
// note: once we have an IconRef,
// we MUST release it before exiting this method!
// start with zero-sized icons which ::GetIconFamilyData will resize
PRUint32 dataCount = 0L, maskCount = 0L;
Handle iconH = ::NewHandle(dataCount);
Handle iconMaskH = ::NewHandle(maskCount);
if (!iconH || !iconMaskH)
{
// sigh; REALLY low-mem, bail
if (iconH) ::DisposeHandle(iconH);
if (iconMaskH) ::DisposeHandle(iconMaskH);
return(NS_ERROR_OUT_OF_MEMORY);
}
PRUint8 *iconBitmapData = nsnull, *maskBitmapData = nsnull;
PRBool isIndexedData = PR_FALSE;
IconFamilyHandle icnFamily;
if (fileExists && (::IconRefToIconFamily(icnRef,
kSelectorAllAvailableData, &icnFamily) == noErr))
{
GetLockedIcons(icnFamily, desiredImageSize, iconH, &dataCount,
&isIndexedData, iconMaskH, &maskCount);
if (dataCount > 0)
{
iconBitmapData = (PRUint8 *)*iconH;
if (maskCount > 0) maskBitmapData = (PRUint8 *)*iconMaskH;
}
::DisposeHandle((Handle)icnFamily);
}
::ReleaseIconRef(icnRef);
icnRef = nsnull;
if (!dataCount)
{
// if file didn't exist, or couldn't get an appropriate
// icon resource, then try again by mimetype mapping
nsCOMPtr<nsIMIMEService> mimeService (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
NS_ENSURE_SUCCESS(rv, rv);
// if we were given an explicit content type, use it....
nsCOMPtr<nsIMIMEInfo> mimeInfo;
if (*contentType.get())
{
mimeService->GetFromMIMEType(contentType, getter_AddRefs(mimeInfo));
}
if (!mimeInfo) // try to grab an extension for the dummy file in the url.
nsCOMPtr<nsIMIMEInfo> mimeInfo;
if (mimeService)
{
if (*contentType.get())
{
mimeService->GetFromMIMEType(contentType, getter_AddRefs(mimeInfo));
}
if (!mimeInfo) // try to grab an extension for the dummy file in the url.
{
mimeService->GetFromExtension(fileExtension, getter_AddRefs(mimeInfo));
}
}
if (!mimeInfo) return NS_ERROR_FAILURE; // we don't have enough info to fetch an application icon.
// get the mac creator and file type for this mime object
// if we don't have enough info to fetch an application icon, bail
if (!mimeInfo)
{
if (iconH) ::DisposeHandle(iconH);
if (iconMaskH) ::DisposeHandle(iconMaskH);
return NS_ERROR_FAILURE;
}
// get the mac creator and file type for this mime object
PRUint32 macType;
PRUint32 macCreator;
mimeInfo->GetMacType(&macType);
mimeInfo->GetMacCreator(&macCreator);
if (::GetIconRef(kOnSystemDisk, macCreator, macType, &icnRef) != noErr)
{
if (iconH) ::DisposeHandle(iconH);
if (iconMaskH) ::DisposeHandle(iconMaskH);
return(NS_ERROR_FAILURE);
}
if (::IconRefToIconFamily(icnRef, kSelectorAllAvailableData, &icnFamily) == noErr)
{
GetLockedIcons(icnFamily, desiredImageSize, iconH, &dataCount,
&isIndexedData, iconMaskH, &maskCount);
if (dataCount > 0)
{
iconBitmapData = (PRUint8 *)*iconH;
if (maskCount > 0) maskBitmapData = (PRUint8 *)*iconMaskH;
}
::DisposeHandle((Handle)icnFamily);
}
::ReleaseIconRef(icnRef);
icnRef = nsnull;
}
// get a refernce to the desktop database
DTPBRec pb;
OSErr err = noErr;
memset(&pb, 0, sizeof(DTPBRec));
pb.ioCompletion = nil;
pb.ioVRefNum = 0; // default desktop volume
pb.ioNamePtr = nil;
err = PBDTGetPath(&pb);
if (err != noErr) return NS_ERROR_FAILURE;
pb.ioFileCreator = macCreator;
pb.ioFileType = macType;
pb.ioCompletion = nil;
pb.ioTagInfo = 0;
PRUint32 numPixelsInRow = 0;
if (desiredImageSize > 16)
// note: we must have icon data, but it is OK to not
// have maskBitmapData (we fake a mask in that case)
if (!iconBitmapData)
{
pb.ioDTReqCount = kLarge8BitIconSize;
pb.ioIconType = kLarge8BitIcon;
numPixelsInRow = 32;
if (iconH) DisposeHandle(iconH);
if (iconMaskH) DisposeHandle(iconMaskH);
return(NS_ERROR_FAILURE);
}
else
{
pb.ioDTReqCount = kSmall8BitIconSize;
pb.ioIconType = kSmall8BitIcon;
numPixelsInRow = 16;
}
// allocate a buffer large enough to handle the icon
PRUint8 * bitmapData = (PRUint8 *) nsMemory::Alloc (pb.ioDTReqCount);
pb.ioDTBuffer = (Ptr) bitmapData;
err = PBDTGetIcon(&pb, false);
if (err != noErr) return NS_ERROR_FAILURE; // unable to fetch the icon....
PRUint32 numPixelsInRow = (desiredImageSize > 16) ? 32 : 16;
PRUint8 *bitmapData = (PRUint8 *)iconBitmapData;
nsCString iconBuffer;
iconBuffer.Assign((char) numPixelsInRow);
iconBuffer.Append((char) numPixelsInRow);
CTabHandle cTabHandle = GetCTable(72);
if (!cTabHandle) return NS_ERROR_FAILURE;
HLock((Handle) cTabHandle);
CTabPtr colTable = *cTabHandle;
CTabHandle cTabHandle = nsnull;
CTabPtr colTable = nsnull;
if (isIndexedData)
{
// only need the CTable if we have an palette-indexed icon
cTabHandle = ::GetCTable(72);
if (!cTabHandle)
{
if (iconH) ::DisposeHandle(iconH);
if (iconMaskH) ::DisposeHandle(iconMaskH);
return NS_ERROR_FAILURE;
}
::HLock((Handle) cTabHandle);
colTable = *cTabHandle;
}
RGBColor rgbCol;
PRUint8 redValue, greenValue, blueValue;
for (PRUint32 index = 0; index < pb.ioDTReqCount; index ++)
PRUint32 index = 0L;
while (index < dataCount)
{
if (!isIndexedData)
{
// 32 bit icon data
iconBuffer.Append((char) bitmapData[index++]);
iconBuffer.Append((char) bitmapData[index++]);
iconBuffer.Append((char) bitmapData[index++]);
iconBuffer.Append((char) bitmapData[index++]);
}
else
{
// each byte in bitmapData needs to be converted from an 8 bit system color into
// 24 bit RGB data which our special icon image decoder can understand.
ColorSpec colSpec = colTable->ctTable[ bitmapData[index]];
rgbCol = colSpec.rgb;
// each byte in bitmapData needs to be converted from an 8 bit system color into
// 24 bit RGB data which our special icon image decoder can understand.
ColorSpec colSpec = colTable->ctTable[ bitmapData[index]];
rgbCol = colSpec.rgb;
redValue = rgbCol.red & 0xff;
greenValue = rgbCol.green & 0xff;
blueValue = rgbCol.blue & 0xff;
// for some reason the image code on the mac expects each RGB pixel value to be padded with a preceding byte.
// so add the padding here....
iconBuffer.Append((char) 0);
iconBuffer.Append((char) redValue);
iconBuffer.Append((char) greenValue);
iconBuffer.Append((char) blueValue);
redValue = rgbCol.red & 0xff;
greenValue = rgbCol.green & 0xff;
blueValue = rgbCol.blue & 0xff;
iconBuffer.Append((char) 0); // alpha channel byte
iconBuffer.Append((char) redValue);
iconBuffer.Append((char) greenValue);
iconBuffer.Append((char) blueValue);
index++;
}
}
HUnlock((Handle) cTabHandle);
DisposeCTable(cTabHandle);
nsMemory::Free(bitmapData);
// now that the color bitmask is taken care of, we need to do the same thing again for the transparency
// bit mask....
if (desiredImageSize > 16)
if (cTabHandle)
{
pb.ioDTReqCount = kLargeIconSize;
pb.ioIconType = kLargeIcon;
::HUnlock((Handle) cTabHandle);
::DisposeCTable(cTabHandle);
}
::DisposeHandle(iconH);
iconH = nsnull;
bitmapData = (PRUint8 *)maskBitmapData;
if (maskBitmapData)
{
// skip over ICN# data to get to mask
// which is half way into data
index = maskCount/2;
while (index < maskCount)
{
iconBuffer.Append((char) bitmapData[index]);
iconBuffer.Append((char) bitmapData[index + 1]);
if (numPixelsInRow == 32)
{
iconBuffer.Append((char) bitmapData[index + 2]);
iconBuffer.Append((char) bitmapData[index + 3]);
index += 4;
}
else
{
iconBuffer.Append((char) 255); // 2 bytes of padding
iconBuffer.Append((char) 255);
index += 2;
}
}
}
else
{
pb.ioDTReqCount = kSmallIconSize;
pb.ioIconType = kSmallIcon;
index = 0L;
while (index++ < maskCount)
{
// edgecase: without a mask, just blit entire icon
iconBuffer.Append((char) 255);
}
}
// allocate a buffer large enough to handle the icon
bitmapData = (PRUint8 *) nsMemory::Alloc (pb.ioDTReqCount);
pb.ioDTBuffer = (Ptr) bitmapData;
err = PBDTGetIcon(&pb, false);
PRUint32 index = pb.ioDTReqCount/2;
while (index < pb.ioDTReqCount)
if (iconMaskH)
{
iconBuffer.Append((char) bitmapData[index]);
iconBuffer.Append((char) bitmapData[index + 1]);
if (numPixelsInRow == 32)
{
iconBuffer.Append((char) bitmapData[index + 2]);
iconBuffer.Append((char) bitmapData[index + 3]);
index += 4;
}
else
{
iconBuffer.Append((char) 255); // 2 bytes of padding
iconBuffer.Append((char) 255);
index += 2;
}
::DisposeHandle(iconMaskH);
iconMaskH = nsnull;
}
nsMemory::Free(bitmapData);
// turn our nsString into a stream looking object...
aListener->OnStartRequest(this, ctxt);
// turn our string into a stream...
nsCOMPtr<nsISupports> streamSupports;
NS_NewByteInputStream(getter_AddRefs(streamSupports), iconBuffer.get(), iconBuffer.Length());
// turn our string into a stream...
nsCOMPtr<nsISupports> streamSupports;
NS_NewByteInputStream(getter_AddRefs(streamSupports), iconBuffer.get(), iconBuffer.Length());
nsCOMPtr<nsIInputStream> inputStr (do_QueryInterface(streamSupports));
aListener->OnDataAvailable(this, ctxt, inputStr, 0, iconBuffer.Length());
aListener->OnStopRequest(this, ctxt, NS_OK);
nsCOMPtr<nsIInputStream> inputStr (do_QueryInterface(streamSupports));
aListener->OnDataAvailable(this, ctxt, inputStr, 0, iconBuffer.Length());
aListener->OnStopRequest(this, ctxt, NS_OK);
return NS_OK;
}

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

@ -26,6 +26,7 @@
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIURI.h"
#include <Icons.h>
class nsIFile;
@ -51,7 +52,15 @@ protected:
nsCOMPtr<nsISupports> mOwner;
nsresult mStatus;
nsresult ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, char ** aContentType, char ** aFileExtension);
nsresult ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize,
char ** aContentType, char ** aFileExtension);
nsresult GetLockedIconData(IconFamilyHandle iconFamilyH, PRUint32 iconType,
Handle iconDataH, PRUint32 *iconDataSize);
nsresult GetLockedIcons(IconFamilyHandle iconFamily, PRUint32 desiredImageSize,
Handle iconH, PRUint32 *dataCount, PRBool *isIndexedData,
Handle iconMaskH, PRUint32 *maskCount);
};

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

@ -100,6 +100,8 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
#endif
#define NS_MOZICON_SCHEME "moz-icon:"
static const char kURINC_FileSystemRoot[] = "NC:FilesRoot";
@ -116,6 +118,7 @@ private:
static nsIRDFResource *kNC_Child;
static nsIRDFResource *kNC_Name;
static nsIRDFResource *kNC_URL;
static nsIRDFResource *kNC_Icon;
static nsIRDFResource *kNC_Length;
static nsIRDFResource *kWEB_LastMod;
static nsIRDFResource *kNC_FileSystemObject;
@ -156,7 +159,7 @@ public:
static nsresult GetVolumeList(nsISimpleEnumerator **aResult);
static nsresult GetFolderList(nsIRDFResource *source, PRBool allowHidden, PRBool onlyFirst, nsISimpleEnumerator **aResult);
static nsresult GetName(nsIRDFResource *source, nsIRDFLiteral** aResult);
static nsresult GetURL(nsIRDFResource *source, nsIRDFLiteral** aResult);
static nsresult GetURL(nsIRDFResource *source, PRBool *isFavorite, nsIRDFLiteral** aResult);
static nsresult GetFileSize(nsIRDFResource *source, nsIRDFInt** aResult);
static nsresult GetLastMod(nsIRDFResource *source, nsIRDFDate** aResult);
@ -186,6 +189,7 @@ nsIRDFResource *FileSystemDataSource::kNC_FileSystemRoot;
nsIRDFResource *FileSystemDataSource::kNC_Child;
nsIRDFResource *FileSystemDataSource::kNC_Name;
nsIRDFResource *FileSystemDataSource::kNC_URL;
nsIRDFResource *FileSystemDataSource::kNC_Icon;
nsIRDFResource *FileSystemDataSource::kNC_Length;
nsIRDFResource *FileSystemDataSource::kWEB_LastMod;
nsIRDFResource *FileSystemDataSource::kNC_FileSystemObject;
@ -315,6 +319,7 @@ FileSystemDataSource::FileSystemDataSource(void)
gRDFService->GetResource(NC_NAMESPACE_URI "child", &kNC_Child);
gRDFService->GetResource(NC_NAMESPACE_URI "Name", &kNC_Name);
gRDFService->GetResource(NC_NAMESPACE_URI "URL", &kNC_URL);
gRDFService->GetResource(NC_NAMESPACE_URI "Icon", &kNC_Icon);
gRDFService->GetResource(NC_NAMESPACE_URI "Content-Length", &kNC_Length);
gRDFService->GetResource(WEB_NAMESPACE_URI "LastModifiedDate", &kWEB_LastMod);
gRDFService->GetResource(NC_NAMESPACE_URI "FileSystemObject", &kNC_FileSystemObject);
@ -344,6 +349,7 @@ FileSystemDataSource::~FileSystemDataSource (void)
NS_RELEASE(kNC_Child);
NS_RELEASE(kNC_Name);
NS_RELEASE(kNC_URL);
NS_RELEASE(kNC_Icon);
NS_RELEASE(kNC_Length);
NS_RELEASE(kWEB_LastMod);
NS_RELEASE(kNC_FileSystemObject);
@ -479,13 +485,33 @@ FileSystemDataSource::GetTarget(nsIRDFResource *source,
else if (property == kNC_URL)
{
nsCOMPtr<nsIRDFLiteral> url;
rv = GetURL(source, getter_AddRefs(url));
rv = GetURL(source, nsnull, getter_AddRefs(url));
if (NS_FAILED(rv)) return(rv);
if (!url) rv = NS_RDF_NO_VALUE;
if (rv == NS_RDF_NO_VALUE) return(rv);
return url->QueryInterface(NS_GET_IID(nsIRDFNode), (void**) target);
}
else if (property == kNC_Icon)
{
nsCOMPtr<nsIRDFLiteral> url;
PRBool isFavorite = PR_FALSE;
rv = GetURL(source, &isFavorite, getter_AddRefs(url));
if (NS_FAILED(rv)) return(rv);
if (isFavorite || !url) rv = NS_RDF_NO_VALUE;
if (rv == NS_RDF_NO_VALUE) return(rv);
const PRUnichar *uni = nsnull;
url->GetValueConst(&uni);
if (!uni) return(NS_RDF_NO_VALUE);
nsAutoString urlStr;
urlStr.Assign(NS_LITERAL_STRING(NS_MOZICON_SCHEME).get());
urlStr.Append(uni);
rv = gRDFService->GetLiteral(urlStr.get(), getter_AddRefs(url));
if (NS_FAILED(rv) || !url) return(NS_RDF_NO_VALUE);
return url->QueryInterface(NS_GET_IID(nsIRDFNode), (void**) target);
}
else if (property == kNC_Length)
{
nsCOMPtr<nsIRDFInt> fileSize;
@ -659,7 +685,7 @@ FileSystemDataSource::GetTargets(nsIRDFResource *source,
else if (property == kNC_URL)
{
nsCOMPtr<nsIRDFLiteral> url;
rv = GetURL(source, getter_AddRefs(url));
rv = GetURL(source, nsnull, getter_AddRefs(url));
if (NS_FAILED(rv)) return rv;
nsISimpleEnumerator* result = new nsSingletonEnumerator(url);
@ -827,23 +853,33 @@ FileSystemDataSource::HasArcIn(nsIRDFNode *aNode, nsIRDFResource *aArc, PRBool *
NS_IMETHODIMP
FileSystemDataSource::HasArcOut(nsIRDFResource *aSource, nsIRDFResource *aArc, PRBool *result)
{
if (aSource == kNC_FileSystemRoot) {
*result = (aArc == kNC_Child || aArc == kNC_pulse);
}
else if (isFileURI(aSource)) {
if (aArc == kNC_pulse) {
*result = PR_TRUE;
}
else if (isDirURI(aSource)) {
#ifdef XP_WIN
*result = isValidFolder(aSource);
#else
*result = PR_TRUE;
#endif
}
}
else {
*result = PR_FALSE;
if (aSource == kNC_FileSystemRoot)
{
*result = (aArc == kNC_Child || aArc == kNC_pulse);
}
else if (isFileURI(aSource))
{
if (aArc == kNC_pulse)
{
*result = PR_TRUE;
}
else if (isDirURI(aSource))
{
#ifdef XP_WIN
*result = isValidFolder(aSource);
#else
*result = PR_TRUE;
#endif
}
else if (aArc == kNC_pulse || aArc == kNC_Name || aArc == kNC_Icon ||
aArc == kNC_URL || aArc == kNC_Length || aArc == kWEB_LastMod ||
aArc == kNC_FileSystemObject || aArc == kRDF_InstanceOf ||
aArc == kRDF_type)
{
*result = PR_TRUE;
}
}
return NS_OK;
}
@ -906,8 +942,6 @@ FileSystemDataSource::ArcLabelsOut(nsIRDFResource *source,
array->AppendElement(kNC_pulse);
}
array->AppendElement(kRDF_type);
nsISimpleEnumerator* result = new nsArrayEnumerator(array);
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
@ -1610,8 +1644,10 @@ FileSystemDataSource::getIEFavoriteURL(nsIRDFResource *source, nsString aFileURL
nsresult
FileSystemDataSource::GetURL(nsIRDFResource *source, nsIRDFLiteral** aResult)
FileSystemDataSource::GetURL(nsIRDFResource *source, PRBool *isFavorite, nsIRDFLiteral** aResult)
{
if (isFavorite) *isFavorite = PR_FALSE;
nsresult rv;
const char *uri;
rv = source->GetValueConst(&uri);
@ -1625,6 +1661,7 @@ FileSystemDataSource::GetURL(nsIRDFResource *source, nsIRDFLiteral** aResult)
{
if (url.Find(ieFavoritesDir) == 0)
{
if (isFavorite) *isFavorite = PR_TRUE;
rv = getIEFavoriteURL(source, url, aResult);
return(rv);
}
@ -1637,6 +1674,7 @@ FileSystemDataSource::GetURL(nsIRDFResource *source, nsIRDFLiteral** aResult)
{
if (url.Find(netPositiveDir) == 0)
{
if (isFavorite) *isFavorite = PR_TRUE;
rv = getNetPositiveURL(source, url, aResult);
return(rv);
}

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

@ -289,6 +289,8 @@ Contributor(s): ______________________________________. -->
<rule parent="hbox" iscontainer="true" isempty="true"
rdf:type="http://home.netscape.com/NC-rdf#Folder">
<toolbarbutton type="menu" editable="true" class="bookmark-item"
image="rdf:http://home.netscape.com/NC-rdf#Icon"
validate="never"
rdf:type="http://home.netscape.com/NC-rdf#Folder"
uri="rdf:*" label="rdf:http://home.netscape.com/NC-rdf#Name"
ondraggesture="if (!event.altKey) { event.preventBubble(); return false; }">
@ -302,6 +304,8 @@ Contributor(s): ______________________________________. -->
<toolbarbutton type="menu" class="bookmark-item" uri="rdf:*" editable="true"
rdf:type="http://home.netscape.com/NC-rdf#Folder"
label="rdf:http://home.netscape.com/NC-rdf#Name"
image="rdf:http://home.netscape.com/NC-rdf#Icon"
validate="never"
ondraggesture="if (!event.altKey) { event.preventBubble(); return false; }">
<menupopup ondraggesture="nsDragAndDrop.startDrag(event, personalToolbarObserver);"/>
</toolbarbutton>
@ -318,6 +322,8 @@ Contributor(s): ______________________________________. -->
</rule>
<rule iscontainer="true" isempty="true"
image="rdf:http://home.netscape.com/NC-rdf#Icon"
validate="never"
rdf:type="http://home.netscape.com/NC-rdf#Folder">
<menupopup>
<menu class="menu-iconic bookmark-item" uri="rdf:*"
@ -332,7 +338,9 @@ Contributor(s): ______________________________________. -->
<rule iscontainer="true">
<menupopup>
<menu class="menu-iconic bookmark-item" uri="rdf:*"
<menu class="menu-iconic bookmark-item" uri="rdf:*"
image="rdf:http://home.netscape.com/NC-rdf#Icon"
validate="never"
label="rdf:http://home.netscape.com/NC-rdf#Name">
<menupopup/>
</menu>

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

@ -309,6 +309,8 @@
rdf:type="http://home.netscape.com/NC-rdf#Folder">
<menupopup>
<menu class="menu-iconic bookmark-item" uri="rdf:*"
src="rdf:http://home.netscape.com/NC-rdf#Icon"
validate="never"
type="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
label="rdf:http://home.netscape.com/NC-rdf#Name">
<menupopup>
@ -319,7 +321,10 @@
</rule>
<rule iscontainer="true">
<menupopup>
<menu class="menu-iconic bookmark-item" uri="rdf:*" label="rdf:http://home.netscape.com/NC-rdf#Name"
<menu class="menu-iconic bookmark-item" uri="rdf:*"
src="rdf:http://home.netscape.com/NC-rdf#Icon"
validate="never"
label="rdf:http://home.netscape.com/NC-rdf#Name"
type="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type">
<menupopup />
</menu>

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

@ -44,6 +44,8 @@
loading="rdf:http://home.netscape.com/NC-rdf#loading" >
<treerow>
<treecell class="treecell-filename treecell-indent" indent="true"
src="rdf:http://home.netscape.com/NC-rdf#Icon"
validate="never"
type="rdf:http://home.netscape.com/NC-rdf#File-Type"
label="rdf:http://home.netscape.com/NC-rdf#Name"/>
<treecell label="rdf:http://home.netscape.com/NC-rdf#Content-Length" />

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

@ -45,7 +45,9 @@
<template>
<menupopup>
<menuitem label="rdf:http://home.netscape.com/NC-rdf#Name" value="..." uri="..."/>
<menuitem value="..." uri="..."
src="rdf:http://home.netscape.com/NC-rdf#Icon"
label="rdf:http://home.netscape.com/NC-rdf#Name"/>
</menupopup>
</template>
</menulist>

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

@ -81,6 +81,7 @@
<menuitem value="..." uri="..."
desc="rdf:http://home.netscape.com/NC-rdf#Description"
ver="rdf:http://home.netscape.com/NC-rdf#Version"
src="rdf:http://home.netscape.com/NC-rdf#Icon"
label="rdf:http://home.netscape.com/NC-rdf#Name"/>
</menupopup>
</template>

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

@ -3771,24 +3771,33 @@ InternetSearchDataSource::SaveEngineInfoIntoGraph(nsIFile *file, nsIFile *icon,
if (!searchRes) return(NS_ERROR_UNEXPECTED);
if (!categoryRes) return(NS_ERROR_UNEXPECTED);
nsAutoString iconURL;
if (icon)
{
nsXPIDLCString iconPath;
icon->GetPath(getter_Copies(iconPath));
nsFileSpec iconSpec((const char *)iconPath);
nsFileURL iconFileURL(iconSpec);
nsAutoString iconURL;
iconURL.AssignWithConversion(iconFileURL.GetURLString());
nsXPIDLCString iconFileURL;
if (NS_FAILED(rv = icon->GetURL(getter_Copies(iconFileURL))))
return(rv);
iconURL.AssignWithConversion(iconFileURL);
}
#ifdef XP_MAC
else if (file)
{
nsXPIDLCString fileURL;
if (NS_FAILED(rv = file->GetURL(getter_Copies(fileURL))))
return(rv);
iconURL.Assign(NS_LITERAL_STRING("moz-icon:"));
iconURL.AppendWithConversion(fileURL);
}
#endif
// save icon url (if we have one)
if (iconURL.Length() > 0)
// save icon url (if we have one)
if (iconURL.Length() > 0)
{
nsCOMPtr<nsIRDFLiteral> iconLiteral;
if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(iconURL.get(),
getter_AddRefs(iconLiteral))))
{
nsCOMPtr<nsIRDFLiteral> iconLiteral;
if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(iconURL.get(),
getter_AddRefs(iconLiteral))))
{
updateAtom(mInner, searchRes, kNC_Icon, iconLiteral, nsnull);
}
updateAtom(mInner, searchRes, kNC_Icon, iconLiteral, nsnull);
}
}