diff -r b276298d5729 -r edd621764147 contentpublishingsrv/contentpublishingserver/cpserver/src/cpactiondatacache.cpp --- a/contentpublishingsrv/contentpublishingserver/cpserver/src/cpactiondatacache.cpp Tue Apr 27 16:57:49 2010 +0300 +++ b/contentpublishingsrv/contentpublishingserver/cpserver/src/cpactiondatacache.cpp Tue May 11 16:30:05 2010 +0300 @@ -20,6 +20,7 @@ #include #include #include +#include #include "cpactiondatacache.h" #include "cpglobals.h" @@ -28,7 +29,7 @@ _LIT8(KCachedMap, "cached_map"); -static const int KMaxCacheItems = 6; +static const int KMaxCacheItems = 18; // ======== MEMBER FUNCTIONS ======== @@ -113,6 +114,7 @@ { const CLiwMap* inputMap = param->Value().AsMap(); CLiwDefaultMap* map = CLiwDefaultMap::NewLC(); + CopyVariantL(KType, inputMap, map); CopyVariantL(KId, inputMap, map); CopyVariantL(KPublisherId, inputMap, map); CopyVariantL(KContentType, inputMap, map); @@ -132,6 +134,22 @@ // // --------------------------------------------------------------------------- // +void CCPActionDataCache::AppendEmptyL( const CLiwMap* aIdsMap ) + { + CLiwDefaultMap* map = CLiwDefaultMap::NewLC(); + CopyVariantL(KType, aIdsMap, map); + CopyVariantL(KId, aIdsMap, map); + CopyVariantL(KPublisherId, aIdsMap, map); + CopyVariantL(KContentType, aIdsMap, map); + CopyVariantL(KContentId, aIdsMap, map); + iInternalList->AppendL(TLiwVariant(map)); + CleanupStack::PopAndDestroy(map); + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// TBool CCPActionDataCache::IsCacheableL(const CLiwMap* aMap) { TBool result(EFalse); @@ -203,21 +221,23 @@ TLiwVariant l, r; l.PushL(); r.PushL(); - if (aCachedMap->FindL(KId, l) && aInputMap->FindL(KId, r) && l.AsTInt32() - == r.AsTInt32()) + if (TypesMatchL(aCachedMap,aInputMap)) { - idMatch = ETrue; - } - if (!idMatch) - { - if (MatchL(aCachedMap, aInputMap, KPublisherId) && MatchL(aCachedMap, - aInputMap, KContentType) && MatchL(aCachedMap, aInputMap, - KContentId)) + if (aCachedMap->FindL(KId, l) && aInputMap->FindL(KId, r) && l.AsTInt32() + == r.AsTInt32()) { idMatch = ETrue; } + if (!idMatch) + { + if (MatchL(aCachedMap, aInputMap, KPublisherId) && MatchL(aCachedMap, + aInputMap, KContentType) && MatchL(aCachedMap, aInputMap, + KContentId)) + { + idMatch = ETrue; + } + } } - CleanupStack::PopAndDestroy(&r); CleanupStack::PopAndDestroy(&l); return idMatch; @@ -227,6 +247,61 @@ // // --------------------------------------------------------------------------- // +TBool CCPActionDataCache::TypesMatchL(const CLiwMap* aCachedMap, + const CLiwMap* aInputMap) + { + TBool typesMatch(EFalse); + TLiwVariant cacheVariant; + TLiwVariant inputVariant; + cacheVariant.PushL(); + inputVariant.PushL(); + if (aCachedMap->FindL(KType, cacheVariant) && aInputMap->FindL(KType, + inputVariant)) + { + RBuf typeCache; + RBuf typeInput; + CleanupClosePushL(typeCache); + CleanupClosePushL(typeInput); + ExtractRBufL(cacheVariant, typeCache); + ExtractRBufL(inputVariant, typeInput); + if (typeCache.Compare(typeInput)==0) + { + typesMatch = ETrue; + } + CleanupStack::PopAndDestroy( &typeInput ); + CleanupStack::PopAndDestroy( &typeCache ); + } + CleanupStack::PopAndDestroy(&inputVariant); + CleanupStack::PopAndDestroy(&cacheVariant); + return typesMatch; + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// +void CCPActionDataCache::ExtractRBufL(const TLiwVariant& aVariant, RBuf& aBuf) + { + TPtrC type( KNullDesC ); + if( !aVariant.Get( type ) ) + { + TPtrC8 type8( KNullDesC8 ); + if( !aVariant.Get( type8 ) ) + { + User::Leave( KErrBadName ); + } + aBuf.Assign( EscapeUtils::ConvertToUnicodeFromUtf8L( type8 ) ); + } + else + { + aBuf.CreateL( type ); + } + } + +// --------------------------------------------------------------------------- +// +// --------------------------------------------------------------------------- +// TBool CCPActionDataCache::MatchL(const CLiwMap* aLeft, const CLiwMap* aRight, const TDesC8& aKey) {