menufw/hierarchynavigator/hnmetadatamodel/inc/hnmdvalueimage.h
changeset 0 f72a12da539e
child 27 7a8b39b569cb
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 #ifndef CHNMDIMAGE_H
       
    20 #define CHNMDIMAGE_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <AknsItemID.h> 
       
    24 #include "hnmdvaluebase.h"
       
    25 #include "hnglobals.h"
       
    26 
       
    27 class TXmlEngElement;
       
    28 class CLiwGenericParamList;
       
    29 struct THnMdCommonPointers;
       
    30 class CGulIcon;
       
    31 class CFbsBitmap;
       
    32 class CHnAttributeBase;
       
    33 class CHnAttributeImage;
       
    34 
       
    35 // CLASS DECLARATION
       
    36 
       
    37 /**
       
    38  * Value Image.
       
    39  * 
       
    40  * Specific class inherigint from CHnMdValue Base. This
       
    41  * class is responsible for images.
       
    42  * 
       
    43  * @lib hnmetadatamodel
       
    44  * @since S60 5.0
       
    45  * @ingroup group_hnmetadatamodel
       
    46  */
       
    47 NONSHARABLE_CLASS(CHnMdValueImage) : public CHnMdValueBase
       
    48     {
       
    49 public:
       
    50     // Constructors and destructor
       
    51 
       
    52     /**
       
    53      * Destructor.
       
    54      */
       
    55     ~CHnMdValueImage();
       
    56 
       
    57     /**
       
    58      * Two-phased constructor.
       
    59      * 
       
    60      * @param aElement XML element.
       
    61      * @param aCmnPtrs pointer to common pointer structure.
       
    62      * @return Object instance of meta data value image.
       
    63      */
       
    64     static CHnMdValueImage* NewL( const TXmlEngElement& aElement,
       
    65             THnMdCommonPointers* aCmnPtrs );
       
    66 
       
    67     /**
       
    68      * Two-phased constructor.
       
    69      * 
       
    70      * @param aElement XML element.
       
    71      * @param aCmnPtrs pointer to common pointer structure.
       
    72      * @return Object instance of meta data value image.
       
    73      */
       
    74     static CHnMdValueImage* NewLC( const TXmlEngElement& aElement,
       
    75             THnMdCommonPointers* aCmnPtrs );
       
    76     
       
    77     /**
       
    78      * Evaluates image object changing references into values
       
    79      * if possible.
       
    80      * 
       
    81      * @param aList Parameters list used in evaluation.
       
    82      * @param aPos Position of the corresponding record in a paramters list.
       
    83      */
       
    84     void EvaluateL( CLiwGenericParamList* aList, TInt aPos );
       
    85     
       
    86 // From CHnMdValueBase.
       
    87     
       
    88     /**
       
    89      * Retruns path to the file or the id of the file.
       
    90      * 
       
    91      * @param aQueriesResultsList Parameters list used when creating an attribute.
       
    92      * @param aPos Position of the corresponding record in a paramters list.
       
    93      * @return Attribute.
       
    94      */
       
    95     CHnAttributeBase* CreateAttributeL( const CLiwGenericParamList* aQueriesResultsList,
       
    96             TInt aPos );
       
    97                 
       
    98     /**
       
    99      * Returns CGulIcon object.
       
   100      * 
       
   101      * @param aQueriesResultsList Parameters list used when creating an attribute.
       
   102      * @param aPos Position of the corresponding record in a paramters list.
       
   103      * @return CGulIcon object.
       
   104      */
       
   105 //    CGulIcon* GetIconL( const CLiwGenericParamList* aQueriesResultsList = NULL,
       
   106 //            TInt aPos = 0 );
       
   107     
       
   108     /**
       
   109      * Returns variant containing bitmap.
       
   110      * 
       
   111      * @param aPath Path to the bitmap file.
       
   112      * @return Variant object. Ownership is transferred.
       
   113      */
       
   114     TLiwVariant* BitmapFromLiwL( const TDesC8& aPath );
       
   115 
       
   116     /**
       
   117      * Returns bitmap.
       
   118      * 
       
   119      * @return Variant containing bitmap object.
       
   120      */
       
   121     TLiwVariant* BitmapL();
       
   122     
       
   123     /**
       
   124      * Returns mask.
       
   125      * 
       
   126      * @return Variant containing bitmap object.
       
   127      */
       
   128     TLiwVariant* MaskL();
       
   129     
       
   130 private:
       
   131 
       
   132     /**
       
   133      * Constructor for performing 1st stage construction
       
   134      */
       
   135     CHnMdValueImage();
       
   136 
       
   137     /**
       
   138      * EPOC default constructor for performing 2nd stage construction
       
   139      * @param aElement Xml element.
       
   140      * @param aCmnPtrs Meta data common pointers.
       
   141      */
       
   142     void ConstructL( const TXmlEngElement& aElement,
       
   143             THnMdCommonPointers* aCmnPtrs );
       
   144    
       
   145     /**
       
   146      * Sets image source.
       
   147      */
       
   148     void SetImageSourceL();
       
   149     
       
   150     /**
       
   151      * Searches for resource id in the given file using
       
   152      * resource name.
       
   153      * 
       
   154      * If not found return KErrNotFound
       
   155      * 
       
   156      * @param aResourceFileContents contents of the file to search
       
   157      * @param aResourceName name of the resource (string)
       
   158      * @return KErrNotFound in case of error, otherwise id if the resource
       
   159      */
       
   160     TInt GetResourceIdL( const TDesC8& aResourceFileContents,
       
   161             const TDesC8& aResourceName );
       
   162     
       
   163     /**
       
   164      * File name getter.
       
   165      * 
       
   166      * @return file name
       
   167      */
       
   168     const TDesC8& FileName8();
       
   169     
       
   170     /**
       
   171      * Skin id getter.
       
   172      * 
       
   173      * @return skin id.
       
   174      */
       
   175     TAknsItemID SkinIdL();
       
   176     
       
   177     /**
       
   178      * Determines bitmap id and mask id in the MIF file.
       
   179      * If bitmap id or/and mask id cannot be determined, KErrNotFound
       
   180      * will be returned in aBitmapId or/and aMaskId. 
       
   181      * 
       
   182      * @param aBitmapId on successful execution will be set to bitmap id
       
   183      * @param aMaskId on successful execution will be set to mask id
       
   184      */
       
   185     void GetBitmapAndMaskIdL( TInt& aBitmapId, TInt& aMaskId );
       
   186     
       
   187     /**
       
   188      * Replaces file extension in a path to a file.
       
   189      * Please note that the new extension must not be longer than the old one,
       
   190      * or the method will leave. This means that this method cannot be applied
       
   191      * to files without extension.
       
   192      * 
       
   193      * @param aPath path to a file with extension
       
   194      * @param aNewExt a new extension
       
   195      * @return path to the same file as aPath but with extension replaced
       
   196      */
       
   197     static HBufC* ReplaceFileExtensionLC(
       
   198             const TDesC& aPath, const TDesC& aNewExt );
       
   199     
       
   200     /**
       
   201      * Application UID getter.
       
   202      * 
       
   203      * @return application uid
       
   204      */
       
   205     TUid ApplicationUidL();
       
   206     
       
   207     /**
       
   208      * Sets attribute data.
       
   209      * 
       
   210      * @param aAttr Attribute data to be set.
       
   211      */
       
   212     void SetAttributeDataL( CHnAttributeImage* aAttr );
       
   213     
       
   214     /**
       
   215      * Return Mif file name.
       
   216      * 
       
   217      * @return Mif file name.
       
   218      */
       
   219     HBufC* GetMifFileNameL();
       
   220 
       
   221     /**
       
   222      * Returns file name.
       
   223      * 
       
   224      * @return File name.
       
   225      */
       
   226     HBufC* GetFileNameSrcL();
       
   227     
       
   228     /**
       
   229      * Returns a path to the best matching mif file corresponding
       
   230      * to the given file name.
       
   231      * 
       
   232      * @param aFs a reference to the file server
       
   233      * @param aFileName a name of the file to be localized
       
   234      * @return a valid path to the mif file
       
   235      * 
       
   236      */
       
   237     HBufC* FindMatchigMifFileL( const RFs& aFs, TDesC& aFileName );
       
   238     
       
   239     /**
       
   240      * Creates keys for caching bitmap and mask ids.
       
   241      * 
       
   242      * @param aKeyBitmap A bitmap key name to be created. 
       
   243      * @param aBitmapIdBuf A bitmap id.
       
   244      * @param aKeyMask A mask key to be created.
       
   245      * @param aMaskIdBuf A mask id.
       
   246      */
       
   247     void CHnMdValueImage::CreateKeysLC( RBuf8& aKeyBitmap, RBuf8& aBitmapIdBuf, 
       
   248     		RBuf8& aKeyMask, RBuf8& aMaskIdBuf );
       
   249     
       
   250 
       
   251 private: // data
       
   252     
       
   253     /**
       
   254      * Own - Skin id minor.
       
   255      */
       
   256     RBuf8 iSkinIdMinor8;
       
   257     
       
   258     /**
       
   259      * Own - Skin id major.
       
   260      */
       
   261     RBuf8 iSkinIdMajor8;
       
   262 
       
   263     /**
       
   264      * Own - File name.
       
   265      */
       
   266     RBuf8 iFileNameSrc8;
       
   267     
       
   268     /**
       
   269      * Own - Mif file name.
       
   270      */
       
   271     RBuf8 iMifFile8;
       
   272     
       
   273     /**
       
   274      * Own - File name.
       
   275      */
       
   276     RBuf iFileName;
       
   277     
       
   278     /**
       
   279      * Own - Bitmap id.
       
   280      */
       
   281     RBuf8 iBitmapId8;
       
   282     
       
   283     /**
       
   284      * Own - Mask id.
       
   285      */
       
   286     RBuf8 iMaskId8;
       
   287     
       
   288     /**
       
   289      * Own - Application uid.
       
   290      */
       
   291     RBuf8 iApplicationUid8;
       
   292     
       
   293     /**
       
   294      * Own - Bitmap.
       
   295      */
       
   296     RBuf8 iBitmap8;
       
   297     
       
   298     /**
       
   299      * Own - Mask;
       
   300      */
       
   301     RBuf8 iMask8;
       
   302     
       
   303     /**
       
   304      * Own - Image source.
       
   305      */
       
   306     TImageSource iImageSource;
       
   307     
       
   308     /**
       
   309      * A value contining path to the physical image
       
   310      * or its id.
       
   311      */
       
   312     RBuf iReturnValue;
       
   313 
       
   314     /**
       
   315      * Common pointers.
       
   316      */
       
   317     THnMdCommonPointers* iCmnPtrs;
       
   318     
       
   319     /**
       
   320      * Parameters list.
       
   321      */
       
   322     const CLiwGenericParamList* iParamList;
       
   323     
       
   324     /**
       
   325      * Position of the corresponding record in parameters list.
       
   326      */
       
   327     TInt iPos;
       
   328     
       
   329     /**
       
   330      * Full path to the MIF file or NULL if there is no MIF file.
       
   331      * Own.
       
   332      */
       
   333     HBufC* iMifFileName;
       
   334 
       
   335     };
       
   336 
       
   337 #endif // CHNMDIMAGE_H