mtpdataproviders/mtpimagedp/src/cmtpimagedpobjectpropertymgr.cpp
branchRCL_3
changeset 58 142dacf7b30e
parent 48 debf68073f2f
equal deleted inserted replaced
48:debf68073f2f 58:142dacf7b30e
    66     };
    66     };
    67 
    67 
    68 CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache* CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::NewL()
    68 CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache* CMTPImageDpObjectPropertyMgr::CMTPImagePropertiesCache::NewL()
    69     {
    69     {
    70     CMTPImagePropertiesCache* self = new(ELeave) CMTPImagePropertiesCache(KElements, ENumProperties);
    70     CMTPImagePropertiesCache* self = new(ELeave) CMTPImagePropertiesCache(KElements, ENumProperties);
    71     CleanupStack::PushL(self);
       
    72     self->ConstructL();
    71     self->ConstructL();
    73     CleanupStack::Pop(self);
       
    74     return self;
    72     return self;
    75     }
    73     }
    76 
    74 
    77 /**
    75 /**
    78 Destructor.
    76 Destructor.
   275         iObjectInfo->SetUint(CMTPObjectMetaData::EFormatCode, aValue);
   273         iObjectInfo->SetUint(CMTPObjectMetaData::EFormatCode, aValue);
   276         break;        
   274         break;        
   277     case EMTPObjectPropCodeProtectionStatus://this property does not supported by image dp
   275     case EMTPObjectPropCodeProtectionStatus://this property does not supported by image dp
   278         //nothing to do
   276         //nothing to do
   279         break;
   277         break;
   280     case EMTPObjectPropCodeHidden:
       
   281         {
       
   282 		__ASSERT_ALWAYS(( EMTPHidden == aValue )||( EMTPVisible == aValue ), User::Leave(KErrArgument));
       
   283         TEntry entry;
       
   284 		User::LeaveIfError(iFramework.Fs().Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), entry));
       
   285         if (( EMTPHidden == aValue ) && ( !entry.IsHidden()))
       
   286             {
       
   287             entry.iAtt &= ~KEntryAttHidden;
       
   288             entry.iAtt |= KEntryAttHidden;
       
   289             User::LeaveIfError(iFramework.Fs().SetAtt(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), entry.iAtt, ~entry.iAtt));
       
   290             }
       
   291         else if (( EMTPVisible == aValue )&&( entry.IsHidden()))
       
   292             {
       
   293             entry.iAtt &= ~KEntryAttHidden;
       
   294             User::LeaveIfError(iFramework.Fs().SetAtt(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), entry.iAtt, ~entry.iAtt));
       
   295             }
       
   296         } 
       
   297         break;
       
   298     default:
   278     default:
   299         //nothing to do
   279         //nothing to do
   300         break;
   280         break;
   301         }
   281         }
   302     __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::SetPropertyL"));
   282     __FLOG(_L8("<< CMTPImageDpObjectPropertyMgr::SetPropertyL"));
   436         else
   416         else
   437             {
   417             {
   438             aValue = EMTPProtectionNoProtection;
   418             aValue = EMTPProtectionNoProtection;
   439             }        
   419             }        
   440         }    
   420         }    
   441         break;
   421         break;    
   442     case EMTPObjectPropCodeHidden:
       
   443         {
       
   444         TInt err = iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), entry);        
       
   445         if ( err == KErrNone && entry.IsHidden())
       
   446             {
       
   447             aValue = EMTPHidden;
       
   448             }
       
   449         else
       
   450             {
       
   451             aValue = EMTPVisible;
       
   452             }        
       
   453         } 
       
   454         break;
       
   455     default:
   422     default:
   456         aValue = 0;//initialization
   423         aValue = 0;//initialization
   457         //ingore the failure if we can't get properties form MdS
   424         //ingore the failure if we can't get properties form MdS
   458         TRAP_IGNORE(GetPropertyFromMdsL(aProperty, &aValue));
   425         TRAP_IGNORE(GetPropertyFromMdsL(aProperty, &aValue));
   459         break;
   426         break;
   483         /**
   450         /**
   484          * try to query thumbnail from TNM, and then store thumbnail to cache
   451          * try to query thumbnail from TNM, and then store thumbnail to cache
   485          */
   452          */
   486         TEntry fileEntry;
   453         TEntry fileEntry;
   487         TInt err = iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), fileEntry);
   454         TInt err = iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), fileEntry);
   488         CMTPImageDpThumbnailCreator* tnc = iDataProvider.ThumbnailManager();
   455         if (err == KErrNone)
   489         if (err == KErrNone && tnc != NULL)
   456             {
   490             {
       
   491             
       
   492             if(fileEntry.FileSize() > KFileSizeMax || !alwaysCreate)
   457             if(fileEntry.FileSize() > KFileSizeMax || !alwaysCreate)
   493                 {
   458                 {
   494                 tnc->GetThumbMgr()->SetFlagsL(CThumbnailManager::EDoNotCreate);
   459                 iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDoNotCreate);
   495                 }
   460                 }
   496             else
   461             else
   497                 {
   462                 {
   498                 tnc->GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags);
   463                 iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags);
   499                 }
   464                 }
   500             
   465             
   501             /**
   466             /**
   502              * trap the leave to avoid return general error when PC get object property list
   467              * trap the leave to avoid return general error when PC get object property list
   503              */
   468              */
   504             TRAP(err, tnc->GetThumbnailL(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), iThumbnailCache.iThumbnailData, err));
   469             TRAP(err, iDataProvider.ThumbnailManager().GetThumbnailL(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), iThumbnailCache.iThumbnailData, err));
   505             if (err == KErrNone)
   470             if (err == KErrNone)
   506                 {
   471                 {
   507                 iThumbnailCache.iObjectHandle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);                        
   472                 iThumbnailCache.iObjectHandle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);                        
   508                 if (iThumbnailCache.iThumbnailData != NULL)
   473                 if (iThumbnailCache.iThumbnailData != NULL)
   509                     {
   474                     {
   514                     {
   479                     {
   515                     //trigger initiator to re-query thumbnail again if the thumbnail size of response is zero
   480                     //trigger initiator to re-query thumbnail again if the thumbnail size of response is zero
   516                     aValue = KThumbCompressedSize;
   481                     aValue = KThumbCompressedSize;
   517                     }
   482                     }
   518                 }
   483                 }
   519             }
       
   520         else
       
   521             {
       
   522             aValue = KThumbCompressedSize;
       
   523             }
   484             }
   524         }
   485         }
   525         break;       
   486         break;       
   526        
   487        
   527     case EMTPObjectPropCodeRepresentativeSampleHeight:
   488     case EMTPObjectPropCodeRepresentativeSampleHeight:
   634             /**
   595             /**
   635              * try to query thumbnail from TNM, and then store thumbnail to cache
   596              * try to query thumbnail from TNM, and then store thumbnail to cache
   636              */
   597              */
   637             TEntry fileEntry;
   598             TEntry fileEntry;
   638             TInt err = iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), fileEntry);
   599             TInt err = iFs.Entry(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), fileEntry);
   639             CMTPImageDpThumbnailCreator* tnc = iDataProvider.ThumbnailManager();
   600             if (err == KErrNone)
   640             if (err == KErrNone && tnc != NULL)
       
   641                 {
   601                 {
   642                 
   602                 
   643                 if(fileEntry.FileSize() > KFileSizeMax || !alwaysCreate)
   603                 if(fileEntry.FileSize() > KFileSizeMax || !alwaysCreate)
   644                     {
   604                     {
   645                     tnc->GetThumbMgr()->SetFlagsL(CThumbnailManager::EDoNotCreate);
   605                     iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDoNotCreate);
   646                     }
   606                     }
   647                 else
   607                 else
   648                     {
   608                     {
   649                     tnc->GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags);
   609                     iDataProvider.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags);
   650                     }
   610                     }
   651                 
   611                 
   652                 /**
   612                 /**
   653                  * 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
   654                  */
   614                  */
   655                 TRAP(err, tnc->GetThumbnailL(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), iThumbnailCache.iThumbnailData, err));
   615                 TRAP(err, iDataProvider.ThumbnailManager().GetThumbnailL(iObjectInfo->DesC(CMTPObjectMetaData::ESuid), iThumbnailCache.iThumbnailData, err));
   656                 if (err == KErrNone)
   616                 if (err == KErrNone)
   657                     {
   617                     {
   658                     iThumbnailCache.iObjectHandle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);                        
   618                     iThumbnailCache.iObjectHandle = iObjectInfo->Uint(CMTPObjectMetaData::EHandle);                        
   659                     if (iThumbnailCache.iThumbnailData != NULL)
   619                     if (iThumbnailCache.iThumbnailData != NULL)
   660                         {
   620                         {