harvester/server/src/harvesterao.cpp
changeset 41 2290317b9ec5
parent 23 33ae025ac1e8
equal deleted inserted replaced
23:33ae025ac1e8 41:2290317b9ec5
    20 #include <driveinfo.h>
    20 #include <driveinfo.h>
    21 
    21 
    22 #include <rlocationobjectmanipulator.h>
    22 #include <rlocationobjectmanipulator.h>
    23 #include <placeholderdata.h>
    23 #include <placeholderdata.h>
    24 #include <harvesterclientdata.h>
    24 #include <harvesterclientdata.h>
       
    25 #include <pathinfo.h>
    25 
    26 
    26 using namespace ContentAccess;
    27 using namespace ContentAccess;
    27 
    28 
    28 #include "harvesterao.h"
    29 #include "harvesterao.h"
    29 #include "harvesterlog.h"
    30 #include "harvesterlog.h"
    32 #include "mdsutils.h"
    33 #include "mdsutils.h"
    33 #include "mdeconstants.h"
    34 #include "mdeconstants.h"
    34 #include "harvesterdata.h"
    35 #include "harvesterdata.h"
    35 #include "ondemandao.h"
    36 #include "ondemandao.h"
    36 #include "harvestercommon.h"
    37 #include "harvestercommon.h"
       
    38 #include "mdscommoninternal.h"
    37 #include "processoriginmapperinterface.h"
    39 #include "processoriginmapperinterface.h"
    38 #include "mdeobjecthandler.h"
    40 #include "mdeobjecthandler.h"
    39 #include "harvestereventmanager.h"
    41 #include "harvestereventmanager.h"
    40 #include "harvestercenreputil.h"
    42 #include "harvestercenreputil.h"
    41 #include "restorewatcher.h"
    43 #include "restorewatcher.h"
    77 	iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty );
    79 	iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty );
    78 	iSizePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty );
    80 	iSizePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty );
    79 	iOriginPropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KOriginProperty );
    81 	iOriginPropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KOriginProperty );
    80 	iItemTypePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty );
    82 	iItemTypePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty );
    81 	iTitlePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KTitleProperty );
    83 	iTitlePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KTitleProperty );
       
    84 	iDefaultFolderPropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KInDefaultFolder );
    82 	
    85 	
    83 	CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MdeConstants::MediaObject::KMediaObject );
    86 	CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MdeConstants::MediaObject::KMediaObject );
    84 	iPreinstalledPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KPreinstalledProperty );
    87 	iPreinstalledPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KPreinstalledProperty );
    85 	}
    88 	}
    86 
    89 
   214 	delete iUnmountHandlerAO;
   217 	delete iUnmountHandlerAO;
   215 	
   218 	
   216 	delete iPropDefs;
   219 	delete iPropDefs;
   217 	delete iCameraExtensionArray;
   220 	delete iCameraExtensionArray;
   218 	
   221 	
       
   222     delete iPhoneImagesPath;
       
   223     delete iMmcImagesPath;
       
   224     
       
   225     delete iPhoneVideosPath;
       
   226     delete iMmcVideosPath;
       
   227     
       
   228     delete iPhoneSoundsPath;
       
   229     delete iMmcSoundsPath;
       
   230 	
   219 	RMediaIdUtil::ReleaseInstance();
   231 	RMediaIdUtil::ReleaseInstance();
   220     
   232     
   221     REComSession::FinalClose();
   233     REComSession::FinalClose();
   222     }
   234     }
   223 
   235 
   270     iCameraExtensionArray->InsertIsqL( KExtensionMpg4 );
   282     iCameraExtensionArray->InsertIsqL( KExtensionMpg4 );
   271     iCameraExtensionArray->InsertIsqL( KExtensionMpeg4 );
   283     iCameraExtensionArray->InsertIsqL( KExtensionMpeg4 );
   272     iCameraExtensionArray->InsertIsqL( KExtension3gp );
   284     iCameraExtensionArray->InsertIsqL( KExtension3gp );
   273     iCameraExtensionArray->InsertIsqL( KExtension3gpp );
   285     iCameraExtensionArray->InsertIsqL( KExtension3gpp );
   274     iCameraExtensionArray->InsertIsqL( KExtension3g2 );
   286     iCameraExtensionArray->InsertIsqL( KExtension3g2 );
   275 	
   287 
       
   288     TFileName phoneRoot = PathInfo::PhoneMemoryRootPath();
       
   289     TFileName mmcRoot = PathInfo::MemoryCardRootPath();
       
   290     
       
   291     TFileName images = PathInfo::ImagesPath();
       
   292     
       
   293     TFileName phoneImagePath( phoneRoot );
       
   294     phoneImagePath.Append( images );
       
   295     iPhoneImagesPath = phoneImagePath.AllocL();
       
   296 
       
   297     TFileName mmcImagePath( mmcRoot );
       
   298     mmcImagePath.Append( images );
       
   299     iMmcImagesPath = mmcImagePath.Right( mmcImagePath.Length() - 1 ).AllocL();
       
   300     
       
   301     TFileName videos = PathInfo::VideosPath();
       
   302     
       
   303     TFileName phoneVideoPath( phoneRoot );
       
   304     phoneVideoPath.Append( videos );
       
   305     iPhoneVideosPath = phoneVideoPath.AllocL();
       
   306 
       
   307     TFileName mmcVideoPath( mmcRoot );
       
   308     mmcVideoPath.Append( videos );
       
   309     iMmcVideosPath = mmcVideoPath.Right( mmcVideoPath.Length() - 1 ).AllocL();
       
   310     
       
   311     TFileName sounds = PathInfo::SoundsPath();
       
   312     
       
   313     TFileName phoneSoundPath( phoneRoot );
       
   314     phoneSoundPath.Append( sounds );
       
   315     iPhoneSoundsPath = phoneSoundPath.AllocL();
       
   316 
       
   317     TFileName mmcSoundPath( mmcRoot );
       
   318     mmcSoundPath.Append( sounds );
       
   319     iMmcSoundsPath = mmcSoundPath.Right( mmcSoundPath.Length() - 1 ).AllocL();
       
   320     
   276     WRITELOG( "CHarvesterAO::ConstructL() - end" );
   321     WRITELOG( "CHarvesterAO::ConstructL() - end" );
   277     }
   322     }
   278 
   323 
   279 // ---------------------------------------------------------------------------
   324 // ---------------------------------------------------------------------------
   280 // LoadMonitorPluginsL
   325 // LoadMonitorPluginsL
   778 	RPointerArray<CMdEObject> mdeObjectArray;
   823 	RPointerArray<CMdEObject> mdeObjectArray;
   779 	CleanupClosePushL( mdeObjectArray );
   824 	CleanupClosePushL( mdeObjectArray );
   780 
   825 
   781 	TTimeIntervalSeconds timeOffsetSeconds = User::UTCOffset();
   826 	TTimeIntervalSeconds timeOffsetSeconds = User::UTCOffset();
   782 	
   827 	
   783 	TInt fastHarvestPlaceholderCount = 0;
       
   784 	
       
   785 	TInt endindex( iPHArray.Count() );
   828 	TInt endindex( iPHArray.Count() );
   786 	for( TInt i = 0; i < endindex; i++ )
   829 	for( TInt i = 0; i < endindex; i++ )
   787 		{
   830 		{
   788 		CHarvesterData* hd = iPHArray[i];
   831 		CHarvesterData* hd = iPHArray[i];
   789 		
   832 		
   844 	            i--;
   887 	            i--;
   845 	            endindex--;
   888 	            endindex--;
   846 				iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeMMC, 1 );
   889 				iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeMMC, 1 );
   847 				CleanupStack::PopAndDestroy( entry );
   890 				CleanupStack::PopAndDestroy( entry );
   848 				CleanupStack::PopAndDestroy( phData );
   891 				CleanupStack::PopAndDestroy( phData );
       
   892 				CleanupStack::PopAndDestroy( mdeObject );
   849 				continue;
   893 				continue;
   850 		    	}
   894 		    	}
   851 		    phData->SetUri( uri );
   895 		    phData->SetUri( uri );
   852 			phData->SetModified( entry->iModified );
   896 			phData->SetModified( entry->iModified );
   853 			phData->SetFileSize( entry->iSize );
   897 			phData->SetFileSize( entry->iSize );
   870 				hd = NULL;
   914 				hd = NULL;
   871 				iPHArray.Remove( i );
   915 				iPHArray.Remove( i );
   872 	            i--;
   916 	            i--;
   873 	            endindex--;
   917 	            endindex--;
   874 				iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeMMC, 1 );
   918 				iHarvesterEventManager->DecreaseItemCountL( EHEObserverTypeMMC, 1 );
       
   919 				CleanupStack::PopAndDestroy( mdeObject );
   875 				continue;
   920 				continue;
   876 		    	}	
   921 		    	}	
   877 			CleanupStack::PushL( phData );
   922 			CleanupStack::PushL( phData );
   878 			}	
   923 			}	
   879 		
   924 		
   910         else
   955         else
   911             {
   956             {
   912             mdeObject->AddTextPropertyL( *iPropDefs->iItemTypePropertyDef, KUndefinedMime );
   957             mdeObject->AddTextPropertyL( *iPropDefs->iItemTypePropertyDef, KUndefinedMime );
   913             }
   958             }
   914 		
   959 		
       
   960         if( hd->Origin() == MdeConstants::Object::ECamera )
       
   961             {
       
   962             TBool inDefaultFolder( ETrue );
       
   963             mdeObject->AddBoolPropertyL( *iPropDefs->iDefaultFolderPropertyDef, inDefaultFolder );
       
   964             }
       
   965         else
       
   966             {
       
   967             AddDefaultFolderDataL( mdeObject );
       
   968             }       
       
   969         
   915 	    TPtrC name;
   970 	    TPtrC name;
   916 	    TBool nameFound = MdsUtils::GetName( hd->Uri(), name );
   971 	    TBool nameFound = MdsUtils::GetName( hd->Uri(), name );
   917 
   972 
   918 	    if ( nameFound )
   973 	    if ( nameFound )
   919 	        {
   974 	        {
   944 	    hd->SetEventType( EHarvesterEdit );
   999 	    hd->SetEventType( EHarvesterEdit );
   945 		
  1000 		
   946 		// skip 
  1001 		// skip 
   947 		if( hd->TakeSnapshot() )
  1002 		if( hd->TakeSnapshot() )
   948 			{
  1003 			{
   949 			fastHarvestPlaceholderCount++;
       
   950 			hd->SetObjectType( EFastHarvest );
  1004 			hd->SetObjectType( EFastHarvest );
   951 			}
  1005 			}
   952 		else
  1006 		else
   953 			{
  1007 			{
   954 			hd->SetClientData( NULL );
  1008 			hd->SetClientData( NULL );
   981 		    {
  1035 		    {
   982 		    // If some error occures, retry
  1036 		    // If some error occures, retry
   983 		    iMdESession->AddObjectsL( mdeObjectArray );
  1037 		    iMdESession->AddObjectsL( mdeObjectArray );
   984 		    }
  1038 		    }
   985 
  1039 
   986 		const TInt eventObjectCount = objectCount - fastHarvestPlaceholderCount;
  1040 	    iHarvesterEventManager->IncreaseItemCount( EHEObserverTypePlaceholder, 
   987 
  1041 		        objectCount );
   988 		if( eventObjectCount > 0 )
  1042 		iHarvesterEventManager->SendEventL( EHEObserverTypePlaceholder, EHEStateStarted, 
   989 			{
  1043 				iHarvesterEventManager->ItemCount( EHEObserverTypePlaceholder ) );
   990 			iHarvesterEventManager->IncreaseItemCount( EHEObserverTypePlaceholder, 
       
   991 					eventObjectCount );
       
   992 			iHarvesterEventManager->SendEventL( EHEObserverTypePlaceholder, EHEStateStarted, 
       
   993 					iHarvesterEventManager->ItemCount( EHEObserverTypePlaceholder ) );
       
   994 			}
       
   995 		
  1044 		
   996 #ifdef _DEBUG
  1045 #ifdef _DEBUG
   997 		for (TInt i = 0; i < objectCount; ++i)
  1046 		for (TInt i = 0; i < objectCount; ++i)
   998 			{
  1047 			{
   999 			CMdEObject* mdeObject = mdeObjectArray[i];
  1048 			CMdEObject* mdeObject = mdeObjectArray[i];
  2418                 else
  2467                 else
  2419                 	{
  2468                 	{
  2420                 	WRITELOG("CHarvesterAO::HarvestingCompleted() NOT COMPLETING AS msg->iMessage->IsNull returns ETrue");
  2469                 	WRITELOG("CHarvesterAO::HarvestingCompleted() NOT COMPLETING AS msg->iMessage->IsNull returns ETrue");
  2421                 	} 
  2470                 	} 
  2422                 iHarvestFileMessages.Remove( i );
  2471                 iHarvestFileMessages.Remove( i );
       
  2472                 if( iHarvestFileMessages.Count() == 0 )
       
  2473                     {
       
  2474                     iHarvestFileMessages.Compress();
       
  2475                     }
  2423                 }
  2476                 }
  2424             }
  2477             }
  2425         }
  2478         }
  2426 	}
  2479 	}
  2427 
  2480 
  2455 void CHarvesterAO::BootPartialRestoreScanL()
  2508 void CHarvesterAO::BootPartialRestoreScanL()
  2456 	{
  2509 	{
  2457 	// check if partial restore was done before last boot
  2510 	// check if partial restore was done before last boot
  2458 	TBool partialRestore = iRestoreWatcher->Register();
  2511 	TBool partialRestore = iRestoreWatcher->Register();
  2459 	
  2512 	
  2460 #ifdef __WINSCW__
  2513 #if defined(__WINSCW__) || defined(FF_PLATFORM_SIMULATOR)
  2461 	partialRestore = ETrue;
  2514 	partialRestore = ETrue;
  2462 #endif
  2515 #endif
  2463 	
  2516 	
  2464 	if ( !partialRestore )
  2517 	if ( !partialRestore )
  2465 		{
  2518 		{
  2836         {
  2889         {
  2837         TRAP_IGNORE( iMdESession->RemoveObjectL( aItem->Uri() ) );
  2890         TRAP_IGNORE( iMdESession->RemoveObjectL( aItem->Uri() ) );
  2838         }
  2891         }
  2839     }
  2892     }
  2840 
  2893 
       
  2894 void CHarvesterAO::AddDefaultFolderDataL( CMdEObject* aObject )
       
  2895     {
       
  2896     TPtrC objectDefName( aObject->Def().Name() );
       
  2897     if( objectDefName == MdeConstants::Image::KImageObject )
       
  2898         {
       
  2899         const TDesC& uri = aObject->Uri();
       
  2900         if( uri.FindF( iMmcImagesPath->Des()) != KErrNotFound ||
       
  2901             uri.FindF( iPhoneImagesPath->Des()) != KErrNotFound ||
       
  2902             uri.FindF( KDCIMFolder ) != KErrNotFound )
       
  2903             {
       
  2904             TBool inDefaultFolder( ETrue );
       
  2905             aObject->AddBoolPropertyL( *iPropDefs->iDefaultFolderPropertyDef, inDefaultFolder );
       
  2906             }
       
  2907         else
       
  2908             {
       
  2909             TBool inDefaultFolder( EFalse );
       
  2910             aObject->AddBoolPropertyL( *iPropDefs->iDefaultFolderPropertyDef, inDefaultFolder );  
       
  2911             }    
       
  2912         }
       
  2913     else if( objectDefName == MdeConstants::Video::KVideoObject )
       
  2914         {
       
  2915         const TDesC& uri = aObject->Uri();
       
  2916         if( uri.FindF( iMmcVideosPath->Des()) != KErrNotFound ||
       
  2917             uri.FindF( iPhoneVideosPath->Des()) != KErrNotFound ||
       
  2918             uri.FindF( KDCIMFolder ) != KErrNotFound )
       
  2919             {
       
  2920             TBool inDefaultFolder( ETrue );
       
  2921             aObject->AddBoolPropertyL( *iPropDefs->iDefaultFolderPropertyDef, inDefaultFolder );
       
  2922             }
       
  2923         else
       
  2924             {
       
  2925             TBool inDefaultFolder( EFalse );
       
  2926             aObject->AddBoolPropertyL( *iPropDefs->iDefaultFolderPropertyDef, inDefaultFolder );   
       
  2927             }    
       
  2928         }
       
  2929     else if( objectDefName == MdeConstants::Audio::KAudioObject )
       
  2930         {
       
  2931         const TDesC& uri = aObject->Uri();
       
  2932         if( uri.FindF( iMmcSoundsPath->Des()) != KErrNotFound ||
       
  2933             uri.FindF( iPhoneSoundsPath->Des()) != KErrNotFound )
       
  2934             {
       
  2935             TBool inDefaultFolder( ETrue );
       
  2936             aObject->AddBoolPropertyL( *iPropDefs->iDefaultFolderPropertyDef, inDefaultFolder );
       
  2937             }
       
  2938         else
       
  2939             {
       
  2940             TBool inDefaultFolder( EFalse );
       
  2941             aObject->AddBoolPropertyL( *iPropDefs->iDefaultFolderPropertyDef, inDefaultFolder );    
       
  2942             }     
       
  2943         }
       
  2944     else
       
  2945         {
       
  2946         // Other objects are set to be in default location by default
       
  2947         TBool inDefaultFolder( ETrue );
       
  2948         aObject->AddBoolPropertyL( *iPropDefs->iDefaultFolderPropertyDef, inDefaultFolder );
       
  2949         }
       
  2950     }