contentpublishingsrv/contentpublishingutils/contentpublishingmap/src/cpliwmap.cpp
changeset 93 82b66994846c
parent 92 782e3408c2ab
child 94 dbb8300717f7
equal deleted inserted replaced
92:782e3408c2ab 93:82b66994846c
     1 /*
       
     2 * Copyright (c) 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:  ?Description
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #include <s32mem.h>
       
    20 #include <liwgenericparam.h>
       
    21 #include <escapeutils.h>
       
    22 #include <badesca.h>
       
    23 
       
    24 #include "cpliwmap.h"
       
    25 #include "cpdebug.h"
       
    26 #include "cpssqlcommands.h"
       
    27 #include "ccontentmap.h"
       
    28 #include "cpublisherregistrymap.h"
       
    29 #include "cpsecuritypolicy.h"
       
    30 
       
    31 // ======== MEMBER FUNCTIONS ========
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // 
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 EXPORT_C CCPLiwMap* CCPLiwMap::NewL( RDesReadStream& aStream )
       
    38     {
       
    39     CLiwGenericParamList* list = CLiwGenericParamList::NewLC( aStream );
       
    40     CCPLiwMap* map = CCPLiwMap::NewL( *list );
       
    41     CleanupStack::PopAndDestroy( list );
       
    42     return map;
       
    43     }
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // 
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 EXPORT_C CCPLiwMap* CCPLiwMap::NewL( const CLiwGenericParamList& aList )
       
    50     {
       
    51     CP_DEBUG( _L8("CCPLiwMap::NewL") );
       
    52     const TLiwGenericParam* param = NULL;
       
    53     TInt pos( 0 );
       
    54     param = aList.FindFirst( pos, KType );
       
    55     CCPLiwMap* map( NULL );
       
    56     if( param && pos !=KErrNotFound )
       
    57         {
       
    58         RBuf typeBuf;
       
    59         typeBuf.CleanupClosePushL();
       
    60         TPtrC type( KNullDesC );
       
    61         if( !param->Value().Get( type ) )
       
    62             {
       
    63             TPtrC8 type8( KNullDesC8 );
       
    64             if( !param->Value().Get( type8 ) )
       
    65                 {
       
    66                 User::Leave( KErrBadName );
       
    67                 }
       
    68             typeBuf.Assign( EscapeUtils::ConvertToUnicodeFromUtf8L( type8 ) );
       
    69             }
       
    70         else
       
    71             {
       
    72             typeBuf.CreateL( type );
       
    73             }
       
    74         if( typeBuf.Find( KCpData () ) != KErrNotFound )
       
    75             {
       
    76             map = CContentMap::NewLC();
       
    77             }
       
    78         else if ( typeBuf.Find( KPublisher () ) != KErrNotFound )
       
    79             {
       
    80             map = CPublisherRegistryMap::NewLC();
       
    81             }
       
    82         else User::Leave( KErrArgument );
       
    83         map->SetL( aList );
       
    84         CleanupStack::Pop( map );
       
    85         CleanupStack::PopAndDestroy( &typeBuf );
       
    86         }
       
    87     else
       
    88         {
       
    89         User::Leave( KErrPathNotFound );
       
    90         }
       
    91     return map;
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // 
       
    96 // ---------------------------------------------------------------------------
       
    97 //		
       
    98 EXPORT_C HBufC8* CCPLiwMap::PackForServerLC() const
       
    99     {
       
   100     CP_DEBUG( _L8("CCPLiwMap::PackForServerLC") );
       
   101     HBufC8* datadesc = HBufC8::NewLC( Size() );
       
   102     TPtr8 ptr = datadesc->Des();
       
   103     RDesWriteStream datastrm( ptr );
       
   104     CleanupClosePushL(datastrm);
       
   105     ExternalizeL(datastrm);
       
   106     datastrm.CommitL();
       
   107     CleanupStack::PopAndDestroy(&datastrm);
       
   108     return datadesc;
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // 
       
   113 // ---------------------------------------------------------------------------
       
   114 //	
       
   115 EXPORT_C void CCPLiwMap::Reset( ) const
       
   116     {
       
   117     iMap->Reset();    
       
   118     }
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // 
       
   122 // ---------------------------------------------------------------------------
       
   123 //
       
   124 void CCPLiwMap::IsValidForAddL( ) const
       
   125     {
       
   126     CP_DEBUG( _L8("CCPLiwMap::IsValidForAddL") );
       
   127     TInt err( KErrNone );
       
   128     TInt32 id( 0 );
       
   129     if( GetProperty( KId, id ) && ( id < 1 ) )
       
   130         {
       
   131         err = KErrArgument;
       
   132         }
       
   133     else if( !IsId() && PropertyExists( KId ) )
       
   134         {
       
   135         err = KErrBadName;
       
   136         }
       
   137 
       
   138     CheckIdentifiersL();
       
   139     
       
   140     if( err == KErrNone && !IsId() && !( IsPublisherNameL() 
       
   141             && IsContentTypeL() && IsContentIdL() ) )
       
   142         {
       
   143         err = KErrPathNotFound;
       
   144         }
       
   145     
       
   146     if( err != KErrNone )
       
   147         {
       
   148         User::Leave( err );
       
   149         }
       
   150     }
       
   151 
       
   152 // ---------------------------------------------------------------------------
       
   153 // 
       
   154 // ---------------------------------------------------------------------------
       
   155 //
       
   156 EXPORT_C void CCPLiwMap::IsValidForActionL( )const
       
   157     {
       
   158     CP_DEBUG( _L8("CCPLiwMap::IsValidForActionL") );
       
   159     CCPLiwMap::IsValidForNotificationL();
       
   160     if( !IsTriggerL() ) User::Leave( KErrPathNotFound );
       
   161     }
       
   162 
       
   163 // ---------------------------------------------------------------------------
       
   164 // 
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 EXPORT_C void CCPLiwMap::IsValidForNotificationL( ) const
       
   168     {
       
   169     CP_DEBUG( _L8("CCPLiwMap::IsValidForAddL") );
       
   170     TInt err( KErrNone );
       
   171     TInt32 id( 0 );
       
   172     if( GetProperty( KId, id ) && ( id < 1 ) )
       
   173         {
       
   174         err = KErrArgument;
       
   175         }
       
   176     else if( !IsId() && PropertyExists( KId ) )
       
   177         {
       
   178         err = KErrBadName;
       
   179         }
       
   180     
       
   181     CheckIdentifiersL();
       
   182     
       
   183     if( err == KErrNone && !IsId() && !IsPublisherNameL() 
       
   184             && !IsContentTypeL() && !IsContentIdL() )
       
   185         {
       
   186         err = KErrPathNotFound;
       
   187         }
       
   188     
       
   189     if( err != KErrNone )
       
   190         {
       
   191         User::Leave( err );
       
   192         }
       
   193     }
       
   194 
       
   195 
       
   196 // ---------------------------------------------------------------------------
       
   197 // 
       
   198 // ---------------------------------------------------------------------------
       
   199 //
       
   200 EXPORT_C TBool CCPLiwMap::GetPropertyL( const TDesC8& aProperty ,
       
   201         RBuf& aResult ) const
       
   202     {
       
   203     //change name
       
   204     CP_DEBUG( _L8("CCPLiwMap::GetProperty - TPtrC") );
       
   205     TBool result( EFalse );
       
   206     TInt pos( 0 );
       
   207     TPtrC result16( KNullDesC);
       
   208     TPtrC8 result8( KNullDesC8);
       
   209     const TLiwGenericParam* paramForValue = iMap->FindFirst( pos, aProperty );
       
   210     if ( pos != KErrNotFound )
       
   211         {
       
   212         if( paramForValue->Value().Get( result16 ) )
       
   213             {
       
   214             aResult.CreateL( result16 );
       
   215             result = ETrue;
       
   216             }
       
   217         else if( paramForValue->Value().Get( result8 ) )
       
   218             {
       
   219             aResult.Assign( EscapeUtils::ConvertToUnicodeFromUtf8L( result8 ) );
       
   220             result = ETrue;
       
   221             }
       
   222         else
       
   223         	{
       
   224         	User::Leave( KErrBadName );
       
   225         	}
       
   226         }
       
   227     return result;
       
   228     }
       
   229 
       
   230 // ---------------------------------------------------------------------------
       
   231 // 
       
   232 // ---------------------------------------------------------------------------
       
   233 //
       
   234 EXPORT_C TBool CCPLiwMap::GetPropertyL( const TDesC8& aProperty ,
       
   235         RBuf8& aResult ) const
       
   236     {
       
   237     CP_DEBUG( _L8("CCPLiwMap::GetProperty - TPtrC8") );
       
   238     TBool result( EFalse );
       
   239     TInt pos( 0 );
       
   240     TPtrC8 result8( KNullDesC8 );
       
   241     TPtrC result16( KNullDesC );
       
   242     const TLiwGenericParam* paramForValue = iMap->FindFirst( pos, aProperty );
       
   243     if ( pos != KErrNotFound )
       
   244         {
       
   245         if( paramForValue->Value().Get( result8 ) )
       
   246             {
       
   247             aResult.CreateL( result8 );
       
   248             result = ETrue;
       
   249             }
       
   250         else if( paramForValue->Value().Get( result16 ) )
       
   251             {
       
   252             aResult.Assign( EscapeUtils::ConvertFromUnicodeToUtf8L( result16 ) );
       
   253             result = ETrue;
       
   254             }
       
   255         else
       
   256         	{
       
   257         	User::Leave( KErrBadName );
       
   258         	}
       
   259         }
       
   260     return result;
       
   261     }
       
   262 
       
   263 // ---------------------------------------------------------------------------
       
   264 // 
       
   265 // ---------------------------------------------------------------------------
       
   266 //
       
   267 EXPORT_C TBool CCPLiwMap::GetProperty( const TDesC8& aProperty ,
       
   268 		TInt32& aResult ) const
       
   269     {
       
   270     CP_DEBUG( _L8("CCPLiwMap::GetProperty - TInt32") );
       
   271     TBool result( EFalse );
       
   272     TInt pos( 0 );
       
   273     const TLiwGenericParam* paramForValue = iMap->FindFirst( pos, aProperty );
       
   274     if ( pos != KErrNotFound )
       
   275         {
       
   276         if( paramForValue->Value().Get( aResult ) )
       
   277             {
       
   278             result = ETrue;
       
   279             }
       
   280         }
       
   281     return result;
       
   282     }
       
   283 
       
   284 
       
   285 // ---------------------------------------------------------------------------
       
   286 // 
       
   287 // ---------------------------------------------------------------------------
       
   288 //
       
   289 EXPORT_C void CCPLiwMap::SetSecurityL(  const RMessage2& aMessage )
       
   290     {
       
   291     delete iPolicy;
       
   292     iPolicy = NULL;    
       
   293     iPolicy = CCPSecurityPolicy::NewL( aMessage );
       
   294     }
       
   295     
       
   296 // ---------------------------------------------------------------------------
       
   297 // 
       
   298 // ---------------------------------------------------------------------------
       
   299 //
       
   300 CCPLiwMap::~CCPLiwMap()
       
   301     {
       
   302     delete iMap;
       
   303     delete iPolicy;
       
   304     }
       
   305 
       
   306 // ---------------------------------------------------------------------------
       
   307 // 
       
   308 // ---------------------------------------------------------------------------
       
   309 //
       
   310 CCPLiwMap::CCPLiwMap()
       
   311     {
       
   312 
       
   313     }
       
   314 
       
   315 // ---------------------------------------------------------------------------
       
   316 // 
       
   317 // ---------------------------------------------------------------------------
       
   318 //
       
   319 void CCPLiwMap::InsertL( const TDesC8& aKey, const TLiwVariant& aValue )
       
   320     {
       
   321     CP_DEBUG( _L8("CCPLiwMap::InsertL") );
       
   322     Remove( aKey );
       
   323     TLiwGenericParam mp;
       
   324     mp.SetNameAndValueL( aKey, aValue );
       
   325     iMap->AppendL( mp );
       
   326     mp.Reset( );
       
   327     }
       
   328 
       
   329 // ---------------------------------------------------------------------------
       
   330 // 
       
   331 // ---------------------------------------------------------------------------
       
   332 //
       
   333 TBool CCPLiwMap::FindL( const TDesC8& aKey, TLiwVariant& aValue ) const
       
   334     {
       
   335     CP_DEBUG( _L8("CCPLiwMap::FindL") );
       
   336     TInt pos = 0;
       
   337     TBool result(EFalse);
       
   338     const TLiwGenericParam* tempParam = iMap->FindFirst( pos, aKey );
       
   339     if ( tempParam )
       
   340         {
       
   341         aValue.SetL( tempParam->Value( ) );
       
   342         result = ETrue;
       
   343         }
       
   344     return result;
       
   345     }
       
   346 
       
   347 // ---------------------------------------------------------------------------
       
   348 // 
       
   349 // ---------------------------------------------------------------------------
       
   350 //
       
   351 TInt CCPLiwMap::Count() const
       
   352     {
       
   353     return iMap->Count( );
       
   354     }
       
   355 
       
   356 // ---------------------------------------------------------------------------
       
   357 // 
       
   358 // ---------------------------------------------------------------------------
       
   359 //
       
   360 TBool CCPLiwMap::AtL( TInt aIndex, TDes8& aKey ) const
       
   361     {
       
   362     CP_DEBUG( _L8("CCPLiwMap::AtL") );
       
   363     TBool result(EFalse);
       
   364     if ( 0 <= aIndex && aIndex < iMap->Count( ) )
       
   365         {
       
   366         aKey = ((*iMap)[aIndex]).Name( );
       
   367         result = ETrue;
       
   368         }
       
   369     return result;
       
   370     }
       
   371 
       
   372 // ---------------------------------------------------------------------------
       
   373 // 
       
   374 // ---------------------------------------------------------------------------
       
   375 //
       
   376 void CCPLiwMap::Remove( const TDesC8& aKey )
       
   377     {
       
   378     CP_DEBUG( _L8("CCPLiwMap::Remove") );
       
   379     TInt pos = 0;
       
   380     iMap->FindFirst( pos, aKey );
       
   381     if ( pos != KErrNotFound )
       
   382         {
       
   383         iMap->Remove( aKey );
       
   384         }
       
   385     }
       
   386 
       
   387 // ---------------------------------------------------------------------------
       
   388 // 
       
   389 // ---------------------------------------------------------------------------
       
   390 //
       
   391 TInt CCPLiwMap::Size() const
       
   392     {
       
   393     return iMap->Size( );
       
   394     }
       
   395 
       
   396 // ---------------------------------------------------------------------------
       
   397 // 
       
   398 // ---------------------------------------------------------------------------
       
   399 //	
       
   400 void CCPLiwMap::ExternalizeL( RWriteStream& aStream ) const
       
   401     {
       
   402     CP_DEBUG( _L8("CCPLiwMap::ExternalizeL") );
       
   403     iMap->ExternalizeL( aStream );
       
   404     }
       
   405 
       
   406 // ---------------------------------------------------------------------------
       
   407 // 
       
   408 // ---------------------------------------------------------------------------
       
   409 //                  
       
   410 void CCPLiwMap::FillChangeInfoMapL( RSqlStatement& aStmt, 
       
   411 		CLiwDefaultMap* aMap )const
       
   412 	{
       
   413     TInt idIndex = ColumnIndexL( aStmt, KColumnId );
       
   414     TInt publisherIndex = ColumnIndexL( aStmt, KColumnPublisher );
       
   415     TInt contentIndex = ColumnIndexL( aStmt, KColumnContent_type );
       
   416     TInt content_idIndex = ColumnIndexL( aStmt, KColumnContent_id );
       
   417     TInt acl_Index = ColumnIndexL( aStmt, KColumnAccessList );
       
   418 	
       
   419     TInt32 id = aStmt.ColumnInt( idIndex ) ;
       
   420     TPtrC publisher;
       
   421     User::LeaveIfError(aStmt.ColumnText( publisherIndex,publisher) );
       
   422     TPtrC content_type;
       
   423     User::LeaveIfError(aStmt.ColumnText( contentIndex,content_type ) );
       
   424     TPtrC content_id;
       
   425     User::LeaveIfError(aStmt.ColumnText( content_idIndex,content_id) );
       
   426     aMap->InsertL( KId, TLiwVariant( id ) );
       
   427     aMap->InsertL( KPublisherId, TLiwVariant( publisher ) );
       
   428     aMap->InsertL( KContentType, TLiwVariant( content_type ) );
       
   429     aMap->InsertL( KContentId, TLiwVariant( content_id ) );
       
   430     aMap->InsertL( KOperation, TLiwVariant( KOperationDelete ) );
       
   431     RBuf type;
       
   432     type.CleanupClosePushL();
       
   433     if( GetPropertyL( KType, type ) )
       
   434          {
       
   435          aMap->InsertL( KType , TLiwVariant( type ) );
       
   436          }        
       
   437     CleanupStack::PopAndDestroy( &type );  
       
   438 	}
       
   439 
       
   440 
       
   441 // ---------------------------------------------------------------------------
       
   442 // 
       
   443 // ---------------------------------------------------------------------------
       
   444 //
       
   445 void CCPLiwMap::SetL( const CLiwGenericParamList& aInParamList )
       
   446     {
       
   447     
       
   448     CP_DEBUG( _L8("CCPLiwMap::SetL") );
       
   449     for ( TInt i = 0; i < aInParamList.Count( ); i++ )
       
   450         {
       
   451         const TLiwGenericParam& param = aInParamList[i];
       
   452         if ( param.Value().TypeId( ) == LIW::EVariantTypeMap )
       
   453             {
       
   454             const CLiwMap* map = param.Value().AsMap( );
       
   455             for ( TInt i = 0; i <map->Count( ); i++ )
       
   456                 {
       
   457                 TBuf8<128> key;
       
   458                 map->AtL( i, key );
       
   459                 TLiwVariant value;
       
   460                 value.PushL( );
       
   461                 map->FindL( key, value );
       
   462                 if ( key == KOperation )
       
   463                 	{
       
   464                 	IsProperOperationL( value );
       
   465                 	}
       
   466                 RBuf8 datadesc;
       
   467                 datadesc.CleanupClosePushL();
       
   468                 if ( value.TypeId( ) == LIW::EVariantTypeMap )
       
   469                     {
       
   470                     const CLiwMap* internalMap = value.AsMap( );
       
   471                     datadesc.CreateL( internalMap->Size( ) );
       
   472                     RDesWriteStream datastrm(datadesc);
       
   473                     CleanupClosePushL( datastrm );
       
   474                     internalMap->ExternalizeL( datastrm );
       
   475                     datastrm.CommitL( );
       
   476                     CleanupStack::PopAndDestroy( &datastrm );
       
   477                     value.Reset( );
       
   478                     value.Set( datadesc );
       
   479                     }
       
   480                 TLiwGenericParam data( key, value);
       
   481                 iMap->AppendL( data );
       
   482                 CleanupStack::PopAndDestroy( &datadesc );
       
   483                 CleanupStack::PopAndDestroy( &value );
       
   484                 }
       
   485             }
       
   486         else
       
   487             {
       
   488             iMap->AppendL( param );
       
   489             }
       
   490         }
       
   491     }
       
   492 
       
   493 // ---------------------------------------------------------------------------
       
   494 // 
       
   495 // ---------------------------------------------------------------------------
       
   496 // 
       
   497 void CCPLiwMap::IsProperOperationL( const TLiwVariant& aValue ) const
       
   498     {
       
   499     CP_DEBUG( _L8("CContentMap::IsProperOperationL") );
       
   500 	TPtrC valDesc( KNullDesC );
       
   501 	TPtrC8 valDesc8( KNullDesC8 );
       
   502 	RBuf desc;
       
   503 	desc.CleanupClosePushL();
       
   504 
       
   505     if( aValue.Get( valDesc ) == EFalse )
       
   506     	{
       
   507     	if( aValue.Get( valDesc8 ) != EFalse )
       
   508 			{
       
   509 			desc.Assign( EscapeUtils::ConvertToUnicodeFromUtf8L( valDesc8 ) );
       
   510 			valDesc.Set( desc );
       
   511 			}
       
   512     	else
       
   513     		{
       
   514     		User::Leave( KErrBadName );
       
   515     		}
       
   516     	}
       
   517     
       
   518     TLex input( valDesc );
       
   519     
       
   520     CDesC16Array* array = new (ELeave) CDesC16ArrayFlat(4);
       
   521     CleanupStack::PushL( array );
       
   522     
       
   523     TLexMark startMark;
       
   524     input.Mark( startMark );
       
   525     TBool notEmpty = EFalse;
       
   526     while ( !input.Eos() )
       
   527         {
       
   528         if( input.Peek() == ':')
       
   529             {
       
   530             array->AppendL( input.MarkedToken( startMark ) );
       
   531             input.Inc();
       
   532             input.Mark( startMark );
       
   533             }
       
   534         input.Inc();     
       
   535         notEmpty = ETrue;       
       
   536         }
       
   537     if ( notEmpty )
       
   538         {
       
   539         array->AppendL( input.MarkedToken( startMark ) );
       
   540         }        
       
   541     
       
   542     for( TInt i= 0; i < array->MdcaCount(); i++ )
       
   543     	{
       
   544     	TPtrC operValue( array->MdcaPoint(i) );
       
   545     	
       
   546     	if( operValue.Compare( KOperationAdd ) &&
       
   547     		operValue.Compare( KOperationUpdate ) &&
       
   548     		operValue.Compare( KOperationDelete ) &&
       
   549     		operValue.Compare( KOperationExecute ) )
       
   550     		{
       
   551     		User::Leave( KErrArgument );
       
   552     	    }
       
   553     	}
       
   554     CleanupStack::PopAndDestroy( array );
       
   555 	CleanupStack::PopAndDestroy( &desc );
       
   556     }
       
   557 
       
   558 
       
   559 // ---------------------------------------------------------------------------
       
   560 // 
       
   561 // ---------------------------------------------------------------------------
       
   562 // 
       
   563 void CCPLiwMap::AppendGetListFilterL( RBuf& aQuery, TUint& aFilter ) const
       
   564     {
       
   565     CP_DEBUG( _L8("CContentMap::AppendGetListFilterL") );
       
   566     if( !IsGetListAllL( aFilter ) )
       
   567     	{
       
   568     	AppendFilterL( aQuery, aFilter );
       
   569     	}
       
   570     }
       
   571 
       
   572 // ---------------------------------------------------------------------------
       
   573 // 
       
   574 // ---------------------------------------------------------------------------
       
   575 // 
       
   576 void CCPLiwMap::AppendRemoveFilterL( RBuf& aQuery, TUint& aFilter ) const
       
   577     {
       
   578     CP_DEBUG( _L8("CContentMap::AppendRemoveFilterL") );
       
   579 	AppendFilterL( aQuery, aFilter );
       
   580     }
       
   581 // ---------------------------------------------------------------------------
       
   582 // 
       
   583 // ---------------------------------------------------------------------------
       
   584 // 
       
   585 void CCPLiwMap::AppendFilterL( RBuf& aQuery, TUint& aFilter ) const
       
   586     {
       
   587     CP_DEBUG( _L8("CContentMap::AppendFilterL") );
       
   588 
       
   589     TBool nextFilter( EFalse );
       
   590     
       
   591 	RemoveAllAttributeL( aFilter ); //remove "all" attribute from publisher, 
       
   592 						   //cont_type or cont_id
       
   593     
       
   594    	aQuery.ReAllocL( aQuery.Length( ) + KWhere().Length( ) );
       
   595    	aQuery.Append( KWhere );
       
   596     	
       
   597    	if( aFilter & EContentType )
       
   598    		{
       
   599    		aQuery.ReAllocL( aQuery.Length( ) + KSQLGetContentType().Length( ) );
       
   600 		aQuery.Append( KSQLGetContentType );
       
   601 		nextFilter = ETrue;    
       
   602    		}
       
   603    	if( aFilter & EPublisher )
       
   604    		{
       
   605    		if( nextFilter )
       
   606    			{
       
   607    			aQuery.ReAllocL( aQuery.Length( ) + KAnd().Length( ) + 
       
   608    					KSQLGetPublisher().Length( ) );
       
   609 			aQuery.Append( KAnd );
       
   610 			aQuery.Append( KSQLGetPublisher );
       
   611    			}
       
   612    		else
       
   613    			{
       
   614    			aQuery.ReAllocL( aQuery.Length( ) + 
       
   615    					KSQLGetPublisher().Length( ) );
       
   616    			aQuery.Append( KSQLGetPublisher );
       
   617    			}
       
   618    		nextFilter = ETrue;  
       
   619    		}
       
   620    	if( aFilter & EContentId )
       
   621    		{
       
   622    		if( nextFilter )
       
   623    			{
       
   624    			aQuery.ReAllocL( aQuery.Length( ) + 
       
   625    					KAnd().Length( ) + KSQLGetContentId().Length( ) );
       
   626             aQuery.Append( KAnd );
       
   627             aQuery.Append( KSQLGetContentId );
       
   628   			}
       
   629 		else
       
   630 			{
       
   631 			aQuery.ReAllocL( aQuery.Length( ) + KSQLGetContentId().Length( ) );
       
   632             aQuery.Append( KSQLGetContentId );
       
   633 			}
       
   634    		nextFilter = ETrue;  
       
   635    		}
       
   636     }
       
   637 
       
   638 // ---------------------------------------------------------------------------
       
   639 // 
       
   640 // ---------------------------------------------------------------------------
       
   641 //  
       
   642 void CCPLiwMap::PrepareStmtforAddL( RSqlDatabase aSqlDb,
       
   643     RSqlStatement& aStmt, const TDesC& aQuery ) const
       
   644     {
       
   645     CP_DEBUG( _L8("CCPLiwMap::PrepareStmtforAddL") );
       
   646     RBuf publisher;
       
   647     publisher.CleanupClosePushL();
       
   648     RBuf content_type;
       
   649     content_type.CleanupClosePushL();  
       
   650     RBuf content_id;
       
   651     content_id.CleanupClosePushL();  
       
   652     if ( GetPropertyL( KPublisherId, publisher )
       
   653         && GetPropertyL( KContentType, content_type )
       
   654         && GetPropertyL( KContentId, content_id ) )
       
   655         {
       
   656         User::LeaveIfError( aStmt.Prepare( aSqlDb, aQuery ) );
       
   657         TInt publisherIndex = aStmt.ParameterIndex( KSQLPublisher );
       
   658         TInt content_typeIndex = aStmt.ParameterIndex( KSQLContent_type );
       
   659         TInt content_idIndex = aStmt.ParameterIndex( KSQLContent_id );
       
   660         
       
   661         BindTextL( aStmt, publisherIndex, publisher );
       
   662         BindTextL( aStmt, content_typeIndex, content_type );
       
   663         BindTextL( aStmt, content_idIndex, content_id );
       
   664         }
       
   665     else
       
   666         {
       
   667         User::Leave( KErrArgument );
       
   668         }
       
   669     CleanupStack::PopAndDestroy( &content_id );
       
   670     CleanupStack::PopAndDestroy( &content_type );
       
   671     CleanupStack::PopAndDestroy( &publisher );
       
   672     }
       
   673 
       
   674 // ---------------------------------------------------------------------------
       
   675 // 
       
   676 // ---------------------------------------------------------------------------
       
   677 //
       
   678 TUint CCPLiwMap::GetFilterL( )const
       
   679     {
       
   680     CP_DEBUG( _L8("CCPLiwMap::GetFilterL") );
       
   681     TUint result (0);
       
   682     if(IsPublisherNameL())
       
   683         {
       
   684         result |= EPublisher;
       
   685         }
       
   686     if(IsContentTypeL())
       
   687         {
       
   688         result |= EContentType;
       
   689         }
       
   690     if(IsContentIdL())
       
   691         {
       
   692         result |= EContentId;
       
   693         }
       
   694     if(IsFlag())
       
   695         {
       
   696         result |= EFlag;
       
   697         }		
       
   698     return result;
       
   699 	}
       
   700 
       
   701 // ---------------------------------------------------------------------------
       
   702 // 
       
   703 // ---------------------------------------------------------------------------
       
   704 //
       
   705 CCPLiwMap::TCPSortOrder CCPLiwMap::GetSortL() const
       
   706     {
       
   707     CP_DEBUG( _L8("CCPLiwMap::GetSortL") );
       
   708     TCPSortOrder result(ECPRecent);
       
   709     RBuf sort;
       
   710     sort.CleanupClosePushL();  
       
   711     if ( GetPropertyL( KSortOrder, sort ) )
       
   712         {
       
   713         if ( !sort.Compare( KSortRecent ) )
       
   714             {
       
   715             result = ECPRecent;
       
   716             }
       
   717         else if ( !sort.Compare( KSortPublisher ) )
       
   718             {
       
   719             result = ECPPublisher;
       
   720             }
       
   721         else if ( !sort.Compare( KSortContentType ) )
       
   722             {
       
   723             result = ECPContent;
       
   724             }
       
   725         else if ( !sort.Compare( KSortContentId ) )
       
   726             {
       
   727             result = ECPContentId;
       
   728             }
       
   729         }
       
   730     CleanupStack::PopAndDestroy( &sort );
       
   731     return result;
       
   732     }
       
   733 
       
   734 // ---------------------------------------------------------------------------
       
   735 // 
       
   736 // ---------------------------------------------------------------------------
       
   737 //
       
   738 TBool CCPLiwMap::IsPublisherNameL() const
       
   739     {
       
   740     TBool result( EFalse );
       
   741     RBuf buffer;
       
   742     buffer.CleanupClosePushL();
       
   743     result = GetPropertyL( KPublisherId, buffer );
       
   744     if( result && buffer.Length() == KErrNone )
       
   745         {
       
   746         User::Leave( KErrArgument );
       
   747         }
       
   748     CleanupStack::PopAndDestroy( &buffer );
       
   749     return result;
       
   750     }
       
   751 
       
   752 // ---------------------------------------------------------------------------
       
   753 // 
       
   754 // ---------------------------------------------------------------------------
       
   755 //
       
   756 TBool CCPLiwMap::IsContentTypeL() const
       
   757     {
       
   758     TBool result( EFalse );
       
   759     RBuf buffer;
       
   760     buffer.CleanupClosePushL();
       
   761     result = GetPropertyL( KContentType, buffer );
       
   762     if( result && buffer.Length() == KErrNone )
       
   763         {
       
   764         User::Leave( KErrArgument );
       
   765         }
       
   766     CleanupStack::PopAndDestroy( &buffer );
       
   767     return result;
       
   768     }
       
   769 
       
   770 // ---------------------------------------------------------------------------
       
   771 // 
       
   772 // ---------------------------------------------------------------------------
       
   773 //
       
   774 TBool CCPLiwMap::IsContentIdL() const
       
   775     {
       
   776     TBool result( EFalse );
       
   777     RBuf buffer;
       
   778     buffer.CleanupClosePushL();
       
   779     result = GetPropertyL( KContentId, buffer );
       
   780     if( result && buffer.Length() == KErrNone )
       
   781         {
       
   782         User::Leave( KErrArgument );
       
   783         }
       
   784     CleanupStack::PopAndDestroy( &buffer );
       
   785     return result;
       
   786     }
       
   787 
       
   788 // ---------------------------------------------------------------------------
       
   789 // 
       
   790 // ---------------------------------------------------------------------------
       
   791 //
       
   792 TBool CCPLiwMap::IsTriggerL( ) const
       
   793     {
       
   794     TBool result( EFalse );
       
   795     RBuf8 buffer;
       
   796     buffer.CleanupClosePushL();
       
   797     result = GetPropertyL( KActionTrigger, buffer );
       
   798     CleanupStack::PopAndDestroy( &buffer );
       
   799     return result;
       
   800     }
       
   801 
       
   802 // ---------------------------------------------------------------------------
       
   803 // 
       
   804 // ---------------------------------------------------------------------------
       
   805 //
       
   806 TBool CCPLiwMap::IsFlag( ) const
       
   807     {
       
   808     TInt32 buffer( 0 );
       
   809     return GetProperty( KFlag, buffer );
       
   810     }
       
   811 		
       
   812 // ---------------------------------------------------------------------------
       
   813 // 
       
   814 // ---------------------------------------------------------------------------
       
   815 //
       
   816 TBool CCPLiwMap::IsId() const
       
   817     {
       
   818     TInt32 id( 0);
       
   819     return GetProperty( KId, id );
       
   820     }
       
   821 
       
   822 // ---------------------------------------------------------------------------
       
   823 // 
       
   824 // ---------------------------------------------------------------------------
       
   825 //
       
   826 TBool CCPLiwMap::PropertyExists( const TDesC8& aProperty ) const
       
   827     {
       
   828     TBool result( EFalse );
       
   829     TInt pos( 0 );
       
   830     iMap->FindFirst( pos, aProperty );
       
   831     if ( pos != KErrNotFound )
       
   832         {
       
   833         result = ETrue;
       
   834         }
       
   835     return result;
       
   836     }
       
   837 
       
   838 
       
   839 // ---------------------------------------------------------------------------
       
   840 // 
       
   841 // ---------------------------------------------------------------------------
       
   842 //
       
   843 TUint CCPLiwMap::GetListL( RSqlDatabase aSqlDb, const TDesC& aQuery,
       
   844     CLiwGenericParamList* aList, RArray<TInt32>& aItemsToDelete ) const
       
   845     {
       
   846     CP_DEBUG( _L8("CCPLiwMap::GetListL") );
       
   847     RBuf sqlquery;
       
   848     sqlquery.CleanupClosePushL();
       
   849     sqlquery.CreateL( aQuery );
       
   850     TInt32 id( 0);
       
   851     if ( GetProperty( KId, id ) )
       
   852         {
       
   853         ConstructSelectIdL( sqlquery );
       
   854         }
       
   855     else
       
   856         {
       
   857         ConstructGetListSelectL( sqlquery );
       
   858         }
       
   859     RSqlStatement stmt;
       
   860     CleanupClosePushL( stmt );
       
   861     User::LeaveIfError( stmt.Prepare( aSqlDb, sqlquery ) );
       
   862     BindValueL( sqlquery, stmt );
       
   863     SaveQueryResultsL( stmt, *aList, aItemsToDelete );
       
   864     CleanupStack::PopAndDestroy( &stmt ) ;
       
   865     CleanupStack::PopAndDestroy( &sqlquery );
       
   866     return aList->Count( );
       
   867     }
       
   868 
       
   869 // ---------------------------------------------------------------------------
       
   870 // 
       
   871 // ---------------------------------------------------------------------------
       
   872 //
       
   873 void CCPLiwMap::RemoveL( RSqlDatabase aSqlDb, const TDesC& aQuery ) const
       
   874     {
       
   875     CP_DEBUG( _L8("CCPLiwMap::RemoveL") );
       
   876     RBuf sqlquery;
       
   877     sqlquery.CleanupClosePushL();
       
   878     sqlquery.CreateL( aQuery );
       
   879     TInt32 id( 0);
       
   880     if ( GetProperty( KId, id ) )
       
   881         {
       
   882         ConstructSelectIdL( sqlquery );
       
   883         }
       
   884     else
       
   885         {
       
   886         ConstructRemoveSelectL( sqlquery, EFalse );
       
   887         }
       
   888 
       
   889     RSqlStatement stmt;
       
   890     CleanupClosePushL( stmt );
       
   891     User::LeaveIfError( stmt.Prepare( aSqlDb, sqlquery ) );
       
   892 
       
   893     BindValueL( sqlquery, stmt );
       
   894     if ( stmt.Exec( ) <= 0 )
       
   895         {
       
   896         User::Leave( KErrNotFound );
       
   897         }
       
   898     CleanupStack::PopAndDestroy( &stmt ) ;
       
   899     CleanupStack::PopAndDestroy( &sqlquery );
       
   900     }
       
   901 // ---------------------------------------------------------------------------
       
   902 // 
       
   903 // ---------------------------------------------------------------------------
       
   904 //  
       
   905 void CCPLiwMap::FetchIdsL( TInt32 aId, const TDesC& aQuery,
       
   906     CLiwDefaultMap* aMap, RSqlDatabase aSqlDb ) const
       
   907     {
       
   908     CP_DEBUG( _L8("CCPLiwMap::FetchIdsL") );    
       
   909     RSqlStatement stmt;
       
   910     CleanupClosePushL( stmt );
       
   911     //prepare statment for "Get Ids" (Publisher, ContentType,ContentId)
       
   912     User::LeaveIfError( stmt.Prepare( aSqlDb, aQuery ) );
       
   913     TInt idIndex = stmt.ParameterIndex( KSQLId );
       
   914     User::LeaveIfError( stmt.BindInt( idIndex, aId ) );
       
   915 
       
   916     TInt publisherIndex = ColumnIndexL( stmt, KColumnPublisher );
       
   917     TInt contentTypeIndex = ColumnIndexL( stmt, KColumnContent_type );
       
   918     TInt contentIdIndex = ColumnIndexL( stmt, KColumnContent_id );
       
   919     TInt acl_Index = ColumnIndexL( stmt, KColumnAccessList );
       
   920     
       
   921     if ( stmt.Next( ) == KSqlAtRow )
       
   922         {
       
   923         if( iPolicy )
       
   924             {
       
   925             TPtrC8 acl;
       
   926             User::LeaveIfError( stmt.ColumnBinary( acl_Index, acl ) );
       
   927             if( !iPolicy->CheckSecurityL( acl , CCPSecurityPolicy::EWrite ) )
       
   928             	{
       
   929             	User::Leave( KErrPermissionDenied );
       
   930             	}
       
   931             }
       
   932         TPtrC publisher;
       
   933         User::LeaveIfError( stmt.ColumnText( publisherIndex, publisher ) );
       
   934         TPtrC content_type;
       
   935         User::LeaveIfError( stmt.ColumnText( contentTypeIndex, content_type ) );
       
   936         TPtrC content_id;
       
   937         User::LeaveIfError( stmt.ColumnText( contentIdIndex, content_id ) );
       
   938         aMap->InsertL( KId, TLiwVariant( aId ) );
       
   939         aMap->InsertL( KPublisherId, TLiwVariant( publisher ) );
       
   940         aMap->InsertL( KContentType, TLiwVariant( content_type ) );
       
   941         aMap->InsertL( KContentId, TLiwVariant( content_id ) );
       
   942         aMap->InsertL( KOperation, TLiwVariant( KOperationUpdate ) );
       
   943         }
       
   944     CleanupStack::PopAndDestroy( &stmt ) ;
       
   945     }
       
   946 
       
   947 // ---------------------------------------------------------------------------
       
   948 // 
       
   949 // ---------------------------------------------------------------------------
       
   950 //
       
   951 void CCPLiwMap::FetchIdL( RSqlDatabase aSqlDb, const TDesC& aQuery, 
       
   952 		TInt32& aId ) const
       
   953     {
       
   954     CP_DEBUG( _L8("CCPLiwMap::FetchIdL") );
       
   955     aId = 0;
       
   956     RSqlStatement stmt;
       
   957     CleanupClosePushL( stmt );
       
   958     PrepareStmtforAddL( aSqlDb, stmt, aQuery );
       
   959     TInt idIndex = ColumnIndexL( stmt, KColumnId );
       
   960     if ( stmt.Next( ) == KSqlAtRow )
       
   961         {
       
   962         aId = stmt.ColumnInt( idIndex );
       
   963         }
       
   964     CleanupStack::PopAndDestroy( &stmt ) ;
       
   965     }
       
   966 
       
   967 // ---------------------------------------------------------------------------
       
   968 // 
       
   969 // ---------------------------------------------------------------------------
       
   970 //  
       
   971 void CCPLiwMap::GetIdsOfRemovedEntriesL( RSqlDatabase aSqlDb,
       
   972     const TDesC& aQuery, CLiwDefaultList* aList ) const
       
   973     {
       
   974     CP_DEBUG( _L8("CCPLiwMap::GetIdsOfRemovedEntriesL") );
       
   975     RBuf sqlquery;
       
   976     sqlquery.CleanupClosePushL();
       
   977     sqlquery.CreateL( aQuery );
       
   978     TInt32 id( 0);
       
   979     if ( GetProperty( KId, id ) )
       
   980         {
       
   981         ConstructSelectIdL( sqlquery );
       
   982         }
       
   983     else
       
   984         {
       
   985         ConstructRemoveSelectL( sqlquery );
       
   986         }
       
   987     RSqlStatement stmt;
       
   988     CleanupClosePushL( stmt );
       
   989     User::LeaveIfError( stmt.Prepare( aSqlDb, sqlquery ) );
       
   990     BindValueL( sqlquery, stmt );
       
   991     SaveQueryResultsIdsL( stmt, aList );
       
   992     if( aList && aList->Count()==0 )
       
   993         {
       
   994         User::Leave( KErrNotFound );
       
   995         }
       
   996     CleanupStack::PopAndDestroy( &stmt ) ;
       
   997     CleanupStack::PopAndDestroy( &sqlquery );
       
   998     }
       
   999 
       
  1000 // ---------------------------------------------------------------------------
       
  1001 // 
       
  1002 // ---------------------------------------------------------------------------
       
  1003 //  
       
  1004 void CCPLiwMap::SaveQueryResultsIdsL( RSqlStatement& aStmt,
       
  1005     CLiwDefaultList* aList ) const
       
  1006     {
       
  1007     CP_DEBUG( _L8("CCPLiwMap::SaveQueryResultsIdsL") );
       
  1008     TInt acl_Index = ColumnIndexL( aStmt, KColumnAccessList );
       
  1009 
       
  1010     while ( aStmt.Next( ) == KSqlAtRow )
       
  1011         {
       
  1012         if( iPolicy )
       
  1013             {
       
  1014             TPtrC8 acl;
       
  1015             User::LeaveIfError( aStmt.ColumnBinary( acl_Index, acl ) );
       
  1016             if ( !iPolicy->CheckSecurityL( acl , 
       
  1017             		CCPSecurityPolicy::EDelete ) )
       
  1018               	{
       
  1019         		User::Leave( KErrPermissionDenied );
       
  1020                	}            
       
  1021             }
       
  1022         if ( aList )
       
  1023             {
       
  1024             CLiwDefaultMap* targetMap = CLiwDefaultMap::NewLC( );
       
  1025             FillChangeInfoMapL( aStmt, targetMap );
       
  1026             aList->AppendL( TLiwVariant( targetMap ) );
       
  1027             CleanupStack::PopAndDestroy( targetMap );    
       
  1028             }
       
  1029         }
       
  1030     }
       
  1031 
       
  1032 // ---------------------------------------------------------------------------
       
  1033 // 
       
  1034 // ---------------------------------------------------------------------------
       
  1035 // 
       
  1036 void CCPLiwMap::ConstructSelectIdL( RBuf& aQuery ) const
       
  1037     {
       
  1038     aQuery.ReAllocL( aQuery.Length( ) + KSQLGetId().Length( ) + 
       
  1039     		KWhere().Length() );
       
  1040     aQuery.Append( KWhere );
       
  1041     aQuery.Append( KSQLGetId );
       
  1042     }
       
  1043 
       
  1044 // ---------------------------------------------------------------------------
       
  1045 // 
       
  1046 // ---------------------------------------------------------------------------
       
  1047 // 
       
  1048 void CCPLiwMap::ConstructGetListSelectL( RBuf& aQuery, TBool aGet ) const
       
  1049     {
       
  1050     TUint filter = GetFilterL( );
       
  1051     AppendGetListFilterL( aQuery, filter );
       
  1052     if ( aGet )
       
  1053         {
       
  1054         AppendSortL( aQuery, GetSortL( ) );
       
  1055         }
       
  1056     }
       
  1057 
       
  1058 // ---------------------------------------------------------------------------
       
  1059 // 
       
  1060 // ---------------------------------------------------------------------------
       
  1061 // 
       
  1062 void CCPLiwMap::ConstructRemoveSelectL( RBuf& aQuery, TBool aGet ) const
       
  1063     {
       
  1064     TUint filter = GetFilterL( );
       
  1065     AppendRemoveFilterL( aQuery, filter );
       
  1066     if ( aGet )
       
  1067         {
       
  1068         AppendSortL( aQuery, GetSortL( ) );
       
  1069         }
       
  1070     }
       
  1071 
       
  1072 // ---------------------------------------------------------------------------
       
  1073 // 
       
  1074 // ---------------------------------------------------------------------------
       
  1075 //
       
  1076 void CCPLiwMap::BindValueL( const RBuf& aQuery, RSqlStatement& aStmt ) const
       
  1077     {
       
  1078     CP_DEBUG( _L8("CCPLiwMap::BindValueL") );
       
  1079     if ( aQuery.Find( KSQLGetPublisher ) != KErrNotFound )
       
  1080         {
       
  1081         TInt param = aStmt.ParameterIndex( KSQLPublisher );
       
  1082         RBuf publisher;
       
  1083         publisher.CleanupClosePushL();
       
  1084         User::LeaveIfError( GetPropertyL( KPublisherId, publisher ));
       
  1085         BindTextL( aStmt, param, publisher );
       
  1086         CleanupStack::PopAndDestroy( &publisher );  
       
  1087         }
       
  1088     if ( aQuery.Find( KSQLGetContentType ) != KErrNotFound )
       
  1089         {
       
  1090         TInt param = aStmt.ParameterIndex( KSQLContent_type );
       
  1091         RBuf content_type;
       
  1092         content_type.CleanupClosePushL();
       
  1093         User::LeaveIfError( GetPropertyL( KContentType, content_type ));
       
  1094         BindTextL( aStmt, param, content_type );
       
  1095         CleanupStack::PopAndDestroy( &content_type );  
       
  1096         }
       
  1097     if ( aQuery.Find( KSQLGetContentId ) != KErrNotFound )
       
  1098         {
       
  1099         TInt param = aStmt.ParameterIndex( KSQLContent_id );
       
  1100         RBuf content_id;
       
  1101         content_id.CleanupClosePushL();
       
  1102         User::LeaveIfError( GetPropertyL( KContentId, content_id ));
       
  1103         BindTextL( aStmt, param, content_id );
       
  1104         CleanupStack::PopAndDestroy( &content_id );  
       
  1105         }
       
  1106     if ( aQuery.Find( KSQLGetId ) != KErrNotFound )
       
  1107         {
       
  1108         TInt param = aStmt.ParameterIndex( KSQLId );
       
  1109         TInt32 id( 0);
       
  1110         User::LeaveIfError( GetProperty( KId, id ));
       
  1111         BindIntL( aStmt, param, id );
       
  1112         }
       
  1113     }
       
  1114 
       
  1115 // ---------------------------------------------------------------------------
       
  1116 // 
       
  1117 // ---------------------------------------------------------------------------
       
  1118 //
       
  1119 TBool CCPLiwMap::IsGetListAllL( TUint aFilter ) const
       
  1120     {
       
  1121     TBool result( EFalse );
       
  1122     if ( !( aFilter & EContentType ) &&
       
  1123     		!( aFilter & EContentId ) &&
       
  1124     		!( aFilter & EPublisher ) )
       
  1125     	{
       
  1126     	result = ETrue;
       
  1127     	}
       
  1128     else if ( ( aFilter & EContentType ) &&
       
  1129 				( aFilter & EContentId ) &&
       
  1130 				( aFilter & EPublisher ) )
       
  1131     	{
       
  1132         RBuf publisher;
       
  1133         publisher.CleanupClosePushL();
       
  1134         RBuf content_type;
       
  1135         content_type.CleanupClosePushL();  
       
  1136         RBuf content_id;
       
  1137         content_id.CleanupClosePushL();  
       
  1138         GetPropertyL( KPublisherId, publisher );
       
  1139         GetPropertyL( KContentType, content_type );
       
  1140         GetPropertyL( KContentId, content_id );    
       
  1141         
       
  1142         if( ( publisher == KAll ) &&
       
  1143         		( content_type == KAll ) &&
       
  1144         		( content_id == KAll) )
       
  1145         	{
       
  1146         	result = ETrue;
       
  1147         	}
       
  1148         CleanupStack::PopAndDestroy( &content_id );
       
  1149         CleanupStack::PopAndDestroy( &content_type );
       
  1150         CleanupStack::PopAndDestroy( &publisher );
       
  1151     	}
       
  1152     return result;
       
  1153     }
       
  1154 
       
  1155 // ---------------------------------------------------------------------------
       
  1156 // 
       
  1157 // ---------------------------------------------------------------------------
       
  1158 //
       
  1159 void CCPLiwMap::RemoveAllAttributeL( TUint& aFilter ) const
       
  1160     {
       
  1161     RBuf publisher;
       
  1162     publisher.CleanupClosePushL();
       
  1163     RBuf content_type;
       
  1164     content_type.CleanupClosePushL();  
       
  1165     RBuf content_id;
       
  1166     content_id.CleanupClosePushL();  
       
  1167     GetPropertyL( KPublisherId, publisher );
       
  1168     GetPropertyL( KContentType, content_type );
       
  1169     GetPropertyL( KContentId, content_id );    
       
  1170     
       
  1171     if( publisher == KAll )
       
  1172     	{
       
  1173     	iMap->Remove( KPublisherId );
       
  1174     	aFilter = aFilter & ~EPublisher;
       
  1175     	}
       
  1176     if( content_type == KAll )
       
  1177     	{
       
  1178     	iMap->Remove( KContentType );
       
  1179     	aFilter = aFilter & ~EContentType;
       
  1180     	}
       
  1181     if( content_id == KAll )
       
  1182     	{
       
  1183     	iMap->Remove( KContentId );
       
  1184     	aFilter = aFilter & ~EContentId;    	
       
  1185     	}
       
  1186 
       
  1187     CleanupStack::PopAndDestroy( &content_id );
       
  1188     CleanupStack::PopAndDestroy( &content_type );
       
  1189     CleanupStack::PopAndDestroy( &publisher );
       
  1190     
       
  1191     }
       
  1192 
       
  1193 // ---------------------------------------------------------------------------
       
  1194 // 
       
  1195 // ---------------------------------------------------------------------------
       
  1196 //
       
  1197 void CCPLiwMap::ConstructL()
       
  1198     {
       
  1199     iMap = CLiwGenericParamList::NewL( );
       
  1200     }
       
  1201 
       
  1202 // ---------------------------------------------------------------------------
       
  1203 // 
       
  1204 // ---------------------------------------------------------------------------
       
  1205 //
       
  1206 void CCPLiwMap::CheckIdentifiersL() const
       
  1207     {
       
  1208     IsPublisherNameL();
       
  1209     IsContentTypeL();
       
  1210     IsContentIdL();
       
  1211     }
       
  1212 
       
  1213 // ---------------------------------------------------------------------------
       
  1214 // 
       
  1215 // ---------------------------------------------------------------------------
       
  1216 //
       
  1217 void CCPLiwMap::BindTextL(RSqlStatement& aStmt, TInt aParameterIndex,
       
  1218     const TDesC& aParameterText) const
       
  1219     {
       
  1220     User::LeaveIfError( aParameterIndex );
       
  1221     User::LeaveIfError( aStmt.BindText( aParameterIndex, aParameterText ) );
       
  1222     }
       
  1223     
       
  1224 // ---------------------------------------------------------------------------
       
  1225 // 
       
  1226 // ---------------------------------------------------------------------------
       
  1227 //
       
  1228 void CCPLiwMap::BindBinaryL(RSqlStatement& aStmt, TInt aParameterIndex,
       
  1229     const TDesC8& aParameterData) const
       
  1230     {
       
  1231     User::LeaveIfError(aParameterIndex);
       
  1232     User::LeaveIfError(aStmt.BindBinary(aParameterIndex, aParameterData));
       
  1233     }
       
  1234 
       
  1235 // ---------------------------------------------------------------------------
       
  1236 // 
       
  1237 // ---------------------------------------------------------------------------
       
  1238 //
       
  1239 void CCPLiwMap::BindInt64L(RSqlStatement& aStmt, TInt aParameterIndex,
       
  1240     TInt64 aParameterValue) const
       
  1241     {
       
  1242     User::LeaveIfError(aParameterIndex);
       
  1243     User::LeaveIfError(aStmt.BindInt64(aParameterIndex, aParameterValue));
       
  1244     }
       
  1245 
       
  1246 // ---------------------------------------------------------------------------
       
  1247 // 
       
  1248 // ---------------------------------------------------------------------------
       
  1249 //
       
  1250 void CCPLiwMap::BindIntL(RSqlStatement& aStmt, TInt aParameterIndex,
       
  1251     TInt aParameterValue) const
       
  1252     {
       
  1253     User::LeaveIfError(aParameterIndex);
       
  1254     User::LeaveIfError(aStmt.BindInt(aParameterIndex, aParameterValue));
       
  1255     }
       
  1256 
       
  1257 // ---------------------------------------------------------------------------
       
  1258 // 
       
  1259 // ---------------------------------------------------------------------------
       
  1260 //
       
  1261 TInt CCPLiwMap::ColumnIndexL(RSqlStatement& aStmt, const TDesC& aColumnName )
       
  1262 	const
       
  1263     {
       
  1264     TInt ret( aStmt.ColumnIndex( aColumnName ) );
       
  1265 	User::LeaveIfError( ret );
       
  1266     return ret;
       
  1267     }
       
  1268 
       
  1269 
       
  1270