From 462ebbb2ad985957b1aba7c5dbad7582baa5d539 Mon Sep 17 00:00:00 2001 From: "cbiesinger%web.de" Date: Sat, 28 Jan 2006 14:25:18 +0000 Subject: [PATCH] bug 269280 implement moz-icon on BeOS patch by Simon and Doug Shelton r=biesi r=mconnor (toolkit parts) --- allmakefiles.sh | 1 + configure | 2 +- configure.in | 2 +- modules/libpr0n/decoders/Makefile.in | 3 + modules/libpr0n/decoders/icon/Makefile.in | 6 +- .../libpr0n/decoders/icon/beos/Makefile.in | 62 +++ .../decoders/icon/beos/nsIconChannel.cpp | 496 ++++++++++++++++++ .../decoders/icon/beos/nsIconChannel.h | 84 +++ .../libpr0n/decoders/icon/nsIconModule.cpp | 6 +- .../mozapps/downloads/content/download.xml | 18 +- 10 files changed, 668 insertions(+), 12 deletions(-) create mode 100644 modules/libpr0n/decoders/icon/beos/Makefile.in create mode 100644 modules/libpr0n/decoders/icon/beos/nsIconChannel.cpp create mode 100644 modules/libpr0n/decoders/icon/beos/nsIconChannel.h diff --git a/allmakefiles.sh b/allmakefiles.sh index 30b2adcaaa6..8e558b799db 100755 --- a/allmakefiles.sh +++ b/allmakefiles.sh @@ -1174,6 +1174,7 @@ embedding/components/profilesharingsetup/src/Makefile modules/libpr0n/decoders/icon/Makefile modules/libpr0n/decoders/icon/win/Makefile modules/libpr0n/decoders/icon/gtk/Makefile + modules/libpr0n/decoders/icon/beos/Makefile modules/libpr0n/decoders/xbm/Makefile modules/libpr0n/encoders/Makefile modules/libpr0n/encoders/png/Makefile diff --git a/configure b/configure index 0f1b8b1a433..9eed644a254 100755 --- a/configure +++ b/configure @@ -15011,7 +15011,7 @@ fi MOZ_EXTENSIONS=`${PERL} ${srcdir}/build/unix/uniq.pl ${MOZ_EXTENSIONS}` case "$MOZ_WIDGET_TOOLKIT" in -windows|os2|mac|cocoa) +beos|windows|os2|mac|cocoa) ;; *) if test -z "$MOZ_ENABLE_GNOMEUI"; then diff --git a/configure.in b/configure.in index fcd7faba02b..2416a174457 100644 --- a/configure.in +++ b/configure.in @@ -5200,7 +5200,7 @@ dnl ======================================================== dnl Image decoders dnl ======================================================== case "$MOZ_WIDGET_TOOLKIT" in -windows|os2|mac|cocoa) +beos|windows|os2|mac|cocoa) ;; *) if test -z "$MOZ_ENABLE_GNOMEUI"; then diff --git a/modules/libpr0n/decoders/Makefile.in b/modules/libpr0n/decoders/Makefile.in index fbb25d56942..5ffe97e37bc 100644 --- a/modules/libpr0n/decoders/Makefile.in +++ b/modules/libpr0n/decoders/Makefile.in @@ -52,6 +52,9 @@ endif ifeq ($(OS_ARCH),OS2) DIRS = icon/os2 icon endif +ifeq ($(OS_ARCH),BeOS) +DIRS = icon/beos icon +endif ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) DIRS = icon/mac icon endif diff --git a/modules/libpr0n/decoders/icon/Makefile.in b/modules/libpr0n/decoders/icon/Makefile.in index 14c8d945f84..1dac37e5e36 100644 --- a/modules/libpr0n/decoders/icon/Makefile.in +++ b/modules/libpr0n/decoders/icon/Makefile.in @@ -74,6 +74,10 @@ ifeq ($(OS_ARCH),Darwin) PLATFORM = mac endif +ifeq ($(OS_ARCH),BeOS) +PLATFORM = beos +endif + REQUIRES = xpcom \ string \ gfx \ @@ -87,7 +91,7 @@ CPPSRCS = \ nsIconProtocolHandler.cpp \ $(NULL) -ifeq (,$(filter-out Darwin OS2,$(OS_ARCH))) +ifeq (,$(filter-out Darwin OS2 BeOS,$(OS_ARCH))) CPPSRCS += nsIconDecoder.cpp endif diff --git a/modules/libpr0n/decoders/icon/beos/Makefile.in b/modules/libpr0n/decoders/icon/beos/Makefile.in new file mode 100644 index 00000000000..c0a8b49bbdf --- /dev/null +++ b/modules/libpr0n/decoders/icon/beos/Makefile.in @@ -0,0 +1,62 @@ +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is the Makefile for the Gnome icon decoder. +# +# The Initial Developer of the Original Code is +# Christian Biesinger . +# Portions created by the Initial Developer are Copyright (C) 2004 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 2 or later (the "GPL"), or +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + + +DEPTH = ../../../../.. +topsrcdir = @top_srcdir@ +srcdir = @srcdir@ +VPATH = @srcdir@ + +include $(DEPTH)/config/autoconf.mk + +MODULE = imgicon +LIBRARY_NAME = imgiconbeos_s +LIBXUL_LIBRARY = 1 + +REQUIRES = xpcom \ + string \ + necko \ + intl \ + mimetype \ + $(NULL) + +CPPSRCS = nsIconChannel.cpp + +# we don't want the shared lib, but we want to force the creation of a static lib. +FORCE_STATIC_LIB = 1 + +include $(topsrcdir)/config/rules.mk + diff --git a/modules/libpr0n/decoders/icon/beos/nsIconChannel.cpp b/modules/libpr0n/decoders/icon/beos/nsIconChannel.cpp new file mode 100644 index 00000000000..c4b7d92f449 --- /dev/null +++ b/modules/libpr0n/decoders/icon/beos/nsIconChannel.cpp @@ -0,0 +1,496 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Brian Ryner. + * Portions created by the Initial Developer are Copyright (C) 2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Scott MacGregor + * Neil Rashbrook + * Ben Goodger + * Simon Taylor + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + + +#include "nsIconChannel.h" +#include "nsIIconURI.h" +#include "nsIServiceManager.h" +#include "nsIInterfaceRequestor.h" +#include "nsIInterfaceRequestorUtils.h" +#include "nsXPIDLString.h" +#include "nsReadableUtils.h" +#include "nsMimeTypes.h" +#include "nsMemory.h" +#include "nsIStringStream.h" +#include "nsIURL.h" +#include "nsNetUtil.h" +#include "nsInt64.h" +#include "nsIFile.h" +#include "nsIFileURL.h" +#include "nsIMIMEService.h" +#include "nsDirectoryServiceDefs.h" + +#include +#include +#include +#include +#include + +// nsIconChannel methods +nsIconChannel::nsIconChannel() +{ +} + +nsIconChannel::~nsIconChannel() +{} + +NS_IMPL_THREADSAFE_ISUPPORTS4(nsIconChannel, + nsIChannel, + nsIRequest, + nsIRequestObserver, + nsIStreamListener) + +nsresult nsIconChannel::Init(nsIURI* uri) +{ + NS_ASSERTION(uri, "no uri"); + mUrl = uri; + + nsresult rv; + mPump = do_CreateInstance(NS_INPUTSTREAMPUMP_CONTRACTID, &rv); + return rv; +} + +//////////////////////////////////////////////////////////////////////////////// +// nsIRequest methods: + +NS_IMETHODIMP nsIconChannel::GetName(nsACString &result) +{ + return mUrl->GetSpec(result); +} + +NS_IMETHODIMP nsIconChannel::IsPending(PRBool *result) +{ + return mPump->IsPending(result); +} + +NS_IMETHODIMP nsIconChannel::GetStatus(nsresult *status) +{ + return mPump->GetStatus(status); +} + +NS_IMETHODIMP nsIconChannel::Cancel(nsresult status) +{ + return mPump->Cancel(status); +} + +NS_IMETHODIMP nsIconChannel::Suspend(void) +{ + return mPump->Suspend(); +} + +NS_IMETHODIMP nsIconChannel::Resume(void) +{ + return mPump->Resume(); +} +NS_IMETHODIMP nsIconChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup) +{ + *aLoadGroup = mLoadGroup; + NS_IF_ADDREF(*aLoadGroup); + return NS_OK; +} + +NS_IMETHODIMP nsIconChannel::SetLoadGroup(nsILoadGroup* aLoadGroup) +{ + mLoadGroup = aLoadGroup; + return NS_OK; +} + +NS_IMETHODIMP nsIconChannel::GetLoadFlags(PRUint32 *aLoadAttributes) +{ + return mPump->GetLoadFlags(aLoadAttributes); +} + +NS_IMETHODIMP nsIconChannel::SetLoadFlags(PRUint32 aLoadAttributes) +{ + return mPump->SetLoadFlags(aLoadAttributes); +} + +//////////////////////////////////////////////////////////////////////////////// +// nsIChannel methods: + +NS_IMETHODIMP nsIconChannel::GetOriginalURI(nsIURI* *aURI) +{ + *aURI = mOriginalURI ? mOriginalURI : mUrl; + NS_ADDREF(*aURI); + return NS_OK; +} + +NS_IMETHODIMP nsIconChannel::SetOriginalURI(nsIURI* aURI) +{ + mOriginalURI = aURI; + return NS_OK; +} + +NS_IMETHODIMP nsIconChannel::GetURI(nsIURI* *aURI) +{ + *aURI = mUrl; + NS_IF_ADDREF(*aURI); + return NS_OK; +} + +NS_IMETHODIMP +nsIconChannel::Open(nsIInputStream **_retval) +{ + return MakeInputStream(_retval, PR_FALSE); +} + +nsresult nsIconChannel::ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsACString &aContentType, nsACString &aFileExtension) +{ + nsresult rv = NS_OK; + nsCOMPtr iconURI (do_QueryInterface(mUrl, &rv)); + NS_ENSURE_SUCCESS(rv, rv); + + iconURI->GetImageSize(aDesiredImageSize); + iconURI->GetContentType(aContentType); + iconURI->GetFileExtension(aFileExtension); + + nsCOMPtr fileURI; + rv = iconURI->GetIconFile(getter_AddRefs(fileURI)); + if (NS_FAILED(rv) || !fileURI) return NS_OK; + + nsCOMPtr fileURL = do_QueryInterface(fileURI, &rv); + if (NS_FAILED(rv) || !fileURL) return NS_OK; + + nsCOMPtr file; + rv = fileURL->GetFile(getter_AddRefs(file)); + if (NS_FAILED(rv) || !file) return NS_OK; + + *aLocalFile = file; + NS_IF_ADDREF(*aLocalFile); + return NS_OK; +} + +NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt) +{ + nsCOMPtr inStream; + nsresult rv = MakeInputStream(getter_AddRefs(inStream), PR_TRUE); + if (NS_FAILED(rv)) + return rv; + + // Init our streampump + rv = mPump->Init(inStream, nsInt64(-1), nsInt64(-1), 0, 0, PR_FALSE); + if (NS_FAILED(rv)) + return rv; + + rv = mPump->AsyncRead(this, ctxt); + if (NS_SUCCEEDED(rv)) { + // Store our real listener + mListener = aListener; + // Add ourself to the load group, if available + if (mLoadGroup) + mLoadGroup->AddRequest(this, nsnull); + } + return rv; +} + +nsresult nsIconChannel::MakeInputStream(nsIInputStream** _retval, PRBool nonBlocking) +{ + nsXPIDLCString contentType; + nsCAutoString filePath; + nsCAutoString fileExtension; + nsCOMPtr localFile; // File we want an icon for + PRUint32 desiredImageSize; + nsresult rv = ExtractIconInfoFromUrl(getter_AddRefs(localFile), &desiredImageSize, contentType, fileExtension); + NS_ENSURE_SUCCESS(rv, rv); + + PRUint32 iconSize = 16; + if (desiredImageSize > 16) + iconSize = 32; + + PRUint32 alphaBytesPerRow = (iconSize / 8); + if (iconSize % 32 != 0) + alphaBytesPerRow = ((iconSize / 32) + 1) * 4; + + PRBool fileExists = PR_FALSE; + if (localFile) + { + localFile->GetNativePath(filePath); + localFile->Exists(&fileExists); + } + + // Get the native icon. + // 1) If it is for an actual local file, BNodeInfo::GetTrackerIcon. + // 2) If the local file does not exist, use the content type + // and BMimeType::GetIcon + BBitmap nativeIcon(BRect(0, 0, iconSize - 1, iconSize - 1), B_CMAP8); + if (!nativeIcon.IsValid()) + return NS_ERROR_OUT_OF_MEMORY; + + PRBool gotBitmap = PR_FALSE; + if (fileExists) + { + BNode localNode(filePath.get()); + // BeOS doesn't MIME type foreign files immediately - + // If there is no type attribute then we can force an identify + if (localNode.ReadAttr("BEOS:TYPE", B_STRING_TYPE, 0, NULL, 0) != B_OK) + update_mime_info(filePath.get(), 0, 1, 1); + + BNodeInfo localNodeInfo(&localNode); + if (iconSize == 16) + { + if (localNodeInfo.GetTrackerIcon(&nativeIcon, B_MINI_ICON) == B_OK) + gotBitmap = PR_TRUE; + } + else + { + if (localNodeInfo.GetTrackerIcon(&nativeIcon, B_LARGE_ICON) == B_OK) + gotBitmap = PR_TRUE; + } + } + + // If we haven't got a bitmap yet, use the content type + if (!gotBitmap) + { + // If no content type specified, use mozilla's mime service to guess a mime type + if (contentType.IsEmpty()) + { + nsCOMPtr mimeService (do_GetService("@mozilla.org/mime;1", &rv)); + if (NS_SUCCEEDED(rv)) + mimeService->GetTypeFromExtension(fileExtension, contentType); + // If unrecognised extension - set to generic file + if (contentType.IsEmpty()) + contentType = "application/octet-stream"; + } + // Create BeOS-Native MIME type info - if unheard of, set to generic file + BMimeType mimeType(contentType.get()); + if (!mimeType.IsInstalled()) + mimeType.SetTo("application/octet-stream"); + if (iconSize == 16) + { + if (mimeType.GetIcon(&nativeIcon, B_MINI_ICON) == B_OK) + gotBitmap = PR_TRUE; + } + else + { + if (mimeType.GetIcon(&nativeIcon, B_LARGE_ICON) == B_OK) + gotBitmap = PR_TRUE; + } + } + + if (!gotBitmap) + return NS_ERROR_NOT_AVAILABLE; + + BScreen mainScreen(B_MAIN_SCREEN_ID); + if (!mainScreen.IsValid()) + return NS_ERROR_NOT_AVAILABLE; + + // Got a bitmap and color space info - convert data to mozilla's icon format + PRUint32 iconLength = 2 + iconSize * (iconSize * 3 + alphaBytesPerRow); + uint8 *buffer = new uint8[iconLength]; + if (!buffer) + return NS_ERROR_OUT_OF_MEMORY; + + buffer[0] = iconSize; + buffer[1] = iconSize; + + // RGB data + uint8* destByte = buffer + 2; + uint8* sourceByte = (uint8*)nativeIcon.Bits(); + for(PRUint32 iconRow = 0; iconRow < iconSize; iconRow++) + { + sourceByte = (uint8*)nativeIcon.Bits() + nativeIcon.BytesPerRow() * iconRow; + for(PRUint32 iconCol = 0; iconCol < iconSize; iconCol++) + { + if (*sourceByte != B_TRANSPARENT_MAGIC_CMAP8) + { + rgb_color colorVal = mainScreen.ColorForIndex(*sourceByte); + *(destByte++) = colorVal.blue; + *(destByte++) = colorVal.green; + *(destByte++) = colorVal.red; + } + else + { + *destByte++ = 0; + *destByte++ = 0; + *destByte++ = 0; + } + // original code had a conditional here: + // if (iconCol < iconSize - 1) + // Leaving this comment in case complications arise later + sourceByte++; + } + } + // Alpha data - bitmask, with rows aligned on 32-bit boundaries + for(PRUint32 iconRow = 0; iconRow < iconSize; iconRow++) + { + destByte = buffer + 2 + iconSize * iconSize * 3 + iconRow * alphaBytesPerRow; + sourceByte = (uint8*)nativeIcon.Bits() + nativeIcon.BytesPerRow() * iconRow; + int bitNo = 0; + for(PRUint32 iconCol = 0; iconCol < iconSize; iconCol++) + { + if (*sourceByte == B_TRANSPARENT_MAGIC_CMAP8) + (*destByte) &= (~(128 >> (bitNo % 8))); + else + (*destByte) |= (128 >> (bitNo % 8)); + + //original code had a conditional here: + //if (iconCol < iconSize - 1) + //Leaving this comment in case complications arise later + bitNo++; + sourceByte++; + if ((bitNo%8) == 0) + destByte++; + } + } + + // Now, create a pipe and stuff our data into it + nsCOMPtr inStream; + nsCOMPtr outStream; + rv = NS_NewPipe(getter_AddRefs(inStream), getter_AddRefs(outStream), + iconLength, iconLength, nonBlocking); + if (NS_SUCCEEDED(rv)) + { + PRUint32 written; + rv = outStream->Write((char*)buffer, iconLength, &written); + if (NS_SUCCEEDED(rv)) + NS_ADDREF(*_retval = inStream); + } + delete [] buffer; + + return rv; +} + +NS_IMETHODIMP nsIconChannel::GetContentType(nsACString &aContentType) +{ + aContentType.AssignLiteral("image/icon"); + return NS_OK; +} + +NS_IMETHODIMP +nsIconChannel::SetContentType(const nsACString &aContentType) +{ + // It doesn't make sense to set the content-type on this type + // of channel... + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP nsIconChannel::GetContentCharset(nsACString &aContentCharset) +{ + aContentCharset.Truncate(); + return NS_OK; +} + +NS_IMETHODIMP +nsIconChannel::SetContentCharset(const nsACString &aContentCharset) +{ + // It doesn't make sense to set the content-charset on this type + // of channel... + return NS_ERROR_FAILURE; +} + +NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt32 *aContentLength) +{ + *aContentLength = mContentLength; + return NS_OK; +} + +NS_IMETHODIMP nsIconChannel::SetContentLength(PRInt32 aContentLength) +{ + NS_NOTREACHED("nsIconChannel::SetContentLength"); + return NS_ERROR_NOT_IMPLEMENTED; +} + +NS_IMETHODIMP nsIconChannel::GetOwner(nsISupports* *aOwner) +{ + *aOwner = mOwner.get(); + NS_IF_ADDREF(*aOwner); + return NS_OK; +} + +NS_IMETHODIMP nsIconChannel::SetOwner(nsISupports* aOwner) +{ + mOwner = aOwner; + return NS_OK; +} + +NS_IMETHODIMP nsIconChannel::GetNotificationCallbacks(nsIInterfaceRequestor* *aNotificationCallbacks) +{ + *aNotificationCallbacks = mCallbacks.get(); + NS_IF_ADDREF(*aNotificationCallbacks); + return NS_OK; +} + +NS_IMETHODIMP nsIconChannel::SetNotificationCallbacks(nsIInterfaceRequestor* aNotificationCallbacks) +{ + mCallbacks = aNotificationCallbacks; + return NS_OK; +} + +NS_IMETHODIMP nsIconChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) +{ + *aSecurityInfo = nsnull; + return NS_OK; +} + +// nsIRequestObserver methods +NS_IMETHODIMP nsIconChannel::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) +{ + if (mListener) + return mListener->OnStartRequest(this, aContext); + return NS_OK; +} + +NS_IMETHODIMP nsIconChannel::OnStopRequest(nsIRequest* aRequest, nsISupports* aContext, nsresult aStatus) +{ + if (mListener) { + mListener->OnStopRequest(this, aContext, aStatus); + mListener = nsnull; + } + + // Remove from load group + if (mLoadGroup) + mLoadGroup->RemoveRequest(this, nsnull, aStatus); + + return NS_OK; +} + +// nsIStreamListener methods +NS_IMETHODIMP nsIconChannel::OnDataAvailable(nsIRequest* aRequest, + nsISupports* aContext, + nsIInputStream* aStream, + PRUint32 aOffset, + PRUint32 aCount) +{ + if (mListener) + return mListener->OnDataAvailable(this, aContext, aStream, aOffset, aCount); + return NS_OK; +} diff --git a/modules/libpr0n/decoders/icon/beos/nsIconChannel.h b/modules/libpr0n/decoders/icon/beos/nsIconChannel.h new file mode 100644 index 00000000000..bf59799ae8b --- /dev/null +++ b/modules/libpr0n/decoders/icon/beos/nsIconChannel.h @@ -0,0 +1,84 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Brian Ryner. + * Portions created by the Initial Developer are Copyright (C) 2000 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Scott MacGregor + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef nsIconChannel_h___ +#define nsIconChannel_h___ + +#include "nsCOMPtr.h" +#include "nsXPIDLString.h" +#include "nsIChannel.h" +#include "nsILoadGroup.h" +#include "nsIInterfaceRequestor.h" +#include "nsIInterfaceRequestorUtils.h" +#include "nsIURI.h" +#include "nsIInputStreamPump.h" +#include "nsIStreamListener.h" + +class nsIFile; + +class nsIconChannel : public nsIChannel, public nsIStreamListener +{ +public: + NS_DECL_ISUPPORTS + NS_DECL_NSIREQUEST + NS_DECL_NSICHANNEL + NS_DECL_NSIREQUESTOBSERVER + NS_DECL_NSISTREAMLISTENER + + nsIconChannel(); + ~nsIconChannel(); + + nsresult Init(nsIURI* uri); + +protected: + nsCOMPtr mUrl; + nsCOMPtr mOriginalURI; + PRInt32 mContentLength; + nsCOMPtr mLoadGroup; + nsCOMPtr mCallbacks; + nsCOMPtr mOwner; + + nsCOMPtr mPump; + nsCOMPtr mListener; + + nsresult ExtractIconInfoFromUrl(nsIFile ** aLocalFile, PRUint32 * aDesiredImageSize, nsACString &aContentType, nsACString &aFileExtension); + nsresult MakeInputStream(nsIInputStream** _retval, PRBool nonBlocking); +}; + +#endif /* nsIconChannel_h___ */ diff --git a/modules/libpr0n/decoders/icon/nsIconModule.cpp b/modules/libpr0n/decoders/icon/nsIconModule.cpp index 8898038a8c0..f92a90a17b9 100644 --- a/modules/libpr0n/decoders/icon/nsIconModule.cpp +++ b/modules/libpr0n/decoders/icon/nsIconModule.cpp @@ -40,7 +40,7 @@ #include "nsIGenericFactory.h" #include "nsIModule.h" -#if defined(XP_MACOSX) || defined(XP_OS2) +#if defined(XP_MACOSX) || defined(XP_OS2) || defined(XP_BEOS) #include "nsIconDecoder.h" #endif #include "nsIconProtocolHandler.h" @@ -53,14 +53,14 @@ */ #define NS_ICONPROTOCOL_CID { 0xd0f9db12, 0x249c, 0x11d5, { 0x99, 0x5, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b } } -#if defined(XP_MACOSX) || defined(XP_OS2) +#if defined(XP_MACOSX) || defined(XP_OS2) || defined(XP_BEOS) NS_GENERIC_FACTORY_CONSTRUCTOR(nsIconDecoder) #endif NS_GENERIC_FACTORY_CONSTRUCTOR(nsIconProtocolHandler) static const nsModuleComponentInfo components[] = { -#if defined(XP_MACOSX) || defined(XP_OS2) +#if defined(XP_MACOSX) || defined(XP_OS2) || defined(XP_BEOS) { "icon decoder", NS_ICONDECODER_CID, "@mozilla.org/image/decoder;2?type=image/icon", diff --git a/toolkit/mozapps/downloads/content/download.xml b/toolkit/mozapps/downloads/content/download.xml index 7535b2bce50..c4ffc8547a5 100644 --- a/toolkit/mozapps/downloads/content/download.xml +++ b/toolkit/mozapps/downloads/content/download.xml @@ -39,6 +39,12 @@ # # ***** END LICENSE BLOCK ***** +#ifdef XP_WIN +#define SHOW_ICONS +#endif +#ifdef XP_BEOS +#define SHOW_ICONS +#endif @@ -131,7 +137,7 @@ -#ifdef XP_WIN +#ifdef SHOW_ICONS @@ -151,7 +157,7 @@ -#ifdef XP_WIN +#ifdef SHOW_ICONS @@ -292,7 +298,7 @@ -#ifdef XP_WIN +#ifdef SHOW_ICONS @@ -331,7 +337,7 @@ -#ifdef XP_WIN +#ifdef SHOW_ICONS @@ -353,7 +359,7 @@ -#ifdef XP_WIN +#ifdef SHOW_ICONS @@ -375,7 +381,7 @@ -#ifdef XP_WIN +#ifdef SHOW_ICONS