mtpdataproviders/mtpimagedp/src/cmtpimagedp.cpp
changeset 31 a26669f87b46
parent 29 3ae5cb0b4c02
child 37 d9d8313203af
equal deleted inserted replaced
29:3ae5cb0b4c02 31:a26669f87b46
   119         iMimeMappings.Insert(KMTPExtensionMimeTypeMappings[i].iExtension, KMTPExtensionMimeTypeMappings[i].iMimeType);
   119         iMimeMappings.Insert(KMTPExtensionMimeTypeMappings[i].iExtension, KMTPExtensionMimeTypeMappings[i].iMimeType);
   120         }     
   120         }     
   121     
   121     
   122     //Define RProperty of new pictures for status data provider
   122     //Define RProperty of new pictures for status data provider
   123     _LIT_SECURITY_POLICY_PASS(KAllowReadAll);
   123     _LIT_SECURITY_POLICY_PASS(KAllowReadAll);
   124     TInt error = RProperty::Define(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();
   168     
   169     
   169     __FLOG(_L8("<< ~CMTPImageDataProvider"));
   170     __FLOG(_L8("<< ~CMTPImageDataProvider"));
   170     __FLOG_CLOSE;
   171     __FLOG_CLOSE;
   171     }
   172     }
   172 
   173 
   608     if (iEnumerated)
   609     if (iEnumerated)
   609         {
   610         {
   610         /**
   611         /**
   611          * Get image object count from framework and calculate the new pictures
   612          * Get image object count from framework and calculate the new pictures
   612          */
   613          */
   613         TUint newPictures = QueryImageObjectCountL();
   614         TUint newPictures = QueryImageObjectCountL();        
   614         RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, newPictures);
       
   615         iNewPicNotifier->SetNewPictures(newPictures);
   615         iNewPicNotifier->SetNewPictures(newPictures);
   616         __FLOG_1(_L16("CMTPImageDpEnumerator::CompleteEnumeration - New Pics: %d"), newPictures);        
   616         __FLOG_1(_L16("CMTPImageDpEnumerator::CompleteEnumeration - New Pics: %d"), newPictures);        
   617         iEnumerated = EFalse;
   617         iEnumerated = EFalse;
   618         }
   618         }
   619     
   619     
   691     RArray<TUint>               handles;
   691     RArray<TUint>               handles;
   692     TMTPObjectMgrQueryParams    params(KMTPStorageAll, KMTPFormatsAll, KMTPHandleNone, Framework().DataProviderId());
   692     TMTPObjectMgrQueryParams    params(KMTPStorageAll, KMTPFormatsAll, KMTPHandleNone, Framework().DataProviderId());
   693     CleanupClosePushL(context);
   693     CleanupClosePushL(context);
   694     CleanupClosePushL(handles);    
   694     CleanupClosePushL(handles);    
   695     
   695     
       
   696     iNewPicHandles.Reset();
       
   697     
   696     do
   698     do
   697         {
   699         {
   698         /*
   700         /*
   699          * Speed up query performance, avoid to duplicated copy object handle between RArrays
   701          * Speed up query performance, avoid to duplicated copy object handle between RArrays
   700          */
   702          */
   710         {
   712         {
   711         Framework().ObjectMgr().ObjectL(handles[i], *objMetadata);
   713         Framework().ObjectMgr().ObjectL(handles[i], *objMetadata);
   712         if (MTPImageDpUtilits::IsNewPicture(*objMetadata))
   714         if (MTPImageDpUtilits::IsNewPicture(*objMetadata))
   713             {
   715             {
   714             ++newPictures;
   716             ++newPictures;
       
   717             iNewPicHandles.Append(handles[i]);
   715             }
   718             }
   716         }
   719         }
   717     
   720     
   718     
   721     
   719     CleanupStack::PopAndDestroy(objMetadata);
   722     CleanupStack::PopAndDestroy(objMetadata);
   763     iNewPicNotifier->DecreaseCount(aCount);
   766     iNewPicNotifier->DecreaseCount(aCount);
   764     
   767     
   765     __FLOG(_L8("<< DecreaseNewPictures "));    
   768     __FLOG(_L8("<< DecreaseNewPictures "));    
   766     }
   769     }
   767 
   770 
       
   771 void CMTPImageDataProvider::ResetNewPictures()
       
   772 	{
       
   773 	__FLOG(_L8(">> ResetNewPictures "));
       
   774 
       
   775 	iNewPicNotifier->SetNewPictures(0);
       
   776 	
       
   777 	TInt count = iNewPicHandles.Count();
       
   778 	if (!count)
       
   779 		{
       
   780 		return;
       
   781 		}
       
   782 
       
   783 	CMTPObjectMetaData* objMetadata = CMTPObjectMetaData::NewLC();
       
   784 	
       
   785 	for (TInt i(0); i<count; ++i)
       
   786 	{
       
   787 		Framework().ObjectMgr().ObjectL(iNewPicHandles[i], *objMetadata);
       
   788 		MTPImageDpUtilits::UpdateObjectStatusToOldL(Framework(), *objMetadata);
       
   789 	}
       
   790 	
       
   791 	iNewPicHandles.Reset();
       
   792 	CleanupStack::PopAndDestroy(objMetadata);
       
   793 	
       
   794 	__FLOG(_L8("<< ResetNewPictures "));
       
   795 	}
       
   796 
   768 void CMTPImageDataProvider::HandleMdeSessionCompleteL(TInt aError)
   797 void CMTPImageDataProvider::HandleMdeSessionCompleteL(TInt aError)
   769     {
   798     {
   770     __FLOG(_L8(">> HandleMdeSessionComplete"));    
   799     __FLOG(_L8(">> HandleMdeSessionComplete"));    
   771 
   800 
   772     NotifyEnumerationCompleteL(KMTPStorageAll, KErrNone);
   801     NotifyEnumerationCompleteL(KMTPStorageAll, KErrNone);