harvester/harvesterplugins/ImagePlugin/src/harvesterimageplugin.cpp
branchRCL_3
changeset 63 e538444823de
parent 47 b73252188534
equal deleted inserted replaced
57:2872ae438bf7 63:e538444823de
    67 
    67 
    68 #ifdef MDS_MULTIPLE_STAGE_IMAGE_PROCESSING
    68 #ifdef MDS_MULTIPLE_STAGE_IMAGE_PROCESSING
    69 const TUid KBGPSUid = { 0x0ADC2480 };
    69 const TUid KBGPSUid = { 0x0ADC2480 };
    70 #endif
    70 #endif
    71 
    71 
    72 CHarvesterImagePluginPropertyDefs::CHarvesterImagePluginPropertyDefs() : CBase(),
    72 CHarvesterImagePluginPropertyDefs::CHarvesterImagePluginPropertyDefs() : CBase()
    73     iCreationDatePropertyDef( NULL )
       
    74 	{
    73 	{
    75 	}
    74 	}
    76 
    75 
    77 void CHarvesterImagePluginPropertyDefs::ConstructL( CMdEObjectDef& aObjectDef )
    76 void CHarvesterImagePluginPropertyDefs::ConstructL(CMdEObjectDef& aObjectDef)
    78 	{
    77 	{
    79     SetByObjectDefL( aObjectDef );
    78 	CMdENamespaceDef& nsDef = aObjectDef.NamespaceDef();
       
    79 
       
    80 	// Image property definitions
       
    81 	CMdEObjectDef& objectDef = nsDef.GetObjectDefL( Object::KBaseObject );
       
    82 	iCreationDatePropertyDef = &objectDef.GetPropertyDefL( Object::KCreationDateProperty );
       
    83 	iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( Object::KLastModifiedDateProperty );
       
    84 	iSizePropertyDef = &objectDef.GetPropertyDefL( Object::KSizeProperty );
       
    85 	iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( Object::KTimeOffsetProperty );
       
    86 	iItemTypePropertyDef = &objectDef.GetPropertyDefL( Object::KItemTypeProperty );
       
    87 	iDefaultFolderPropertyDef = &objectDef.GetPropertyDefL( Object::KInDefaultFolder );
       
    88 
       
    89 	// Media property definitions
       
    90 	CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MediaObject::KMediaObject );
       
    91 	iWidthPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KWidthProperty );
       
    92 	iHeightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KHeightProperty );
       
    93 	iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDescriptionProperty );
       
    94 	iCommentPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCommentProperty );
       
    95 	iReleaseDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KReleaseDateProperty );
       
    96 	iCopyrightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCopyrightProperty );
       
    97 	iCaptureDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCaptureDateProperty );
       
    98 	iResolutionUnitPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KResolutionUnitProperty );
       
    99 	iArtistPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KArtistProperty );
       
   100 
       
   101 	// Image property definitions
       
   102 	CMdEObjectDef& imageDef = nsDef.GetObjectDefL( Image::KImageObject );
       
   103 	iPixelYDimensionPropertyDef = &imageDef.GetPropertyDefL( Image::KPixelYDimensionProperty );
       
   104 	iPixelXDimensionPropertyDef = &imageDef.GetPropertyDefL( Image::KPixelXDimensionProperty );
       
   105 	iBitsPerSamplePropertyDef = &imageDef.GetPropertyDefL( Image::KBitsPerSampleProperty );
       
   106 	iFrameCountPropertyDef = &imageDef.GetPropertyDefL( Image::KFrameCountProperty );
       
   107 	iDateTimeOriginalPropertyDef = &imageDef.GetPropertyDefL( Image::KDateTimeOriginalProperty );
       
   108 	iDateTimeDigitizedPropertyDef = &imageDef.GetPropertyDefL( Image::KDateTimeDigitizedProperty );
       
   109 	iDateTimePropertyDef = &imageDef.GetPropertyDefL( Image::KDateTimeProperty );
       
   110 	iWhiteBalancePropertyDef = &imageDef.GetPropertyDefL( Image::KWhiteBalanceProperty );
       
   111 	iFlashPropertyDef = &imageDef.GetPropertyDefL( Image::KFlashProperty );
       
   112 	iExposureProgramPropertyDef = &imageDef.GetPropertyDefL( Image::KExposureProgramProperty );
       
   113 	iMakePropertyDef = &imageDef.GetPropertyDefL( Image::KMakeProperty );
       
   114 	iModelPropertyDef = &imageDef.GetPropertyDefL( Image::KModelProperty );
       
   115 	iOrientationPropertyDef = &imageDef.GetPropertyDefL( Image::KOrientationProperty );
       
   116 	iXResolutionPropertyDef = &imageDef.GetPropertyDefL( Image::KXResolutionProperty );
       
   117 	iYResolutionPropertyDef = &imageDef.GetPropertyDefL( Image::KYResolutionProperty );
       
   118 	iYCbCrPositioningPropertyDef = &imageDef.GetPropertyDefL( Image::KYCbCrPositioningProperty );
       
   119 	iExposureTimePropertyDef = &imageDef.GetPropertyDefL( Image::KExposureTimeProperty );
       
   120 	iFNumberPropertyDef = &imageDef.GetPropertyDefL( Image::KFNumberProperty );
       
   121 	iExifVersionPropertyDef = &imageDef.GetPropertyDefL( Image::KExifVersionProperty );
       
   122 	iShutterSpeedValuePropertyDef = &imageDef.GetPropertyDefL( Image::KShutterSpeedValueProperty );
       
   123 	iApertureValuePropertyDef = &imageDef.GetPropertyDefL( Image::KApertureValueProperty );
       
   124 	iFocalLengthPropertyDef = &imageDef.GetPropertyDefL( Image::KFocalLengthProperty );
       
   125 	iFlashPixVersionPropertyDef = &imageDef.GetPropertyDefL( Image::KFlashPixVersionProperty );
       
   126 	iColourSpacePropertyDef = &imageDef.GetPropertyDefL( Image::KColourSpaceProperty );
       
   127 	iISOSpeedRatingsPropertyDef = &imageDef.GetPropertyDefL( Image::KISOSpeedRatingsProperty );
       
   128 	iComponentsConfigurationPropertyDef = &imageDef.GetPropertyDefL( Image::KComponentsConfigurationProperty );
       
   129 	iExposureBiasValuePropertyDef = &imageDef.GetPropertyDefL( Image::KExposureBiasValueProperty );
       
   130 	iSamplesPerPixelPropertyDef = &imageDef.GetPropertyDefL( Image::KSamplesPerPixelProperty );
       
   131 	iThumbCompressionPropertyDef = &imageDef.GetPropertyDefL( Image::KThumbCompressionProperty );
       
   132 	iThumbXResolutionPropertyDef = &imageDef.GetPropertyDefL( Image::KThumbXResolutionProperty );
       
   133 	iThumbYResolutionPropertyDef = &imageDef.GetPropertyDefL( Image::KThumbYResolutionProperty );
       
   134 	iThumbResolutionUnitPropertyDef = &imageDef.GetPropertyDefL( Image::KThumbResolutionUnitProperty );
       
   135 	iFocalLengthIn35mmFilmPropertyDef = &imageDef.GetPropertyDefL( Image::KFocalLengthIn35mmFilmProperty );
       
   136 	iMeteringModePropertyDef = &imageDef.GetPropertyDefL( Image::KMeteringModeProperty );
       
   137 	iRelatedSoundFilePropertyDef = &imageDef.GetPropertyDefL( Image::KRelatedSoundFileProperty );
       
   138 	iFocalPlaneResolutionUnitPropertyDef = &imageDef.GetPropertyDefL( Image::KFocalPlaneResolutionUnitProperty );
       
   139 	iFocalPlaneXResolutionPropertyDef = &imageDef.GetPropertyDefL( Image::KFocalPlaneXResolutionProperty );
       
   140 	iFocalPlaneYResolutionPropertyDef = &imageDef.GetPropertyDefL( Image::KFocalPlaneYResolutionProperty );
       
   141 	iDraftPropertyDef = &imageDef.GetPropertyDefL( Image::KDraftProperty );
    80 	}
   142 	}
    81 
   143 
    82 CHarvesterImagePluginPropertyDefs* CHarvesterImagePluginPropertyDefs::NewL()
   144 CHarvesterImagePluginPropertyDefs* CHarvesterImagePluginPropertyDefs::NewL(CMdEObjectDef& aObjectDef)
    83     {
   145 	{
    84     CHarvesterImagePluginPropertyDefs* self = 
   146 	CHarvesterImagePluginPropertyDefs* self = 
    85         new (ELeave) CHarvesterImagePluginPropertyDefs();
   147 		new (ELeave) CHarvesterImagePluginPropertyDefs();
    86     return self;
   148 	CleanupStack::PushL( self );
    87     }
   149 	self->ConstructL( aObjectDef );
    88 
   150 	CleanupStack::Pop( self );
    89 void CHarvesterImagePluginPropertyDefs::SetByObjectDefL(CMdEObjectDef& aObjectDef)
   151 	return self;
    90     {
   152 	}
    91     CMdENamespaceDef& nsDef = aObjectDef.NamespaceDef();
       
    92 
       
    93     // Image property definitions
       
    94     CMdEObjectDef& objectDef = nsDef.GetObjectDefL( Object::KBaseObject );
       
    95     iCreationDatePropertyDef = &objectDef.GetPropertyDefL( Object::KCreationDateProperty );
       
    96     iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( Object::KLastModifiedDateProperty );
       
    97     iSizePropertyDef = &objectDef.GetPropertyDefL( Object::KSizeProperty );
       
    98     iTimeOffsetPropertyDef = &objectDef.GetPropertyDefL( Object::KTimeOffsetProperty );
       
    99     iItemTypePropertyDef = &objectDef.GetPropertyDefL( Object::KItemTypeProperty );
       
   100     iDefaultFolderPropertyDef = &objectDef.GetPropertyDefL( Object::KInDefaultFolder );
       
   101 
       
   102     // Media property definitions
       
   103     CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MediaObject::KMediaObject );
       
   104     iWidthPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KWidthProperty );
       
   105     iHeightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KHeightProperty );
       
   106     iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KDescriptionProperty );
       
   107     iCommentPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCommentProperty );
       
   108     iReleaseDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KReleaseDateProperty );
       
   109     iCopyrightPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCopyrightProperty );
       
   110     iCaptureDatePropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KCaptureDateProperty );
       
   111     iResolutionUnitPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KResolutionUnitProperty );
       
   112     iArtistPropertyDef = &mediaDef.GetPropertyDefL( MediaObject::KArtistProperty );
       
   113 
       
   114     // Image property definitions
       
   115     CMdEObjectDef& imageDef = nsDef.GetObjectDefL( Image::KImageObject );
       
   116     iPixelYDimensionPropertyDef = &imageDef.GetPropertyDefL( Image::KPixelYDimensionProperty );
       
   117     iPixelXDimensionPropertyDef = &imageDef.GetPropertyDefL( Image::KPixelXDimensionProperty );
       
   118     iBitsPerSamplePropertyDef = &imageDef.GetPropertyDefL( Image::KBitsPerSampleProperty );
       
   119     iFrameCountPropertyDef = &imageDef.GetPropertyDefL( Image::KFrameCountProperty );
       
   120     iDateTimeOriginalPropertyDef = &imageDef.GetPropertyDefL( Image::KDateTimeOriginalProperty );
       
   121     iDateTimeDigitizedPropertyDef = &imageDef.GetPropertyDefL( Image::KDateTimeDigitizedProperty );
       
   122     iDateTimePropertyDef = &imageDef.GetPropertyDefL( Image::KDateTimeProperty );
       
   123     iWhiteBalancePropertyDef = &imageDef.GetPropertyDefL( Image::KWhiteBalanceProperty );
       
   124     iFlashPropertyDef = &imageDef.GetPropertyDefL( Image::KFlashProperty );
       
   125     iExposureProgramPropertyDef = &imageDef.GetPropertyDefL( Image::KExposureProgramProperty );
       
   126     iMakePropertyDef = &imageDef.GetPropertyDefL( Image::KMakeProperty );
       
   127     iModelPropertyDef = &imageDef.GetPropertyDefL( Image::KModelProperty );
       
   128     iOrientationPropertyDef = &imageDef.GetPropertyDefL( Image::KOrientationProperty );
       
   129     iXResolutionPropertyDef = &imageDef.GetPropertyDefL( Image::KXResolutionProperty );
       
   130     iYResolutionPropertyDef = &imageDef.GetPropertyDefL( Image::KYResolutionProperty );
       
   131     iYCbCrPositioningPropertyDef = &imageDef.GetPropertyDefL( Image::KYCbCrPositioningProperty );
       
   132     iExposureTimePropertyDef = &imageDef.GetPropertyDefL( Image::KExposureTimeProperty );
       
   133     iFNumberPropertyDef = &imageDef.GetPropertyDefL( Image::KFNumberProperty );
       
   134     iExifVersionPropertyDef = &imageDef.GetPropertyDefL( Image::KExifVersionProperty );
       
   135     iShutterSpeedValuePropertyDef = &imageDef.GetPropertyDefL( Image::KShutterSpeedValueProperty );
       
   136     iApertureValuePropertyDef = &imageDef.GetPropertyDefL( Image::KApertureValueProperty );
       
   137     iFocalLengthPropertyDef = &imageDef.GetPropertyDefL( Image::KFocalLengthProperty );
       
   138     iFlashPixVersionPropertyDef = &imageDef.GetPropertyDefL( Image::KFlashPixVersionProperty );
       
   139     iColourSpacePropertyDef = &imageDef.GetPropertyDefL( Image::KColourSpaceProperty );
       
   140     iISOSpeedRatingsPropertyDef = &imageDef.GetPropertyDefL( Image::KISOSpeedRatingsProperty );
       
   141     iComponentsConfigurationPropertyDef = &imageDef.GetPropertyDefL( Image::KComponentsConfigurationProperty );
       
   142     iExposureBiasValuePropertyDef = &imageDef.GetPropertyDefL( Image::KExposureBiasValueProperty );
       
   143     iSamplesPerPixelPropertyDef = &imageDef.GetPropertyDefL( Image::KSamplesPerPixelProperty );
       
   144     iThumbCompressionPropertyDef = &imageDef.GetPropertyDefL( Image::KThumbCompressionProperty );
       
   145     iThumbXResolutionPropertyDef = &imageDef.GetPropertyDefL( Image::KThumbXResolutionProperty );
       
   146     iThumbYResolutionPropertyDef = &imageDef.GetPropertyDefL( Image::KThumbYResolutionProperty );
       
   147     iThumbResolutionUnitPropertyDef = &imageDef.GetPropertyDefL( Image::KThumbResolutionUnitProperty );
       
   148     iFocalLengthIn35mmFilmPropertyDef = &imageDef.GetPropertyDefL( Image::KFocalLengthIn35mmFilmProperty );
       
   149     iMeteringModePropertyDef = &imageDef.GetPropertyDefL( Image::KMeteringModeProperty );
       
   150     iRelatedSoundFilePropertyDef = &imageDef.GetPropertyDefL( Image::KRelatedSoundFileProperty );
       
   151     iFocalPlaneResolutionUnitPropertyDef = &imageDef.GetPropertyDefL( Image::KFocalPlaneResolutionUnitProperty );
       
   152     iFocalPlaneXResolutionPropertyDef = &imageDef.GetPropertyDefL( Image::KFocalPlaneXResolutionProperty );
       
   153     iFocalPlaneYResolutionPropertyDef = &imageDef.GetPropertyDefL( Image::KFocalPlaneYResolutionProperty );
       
   154     iDraftPropertyDef = &imageDef.GetPropertyDefL( Image::KDraftProperty );
       
   155     }
       
   156 
   153 
   157 /**
   154 /**
   158 * Default constructor
   155 * Default constructor
   159 */
   156 */
   160 CHarvesterImagePlugin::CHarvesterImagePlugin() : CHarvesterPlugin(),
   157 CHarvesterImagePlugin::CHarvesterImagePlugin() : CHarvesterPlugin(),
   186 	
   183 	
   187 	if (iDecoder)
   184 	if (iDecoder)
   188 		{
   185 		{
   189 		iDecoder->Reset();
   186 		iDecoder->Reset();
   190 	    delete iDecoder;
   187 	    delete iDecoder;
   191 	    iDecoder = NULL;
       
   192 		}   
   188 		}   
   193     
   189     
   194     if (iExifUtil)
   190     if (iExifUtil)
   195 		{
   191 		{
   196 		delete iExifUtil;
   192 		delete iExifUtil;
   197 		iExifUtil = NULL;
       
   198 		}
   193 		}
   199    	
   194    	
   200     delete iPropDefs;
   195     delete iPropDefs;
   201     iPropDefs = NULL;
       
   202     
   196     
   203     delete iPhoneImagesPath;
   197     delete iPhoneImagesPath;
   204     iPhoneImagesPath = NULL;
       
   205     delete iMmcImagesPath;
   198     delete iMmcImagesPath;
   206     iMmcImagesPath = NULL;
       
   207     
   199     
   208     iMimeTypeMappings.Close();
   200     iMimeTypeMappings.Close();
   209     iFbs.Disconnect();
   201     iFbs.Disconnect();
   210 	}
   202 	}
   211 
   203 
   216 	{
   208 	{
   217 	WRITELOG( "CHarvesterImagePlugin::ConstructL()" );
   209 	WRITELOG( "CHarvesterImagePlugin::ConstructL()" );
   218 	iDecoder = CBufferedImageDecoder::NewL( iFs );
   210 	iDecoder = CBufferedImageDecoder::NewL( iFs );
   219 	iExifUtil = CHarvesterExifUtil::NewL();
   211 	iExifUtil = CHarvesterExifUtil::NewL();
   220     User::LeaveIfError( iFbs.Connect() );
   212     User::LeaveIfError( iFbs.Connect() );
   221 
       
   222     iPropDefs = CHarvesterImagePluginPropertyDefs::NewL(); 
       
   223 
   213 
   224     TLinearOrder< TMimeTypeMapping<TImageMetadataHandling> > cmp(
   214     TLinearOrder< TMimeTypeMapping<TImageMetadataHandling> > cmp(
   225     		TMimeTypeMapping<TImageMetadataHandling>::CompareFunction);
   215     		TMimeTypeMapping<TImageMetadataHandling>::CompareFunction);
   226 
   216 
   227     User::LeaveIfError( iMimeTypeMappings.InsertInOrder( TMimeTypeMapping<TImageMetadataHandling>(
   217     User::LeaveIfError( iMimeTypeMappings.InsertInOrder( TMimeTypeMapping<TImageMetadataHandling>(
   404     
   394     
   405     if( dataExtracted )
   395     if( dataExtracted )
   406         {
   396         {
   407         CMdEProperty* prop = NULL;
   397         CMdEProperty* prop = NULL;
   408         CMdEObjectDef& objectDef = *aFileData.iImageDef;
   398         CMdEObjectDef& objectDef = *aFileData.iImageDef;
   409 		
   399         
   410         InitPropDefsL( objectDef );        
   400         if( !iPropDefs )
       
   401         	{
       
   402         	iPropDefs = CHarvesterImagePluginPropertyDefs::NewL( objectDef );
       
   403         	// Prefetch max text lengt for validity checking
       
   404         	iMaxTextLength = iPropDefs->iCopyrightPropertyDef->MaxTextLengthL();
       
   405         	}
   411         
   406         
   412         aMetadataObject.Property( *iPropDefs->iSizePropertyDef, prop );
   407         aMetadataObject.Property( *iPropDefs->iSizePropertyDef, prop );
   413         if( prop )
   408         if( prop )
   414             {
   409             {
   415             aFileData.iFileSize  = prop->Uint32ValueL();
   410             aFileData.iFileSize  = prop->Uint32ValueL();
   695 		TBool aIsAdd )
   690 		TBool aIsAdd )
   696     {
   691     {
   697     WRITELOG( "CHarvesterImagePlugin::HandleObjectPropertiesL() - New MdE object" );
   692     WRITELOG( "CHarvesterImagePlugin::HandleObjectPropertiesL() - New MdE object" );
   698     
   693     
   699     CMdEObject& mdeObject = aHarvesterData.MdeObject();
   694     CMdEObject& mdeObject = aHarvesterData.MdeObject();
   700 	
   695     
   701     InitPropDefsL( mdeObject.Def() );
   696     if( !iPropDefs )
       
   697     	{
       
   698     	iPropDefs = CHarvesterImagePluginPropertyDefs::NewL( mdeObject.Def() );
       
   699     	// Prefetch max text lengt for validity checking
       
   700     	iMaxTextLength = iPropDefs->iCopyrightPropertyDef->MaxTextLengthL();
       
   701     	}
   702 
   702 
   703     TTimeIntervalSeconds timeOffsetSeconds = User::UTCOffset();
   703     TTimeIntervalSeconds timeOffsetSeconds = User::UTCOffset();
   704 
   704 
   705     TTime localModifiedDate = aFileData.iModified + timeOffsetSeconds;
   705     TTime localModifiedDate = aFileData.iModified + timeOffsetSeconds;
   706     
   706     
  1082         return KErrNone;
  1082         return KErrNone;
  1083         }
  1083         }
  1084     
  1084     
  1085     return KErrNotSupported;
  1085     return KErrNotSupported;
  1086     }
  1086     }
  1087 
       
  1088 void CHarvesterImagePlugin::InitPropDefsL( CMdEObjectDef& aObjectDef )
       
  1089     {
       
  1090     if( !iPropDefs->iCreationDatePropertyDef )
       
  1091         {
       
  1092         iPropDefs->SetByObjectDefL( aObjectDef );
       
  1093         // Prefetch max text lengt for validity checking
       
  1094         iMaxTextLength = iPropDefs->iCopyrightPropertyDef->MaxTextLengthL();
       
  1095         }
       
  1096     }
       
  1097