CThumbnailManager Class Reference

class CThumbnailManager : public CBase

Thumbnail engine.

This is the main interface class to thumbnail engine. Thumbnail engine can be used to request thumbnails for different kinds of media objects.

The client using thumbnail engine must implement the MThumbnailManagerObserver. The observer interface is used to provide thumbnail data when it is available.

Typical use of thumbnail engine consists of 4 parts:

Here is an example of how thumbnail engine could be used by a typical application:

  #include <thumbnailmanagerobserver.h>
  #include <thumbnailmanager.h>

  class CMyThumbnailControl: public CCoeControl,
                             public MThumbnailManagerObserver
      {
  public:
      CMyThumbnailControl();
      ~CMyThumbnailControl();
      ...

      // Callbacks from MThumbnailManagerObserver for getting thumbnails
      void ThumbnailPreviewReady(
          MThumbnailData& aThumbnail,
          TThumbnailRequestId aId );
      void ThumbnailReady(
          TInt aError, 
          MThumbnailData& aThumbnail, 
          TThumbnailRequestId aId );

  private:
      void ConstructL();
      CThumbnailManager* iManager;
      CFbsBitmap* iBitmap;
      }

  _LIT( KTestFilePath, "e:\\TestImage.jpg" );
  _LIT( KTestFileType, "image/jpeg" );

  void CMyThumbnailControl::ConstructL()
      {
      // Create Thumbnail Manager instance. This object is the observer.
      iManager = CThumbnailManager::NewL( *this ); 

      // Set flags: If the aspect ratio of the media object does not match
      // 4:3 then we would like it to be cropped. We don t mind getting
      // smaller images than requested.
      iManager->SetFlagsL( CThumbnailManager::ECropToAspectRatio |
                           CThumbnailManager::EAllowAnySize );

      // Preferred size is 160x120 (or less)
      iManager->SetSizeL( TSize( 160, 120 ) );

      // Get a preview thumbnail first, if available.
      // The preview thumbnail is delivered via a ThumbnailPreviewReady()
      // callback.
      iManager->SetQualityPreferenceL(
          CThumbnailManager::EOptimizeForQualityWithPreview );

      // Create an object source representing a path to a file on local
      // file system.
      CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC(
          KTestFilePath,   // File path
          KTestFileType ); // Let Thumbnail Manager know it s a JPEG, so
                           // it doesn t need to recognize the file format

      // Issue the request using default priority
      iManager->GetThumbnailL( *source );

      // If GetThumbnailL() did not leave, the ThumbnailReady() callback is
      // now guaranteed to be called, unless the request is cancelled or
      // CThumbnailManager instance is deleted.

      // The source can be deleted immediately after issuing the request
      CleanupStack::PopAndDestroy( source );
      }

  CMyThumbnailControl::~CMyThumbnailControl()
      {
      // Bitmap should be destroyed before Thumbnail Manager
      delete iBitmap;
      delete iManager;
      }

  void CMyThumbnailControl::ThumbnailReady(
      TInt aError,
      MThumbnailData& aThumbnail,
      TThumbnailRequestId aId )
      {
      // This function must not leave.

      delete iBitmap; iBitmap = NULL;
      if ( !aError )
          {
          // Claim ownership of the bitmap instance for later use
          iBitmap = aThumbnail.DetachBitmap();

          // We can now use iBitmap in our Draw() method
          DrawDeferred();
          }
      else
          {
          // An error occurred while getting the thumbnail.
          // Perhaps we should show a broken image icon to the user.
          }
      }
thumbnailmanager.lib
Since
S60 v5.0

Inherits from

