extras/about/inc/AboutResourceLoader.h
branchRCL_3
changeset 25 bec11adf88f9
equal deleted inserted replaced
24:10c6e6d6e4d9 25:bec11adf88f9
       
     1 /*
       
     2 * Copyright (c) 2010 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: Resource loader for About in order to asynchronous load resource.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef ABOUTRESOURCELOADER_H
       
    19 #define ABOUTRESOURCELOADER_H
       
    20 
       
    21 #include <e32base.h>    // For CActive
       
    22 #include <barsread.h>    // For TResourceReader
       
    23 #include "about.hrh"    // For TAboutItemType;
       
    24 
       
    25 // Class declaration
       
    26 class CEikonEnv;
       
    27 class MResourceLoaderObserver;
       
    28 class RConeResourceLoader;
       
    29 class CAboutResource;
       
    30 
       
    31 /*
       
    32  * The resource loader for about application.
       
    33  * Resource loader load the resource items asynchronously.
       
    34  */
       
    35 class CAboutResourceLoader : public CActive
       
    36     {
       
    37 public:
       
    38     // Cancel and destroy
       
    39     ~CAboutResourceLoader();
       
    40 
       
    41     // Two-phased constructor.
       
    42     static CAboutResourceLoader* NewL( CEikonEnv* aEikonEnv,
       
    43                             MResourceLoaderObserver* aObserver );
       
    44 
       
    45     // Two-phased constructor.
       
    46     static CAboutResourceLoader* NewLC( CEikonEnv* aEikonEnv, 
       
    47                             MResourceLoaderObserver* aObserver );
       
    48 
       
    49 private:
       
    50     // C++ constructor
       
    51     CAboutResourceLoader( CEikonEnv* aEikonEnv, 
       
    52                     MResourceLoaderObserver* aObserver );
       
    53 
       
    54     // Second-phase constructor
       
    55     void ConstructL();
       
    56 
       
    57 private: //From CActive
       
    58     void RunL();
       
    59     void DoCancel();
       
    60     TInt RunError( TInt aError );
       
    61     
       
    62 private:
       
    63     /*
       
    64      * Activate itself.
       
    65      */
       
    66     void Activate();
       
    67     
       
    68 public:
       
    69     
       
    70     /*
       
    71      * Start the loader. 
       
    72      * Note: The resource id must be set before this method called,
       
    73      * otherwise, leave with KErrGeneral.
       
    74      */
       
    75     void StartL();
       
    76     
       
    77     /**
       
    78      * Set the id of the resource to be loaded.
       
    79      * @Param aResourceId the id of the resource to be loaded.
       
    80      * @aLoaded Indicate the resource file has been loaded or not.
       
    81      * If the resource file is not load yet, the resource path must
       
    82      * pass to loader.
       
    83      * @aResourcePath the path of the resource file which the resouce stored in.
       
    84      */
       
    85     void SetResourceId( const TInt aResourceId, 
       
    86         const TBool aLoaded, const TDesC& aResourcePath );
       
    87     
       
    88     /**
       
    89      * Get the currentlly resource Id from the loader
       
    90      * @Return The current resource Id 
       
    91      */
       
    92     TInt CurrentResourceId();
       
    93     
       
    94     /*
       
    95      * Get the loaded items array.
       
    96      * @Return The loaded items array.
       
    97      */
       
    98     RPointerArray<CAboutResource>* LoadedResourceItems() const;
       
    99     
       
   100     /*
       
   101      * Delete the loaded items. 
       
   102      */
       
   103     void ReleaseLoadedItems();
       
   104     
       
   105     /*
       
   106      * Return the count of the item in the resource.
       
   107      */
       
   108     TInt ItemCount() const;
       
   109 
       
   110 private:
       
   111     // Ref: Environment.
       
   112     CEikonEnv* iEnv;
       
   113     
       
   114     // The id of the resource which the stings stored in.
       
   115     TInt iResourceId;
       
   116     
       
   117     // The flag indicates the resource file has been loaded or not.
       
   118     TBool iLoaded;
       
   119     
       
   120     // The path of resource file
       
   121     TFileName iResourcePath;
       
   122     
       
   123     // Ref: Observer
       
   124     MResourceLoaderObserver* iObserver;
       
   125     
       
   126     // Iterator.
       
   127     TInt iItemIterator;
       
   128     
       
   129     // Owned: the buffer for the resource.
       
   130     HBufC8* iResourceBuffer;
       
   131     
       
   132     // Reader.
       
   133     TResourceReader iReader;
       
   134     
       
   135     // The count of the items in the resource.
       
   136     TInt iItemCount;
       
   137     
       
   138     // Owned: Resource file loader.
       
   139     RConeResourceLoader* iLoader;
       
   140     
       
   141     // Owned: the array store the loaded items.
       
   142     RPointerArray<CAboutResource>* iLoadedItem;
       
   143 
       
   144     };
       
   145 
       
   146 #endif // ABOUTRESOURCELOADER_H