contentpublishingsrv/contentpublishingserver/cpserver/src/cpactiondatacache.cpp
branchRCL_3
changeset 31 8baec10861af
parent 30 a5a39a295112
equal deleted inserted replaced
30:a5a39a295112 31:8baec10861af
    27 
    27 
    28 using namespace LIW;
    28 using namespace LIW;
    29 
    29 
    30 _LIT8(KCachedMap, "cached_map");
    30 _LIT8(KCachedMap, "cached_map");
    31 
    31 
    32 static const int KMaxCacheItems = 18; 
    32 static const int KMaxCacheItems = 24;
    33 
    33 
    34 
    34 
    35 // ======== MEMBER FUNCTIONS ========
    35 // ======== MEMBER FUNCTIONS ========
    36 
    36 
    37 
    37 
    38 // ---------------------------------------------------------------------------
    38 // ---------------------------------------------------------------------------
    39 // 
    39 //
    40 // ---------------------------------------------------------------------------
    40 // ---------------------------------------------------------------------------
    41 //
    41 //
    42 CCPActionDataCache* CCPActionDataCache::NewL()
    42 CCPActionDataCache* CCPActionDataCache::NewL()
    43     {
    43     {
    44     CCPActionDataCache* self = CCPActionDataCache::NewLC();
    44     CCPActionDataCache* self = CCPActionDataCache::NewLC();
    45     CleanupStack::Pop(self);
    45     CleanupStack::Pop(self);
    46     return self;
    46     return self;
    47     }
    47     }
    48 
    48 
    49 // ---------------------------------------------------------------------------
    49 // ---------------------------------------------------------------------------
    50 // 
    50 //
    51 // ---------------------------------------------------------------------------
    51 // ---------------------------------------------------------------------------
    52 //
    52 //
    53 CCPActionDataCache* CCPActionDataCache::NewLC()
    53 CCPActionDataCache* CCPActionDataCache::NewLC()
    54     {
    54     {
    55     CCPActionDataCache* self = new (ELeave) CCPActionDataCache;
    55     CCPActionDataCache* self = new (ELeave) CCPActionDataCache;
    57     self->ConstructL();
    57     self->ConstructL();
    58     return self;
    58     return self;
    59     }
    59     }
    60 
    60 
    61 // ---------------------------------------------------------------------------
    61 // ---------------------------------------------------------------------------
    62 // 
    62 //
    63 // ---------------------------------------------------------------------------
    63 // ---------------------------------------------------------------------------
    64 //
    64 //
    65 void CCPActionDataCache::ConstructL( )
    65 void CCPActionDataCache::ConstructL( )
    66     {
    66     {
    67     iInternalList = CLiwDefaultList::NewL();
    67     iInternalList = CLiwDefaultList::NewL();
    68     }
    68     }
    69 
    69 
    70 // ---------------------------------------------------------------------------
    70 // ---------------------------------------------------------------------------
    71 // 
    71 //
    72 // ---------------------------------------------------------------------------
    72 // ---------------------------------------------------------------------------
    73 //
    73 //
    74 CCPActionDataCache::CCPActionDataCache()
    74 CCPActionDataCache::CCPActionDataCache()
    75     {
    75     {
    76     }
    76     }
    77 
    77 
    78 // ---------------------------------------------------------------------------
    78 // ---------------------------------------------------------------------------
    79 // 
    79 //
    80 // ---------------------------------------------------------------------------
    80 // ---------------------------------------------------------------------------
    81 //
    81 //
    82 CCPActionDataCache::~CCPActionDataCache()
    82 CCPActionDataCache::~CCPActionDataCache()
    83     {
    83     {
    84     if (iInternalList)
    84     if (iInternalList)
    86         iInternalList->Close();
    86         iInternalList->Close();
    87         }
    87         }
    88     }
    88     }
    89 
    89 
    90 // ---------------------------------------------------------------------------
    90 // ---------------------------------------------------------------------------
    91 // 
    91 //
    92 // ---------------------------------------------------------------------------
    92 // ---------------------------------------------------------------------------
    93 //
    93 //
    94 void CCPActionDataCache::HandleCacheRemoveL(const CLiwMap* aMap)
    94 void CCPActionDataCache::HandleCacheRemoveL(const CLiwMap* aMap)
    95     {
    95     {
    96     TInt id = FindL(aMap);
    96     TInt id = FindL(aMap);
    99         iInternalList->Remove(id);
    99         iInternalList->Remove(id);
   100         }
   100         }
   101     }
   101     }
   102 
   102 
   103 // ---------------------------------------------------------------------------
   103 // ---------------------------------------------------------------------------
   104 // 
   104 //
   105 // ---------------------------------------------------------------------------
   105 // ---------------------------------------------------------------------------
   106 //
   106 //
   107 void CCPActionDataCache::AppendL( const CLiwGenericParamList* aParamList)
   107 void CCPActionDataCache::AppendL( const CLiwGenericParamList* aParamList)
   108     {
   108     {
   109     const TLiwGenericParam* param;
   109     const TLiwGenericParam* param;
   120         CopyVariantL(KContentType, inputMap, map);
   120         CopyVariantL(KContentType, inputMap, map);
   121         CopyVariantL(KContentId, inputMap, map);
   121         CopyVariantL(KContentId, inputMap, map);
   122         map->InsertL(KCachedMap, TLiwVariant(inputMap));
   122         map->InsertL(KCachedMap, TLiwVariant(inputMap));
   123         iInternalList->AppendL(TLiwVariant(map));
   123         iInternalList->AppendL(TLiwVariant(map));
   124         CleanupStack::PopAndDestroy(map);
   124         CleanupStack::PopAndDestroy(map);
   125     
   125 
   126         if (iInternalList->Count() > KMaxCacheItems)
   126         if (iInternalList->Count() > KMaxCacheItems)
   127             {
   127             {
   128             iInternalList->Remove(0);
   128             iInternalList->Remove(0);
   129             }
   129             }
   130         }
   130         }
   131     }
   131     }
   132 
   132 
   133 // ---------------------------------------------------------------------------
   133 // ---------------------------------------------------------------------------
   134 // 
   134 //
   135 // ---------------------------------------------------------------------------
   135 // ---------------------------------------------------------------------------
   136 //
   136 //
   137 void CCPActionDataCache::AppendEmptyL( const CLiwMap* aIdsMap )
   137 void CCPActionDataCache::AppendEmptyL( const CLiwMap* aIdsMap )
   138     {
   138     {
   139     CLiwDefaultMap* map = CLiwDefaultMap::NewLC();
   139     CLiwDefaultMap* map = CLiwDefaultMap::NewLC();
   145     iInternalList->AppendL(TLiwVariant(map));
   145     iInternalList->AppendL(TLiwVariant(map));
   146     CleanupStack::PopAndDestroy(map);
   146     CleanupStack::PopAndDestroy(map);
   147     }
   147     }
   148 
   148 
   149 // ---------------------------------------------------------------------------
   149 // ---------------------------------------------------------------------------
   150 // 
   150 //
   151 // ---------------------------------------------------------------------------
   151 // ---------------------------------------------------------------------------
   152 //
   152 //
   153 TBool CCPActionDataCache::IsCacheableL(const CLiwMap* aMap)
   153 TBool CCPActionDataCache::IsCacheableL(const CLiwMap* aMap)
   154     {
   154     {
   155     TBool result(EFalse);
   155     TBool result(EFalse);
   169     CleanupStack::PopAndDestroy(&value);
   169     CleanupStack::PopAndDestroy(&value);
   170     return result;
   170     return result;
   171     }
   171     }
   172 
   172 
   173 // ---------------------------------------------------------------------------
   173 // ---------------------------------------------------------------------------
   174 // 
   174 //
   175 // ---------------------------------------------------------------------------
   175 // ---------------------------------------------------------------------------
   176 //
   176 //
   177 TBool CCPActionDataCache::ExistL(const CLiwMap* aMap)
   177 TBool CCPActionDataCache::ExistL(const CLiwMap* aMap)
   178     {
   178     {
   179     TBool result(EFalse);
   179     TBool result(EFalse);
   183         }
   183         }
   184     return result;
   184     return result;
   185     }
   185     }
   186 
   186 
   187 // ---------------------------------------------------------------------------
   187 // ---------------------------------------------------------------------------
   188 // 
   188 //
   189 // ---------------------------------------------------------------------------
   189 // ---------------------------------------------------------------------------
   190 //
   190 //
   191 void CCPActionDataCache::GetL(const CLiwMap* aMap,
   191 void CCPActionDataCache::GetL(const CLiwMap* aMap,
   192         CLiwGenericParamList* aParamList)
   192         CLiwGenericParamList* aParamList)
   193     {
   193     {
   209         CleanupStack::PopAndDestroy(&value);
   209         CleanupStack::PopAndDestroy(&value);
   210         }
   210         }
   211     }
   211     }
   212 
   212 
   213 // ---------------------------------------------------------------------------
   213 // ---------------------------------------------------------------------------
   214 // 
   214 //
   215 // ---------------------------------------------------------------------------
   215 // ---------------------------------------------------------------------------
   216 //
   216 //
   217 TBool CCPActionDataCache::MatchL(const CLiwMap* aCachedMap,
   217 TBool CCPActionDataCache::MatchL(const CLiwMap* aCachedMap,
   218         const CLiwMap* aInputMap)
   218         const CLiwMap* aInputMap)
   219     {
   219     {
   242     CleanupStack::PopAndDestroy(&l);
   242     CleanupStack::PopAndDestroy(&l);
   243     return idMatch;
   243     return idMatch;
   244     }
   244     }
   245 
   245 
   246 // ---------------------------------------------------------------------------
   246 // ---------------------------------------------------------------------------
   247 // 
   247 //
   248 // ---------------------------------------------------------------------------
   248 // ---------------------------------------------------------------------------
   249 //
   249 //
   250 TBool CCPActionDataCache::TypesMatchL(const CLiwMap* aCachedMap,
   250 TBool CCPActionDataCache::TypesMatchL(const CLiwMap* aCachedMap,
   251         const CLiwMap* aInputMap)
   251         const CLiwMap* aInputMap)
   252     {
   252     {
   275     CleanupStack::PopAndDestroy(&cacheVariant);
   275     CleanupStack::PopAndDestroy(&cacheVariant);
   276     return typesMatch;
   276     return typesMatch;
   277     }
   277     }
   278 
   278 
   279 // ---------------------------------------------------------------------------
   279 // ---------------------------------------------------------------------------
   280 // 
   280 //
   281 // ---------------------------------------------------------------------------
   281 // ---------------------------------------------------------------------------
   282 //
   282 //
   283 void CCPActionDataCache::ExtractRBufL(const TLiwVariant& aVariant, RBuf& aBuf)
   283 void CCPActionDataCache::ExtractRBufL(const TLiwVariant& aVariant, RBuf& aBuf)
   284     {
   284     {
   285     TPtrC type( KNullDesC );
   285     TPtrC type( KNullDesC );
   297         aBuf.CreateL( type );
   297         aBuf.CreateL( type );
   298         }
   298         }
   299     }
   299     }
   300 
   300 
   301 // ---------------------------------------------------------------------------
   301 // ---------------------------------------------------------------------------
   302 // 
   302 //
   303 // ---------------------------------------------------------------------------
   303 // ---------------------------------------------------------------------------
   304 //
   304 //
   305 TBool CCPActionDataCache::MatchL(const CLiwMap* aLeft, const CLiwMap* aRight,
   305 TBool CCPActionDataCache::MatchL(const CLiwMap* aLeft, const CLiwMap* aRight,
   306         const TDesC8& aKey)
   306         const TDesC8& aKey)
   307     {
   307     {
   318     CleanupStack::PopAndDestroy(&l);
   318     CleanupStack::PopAndDestroy(&l);
   319     return match;
   319     return match;
   320     }
   320     }
   321 
   321 
   322 // ---------------------------------------------------------------------------
   322 // ---------------------------------------------------------------------------
   323 // 
   323 //
   324 // ---------------------------------------------------------------------------
   324 // ---------------------------------------------------------------------------
   325 //
   325 //
   326 TBool CCPActionDataCache::IsSpecifiedL(const CLiwMap* aMap,
   326 TBool CCPActionDataCache::IsSpecifiedL(const CLiwMap* aMap,
   327         const TDesC8& aKey)
   327         const TDesC8& aKey)
   328     {
   328     {
   337     CleanupStack::PopAndDestroy(&value);
   337     CleanupStack::PopAndDestroy(&value);
   338     return result;
   338     return result;
   339     }
   339     }
   340 
   340 
   341 // ---------------------------------------------------------------------------
   341 // ---------------------------------------------------------------------------
   342 // 
   342 //
   343 // ---------------------------------------------------------------------------
   343 // ---------------------------------------------------------------------------
   344 //
   344 //
   345 TInt CCPActionDataCache::FindL(const CLiwMap* aKey)
   345 TInt CCPActionDataCache::FindL(const CLiwMap* aKey)
   346     {
   346     {
   347     TInt result(KErrNotFound);
   347     TInt result(KErrNotFound);