harvester/harvesterplugins/OMADRMPlugin/src/harvesteromadrmplugin.cpp
branchRCL_3
changeset 47 b73252188534
parent 27 4a4892eec172
child 49 f23c07ec56e2
equal deleted inserted replaced
46:63c982fb92f2 47:b73252188534
    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     SetPriority( KHarvesterPriorityHarvestingPlugin - 1 );	
   154     SetPriority( KHarvesterPriorityHarvestingPlugin - 1 );	
   130 	
   155     
       
   156     User::LeaveIfError( iFs.Connect() );
       
   157 	
       
   158     iPropDefs = CHarvesterOmaDrmPluginPropertyDefs::NewL();
       
   159     
   131 	TFileName phoneRoot = PathInfo::PhoneMemoryRootPath();
   160 	TFileName phoneRoot = PathInfo::PhoneMemoryRootPath();
   132 	TFileName mmcRoot = PathInfo::MemoryCardRootPath();
   161 	TFileName mmcRoot = PathInfo::MemoryCardRootPath();
   133 	
   162 	
   134 	TFileName images = PathInfo::ImagesPath();
   163 	TFileName images = PathInfo::ImagesPath();
   135 	
   164 	
   160     TFileName mmcSoundPath( mmcRoot );
   189     TFileName mmcSoundPath( mmcRoot );
   161     mmcSoundPath.Append( sounds );
   190     mmcSoundPath.Append( sounds );
   162     iMmcSoundsPath = mmcSoundPath.Right( mmcSoundPath.Length() - 1 ).AllocL();
   191     iMmcSoundsPath = mmcSoundPath.Right( mmcSoundPath.Length() - 1 ).AllocL();
   163 	}
   192 	}
   164 
   193 
   165 void CHarvesterOMADRMPlugin::HarvestL( CHarvesterData* aHD )
   194 void CHarvesterOMADRMPlugin::HarvestL( CHarvesterData* aHarvesterData )
   166 	{
   195 	{
   167     CMdEObject& mdeObject = aHD->MdeObject();
   196 	WRITELOG( "CHarvesterImagePlugin::HarvestL()" );
   168     CDRMHarvestData* fileData = CDRMHarvestData::NewL();
   197     CMdEObject& mdeObject = aHarvesterData->MdeObject();
       
   198 	CDRMHarvestData* drmHarvestData = CDRMHarvestData::NewL();
       
   199 	CleanupStack::PushL( drmHarvestData );
       
   200 	
       
   201     CFileData* fileData = CFileData::NewL();
   169     CleanupStack::PushL( fileData );
   202     CleanupStack::PushL( fileData );
   170 
   203 
   171     TRAPD( error, GatherDataL( mdeObject, *fileData ) );
   204     CHarvestData* harvestData = CHarvestData::NewL();
   172     if ( error == KErrNone || error == KErrCompletion )
   205     CleanupStack::PushL( harvestData );
   173     	{
   206         
   174         TBool isNewObject( mdeObject.Id() == 0 );
   207     TInt errorCode( KErrNone );
   175         
   208     
   176         if ( isNewObject || mdeObject.Placeholder() )
   209     TRAPD( error, errorCode = GatherDataL( mdeObject, *drmHarvestData, *fileData, *harvestData ) );
   177             {
   210     
   178             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 ) );
   179             mdeObject.SetPlaceholder( EFalse );
   216             mdeObject.SetPlaceholder( EFalse );
   180             }
   217             }
   181         else
   218         else   // not a new object
   182             {
   219             {
   183             TRAP( error, HandleObjectPropertiesL( *aHD, *fileData, EFalse ) );
   220             TRAP_IGNORE( HandleObjectPropertiesL( *harvestData, *drmHarvestData, *fileData, *aHarvesterData, EFalse ) );
   184             }
   221             }
   185 
   222 
   186         if ( error != KErrNone )
   223         if ( error != KErrNone )
   187             {
   224             {
   188             WRITELOG1( "CHarvesterOMADRMPlugin::HarvestL() - Handling object failed: ", error );
   225             WRITELOG1( "CHarvesterOMADRMPlugin::HarvestL() - Handling object failed: ", error );
   189             }
   226             }
   190     	}
   227     	}
   191     else	
   228     else	
   192         {
   229         {
   193         WRITELOG1( "CHarvesterOMADRMPlugin::HarvestL() - TRAP error: %d", error );
   230         WRITELOG1( "CHarvesterOMADRMPlugin::HarvestL() - TRAP error: %d, errorCode %d", error );
   194         TInt convertedError = KErrNone;
   231         TInt convertedError = KErrNone;
   195         MdsUtils::ConvertTrapError( error, convertedError );
   232         MdsUtils::ConvertTrapError( error, convertedError );
   196         aHD->SetErrorCode( convertedError );
   233         aHarvesterData->SetErrorCode( convertedError );
   197         }
   234         }
   198 
   235 
   199     CleanupStack::PopAndDestroy( fileData );
   236     CleanupStack::PopAndDestroy( 3, drmHarvestData );
   200 	}
   237 	}
   201 
   238 
   202 // ---------------------------------------------------------------------------
   239 // ---------------------------------------------------------------------------
   203 // GatherDataL
   240 // GatherDataL
   204 // ---------------------------------------------------------------------------
   241 // ---------------------------------------------------------------------------
   205 //
   242 //
   206 void CHarvesterOMADRMPlugin::GatherDataL( CMdEObject& aMetadataObject,
   243 TInt CHarvesterOMADRMPlugin::GatherDataL( CMdEObject& aMetadataObject, CDRMHarvestData& aDRMharvestData, 
   207 		CDRMHarvestData& aVHD )
   244         CFileData& aFileData, CHarvestData& /*aHarvestData*/ )
   208     {
   245     {
   209     WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL" );
   246     WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL" );
   210     
   247     
   211     TEntry* entry = new (ELeave) TEntry();
   248     TEntry* entry = new (ELeave) TEntry();
   212     CleanupStack::PushL( entry );
   249     CleanupStack::PushL( entry );
   213     
   250     
   214     const TDesC& uri = aMetadataObject.Uri();
   251     const TDesC& uri = aMetadataObject.Uri();
   215     User::LeaveIfError( iFs.Entry( uri, *entry ) );
   252     User::LeaveIfError( iFs.Entry( uri, *entry ) );
   216     
   253     
   217     aVHD.iModified = entry->iModified;
   254     aDRMharvestData.iModified = entry->iModified;
   218     aVHD.iFileSize = (TUint)entry->iSize;
   255     aDRMharvestData.iFileSize = (TUint)entry->iSize;
   219     CleanupStack::PopAndDestroy( entry );
   256     CleanupStack::PopAndDestroy( entry );
   220     
   257     
   221     ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri );   
   258     ContentAccess::CContent* content = ContentAccess::CContent::NewLC( uri );   
   222     ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek );
   259     ContentAccess::CData* data = content->OpenContentLC( ContentAccess::EPeek );
   223     
   260     
   230     attrSet.AddL( ContentAccess::EAuthor );
   267     attrSet.AddL( ContentAccess::EAuthor );
   231     attrSet.AddL( ContentAccess::EGenre );
   268     attrSet.AddL( ContentAccess::EGenre );
   232 
   269 
   233     User::LeaveIfError( data->GetStringAttributeSet(attrSet) );
   270     User::LeaveIfError( data->GetStringAttributeSet(attrSet) );
   234     
   271     
   235     TInt err = attrSet.GetValue( ContentAccess::EDescription, aVHD.iDescription );
   272     TInt err = attrSet.GetValue( ContentAccess::EDescription, aDRMharvestData.iDescription );
   236     if ( err != KErrNone)
   273     if ( err != KErrNone)
   237         {
   274         {
   238         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting description failed %d", err );
   275         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting description failed %d", err );
   239         }
   276         }
   240         
   277         
   241     if ( aVHD.iDescription.Length() <= 0 )
   278     if ( aDRMharvestData.iDescription.Length() <= 0 )
   242         {
   279         {
   243         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no description" );
   280         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no description" );
   244         }
   281         }
   245     
   282     
   246     err = attrSet.GetValue( ContentAccess::EMimeType, aVHD.iMimetype );
   283     err = attrSet.GetValue( ContentAccess::EMimeType, aDRMharvestData.iMimetype );
   247     if ( err != KErrNone)
   284     if ( err != KErrNone)
   248         {
   285         {
   249         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting mimetype failed %d", err );
   286         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting mimetype failed %d", err );
   250         }
   287         }
   251         
   288         
   252     if ( aVHD.iMimetype.Length() <= 0 )
   289     if ( aDRMharvestData.iMimetype.Length() <= 0 )
   253         {
   290         {
   254         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no mimetype" );
   291         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no mimetype" );
   255         }
   292         }
   256     
   293     
   257     err = attrSet.GetValue( ContentAccess::ETitle, aVHD.iTitle );
   294     err = attrSet.GetValue( ContentAccess::ETitle, aDRMharvestData.iTitle );
   258     if ( err != KErrNone)
   295     if ( err != KErrNone)
   259         {
   296         {
   260         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting title failed %d", err );
   297         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting title failed %d", err );
   261         }
   298         }
   262         
   299         
   263     if ( aVHD.iTitle.Length() <= 0 )
   300     if ( aDRMharvestData.iTitle.Length() <= 0 )
   264         {
   301         {
   265         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no title" );
   302         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no title" );
   266         }
   303         }
   267     
   304     
   268     err = attrSet.GetValue( ContentAccess::EAuthor, aVHD.iAuthor );
   305     err = attrSet.GetValue( ContentAccess::EAuthor, aDRMharvestData.iAuthor );
   269     if ( err != KErrNone)
   306     if ( err != KErrNone)
   270         {
   307         {
   271         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting author failed %d", err );
   308         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting author failed %d", err );
   272         }
   309         }
   273         
   310         
   274     if ( aVHD.iAuthor.Length() <= 0 )
   311     if ( aDRMharvestData.iAuthor.Length() <= 0 )
   275         {
   312         {
   276         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no author" );
   313         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no author" );
   277         }
   314         }
   278 
   315 
   279     err = attrSet.GetValue( ContentAccess::EGenre, aVHD.iGenre );
   316     err = attrSet.GetValue( ContentAccess::EGenre, aDRMharvestData.iGenre );
   280     if ( err != KErrNone)
   317     if ( err != KErrNone)
   281         {
   318         {
   282         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting genre failed %d", err );
   319         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting genre failed %d", err );
   283         }
   320         }
   284         
   321         
   285     if ( aVHD.iGenre.Length() <= 0 )
   322     if ( aDRMharvestData.iGenre.Length() <= 0 )
   286         {
   323         {
   287         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no genre" );
   324         WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL - no genre" );
   288         }
   325         }
   289     
   326     
   290     err = content->GetAttribute( ContentAccess::EIsProtected, aVHD.iDrmProtected );
   327     err = content->GetAttribute( ContentAccess::EIsProtected, aDRMharvestData.iDrmProtected );
   291     if ( err != KErrNone)
   328     if ( err != KErrNone)
   292         {
   329         {
   293         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting protection info failed %d", err );
   330         WRITELOG1( "CHarvesterOMADRMPlugin::GatherDataL - ERROR: getting protection info failed %d", err );
   294         }
   331         }
   295         
   332       
   296     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;
   297     }
   359     }
   298 
   360 
   299 // ---------------------------------------------------------------------------
   361 // ---------------------------------------------------------------------------
   300 // HandleObjectPropertiesL
   362 // HandleObjectPropertiesL
   301 // ---------------------------------------------------------------------------
   363 // ---------------------------------------------------------------------------
   302 //
   364 //
   303 void CHarvesterOMADRMPlugin::HandleObjectPropertiesL(
   365 void CHarvesterOMADRMPlugin::HandleObjectPropertiesL( CHarvestData& /*aHarvestData*/, CDRMHarvestData& aDRMharvestData, CFileData& aFileData, 
   304 		CHarvesterData& aHD,
   366         CHarvesterData& aHarvesterData, TBool aIsAdd )
   305 		CDRMHarvestData& aVHD,
       
   306 		TBool aIsAdd )
       
   307     {
   367     {
   308     WRITELOG("CHarvesterOMADRMPlugin - HandleNewObject ");
   368     WRITELOG("CHarvesterOMADRMPlugin - HandleNewObject ");
   309     CMdEObject& mdeObject = aHD.MdeObject();
   369     CMdEObject& mdeObject = aHarvesterData.MdeObject();
   310 
   370 
   311     if( !iPropDefs )
   371     InitPropDefsL( mdeObject.Def() );
   312     	{
       
   313     	CMdEObjectDef& objectDef = mdeObject.Def();
       
   314     	iPropDefs = CHarvesterOmaDrmPluginPropertyDefs::NewL( objectDef );
       
   315     	// Prefetch max text lengt for validity checking
       
   316     	iMaxTextLength = iPropDefs->iGenrePropertyDef->MaxTextLengthL();
       
   317     	}
       
   318     
   372     
   319     TTimeIntervalSeconds timeOffset = User::UTCOffset();
   373     TTimeIntervalSeconds timeOffset = User::UTCOffset();
       
   374     
       
   375     TPtrC objectDefName( mdeObject.Def().Name());
   320     
   376     
   321     if( ! mdeObject.Placeholder() )
   377     if( ! mdeObject.Placeholder() )
   322     	{
   378     	{
   323     	// Creation date
   379     	// Creation date
   324     	TTime localTime = aVHD.iModified + timeOffset;
   380     	TTime localTime = aDRMharvestData.iModified + timeOffset;
   325     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   381     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   326     			*iPropDefs->iCreationDatePropertyDef, &localTime, aIsAdd );
   382     			*iPropDefs->iCreationDatePropertyDef, &localTime, aIsAdd );
   327     	// Last modified date
   383     	// Last modified date
   328     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   384     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   329     			*iPropDefs->iLastModifiedDatePropertyDef, &aVHD.iModified, aIsAdd );
   385     			*iPropDefs->iLastModifiedDatePropertyDef, &aDRMharvestData.iModified, aIsAdd );
   330     	// File size
   386     	// File size
   331     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   387     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   332     			*iPropDefs->iSizePropertyDef, &aVHD.iFileSize, aIsAdd );
   388     			*iPropDefs->iSizePropertyDef, &aDRMharvestData.iFileSize, aIsAdd );
   333 
   389 
   334     	TPtrC objectDefName( mdeObject.Def().Name() );
   390     	TPtrC objectDefName( mdeObject.Def().Name());
       
   391     	
   335         if( objectDefName == MdeConstants::Image::KImageObject )
   392         if( objectDefName == MdeConstants::Image::KImageObject )
   336             {
   393             {
   337             const TDesC& uri = mdeObject.Uri();
   394             const TDesC& uri = mdeObject.Uri();
   338             if( uri.FindF( iMmcImagesPath->Des()) != KErrNotFound ||
   395             if( uri.FindF( iMmcImagesPath->Des()) != KErrNotFound ||
   339                 uri.FindF( iPhoneImagesPath->Des()) != KErrNotFound ||
   396                 uri.FindF( iPhoneImagesPath->Des()) != KErrNotFound ||
   380                 }     
   437                 }     
   381             }
   438             }
   382     	}
   439     	}
   383         
   440         
   384     // Item Type
   441     // Item Type
   385     if(aVHD.iMimetype.Length() > 0)
   442     if(aDRMharvestData.iMimetype.Length() > 0)
   386         {
   443         {
   387         TBool isAdd( EFalse );
   444         TBool isAdd( EFalse );
   388         CMdEProperty* prop = NULL;
   445         CMdEProperty* prop = NULL;
   389         TInt index = mdeObject.Property( *iPropDefs->iItemTypePropertyDef, prop );
   446         TInt index = mdeObject.Property( *iPropDefs->iItemTypePropertyDef, prop );
   390         if( index < 0 )
   447         if( index < 0 )
   391             {
   448             {
   392             isAdd = ETrue;
   449             isAdd = ETrue;
   393             }
   450             }
   394         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   451         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   395                 *iPropDefs->iItemTypePropertyDef, &aVHD.iMimetype, isAdd );
   452                 *iPropDefs->iItemTypePropertyDef, &aDRMharvestData.iMimetype, isAdd );
   396         }
   453         }
   397     
   454     
   398     // DRM protection
   455     // DRM protection
   399     CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   456     CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   400     		*iPropDefs->iDrmPropertyDef, &aVHD.iDrmProtected, aIsAdd );
   457     		*iPropDefs->iDrmPropertyDef, &aDRMharvestData.iDrmProtected, aIsAdd );
   401     
   458     
   402     // Title (is set from URI by default)
   459     // Title (is set from URI by default)
   403     if( aVHD.iTitle.Length() > 0 && aVHD.iTitle.Length() < KMaxTitleFieldLength )
   460     if( aDRMharvestData.iTitle.Length() > 0 && aDRMharvestData.iTitle.Length() < KMaxTitleFieldLength )
   404     	{
   461     	{
   405     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   462     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   406     			*iPropDefs->iTitlePropertyDef, &aVHD.iTitle, EFalse );
   463     			*iPropDefs->iTitlePropertyDef, &aDRMharvestData.iTitle, EFalse );
   407     	}
   464     	}
   408     // Description
   465     // Description
   409     if( aVHD.iDescription.Length() > 0 && aVHD.iDescription.Length() < iMaxTextLength )
   466     if( aDRMharvestData.iDescription.Length() > 0 && aDRMharvestData.iDescription.Length() < iMaxTextLength )
   410     	{
   467     	{
   411     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   468     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   412     			*iPropDefs->iDescriptionPropertyDef, &aVHD.iDescription, aIsAdd );
   469     			*iPropDefs->iDescriptionPropertyDef, &aDRMharvestData.iDescription, aIsAdd );
   413     	}   
   470     	}   
   414     // Author
   471     // Author
   415     if( aVHD.iAuthor.Length() > 0 && aVHD.iAuthor.Length() < iMaxTextLength )
   472     if( aDRMharvestData.iAuthor.Length() > 0 && aDRMharvestData.iAuthor.Length() < iMaxTextLength )
   416     	{
   473     	{
   417     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   474     	CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   418     			*iPropDefs->iAuthorPropertyDef, &aVHD.iAuthor, aIsAdd );
   475     			*iPropDefs->iAuthorPropertyDef, &aDRMharvestData.iAuthor, aIsAdd );
   419     	}
   476     	}
   420     // Genre
   477     // Genre
   421     if( aVHD.iGenre.Length() > 0 && aVHD.iGenre.Length() < iMaxTextLength )
   478     if( aDRMharvestData.iGenre.Length() > 0 && aDRMharvestData.iGenre.Length() < iMaxTextLength )
   422         {
   479         {
   423         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   480         CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, 
   424                 *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             } 
   425         }
   505         }
   426     }
   506     }
   427 
   507 
   428 // ---------------------------------------------------------------------------
   508 // ---------------------------------------------------------------------------
   429 // ChangeObjectType
   509 // ChangeObjectType
   437 	TRAPD( err, content = ContentAccess::CContent::NewL( aUri ) );
   517 	TRAPD( err, content = ContentAccess::CContent::NewL( aUri ) );
   438 	if (err == KErrNone) 
   518 	if (err == KErrNone) 
   439 		{
   519 		{
   440 		err = content->GetStringAttribute( ContentAccess::EMimeType, mime );
   520 		err = content->GetStringAttribute( ContentAccess::EMimeType, mime );
   441 		delete content;
   521 		delete content;
       
   522 		content = NULL;
   442 		}
   523 		}
   443 
   524 
   444 #ifdef _DEBUG
   525 #ifdef _DEBUG
   445     if( err == KErrInUse || err == KErrLocked )
   526     if( err == KErrInUse || err == KErrLocked )
   446         {
   527         {
   557     TRAPD( err, content = ContentAccess::CContent::NewL( aUri ) );
   638     TRAPD( err, content = ContentAccess::CContent::NewL( aUri ) );
   558     if (err == KErrNone) 
   639     if (err == KErrNone) 
   559         {
   640         {
   560         err = content->GetStringAttribute( ContentAccess::EMimeType, aMimeType );
   641         err = content->GetStringAttribute( ContentAccess::EMimeType, aMimeType );
   561         delete content;
   642         delete content;
       
   643         content = NULL;
   562         }
   644         }
   563     }
   645     }
   564 
   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