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