Public Member Functions
~CThumbnailManager()
TInt CancelRequest(TThumbnailRequestId)
TInt ChangePriority(TThumbnailRequestId, TInt)
TThumbnailRequestId CreateThumbnails(CThumbnailObjectSource &, TInt)
voidDeleteThumbnails(CThumbnailObjectSource &)
voidDeleteThumbnails(const TThumbnailId)
TDisplayMode DisplayMode()
TThumbnailFlags Flags()
const CDesCArray &GetSupportedMimeTypesL()
TThumbnailRequestId GetThumbnailL(CThumbnailObjectSource &, TAny *, TInt)
TThumbnailRequestId GetThumbnailL(const TThumbnailId, TAny *, TInt)
TThumbnailRequestId ImportThumbnailL(CThumbnailObjectSource &, const TDesC &, TAny *, TInt)
IMPORT_C CThumbnailManager *NewL(MThumbnailManagerObserver &)
IMPORT_C CThumbnailManager *NewLC(MThumbnailManagerObserver &)
TThumbnailQualityPreference QualityPreference()
voidRemoveRequestObserver()
TThumbnailRequestId RenameThumbnailsL(const TDesC &, const TDesC &, TInt)
voidSetDisplayModeL(TDisplayMode)
voidSetFlagsL(TThumbnailFlags)
voidSetQualityPreferenceL(TThumbnailQualityPreference)
voidSetRequestObserver(MThumbnailManagerRequestObserver &)
TThumbnailRequestId SetThumbnailL(CThumbnailObjectSource &, TAny *, TInt)
voidSetThumbnailSizeL(const TSize &)
voidSetThumbnailSizeL(const TThumbnailSize)
const TSize &ThumbnailSize()
voidUpdateThumbnailsL(const TThumbnailId, const TDesC &, const TInt, const TInt64, const TInt)
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Public Member Enumerations
enumTThumbnailFlags { EDefaultFlags = 0, EAllowAnySize = 1, EDoNotCreate = 2, ECropToAspectRatio = 4 }
enumTThumbnailQualityPreference { EOptimizeForQuality, EOptimizeForPerformance, EOptimizeForQualityWithPreview }

Constructor & Destructor Documentation

~CThumbnailManager()

~CThumbnailManager()[virtual]

Destructor

Since
S60 v5.0

Member Functions Documentation

CancelRequest(TThumbnailRequestId)

TInt CancelRequest(TThumbnailRequestIdaId)[pure virtual]

Cancel a thumbnail operation.

Since
S60 v5.0

Parameters

TThumbnailRequestId aIdRequest ID for the operation to be cancelled.

ChangePriority(TThumbnailRequestId, TInt)

TInt ChangePriority(TThumbnailRequestIdaId,
TIntaNewPriority
)[pure virtual]

Change the priority of a queued thumbnail operation.

Since
S60 v5.0

Parameters

TThumbnailRequestId aIdRequest ID for the request which to assign a new priority.
TInt aNewPriorityNew priority value

CreateThumbnails(CThumbnailObjectSource &, TInt)

TThumbnailRequestId CreateThumbnails(CThumbnailObjectSource &aObjectSource,
TIntaPriority = CActive::EPriorityIdle
)[pure virtual]

Create thumbnail for a given object. This is an asynchronous operation, which always returns immediately. No callbacks are emitted.

Since
S60 v5.0

Parameters

CThumbnailObjectSource & aObjectSourceSource object or file
TInt aPriority = CActive::EPriorityIdlePriority for this operation

DeleteThumbnails(CThumbnailObjectSource &)

voidDeleteThumbnails(CThumbnailObjectSource &aObjectSource)[pure virtual]

Delete all thumbnails for a given object. This is an asynchronous operation, which always returns immediately.

Since
S60 v5.0

Parameters

CThumbnailObjectSource & aObjectSourceSource object or file

DeleteThumbnails(const TThumbnailId)

voidDeleteThumbnails(const TThumbnailIdaItemId)[pure virtual]

Delete thumbnails by TThumbnailId. This is an asynchronous operation, which always returns immediately.

Since
S60 v5.0

Parameters

const TThumbnailId aItemIdTThumbnailId

DisplayMode()

TDisplayMode DisplayMode()const [pure virtual]

Get the current display mode for thumbnail bitmaps.

Since
S60 v5.0

Flags()

TThumbnailFlags Flags()const [pure virtual]

Get current flags for thumbnail generation.

Since
S60 v5.0

GetSupportedMimeTypesL()

const CDesCArray &GetSupportedMimeTypesL()[pure virtual]

Get a list of supported file formats for object files.

The return value is a reference to a list that contains each supported MIME type. There may also be wildcards, such as "image/*".

The returned reference is valid until CThumbnailManager is destroyed or GetSupportedMimeTypesL() is called again.

Since
S60 v5.0

GetThumbnailL(CThumbnailObjectSource &, TAny *, TInt)

TThumbnailRequestId GetThumbnailL(CThumbnailObjectSource &aObjectSource,
TAny *aClientData = NULL,
TIntaPriority = CActive::EPriorityStandard
)[pure virtual]

Get a thumbnail for an object file. If a thumbnail already exists, it is loaded and if a thumbnail does not exist, it is created transparently. ThumbnailReady() callback will be called when the operation is complete. In addition, ThumbnailPreviewReady() callback may be called if EOptimizeForQualityWithPreview mode was defined.

Current values for display mode, thumbnail size, flags and performance preference are used.

