engine/collectionframework/thumbnailcreator/inc/glxtnbackgroundgenerationtask.h
changeset 71 27f2d7aec52a
parent 69 45459746d5e8
child 72 0a8e959402e5
equal deleted inserted replaced
69:45459746d5e8 71:27f2d7aec52a
     1 /*
       
     2 * Copyright (c) 2008-2009 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:   Thumbnail background generation task implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  * @internal reviewed 30/07/2007 by Simon Brooks
       
    22  */
       
    23 
       
    24 #ifndef GLXTNBACKGROUNDGENERATIONTASK_H
       
    25 #define GLXTNBACKGROUNDGENERATIONTASK_H
       
    26 
       
    27 // INCLUDES
       
    28 
       
    29 #include "glxtnsavethumbnailtask.h"
       
    30 #include <glxsettingsmodel.h>
       
    31 
       
    32 // CONSTANTS
       
    33 
       
    34 // MACROS
       
    35 
       
    36 // DATA TYPES
       
    37 
       
    38 // FUNCTION PROTOTYPES
       
    39 
       
    40 // FORWARD DECLARATIONS
       
    41 
       
    42 class CGlxtnFileUtility;
       
    43 class CGlxtnImageUtility;
       
    44 class CGlxtnVideoUtility;
       
    45 
       
    46 // CLASS DECLARATION
       
    47 
       
    48 /**
       
    49 * Background task to generate a thumbnail.
       
    50 *
       
    51 * @author Dan Rhodes
       
    52 * @ingroup glx_thumbnail_creator
       
    53 */
       
    54 NONSHARABLE_CLASS(CGlxtnBackgroundGenerationTask) : public CGlxtnSaveThumbnailTask
       
    55     {
       
    56     public:  // Constructors and destructor
       
    57 
       
    58         /**
       
    59         * Two-phased constructor.
       
    60         * @param iItemId Media ID of item to thumbnail.
       
    61         * @param aFileUtility File utility for use by the task.
       
    62         * @param aClient Client initiating the request.
       
    63         */
       
    64         static CGlxtnBackgroundGenerationTask* NewL(
       
    65                     const TGlxMediaId& iItemId, CGlxtnFileUtility& aFileUtility,
       
    66                     MGlxtnThumbnailCreatorClient& aClient, 
       
    67                     CGlxSettingsModel::TSupportedOrientations aSupportedOrientations);
       
    68 
       
    69         /**
       
    70         * Destructor.
       
    71         */
       
    72         virtual ~CGlxtnBackgroundGenerationTask();
       
    73 
       
    74     private:    // From CGlxtnTask
       
    75         TBool DoStartL(TRequestStatus& aStatus);
       
    76     	void DoCancel(); 
       
    77     	TBool DoRunL(TRequestStatus& aStatus);
       
    78         TBool DoRunError(TInt aError);
       
    79 
       
    80     private:
       
    81         /**
       
    82         * C++ default constructor.
       
    83         * @param iItemId Media ID of item to thumbnail.
       
    84         * @param aFileUtility File utility for use by the task.
       
    85         * @param aClient Client initiating the request.
       
    86         */
       
    87         CGlxtnBackgroundGenerationTask(const TGlxMediaId& iItemId,
       
    88                                     CGlxtnFileUtility& aFileUtility,
       
    89                                     MGlxtnThumbnailCreatorClient& aClient, 
       
    90                     CGlxSettingsModel::TSupportedOrientations aSupportedOrientations);
       
    91 
       
    92         /**
       
    93         * By default Symbian 2nd phase constructor is private.
       
    94         */
       
    95         void ConstructL();
       
    96 
       
    97         /**
       
    98         * Check whether next size already exists or needs to be generated.
       
    99         * @param aStatus Request status for the asynchronous operation.
       
   100         * @return ETrue if the task has issued an asyncronous request.
       
   101         */
       
   102         TBool CheckNextL(TRequestStatus& aStatus);
       
   103 
       
   104         /**
       
   105         * Create the next size to be generated.
       
   106         * @param aStatus Request status for the asynchronous operation.
       
   107         * @return ETrue if the task has issued an asyncronous request.
       
   108         */
       
   109         TBool ProcessNextL(TRequestStatus& aStatus);
       
   110 
       
   111         /**
       
   112         * Filter the thumbnail for the next required size.
       
   113         * @param aStatus Request status for the asynchronous operation.
       
   114         */
       
   115         void FilterThumbnailL(TRequestStatus& aStatus);
       
   116 
       
   117         /**
       
   118         * Scale the thumbnail to the next required size.
       
   119         * @param aStatus Request status for the asynchronous operation.
       
   120         */
       
   121         void ScaleThumbnailL(TRequestStatus& aStatus);
       
   122 
       
   123         /**
       
   124         * Decode the image for the required size.
       
   125         * @param aStatus Request status for the asynchronous operation.
       
   126         */
       
   127         void DecodeImageL(TRequestStatus& aStatus);
       
   128 
       
   129     private:    // Data
       
   130         /** Pointer to client, or NULL after client goes away */
       
   131         MGlxtnThumbnailCreatorClient* iClient;
       
   132         /** File utility */
       
   133         CGlxtnFileUtility& iFileUtility;
       
   134         /** Array of sizes to check if need to generate */
       
   135         RArray<TSize> iSizes;
       
   136         /** Array of sizes to generate */
       
   137         RArray<TSize> iTodoSizes;
       
   138         /** Utility to get thumbnail from image */
       
   139         CGlxtnImageUtility* iImageUtility;
       
   140         /** Utility to get thumbnail from video */
       
   141         CGlxtnVideoUtility* iVideoUtility;
       
   142         /** Image loaded from file */
       
   143         CFbsBitmap* iImage;
       
   144        /** Image loaded from file */
       
   145         CFbsBitmap* iFilteredImage;
       
   146         /** Flag to show BadFileMarker not created so no need to delete **/
       
   147         TBool iBadFileMarkerNotNeededFlag;
       
   148         /** Flag to show whether image has been decoded yet **/
       
   149         TBool iImageDecoded;
       
   150         /** Flag to show which orientations are supported **/
       
   151         CGlxSettingsModel::TSupportedOrientations iSupportedOrientations;
       
   152         
       
   153     };
       
   154 
       
   155 #endif  // GLXTNBACKGROUNDGENERATIONTASK_H
       
   156 
       
   157 // End of File