mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp
branchRCL_3
changeset 58 142dacf7b30e
parent 45 74aa6861c87d
equal deleted inserted replaced
48:debf68073f2f 58:142dacf7b30e
    94 */
    94 */
    95 void CMTPImageDataProvider::ConstructL()
    95 void CMTPImageDataProvider::ConstructL()
    96     {
    96     {
    97     __FLOG_OPEN(KMTPSubsystem, KComponent);
    97     __FLOG_OPEN(KMTPSubsystem, KComponent);
    98     __FLOG(_L8(">> CMTPImageDataProvider::ConstructL"));
    98     __FLOG(_L8(">> CMTPImageDataProvider::ConstructL"));
       
    99     
       
   100     iThumbnailManager = CMTPImageDpThumbnailCreator::NewL(*this);
    99     iNewPicNotifier = CMTPImageDpNewPicturesNotifier::NewL();
   101     iNewPicNotifier = CMTPImageDpNewPicturesNotifier::NewL();
   100     
   102     
   101     //Setup central repository connection
   103     //Setup central repository connection
   102     const TUint32 KUidMTPImageRepositoryValue(0x2001FCA2);
   104     const TUint32 KUidMTPImageRepositoryValue(0x2001FCA2);
   103     const TUid KUidMTPImageRepository = {KUidMTPImageRepositoryValue};
   105     const TUid KUidMTPImageRepository = {KUidMTPImageRepositoryValue};
   116         {
   118         {
   117         iMimeMappings.Insert(KMTPExtensionMimeTypeMappings[i].iExtension, KMTPExtensionMimeTypeMappings[i].iMimeType);
   119         iMimeMappings.Insert(KMTPExtensionMimeTypeMappings[i].iExtension, KMTPExtensionMimeTypeMappings[i].iMimeType);
   118         }     
   120         }     
   119     
   121     
   120     //Define RProperty of new pictures for status data provider
   122     //Define RProperty of new pictures for status data provider
   121 	RProcess process;
       
   122 	TUid tSid = process.SecureId();
       
   123     _LIT_SECURITY_POLICY_PASS(KAllowReadAll);
   123     _LIT_SECURITY_POLICY_PASS(KAllowReadAll);
   124     TInt error = RProperty::Define(tSid, KMTPNewPicKey, RProperty::EInt, KAllowReadAll, KAllowReadAll);
   124     TInt error = RProperty::Define(TUid::Uid(KMTPServerUID), KMTPNewPicKey, RProperty::EInt, KAllowReadAll, KAllowReadAll);
   125     if (error != KErrNone && error != KErrAlreadyExists)
   125     if (error != KErrNone && error != KErrAlreadyExists)
   126         {
   126         {
   127         __FLOG_1(_L8("CMTPImageDataProvider::ConstructL - RProperty define error:%d"), error);
   127         __FLOG_1(_L8("CMTPImageDataProvider::ConstructL - RProperty define error:%d"), error);
   128         User::LeaveIfError(error);
   128         User::LeaveIfError(error);
   129         }    
   129         }    
   163     iMimeMappings.Close();
   163     iMimeMappings.Close();
   164     
   164     
   165     //Try to delete objects in array
   165     //Try to delete objects in array
   166     HandleDeleteObjectsArray();
   166     HandleDeleteObjectsArray();
   167     iDeleteObjectsArray.ResetAndDestroy();
   167     iDeleteObjectsArray.ResetAndDestroy();
   168     iNewPicHandles.Reset();
       
   169     
   168     
   170     __FLOG(_L8("<< ~CMTPImageDataProvider"));
   169     __FLOG(_L8("<< ~CMTPImageDataProvider"));
   171     __FLOG_CLOSE;
   170     __FLOG_CLOSE;
   172     }
   171     }
   173 
   172 
   450     __FLOG(_L8(">> NotifyStorageEnumerationCompleteL"));    
   449     __FLOG(_L8(">> NotifyStorageEnumerationCompleteL"));    
   451     Framework().StorageEnumerationCompleteL();    
   450     Framework().StorageEnumerationCompleteL();    
   452     __FLOG(_L8("<< NotifyStorageEnumerationCompleteL"));        
   451     __FLOG(_L8("<< NotifyStorageEnumerationCompleteL"));        
   453     }
   452     }
   454 
   453 
   455 CMTPImageDpThumbnailCreator* CMTPImageDataProvider::ThumbnailManager()
   454 CMTPImageDpThumbnailCreator& CMTPImageDataProvider::ThumbnailManager() const
   456     {
   455 	{
   457     if(NULL == iThumbnailManager)
   456     __ASSERT_DEBUG(iThumbnailManager, User::Invariant());
   458         {
   457 	return *iThumbnailManager;
   459         TRAP_IGNORE(iThumbnailManager = CMTPImageDpThumbnailCreator::NewL(*this));
   458 	}
   460         }
       
   461     return iThumbnailManager;
       
   462     }
       
   463 
   459 
   464 CMTPImageDpObjectPropertyMgr& CMTPImageDataProvider::PropertyMgr()const
   460 CMTPImageDpObjectPropertyMgr& CMTPImageDataProvider::PropertyMgr()const
   465 	{
   461 	{
   466 	__ASSERT_DEBUG(iPropertyMgr, User::Invariant());
   462 	__ASSERT_DEBUG(iPropertyMgr, User::Invariant());
   467 	return *iPropertyMgr;	
   463 	return *iPropertyMgr;	
   612     if (iEnumerated)
   608     if (iEnumerated)
   613         {
   609         {
   614         /**
   610         /**
   615          * Get image object count from framework and calculate the new pictures
   611          * Get image object count from framework and calculate the new pictures
   616          */
   612          */
   617         TUint newPictures = QueryImageObjectCountL();        
   613         TUint newPictures = QueryImageObjectCountL();
       
   614         RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, newPictures);
   618         iNewPicNotifier->SetNewPictures(newPictures);
   615         iNewPicNotifier->SetNewPictures(newPictures);
   619         __FLOG_1(_L16("CMTPImageDpEnumerator::CompleteEnumeration - New Pics: %d"), newPictures);        
   616         __FLOG_1(_L16("CMTPImageDpEnumerator::CompleteEnumeration - New Pics: %d"), newPictures);        
   620         iEnumerated = EFalse;
   617         iEnumerated = EFalse;
   621         }
   618         }
   622     
   619     
   694     RArray<TUint>               handles;
   691     RArray<TUint>               handles;
   695     TMTPObjectMgrQueryParams    params(KMTPStorageAll, KMTPFormatsAll, KMTPHandleNone, Framework().DataProviderId());
   692     TMTPObjectMgrQueryParams    params(KMTPStorageAll, KMTPFormatsAll, KMTPHandleNone, Framework().DataProviderId());
   696     CleanupClosePushL(context);
   693     CleanupClosePushL(context);
   697     CleanupClosePushL(handles);    
   694     CleanupClosePushL(handles);    
   698     
   695     
   699     iNewPicHandles.Reset();
       
   700     
       
   701     do
   696     do
   702         {
   697         {
   703         /*
   698         /*
   704          * Speed up query performance, avoid to duplicated copy object handle between RArrays
   699          * Speed up query performance, avoid to duplicated copy object handle between RArrays
   705          */
   700          */
   715         {
   710         {
   716         Framework().ObjectMgr().ObjectL(handles[i], *objMetadata);
   711         Framework().ObjectMgr().ObjectL(handles[i], *objMetadata);
   717         if (MTPImageDpUtilits::IsNewPicture(*objMetadata))
   712         if (MTPImageDpUtilits::IsNewPicture(*objMetadata))
   718             {
   713             {
   719             ++newPictures;
   714             ++newPictures;
   720             iNewPicHandles.Append(handles[i]);
       
   721             }
   715             }
   722         }
   716         }
   723     
   717     
   724     
   718     
   725     CleanupStack::PopAndDestroy(objMetadata);
   719     CleanupStack::PopAndDestroy(objMetadata);
   769     iNewPicNotifier->DecreaseCount(aCount);
   763     iNewPicNotifier->DecreaseCount(aCount);
   770     
   764     
   771     __FLOG(_L8("<< DecreaseNewPictures "));    
   765     __FLOG(_L8("<< DecreaseNewPictures "));    
   772     }
   766     }
   773 
   767 
   774 void CMTPImageDataProvider::ResetNewPictures()
       
   775 	{
       
   776 	__FLOG(_L8(">> ResetNewPictures "));
       
   777 
       
   778 	iNewPicNotifier->SetNewPictures(0);
       
   779 	
       
   780 	TInt count = iNewPicHandles.Count();
       
   781 	if (!count)
       
   782 		{
       
   783 		return;
       
   784 		}
       
   785 
       
   786 	CMTPObjectMetaData* objMetadata = CMTPObjectMetaData::NewLC();
       
   787 	
       
   788 	for (TInt i(0); i<count; ++i)
       
   789 	{
       
   790 		Framework().ObjectMgr().ObjectL(iNewPicHandles[i], *objMetadata);
       
   791 		MTPImageDpUtilits::UpdateObjectStatusToOldL(Framework(), *objMetadata);
       
   792 	}
       
   793 	
       
   794 	iNewPicHandles.Reset();
       
   795 	CleanupStack::PopAndDestroy(objMetadata);
       
   796 	
       
   797 	__FLOG(_L8("<< ResetNewPictures "));
       
   798 	}
       
   799 
       
   800 void CMTPImageDataProvider::HandleMdeSessionCompleteL(TInt aError)
   768 void CMTPImageDataProvider::HandleMdeSessionCompleteL(TInt aError)
   801     {
   769     {
   802     __FLOG(_L8(">> HandleMdeSessionComplete"));    
   770     __FLOG(_L8(">> HandleMdeSessionComplete"));    
   803 
   771 
   804     NotifyEnumerationCompleteL(KMTPStorageAll, KErrNone);
   772     NotifyEnumerationCompleteL(KMTPStorageAll, KErrNone);