mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp
changeset 29 3ae5cb0b4c02
parent 20 6e82ae192c3a
child 37 d9d8313203af
equal deleted inserted replaced
20:6e82ae192c3a 29:3ae5cb0b4c02
    49 #include "mtpdebug.h"
    49 #include "mtpdebug.h"
    50 
    50 
    51 // Class constants.
    51 // Class constants.
    52 __FLOG_STMT(_LIT8(KComponent,"MTPImageDpPropertyMgr");)
    52 __FLOG_STMT(_LIT8(KComponent,"MTPImageDpPropertyMgr");)
    53 
    53 
       
    54 // Indicate how many cache can be stored
       
    55 const TUint KCacheThreshold = 16;
       
    56 
    54 /**
    57 /**
    55 The properties cache table content.
    58 The properties cache table content.
    56 */
    59 */
    57 const CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::TElementMetaData CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::KElements[CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::ENumProperties] = 
    60 const CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::TElementMetaData CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::KElements[CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::ENumProperties] = 
    58     {
    61     {
   110             //nothing to do
   113             //nothing to do
   111             __DEBUG_ONLY(User::Invariant());
   114             __DEBUG_ONLY(User::Invariant());
   112             break;
   115             break;
   113             }         
   116             }         
   114         }
   117         }
   115     
       
   116     iObjectHandle = KMTPHandleNone;   
       
   117     }
   118     }
   118 
   119 
   119 void CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::ResetL()
   120 void CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::ResetL()
   120     {
   121     {
   121     iObjectHandle = KMTPHandleNone;
       
   122     SetUint(EImagePixWidth, 0);
   122     SetUint(EImagePixWidth, 0);
   123     SetUint(EImagePixHeight, 0);
   123     SetUint(EImagePixHeight, 0);
   124     SetUint(EImageBitDepth, 0);
   124     SetUint(EImageBitDepth, 0);
   125     SetDesCL(EDateCreated, KNullDesC);
   125     SetDesCL(EDateCreated, KNullDesC);
   126     }
   126     }
   133 
   133 
   134 TUint CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::Uint(TUint aId) const
   134 TUint CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::Uint(TUint aId) const
   135     {
   135     {
   136     __ASSERT_DEBUG((iElements[aId].iType == EUint), Panic(EMTPImageDpTypeMismatch));
   136     __ASSERT_DEBUG((iElements[aId].iType == EUint), Panic(EMTPImageDpTypeMismatch));
   137     return iElementsUint[iElements[aId].iOffset];
   137     return iElementsUint[iElements[aId].iOffset];
   138     }
       
   139 
       
   140 TUint CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::ObjectHandle() const
       
   141     {
       
   142     return iObjectHandle;
       
   143     }
   138     }
   144 
   139 
   145 void CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::SetDesCL(TUint aId, const TDesC& aValue)
   140 void CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::SetDesCL(TUint aId, const TDesC& aValue)
   146     {
   141     {
   147     const TElementMetaData& KElement(iElements[aId]);
   142     const TElementMetaData& KElement(iElements[aId]);
   155     {
   150     {
   156     __ASSERT_DEBUG((iElements[aId].iType == EUint), Panic(EMTPImageDpTypeMismatch));
   151     __ASSERT_DEBUG((iElements[aId].iType == EUint), Panic(EMTPImageDpTypeMismatch));
   157     iElementsUint[iElements[aId].iOffset] = aValue;
   152     iElementsUint[iElements[aId].iOffset] = aValue;
   158     }
   153     }
   159 
   154 
   160 void CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::SetObjectHandle(TUint aObjectHandle)
       
   161     {
       
   162     iObjectHandle = aObjectHandle;
       
   163     }
       
   164 
       
   165 CMTPImageDpObjectPropertyMgr* CMTPImageDpObjectPropertyMgr::NewL(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider)
   155 CMTPImageDpObjectPropertyMgr* CMTPImageDpObjectPropertyMgr::NewL(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider)
   166     {
   156     {
   167     CMTPImageDpObjectPropertyMgr* self = new (ELeave) CMTPImageDpObjectPropertyMgr(aFramework, aDataProvider);
   157     CMTPImageDpObjectPropertyMgr* self = new (ELeave) CMTPImageDpObjectPropertyMgr(aFramework, aDataProvider);
   168     CleanupStack::PushL(self);
   158     CleanupStack::PushL(self);
   169     self->ConstructL(aFramework);
   159     self->ConstructL(aFramework);
   173 
   163 
   174 CMTPImageDpObjectPropertyMgr::CMTPImageDpObjectPropertyMgr(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider) :
   164 CMTPImageDpObjectPropertyMgr::CMTPImageDpObjectPropertyMgr(MMTPDataProviderFramework& aFramework, CMTPImageDataProvider& aDataProvider) :
   175     iFramework(aFramework),
   165     iFramework(aFramework),
   176     iDataProvider(aDataProvider),
   166     iDataProvider(aDataProvider),
   177     iFs(aFramework.Fs()),
   167     iFs(aFramework.Fs()),
   178     iObjectMgr(aFramework.ObjectMgr())
   168     iObjectMgr(aFramework.ObjectMgr())    
   179     {
   169     {
   180     __FLOG_OPEN(KMTPSubsystem, KComponent);
   170     __FLOG_OPEN(KMTPSubsystem, KComponent);
   181     }
   171     }
   182 
   172 
   183 void CMTPImageDpObjectPropertyMgr::ConstructL(MMTPDataProviderFramework& /*aFramework*/)
   173 void CMTPImageDpObjectPropertyMgr::ConstructL(MMTPDataProviderFramework& /*aFramework*/)
   184     {
   174     {
   185     __FLOG(_L8("CMTPImageDpObjectPropertyMgr::ConstructL - Entry"));
   175     __FLOG(_L8("CMTPImageDpObjectPropertyMgr::ConstructL - Entry"));
   186     iPropertiesCache = CMTPImagePropertiesCache::NewL();    
       
   187     iMetaDataSession = CMdESession::NewL(*this);
   176     iMetaDataSession = CMdESession::NewL(*this);
   188     __FLOG(_L8("CMTPImageDpObjectPropertyMgr::ConstructL - Exit"));
   177     __FLOG(_L8("CMTPImageDpObjectPropertyMgr::ConstructL - Exit"));
   189     }
   178     }
   190     
   179     
   191 CMTPImageDpObjectPropertyMgr::~CMTPImageDpObjectPropertyMgr()
   180 CMTPImageDpObjectPropertyMgr::~CMTPImageDpObjectPropertyMgr()
   192     {
   181     {
   193     __FLOG(_L8("CMTPImageDpObjectPropertyMgr::~CMTPImageDpObjectPropertyMgr - Entry"));
   182     __FLOG(_L8("CMTPImageDpObjectPropertyMgr::~CMTPImageDpObjectPropertyMgr - Entry"));
   194     delete iPropertiesCache;
       
   195     delete iObject;
   183     delete iObject;
   196     delete iMetaDataSession;
   184     delete iMetaDataSession;
   197     delete iThumbnailCache.iThumbnailData;
   185     delete iThumbnailCache.iThumbnailData;
       
   186     
       
   187     //Clear propreties cache map
       
   188     ClearAllCache();
       
   189     iPropretiesCacheMap.Close();
   198     __FLOG(_L8("CMTPImageDpObjectPropertyMgr::~CMTPImageDpObjectPropertyMgr - Exit"));
   190     __FLOG(_L8("CMTPImageDpObjectPropertyMgr::~CMTPImageDpObjectPropertyMgr - Exit"));
   199     __FLOG_CLOSE;
   191     __FLOG_CLOSE;
   200     }
   192     }
   201 
   193 
   202 void CMTPImageDpObjectPropertyMgr::SetCurrentObjectL(CMTPObjectMetaData& aObjectInfo, TBool aRequireForModify, TBool aSaveToCache)
   194 void CMTPImageDpObjectPropertyMgr::SetCurrentObjectL(CMTPObjectMetaData& aObjectInfo, TBool aRequireForModify, TBool aSaveToCache)
   210     if(!aRequireForModify)
   202     if(!aRequireForModify)
   211         {
   203         {
   212         /**
   204         /**
   213          * determine whether the cache hit is occured
   205          * determine whether the cache hit is occured
   214          */
   206          */
   215         if (iPropertiesCache->ObjectHandle() == iObjectInfo->Uint(CMTPObjectMetaData::EHandle))
   207         iCacheHit = FindPropertiesCache(iObjectInfo->Uint(CMTPObjectMetaData::EHandle));
   216             {
   208         if (!iCacheHit)
   217             iCacheHit = ETrue;
   209             {
   218             }
       
   219         else
       
   220             {            
       
   221             iCacheHit = EFalse;
       
   222 
       
   223             /**
       
   224              * if cache miss, we should clear the cache content
       
   225              */
       
   226             ClearCacheL();
       
   227             
       
   228 			//need parse image file by our self if fail to get properties from MdS
       
   229             iNeedParse = ETrue;
       
   230 
       
   231 			//clear previous Mde object
       
   232             delete iObject;
   210             delete iObject;
   233             iObject = NULL;            
   211             iObject = NULL; 
   234             }        
   212             }          
   235         }    
   213         }    
   236     else
   214     else
   237         {        
   215         {        
   238         /**
   216         /**
   239          * Set image object properties, because the cached properties are all readonly,
   217          * Set image object properties, because the cached properties are all readonly,
   240          * so only sendobjectproplist/sendobjectinfo operations can use cache mechanism, 
   218          * so only sendobjectproplist/sendobjectinfo operations can use cache mechanism, 
   241          * other operations will not use cache, such as setobjectvalue/setobjectproplist
   219          * other operations will not use cache, such as setobjectvalue/setobjectproplist
   242          */
   220          */
   243         if (aSaveToCache)
   221         if (aSaveToCache)
   244             {
   222             {            
   245             TUint objectHandle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);
   223             TUint objectHandle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);
   246             if (iPropertiesCache->ObjectHandle() != objectHandle)
   224             if (FindPropertiesCache(objectHandle))
   247                 {
   225                 {
   248                 iPropertiesCache->ResetL();
   226                 __FLOG_VA((_L16("SetCurrentObjectL - find object in cache:%u"), objectHandle));
   249                 }
   227                 iCurrentPropertiesCache->ResetL();
   250             iPropertiesCache->SetObjectHandle(objectHandle);            
   228                 }
       
   229             else
       
   230                 {
       
   231                 if (iPropretiesCacheMap.Count() > KCacheThreshold)
       
   232                     {
       
   233                     // Find the first object handle from cache map and then destory it
       
   234                     RHashMap<TUint, CMTPImagePropertiesCache*>::TIter iter(iPropretiesCacheMap);
       
   235                     DestroyPropertiesCahce(*iter.NextKey());
       
   236                     __FLOG_VA((_L16("SetCurrentObjectL - destory object:%u"), objectHandle));
       
   237                     }                
       
   238                 
       
   239                 iCurrentPropertiesCache = CMTPImagePropertiesCache::NewL();
       
   240                 iPropretiesCacheMap.Insert(objectHandle, iCurrentPropertiesCache);
       
   241                 __FLOG_VA((_L16("SetCurrentObjectL - create new object:%u"), objectHandle));
       
   242                 }
   251             }
   243             }
   252         }
   244         }
   253     
   245     
   254     __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::SetCurrentObjectL"));
   246     __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::SetCurrentObjectL"));
   255     }
   247     }
   302         break;
   294         break;
   303     case EMTPObjectPropCodeParentObject:
   295     case EMTPObjectPropCodeParentObject:
   304         iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, aValue);
   296         iObjectInfo->SetUint(CMTPObjectMetaData::EParentHandle, aValue);
   305         break;
   297         break;
   306     case EMTPObjectPropCodeWidth:
   298     case EMTPObjectPropCodeWidth:
   307         iPropertiesCache->SetUint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImagePixWidth, aValue);
   299         if (iCurrentPropertiesCache != NULL)
       
   300             {
       
   301             iCurrentPropertiesCache->SetUint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImagePixWidth, aValue);
       
   302             }
   308         break;
   303         break;
   309     case EMTPObjectPropCodeHeight:
   304     case EMTPObjectPropCodeHeight:
   310         iPropertiesCache->SetUint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImagePixHeight, aValue);
   305         if (iCurrentPropertiesCache != NULL)
       
   306             {        
       
   307             iCurrentPropertiesCache->SetUint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImagePixHeight, aValue);
       
   308             }
   311         break; 
   309         break; 
   312     case EMTPObjectPropCodeImageBitDepth:
   310     case EMTPObjectPropCodeImageBitDepth:
   313         iPropertiesCache->SetUint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImageBitDepth, aValue);
   311         if (iCurrentPropertiesCache != NULL)
       
   312             {        
       
   313             iCurrentPropertiesCache->SetUint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImageBitDepth, aValue);
       
   314             }
   314         break;          
   315         break;          
   315     default:
   316     default:
   316         //nothing to do
   317         //nothing to do
   317         break;
   318         break;
   318         }
   319         }
   361         iFs.SetModified(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), modifiedTime);            
   362         iFs.SetModified(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), modifiedTime);            
   362         }
   363         }
   363         break;
   364         break;
   364       
   365       
   365     case EMTPObjectPropCodeDateCreated://MdS property
   366     case EMTPObjectPropCodeDateCreated://MdS property
   366         iPropertiesCache->SetDesCL(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EDateCreated, aValue);
   367         if (iCurrentPropertiesCache != NULL)
       
   368             {
       
   369             iCurrentPropertiesCache->SetDesCL(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EDateCreated, aValue);
       
   370             }
   367         break;
   371         break;
   368         
   372         
   369     default:
   373     default:
   370         //nothing to do
   374         //nothing to do
   371         break;
   375         break;
   401         break;
   405         break;
   402     case EMTPObjectPropCodeRepresentativeSampleFormat:
   406     case EMTPObjectPropCodeRepresentativeSampleFormat:
   403         aValue = KThumbFormatCode;
   407         aValue = KThumbFormatCode;
   404        break;        
   408        break;        
   405     case EMTPObjectPropCodeProtectionStatus:
   409     case EMTPObjectPropCodeProtectionStatus:
   406         iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), entry);
   410         {
   407         if (entry.IsReadOnly())
   411         TInt err = iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), entry);        
       
   412         if ( err == KErrNone && entry.IsReadOnly())
   408             {
   413             {
   409             aValue = EMTPProtectionReadOnly;
   414             aValue = EMTPProtectionReadOnly;
   410             }
   415             }
   411         else
   416         else
   412             {
   417             {
   413             aValue = EMTPProtectionNoProtection;
   418             aValue = EMTPProtectionNoProtection;
   414             }
   419             }        
   415         break;        
   420         }    
       
   421         break;    
   416     default:
   422     default:
   417         aValue = 0;//initialization
   423         aValue = 0;//initialization
   418         //ingore the failure if we can't get properties form MdS
   424         //ingore the failure if we can't get properties form MdS
   419         TRAP_IGNORE(GetPropertyFromMdsL(aProperty, &aValue));
   425         TRAP_IGNORE(GetPropertyFromMdsL(aProperty, &aValue));
   420         break;
   426         break;
   435         
   441         
   436     case EMTPObjectPropCodeParentObject:
   442     case EMTPObjectPropCodeParentObject:
   437         aValue = iObjectInfo->Uint(CMTPObjectMetaData::EParentHandle);
   443         aValue = iObjectInfo->Uint(CMTPObjectMetaData::EParentHandle);
   438         break;        
   444         break;        
   439        
   445        
   440     case EMTPObjectPropCodeRepresentativeSampleSize: 
   446     case EMTPObjectPropCodeRepresentativeSampleSize:
   441         aValue = MTPImageDpUtilits::GetThumbnailSize(*iObjectInfo);
   447         {
   442         if (aValue == 0)
   448         __FLOG_VA((_L16("Query smaple size from MdS - URI:%S"), &iObjectInfo->DesC(CMTPObjectMetaData::ESuid)));
   443             {
   449         ClearThumnailCache();                                
   444             __FLOG_VA((_L16("Query smaple size from MdS - URI:%S"), &iObjectInfo->DesC(CMTPObjectMetaData::ESuid)));
   450         /**
   445             ClearThumnailCache();                                
   451          * try to query thumbnail from TNM, and then store thumbnail to cache
       
   452          */
       
   453         TEntry fileEntry;
       
   454         TInt err = iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), fileEntry);
       
   455         if (err == KErrNone)
       
   456             {
       
   457             if(fileEntry.FileSize() > KFileSizeMax || !alwaysCreate)
       
   458                 {
       
   459                 iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDoNotCreate);
       
   460                 }
       
   461             else
       
   462                 {
       
   463                 iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags);
       
   464                 }
       
   465             
   446             /**
   466             /**
   447              * try to query thumbnail from TNM, and then store thumbnail to cache
   467              * trap the leave to avoid return general error when PC get object property list
   448              */
   468              */
   449             TEntry fileEntry;
   469             TRAP(err, iDataProvider.ThumbnailManager().GetThumbnailL(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), iThumbnailCache.iThumbnailData, err));
   450             TInt err = iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), fileEntry);
       
   451             if (err == KErrNone)
   470             if (err == KErrNone)
   452                 {
   471                 {
   453                 if(fileEntry.FileSize() > KFileSizeMax || !alwaysCreate)
   472                 iThumbnailCache.iObjectHandle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);                        
   454                     {
   473                 if (iThumbnailCache.iThumbnailData != NULL)
   455                     iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDoNotCreate);
   474                     {
       
   475                     aValue = static_cast<TUint32>(iThumbnailCache.iThumbnailData->Size());
   456                     }
   476                     }
   457                 else
   477                                             
   458                     {
   478                 if (aValue <= 0)
   459                     iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags);
   479                     {
       
   480                     //trigger initiator to re-query thumbnail again if the thumbnail size of response is zero
       
   481                     aValue = KThumbCompressedSize;
   460                     }
   482                     }
   461                 
   483                 }
   462                 /**
   484             }
   463                  * trap the leave to avoid return general error when PC get object property list
   485         }
   464                  */
       
   465                 TRAP(err, iDataProvider.ThumbnailManager().GetThumbnailL(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), iThumbnailCache.iThumbnailData, err));
       
   466                 if (err == KErrNone)
       
   467                     {
       
   468                     iThumbnailCache.iObjectHandle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);                        
       
   469                     if (iThumbnailCache.iThumbnailData != NULL)
       
   470                         {
       
   471                         aValue = static_cast<TUint32>(iThumbnailCache.iThumbnailData->Size());
       
   472                         }
       
   473                                                 
       
   474                     if (aValue > 0)
       
   475                         {
       
   476                         //update metadata column
       
   477                         MTPImageDpUtilits::UpdateObjectThumbnailSizeL(iFramework, *iObjectInfo, aValue);
       
   478                         }
       
   479                     else
       
   480                         {
       
   481                         //trigger initiator to re-query thumbnail again if the thumbnail size of response is zero
       
   482                         aValue = KThumbCompressedSize;
       
   483                         }
       
   484 
       
   485                     __FLOG_VA((_L16("Cache miss:GetThumbnailSize - URI:%S, Size:%u"), &iObjectInfo->DesC(CMTPObjectMetaData::ESuid), aValue));
       
   486                     }
       
   487                 }
       
   488             }	    
       
   489         break;       
   486         break;       
   490        
   487        
   491     case EMTPObjectPropCodeRepresentativeSampleHeight:
   488     case EMTPObjectPropCodeRepresentativeSampleHeight:
   492         aValue = KThumbHeigth;
   489         aValue = KThumbHeigth;
   493         break;
   490         break;
   616                  * trap the leave to avoid return general error when PC get object property list
   613                  * trap the leave to avoid return general error when PC get object property list
   617                  */
   614                  */
   618                 TRAP(err, iDataProvider.ThumbnailManager().GetThumbnailL(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), iThumbnailCache.iThumbnailData, err));
   615                 TRAP(err, iDataProvider.ThumbnailManager().GetThumbnailL(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), iThumbnailCache.iThumbnailData, err));
   619                 if (err == KErrNone)
   616                 if (err == KErrNone)
   620                     {
   617                     {
   621                     TInt size = MTPImageDpUtilits::GetThumbnailSize(*iObjectInfo);
       
   622                     iThumbnailCache.iObjectHandle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);                        
   618                     iThumbnailCache.iObjectHandle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);                        
   623                     if (iThumbnailCache.iThumbnailData != NULL)
   619                     if (iThumbnailCache.iThumbnailData != NULL)
   624                         {
   620                         {
   625                         aValue.SetByDesL(*iThumbnailCache.iThumbnailData);
   621                         aValue.SetByDesL(*iThumbnailCache.iThumbnailData);
   626                         if (size == 0)
       
   627                             {
       
   628                             //update metadata column
       
   629                             MTPImageDpUtilits::UpdateObjectThumbnailSizeL(iFramework, *iObjectInfo, iThumbnailCache.iThumbnailData->Size());
       
   630                             __FLOG_VA((_L16("Cache miss:GetThumbnailSize - URI:%S, Size:%u"), &iObjectInfo->DesC(CMTPObjectMetaData::ESuid), size));
       
   631                             }
       
   632                         }                                
   622                         }                                
   633                     }
   623                     }
   634                 }
   624                 }
   635             }
   625             }
   636         }
   626         }
   652          * The object hit the cache, so we query properties from cache
   642          * The object hit the cache, so we query properties from cache
   653          */
   643          */
   654         switch (aProperty)
   644         switch (aProperty)
   655             {
   645             {
   656         case EMTPObjectPropCodeDateCreated:
   646         case EMTPObjectPropCodeDateCreated:
   657             (*(static_cast<CMTPTypeString*>(aValue))).SetL(iPropertiesCache->DesC(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EDateCreated));            
   647             (*(static_cast<CMTPTypeString*>(aValue))).SetL(iCurrentPropertiesCache->DesC(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EDateCreated));            
   658             break;
   648             break;
   659           
   649           
   660         case EMTPObjectPropCodeWidth:
   650         case EMTPObjectPropCodeWidth:
   661             *static_cast<TUint32*>(aValue) = iPropertiesCache->Uint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImagePixWidth);            
   651             *static_cast<TUint32*>(aValue) = iCurrentPropertiesCache->Uint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImagePixWidth);            
   662             break;
   652             break;
   663             
   653             
   664         case EMTPObjectPropCodeHeight:
   654         case EMTPObjectPropCodeHeight:
   665             *static_cast<TUint32*>(aValue) = iPropertiesCache->Uint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImagePixHeight);           
   655             *static_cast<TUint32*>(aValue) = iCurrentPropertiesCache->Uint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImagePixHeight);           
   666             break;
   656             break;
   667             
   657             
   668         case EMTPObjectPropCodeImageBitDepth:
   658         case EMTPObjectPropCodeImageBitDepth:
   669             *static_cast<TUint32*>(aValue) = iPropertiesCache->Uint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImageBitDepth);            
   659             *static_cast<TUint32*>(aValue) = iCurrentPropertiesCache->Uint(CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::EImageBitDepth);            
   670             break;
   660             break;
   671             
   661             
   672         default:
   662         default:
   673             //nothing to do
   663             //nothing to do
   674             break;
   664             break;
   970 void CMTPImageDpObjectPropertyMgr::SetMdeSessionError(TInt aError)
   960 void CMTPImageDpObjectPropertyMgr::SetMdeSessionError(TInt aError)
   971     {
   961     {
   972     iMdeSessionError = aError;
   962     iMdeSessionError = aError;
   973     }
   963     }
   974 
   964 
   975 void CMTPImageDpObjectPropertyMgr::ClearCacheL()
   965 void CMTPImageDpObjectPropertyMgr::ClearAllCache()
   976     {
   966     {
   977     iPropertiesCache->ResetL();
   967     while (iPropretiesCacheMap.Count())
       
   968         {
       
   969         RHashMap<TUint, CMTPImagePropertiesCache*>::TIter iter(iPropretiesCacheMap);
       
   970         DestroyPropertiesCahce(*iter.NextKey());
       
   971         };
       
   972     }
       
   973 
       
   974 void CMTPImageDpObjectPropertyMgr::ClearCache(TUint aHandle)
       
   975     {
       
   976     DestroyPropertiesCahce(aHandle);    
   978     }
   977     }
   979 
   978 
   980 void CMTPImageDpObjectPropertyMgr::OpenMdeObjectL()
   979 void CMTPImageDpObjectPropertyMgr::OpenMdeObjectL()
   981     {
   980     {
   982     if (iObject == NULL)
   981     if (iObject == NULL)
   998     delete iThumbnailCache.iThumbnailData;
   997     delete iThumbnailCache.iThumbnailData;
   999     iThumbnailCache.iThumbnailData = NULL;
   998     iThumbnailCache.iThumbnailData = NULL;
  1000     
   999     
  1001     iThumbnailCache.iObjectHandle = KMTPHandleNone;
  1000     iThumbnailCache.iObjectHandle = KMTPHandleNone;
  1002     }
  1001     }
       
  1002 
       
  1003 TBool CMTPImageDpObjectPropertyMgr::FindPropertiesCache(TUint aObjectHandle)
       
  1004     {
       
  1005     TBool ret = EFalse;
       
  1006     CMTPImagePropertiesCache** ppCache = iPropretiesCacheMap.Find(aObjectHandle);
       
  1007     if (ppCache)
       
  1008         {
       
  1009         iCurrentPropertiesCache = *ppCache;
       
  1010         ret = (iCurrentPropertiesCache != NULL) ? ETrue : EFalse;
       
  1011         }
       
  1012     else
       
  1013         {
       
  1014         iCurrentPropertiesCache = NULL;
       
  1015         ret = EFalse;
       
  1016         }
       
  1017     
       
  1018     return ret;
       
  1019     }
       
  1020 
       
  1021 void CMTPImageDpObjectPropertyMgr::DestroyPropertiesCahce(TUint aObjectHandle)
       
  1022     {
       
  1023     CMTPImagePropertiesCache** ppCache = iPropretiesCacheMap.Find(aObjectHandle);  
       
  1024     if (ppCache)
       
  1025         {
       
  1026         CMTPImagePropertiesCache* pCache = *ppCache;
       
  1027         delete pCache;
       
  1028         iPropretiesCacheMap.Remove(aObjectHandle);
       
  1029         }    
       
  1030     }