harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp
changeset 41 2290317b9ec5
parent 23 33ae025ac1e8
--- a/harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp	Mon May 03 12:55:01 2010 +0300
+++ b/harvester/harvesterplugins/VideoPlugin/src/harvestervideoplugin.cpp	Fri May 14 16:38:28 2010 +0300
@@ -21,12 +21,14 @@
 #include <hxmetadatautil.h>
 #include <hxmetadatakeys.h>
 #include <caf/caf.h>
+#include <pathinfo.h>
 
 #include "mdsutils.h"
 #include "harvestervideoplugin.h"
 #include "harvesterlog.h"
 #include "harvesterblacklist.h"
 #include "mdeobjectwrapper.h"
+#include "mdscommoninternal.h"
 
 #include <mdenamespacedef.h>
 #include <mdeobjectdef.h>
@@ -97,6 +99,7 @@
 	iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( Object::KTimeOffsetProperty );
 	iItemTypePropertyDef = &objectDef.GetPropertyDefL( Object::KItemTypeProperty );
 	iTitlePropertyDef = &objectDef.GetPropertyDefL( Object::KTitleProperty );
+	iDefaultFolderPropertyDef = &objectDef.GetPropertyDefL( Object::KInDefaultFolder );
 
 	CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MediaObject::KMediaObject );
 	iReleaseDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KReleaseDateProperty );
@@ -163,6 +166,9 @@
 	iMimeTypeMappings.Close();
     RMediaIdUtil::ReleaseInstance();
 
+    delete iPhoneVideosPath;
+    delete iMmcVideosPath;
+    
 	WRITELOG("CHarvesterVideoPlugin::CHarvesterVideoPlugin()");
 	}
 
@@ -268,6 +274,16 @@
             TVideoMetadataHandling( TVideoMetadataHandling::EHexilMetadataHandling, KVideo(),
                     KMimeTypeWmv(), KMimeTypeWmv() ) ), 
             cmp ) );
+
+    TFileName videos = PathInfo::VideosPath();
+    
+    TFileName phonePath = PathInfo::PhoneMemoryRootPath();
+    phonePath.Append( videos );
+    iPhoneVideosPath = phonePath.AllocL();
+
+    TFileName mmcPath = PathInfo::MemoryCardRootPath();
+    mmcPath.Append( videos );
+    iMmcVideosPath = mmcPath.Right( mmcPath.Length() - 1 ).AllocL();
     
     iMediaIdUtil = &RMediaIdUtil::GetInstanceL();
     }
@@ -398,7 +414,7 @@
     	}
     else
         {
-        WRITELOG1( "CHarvesterVideoPlugin::HarvestSingleFileL() - TRAP error: %d", error );
+        WRITELOG1( "CHarvesterVideoPlugin::HarvestL() - TRAP error: %d", error );
         TInt convertedError = KErrNone;
         MdsUtils::ConvertTrapError( error, convertedError );
         aHD->SetErrorCode( convertedError );
@@ -433,6 +449,12 @@
 void CHarvesterVideoPlugin::GatherDataL( CMdEObject& aMetadataObject,
 		CVideoHarvestData& aVHD )
     {
+#ifdef _DEBUG
+    TTime dStart, dStop;
+    dStart.UniversalTime();
+    dStop.UniversalTime();
+    WRITELOG1( "CHarvesterVideoPlugin::GatherDataL start %d us", (TInt)dStop.MicroSecondsFrom(dStart).Int64() );
+#endif
     const TDesC& uri = aMetadataObject.Uri();
     
     WRITELOG1( "CHarvesterVideoPlugin - Gather data from file %S", &uri );
@@ -758,7 +780,6 @@
         	aVHD.iMimeBuf = mime.Alloc();
         	}
         
-        helixMetadata->ResetL();
         CleanupStack::PopAndDestroy( helixMetadata );
         
         // don't destory mime type pointers just clean array
@@ -932,6 +953,11 @@
     WRITELOG( "CHarvesterVideoPlugin - Closing file" );        
     CleanupStack::PopAndDestroy( &file );        
 
+#ifdef _DEBUG
+    dStop.UniversalTime();
+    WRITELOG1( "CHarvesterVideoPlugin::GatherDataL start %d us", (TInt)dStop.MicroSecondsFrom(dStart).Int64() );
+#endif  
+    
     WRITELOG( "CHarvesterVideoPlugin - Start adding data to object" );
     }
 
@@ -969,6 +995,21 @@
     
     	// File size
     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iSizePropertyDef, &aVHD.iFileSize, aIsAdd );
+    	
+    	// Default folder
+        const TDesC& uri = mdeObject.Uri();
+        if( uri.FindF( iMmcVideosPath->Des()) != KErrNotFound ||
+            uri.FindF( iPhoneVideosPath->Des()) != KErrNotFound ||
+            uri.FindF( KDCIMFolder ) != KErrNotFound ) 
+            {
+            TBool inDefaultFolder( ETrue );
+            CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDefaultFolderPropertyDef, &inDefaultFolder, aIsAdd );
+            }
+        else
+            {
+            TBool inDefaultFolder( EFalse );
+            CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDefaultFolderPropertyDef, &inDefaultFolder, aIsAdd );    
+            }
     	}
 
     // Item Type
@@ -1089,7 +1130,7 @@
         }
     
     // Title
-    if( aVHD.iTitle && aVHD.iTitle->Length() < iMaxTextLength )
+    if( aVHD.iTitle && aVHD.iTitle->Length() < KMaxTitleFieldLength )
         {
         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTitlePropertyDef, aVHD.iTitle, EFalse );
         }