Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsIconChannel.cpp File Reference
#include "nsIconChannel.h"
#include "nsIIconURI.h"
#include "nsIServiceManager.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsXPIDLString.h"
#include "nsMimeTypes.h"
#include "nsMemory.h"
#include "nsIStringStream.h"
#include "nsIURL.h"
#include "nsNetUtil.h"
#include "nsIMIMEService.h"
#include "nsCExternalHandlerService.h"
#include "plstr.h"
#include "nsILocalFileMac.h"
#include "nsIFileURL.h"
#include "nsInt64.h"
#include <Icons.h>
#include <Files.h>
#include <Folders.h>
#include <Quickdraw.h>
#include <MacMemory.h>

Go to the source code of this file.

Functions

 NS_IMPL_THREADSAFE_ISUPPORTS4 (nsIconChannel, nsIChannel, nsIRequest, nsIRequestObserver, nsIStreamListener) nsresult nsIconChannel
nsresult GetLockedIconData (IconFamilyHandle iconFamilyH, PRUint32 iconType, Handle iconDataH, PRUint32 *iconDataSize)
nsresult GetLockedIcons (IconFamilyHandle icnFamily, PRUint32 desiredImageSize, Handle iconH, PRUint32 *dataCount, PRBool *isIndexedData, Handle iconMaskH, PRUint32 *maskCount, PRUint8 *alphaBitCount)

Function Documentation

nsresult GetLockedIconData ( IconFamilyHandle  iconFamilyH,
PRUint32  iconType,
Handle  iconDataH,
PRUint32 iconDataSize 
)

Definition at line 219 of file nsIconChannel.cpp.

{
  *iconDataSize = 0;

  if (::GetIconFamilyData(iconFamilyH, iconType, iconDataH) != noErr)
    return(NS_ERROR_FAILURE);

  *iconDataSize = (PRUint32)::GetHandleSize(iconDataH);
  if (*iconDataSize > 0)
  {
    ::HLock(iconDataH);
  }
  return(NS_OK);
}

Here is the caller graph for this function:

nsresult GetLockedIcons ( IconFamilyHandle  icnFamily,
PRUint32  desiredImageSize,
Handle  iconH,
PRUint32 dataCount,
PRBool isIndexedData,
Handle  iconMaskH,
PRUint32 maskCount,
PRUint8 alphaBitCount 
)

Definition at line 237 of file nsIconChannel.cpp.

{
  // 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))
  {
    // try to get an 8-bit alpha mask first
    *alphaBitCount = 8;
    rv = GetLockedIconData(icnFamily, (desiredImageSize > 16) ?
                           kLarge8BitMask : kSmall8BitMask,
                           iconMaskH, maskCount);
    if (NS_FAILED(rv) || (*maskCount == 0)) {
      // oh well, try to get a 1-bit mask
      *alphaBitCount = 1;
      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;
}

Here is the call graph for this function:

Definition at line 76 of file nsIconChannel.cpp.

{
  NS_ASSERTION(uri, "no uri");
  mUrl = uri;
  
  nsresult rv;
  mPump = do_CreateInstance(NS_INPUTSTREAMPUMP_CONTRACTID, &rv);
  return rv;
}

Here is the call graph for this function: