--- a/harvester/harvesterplugins/ImagePlugin/src/harvesterimageplugin.cpp Tue Feb 02 00:24:33 2010 +0200
+++ b/harvester/harvesterplugins/ImagePlugin/src/harvesterimageplugin.cpp Fri Feb 19 23:14:48 2010 +0200
@@ -25,6 +25,7 @@
#include "mdsutils.h"
#include "harvesterexifutil.h"
#include "harvesterimageplugin.h"
+#include "harvestercommon.h"
#include "mdeobjectwrapper.h"
using namespace MdeConstants;
@@ -254,6 +255,8 @@
User::LeaveIfError( iMimeTypeMappings.InsertInOrder( TMimeTypeMapping<TImageMetadataHandling>(
KExtOtb(), KOtbMime(), EOtherHandling ), cmp ) );
+
+ SetPriority( KHarvesterPriorityHarvestingPlugin + 1 );
}
void CHarvesterImagePlugin::HarvestL( CHarvesterData* aHD )
@@ -329,6 +332,34 @@
}
// ---------------------------------------------------------------------------
+// CHarvesterImagePlugin::GetMimeType (from CHarvesterPlugin)
+// ---------------------------------------------------------------------------
+//
+void CHarvesterImagePlugin::GetMimeType( const TDesC& aUri, TDes& aMimeType )
+ {
+ aMimeType.Zero();
+
+ TPtrC ext;
+ if( !MdsUtils::GetExt( aUri, ext ) )
+ {
+ return;
+ }
+
+ TMimeTypeMapping<TImageMetadataHandling> finder(ext);
+ TLinearOrder< TMimeTypeMapping<TImageMetadataHandling> > cmp(
+ TMimeTypeMapping<TImageMetadataHandling>::CompareFunction);
+
+ const TInt pos = iMimeTypeMappings.FindInOrder( finder, cmp );
+
+ if ( pos == KErrNotFound )
+ {
+ return;
+ }
+
+ aMimeType = iMimeTypeMappings[pos].iMimeType;
+ }
+
+// ---------------------------------------------------------------------------
// GatherData
// ---------------------------------------------------------------------------
//
@@ -417,8 +448,6 @@
// Exif couldn't be found. Open the image with ICL decoder instead.
WRITELOG( "CHarvesterImagePlugin::GatherData() - Exif could not be read. Using ICL." );
- iDecoder->Reset();
-
TPtr8 imageDataPtr = aFileData.iImageData->Des();
TRAP( err, iDecoder->OpenL(imageDataPtr, aFileData.iMime8,
CImageDecoder::TOptions( CImageDecoder::EPreferFastDecode | CImageDecoder::EOptionIgnoreExifMetaData ) ) );
@@ -427,6 +456,7 @@
if ( err != KErrNone )
{
WRITELOG1( "CHarvesterImagePlugin::GatherData() - ERROR: Decoder could not open image data! Code %d", err );
+ iDecoder->Reset();
return KErrCompletion; // metadata item still can be created, thus KErrCompletion
}
@@ -448,6 +478,7 @@
if ( readStatus != KErrNone )
{
CleanupStack::PopAndDestroy( additionalData );
+ iDecoder->Reset();
return KErrCompletion;
}
@@ -463,6 +494,7 @@
if ( err || !iDecoder->ValidDecoder() )
{
WRITELOG( "CHarvesterImagePlugin::GatherData() - ERROR: no valid decoder" );
+ iDecoder->Reset();
return KErrCompletion; // metadata item still can be created, thus KErrCompletion
}
}
@@ -475,6 +507,8 @@
aFileData.iImageWidth = imageSize.iWidth;
aFileData.iImageHeight = imageSize.iHeight;
aFileData.iBitsPerPixel = info.iBitsPerPixel;
+
+ iDecoder->Reset();
}
WRITELOG( "CHarvesterImagePlugin::GatherData() - end" );
@@ -504,7 +538,7 @@
TLinearOrder< TMimeTypeMapping<TImageMetadataHandling> > cmp(
TMimeTypeMapping<TImageMetadataHandling>::CompareFunction);
- TInt pos = iMimeTypeMappings.FindInOrder( finder, cmp );
+ const TInt pos = iMimeTypeMappings.FindInOrder( finder, cmp );
TImageMetadataHandling handler( EOtherHandling );
@@ -608,9 +642,9 @@
TTime localModifiedDate = aFileData.iModified + timeOffsetSeconds;
- // Object - Creation date
if( ! mdeObject.Placeholder() )
{
+ // Object - Creation date
if ( aFileData.iExifSupported && aHd.iDateOriginal8 )
{
TTime originalTime = iExifUtil->ConvertExifDateTimeToSymbianTimeL(
@@ -621,12 +655,15 @@
{
CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iCreationDatePropertyDef, &localModifiedDate, aIsAdd );
}
- }
-
- // Object - last aFileData.iModified date
- if( ! mdeObject.Placeholder() )
- {
- CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iLastModifiedDatePropertyDef, &aFileData.iModified, aIsAdd );
+
+ // Object - last aFileData.iModified date
+ CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iLastModifiedDatePropertyDef, &aFileData.iModified, aIsAdd );
+
+ // Object - Size
+ CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iSizePropertyDef, &aFileData.iFileSize, aIsAdd );
+
+ // Item Type
+ CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iItemTypePropertyDef, &aFileData.iMime16, aIsAdd );
}
if( aFileData.iJpeg )
@@ -635,15 +672,6 @@
TInt16 timeOffsetMinutes = timeOffsetSeconds.Int() / 60;
CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iTimeOffsetPropertyDef, &timeOffsetMinutes, aIsAdd );
}
-
- // Object - Size
- if( ! mdeObject.Placeholder() )
- {
- CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iSizePropertyDef, &aFileData.iFileSize, aIsAdd );
- }
-
- // Item Type
- CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iItemTypePropertyDef, &aFileData.iMime16, aIsAdd );
// MediaObject - Width
if ( aFileData.iExifSupported )