harvester/harvesterplugins/OMADRMPlugin/src/harvesteromadrmplugin.cpp
changeset 45 a93990e5815e
parent 28 c461c7fa72c2
child 52 40db28bb26b8
equal deleted inserted replaced
36:aa5a574040a4 45:a93990e5815e
    18 #include <e32base.h>
    18 #include <e32base.h>
    19 #include <caf/caf.h>
    19 #include <caf/caf.h>
    20 #include <pathinfo.h>
    20 #include <pathinfo.h>
    21 
    21 
    22 #include "mdsutils.h"
    22 #include "mdsutils.h"
       
    23 #include "harvesterexifutil.h"
    23 #include "harvesteromadrmplugin.h"
    24 #include "harvesteromadrmplugin.h"
    24 #include "harvesterlog.h"
    25 #include "harvesterlog.h"
    25 #include "harvestercommon.h"
    26 #include "harvestercommon.h"
    26 #include "mdeobjectwrapper.h"
    27 #include "mdeobjectwrapper.h"
    27 #include "mdscommoninternal.h"
    28 #include "mdscommoninternal.h"
    31 #include <mdeobjectdef.h>
    32 #include <mdeobjectdef.h>
    32 #include <mdeobject.h>
    33 #include <mdeobject.h>
    33 #include <mdetextproperty.h>
    34 #include <mdetextproperty.h>
    34 #include <mdenamespacedef.h>
    35 #include <mdenamespacedef.h>
    35 #include <mdeconstants.h>
    36 #include <mdeconstants.h>
       
    37 #include <imageconversion.h>
       
    38 
       
    39 using namespace MdeConstants;
    36 
    40 
    37 _LIT(KImage, "Image");
    41 _LIT(KImage, "Image");
    38 _LIT(KVideo, "Video");
    42 _LIT(KVideo, "Video");
    39 _LIT(KAudio, "Audio");
    43 _LIT(KAudio, "Audio");
    40 _LIT(KRmMimetype, "realmedia");
    44 _LIT(KRmMimetype, "realmedia");
    42 _LIT( KSvgMime, "image/svg+xml" );
    46 _LIT( KSvgMime, "image/svg+xml" );
    43 _LIT( KRingingToneMime, "application/vnd.nokia.ringing-tone" );
    47 _LIT( KRingingToneMime, "application/vnd.nokia.ringing-tone" );
    44 
    48 
    45 _LIT(KInUse, "InUse");
    49 _LIT(KInUse, "InUse");
    46 
    50 
    47 CHarvesterOmaDrmPluginPropertyDefs::CHarvesterOmaDrmPluginPropertyDefs() : CBase()
    51 CHarvesterOmaDrmPluginPropertyDefs::CHarvesterOmaDrmPluginPropertyDefs() : CBase(),
    48 	{
    52     iCreationDatePropertyDef( NULL )
    49 	}
    53 	{
    50 
    54 	}
    51 void CHarvesterOmaDrmPluginPropertyDefs::ConstructL(CMdEObjectDef& aObjectDef)
    55 
       
    56 void CHarvesterOmaDrmPluginPropertyDefs::ConstructL( CMdEObjectDef& aObjectDef )
       
    57     {
       
    58     SetByObjectDefL( aObjectDef );
       
    59     }
       
    60 
       
    61 CHarvesterOmaDrmPluginPropertyDefs* CHarvesterOmaDrmPluginPropertyDefs::NewL()
       
    62     {
       
    63     CHarvesterOmaDrmPluginPropertyDefs* self = 
       
    64         new (ELeave) CHarvesterOmaDrmPluginPropertyDefs();
       
    65     return self;
       
    66     }
       
    67 
       
    68 void CHarvesterOmaDrmPluginPropertyDefs::SetByObjectDefL( CMdEObjectDef& aObjectDef )
    52 	{
    69 	{
    53 	CMdENamespaceDef& nsDef = aObjectDef.NamespaceDef();
    70 	CMdENamespaceDef& nsDef = aObjectDef.NamespaceDef();
    54 	
    71 	
    55 	// Common property definitions
    72 	// Common property definitions
    56 	CMdEObjectDef& objectDef = nsDef.GetObjectDefL( MdeConstants::Object::KBaseObject );
    73 	CMdEObjectDef& objectDef = nsDef.GetObjectDefL( MdeConstants::Object::KBaseObject );
    63 
    80 
    64 	CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MdeConstants::MediaObject::KMediaObject );
    81 	CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MdeConstants::MediaObject::KMediaObject );
    65 	iDrmPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDRMProperty );
    82 	iDrmPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDRMProperty );
    66 	iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDescriptionProperty );
    83 	iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDescriptionProperty );
    67 	iAuthorPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KAuthorProperty );
    84 	iAuthorPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KAuthorProperty );
       
    85 
       
    86 	// Media property definitions
       
    87 	iWidthPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KWidthProperty );
       
    88 	iHeightPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KHeightProperty );
       
    89 
       
    90 	// Image property definitions
       
    91 	CMdEObjectDef& imageDef = nsDef.GetObjectDefL( MdeConstants::Image::KImageObject );
       
    92 	iBitsPerSamplePropertyDef = &imageDef.GetPropertyDefL( MdeConstants::Image::KBitsPerSampleProperty );
       
    93 	iFrameCountPropertyDef = &imageDef.GetPropertyDefL( MdeConstants::Image::KFrameCountProperty );
    68 	iGenrePropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KGenreProperty );
    94 	iGenrePropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KGenreProperty );
    69 	}
       
    70 
       
    71 CHarvesterOmaDrmPluginPropertyDefs* CHarvesterOmaDrmPluginPropertyDefs::NewL(CMdEObjectDef& aObjectDef)
       
    72 	{
       
    73 	CHarvesterOmaDrmPluginPropertyDefs* self = 
       
    74 		new (ELeave) CHarvesterOmaDrmPluginPropertyDefs();
       
    75 	CleanupStack::PushL( self );
       
    76 	self->ConstructL( aObjectDef );
       
    77 	CleanupStack::Pop( self );
       
    78 	return self;
       
    79 	}
    95 	}
    80 
    96 
    81 /**
    97 /**
    82 * Default constructor
    98 * Default constructor
    83 */
    99 */
   106 */
   122 */
   107 CHarvesterOMADRMPlugin::~CHarvesterOMADRMPlugin()
   123 CHarvesterOMADRMPlugin::~CHarvesterOMADRMPlugin()
   108 	{
   124 	{
   109 	WRITELOG("CHarvesterOMADRMPlugin::~CHarvesterOMADRMPlugin()");
   125 	WRITELOG("CHarvesterOMADRMPlugin::~CHarvesterOMADRMPlugin()");
   110 	
   126 	
       
   127 	iFs.Close();
       
   128 
       
   129 	delete iPropDefs;
       
   130     iPropDefs = NULL;
       
   131 
   111     delete iPhoneImagesPath;
   132     delete iPhoneImagesPath;
       
   133     iPhoneImagesPath = NULL;
   112     delete iMmcImagesPath;
   134     delete iMmcImagesPath;
       
   135     iMmcImagesPath = NULL;
   113     
   136     
   114     delete iPhoneVideosPath;
   137     delete iPhoneVideosPath;
       
   138     iPhoneVideosPath = NULL;
   115     delete iMmcVideosPath;
   139     delete iMmcVideosPath;
       
   140     iMmcVideosPath = NULL;
   116     
   141     
   117     delete iPhoneSoundsPath;
   142     delete iPhoneSoundsPath;
       
   143     iPhoneSoundsPath = NULL;
   118     delete iMmcSoundsPath;
   144     delete iMmcSoundsPath;
   119 	
   145     iMmcSoundsPath = NULL;
   120 	delete iPropDefs;
       
   121 	}
   146 	}
   122 
   147 
   123 /**
   148 /**
   124 * 2nd phase constructor
   149 * 2nd phase constructor
   125 */
   150 */
   126 void CHarvesterOMADRMPlugin::ConstructL()
   151 void CHarvesterOMADRMPlugin::ConstructL()
   127 	{
   152 	{
   128 	WRITELOG( "CHarvesterOMADRMPlugin::ConstructL()" );
   153 	WRITELOG( "CHarvesterOMADRMPlugin::ConstructL()" );
   129 	
   154     SetPriority( KHarvesterPriorityHarvestingPlugin - 1 );	
       
   155     
       
   156     User::LeaveIfError( iFs.Connect() );
       
   157 	
       
   158     iPropDefs = CHarvesterOmaDrmPluginPropertyDefs::NewL();
       
   159     
   130 	TFileName phoneRoot = PathInfo::PhoneMemoryRootPath();
   160 	TFileName phoneRoot = PathInfo::PhoneMemoryRootPath();
   131 	TFileName mmcRoot = PathInfo::MemoryCardRootPath();
   161 	TFileName mmcRoot = PathInfo::MemoryCardRootPath();
   132 	
   162 	
   133 	TFileName images = PathInfo::ImagesPath();
   163 	TFileName images = PathInfo::ImagesPath();
   134 	
   164 	
   159     TFileName mmcSoundPath( mmcRoot );
   189     TFileName mmcSoundPath( mmcRoot );
   160     mmcSoundPath.Append( sounds );
   190     mmcSoundPath.Append( sounds );
   161     iMmcSoundsPath = mmcSoundPath.Right( mmcSoundPath.Length() - 1 ).AllocL();
   191     iMmcSoundsPath = mmcSoundPath.Right( mmcSoundPath.Length() - 1 ).AllocL();
   162 	}
   192 	}
   163 
   193 
   164 void CHarvesterOMADRMPlugin::HarvestL( CHarvesterData* aHD )
   194 void CHarvesterOMADRMPlugin::HarvestL( CHarvesterData* aHarvesterData )
   165 	{
   195 	{
   166     CMdEObject& mdeObject = aHD->MdeObject();
   196 	WRITELOG( "CHarvesterImagePlugin::HarvestL()" );
   167     CDRMHarvestData* fileData = CDRMHarvestData::NewL();
   197     CMdEObject& mdeObject = aHarvesterData->MdeObject();
       
   198 	CDRMHarvestData* drmHarvestData = CDRMHarvestData::NewL();
       
   199 	CleanupStack::PushL( drmHarvestData );
       
   200 	
       
   201     CFileData* fileData = CFileData::NewL();
   168     CleanupStack::PushL( fileData );
   202     CleanupStack::PushL( fileData );
   169 
   203 
   170     TRAPD( error, GatherDataL( mdeObject, *fileData ) );
   204     CHarvestData* harvestData = CHarvestData::NewL();
   171     if ( error == KErrNone || error == KErrCompletion )
   205     CleanupStack::PushL( harvestData );
   172     	{
   206         
   173         TBool isNewObject( mdeObject.Id() == 0 );
   207     TInt errorCode( KErrNone );
   174         
   208     
   175         if ( isNewObject || mdeObject.Placeholder() )
   209     TRAPD( error, errorCode = GatherDataL( mdeObject, *drmHarvestData, *fileData, *harvestData ) );
   176             {
   210     
   177             TRAP( error, HandleObjectPropertiesL( *aHD, *fileData, ETrue ) );
   211     if ( error == KErrNone && (errorCode == KErrNone || errorCode == KErrCompletion ) ) // ok, something got harvested
       
   212         {
       
   213         if ( mdeObject.Id() == 0 || mdeObject.Placeholder() ) // is a new object or placeholder
       
   214             {
       
   215             TRAP_IGNORE( HandleObjectPropertiesL( *harvestData,  *drmHarvestData, *fileData, *aHarvesterData, ETrue ) );
   178             mdeObject.SetPlaceholder( EFalse );
   216             mdeObject.SetPlaceholder( EFalse );
   179             }
   217             }
   180         else
   218         else   // not a new object
   181             {
   219             {
   182             TRAP( error, HandleObjectPropertiesL( *aHD, *fileData, EFalse ) );
   220             TRAP_IGNORE( HandleObjectPropertiesL( *harvestData, *drmHarvestData, *fileData, *aHarvesterData, EFalse ) );
   183             }
   221             }
   184 
   222 
   185         if ( error != KErrNone )
   223         if ( error != KErrNone )
   186             {
   224             {
   187             WRITELOG1( "CHarvesterOMADRMPlugin::HarvestL() - Handling object failed: ", error );
   225             WRITELOG1( "CHarvesterOMADRMPlugin::HarvestL() - Handling object failed: ", error );
   188             }
   226             }
   189     	}
   227     	}
   190     else	
   228     else	
   191         {
   229         {
   192         WRITELOG1( "CHarvesterOMADRMPlugin::HarvestL() - TRAP error: %d", error );
   230         WRITELOG1( "CHarvesterOMADRMPlugin::HarvestL() - TRAP error: %d, errorCode %d", error );
   193         TInt convertedError = KErrNone;
   231         TInt convertedError = KErrNone;
   194         MdsUtils::ConvertTrapError( error, convertedError );
   232         MdsUtils::ConvertTrapError( error, convertedError );
   195         aHD->SetErrorCode( convertedError );
   233         aHarvesterData->SetErrorCode( convertedError );
   196         }
   234         }
   197 
   235 
   198     CleanupStack::PopAndDestroy( fileData );
   236     CleanupStack::PopAndDestroy( 3, drmHarvestData );
   199 	}
   237 	}
   200 
   238 
   201 // ---------------------------------------------------------------------------
   239 // ---------------------------------------------------------------------------
   202 // GatherDataL
   240 // GatherDataL
   203 // ---------------------------------------------------------------------------
   241 // ---------------------------------------------------------------------------
   204 //
   242 //
   205 void CHarvesterOMADRMPlugin::GatherDataL( CMdEObject& aMetadataObject,
   243 TInt CHarvesterOMADRMPlugin::GatherDataL( CMdEObject& aMetadataObject, CDRMHarvestData& aDRMharvestData, 
   206 		CDRMHarvestData& aVHD )
   244         CFileData& aFileData, CHarvestData& /*aHarvestData*/ )
   207     {
   245     {
   208     WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL" );
   246     WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL" );
   209     
   247     
   210     TEntry* entry = new (ELeave) TEntry();
   248     TEntry* entry = new (ELeave) TEntry();
   211     CleanupStack::PushL( entry );
   249     CleanupStack::PushL( entry );
   212     
   250     
   213     const TDesC& uri = aMetadataObject.Uri();
   251     const TDesC& uri = aMetadataObject.Uri();
   214     User::LeaveIfError( iFs.Entry( uri, *entry ) );
   252     User::LeaveIfError( iFs.Entry( uri, *entry ) );
   215     
   253     
   216     aVHD.iModified = entry->iModified;
   254     aDRMharvestData.iModified = entry->iModified;
   217     aVHD.iFileSize = (TUint)entry->iSize;
   255     aDRMharvestData.iFileSize = (TUint)entry->iSize;
   218     CleanupStack::PopAndDestroy( entry );
   256     CleanupStack::PopAndDestroy( entry );
   219     
   257     
   220     ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri );   
   258     ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri );   
   221     ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek );
   259     ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek );
   222     
   260     
   229     attrSet.AddL( ContentAccess::EAuthor );
   267     attrSet.AddL( ContentAccess::EAuthor );
   230     attrSet.AddL( ContentAccess::EGenre );
   268     attrSet.AddL( ContentAccess::EGenre );
   231 
   269 
   232     User::LeaveIfError( data->GetStringAttributeSet(attrSet) );
   270     User::LeaveIfError( data->GetStringAttributeSet(attrSet) );
   233     
   271     
   234     TInt err = attrSet.GetValue( ContentAccess::EDescription, aVHD.iDescription );
   272     TInt err = attrSet.GetValue( ContentAccess::EDescription, aDRMharvestData.iDescription );
   235     if ( err != KErrNone)
   273     if ( err != KErrNone)
   236         {
   274         {
   237         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting description failed %d", err );
   275         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting description failed %d", err );
   238         }
   276         }
   239         
   277         
   240     if ( aVHD.iDescription.Length() <= 0 )
   278     if ( aDRMharvestData.iDescription.Length() <= 0 )
   241         {
   279         {
   242         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no description" );
   280         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no description" );
   243         }
   281         }
   244     
   282     
   245     err = attrSet.GetValue( ContentAccess::EMimeType, aVHD.iMimetype );
   283     err = attrSet.GetValue( ContentAccess::EMimeType, aDRMharvestData.iMimetype );
   246     if ( err != KErrNone)
   284     if ( err != KErrNone)
   247         {
   285         {
   248         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting mimetype failed %d", err );
   286         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting mimetype failed %d", err );
   249         }
   287         }
   250         
   288         
   251     if ( aVHD.iMimetype.Length() <= 0 )
   289     if ( aDRMharvestData.iMimetype.Length() <= 0 )
   252         {
   290         {
   253         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no mimetype" );
   291         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no mimetype" );
   254         }
   292         }
   255     
   293     
   256     err = attrSet.GetValue( ContentAccess::ETitle, aVHD.iTitle );
   294     err = attrSet.GetValue( ContentAccess::ETitle, aDRMharvestData.iTitle );
   257     if ( err != KErrNone)
   295     if ( err != KErrNone)
   258         {
   296         {
   259         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting title failed %d", err );
   297         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting title failed %d", err );
   260         }
   298         }
   261         
   299         
   262     if ( aVHD.iTitle.Length() <= 0 )
   300     if ( aDRMharvestData.iTitle.Length() <= 0 )
   263         {
   301         {
   264         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no title" );
   302         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no title" );
   265         }
   303         }
   266     
   304     
   267     err = attrSet.GetValue( ContentAccess::EAuthor, aVHD.iAuthor );
   305     err = attrSet.GetValue( ContentAccess::EAuthor, aDRMharvestData.iAuthor );
   268     if ( err != KErrNone)
   306     if ( err != KErrNone)
   269         {
   307         {
   270         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting author failed %d", err );
   308         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting author failed %d", err );
   271         }
   309         }
   272         
   310         
   273     if ( aVHD.iAuthor.Length() <= 0 )
   311     if ( aDRMharvestData.iAuthor.Length() <= 0 )
   274         {
   312         {
   275         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no author" );
   313         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no author" );
   276         }
   314         }
   277 
   315 
   278     err = attrSet.GetValue( ContentAccess::EGenre, aVHD.iGenre );
   316     err = attrSet.GetValue( ContentAccess::EGenre, aDRMharvestData.iGenre );
   279     if ( err != KErrNone)
   317     if ( err != KErrNone)
   280         {
   318         {
   281         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting genre failed %d", err );
   319         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting genre failed %d", err );
   282         }
   320         }
   283         
   321         
   284     if ( aVHD.iGenre.Length() <= 0 )
   322     if ( aDRMharvestData.iGenre.Length() <= 0 )
   285         {
   323         {
   286         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no genre" );
   324         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no genre" );
   287         }
   325         }
   288     
   326     
   289     err = content->GetAttribute( ContentAccess::EIsProtected, aVHD.iDrmProtected );
   327     err = content->GetAttribute( ContentAccess::EIsProtected, aDRMharvestData.iDrmProtected );
   290     if ( err != KErrNone)
   328     if ( err != KErrNone)
   291         {
   329         {
   292         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting protection info failed %d", err );
   330         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting protection info failed %d", err );
   293         }
   331         }
   294         
   332       
   295     CleanupStack::PopAndDestroy( 3 ); // content, data, attrSet
   333     CImageDecoder* decoder = NULL;
       
   334 
       
   335     TRAP( err, decoder = CImageDecoder::FileNewL( iFs, uri, ContentAccess::EPeek, 
       
   336             ( CImageDecoder::TOptions )( CImageDecoder::EPreferFastDecode )));
       
   337 
       
   338     CleanupStack::PushL( decoder );
       
   339     
       
   340     if(decoder && !err)
       
   341         {
       
   342         WRITELOG( "CHarvesterImagePlugin::GatherData() - Image decoder has opened the file." );        
       
   343         // Get image width, frame count, height and bits per pixel from image decoder.
       
   344         const TFrameInfo info = decoder->FrameInfo( 0 );
       
   345         const TSize imageSize = info.iOverallSizeInPixels;
       
   346         const TInt framecount = decoder->FrameCount();
       
   347         aFileData.iFrameCount = framecount;
       
   348         aFileData.iImageWidth = imageSize.iWidth;
       
   349         aFileData.iImageHeight = imageSize.iHeight;
       
   350         aFileData.iBitsPerPixel = info.iBitsPerPixel;
       
   351         }
       
   352     else
       
   353         {
       
   354         WRITELOG1( "CHarvesterImagePlugin::GatherData() - ERROR: decoder %d", err );
       
   355         }
       
   356 
       
   357     CleanupStack::PopAndDestroy( 4 ); // content, data, attrSet, imagedecoder
       
   358     return KErrNone;
   296     }
   359     }
   297 
   360 
   298 // ---------------------------------------------------------------------------
   361 // ---------------------------------------------------------------------------
   299 // HandleObjectPropertiesL
   362 // HandleObjectPropertiesL
   300 // ---------------------------------------------------------------------------
   363 // ---------------------------------------------------------------------------
   301 //
   364 //
   302 void CHarvesterOMADRMPlugin::HandleObjectPropertiesL(
   365 void CHarvesterOMADRMPlugin::HandleObjectPropertiesL( CHarvestData& /*aHarvestData*/, CDRMHarvestData& aDRMharvestData, CFileData& aFileData, 
   303 		CHarvesterData& aHD,
   366         CHarvesterData& aHarvesterData, TBool aIsAdd )
   304 		CDRMHarvestData& aVHD,
       
   305 		TBool aIsAdd )
       
   306     {
   367     {
   307     WRITELOG("CHarvesterOMADRMPlugin - HandleNewObject ");
   368     WRITELOG("CHarvesterOMADRMPlugin - HandleNewObject ");
   308     CMdEObject& mdeObject = aHD.MdeObject();
   369     CMdEObject& mdeObject = aHarvesterData.MdeObject();
   309 
   370 
   310     if( !iPropDefs )
   371     InitPropDefsL( mdeObject.Def() );
   311     	{
       
   312     	CMdEObjectDef& objectDef = mdeObject.Def();
       
   313     	iPropDefs = CHarvesterOmaDrmPluginPropertyDefs::NewL( objectDef );
       
   314     	// Prefetch max text lengt for validity checking
       
   315     	iMaxTextLength = iPropDefs->iGenrePropertyDef->MaxTextLengthL();
       
   316     	}
       
   317     
   372     
   318     TTimeIntervalSeconds timeOffset = User::UTCOffset();
   373     TTimeIntervalSeconds timeOffset = User::UTCOffset();
       
   374     
       
   375     TPtrC objectDefName( mdeObject.Def().Name());
   319     
   376     
   320     if( ! mdeObject.Placeholder() )
   377     if( ! mdeObject.Placeholder() )
   321     	{
   378     	{
   322     	// Creation date
   379     	// Creation date
   323     	TTime localTime = aVHD.iModified + timeOffset;
   380     	TTime localTime = aDRMharvestData.iModified + timeOffset;
   324     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   381     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   325     			*iPropDefs->iCreationDatePropertyDef, &localTime, aIsAdd );
   382     			*iPropDefs->iCreationDatePropertyDef, &localTime, aIsAdd );
   326     	// Last modified date
   383     	// Last modified date
   327     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   384     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   328     			*iPropDefs->iLastModifiedDatePropertyDef, &aVHD.iModified, aIsAdd );
   385     			*iPropDefs->iLastModifiedDatePropertyDef, &aDRMharvestData.iModified, aIsAdd );
   329     	// File size
   386     	// File size
   330     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   387     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   331     			*iPropDefs->iSizePropertyDef, &aVHD.iFileSize, aIsAdd );
   388     			*iPropDefs->iSizePropertyDef, &aDRMharvestData.iFileSize, aIsAdd );
   332 
   389 
   333     	TPtrC objectDefName( mdeObject.Def().Name() );
   390     	TPtrC objectDefName( mdeObject.Def().Name());
       
   391     	
   334         if( objectDefName == MdeConstants::Image::KImageObject )
   392         if( objectDefName == MdeConstants::Image::KImageObject )
   335             {
   393             {
   336             const TDesC& uri = mdeObject.Uri();
   394             const TDesC& uri = mdeObject.Uri();
   337             if( uri.FindF( iMmcImagesPath->Des()) != KErrNotFound ||
   395             if( uri.FindF( iMmcImagesPath->Des()) != KErrNotFound ||
   338                 uri.FindF( iPhoneImagesPath->Des()) != KErrNotFound ||
   396                 uri.FindF( iPhoneImagesPath->Des()) != KErrNotFound ||
   379                 }     
   437                 }     
   380             }
   438             }
   381     	}
   439     	}
   382         
   440         
   383     // Item Type
   441     // Item Type
   384     if(aVHD.iMimetype.Length() > 0)
   442     if(aDRMharvestData.iMimetype.Length() > 0)
   385         {
   443         {
   386         TBool isAdd( EFalse );
   444         TBool isAdd( EFalse );
   387         CMdEProperty* prop = NULL;
   445         CMdEProperty* prop = NULL;
   388         TInt index = mdeObject.Property( *iPropDefs->iItemTypePropertyDef, prop );
   446         TInt index = mdeObject.Property( *iPropDefs->iItemTypePropertyDef, prop );
   389         if( index < 0 )
   447         if( index < 0 )
   390             {
   448             {
   391             isAdd = ETrue;
   449             isAdd = ETrue;
   392             }
   450             }
   393         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   451         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   394                 *iPropDefs->iItemTypePropertyDef, &aVHD.iMimetype, isAdd );
   452                 *iPropDefs->iItemTypePropertyDef, &aDRMharvestData.iMimetype, isAdd );
   395         }
   453         }
   396     
   454     
   397     // DRM protection
   455     // DRM protection
   398     CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   456     CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   399     		*iPropDefs->iDrmPropertyDef, &aVHD.iDrmProtected, aIsAdd );
   457     		*iPropDefs->iDrmPropertyDef, &aDRMharvestData.iDrmProtected, aIsAdd );
   400     
   458     
   401     // Title (is set from URI by default)
   459     // Title (is set from URI by default)
   402     if( aVHD.iTitle.Length() > 0 && aVHD.iTitle.Length() < KMaxTitleFieldLength )
   460     if( aDRMharvestData.iTitle.Length() > 0 && aDRMharvestData.iTitle.Length() < KMaxTitleFieldLength )
   403     	{
   461     	{
   404     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   462     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   405     			*iPropDefs->iTitlePropertyDef, &aVHD.iTitle, EFalse );
   463     			*iPropDefs->iTitlePropertyDef, &aDRMharvestData.iTitle, EFalse );
   406     	}
   464     	}
   407     // Description
   465     // Description
   408     if( aVHD.iDescription.Length() > 0 && aVHD.iDescription.Length() < iMaxTextLength )
   466     if( aDRMharvestData.iDescription.Length() > 0 && aDRMharvestData.iDescription.Length() < iMaxTextLength )
   409     	{
   467     	{
   410     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   468     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   411     			*iPropDefs->iDescriptionPropertyDef, &aVHD.iDescription, aIsAdd );
   469     			*iPropDefs->iDescriptionPropertyDef, &aDRMharvestData.iDescription, aIsAdd );
   412     	}   
   470     	}   
   413     // Author
   471     // Author
   414     if( aVHD.iAuthor.Length() > 0 && aVHD.iAuthor.Length() < iMaxTextLength )
   472     if( aDRMharvestData.iAuthor.Length() > 0 && aDRMharvestData.iAuthor.Length() < iMaxTextLength )
   415     	{
   473     	{
   416     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   474     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   417     			*iPropDefs->iAuthorPropertyDef, &aVHD.iAuthor, aIsAdd );
   475     			*iPropDefs->iAuthorPropertyDef, &aDRMharvestData.iAuthor, aIsAdd );
   418     	}
   476     	}
   419     // Genre
   477     // Genre
   420     if( aVHD.iGenre.Length() > 0 && aVHD.iGenre.Length() < iMaxTextLength )
   478     if( aDRMharvestData.iGenre.Length() > 0 && aDRMharvestData.iGenre.Length() < iMaxTextLength )
   421         {
   479         {
   422         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   480         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   423                 *iPropDefs->iGenrePropertyDef, &aVHD.iGenre, aIsAdd );
   481                 *iPropDefs->iGenrePropertyDef, &aDRMharvestData.iGenre, aIsAdd );
       
   482         }
       
   483     
       
   484     if( objectDefName == MdeConstants::Image::KImageObject )
       
   485         {
       
   486       // Image - Bits per Sample
       
   487         if (aFileData.iBitsPerPixel != 0)
       
   488             {
       
   489             CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iBitsPerSamplePropertyDef, &aFileData.iBitsPerPixel, aIsAdd );
       
   490             }
       
   491     
       
   492         // Image - Framecount
       
   493         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iFrameCountPropertyDef, &aFileData.iFrameCount, aIsAdd );
       
   494         
       
   495         // MediaObject - Width
       
   496         if (aFileData.iImageWidth != 0)
       
   497             {
       
   498             CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iWidthPropertyDef, &aFileData.iImageWidth, aIsAdd );
       
   499             }
       
   500         
       
   501         if (aFileData.iImageHeight != 0)
       
   502             {
       
   503             CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iHeightPropertyDef, &aFileData.iImageHeight, aIsAdd );
       
   504             } 
   424         }
   505         }
   425     }
   506     }
   426 
   507 
   427 // ---------------------------------------------------------------------------
   508 // ---------------------------------------------------------------------------
   428 // ChangeObjectType
   509 // ChangeObjectType
   436 	TRAPD( err, content = ContentAccess::CContent::NewL( aUri ) );
   517 	TRAPD( err, content = ContentAccess::CContent::NewL( aUri ) );
   437 	if (err == KErrNone) 
   518 	if (err == KErrNone) 
   438 		{
   519 		{
   439 		err = content->GetStringAttribute( ContentAccess::EMimeType, mime );
   520 		err = content->GetStringAttribute( ContentAccess::EMimeType, mime );
   440 		delete content;
   521 		delete content;
       
   522 		content = NULL;
   441 		}
   523 		}
   442 
   524 
   443 #ifdef _DEBUG
   525 #ifdef _DEBUG
   444     if( err == KErrInUse || err == KErrLocked )
   526     if( err == KErrInUse || err == KErrLocked )
   445         {
   527         {
   556     TRAPD( err, content = ContentAccess::CContent::NewL( aUri ) );
   638     TRAPD( err, content = ContentAccess::CContent::NewL( aUri ) );
   557     if (err == KErrNone) 
   639     if (err == KErrNone) 
   558         {
   640         {
   559         err = content->GetStringAttribute( ContentAccess::EMimeType, aMimeType );
   641         err = content->GetStringAttribute( ContentAccess::EMimeType, aMimeType );
   560         delete content;
   642         delete content;
       
   643         content = NULL;
   561         }
   644         }
   562     }
   645     }
   563 
   646 
       
   647 void CHarvesterOMADRMPlugin::InitPropDefsL( CMdEObjectDef& aObjectDef )
       
   648     {
       
   649     if( !iPropDefs->iCreationDatePropertyDef )
       
   650         {
       
   651         iPropDefs->SetByObjectDefL( aObjectDef );
       
   652         // Prefetch max text lengt for validity checking
       
   653         iMaxTextLength = iPropDefs->iGenrePropertyDef->MaxTextLengthL();
       
   654         }
       
   655     }
       
   656