menufw/hierarchynavigator/hnmetadatamodel/inc/hnmdlocalizationelement.h
changeset 0 f72a12da539e
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_HNMDLOCALIZATIONELEMENT_H
       
    21 #define C_HNMDLOCALIZATIONELEMENT_H
       
    22 
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <e32hashtab.h> //RHashMap
       
    26 #include <xmlengelement.h> 
       
    27 #include <xmlengnodelist.h>
       
    28 
       
    29 
       
    30 /**
       
    31  * Localization Element.
       
    32  * 
       
    33  * This is the localization element which is wrapped by the localization
       
    34  * class. 
       
    35  *
       
    36  * @lib hnmetadatamodel
       
    37  * @since S60 5.0
       
    38  * @ingroup group_hnmetadatamodel
       
    39  */
       
    40 NONSHARABLE_CLASS(CHnMdLocalizationElement) : public CBase
       
    41     {
       
    42     /**
       
    43      * State of element - used for caching purpose 
       
    44      */
       
    45     enum TLocalizationElementStates {
       
    46         EInitialized = 1,
       
    47         EWholeFileCached = 2,
       
    48         EUsedItemsCached = 4
       
    49     };
       
    50 public:
       
    51 
       
    52     /**
       
    53      * Two-phase constructor.
       
    54      *
       
    55      * @since S60 5.0
       
    56      * @param aElement Xml element.
       
    57      * @return Fully constructed element.
       
    58      */
       
    59     static CHnMdLocalizationElement* NewL( TXmlEngElement aElement );
       
    60 
       
    61     /**
       
    62      * Two-phase constructor.
       
    63      *
       
    64      * @since S60 5.0
       
    65      * @param aNamespace namespace
       
    66      * @param aSource source
       
    67      * @return Fully constructed element.
       
    68      */
       
    69     static CHnMdLocalizationElement* NewL( const TDesC& aNamespace, 
       
    70                                            const TDesC& aSource);
       
    71 
       
    72     /**
       
    73      * Standard C++ virtal destructor.
       
    74      *
       
    75      * @since S60 5.0
       
    76      */
       
    77     virtual ~CHnMdLocalizationElement();
       
    78     
       
    79     /**
       
    80      * Gets namespace.
       
    81      *
       
    82      * @since S60 5.0
       
    83      * @return Namespace.
       
    84      */
       
    85     const TDesC& Namespace() const;
       
    86     
       
    87     /**
       
    88      * Gets source.
       
    89      *
       
    90      * @since S60 5.0
       
    91      * @return Source.
       
    92      */
       
    93     const TDesC& Source() const;
       
    94     
       
    95     /**
       
    96      * Gets source path.
       
    97      *
       
    98      * @since S60 5.0
       
    99      * @return Source.
       
   100      */
       
   101     HBufC* SourcePath() const;
       
   102     
       
   103     /**
       
   104      * Returns true if path to source exists.
       
   105      *
       
   106      * @since S60 5.0
       
   107      * @return Does path to source exist.
       
   108      */
       
   109     TBool SourceExists() const;
       
   110     
       
   111     /**
       
   112      * Reloads the resource file path.
       
   113      *
       
   114      * @since S60 5.0
       
   115      */
       
   116     void LocateLanguageFileL();
       
   117 
       
   118     /**
       
   119      * Gets resource id from corresponsing rsg if exist
       
   120      * Inside it implemented caching mechanism
       
   121      * If file is small (<KWholeFileReadLimit) cache all entries, 
       
   122      * otherwise it caches only used resources.
       
   123      * 
       
   124      * @since S60 5.0
       
   125      * @param aResourceName Resource name.
       
   126      * @return Resource id if exist.
       
   127      */
       
   128     const TInt& FindResourceIdL( HBufC8* aResourceName );
       
   129     
       
   130 private:
       
   131 
       
   132     /**
       
   133      * Standard C++ constructor.
       
   134      *
       
   135      * @since S60 5.0
       
   136      */
       
   137     CHnMdLocalizationElement();
       
   138 
       
   139     /**
       
   140      * Standard symbian 2nd pahse constructor.
       
   141      *
       
   142      * @since S60 5.0
       
   143      * @param aElement Xml element.
       
   144      */
       
   145     void ConstructL( TXmlEngElement aElement );
       
   146 
       
   147     /**
       
   148      * Standard symbian 2nd pahse constructor.
       
   149      *
       
   150      * @since S60 5.0
       
   151      * @param aNamespace namespace
       
   152      * @param aSource source
       
   153      */
       
   154     void ConstructL( const TDesC& aNamespace, const TDesC& aSource);
       
   155     
       
   156     /**
       
   157      * Sets namespace
       
   158      *
       
   159      * @since S60 5.0
       
   160      * @param aNamespace Namespace.
       
   161      */
       
   162     void SetNamespaceL( TXmlEngAttr aNamespace );
       
   163     
       
   164     /**
       
   165      * Sets source.
       
   166      *
       
   167      * @since S60 5.0
       
   168      * @param aSource Xml attribute.
       
   169      */
       
   170     void SetSourceL( TXmlEngAttr aSource );
       
   171         
       
   172     /**
       
   173      * Read corresponding rsg file return content.
       
   174      * 
       
   175      * @since S60 5.0 
       
   176      * @return Descriptor with file content.
       
   177      */     
       
   178     HBufC8* ReadRsgContentLC( );
       
   179     
       
   180     /**
       
   181      * Parse content of corresponding rsg file and 
       
   182      * fill in maping to internal map for all resource listed in content.
       
   183      *  
       
   184      * @since S60 5.0 
       
   185      * @param aContent Descriptor with content.
       
   186      */    
       
   187     void ParseRsgContentL( const TDesC8& aContent );
       
   188 
       
   189     /**
       
   190      * Parse content of corresponding rsg file and 
       
   191      * fill in maping to internal map only requested resource 
       
   192      *
       
   193      * @since S60 5.0  
       
   194      * @param aContent Descriptor with content.
       
   195      * @param aResourceName Requested resource name.
       
   196      */        
       
   197     void ParseRsgContentL( const TDesC8& aContent, const TDesC8& aResourceName );    
       
   198     
       
   199 private: // data
       
   200 
       
   201     /**
       
   202      * Namespace.
       
   203      */
       
   204     RBuf iNamespace;
       
   205     
       
   206     /**
       
   207      * Source.
       
   208      */
       
   209     RBuf iSource;
       
   210     
       
   211     /**
       
   212      * Source path.
       
   213      */
       
   214     HBufC* iSourcePath;
       
   215     
       
   216     /**
       
   217      * Mapping between resource name and resource id.
       
   218      */
       
   219     RHashMap< HBufC8*, TInt> iResourceIDs;
       
   220     
       
   221     /**
       
   222      * State of element. 
       
   223      */
       
   224     TInt iState;
       
   225     };
       
   226 
       
   227 #endif // C_HNMMLOCALIZATIONELEMENT_H