homescreensrv_plat/sapi_contentpublishing/src/cpclientiterable.cpp
changeset 73 4bc7b118b3df
parent 66 32469d7d46ff
child 80 397d00875918
child 81 5ef31a21fdd5
equal deleted inserted replaced
66:32469d7d46ff 73:4bc7b118b3df
     1 /*
       
     2 * Copyright (c) 2007 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 #include <s32mem.h>
       
    19 
       
    20 #include "cpclientiterable.h"
       
    21 #include "cpglobals.h"
       
    22 #include "cpdebug.h"
       
    23 
       
    24 using namespace LIW;
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // Two-Phase constructor
       
    28 // ---------------------------------------------------------------------------
       
    29 //
       
    30 CCPClientIterable* CCPClientIterable::NewL( CLiwGenericParamList* aList )
       
    31     {
       
    32     return new(ELeave) CCPClientIterable( aList );
       
    33     }
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // Constructor
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 CCPClientIterable::CCPClientIterable( CLiwGenericParamList* aList ) :
       
    40     iList(aList)
       
    41     {
       
    42     }
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 // Destructor
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 CCPClientIterable::~CCPClientIterable()
       
    49     {
       
    50     delete iList;
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // Reset the list
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 void CCPClientIterable::Reset()
       
    58     {
       
    59     iPos = 0;
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // Gets next element in list
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 TBool CCPClientIterable::NextL( TLiwVariant& aNext )
       
    67     {
       
    68     CP_DEBUG( _L8("CCPClientIterable::NextL()") );
       
    69     TBool retValue = EFalse;
       
    70     const TLiwGenericParam* param= NULL;
       
    71     param = iList->FindFirst( iPos, KListMap, EVariantTypeMap );
       
    72 
       
    73     if ( param && iPos !=KErrNotFound )
       
    74         {
       
    75         CLiwDefaultMap* map = CLiwDefaultMap::NewLC( );
       
    76         //get map
       
    77         if ( param->Value().Get( *map ) )
       
    78             {
       
    79             ExctractBinariesL( *map );
       
    80             aNext.SetL( map );
       
    81             retValue = ETrue;
       
    82             }
       
    83         CleanupStack::PopAndDestroy( map );
       
    84         iPos++;
       
    85         }
       
    86     return retValue;
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // 
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 void CCPClientIterable::ExctractBinariesL( CLiwDefaultMap& aMap )
       
    94     {
       
    95     CP_DEBUG( _L8("CCPClientIterable::ExctractBinariesL()") );
       
    96     TLiwVariant buffer;
       
    97     buffer.PushL( );
       
    98     if ( aMap.FindL( KDataMap, buffer ) )
       
    99         {
       
   100         TPtrC8 packedData( KNullDesC8 );
       
   101         if ( buffer.Get( packedData ) )
       
   102             {
       
   103             RDesReadStream str(packedData);
       
   104             CleanupClosePushL( str );
       
   105             CLiwDefaultMap* datamap = CLiwDefaultMap::NewLC( str );
       
   106             aMap.Remove( KDataMap );
       
   107             aMap.InsertL( KDataMap, datamap );
       
   108             CleanupStack::PopAndDestroy( datamap );
       
   109             CleanupStack::PopAndDestroy( &str );
       
   110             }
       
   111         }
       
   112     if ( aMap.FindL( KActionMap, buffer ) )
       
   113         {
       
   114         TPtrC8 packedAction( KNullDesC8 );
       
   115         if ( buffer.Get( packedAction ) )
       
   116             {
       
   117             RDesReadStream str(packedAction);
       
   118             CleanupClosePushL( str );
       
   119             CLiwDefaultMap* actionmap = CLiwDefaultMap::NewLC( str );
       
   120             aMap.Remove( KActionMap );
       
   121             aMap.InsertL( KActionMap, actionmap );
       
   122             CleanupStack::PopAndDestroy( actionmap );
       
   123             CleanupStack::PopAndDestroy( &str );
       
   124             }
       
   125         }
       
   126     CleanupStack::PopAndDestroy( &buffer );
       
   127     }