37 _LIT(KVideo, "Video"); |
38 _LIT(KVideo, "Video"); |
38 _LIT(KAudio, "Audio"); |
39 _LIT(KAudio, "Audio"); |
39 _LIT(KRmMimetype, "realmedia"); |
40 _LIT(KRmMimetype, "realmedia"); |
40 |
41 |
41 _LIT( KSvgMime, "image/svg+xml" ); |
42 _LIT( KSvgMime, "image/svg+xml" ); |
|
43 _LIT( KRingingToneMime, "application/vnd.nokia.ringing-tone" ); |
42 |
44 |
43 _LIT(KInUse, "InUse"); |
45 _LIT(KInUse, "InUse"); |
44 |
46 |
45 CHarvesterOmaDrmPluginPropertyDefs::CHarvesterOmaDrmPluginPropertyDefs() : CBase() |
47 CHarvesterOmaDrmPluginPropertyDefs::CHarvesterOmaDrmPluginPropertyDefs() : CBase() |
46 { |
48 { |
55 iCreationDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KCreationDateProperty ); |
57 iCreationDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KCreationDateProperty ); |
56 iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty ); |
58 iLastModifiedDatePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KLastModifiedDateProperty ); |
57 iSizePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty ); |
59 iSizePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KSizeProperty ); |
58 iItemTypePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty ); |
60 iItemTypePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KItemTypeProperty ); |
59 iTitlePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KTitleProperty ); |
61 iTitlePropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KTitleProperty ); |
|
62 iDefaultFolderPropertyDef = &objectDef.GetPropertyDefL( MdeConstants::Object::KInDefaultFolder ); |
60 |
63 |
61 CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MdeConstants::MediaObject::KMediaObject ); |
64 CMdEObjectDef& mediaDef = nsDef.GetObjectDefL( MdeConstants::MediaObject::KMediaObject ); |
62 iDrmPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDRMProperty ); |
65 iDrmPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDRMProperty ); |
63 iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDescriptionProperty ); |
66 iDescriptionPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KDescriptionProperty ); |
64 iAuthorPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KAuthorProperty ); |
67 iAuthorPropertyDef = &mediaDef.GetPropertyDefL( MdeConstants::MediaObject::KAuthorProperty ); |
103 */ |
106 */ |
104 CHarvesterOMADRMPlugin::~CHarvesterOMADRMPlugin() |
107 CHarvesterOMADRMPlugin::~CHarvesterOMADRMPlugin() |
105 { |
108 { |
106 WRITELOG("CHarvesterOMADRMPlugin::~CHarvesterOMADRMPlugin()"); |
109 WRITELOG("CHarvesterOMADRMPlugin::~CHarvesterOMADRMPlugin()"); |
107 |
110 |
|
111 delete iPhoneImagesPath; |
|
112 delete iMmcImagesPath; |
|
113 |
|
114 delete iPhoneVideosPath; |
|
115 delete iMmcVideosPath; |
|
116 |
|
117 delete iPhoneSoundsPath; |
|
118 delete iMmcSoundsPath; |
|
119 |
108 delete iPropDefs; |
120 delete iPropDefs; |
109 } |
121 } |
110 |
122 |
111 /** |
123 /** |
112 * 2nd phase constructor |
124 * 2nd phase constructor |
113 */ |
125 */ |
114 void CHarvesterOMADRMPlugin::ConstructL() |
126 void CHarvesterOMADRMPlugin::ConstructL() |
115 { |
127 { |
116 WRITELOG( "CHarvesterOMADRMPlugin::ConstructL()" ); |
128 WRITELOG( "CHarvesterOMADRMPlugin::ConstructL()" ); |
117 SetPriority( KHarvesterPriorityHarvestingPlugin - 1 ); |
129 SetPriority( KHarvesterPriorityHarvestingPlugin - 1 ); |
|
130 |
|
131 TFileName phoneRoot = PathInfo::PhoneMemoryRootPath(); |
|
132 TFileName mmcRoot = PathInfo::MemoryCardRootPath(); |
|
133 |
|
134 TFileName images = PathInfo::ImagesPath(); |
|
135 |
|
136 TFileName phoneImagePath( phoneRoot ); |
|
137 phoneImagePath.Append( images ); |
|
138 iPhoneImagesPath = phoneImagePath.AllocL(); |
|
139 |
|
140 TFileName mmcImagePath( mmcRoot ); |
|
141 mmcImagePath.Append( images ); |
|
142 iMmcImagesPath = mmcImagePath.Right( mmcImagePath.Length() - 1 ).AllocL(); |
|
143 |
|
144 TFileName videos = PathInfo::VideosPath(); |
|
145 |
|
146 TFileName phoneVideoPath( phoneRoot ); |
|
147 phoneVideoPath.Append( videos ); |
|
148 iPhoneVideosPath = phoneVideoPath.AllocL(); |
|
149 |
|
150 TFileName mmcVideoPath( mmcRoot ); |
|
151 mmcVideoPath.Append( videos ); |
|
152 iMmcVideosPath = mmcVideoPath.Right( mmcVideoPath.Length() - 1 ).AllocL(); |
|
153 |
|
154 TFileName sounds = PathInfo::SoundsPath(); |
|
155 |
|
156 TFileName phoneSoundPath( phoneRoot ); |
|
157 phoneSoundPath.Append( sounds ); |
|
158 iPhoneSoundsPath = phoneSoundPath.AllocL(); |
|
159 |
|
160 TFileName mmcSoundPath( mmcRoot ); |
|
161 mmcSoundPath.Append( sounds ); |
|
162 iMmcSoundsPath = mmcSoundPath.Right( mmcSoundPath.Length() - 1 ).AllocL(); |
118 } |
163 } |
119 |
164 |
120 void CHarvesterOMADRMPlugin::HarvestL( CHarvesterData* aHD ) |
165 void CHarvesterOMADRMPlugin::HarvestL( CHarvesterData* aHD ) |
121 { |
166 { |
122 CMdEObject& mdeObject = aHD->MdeObject(); |
167 CMdEObject& mdeObject = aHD->MdeObject(); |
250 |
295 |
251 CleanupStack::PopAndDestroy( 3 ); // content, data, attrSet |
296 CleanupStack::PopAndDestroy( 3 ); // content, data, attrSet |
252 } |
297 } |
253 |
298 |
254 // --------------------------------------------------------------------------- |
299 // --------------------------------------------------------------------------- |
255 // HandleNewObjectL |
300 // HandleObjectPropertiesL |
256 // --------------------------------------------------------------------------- |
301 // --------------------------------------------------------------------------- |
257 // |
302 // |
258 void CHarvesterOMADRMPlugin::HandleObjectPropertiesL( |
303 void CHarvesterOMADRMPlugin::HandleObjectPropertiesL( |
259 CHarvesterData& aHD, |
304 CHarvesterData& aHD, |
260 CDRMHarvestData& aVHD, |
305 CDRMHarvestData& aVHD, |
283 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, |
328 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, |
284 *iPropDefs->iLastModifiedDatePropertyDef, &aVHD.iModified, aIsAdd ); |
329 *iPropDefs->iLastModifiedDatePropertyDef, &aVHD.iModified, aIsAdd ); |
285 // File size |
330 // File size |
286 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, |
331 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, |
287 *iPropDefs->iSizePropertyDef, &aVHD.iFileSize, aIsAdd ); |
332 *iPropDefs->iSizePropertyDef, &aVHD.iFileSize, aIsAdd ); |
|
333 |
|
334 TPtrC objectDefName( mdeObject.Def().Name() ); |
|
335 if( objectDefName == MdeConstants::Image::KImageObject ) |
|
336 { |
|
337 const TDesC& uri = mdeObject.Uri(); |
|
338 if( uri.FindF( iMmcImagesPath->Des()) != KErrNotFound || |
|
339 uri.FindF( iPhoneImagesPath->Des()) != KErrNotFound || |
|
340 uri.FindF( KDCIMFolder ) != KErrNotFound ) |
|
341 { |
|
342 TBool inDefaultFolder( ETrue ); |
|
343 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDefaultFolderPropertyDef, &inDefaultFolder, aIsAdd ); |
|
344 } |
|
345 else |
|
346 { |
|
347 TBool inDefaultFolder( EFalse ); |
|
348 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDefaultFolderPropertyDef, &inDefaultFolder, aIsAdd ); |
|
349 } |
|
350 } |
|
351 else if( objectDefName == MdeConstants::Video::KVideoObject ) |
|
352 { |
|
353 const TDesC& uri = mdeObject.Uri(); |
|
354 if( uri.FindF( iMmcVideosPath->Des()) != KErrNotFound || |
|
355 uri.FindF( iPhoneVideosPath->Des()) != KErrNotFound || |
|
356 uri.FindF( KDCIMFolder ) != KErrNotFound ) |
|
357 { |
|
358 TBool inDefaultFolder( ETrue ); |
|
359 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDefaultFolderPropertyDef, &inDefaultFolder, aIsAdd ); |
|
360 } |
|
361 else |
|
362 { |
|
363 TBool inDefaultFolder( EFalse ); |
|
364 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDefaultFolderPropertyDef, &inDefaultFolder, aIsAdd ); |
|
365 } |
|
366 } |
|
367 else if( objectDefName == MdeConstants::Audio::KAudioObject ) |
|
368 { |
|
369 const TDesC& uri = mdeObject.Uri(); |
|
370 if( uri.FindF( iMmcSoundsPath->Des()) != KErrNotFound || |
|
371 uri.FindF( iPhoneSoundsPath->Des()) != KErrNotFound ) |
|
372 { |
|
373 TBool inDefaultFolder( ETrue ); |
|
374 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDefaultFolderPropertyDef, &inDefaultFolder, aIsAdd ); |
|
375 } |
|
376 else |
|
377 { |
|
378 TBool inDefaultFolder( EFalse ); |
|
379 CMdeObjectWrapper::HandleObjectPropertyL(mdeObject, *iPropDefs->iDefaultFolderPropertyDef, &inDefaultFolder, aIsAdd ); |
|
380 } |
|
381 } |
288 } |
382 } |
289 |
383 |
290 // Item Type |
384 // Item Type |
291 if(aVHD.iMimetype.Length() > 0) |
385 if(aVHD.iMimetype.Length() > 0) |
292 { |
386 { |
293 TBool isAdd( EFalse ); |
387 TBool isAdd( EFalse ); |
294 CMdEProperty* prop = NULL; |
388 CMdEProperty* prop = NULL; |
344 if (err == KErrNone) |
438 if (err == KErrNone) |
345 { |
439 { |
346 err = content->GetStringAttribute( ContentAccess::EMimeType, mime ); |
440 err = content->GetStringAttribute( ContentAccess::EMimeType, mime ); |
347 delete content; |
441 delete content; |
348 } |
442 } |
|
443 |
|
444 #ifdef _DEBUG |
|
445 if( err == KErrInUse || err == KErrLocked ) |
|
446 { |
|
447 TPtrC fileName( aUri.Mid(2) ); |
|
448 WRITELOG1( "CHarvesterOMADRMPlugin :: Checking open file handles to %S", &fileName ); |
|
449 |
|
450 CFileList* fileList = 0; |
|
451 TOpenFileScan fileScan( iFs ); |
|
452 |
|
453 TRAP_IGNORE( fileScan.NextL( fileList ) ); |
|
454 |
|
455 while ( fileList ) |
|
456 { |
|
457 const TInt count( fileList->Count() ); |
|
458 for (TInt i = 0; i < count; i++ ) |
|
459 { |
|
460 if ( (*fileList)[i].iName == aUri.Mid(2) ) |
|
461 { |
|
462 TFullName processName; |
|
463 TFindThread find(_L("*")); |
|
464 while( find.Next( processName ) == KErrNone ) |
|
465 { |
|
466 RThread thread; |
|
467 TInt error = thread.Open( processName ); |
|
468 |
|
469 if ( error == KErrNone ) |
|
470 { |
|
471 if ( thread.Id().Id() == fileScan.ThreadId() ) |
|
472 { |
|
473 processName = thread.Name(); |
|
474 thread.Close(); |
|
475 WRITELOG1( "CHarvesterOMADRMPlugin :: %S has a file handle open", &processName ); |
|
476 break; |
|
477 } |
|
478 thread.Close(); |
|
479 } |
|
480 } |
|
481 } |
|
482 } |
|
483 TRAP_IGNORE( fileScan.NextL( fileList ) ); |
|
484 } |
|
485 } |
|
486 #endif |
349 |
487 |
350 if( err == KErrInUse || err == KErrLocked ) |
488 if( err == KErrInUse || err == KErrLocked ) |
351 { |
489 { |
352 aObjectType.Copy( KInUse() ); |
490 aObjectType.Copy( KInUse() ); |
353 return; |
491 return; |
391 { |
529 { |
392 WRITELOG1( "CHarvesterOMADRMPlugin::GetObjectType - mimetype %S. Object type changed to Rm", &mime ); |
530 WRITELOG1( "CHarvesterOMADRMPlugin::GetObjectType - mimetype %S. Object type changed to Rm", &mime ); |
393 aObjectType.Copy( KVideo ); |
531 aObjectType.Copy( KVideo ); |
394 return; |
532 return; |
395 } |
533 } |
|
534 |
|
535 if( mime == KRingingToneMime ) |
|
536 { |
|
537 WRITELOG1( "CHarvesterOMADRMPlugin::GetObjectType - mimetype %S. Object type changed to Audio", &mime ); |
|
538 aObjectType.Copy( KAudio ); |
|
539 return; |
|
540 } |
396 } |
541 } |
397 |
542 |
398 WRITELOG1( "CHarvesterOMADRMPlugin::GetObjectType - ERROR: mimetype %S. No object type found", &mime ); |
543 WRITELOG1( "CHarvesterOMADRMPlugin::GetObjectType - ERROR: mimetype %S. No object type found", &mime ); |
399 aObjectType.Zero(); |
544 aObjectType.Zero(); |
400 } |
545 } |