engine/collectionframework/thumbnailcreator/inc/glxtndatabase.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 storage implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 /**
       
    21  * @internal reviewed 30/07/2007 by Simon Brooks
       
    22  */
       
    23 
       
    24 #ifndef GLXTNDATABASE_H
       
    25 #define GLXTNDATABASE_H
       
    26 
       
    27 // INCLUDES
       
    28 
       
    29 #include <e32base.h>
       
    30 #include <f32file.h>
       
    31 #include "mglxtnstorage.h"
       
    32 #include "mglxtnvolumedatabaseobserver.h"
       
    33 
       
    34 // CONSTANTS
       
    35 
       
    36 // MACROS
       
    37 
       
    38 // DATA TYPES
       
    39 
       
    40 // FUNCTION PROTOTYPES
       
    41 
       
    42 // FORWARD DECLARATIONS
       
    43 
       
    44 class CGlxtnVolumeDatabase;
       
    45 
       
    46 // CLASS DECLARATION
       
    47 
       
    48 /**
       
    49 *  Default implementation of thumbnail storage.
       
    50 *
       
    51 * @author Dan Rhodes
       
    52 * @ingroup glx_thumbnail_creator
       
    53 */
       
    54 class CGlxtnThumbnailDatabase : public CBase, public MGlxtnThumbnailStorage,
       
    55                                 public MGlxtnVolumeDatabaseObserver
       
    56     {
       
    57     public:  // Constructors and destructor
       
    58 
       
    59         /**
       
    60         * Two-phased constructor.
       
    61         * @param aDbFilename Filename (without path) for database.
       
    62         * @param aStorageObserver Observer of storage operations.
       
    63         */
       
    64         IMPORT_C static CGlxtnThumbnailDatabase* NewL(const TDesC& aDbFilename,
       
    65                 MGlxtnThumbnailStorageObserver* aStorageObserver = NULL);
       
    66 
       
    67         /**
       
    68         * Destructor.
       
    69         */
       
    70         virtual ~CGlxtnThumbnailDatabase();
       
    71 
       
    72     public: // New functions
       
    73 
       
    74     public: // Functions from MGlxtnThumbnailStorage
       
    75         void LoadThumbnailDataL(HBufC8*& aData, TGlxImageDataFormat& aFormat,
       
    76                     const TGlxMediaId& aId, const CGlxtnFileInfo& aFileInfo,
       
    77                     const TSize& aSize, TRequestStatus* aStatus);
       
    78         void SaveThumbnailDataL(const TDesC8& aData,
       
    79                     TGlxImageDataFormat aFormat, const TGlxMediaId& aId,
       
    80                     const CGlxtnFileInfo& aFileInfo, const TSize& aSize,
       
    81                     TRequestStatus* aStatus);
       
    82         void DeleteThumbnailsL(const TGlxMediaId& aId,
       
    83                     const CGlxtnFileInfo& aFileInfo, TRequestStatus* aStatus);
       
    84         void CleanupThumbnailsL(TRequestStatus* aStatus);
       
    85         void IsThumbnailAvailableL(const TGlxMediaId& aId,
       
    86                     const CGlxtnFileInfo& aFileInfo,
       
    87                     const TSize& aSize, TRequestStatus* aStatus);
       
    88         void StorageCancel();
       
    89         void NotifyBackgroundError(const TGlxMediaId& aId, TInt aError);
       
    90 
       
    91     private:    // From MGlxtnVolumeDatabaseObserver
       
    92         void HandleDatabaseError(TInt aError);
       
    93         void HandleThumbnailIdFromMediaIdL(
       
    94                                         const TGlxtnThumbnailId& aThumbId );
       
    95         void HandleThumbnailIdFromFilenameL(
       
    96                                         const TGlxtnThumbnailId& aThumbId );
       
    97         void HandleThumbnailIdStoredL();
       
    98         void HandleThumbnail(TGlxImageDataFormat aFormat, HBufC8* aData);
       
    99         void HandleThumbnailStored();
       
   100         void HandleMediaIdDeletedL();
       
   101         void HandleThumbnailsDeletedL();
       
   102         void HandleItemDeletedL();
       
   103         void HandleAvailabilityChecked(TInt aResult);
       
   104         void HandleDatabaseCleanedL();
       
   105 
       
   106     private:
       
   107 
       
   108         /**
       
   109         * C++ default constructor.
       
   110         */
       
   111         CGlxtnThumbnailDatabase();
       
   112 
       
   113         /**
       
   114         * By default Symbian 2nd phase constructor is private.
       
   115         * @param aDbFilename Filename (without path) for database.
       
   116         * @param aStorageObserver Observer of storage operations.
       
   117         */
       
   118         void ConstructL(const TDesC& aDbFilename,
       
   119                         MGlxtnThumbnailStorageObserver* aStorageObserver);
       
   120 
       
   121         /**
       
   122         * Continue current operation after receiving the thumbnail ID.
       
   123         */
       
   124         void DoHandleThumbnailIdL();
       
   125 
       
   126         /**
       
   127         * Open a volume database on the specified drive.
       
   128         * @param aDrive String beginnning with drive letter and colon.
       
   129         */
       
   130         CGlxtnVolumeDatabase* OpenDatabaseL(const TDesC& aDrive);
       
   131 
       
   132     private:    // Data
       
   133         enum TDatabaseOperation
       
   134             {
       
   135             ELoading, ESaving, EDeleting, ECleaning, ECheckingAvailable
       
   136             };
       
   137 
       
   138         /** Pointer to a storage observer */
       
   139         MGlxtnThumbnailStorageObserver* iStorageObserver;
       
   140         /** File server session */
       
   141         RFs iFs;
       
   142         /** Path to the database files (excluding drive letter) */
       
   143         TFileName iDatabasePath;
       
   144         /** Drive name of the phone memory drive */
       
   145         TDriveName iInternalDrive;
       
   146         /** Array of open databases (one per volume) */
       
   147         RPointerArray<CGlxtnVolumeDatabase> iDatabaseArray;
       
   148         /** Request status for asynchronous operation */
       
   149         TRequestStatus* iClientStatus;
       
   150         /** Operation currently being carried out by the database */
       
   151         TDatabaseOperation iCurrentOperation;
       
   152         /** Media ID for request */
       
   153         TGlxMediaId iMediaId;
       
   154         /** URI for request (not owned) */
       
   155         const CGlxtnFileInfo* iFileInfo;
       
   156         /** Thumbnail size for request */
       
   157         TSize iSize;
       
   158         /** Data buffer for load request */
       
   159         HBufC8** iLoadData;
       
   160         /** Data buffer for save request */
       
   161         TPtrC8 iSaveData;
       
   162         /** Thumbnail format for load request */
       
   163         TGlxImageDataFormat* iLoadFormat;
       
   164         /** Thumbnail format for save request */
       
   165         TGlxImageDataFormat iSaveFormat;
       
   166         /** ID for thumbnail */
       
   167         TGlxtnThumbnailId iThumbId;
       
   168         /** Index to count through iDatabaseArray */
       
   169         TInt  iDatabaseIndex;
       
   170     };
       
   171 
       
   172 #endif  // GLXTNDATABASE_H
       
   173 
       
   174 // End of File