harvester/harvesterplugins/ImagePlugin/src/harvesterimageplugin.cpp
branchRCL_3
changeset 13 4a4892eec172
parent 9 82c0024438c8
child 19 b73252188534
equal deleted inserted replaced
12:9f21bab39f42 13:4a4892eec172
    18 
    18 
    19 #include <e32base.h>
    19 #include <e32base.h>
    20 #include <e32math.h>
    20 #include <e32math.h>
    21 #include <locationdatatype.h>
    21 #include <locationdatatype.h>
    22 #include <harvesterdata.h>
    22 #include <harvesterdata.h>
       
    23 #include <pathinfo.h>
    23 
    24 
    24 #include "harvesterlog.h"
    25 #include "harvesterlog.h"
    25 #include "mdsutils.h"
    26 #include "mdsutils.h"
    26 #include "harvesterexifutil.h"
    27 #include "harvesterexifutil.h"
    27 #include "harvesterimageplugin.h"
    28 #include "harvesterimageplugin.h"
    28 #include "mdeobjectwrapper.h"
    29 #include "mdeobjectwrapper.h"
       
    30 #include "mdscommoninternal.h"
    29 
    31 
    30 using namespace MdeConstants;
    32 using namespace MdeConstants;
    31 
    33 
    32 // image mime types
    34 // image mime types
    33 _LIT( KJpegMime, "image/jpeg" );
    35 _LIT( KJpegMime, "image/jpeg" );
    80 	iCreationDatePropertyDef = &objectDef.GetPropertyDefL( Object::KCreationDateProperty );
    82 	iCreationDatePropertyDef = &objectDef.GetPropertyDefL( Object::KCreationDateProperty );
    81 	iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( Object::KLastModifiedDateProperty );
    83 	iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( Object::KLastModifiedDateProperty );
    82 	iSizePropertyDef = &objectDef.GetPropertyDefL( Object::KSizeProperty );
    84 	iSizePropertyDef = &objectDef.GetPropertyDefL( Object::KSizeProperty );
    83 	iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( Object::KTimeOffsetProperty );
    85 	iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( Object::KTimeOffsetProperty );
    84 	iItemTypePropertyDef = &objectDef.GetPropertyDefL( Object::KItemTypeProperty );
    86 	iItemTypePropertyDef = &objectDef.GetPropertyDefL( Object::KItemTypeProperty );
       
    87 	iDefaultFolderPropertyDef = &objectDef.GetPropertyDefL( Object::KInDefaultFolder );
    85 
    88 
    86 	// Media property definitions
    89 	// Media property definitions
    87 	CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MediaObject::KMediaObject );
    90 	CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MediaObject::KMediaObject );
    88 	iWidthPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KWidthProperty );
    91 	iWidthPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KWidthProperty );
    89 	iHeightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KHeightProperty );
    92 	iHeightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KHeightProperty );
   189 		delete iExifUtil;
   192 		delete iExifUtil;
   190 		}
   193 		}
   191    	
   194    	
   192     delete iPropDefs;
   195     delete iPropDefs;
   193     
   196     
       
   197     delete iPhoneImagesPath;
       
   198     delete iMmcImagesPath;
       
   199     
   194     iMimeTypeMappings.Close();
   200     iMimeTypeMappings.Close();
   195     iFbs.Disconnect();
   201     iFbs.Disconnect();
   196 	}
   202 	}
   197 
   203 
   198 /**
   204 /**
   253     User::LeaveIfError( iMimeTypeMappings.InsertInOrder( TMimeTypeMapping<TImageMetadataHandling>(
   259     User::LeaveIfError( iMimeTypeMappings.InsertInOrder( TMimeTypeMapping<TImageMetadataHandling>(
   254     		KExtWmf(), KWmfMime(), EOtherHandling ), cmp ) );
   260     		KExtWmf(), KWmfMime(), EOtherHandling ), cmp ) );
   255     
   261     
   256     User::LeaveIfError( iMimeTypeMappings.InsertInOrder( TMimeTypeMapping<TImageMetadataHandling>(
   262     User::LeaveIfError( iMimeTypeMappings.InsertInOrder( TMimeTypeMapping<TImageMetadataHandling>(
   257             KExtOtb(), KOtbMime(), EOtherHandling ), cmp ) );
   263             KExtOtb(), KOtbMime(), EOtherHandling ), cmp ) );
   258     
   264 
       
   265     TFileName images = PathInfo::ImagesPath();
       
   266     
       
   267     TFileName phonePath = PathInfo::PhoneMemoryRootPath();
       
   268     phonePath.Append( images );
       
   269     iPhoneImagesPath = phonePath.AllocL();
       
   270 
       
   271     TFileName mmcPath = PathInfo::MemoryCardRootPath();
       
   272     mmcPath.Append( images );
       
   273     iMmcImagesPath = mmcPath.Right( mmcPath.Length() - 1 ).AllocL();
   259 	}
   274 	}
   260 
   275 
   261 void CHarvesterImagePlugin::HarvestL( CHarvesterData* aHD )
   276 void CHarvesterImagePlugin::HarvestL( CHarvesterData* aHD )
   262 	{
   277 	{
   263 	WRITELOG( "CHarvesterImagePlugin::HarvestL()" );
   278 	WRITELOG( "CHarvesterImagePlugin::HarvestL()" );
   709 	    // Object - Size
   724 	    // Object - Size
   710 	    CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iSizePropertyDef, &aFileData.iFileSize, aIsAdd );
   725 	    CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iSizePropertyDef, &aFileData.iFileSize, aIsAdd );
   711 	    
   726 	    
   712 	    // Item Type
   727 	    // Item Type
   713 	    CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iItemTypePropertyDef, &aFileData.iMime16, aIsAdd );
   728 	    CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iItemTypePropertyDef, &aFileData.iMime16, aIsAdd );
       
   729 
       
   730 	    const TDesC& uri = mdeObject.Uri();
       
   731 	    if( uri.FindF( iMmcImagesPath->Des()) != KErrNotFound ||
       
   732 	        uri.FindF( iPhoneImagesPath->Des()) != KErrNotFound ||
       
   733 	        uri.FindF( KDCIMFolder ) != KErrNotFound )
       
   734 	        {
       
   735 	        TBool inDefaultFolder( ETrue );
       
   736 	        CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDefaultFolderPropertyDef, &inDefaultFolder, aIsAdd );
       
   737 	        }
       
   738 	    else
       
   739 	        {
       
   740 	        TBool inDefaultFolder( EFalse );
       
   741 	        CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDefaultFolderPropertyDef, &inDefaultFolder, aIsAdd );    
       
   742 	        }    	
   714     	}
   743     	}
   715 
   744     
   716     if( aFileData.iJpeg )
   745     if( aFileData.iJpeg )
   717     	{
   746     	{
   718     	// Time offset
   747     	// Time offset
   719     	TInt16 timeOffsetMinutes = timeOffsetSeconds.Int() / 60;
   748     	TInt16 timeOffsetMinutes = timeOffsetSeconds.Int() / 60;
   720     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTimeOffsetPropertyDef, &timeOffsetMinutes, aIsAdd );
   749     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTimeOffsetPropertyDef, &timeOffsetMinutes, aIsAdd );