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