Since
S60 v5.0

Parameters

CThumbnailObjectSource & aObjectSourceSource object or file
TAny * aClientData = NULLPointer to arbitrary client data. This pointer is not used by the API for anything other than returning it in the ThumbnailReady callback.
TInt aPriority = CActive::EPriorityStandardPriority for this operation

GetThumbnailL(const TThumbnailId, TAny *, TInt)

TThumbnailRequestId GetThumbnailL(const TThumbnailIdaThumbnailId,
TAny *aClientData = NULL,
TIntaPriority = CActive::EPriorityStandard
)[pure virtual]

Get a persistent thumbnail for an object file. If a thumbnail already exists, it is loaded and if a thumbnail does not exist, it is created transparently. ThumbnailReady() callback will be called when the operation is complete. In addition, ThumbnailPreviewReady() callback may be called if EOptimizeForQualityWithPreview mode was defined.

Current values for display mode, thumbnail size, flags and performance preference are used.

Since
S60 v5.0

Parameters

const TThumbnailId aThumbnailIdThumbnail ID
TAny * aClientData = NULLPointer to arbitrary client data. This pointer is not used by the API for anything other than returning it in the ThumbnailReady callback.
TInt aPriority = CActive::EPriorityStandardPriority for this operation

ImportThumbnailL(CThumbnailObjectSource &, const TDesC &, TAny *, TInt)

TThumbnailRequestId ImportThumbnailL(CThumbnailObjectSource &aObjectSource,
const TDesC &aTargetUri,
TAny *aClientData = NULL,
TIntaPriority = CActive::EPriorityIdle
)[pure virtual]

Import an image to be used as thumbnail for an object. If a thumbnail already exists, it is loaded and if a thumbnail does not exist, it is created transparently. ThumbnailReady() callback will be called when the operation is complete. In addition, ThumbnailPreviewReady() callback may be called if EOptimizeForQualityWithPreview mode was defined.

Current values for display mode, thumbnail size, flags and performance preference are used.

Since
S60 v5.0

Parameters

CThumbnailObjectSource & aObjectSourceSource object or file
const TDesC & aTargetUriTarget URI to which the imported thumbnail is linked.
TAny * aClientData = NULLPointer to arbitrary client data. This pointer is not used by the API for anything other than returning it in the ThumbnailReady callback.
TInt aPriority = CActive::EPriorityIdlePriority for this operation

NewL(MThumbnailManagerObserver &)

IMPORT_C CThumbnailManager *NewL(MThumbnailManagerObserver &aObserver)[static]

Two-phased constructor.

Since
S60 v5.0

Parameters

MThumbnailManagerObserver & aObserverObserver to receive notifications about completed operations.

NewLC(MThumbnailManagerObserver &)

IMPORT_C CThumbnailManager *NewLC(MThumbnailManagerObserver &aObserver)[static]

Two-phased constructor.

Since
S60 v5.0

Parameters

MThumbnailManagerObserver & aObserverObserver to receive notifications about completed operations.

QualityPreference()

TThumbnailQualityPreference QualityPreference()const [pure virtual]

Get the current quality versus performance preference.

Since
S60 v5.0

RemoveRequestObserver()

voidRemoveRequestObserver()[pure virtual]

Remove optional request observer.

Since
Symbian^3

RenameThumbnailsL(const TDesC &, const TDesC &, TInt)

TThumbnailRequestId RenameThumbnailsL(const TDesC &aCurrentPath,
const TDesC &aNewPath,
TIntaPriority = CActive::EPriorityIdle
)[pure virtual]

Rename Thumbnails. This is an asynchronous operation, which always returns immediately.

Since
S60 v5.0

Parameters

const TDesC & aCurrentPathCurrent path of the Thumbnail
const TDesC & aNewPathNew path for the Thumbnail
TInt aPriority = CActive::EPriorityIdlePriority for this operation

SetDisplayModeL(TDisplayMode)

voidSetDisplayModeL(TDisplayModeaDisplayMode)[pure virtual]

Set the current display mode for thumbnail bitmaps.

Since
S60 v5.0

Parameters

TDisplayMode aDisplayModeNew display mode value for the thumbnail bitmaps.

SetFlagsL(TThumbnailFlags)

voidSetFlagsL(TThumbnailFlagsaFlags)[pure virtual]

Set flags for thumbnail generation. Several flags may be enabled by combining the values using bitwise or.

Since
S60 v5.0

Parameters

TThumbnailFlags aFlagsNew flags.

