harvester/harvesterplugins/OMADRMPlugin/src/harvesteromadrmplugin.cpp
changeset 43 c5e73110f733
parent 40 910a23996aa0
child 48 1389872e7c51
equal deleted inserted replaced
40:910a23996aa0 43:c5e73110f733
    46 _LIT( KSvgMime, "image/svg+xml" );
    46 _LIT( KSvgMime, "image/svg+xml" );
    47 _LIT( KRingingToneMime, "application/vnd.nokia.ringing-tone" );
    47 _LIT( KRingingToneMime, "application/vnd.nokia.ringing-tone" );
    48 
    48 
    49 _LIT(KInUse, "InUse");
    49 _LIT(KInUse, "InUse");
    50 
    50 
    51 CHarvesterOmaDrmPluginPropertyDefs::CHarvesterOmaDrmPluginPropertyDefs() : CBase()
    51 CHarvesterOmaDrmPluginPropertyDefs::CHarvesterOmaDrmPluginPropertyDefs() : CBase(),
    52 	{
    52     iCreationDatePropertyDef( NULL )
    53 	}
    53 	{
    54 
    54 	}
    55 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 )
    56 	{
    69 	{
    57 	CMdENamespaceDef& nsDef = aObjectDef.NamespaceDef();
    70 	CMdENamespaceDef& nsDef = aObjectDef.NamespaceDef();
    58 	
    71 	
    59 	// Common property definitions
    72 	// Common property definitions
    60 	CMdEObjectDef& objectDef = nsDef.GetObjectDefL( MdeConstants::Object::KBaseObject );
    73 	CMdEObjectDef& objectDef = nsDef.GetObjectDefL( MdeConstants::Object::KBaseObject );
    79 	iBitsPerSamplePropertyDef = &imageDef.GetPropertyDefL( MdeConstants::Image::KBitsPerSampleProperty );
    92 	iBitsPerSamplePropertyDef = &imageDef.GetPropertyDefL( MdeConstants::Image::KBitsPerSampleProperty );
    80 	iFrameCountPropertyDef = &imageDef.GetPropertyDefL( MdeConstants::Image::KFrameCountProperty );
    93 	iFrameCountPropertyDef = &imageDef.GetPropertyDefL( MdeConstants::Image::KFrameCountProperty );
    81 	iGenrePropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KGenreProperty );
    94 	iGenrePropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KGenreProperty );
    82 	}
    95 	}
    83 
    96 
    84 CHarvesterOmaDrmPluginPropertyDefs* CHarvesterOmaDrmPluginPropertyDefs::NewL(CMdEObjectDef& aObjectDef)
       
    85 	{
       
    86 	CHarvesterOmaDrmPluginPropertyDefs* self = 
       
    87 		new (ELeave) CHarvesterOmaDrmPluginPropertyDefs();
       
    88 	CleanupStack::PushL( self );
       
    89 	self->ConstructL( aObjectDef );
       
    90 	CleanupStack::Pop( self );
       
    91 	return self;
       
    92 	}
       
    93 
       
    94 /**
    97 /**
    95 * Default constructor
    98 * Default constructor
    96 */
    99 */
    97 CHarvesterOMADRMPlugin::CHarvesterOMADRMPlugin() : CHarvesterPlugin()
   100 CHarvesterOMADRMPlugin::CHarvesterOMADRMPlugin() : CHarvesterPlugin()
    98 	{
   101 	{
   138     
   141     
   139     delete iPhoneSoundsPath;
   142     delete iPhoneSoundsPath;
   140     iPhoneSoundsPath = NULL;
   143     iPhoneSoundsPath = NULL;
   141     delete iMmcSoundsPath;
   144     delete iMmcSoundsPath;
   142     iMmcSoundsPath = NULL;
   145     iMmcSoundsPath = NULL;
   143 	
       
   144 	delete iPropDefs;
       
   145 	iPropDefs = NULL;
       
   146 	}
   146 	}
   147 
   147 
   148 /**
   148 /**
   149 * 2nd phase constructor
   149 * 2nd phase constructor
   150 */
   150 */
   153 	WRITELOG( "CHarvesterOMADRMPlugin::ConstructL()" );
   153 	WRITELOG( "CHarvesterOMADRMPlugin::ConstructL()" );
   154     SetPriority( KHarvesterPriorityHarvestingPlugin - 1 );	
   154     SetPriority( KHarvesterPriorityHarvestingPlugin - 1 );	
   155     
   155     
   156     User::LeaveIfError( iFs.Connect() );
   156     User::LeaveIfError( iFs.Connect() );
   157 	
   157 	
       
   158     iPropDefs = CHarvesterOmaDrmPluginPropertyDefs::NewL();
       
   159     
   158 	TFileName phoneRoot = PathInfo::PhoneMemoryRootPath();
   160 	TFileName phoneRoot = PathInfo::PhoneMemoryRootPath();
   159 	TFileName mmcRoot = PathInfo::MemoryCardRootPath();
   161 	TFileName mmcRoot = PathInfo::MemoryCardRootPath();
   160 	
   162 	
   161 	TFileName images = PathInfo::ImagesPath();
   163 	TFileName images = PathInfo::ImagesPath();
   162 	
   164 	
   192 void CHarvesterOMADRMPlugin::HarvestL( CHarvesterData* aHarvesterData )
   194 void CHarvesterOMADRMPlugin::HarvestL( CHarvesterData* aHarvesterData )
   193 	{
   195 	{
   194 	WRITELOG( "CHarvesterImagePlugin::HarvestL()" );
   196 	WRITELOG( "CHarvesterImagePlugin::HarvestL()" );
   195     CMdEObject& mdeObject = aHarvesterData->MdeObject();
   197     CMdEObject& mdeObject = aHarvesterData->MdeObject();
   196 	CDRMHarvestData* drmHarvestData = CDRMHarvestData::NewL();
   198 	CDRMHarvestData* drmHarvestData = CDRMHarvestData::NewL();
       
   199 	CleanupStack::PushL( drmHarvestData );
   197 	
   200 	
   198     CFileData* fileData = CFileData::NewL();
   201     CFileData* fileData = CFileData::NewL();
   199     CleanupStack::PushL( fileData );
   202     CleanupStack::PushL( fileData );
   200 
   203 
   201     CHarvestData* harvestData = CHarvestData::NewL();
   204     CHarvestData* harvestData = CHarvestData::NewL();
   228         TInt convertedError = KErrNone;
   231         TInt convertedError = KErrNone;
   229         MdsUtils::ConvertTrapError( error, convertedError );
   232         MdsUtils::ConvertTrapError( error, convertedError );
   230         aHarvesterData->SetErrorCode( convertedError );
   233         aHarvesterData->SetErrorCode( convertedError );
   231         }
   234         }
   232 
   235 
   233     CleanupStack::PopAndDestroy( 2, fileData );
   236     CleanupStack::PopAndDestroy( 3, drmHarvestData );
   234 	}
   237 	}
   235 
   238 
   236 // ---------------------------------------------------------------------------
   239 // ---------------------------------------------------------------------------
   237 // GatherDataL
   240 // GatherDataL
   238 // ---------------------------------------------------------------------------
   241 // ---------------------------------------------------------------------------
   239 //
   242 //
   240 TInt CHarvesterOMADRMPlugin::GatherDataL( CMdEObject& aMetadataObject, CDRMHarvestData& aDRMharvestData, 
   243 TInt CHarvesterOMADRMPlugin::GatherDataL( CMdEObject& aMetadataObject, CDRMHarvestData& aDRMharvestData, 
   241         CFileData& aFileData, CHarvestData& aHarvestData )
   244         CFileData& aFileData, CHarvestData& /*aHarvestData*/ )
   242     {
   245     {
   243     WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL" );
   246     WRITELOG( "CHarvesterOMADRMPlugin::GatherDataL" );
   244     
   247     
   245     TEntry* entry = new (ELeave) TEntry();
   248     TEntry* entry = new (ELeave) TEntry();
   246     CleanupStack::PushL( entry );
   249     CleanupStack::PushL( entry );
   357 
   360 
   358 // ---------------------------------------------------------------------------
   361 // ---------------------------------------------------------------------------
   359 // HandleObjectPropertiesL
   362 // HandleObjectPropertiesL
   360 // ---------------------------------------------------------------------------
   363 // ---------------------------------------------------------------------------
   361 //
   364 //
   362 void CHarvesterOMADRMPlugin::HandleObjectPropertiesL( CHarvestData& aHarvestData, CDRMHarvestData& aDRMharvestData, CFileData& aFileData, 
   365 void CHarvesterOMADRMPlugin::HandleObjectPropertiesL( CHarvestData& /*aHarvestData*/, CDRMHarvestData& aDRMharvestData, CFileData& aFileData, 
   363         CHarvesterData& aHarvesterData, TBool aIsAdd )
   366         CHarvesterData& aHarvesterData, TBool aIsAdd )
   364     {
   367     {
   365     WRITELOG("CHarvesterOMADRMPlugin - HandleNewObject ");
   368     WRITELOG("CHarvesterOMADRMPlugin - HandleNewObject ");
   366     CMdEObject& mdeObject = aHarvesterData.MdeObject();
   369     CMdEObject& mdeObject = aHarvesterData.MdeObject();
   367 
   370 
   368     if( !iPropDefs )
   371     InitPropDefsL( mdeObject.Def() );
   369     	{
       
   370     	CMdEObjectDef& objectDef = mdeObject.Def();
       
   371     	iPropDefs = CHarvesterOmaDrmPluginPropertyDefs::NewL( objectDef );
       
   372     	// Prefetch max text lengt for validity checking
       
   373     	iMaxTextLength = iPropDefs->iGenrePropertyDef->MaxTextLengthL();
       
   374     	}
       
   375     
   372     
   376     TTimeIntervalSeconds timeOffset = User::UTCOffset();
   373     TTimeIntervalSeconds timeOffset = User::UTCOffset();
   377     
   374     
   378     TPtrC objectDefName( mdeObject.Def().Name());
   375     TPtrC objectDefName( mdeObject.Def().Name());
   379     
   376     
   645         delete content;
   642         delete content;
   646         content = NULL;
   643         content = NULL;
   647         }
   644         }
   648     }
   645     }
   649 
   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