imagehandlingutilities/thumbnailmanager/inc/thumbnailprovider.h
changeset 0 2014ca87e772
equal deleted inserted replaced
-1:000000000000 0:2014ca87e772
       
     1 /*
       
     2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Base class for thumbnail provider plug-ins
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef THUMBNAILPROVIDER_H
       
    20 #define THUMBNAILPROVIDER_H
       
    21 
       
    22 #include <ecom/ecom.h>
       
    23 #include <apmstd.h>
       
    24 
       
    25 #include "thumbnailmanager.h" // TThumbnailFlags
       
    26 #include "thumbnaillog.h"
       
    27 
       
    28 /**
       
    29  *  Thumbnail provider observer class
       
    30  *
       
    31  *  @since S60 v5.0
       
    32  */
       
    33 class MThumbnailProviderObserver
       
    34     {
       
    35 public:
       
    36     /**
       
    37      * Thumbnail provider observer callback to notify the server when
       
    38      * thumbnail has been generated.
       
    39      *
       
    40      * @since S60 5.0
       
    41      * @param aError Error code
       
    42      * @param aBitmap Thumbnail bitmap. The observer implementation will
       
    43      *                assume ownership of the bitmap.
       
    44      * @param aOriginalSize Original size of the object in pixels.
       
    45      * @param aEXIF ETrue if thumbnail origin is EXIF.
       
    46      */
       
    47     virtual void ThumbnailProviderReady( TInt aError, CFbsBitmap* aBitmap,
       
    48         const TSize& aOriginalSize, const TBool aEXIF, const TBool aPortrait  ) = 0;
       
    49 };
       
    50 
       
    51 
       
    52 /**
       
    53  *  Base class for thumbnail provider plug-ins.
       
    54  *
       
    55  *  @since S60 v5.0
       
    56  */
       
    57 class CThumbnailProvider: public CBase
       
    58     {
       
    59 public:
       
    60     /**
       
    61      * Create a provider instance. The instance is identified
       
    62      * by the implementation UID.
       
    63      */
       
    64     static CThumbnailProvider* NewL( TUid aUid );
       
    65 
       
    66     /**
       
    67      * Get the UID of this provider.
       
    68      *
       
    69      * @since S60 5.0
       
    70      * @return Provider implementation UID
       
    71      */
       
    72     TUid Uid();
       
    73 
       
    74     /**
       
    75      * Set the observer to receive notification
       
    76      * about thumbnail generation completion.
       
    77      *
       
    78      * @since S60 5.0
       
    79      * @param aObserver Reference to the observing object. Ownership not
       
    80      *                  transferred.
       
    81      */
       
    82     void SetObserver( MThumbnailProviderObserver& aObserver );
       
    83 
       
    84     /**
       
    85      * Set the target size for uncropped thumbnails. The actual thumbnail
       
    86      * at least this wide or high, depending on which is the limiting
       
    87      * factor.
       
    88      *
       
    89      * @since S60 5.0
       
    90      * @param aSize Target size in pixels for uncropped thumbnails.
       
    91      */
       
    92     void SetTargetSize( const TSize& aSize );
       
    93 
       
    94     /**
       
    95      * Set the target size for cropped thumbnails. The actual thumbnail
       
    96      * at least this large and it will include the whole thumbnail,
       
    97      * not just the cropped portion.
       
    98      *
       
    99      * @since S60 5.0
       
   100      * @param aCroppedSize Target size in pixels for cropped thumbnails.
       
   101      */
       
   102     void SetCroppedTargetSize( const TSize& aCroppedSize );
       
   103 
       
   104     /**
       
   105      * Reset thumbnail parameters to defaults.
       
   106      */
       
   107     void Reset();
       
   108 
       
   109     /**
       
   110      * Get thumbnail bitmap. Must be implemented by provider plug-ins.
       
   111      *
       
   112      * @since S60 5.0
       
   113      * @param aFs File server session that can be used
       
   114      * @param aFile File handle to the object file
       
   115      * @param aMimeType MIME-type of the object file.
       
   116      * @param aFlags Thumbnail generation flags
       
   117      * @param aDisplayMode Display mode
       
   118      */
       
   119     virtual void GetThumbnailL( RFs& aFs, RFile64& aFile, const TDataType&
       
   120         aMimeType, const CThumbnailManager::TThumbnailFlags aFlags, const
       
   121         TDisplayMode aDisplayMode, const CThumbnailManager::TThumbnailQualityPreference aQualityPreference ) = 0;
       
   122   
       
   123     /**
       
   124      * Get thumbnail bitmap. Must be implemented by provider plug-ins.
       
   125      *
       
   126      * @since S60 5.0
       
   127      * @param aFs File server session that can be used
       
   128      * @param aBuffer object buffer
       
   129      * @param aMimeType MIME-type of the object file.
       
   130      * @param aFlags Thumbnail generation flags
       
   131      * @param aDisplayMode Display mode
       
   132      */    
       
   133     virtual void GetThumbnailL( RFs& aFs, TDesC8* aBuffer, const
       
   134         TDataType& aMimeType, const CThumbnailManager::TThumbnailFlags aFlags,
       
   135         const TDisplayMode aDisplayMode, const CThumbnailManager::TThumbnailQualityPreference aQualityPreference  ) = 0;  
       
   136     
       
   137     /**
       
   138      * Get thumbnail bitmap. Must be implemented by provider plug-ins.
       
   139      *
       
   140      * @since S60 5.0
       
   141      * @param aFs File server session that can be used
       
   142      * @param aBuffer object buffer
       
   143      */
       
   144     
       
   145     virtual void GetThumbnailL( RFs& aFs, TDesC8& aBuffer) = 0;
       
   146 
       
   147     /**
       
   148      * Cancel a previous thumbnail request, if any.
       
   149      *
       
   150      * @since S60 5.0
       
   151      */
       
   152     virtual void CancelGetThumbnail() = 0;
       
   153 
       
   154     virtual ~CThumbnailProvider(){}
       
   155 
       
   156 protected:
       
   157     /**
       
   158      * Get the actual target size for the thumbnail.
       
   159      * This is the maximum of the non-cropped and cropped
       
   160      * target sizes.
       
   161      *
       
   162      * @since S60 5.0
       
   163      */
       
   164     inline void ResolveSize();
       
   165 
       
   166     /**
       
   167      * Calculate the scaled down size for the thumbnail.
       
   168      * Aspect ratio is always preserved. If cropping is disabled
       
   169      * the resulting size at most as wide or tall as requested.
       
   170      * If cropping is enabled, the result is at least as wide
       
   171      * and as tall as requested (unless original size is smaller
       
   172      * than requested).
       
   173      *
       
   174      * @since S60 5.0
       
   175      * @param aOriginalSize Original size in pixels
       
   176      * @param aTargetSize Target size in pixels
       
   177      * @param aCrop Enable cropping
       
   178      * @return Result size
       
   179      */
       
   180     inline TSize FitToSize( const TSize& aOriginalSize, const TSize&
       
   181         aTargetSize, TBool aCrop );
       
   182 
       
   183 protected:
       
   184     /**
       
   185      * Provider observer. Implemented by thumbnail generation task.
       
   186      * Not own.
       
   187      */
       
   188     MThumbnailProviderObserver* iObserver;
       
   189 
       
   190     /**
       
   191      * Thumbnail generation flags.
       
   192      */
       
   193     CThumbnailManager::TThumbnailFlags iFlags;
       
   194 
       
   195     /**
       
   196      * Thumbnail generation flags.
       
   197      */
       
   198     CThumbnailManager::TThumbnailQualityPreference iQualityPreference;
       
   199 
       
   200     /**
       
   201      * Size of the original object.
       
   202      */
       
   203     TSize iOriginalSize;
       
   204 
       
   205     /**
       
   206      * Target size for uncropped thumbnails.
       
   207      */
       
   208     TSize iTargetSize;
       
   209 
       
   210     /**
       
   211      * Target size for cropped thumbnails.
       
   212      */
       
   213     TSize iCroppedTargetSize;
       
   214 
       
   215     /**
       
   216      * Display mode for thumbnail bitmap
       
   217      */
       
   218     TDisplayMode iDisplayMode;
       
   219 
       
   220     /**
       
   221      * ECOM plug-in destructor key.
       
   222      */
       
   223     TUid iDtor_ID_Key;
       
   224 
       
   225     /**
       
   226      * UID of this implementation.
       
   227      */
       
   228     TUid iUid;
       
   229 };
       
   230 
       
   231 
       
   232 #endif // THUMBNAILPROVIDER_H