SetQualityPreferenceL(TThumbnailQualityPreference)

voidSetQualityPreferenceL(TThumbnailQualityPreferenceaQualityPreference)[pure virtual]

Set quality versus performance preference.

Since
S60 v5.0

Parameters

TThumbnailQualityPreference aQualityPreferenceNew quality versus performance preference value.

SetRequestObserver(MThumbnailManagerRequestObserver &)

voidSetRequestObserver(MThumbnailManagerRequestObserver &aObserver)[pure virtual]

Set optional request observer for getting information about completed requests that don't include a thumbnail.

Since
Symbian^3

Parameters

MThumbnailManagerRequestObserver & aObserverObserver to receive notifications.

SetThumbnailL(CThumbnailObjectSource &, TAny *, TInt)

TThumbnailRequestId SetThumbnailL(CThumbnailObjectSource &aObjectSource,
TAny * = NULL,
TIntaPriority = CActive::EPriorityIdle
)[pure virtual]

Set a thumbnail for an object file generated from buffer delivered in source object. ThumbnailReady() callback will be called when the operation is complete. In addition, ThumbnailPreviewReady() callback may be called if EOptimizeForQualityWithPreview mode was defined.

Current values for display mode, thumbnail size, flags and performance preference are used.

Since
S60 v5.0

Parameters

CThumbnailObjectSource & aObjectSource
TAny *  = NULL
TInt aPriority = CActive::EPriorityIdlePriority for this operation

SetThumbnailSizeL(const TSize &)

voidSetThumbnailSizeL(const TSize &aThumbnailSize)[pure virtual]

Set desired size for thumbnail bitmaps.

Since
S60 v5.0

Parameters

const TSize & aThumbnailSizeNew quality for the desired thumbnail size.

SetThumbnailSizeL(const TThumbnailSize)

voidSetThumbnailSizeL(const TThumbnailSizeaThumbnailSize)[pure virtual]

Set desired size for thumbnail bitmaps.

Since
S60 v5.0

Parameters

const TThumbnailSize aThumbnailSizeDesired thumbnail size.

ThumbnailSize()

const TSize &ThumbnailSize()const [pure virtual]

Get the current desired size for thumbnail bitmaps.

Since
S60 v5.0

UpdateThumbnailsL(const TThumbnailId, const TDesC &, const TInt, const TInt64, const TInt)

voidUpdateThumbnailsL(const TThumbnailIdaItemId,
const TDesC &aPath,
const TIntaOrientation,
const TInt64aModified,
const TIntaPriority
)[pure virtual]

Update Thumbnails by TThumbnailId. This is an asynchronous operation, which always returns immediately.

Since
S60 v5.0

Parameters

const TThumbnailId aItemIdTThumbnailId
const TDesC & aPath(New) path for the Thumbnail
const TInt aOrientationThumbnail orientation
const TInt64 aModifiedLast modified
const TInt aPriority

Member Enumerations Documentation

Enum TThumbnailFlags

Flags for thumbnail creation. These can be combined using bitwise or.

Enumerators

EDefaultFlags = 0
Default flags. This means that:
  • Thumbnail must be as large as requested (unless the actual object is smaller).

  • Smaller thumbnails may be up scaled to desired resolution.

  • Aspect ratio is maintained and thumbnails are not cropped. The resulting thumbnail may smaller in either width or height if the aspect ratio of the object does not match the aspect ratio of the requested size.

EAllowAnySize = 1

Allow thumbnails which are smaller than requested are. Thumbnail bitmaps are never up scaled if this flag is set.

EDoNotCreate = 2

New thumbnail images are not created if this flag is set. Only existing thumbnails may be returned. If a requested thumbnail does not exist, KErrNotFound error is returned in ThumbnailReady() callback.

ECropToAspectRatio = 4

Thumbnail images are cropped to match requested aspect ratio. If this flag is set, the size of the resulting thumbnail always matches the requested size.

Enum TThumbnailQualityPreference

Quality versus speed preference setting

Enumerators

EOptimizeForQuality

Prefer thumbnails in the highest quality possible disregarding any negative impact on performance.

EOptimizeForPerformance

Get thumbnails as fast as possible, even if it means lower quality.

EOptimizeForQualityWithPreview

Get lower quality preview thumbnail as fast as possible first and then a higher quality thumbnail later. The preview thumbnail is provided in the ThumbnailPreviewReady() callback and the high quality thumbnail in ThumbnailReady(). ThumbnailPreviewReady() is not get called at all if a suitable existing thumbnail is not found or if a high quality version is already available.