menufw/hierarchynavigator/hnutilities/src/hnmdmapkey.cpp
branchv5backport
changeset 14 1abc632eb502
parent 13 6205fd287e8a
child 20 636d517f67e6
equal deleted inserted replaced
13:6205fd287e8a 14:1abc632eb502
     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 #include <liwservicehandler.h>
       
    20 
       
    21 #include "hnmdmapkey.h"
       
    22 #include "hnconvutils.h"
       
    23 #include "hnliwutils.h"
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // 
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 CHnMdMapKey* CHnMdMapKey::NewL()
       
    32     {
       
    33     CHnMdMapKey* self = NewLC();
       
    34     CleanupStack::Pop( self );
       
    35     return self;
       
    36     }
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // 
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 CHnMdMapKey* CHnMdMapKey::NewLC()
       
    43     {
       
    44     CHnMdMapKey* self = new ( ELeave ) CHnMdMapKey();
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructL();
       
    47     return self;
       
    48     }
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // 
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CHnMdMapKey* CHnMdMapKey::NewL( const CHnMdMapKey* aKey )
       
    55     {
       
    56     CHnMdMapKey* self = NewLC( aKey );
       
    57     CleanupStack::Pop( self );
       
    58     return self;
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // 
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 CHnMdMapKey* CHnMdMapKey::NewLC( const CHnMdMapKey* aKey )
       
    66     {
       
    67     CHnMdMapKey* self = new ( ELeave ) CHnMdMapKey();
       
    68     CleanupStack::PushL( self );
       
    69     self->ConstructL( aKey );
       
    70     return self;
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // 
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 CHnMdBaseKey* CHnMdMapKey::CopyLC()
       
    78     {
       
    79     CHnMdMapKey* self = CHnMdMapKey::NewL( this );
       
    80     CleanupStack::PushL( self );
       
    81     return self;
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // 
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 CHnMdMapKey::~CHnMdMapKey()
       
    89     {
       
    90     iVariantContent.Reset();
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // 
       
    95 // ---------------------------------------------------------------------------
       
    96 //
       
    97 CHnMdMapKey::CHnMdMapKey()
       
    98     {
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 // 
       
   103 // ---------------------------------------------------------------------------
       
   104 //
       
   105 void CHnMdMapKey::ConstructL()
       
   106     {
       
   107     }
       
   108 
       
   109 // ---------------------------------------------------------------------------
       
   110 // 
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 void CHnMdMapKey::ConstructL( const CHnMdMapKey* aKey )
       
   114     {
       
   115     BaseConstructL( aKey );
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // 
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 void CHnMdMapKey::ToVariantL( TLiwVariant& aRet ) const
       
   123     {
       
   124     if ( iVariantContent.TypeId() == LIW::EVariantTypeNull )
       
   125         {
       
   126         CLiwDefaultMap* map = CLiwDefaultMap::NewL();
       
   127         map->PushL();
       
   128           
       
   129         // handle children
       
   130         for( TInt i( 0 ); i < SubKeys().Count(); i++ )
       
   131             {
       
   132             TLiwVariant variant;
       
   133             SubKeys()[ i ]->ToVariantL( variant );
       
   134             map->InsertL( SubKeys()[ i ]->KeyName(), variant );
       
   135             variant.Reset();
       
   136             }
       
   137     
       
   138         aRet.SetL( TLiwVariant( map ) );
       
   139         CleanupStack::PopAndDestroy( map );
       
   140         }
       
   141     else
       
   142         {
       
   143         aRet.SetL(iVariantContent);
       
   144         }
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // 
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 void CHnMdMapKey::EvaluateKeyValueL( const CLiwGenericParamList& aParamList,
       
   152         TInt aPos )
       
   153     {
       
   154     HBufC8 *path8 = HnConvUtils::StrToStr8LC(iContent);
       
   155     iVariantContent.Reset();
       
   156     
       
   157     TLiwVariant variant;
       
   158     if ( HnLiwUtils::GetVariantL(aParamList, *path8, aPos, variant) == KErrNone
       
   159             &&  variant.TypeId() == LIW::EVariantTypeMap )
       
   160         {
       
   161         iVariantContent = variant;
       
   162         }
       
   163     else
       
   164         {
       
   165         variant.Reset();
       
   166         }
       
   167         
       
   168     CleanupStack::PopAndDestroy(path8);
       
   169     }
       
   170