harvester/harvesterplugins/ImagePlugin/src/harvesterimageplugin.cpp
branchRCL_3
changeset 19 b73252188534
parent 13 4a4892eec172
equal deleted inserted replaced
18:63c982fb92f2 19:b73252188534
    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 )
    73 	{
    74 	{
    74 	}
    75 	}
    75 
    76 
    76 void CHarvesterImagePluginPropertyDefs::ConstructL(CMdEObjectDef& aObjectDef)
    77 void CHarvesterImagePluginPropertyDefs::ConstructL( CMdEObjectDef& aObjectDef )
    77 	{
    78 	{
    78 	CMdENamespaceDef& nsDef = aObjectDef.NamespaceDef();
    79     SetByObjectDefL( aObjectDef );
    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 );
       
   142 	}
    80 	}
   143 
    81 
   144 CHarvesterImagePluginPropertyDefs* CHarvesterImagePluginPropertyDefs::NewL(CMdEObjectDef& aObjectDef)
    82 CHarvesterImagePluginPropertyDefs* CHarvesterImagePluginPropertyDefs::NewL()
   145 	{
    83     {
   146 	CHarvesterImagePluginPropertyDefs* self = 
    84     CHarvesterImagePluginPropertyDefs* self = 
   147 		new (ELeave) CHarvesterImagePluginPropertyDefs();
    85         new (ELeave) CHarvesterImagePluginPropertyDefs();
   148 	CleanupStack::PushL( self );
    86     return self;
   149 	self->ConstructL( aObjectDef );
    87     }
   150 	CleanupStack::Pop( self );
    88 
   151 	return self;
    89 void CHarvesterImagePluginPropertyDefs::SetByObjectDefL(CMdEObjectDef& aObjectDef)
   152 	}
    90     {
       
    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     }
   153 
   156 
   154 /**
   157 /**
   155 * Default constructor
   158 * Default constructor
   156 */
   159 */
   157 CHarvesterImagePlugin::CHarvesterImagePlugin() : CHarvesterPlugin(),
   160 CHarvesterImagePlugin::CHarvesterImagePlugin() : CHarvesterPlugin(),
   183 	
   186 	
   184 	if (iDecoder)
   187 	if (iDecoder)
   185 		{
   188 		{
   186 		iDecoder->Reset();
   189 		iDecoder->Reset();
   187 	    delete iDecoder;
   190 	    delete iDecoder;
       
   191 	    iDecoder = NULL;
   188 		}   
   192 		}   
   189     
   193     
   190     if (iExifUtil)
   194     if (iExifUtil)
   191 		{
   195 		{
   192 		delete iExifUtil;
   196 		delete iExifUtil;
       
   197 		iExifUtil = NULL;
   193 		}
   198 		}
   194    	
   199    	
   195     delete iPropDefs;
   200     delete iPropDefs;
       
   201     iPropDefs = NULL;
   196     
   202     
   197     delete iPhoneImagesPath;
   203     delete iPhoneImagesPath;
       
   204     iPhoneImagesPath = NULL;
   198     delete iMmcImagesPath;
   205     delete iMmcImagesPath;
       
   206     iMmcImagesPath = NULL;
   199     
   207     
   200     iMimeTypeMappings.Close();
   208     iMimeTypeMappings.Close();
   201     iFbs.Disconnect();
   209     iFbs.Disconnect();
   202 	}
   210 	}
   203 
   211 
   208 	{
   216 	{
   209 	WRITELOG( "CHarvesterImagePlugin::ConstructL()" );
   217 	WRITELOG( "CHarvesterImagePlugin::ConstructL()" );
   210 	iDecoder = CBufferedImageDecoder::NewL( iFs );
   218 	iDecoder = CBufferedImageDecoder::NewL( iFs );
   211 	iExifUtil = CHarvesterExifUtil::NewL();
   219 	iExifUtil = CHarvesterExifUtil::NewL();
   212     User::LeaveIfError( iFbs.Connect() );
   220     User::LeaveIfError( iFbs.Connect() );
       
   221 
       
   222     iPropDefs = CHarvesterImagePluginPropertyDefs::NewL(); 
   213 
   223 
   214     TLinearOrder< TMimeTypeMapping<TImageMetadataHandling> > cmp(
   224     TLinearOrder< TMimeTypeMapping<TImageMetadataHandling> > cmp(
   215     		TMimeTypeMapping<TImageMetadataHandling>::CompareFunction);
   225     		TMimeTypeMapping<TImageMetadataHandling>::CompareFunction);
   216 
   226 
   217     User::LeaveIfError( iMimeTypeMappings.InsertInOrder( TMimeTypeMapping<TImageMetadataHandling>(
   227     User::LeaveIfError( iMimeTypeMappings.InsertInOrder( TMimeTypeMapping<TImageMetadataHandling>(
   394     
   404     
   395     if( dataExtracted )
   405     if( dataExtracted )
   396         {
   406         {
   397         CMdEProperty* prop = NULL;
   407         CMdEProperty* prop = NULL;
   398         CMdEObjectDef& objectDef = *aFileData.iImageDef;
   408         CMdEObjectDef& objectDef = *aFileData.iImageDef;
   399         
   409 		
   400         if( !iPropDefs )
   410         InitPropDefsL( objectDef );        
   401         	{
       
   402         	iPropDefs = CHarvesterImagePluginPropertyDefs::NewL( objectDef );
       
   403         	// Prefetch max text lengt for validity checking
       
   404         	iMaxTextLength = iPropDefs->iCopyrightPropertyDef->MaxTextLengthL();
       
   405         	}
       
   406         
   411         
   407         aMetadataObject.Property( *iPropDefs->iSizePropertyDef, prop );
   412         aMetadataObject.Property( *iPropDefs->iSizePropertyDef, prop );
   408         if( prop )
   413         if( prop )
   409             {
   414             {
   410             aFileData.iFileSize  = prop->Uint32ValueL();
   415             aFileData.iFileSize  = prop->Uint32ValueL();
   690 		TBool aIsAdd )
   695 		TBool aIsAdd )
   691     {
   696     {
   692     WRITELOG( "CHarvesterImagePlugin::HandleObjectPropertiesL() - New MdE object" );
   697     WRITELOG( "CHarvesterImagePlugin::HandleObjectPropertiesL() - New MdE object" );
   693     
   698     
   694     CMdEObject& mdeObject = aHarvesterData.MdeObject();
   699     CMdEObject& mdeObject = aHarvesterData.MdeObject();
   695     
   700 	
   696     if( !iPropDefs )
   701     InitPropDefsL( mdeObject.Def() );
   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