skins/AknSkins/srvinc/AknsSrvWallpaperCache.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 15 Jul 2010 19:48:07 +0300
branchRCL_3
changeset 99 e871a07c0ce0
parent 58 a2f9480e2280
child 106 e4e3998ddda2
permissions -rw-r--r--
Revision: 201025 Kit: 2010127

/*
* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  Wallpaper Cache
*
*/


#ifndef AKNSSRVWALLPAPERCACHE_H
#define AKNSSRVWALLPAPERCACHE_H

// INCLUDE FILES
#include <e32std.h>
#include <fbs.h>

// FORWARD DECLARATIONS
struct TAknsSrvWallpaper
    {
    CFbsBitmap* iPortrait;
    CFbsBitmap* iPortraitMask;
    CFbsBitmap* iLandscape;
    CFbsBitmap* iLandscapeMask;
    TFileName   iName;
    };
    
    
const TInt KAknsWallpaperCacheSize = 6;

// CLASS DECLARATION

NONSHARABLE_CLASS( CAknsSrvWallpaperCache )
    {
public:
    /**
    * Symbian constructor.
    */    
    static CAknsSrvWallpaperCache* NewL( TInt aCacheSize );
    
    /**
    * Destructor.
    */
    virtual ~CAknsSrvWallpaperCache();
    
    /**
    * Add a image to wallpaper cache
    */
    TAknsSrvWallpaper* AddL( RFs& aRFs, const TDesC& aFileName, 
                   const TSize aTargetSize, const TSize aMaxSize);
    
    /**
    * Remove a image from wallpaper cache
    */    
    void Remove( const TDesC& aFileName );

    /**
    * Check if a image is in wallpaper cache
    */ 
    TBool IsCached( const TDesC& aFileName );

    /**
    * Reset wallpaper cache
    */ 
    void ResetAndDestory( );
    
private:
    
    /**
    * Symbian 2nd phase constructor.
    */
    void ConstructL( TInt aCacheSize );
    /**
    * Constructor.
    */
    CAknsSrvWallpaperCache();

    /**
    * Destory one TAknsSrvWallpaper item
    */
    void DestoryItem( TAknsSrvWallpaper& aItem );

    /**
    * Reset one TAknsSrvWallpaper item
    */
    void ZeroItem( TAknsSrvWallpaper& aItem );

    /**
    * Remove the oldest wallpaper from cache
    */
    void RemoveOldestItem();
    
    /**
    * Get cached image
    */    
    TAknsSrvWallpaper* CachedImage( const TDesC& aFileName );
    
    /**
    * Try Decode image
    */
    void TryDecodeImageL( RFs& aRFs,const TDesC& aFileName );
    
private:

    /**
    * Wallpaper cache
    */
    RPointerArray<TAknsSrvWallpaper> iCache;
   
    /**
    * Wallpaper cache size
    */
    TInt iCacheSize;
    };

#endif

// End of File