imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailgeneratetask.h
changeset 54 48dd0f169f0d
parent 42 2e2a89493e2b
equal deleted inserted replaced
42:2e2a89493e2b 54:48dd0f169f0d
     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:  Task for generating new thumbnails
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef THUMBNAILGENERATETASK_H
       
    20 #define THUMBNAILGENERATETASK_H
       
    21 
       
    22 #include <apmstd.h>
       
    23 
       
    24 #include "thumbnailtask.h"
       
    25 #include "thumbnailprovider.h"
       
    26 #include "thumbnailstore.h" // TThumbnailPersistentSize
       
    27 
       
    28 class CThumbnailServer;
       
    29 
       
    30 /**
       
    31  *  Task for generating new thumbnails.
       
    32  *
       
    33  *  @since S60 v5.0
       
    34  */
       
    35 class CThumbnailGenerateTask: public CThumbnailTask,
       
    36                               public MThumbnailProviderObserver
       
    37     {
       
    38 public:
       
    39 
       
    40     /**
       
    41      * C++ default constructor
       
    42      *
       
    43      * @since S60 v5.0
       
    44      * @param aProcessor Processor object for running tasks.
       
    45      * @param aServer Thumbnail server in use.
       
    46      * @param aFile File from which the thumbnail is to be created.
       
    47      * @param aFlags Flags that control the creation of thumbnail.
       
    48      * @param aSize Requested size of thumbnail.
       
    49      * @param aDisplayMode Display mode.
       
    50      * @param aPriority Priority of the request.
       
    51      * @return New CThumbnailGenerateTask object.
       
    52      */
       
    53     CThumbnailGenerateTask( CThumbnailTaskProcessor& aProcessor, CThumbnailServer& aServer,
       
    54             RFile64* aFile, TDesC8* aBuffer, const TDataType* aMimeType,
       
    55             CThumbnailManager::TThumbnailFlags aFlags, const TSize& aSize,
       
    56             TDisplayMode aDisplayMode, TInt aPriority,
       
    57             RArray < TThumbnailPersistentSize >* aMissingSizes, const TDesC& aTargetUri,
       
    58             TThumbnailSize aThumbnailSize, const TInt64 aModified,
       
    59             const CThumbnailManager::TThumbnailQualityPreference aQualityPreference,
       
    60             TBool aImportVirtual );
       
    61 
       
    62     /**
       
    63      * Destructor.
       
    64      *
       
    65      * @since S60 v5.0
       
    66      */
       
    67     virtual ~CThumbnailGenerateTask();
       
    68 
       
    69     /**
       
    70      * StartL
       
    71      *
       
    72      * @since S60 v5.0
       
    73      */
       
    74     void StartL();
       
    75 
       
    76     /**
       
    77      * Handles an active object's request completion event.
       
    78      *
       
    79      * @since S60 v5.0
       
    80      */
       
    81     void RunL();
       
    82 
       
    83     /**
       
    84      * Implements cancellation of an outstanding request.
       
    85      *
       
    86      * @since S60 v5.0
       
    87      */
       
    88     void DoCancel();
       
    89 
       
    90     /**
       
    91      * Defines if scaled bitmaps needs to be added to pool.
       
    92      *
       
    93      * @since S60 v5.0
       
    94      * @param aBool boolean
       
    95      */
       
    96     void ScaledBitmapToPool(TBool aBool);    
       
    97     
       
    98 private:
       
    99 
       
   100     /**
       
   101      * Calculate the largest non-cropped size and largest cropped size and
       
   102      * let the provider know.
       
   103      *
       
   104      * @since S60 v5.0
       
   105      * @param aEffectiveTargetSize Effective target size.
       
   106      * @param aCroppedTargetSize Cropped target size.
       
   107      */
       
   108     void CalculateTargetSizesL( TSize& aEffectiveTargetSize, TSize&
       
   109         aCroppedTargetSize );
       
   110 
       
   111     /**
       
   112      * For notifying when task has been finished.
       
   113      *
       
   114      * @since S60 v5.0
       
   115      * @param aError Error code.
       
   116      * @param aBitmap Thumbnail image.
       
   117      * @param aOriginalSize Original image size.
       
   118      * @param aEXIF is origin EXIF.
       
   119      */
       
   120     void ThumbnailProviderReady( const TInt aError, CFbsBitmap* aBitmap, const
       
   121         TSize& aOriginalSize, const TBool aEXIF, const TBool aPortrait );
       
   122 
       
   123     /**
       
   124      * For creating scaling task.
       
   125      *
       
   126      * @since S60 v5.0
       
   127      * @param aBitmap Bitmap image.
       
   128      * @param aEXIF is origin EXIF.
       
   129      */
       
   130     void CreateScaleTasksL( CFbsBitmap* aBitmap );
       
   131     
       
   132     /**
       
   133      * For creating blacklisted thumbnail.
       
   134      *
       
   135      * @param aOriginalSize Original size of bitmap.
       
   136      */
       
   137     void CreateBlackListedL( const TSize& aOriginalSize );
       
   138     
       
   139     
       
   140     /**
       
   141      * Check is blacklisting needed
       
   142      *
       
   143      * @param aErrorCode verdict is based on this error code
       
   144      * @param aOriginalSize Original size of bitmap.
       
   145      */
       
   146     void DoBlacklisting( const TInt aError, const TSize& aOriginalSize );
       
   147     
       
   148 private:
       
   149     // Data
       
   150 
       
   151     /**
       
   152      * Server.
       
   153      */
       
   154     CThumbnailServer& iServer;
       
   155 
       
   156     /**
       
   157      * Imagefile from which the thumbnail is to be created.
       
   158      */
       
   159     RFile64 iFile;
       
   160     
       
   161     /**
       
   162      * Image buffer
       
   163      */    
       
   164     TDesC8* iBuffer;
       
   165 
       
   166     /**
       
   167      * Mime type of the original image.
       
   168      */
       
   169     TDataType iMimeType;
       
   170 
       
   171     /**
       
   172      * Filename of the image from which the thumbnail is to be created.
       
   173      */
       
   174     TFileName iFilename;
       
   175     
       
   176     /**
       
   177      * Flags
       
   178      */
       
   179     CThumbnailManager::TThumbnailFlags iFlags;
       
   180     /**
       
   181      * Requested  size of thumbnail.
       
   182      */
       
   183     TSize iSize;
       
   184 
       
   185     /**
       
   186      * Display mode.
       
   187      */
       
   188     TDisplayMode iDisplayMode;
       
   189 
       
   190     /**
       
   191      * Only missing persistent sized thumbnails will be created
       
   192      */
       
   193     RArray < TThumbnailPersistentSize >* iMissingSizes;
       
   194 
       
   195     /**
       
   196      * Uri of the target object
       
   197      */
       
   198     TFileName iTargetUri;    
       
   199     
       
   200     /**
       
   201      * Relative thumbnail size
       
   202      */
       
   203     TThumbnailSize iThumbnailSize;    
       
   204     
       
   205 	 /**
       
   206      * timestamp
       
   207      */
       
   208     TInt64 iModified;
       
   209 
       
   210     /**
       
   211      * Size of the original image.
       
   212      */
       
   213     TSize iOriginalSize;
       
   214 
       
   215     /**
       
   216      * Thumbnail provider implementation.
       
   217      * Not own.
       
   218      */
       
   219     CThumbnailProvider* iProvider;
       
   220     
       
   221     TBool iScaledBitmapToPool;
       
   222     
       
   223 #ifdef _DEBUG
       
   224     TTime aStart, aStop;
       
   225 #endif
       
   226     
       
   227     CThumbnailManager::TThumbnailQualityPreference iQualityPreference;
       
   228     
       
   229     TBool iEXIF;
       
   230     
       
   231     /**
       
   232      * Target rect rotated (portrait image)
       
   233      */
       
   234     TBool iPortrait;
       
   235     
       
   236     TInt iBitmapHandle;
       
   237     
       
   238     // virtual uri
       
   239     TBool iVirtualUri;
       
   240 };
       
   241 
       
   242 #endif // THUMBNAILGENERATETASK_H