engine/collectionframework/thumbnailcreator/inc/glxtnsavethumbnailtask.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 save task implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  * @internal reviewed 30/07/2007 by Simon Brooks
       
    22  */
       
    23 
       
    24 #ifndef GLXTNSAVETHUMBNAILTASK_H
       
    25 #define GLXTNSAVETHUMBNAILTASK_H
       
    26 
       
    27 // INCLUDES
       
    28 
       
    29 #include "glxtntask.h"
       
    30 
       
    31 // CONSTANTS
       
    32 
       
    33 // MACROS
       
    34 
       
    35 // DATA TYPES
       
    36 
       
    37 // FUNCTION PROTOTYPES
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 
       
    41 class CFbsBitmap;
       
    42 class CImageEncoder;
       
    43 class CGlxtnFileInfo;
       
    44 
       
    45 // CLASS DECLARATION
       
    46 
       
    47 /**
       
    48 * Task to save a generated thumbnail in persistent storage.
       
    49 *
       
    50 * @author Dan Rhodes
       
    51 * @ingroup glx_thumbnail_creator
       
    52 */
       
    53 NONSHARABLE_CLASS(CGlxtnSaveThumbnailTask) : public CGlxtnTask
       
    54     {
       
    55     public:  // Constructors and destructor
       
    56 
       
    57         /**
       
    58         * Two-phased constructor.
       
    59         * @param iItemId Media ID of item whose thumbnail is to be saved.
       
    60         * @param aFileInfo Information about the media file.
       
    61         * @param aSize Requested thumbnail size.
       
    62         * @param aThumbnail Thumbnail bitmap to save.
       
    63         * @param aStorage Client's storage interface.
       
    64         */
       
    65         static CGlxtnSaveThumbnailTask* NewL(
       
    66                     const TGlxMediaId& aItemId,
       
    67                     CGlxtnFileInfo* aFileInfo, const TSize& aSize,
       
    68                     CFbsBitmap* aThumbnail, MGlxtnThumbnailStorage* aStorage);
       
    69 
       
    70         /**
       
    71         * Destructor.
       
    72         */
       
    73         virtual ~CGlxtnSaveThumbnailTask();
       
    74 
       
    75     protected:  // From CGlxtnTask
       
    76         TBool DoStartL(TRequestStatus& aStatus);
       
    77     	void DoCancel(); 
       
    78     	TBool DoRunL(TRequestStatus& aStatus);
       
    79         TBool DoRunError(TInt aError);
       
    80 
       
    81     protected:
       
    82         /**
       
    83         * Constructor for derived classes.
       
    84         * @param aId Task type ID.
       
    85         * @param iItemId Media ID of item whose thumbnail is to be saved.
       
    86         * @param aStorage Client's storage interface.
       
    87         */
       
    88         CGlxtnSaveThumbnailTask(const TGlxtnTaskId& aId,
       
    89                 const TGlxMediaId& aItemId, MGlxtnThumbnailStorage* aStorage);
       
    90 
       
    91         /**
       
    92         * Encode the bitmap to a data buffer.
       
    93         * @param aStatus Request status for the asynchronous operation.
       
    94         */
       
    95         void EncodeThumbnailL(TRequestStatus& aStatus);
       
    96         /**
       
    97         * Save buffer to storage.
       
    98         * @param aStatus Request status for the asynchronous operation.
       
    99         */
       
   100         void SaveThumbnailL(TRequestStatus& aStatus);
       
   101 
       
   102     private:
       
   103         /**
       
   104         * Constructor.
       
   105         * @param iItemId Media ID of item whose thumbnail is to be saved.
       
   106         * @param aSize Requested thumbnail size.
       
   107         * @param aStorage Client's storage interface.
       
   108         */
       
   109         CGlxtnSaveThumbnailTask(const TGlxMediaId& aItemId, const TSize& aSize,
       
   110                                 MGlxtnThumbnailStorage* aStorage);
       
   111 
       
   112         /**
       
   113         * By default Symbian 2nd phase constructor is private.
       
   114         * @param aFileInfo Information about the media file.
       
   115         * @param aThumbnail Thumbnail bitmap to save.
       
   116         */
       
   117         void ConstructL(CGlxtnFileInfo* aFileInfo, CFbsBitmap* aThumbnail);
       
   118 
       
   119     protected:  // Data
       
   120         /**
       
   121         * States for the task's state machine.
       
   122         */
       
   123         enum TSaveState
       
   124             {
       
   125             EStateEncoding, EStateSaving, EStateFetchingUri, 
       
   126             EStateDecoding, EStateChecking, EStateScaling, EStateFiltering
       
   127             };
       
   128 
       
   129         /** Requested thumbnail size */
       
   130         TSize iSize;
       
   131         /** Information about the item's media file */
       
   132         CGlxtnFileInfo* iFileInfo;
       
   133         /** Thumbnail bitmap to save (owned) */
       
   134         CFbsBitmap* iThumbnail;
       
   135         /** Current task state */
       
   136         TSaveState iState;
       
   137 
       
   138     private:    // Data
       
   139         /** Format in which the bitmap was encoded */
       
   140         TGlxImageDataFormat iFormat;
       
   141         /** Encoder for the bitmap (owned) */
       
   142         CImageEncoder* iEncoder;
       
   143         /** Buffer for encoded data (owned) */
       
   144         HBufC8* iData;
       
   145     };
       
   146 
       
   147 #endif  // GLXTNSAVETHUMBNAILTASK_H
       
   148 
       
   149 // End of File