ncdengine/provider/server/inc/ncdpreviewmanager.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2006 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:   Contains CNcdPreviewManager class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_NCDPREVIEWMANAGER_H
       
    20 #define C_NCDPREVIEWMANAGER_H
       
    21 
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <f32file.h>
       
    25 #include "ncdstoragedataitem.h"
       
    26 
       
    27 class CNcdNodeIdentifier;
       
    28 class MNcdStorageManager;
       
    29 class MNcdFileStorage;
       
    30 class CNcdGeneralManager;
       
    31 
       
    32 /**
       
    33  * Manages previews
       
    34  */
       
    35 class CNcdPreviewManager : public CBase, public MNcdStorageDataItem
       
    36     {
       
    37 public: // Constructor & destructor
       
    38 
       
    39         
       
    40     static CNcdPreviewManager* NewL( 
       
    41         CNcdGeneralManager& aGeneralManager, TInt aMaxCount );    
       
    42         
       
    43     virtual ~CNcdPreviewManager();
       
    44     
       
    45 public:    
       
    46 
       
    47     /**
       
    48      * Adds a new preview file.
       
    49      *
       
    50      * @param aId Id used to identify the owner of the preview
       
    51      * @param aUri Download uri
       
    52      * @param aPreviewFile Downloaded preview file
       
    53      * @param aMimeType MIME type
       
    54      */
       
    55     void AddPreviewL( 
       
    56         const CNcdNodeIdentifier& aId, 
       
    57         const TDesC& aUri, 
       
    58         const TDesC& aPreviewFile,
       
    59         const TDesC& aMimeType );
       
    60 
       
    61 
       
    62     /**
       
    63      * Removes a preview file
       
    64      *
       
    65      * @param aId Id used to identify the owner of the preview
       
    66      * @param aUri URI where the preview was downloaded from
       
    67      * @return KErrNone or a Symbian error code
       
    68      */
       
    69     TInt RemovePreviewL( 
       
    70         const CNcdNodeIdentifier& aId, 
       
    71         const TDesC& aUri );
       
    72        
       
    73     
       
    74     /**
       
    75      * Opens a preview file if it exists
       
    76      *
       
    77      */   
       
    78     RFile PreviewL( 
       
    79         RFs& aFs,
       
    80         const CNcdNodeIdentifier& aId,
       
    81         const TDesC& aUri );
       
    82     
       
    83     
       
    84     /**
       
    85      * Checks that a preview file exists
       
    86      */
       
    87     TBool PreviewExists( 
       
    88         const CNcdNodeIdentifier& aId,
       
    89         const TDesC& aUri ) const;
       
    90        
       
    91     
       
    92     const TDesC& PreviewMimeType(
       
    93         const CNcdNodeIdentifier& aId,
       
    94         const TDesC& aUri ) const;
       
    95            
       
    96     /**
       
    97      * Removes all previews
       
    98      */
       
    99     void RemoveAllPreviewsL();     
       
   100 
       
   101     void SaveDataL();
       
   102     void LoadDataL();
       
   103     
       
   104 public: // MNcdStorageDataItem
       
   105 
       
   106 
       
   107     /**
       
   108      * @see MNcdStorageDataItem::ExternalizeL()
       
   109      */
       
   110     void ExternalizeL( RWriteStream& aStream );
       
   111 
       
   112 
       
   113     /**
       
   114      * @see MNcdStorageDataItem::InternalizeL()
       
   115      */
       
   116     void InternalizeL( RReadStream& aStream );
       
   117 
       
   118      
       
   119 private:
       
   120 
       
   121     CNcdPreviewManager( CNcdGeneralManager& aGeneralManager, TInt aMaxCount );
       
   122     void ConstructL();
       
   123     
       
   124     CNcdPreviewManager( const CNcdPreviewManager& );
       
   125     CNcdPreviewManager& operator=( const CNcdPreviewManager& );
       
   126     
       
   127     
       
   128     // Searches for the preview
       
   129     TInt FindPreview( const CNcdNodeIdentifier& aId, const TDesC& aUri ) const;
       
   130     
       
   131     // Returns the file storage for the client
       
   132     MNcdFileStorage& FileStorageL( const CNcdNodeIdentifier& aId );
       
   133     
       
   134 protected:
       
   135 
       
   136     /** 
       
   137      * Utility class for holding preview related data
       
   138      */
       
   139     class  CNcdPreviewData : public CBase
       
   140         {      
       
   141     public:
       
   142     
       
   143         CNcdPreviewData();
       
   144         static CNcdPreviewData* NewLC( 
       
   145             const CNcdNodeIdentifier& aId,
       
   146             const TDesC& aUri, 
       
   147             const TDesC& aPreviewFile,
       
   148             const TDesC& aMimeType );
       
   149             
       
   150         virtual ~CNcdPreviewData();
       
   151         
       
   152         TBool Equals( const CNcdNodeIdentifier& aId, const TDesC& aUri ) const;
       
   153         
       
   154         const CNcdNodeIdentifier& Id() const;
       
   155         const TDesC& Uri() const;
       
   156         const TDesC& Filename() const;
       
   157         const TDesC& MimeType() const;
       
   158 
       
   159         void ExternalizeL( RWriteStream& aStream );
       
   160         void InternalizeL( RReadStream& aStream );
       
   161 
       
   162     
       
   163     protected:
       
   164     
       
   165         void ConstructL( 
       
   166             const CNcdNodeIdentifier& aId,
       
   167             const TDesC& aUri, 
       
   168             const TDesC& aPreviewFile,
       
   169             const TDesC& aMimeType );
       
   170         
       
   171         CNcdPreviewData( const CNcdPreviewData& );
       
   172         CNcdPreviewData& operator=( const CNcdPreviewData& );
       
   173     
       
   174     private:
       
   175         CNcdNodeIdentifier* iId;
       
   176         HBufC* iUri;
       
   177         HBufC* iFilename;
       
   178         HBufC* iMimeType;
       
   179         };
       
   180 
       
   181     typedef RPointerArray<CNcdPreviewData> RNcdPreviewArray;
       
   182 
       
   183         
       
   184 private:
       
   185 
       
   186     CNcdGeneralManager& iGeneralManager;
       
   187     MNcdStorageManager& iStorageManager;
       
   188 
       
   189     // Maximum previews per family
       
   190     TInt iMaxCount;
       
   191     
       
   192     // PreviewManager is family specific so we need only one dimensional
       
   193     // array for all the previews of a family
       
   194     RNcdPreviewArray iPreviews;
       
   195         
       
   196     };
       
   197 
       
   198 #endif // C_NCDPREVIEWMANAGER_H