harvester/monitorplugins/fileplugin/src/fileeventhandlerao.cpp
changeset 43 c5e73110f733
parent 40 910a23996aa0
child 48 1389872e7c51
--- a/harvester/monitorplugins/fileplugin/src/fileeventhandlerao.cpp	Fri Jul 23 10:03:59 2010 +0300
+++ b/harvester/monitorplugins/fileplugin/src/fileeventhandlerao.cpp	Fri Aug 06 09:56:02 2010 +0300
@@ -16,6 +16,7 @@
 
 #include <collate.h>
 #include <mdeobject.h>
+#include <pathinfo.h>
 
 #include "fileeventhandlerao.h"
 #include "harvesterlog.h"
@@ -90,6 +91,39 @@
     	}
     
     iEventArray = new (ELeave) CArrayFixSeg< TMdsFSPStatus >( KMaxEventsGranularity );
+    
+    TFileName phoneRoot = PathInfo::PhoneMemoryRootPath();
+    TFileName mmcRoot = PathInfo::MemoryCardRootPath();
+    
+    TFileName images = PathInfo::ImagesPath();
+    
+    TFileName phoneImagePath( phoneRoot );
+    phoneImagePath.Append( images );
+    iPhoneImagesPath = phoneImagePath.AllocL();
+
+    TFileName mmcImagePath( mmcRoot );
+    mmcImagePath.Append( images );
+    iMmcImagesPath = mmcImagePath.Right( mmcImagePath.Length() - 1 ).AllocL();
+    
+    TFileName videos = PathInfo::VideosPath();
+    
+    TFileName phoneVideoPath( phoneRoot );
+    phoneVideoPath.Append( videos );
+    iPhoneVideosPath = phoneVideoPath.AllocL();
+
+    TFileName mmcVideoPath( mmcRoot );
+    mmcVideoPath.Append( videos );
+    iMmcVideosPath = mmcVideoPath.Right( mmcVideoPath.Length() - 1 ).AllocL();
+    
+    TFileName sounds = PathInfo::SoundsPath();
+    
+    TFileName phoneSoundPath( phoneRoot );
+    phoneSoundPath.Append( sounds );
+    iPhoneSoundsPath = phoneSoundPath.AllocL();
+
+    TFileName mmcSoundPath( mmcRoot );
+    mmcSoundPath.Append( sounds );
+    iMmcSoundsPath = mmcSoundPath.Right( mmcSoundPath.Length() - 1 ).AllocL();
     }
 
 // ---------------------------------------------------------------------------
@@ -121,6 +155,21 @@
 	
     iUriArray.ResetAndDestroy();
     iUriArray.Close();
+    
+    delete iPhoneImagesPath;
+	iPhoneImagesPath = NULL;
+    delete iMmcImagesPath;
+	iMmcImagesPath = NULL;
+    
+    delete iPhoneVideosPath;
+	iPhoneVideosPath = NULL;
+    delete iMmcVideosPath;
+	iMmcVideosPath = NULL;
+    
+    delete iPhoneSoundsPath;
+	iPhoneSoundsPath = NULL;
+    delete iMmcSoundsPath;
+	iMmcSoundsPath = NULL;
     }
 
 
@@ -449,6 +498,7 @@
         		newObject->Id() );
         if ( removedId != KNoId )
         	{
+            SetTitleL( oldObject , aNewUrl );
 	        oldObject->SetUriL( aNewUrl );
 	        TUint32 mediaId = FSUtil::MediaID( iFs, aNewUrl );
 	        oldObject->SetMediaId( mediaId );
@@ -462,6 +512,7 @@
 
     if ( oldObject )
         {
+        CheckDefaultFolderL( oldObject );
         SetModifiedTimeL( oldObject, aNewUrl );
         TOrigin origin = OriginFromMdEObjectL( *oldObject );
         if( origin == MdeConstants::Object::EOther)
@@ -639,8 +690,10 @@
                     CleanupStack::PushL( oldObject );
                     SetTitleL( oldObject , aNewUrl );
         	        oldObject->SetUriL( aNewUrl );
+        	        CheckDefaultFolderL( oldObject );
         	        TUint32 mediaId = FSUtil::MediaID( iFs, aNewUrl );
         	        oldObject->SetMediaId( mediaId );
+        	        SetModifiedTimeL( oldObject, aNewUrl );
         	        TOrigin origin = OriginFromMdEObjectL( *oldObject );
         	        if( origin == MdeConstants::Object::EOther)
         	        	{
@@ -661,6 +714,7 @@
                 CleanupStack::PushL( oldObject );
                 SetTitleL( oldObject , aNewUrl );
     	        oldObject->SetUriL( aNewUrl );
+    	        CheckDefaultFolderL( oldObject );
     	        TUint32 mediaId = FSUtil::MediaID( iFs, aNewUrl );
     	        oldObject->SetMediaId( mediaId );
     	        SetModifiedTimeL( oldObject, aNewUrl );
@@ -981,3 +1035,60 @@
         }
     }
 
+//---------------------------------------------------------------------------
+// CFileEventHandlerAO::CheckDefaultFolderL()
+// ---------------------------------------------------------------------------
+//   
+void CFileEventHandlerAO::CheckDefaultFolderL( CMdEObject* aOldObject )
+    {
+    if( !iDefaultFolderPropertyDef )
+        {
+        iDefaultFolderPropertyDef = &aOldObject->Def().GetPropertyDefL( 
+                       MdeConstants::Object::KInDefaultFolder );
+        }
+    
+    CMdEProperty* folderProp = NULL;
+    aOldObject->Property( *iDefaultFolderPropertyDef, folderProp );
+    
+    TBool inDefaultFolder( EFalse );
+    TPtrC objectDefName( aOldObject->Def().Name() );
+    if( objectDefName == MdeConstants::Image::KImageObject )
+        {
+        const TDesC& uri = aOldObject->Uri();
+        if( uri.FindF( iMmcImagesPath->Des()) != KErrNotFound ||
+            uri.FindF( iPhoneImagesPath->Des()) != KErrNotFound ||
+            uri.FindF( KDCIMFolder ) != KErrNotFound )
+            {
+            inDefaultFolder = ETrue; 
+            }    
+        }
+    else if( objectDefName == MdeConstants::Video::KVideoObject )
+        {
+        const TDesC& uri = aOldObject->Uri();
+        if( uri.FindF( iMmcVideosPath->Des()) != KErrNotFound ||
+            uri.FindF( iPhoneVideosPath->Des()) != KErrNotFound ||
+            uri.FindF( KDCIMFolder ) != KErrNotFound )
+            {
+            inDefaultFolder = ETrue; 
+            }    
+        }
+    else if( objectDefName == MdeConstants::Audio::KAudioObject )
+        {
+        const TDesC& uri = aOldObject->Uri();
+        if( uri.FindF( iMmcSoundsPath->Des()) != KErrNotFound ||
+            uri.FindF( iPhoneSoundsPath->Des()) != KErrNotFound )
+            {
+            inDefaultFolder = ETrue;
+            } 
+        }
+
+    if( folderProp )
+        {
+        folderProp->SetBoolValueL( inDefaultFolder );
+        }
+    else
+        {
+        aOldObject->AddBoolPropertyL( *iDefaultFolderPropertyDef, inDefaultFolder );
+        }
+    }
+