mmappcomponents/harvester/metadataextractor/src/mpxmetadataextractor.cpp
branchRCL_3
changeset 56 63223d4fd956
parent 55 6c1dfe4da5dd
child 59 666f9a5a90a9
equal deleted inserted replaced
55:6c1dfe4da5dd 56:63223d4fd956
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description:  Extracts metadata from a file
    14 * Description:  Extracts metadata from a file
    15 *  Version     : %version: da1mmcf#38.1.4.2.6.1.5.3.8 % << Don't touch! Updated by Synergy at check-out.
    15 *  Version     : %version: da1mmcf#38.1.4.2.6.1.15 % << Don't touch! Updated by Synergy at check-out.
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 #include <e32base.h>
    19 #include <e32base.h>
    20 #include <badesca.h>
    20 #include <badesca.h>
    50 _LIT( KWmaCafMimeType, "x-caf-audio/x-ms-wma" );
    50 _LIT( KWmaCafMimeType, "x-caf-audio/x-ms-wma" );
    51 
    51 
    52 #ifdef RD_MPX_TNM_INTEGRATION
    52 #ifdef RD_MPX_TNM_INTEGRATION
    53 _LIT( KImageFileType, "image/jpeg" );
    53 _LIT( KImageFileType, "image/jpeg" );
    54 const TInt KMPXTimeoutTimer = 3000000; // 3 seconds
    54 const TInt KMPXTimeoutTimer = 3000000; // 3 seconds
    55 const TInt KMPXMaxThumbnailRequest = 2;
    55 const TInt KMPXMaxThumbnailRequest = 2; 
    56 #endif //RD_MPX_TNM_INTEGRATION
    56 #endif //RD_MPX_TNM_INTEGRATION
    57 
    57 
    58 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
    58 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
    59 _LIT( KNonEmbeddedArtExt, ".alb" );
    59 _LIT( KNonEmbeddedArtExt, ".alb" );
    60 #endif
    60 #endif
   184     iFileOpenError = KErrNone;
   184     iFileOpenError = KErrNone;
   185     iObs = NULL;
   185     iObs = NULL;
   186     aNewProperty = NULL;
   186     aNewProperty = NULL;
   187     iFileName = aFile;
   187     iFileName = aFile;
   188     iMetadataOnly = aMetadataOnly;
   188     iMetadataOnly = aMetadataOnly;
   189 
   189     
   190     // populate the task array
   190     // populate the task array
   191     AddTasksL();
   191     AddTasksL();
   192 
   192     
   193     // execute all tasks in the array
   193     // execute all tasks in the array
   194     while ( iArrayTasks.Count() )
   194     while ( iArrayTasks.Count() )
   195         {
   195         {
   196         // execute task at index 0
   196         // execute task at index 0
   197         MPX_TRAPD( error, ExecuteTaskL() );
   197         MPX_TRAPD( error, ExecuteTaskL() );
   209                 CleanUp();
   209                 CleanUp();
   210                 User::LeaveIfError( error );
   210                 User::LeaveIfError( error );
   211                 }
   211                 }
   212             break;
   212             break;
   213             }
   213             }
   214 
   214         
   215         iArrayTasks.Remove( 0 );
   215         iArrayTasks.Remove( 0 );
   216         }
   216         }
   217 
   217     
   218     aNewProperty = iMedia;
   218     aNewProperty = iMedia;
   219     iMedia = NULL;  // ownership transferred.
   219     iMedia = NULL;  // ownership transferred.
   220     CleanUp();
   220     CleanUp();
   221     }
   221     }
   222 
   222 
   234     aMediaProp.SetTextValueL( KMPXMediaMusicArtist,
   234     aMediaProp.SetTextValueL( KMPXMediaMusicArtist,
   235                               KNullDesC );
   235                               KNullDesC );
   236     // Album
   236     // Album
   237     aMediaProp.SetTextValueL( KMPXMediaMusicAlbum,
   237     aMediaProp.SetTextValueL( KMPXMediaMusicAlbum,
   238                               KNullDesC );
   238                               KNullDesC );
       
   239     // Year
       
   240     aMediaProp.SetTObjectValueL<TInt64>( KMPXMediaMusicYear,
       
   241                                          (TInt64) 0 );
   239     // Track
   242     // Track
   240     aMediaProp.SetTextValueL( KMPXMediaMusicAlbumTrack,
   243     aMediaProp.SetTextValueL( KMPXMediaMusicAlbumTrack,
   241                               KNullDesC );
   244                               KNullDesC );
   242     // Genre
   245     // Genre
   243     aMediaProp.SetTextValueL( KMPXMediaMusicGenre,
   246     aMediaProp.SetTextValueL( KMPXMediaMusicGenre,
   249     aMediaProp.SetTextValueL( KMPXMediaMusicAlbumArtFileName,
   252     aMediaProp.SetTextValueL( KMPXMediaMusicAlbumArtFileName,
   250                               KNullDesC );
   253                               KNullDesC );
   251     // URL
   254     // URL
   252     aMediaProp.SetTextValueL( KMPXMediaMusicURL,
   255     aMediaProp.SetTextValueL( KMPXMediaMusicURL,
   253                               KNullDesC );
   256                               KNullDesC );
   254     // AlbumArtist
       
   255     aMediaProp.SetTextValueL( KMPXMediaMusicAlbumArtist,
       
   256                               KNullDesC );
       
   257     
       
   258     }
   257     }
   259 
   258 
   260 // ---------------------------------------------------------------------------
   259 // ---------------------------------------------------------------------------
   261 // Sets media object attributes from metadata utilities
   260 // Sets media object attributes from metadata utilities
   262 // ---------------------------------------------------------------------------
   261 // ---------------------------------------------------------------------------
   266     MPX_FUNC("CMPXMetadataExtractor::SetMediaPropertiesL()");
   265     MPX_FUNC("CMPXMetadataExtractor::SetMediaPropertiesL()");
   267 
   266 
   268     const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   267     const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   269     HBufC8* mimeType8 = HBufC8::NewLC( mimeType.Length() );
   268     HBufC8* mimeType8 = HBufC8::NewLC( mimeType.Length() );
   270     mimeType8->Des().Append( mimeType );
   269     mimeType8->Des().Append( mimeType );
   271 
   270     
   272     // Continue to extract metadata even if fail.
   271     // Continue to extract metadata even if fail.
   273     MPX_TRAPD( metadataerror, iMetadataUtility->OpenFileL( iFile, *mimeType8 ) );
   272     MPX_TRAPD( metadataerror, iMetadataUtility->OpenFileL( iFile, *mimeType8 ) );
   274     CleanupStack::PopAndDestroy( mimeType8 );
   273     CleanupStack::PopAndDestroy( mimeType8 );
   275 
   274     
   276     // Get MetadataUtility Container
   275     // Get MetadataUtility Container
   277     const CMetaDataFieldContainer& metaCont = iMetadataUtility->MetaDataFieldsL();
   276     const CMetaDataFieldContainer& metaCont = iMetadataUtility->MetaDataFieldsL();
   278 
   277 
   279     // Get DRM data
   278     // Get DRM data
   280     // Need the protected flag from metadataUtility Container
   279     // Need the protected flag from metadataUtility Container
   281     MPX_TRAPD( drmerror, SetDrmMediaPropertiesL( metaCont ) );
   280     MPX_TRAPD( drmerror, SetDrmMediaPropertiesL( metaCont ) );
   282     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, result=%d getting drm data",
   281     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, result=%d getting drm data", 
   283             drmerror );
   282             drmerror );
   284 
   283         
   285     // Get metadata fields
   284     // Get metadata fields
   286     TInt count( metaCont.Count() );
   285     TInt count( metaCont.Count() );
   287     for( TInt i=0; i<count; ++i )
   286     for( TInt i=0; i<count; ++i )
   288         {
   287         {
   289         TMetaDataFieldId fieldType;
   288         TMetaDataFieldId fieldType;
   290 
   289 
   291         HBufC* value = NULL;
   290         HBufC* value = NULL;
   292         metaCont.FieldIdAt( i, fieldType );  // get the field type
   291         metaCont.FieldIdAt( i, fieldType );  // get the field type
   293 
   292         
   294         // get the value, except for album art
   293         // get the value, except for album art
   295         if ( fieldType != EMetaDataJpeg )
   294         if ( fieldType != EMetaDataJpeg )
   296            {
   295            {
   297             MPX_TRAPD( err, value = metaCont.At( i, fieldType ).AllocL() );
   296             MPX_TRAPD( err, value = metaCont.At( i, fieldType ).AllocL() );
   298            if ( KErrNone != err )
   297            if ( KErrNone != err )
   299                {
   298                {
   300                MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL - error = %i", err);
   299                MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL - error = %i", err);           
   301                continue;
   300                continue;
   302                }
   301                }     
   303            CleanupStack::PushL( value );
   302            CleanupStack::PushL( value );
   304            }
   303            }
   305 
   304         
   306         switch( fieldType )
   305         switch( fieldType )
   307             {
   306             {
   308             case EMetaDataSongTitle:
   307             case EMetaDataSongTitle:
   309                 {
   308                 {
   310                 TPtr valptr = value->Des();
   309                 TPtr valptr = value->Des();
   408                 {
   407                 {
   409                 iMedia->SetTextValueL( KMPXMediaGeneralCopyright,
   408                 iMedia->SetTextValueL( KMPXMediaGeneralCopyright,
   410                                       *value );
   409                                       *value );
   411                 break;
   410                 break;
   412                 }
   411                 }
   413             case EMetaDataDuration:
   412             case EMetaDataDuration:     
   414                 {
   413                 {                  
   415                 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   414                 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   416                 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType);
   415                 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType);   
   417 
   416                 
   418                 // Verify if WMA, get the duration
   417                 // Verify if WMA, get the duration
   419                 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   418                 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   420                     {
   419                     {
   421                     MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA");
   420                     MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA");                         
   422 
   421 
   423                     // Perform the duration conversion
   422                     // Perform the duration conversion
   424                     TLex lexer( *value );
   423                     TLex lexer( *value );
   425                     TInt32 duration ( 0 );
   424                     TInt32 duration ( 0 );
   426                     lexer.Val( duration );   // [second]
   425                     lexer.Val( duration );   // [second]      
   427                     duration *= 1000;        // [msec]
   426                     duration *= 1000;        // [msec]
   428 
   427                 
   429                     iMedia->SetTObjectValueL<TInt32>( KMPXMediaGeneralDuration,
   428                     iMedia->SetTObjectValueL<TInt32>( KMPXMediaGeneralDuration,
   430                                                 duration );
   429                                                 duration );      
   431 
   430                 
   432                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- duration = %i", duration);
   431                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- duration = %i", duration);  
   433                     }
   432                     }
   434                 break;
   433                 break;
   435                 }
   434                 }
   436             case EMetaDataSampleRate:
   435             case EMetaDataSampleRate:     
   437                 {
   436                 {                  
   438                 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   437                 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   439                 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType);
   438                 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType);   
   440 
   439                 
   441                 // Verify if WMA, get the sample rate
   440                 // Verify if WMA, get the sample rate
   442                 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   441                 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   443                     {
   442                     {
   444                     MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA");
   443                     MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA");                         
   445 
   444 
   446                     // Perform the sample rate conversion
   445                     // Perform the sample rate conversion
   447                     TLex lexer( *value );
   446                     TLex lexer( *value );
   448                     TInt32 sampleRate ( 0 );
   447                     TInt32 sampleRate ( 0 );
   449                     lexer.Val( sampleRate );
   448                     lexer.Val( sampleRate );         
   450 
   449                     
   451                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioSamplerate,
   450                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioSamplerate,
   452                                                       sampleRate );
   451                                                       sampleRate );
   453 
   452                            
   454                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- sample rate = %i", sampleRate);
   453                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- sample rate = %i", sampleRate);  
   455                     }
   454                     }
   456                 break;
   455                 break;
   457                 }
   456                 }
   458             case EMetaDataBitRate:
   457             case EMetaDataBitRate:     
   459                 {
   458                 {                  
   460                 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   459                 const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   461                 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType);
   460                 MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL, mimeType = %S", &mimeType);   
   462 
   461                 
   463                 // Verify if WMA, get the duration
   462                 // Verify if WMA, get the duration
   464                 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   463                 if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   465                     {
   464                     {
   466                     MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA");
   465                     MPX_DEBUG1("CMPXMetadataExtractor::SetMediaPropertiesL- WMA");                         
   467 
   466 
   468                     // Perform the duration conversion
   467                     // Perform the duration conversion
   469                     TLex lexer( *value );
   468                     TLex lexer( *value );
   470                     TInt32 bitRate ( 0 );
   469                     TInt32 bitRate ( 0 );
   471                     lexer.Val( bitRate );
   470                     lexer.Val( bitRate );   
   472 
   471                 
   473                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioBitrate,
   472                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioBitrate,
   474                                                      bitRate );
   473                                                      bitRate );
   475 
   474                 
   476                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- duration = %i", bitRate);
   475                     MPX_DEBUG2("CMPXMetadataExtractor::SetMediaPropertiesL- duration = %i", bitRate);  
   477                     }
       
   478                 break;
       
   479                 }
       
   480             case EMetaDataAlbumArtist:
       
   481                 {
       
   482                 TPtr valptr = value->Des();
       
   483                 valptr.Trim();
       
   484                 TInt vallen = value->Length();
       
   485                 if (vallen>0)
       
   486                     {
       
   487                     FindAndReplaceForbiddenChars(valptr, vallen);
       
   488                     iMedia->SetTextValueL(KMPXMediaMusicAlbumArtist, *value);
       
   489                     }
   476                     }
   490                 break;
   477                 break;
   491                 }
   478                 }
   492             case EMetaDataOriginalArtist:  // fall through
   479             case EMetaDataOriginalArtist:  // fall through
   493             case EMetaDataVendor:          // fall through
   480             case EMetaDataVendor:          // fall through
   504                 break;
   491                 break;
   505                 }
   492                 }
   506             }
   493             }
   507         if (fieldType != EMetaDataJpeg)
   494         if (fieldType != EMetaDataJpeg)
   508             {
   495             {
   509             CleanupStack::PopAndDestroy( value );
   496             CleanupStack::PopAndDestroy( value );       
   510             }
   497             }
   511         }
   498         }
   512     }
   499     }
   513 
   500 
   514 // ---------------------------------------------------------------------------
   501 // ---------------------------------------------------------------------------
   524     //
   511     //
   525     TInt size( 0 );
   512     TInt size( 0 );
   526     if( iFileOpenError == KErrNone )
   513     if( iFileOpenError == KErrNone )
   527         {
   514         {
   528         const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   515         const TDesC& mimeType = iMedia->ValueText( KMPXMediaGeneralMimeType );
   529         MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL, mimeType = %S", &mimeType);
   516         MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL, mimeType = %S", &mimeType);   
   530         iFile.Size( size );
   517         iFile.Size( size );
   531         iMedia->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, size );
   518         iMedia->SetTObjectValueL<TInt>( KMPXMediaGeneralSize, size );
   532 
   519         
   533         // Verify if WMA, skip getting info from MMF
   520         // Verify if WMA, skip getting info from MMF
   534         if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   521         if( mimeType.Compare(KWmaMimeType) == 0 || mimeType.Compare(KWmaCafMimeType) == 0 )
   535             {
   522             {
   536             // No need to get MMF support
   523             // No need to get MMF support
   537             MPX_DEBUG1("CMPXMetadataExtractor::SetExtMediaPropertiesL, skip MMF ");
   524             MPX_DEBUG1("CMPXMetadataExtractor::SetExtMediaPropertiesL, skip MMF ");   
   538             }
   525             }
   539         else
   526         else
   540             {
   527             {
   541             MPX_DEBUG1("CMPXMetadataExtractor::SetExtMediaPropertiesL, get MMF controller");
   528             MPX_DEBUG1("CMPXMetadataExtractor::SetExtMediaPropertiesL, get MMF controller");   
   542             // Duration, bitrate, samplerate, etc
   529             // Duration, bitrate, samplerate, etc
   543             //
   530             //
   544             if( !iMetadataOnly )
   531             if( !iMetadataOnly )
   545             {
   532             {
   546                 MPX_TRAPD(err2, iFileInfoUtil->OpenFileL(
   533                 MPX_TRAPD(err2, iFileInfoUtil->OpenFileL(
   547                           iFile,
   534                           iFile, 
   548                           iMedia->ValueText(KMPXMediaGeneralMimeType)));
   535                           iMedia->ValueText(KMPXMediaGeneralMimeType)));
   549                 MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL, file info util error %i", err2);
   536                 MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL, file info util error %i", err2);
   550                 if( KErrNone == err2 )
   537                 if( KErrNone == err2 )
   551                     {
   538                     {
   552                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioBitrate,
   539                     iMedia->SetTObjectValueL<TUint>( KMPXMediaAudioBitrate,
   557                     iMedia->SetTObjectValueL<TInt32>( KMPXMediaGeneralDuration,
   544                     iMedia->SetTObjectValueL<TInt32>( KMPXMediaGeneralDuration,
   558                                                     duration );
   545                                                     duration );
   559 
   546 
   560                     MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL -- duration %i", duration);
   547                     MPX_DEBUG2("CMPXMetadataExtractor::SetExtMediaPropertiesL -- duration %i", duration);
   561                     }
   548                     }
   562 
   549                 
   563                 iFileInfoUtil->Reset();
   550                 iFileInfoUtil->Reset();
   564                 }
   551                 }
   565             }
   552             }
   566         }
   553         }
   567     }
   554     }
   593 
   580 
   594 // ---------------------------------------------------------------------------
   581 // ---------------------------------------------------------------------------
   595 // CMPXMetadataExtractor::ThumbnailPreviewReady
   582 // CMPXMetadataExtractor::ThumbnailPreviewReady
   596 // Callback but not used here
   583 // Callback but not used here
   597 // ---------------------------------------------------------------------------
   584 // ---------------------------------------------------------------------------
   598 void CMPXMetadataExtractor::ThumbnailPreviewReady(
   585 void CMPXMetadataExtractor::ThumbnailPreviewReady( 
   599         MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ )
   586         MThumbnailData& /*aThumbnail*/, TThumbnailRequestId /*aId*/ )
   600     {
   587     {
   601     MPX_FUNC("CMPXMetadataExtractor::ThumbnailPreviewReady()");
   588     MPX_FUNC("CMPXMetadataExtractor::ThumbnailPreviewReady()");
   602     }
   589     }
   603 
   590         
   604 
   591 
   605 // ---------------------------------------------------------------------------
   592 // ---------------------------------------------------------------------------
   606 // CMPXMetadataExtractor::ThumbnailReady
   593 // CMPXMetadataExtractor::ThumbnailReady
   607 // Callback but not used here
   594 // Callback but not used here
   608 // ---------------------------------------------------------------------------
   595 // ---------------------------------------------------------------------------
   609 void CMPXMetadataExtractor::ThumbnailReady( TInt /*aError*/,
   596 void CMPXMetadataExtractor::ThumbnailReady( TInt /*aError*/, 
   610         MThumbnailData& /*aThumbnail*/, TThumbnailRequestId aId )
   597         MThumbnailData& /*aThumbnail*/, TThumbnailRequestId aId )
   611     {
   598     {
   612     MPX_FUNC("CMPXMetadataExtractor::ThumbnailReady()");
   599     MPX_FUNC("CMPXMetadataExtractor::ThumbnailReady()");
   613 
   600     
   614     // Remove thumbnail id from array.
   601     // Remove thumbnail id from array.
   615     TInt index = iArrayTNRequestId.Find( aId );
   602     TInt index = iArrayTNRequestId.Find( aId );
   616     if ( index >= 0 )
   603     if ( index >= 0 )
   617         {
   604         {
   618         iArrayTNRequestId.Remove( index );
   605         iArrayTNRequestId.Remove( index );
   633     {
   620     {
   634     MPX_FUNC("CMPXMetadataExtractor::TimeoutTimerCallback()");
   621     MPX_FUNC("CMPXMetadataExtractor::TimeoutTimerCallback()");
   635 
   622 
   636     CMPXMetadataExtractor* ptr =
   623     CMPXMetadataExtractor* ptr =
   637         static_cast<CMPXMetadataExtractor*>(aPtr);
   624         static_cast<CMPXMetadataExtractor*>(aPtr);
   638 
   625         
   639     // Timer expired before thumbnail callback occurred. Stop wait loop to unblock.
   626     // Timer expired before thumbnail callback occurred. Stop wait loop to unblock. 
   640     ptr->StopWaitLoop();
   627     ptr->StopWaitLoop();
   641     return KErrNone;
   628     return KErrNone;
   642     }
   629     }
   643 
   630 
   644 // ----------------------------------------------------------------------------
   631 // ----------------------------------------------------------------------------
   647 void CMPXMetadataExtractor::StopWaitLoop()
   634 void CMPXMetadataExtractor::StopWaitLoop()
   648     {
   635     {
   649     MPX_FUNC("CMPXMetadataExtractor::StopWaitLoop()");
   636     MPX_FUNC("CMPXMetadataExtractor::StopWaitLoop()");
   650     // Cancel timer
   637     // Cancel timer
   651     CancelTimeoutTimer();
   638     CancelTimeoutTimer();
   652 
   639     
   653     // Stop wait loop to unblock.
   640     // Stop wait loop to unblock.
   654     if ( iTNSyncWait->IsStarted() )
   641     if ( iTNSyncWait->IsStarted() )
   655         {
   642         {
   656         MPX_DEBUG1("CMPXMetadataExtractor::StopWaitLoop(): Stopping the wait loop.");
   643         MPX_DEBUG1("CMPXMetadataExtractor::StopWaitLoop(): Stopping the wait loop.");
   657         iTNSyncWait->AsyncStop();
   644         iTNSyncWait->AsyncStop();
   658         }
   645         }
   659     }
   646     }
   660 
   647 
   661 // ----------------------------------------------------------------------------
   648 // ----------------------------------------------------------------------------
   662 // Cancel timer.
   649 // Cancel timer. 
   663 // ----------------------------------------------------------------------------
   650 // ----------------------------------------------------------------------------
   664 void CMPXMetadataExtractor::CancelTimeoutTimer()
   651 void CMPXMetadataExtractor::CancelTimeoutTimer()
   665     {
   652     {
   666     MPX_FUNC("CMPXMetadataExtractor::CancelTimeoutTimer()");
   653     MPX_FUNC("CMPXMetadataExtractor::CancelTimeoutTimer()");
   667 
   654     
   668     // Cancel timer.
   655     // Cancel timer.
   669     if ( iTimer && iTimer->IsActive() )
   656     if ( iTimer && iTimer->IsActive() )
   670         {
   657         {
   671         MPX_DEBUG1("CMPXMetadataExtractor::CancelTimeoutTimer(): Timer active, cancelling");
   658         MPX_DEBUG1("CMPXMetadataExtractor::CancelTimeoutTimer(): Timer active, cancelling");
   672         iTimer->Cancel();
   659         iTimer->Cancel();
   679 EXPORT_C TInt CMPXMetadataExtractor::ExtractAlbumArtL( CMPXMedia* aMedia )
   666 EXPORT_C TInt CMPXMetadataExtractor::ExtractAlbumArtL( CMPXMedia* aMedia )
   680     {
   667     {
   681     MPX_FUNC("CMPXMetadataExtractor::ExtractAlbumArtL()");
   668     MPX_FUNC("CMPXMetadataExtractor::ExtractAlbumArtL()");
   682     TInt err = KErrNone;
   669     TInt err = KErrNone;
   683     iCancelled = EFalse;
   670     iCancelled = EFalse;
   684 
   671     
   685     if ( !aMedia->IsSupported(KMPXMediaGeneralUri) )
   672     if ( !aMedia->IsSupported(KMPXMediaGeneralUri) )
   686         {
   673         {
   687         return KErrArgument;
   674         return KErrArgument;
   688         }
   675         }
   689 
   676     
   690     // Get full file name.
   677     // Get full file name.
   691     const TDesC& path = aMedia->ValueText(KMPXMediaGeneralUri);
   678     const TDesC& path = aMedia->ValueText(KMPXMediaGeneralUri);
   692     MPX_DEBUG2("CMPXMetadataExtractor::ExtractAlbumArtL Filename:%S ", &path );
   679     MPX_DEBUG2("CMPXMetadataExtractor::ExtractAlbumArtL Filename:%S ", &path );
   693 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
   680 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
   694     TParsePtrC parse( path );
   681     TParsePtrC parse( path );
   706             TBuf<20> mimeType(KImageFileType);
   693             TBuf<20> mimeType(KImageFileType);
   707             TInt sampleData = aMedia->ValueTObjectL<TInt>(KMPXMediaMTPSampleData);
   694             TInt sampleData = aMedia->ValueTObjectL<TInt>(KMPXMediaMTPSampleData);
   708             HBufC8* value8 = ((HBufC8*)sampleData)->Des().AllocLC();   // make a local copy of sampleData
   695             HBufC8* value8 = ((HBufC8*)sampleData)->Des().AllocLC();   // make a local copy of sampleData
   709             source = CThumbnailObjectSource::NewLC(
   696             source = CThumbnailObjectSource::NewLC(
   710                 value8, mimeType, path );    // give up ownership of value8
   697                 value8, mimeType, path );    // give up ownership of value8
   711 
   698             
   712             MPX_DEBUG1("CMPXMetadataExtractor::ExtractAlbumArtL source created from buffer");
   699             MPX_DEBUG1("CMPXMetadataExtractor::ExtractAlbumArtL source created from buffer");
   713             TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source );
   700             TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source );
   714             iArrayTNRequestId.Append( tnId );
   701             iArrayTNRequestId.Append( tnId );
   715             CleanupStack::PopAndDestroy( source );
   702             CleanupStack::PopAndDestroy( source );
   716             CleanupStack::Pop( value8 );
   703             CleanupStack::Pop( value8 );
   717             }
   704             }
   718         else
   705         else
   719             {
   706             {
   720             source = CThumbnailObjectSource::NewLC(
   707             source = CThumbnailObjectSource::NewLC(
   721                 path, KImageFileType  );
   708                 path, KImageFileType  );
   722 
   709             
   723             MPX_DEBUG1("CMPXMetadataExtractor::ExtractAlbumArtL source created from path");
   710             MPX_DEBUG1("CMPXMetadataExtractor::ExtractAlbumArtL source created from path");
   724             TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source );
   711             TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source );
   725             iArrayTNRequestId.Append( tnId );
   712             iArrayTNRequestId.Append( tnId );
   726             CleanupStack::PopAndDestroy( source );
   713             CleanupStack::PopAndDestroy( source );
   727             }
   714             }
   732 #endif // ABSTRACTAUDIOALBUM_INCLUDED
   719 #endif // ABSTRACTAUDIOALBUM_INCLUDED
   733     // create wanted fields array
   720     // create wanted fields array
   734     RArray<TMetaDataFieldId> wantedFields;
   721     RArray<TMetaDataFieldId> wantedFields;
   735     CleanupClosePushL( wantedFields );
   722     CleanupClosePushL( wantedFields );
   736     wantedFields.Append(EMetaDataJpeg);
   723     wantedFields.Append(EMetaDataJpeg);
   737 
   724     
   738     // Open file
   725     // Open file
   739     if ( aMedia->IsSupported(KMPXMediaGeneralMimeType) )
   726     if ( aMedia->IsSupported(KMPXMediaGeneralMimeType) )
   740         {
   727         {
   741         const TDesC& mimeType = aMedia->ValueText( KMPXMediaGeneralMimeType );
   728         const TDesC& mimeType = aMedia->ValueText( KMPXMediaGeneralMimeType );
   742         MPX_DEBUG2("CMPXMetadataExtractor::ExtractAlbumArtL MimeType:%S ", &mimeType );
   729         MPX_DEBUG2("CMPXMetadataExtractor::ExtractAlbumArtL MimeType:%S ", &mimeType );
   748     else
   735     else
   749         {
   736         {
   750         MPX_TRAP( err, iMetadataUtility->OpenFileL( path, wantedFields ) );
   737         MPX_TRAP( err, iMetadataUtility->OpenFileL( path, wantedFields ) );
   751         }
   738         }
   752     CleanupStack::PopAndDestroy( &wantedFields );
   739     CleanupStack::PopAndDestroy( &wantedFields );
   753 
   740     
   754     if ( !err )
   741     if ( !err )
   755         {
   742         {
   756         //check if can send TN request, If thumbnail creation is ongoing, wait til it is done
   743         //check if can send TN request, If thumbnail creation is ongoing, wait til it is done
   757         CheckBeforeSendRequest();
   744         CheckBeforeSendRequest();
   758         MPX_TRAP( err, AddMediaAlbumArtL( *aMedia, path ));
   745         MPX_TRAP( err, AddMediaAlbumArtL( *aMedia, path ));
   767     }
   754     }
   768 
   755 
   769 // ----------------------------------------------------------------------------
   756 // ----------------------------------------------------------------------------
   770 // Add album art to media object.
   757 // Add album art to media object.
   771 // ----------------------------------------------------------------------------
   758 // ----------------------------------------------------------------------------
   772 void CMPXMetadataExtractor::AddMediaAlbumArtL( CMPXMedia& aMedia,
   759 void CMPXMetadataExtractor::AddMediaAlbumArtL( CMPXMedia& aMedia, 
   773                                                const TDesC& aFile )
   760                                                const TDesC& aFile )
   774     {
   761     {
   775     MPX_FUNC("CMPXMetadataExtractor::AddMediaAlbumArtL()");
   762     MPX_FUNC("CMPXMetadataExtractor::AddMediaAlbumArtL()");
   776 
   763     
   777     // get metadata container.
   764     // get metadata container.
   778     const CMetaDataFieldContainer& metaCont = iMetadataUtility->MetaDataFieldsL();
   765     const CMetaDataFieldContainer& metaCont = iMetadataUtility->MetaDataFieldsL();
   779     TPtrC8 data8 = metaCont.Field8( EMetaDataJpeg );
   766     TPtrC8 data8 = metaCont.Field8( EMetaDataJpeg );
   780 
   767    
   781     if ( data8.Length() )
   768     if ( data8.Length() )
   782         {
   769         {
   783         MPX_DEBUG1("CMPXMetadataExtractor::GetMediaAlbumArtL(): Album art exist.");
   770         MPX_DEBUG1("CMPXMetadataExtractor::GetMediaAlbumArtL(): Album art exist.");
   784 #ifdef RD_MPX_TNM_INTEGRATION
   771 #ifdef RD_MPX_TNM_INTEGRATION
   785         HBufC8* value8 = NULL;
   772         HBufC8* value8 = NULL; 
   786         MPX_TRAPD( err, value8 = data8.AllocL() );
   773         MPX_TRAPD( err, value8 = data8.AllocL() );
   787         if ( KErrNone != err )
   774         if ( KErrNone != err )
   788             {
   775             {
   789             MPX_DEBUG2("CMPXMetadataExtractor::GetMediaAlbumArtL - error jpeg = %i", err);
   776             MPX_DEBUG2("CMPXMetadataExtractor::GetMediaAlbumArtL - error jpeg = %i", err);
   790             return;
   777             return;
   791             }
   778             }              
   792         CleanupStack::PushL( value8 );
   779         CleanupStack::PushL( value8 );
   793 
   780     
   794         TBuf<256> mimeType;
   781         TBuf<256> mimeType;
   795         mimeType.Copy( KImageFileType );
   782         mimeType.Copy( KImageFileType );
   796         CThumbnailObjectSource* source = CThumbnailObjectSource::NewL(
   783         CThumbnailObjectSource* source = CThumbnailObjectSource::NewL(
   797                 value8, mimeType, aFile );
   784                 value8, mimeType, aFile );
   798         TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source );
   785         TThumbnailRequestId tnId = iTNManager->CreateThumbnails( *source );
   799         iArrayTNRequestId.Append( tnId ); // add thumbnail id to array
   786         iArrayTNRequestId.Append( tnId ); // add thumbnail id to array
   800         CleanupStack::Pop( value8 );
   787         CleanupStack::Pop( value8 );
   801         delete source;
   788         delete source;
   802 
   789         
   803         aMedia.SetTextValueL( KMPXMediaMusicOriginalAlbumArtFileName, aFile );
   790         aMedia.SetTextValueL( KMPXMediaMusicOriginalAlbumArtFileName, aFile );
   804 #endif // RD_MPX_TNM_INTEGRATION
   791 #endif // RD_MPX_TNM_INTEGRATION          
   805         aMedia.SetTextValueL( KMPXMediaMusicAlbumArtFileName, aFile );
   792         aMedia.SetTextValueL( KMPXMediaMusicAlbumArtFileName, aFile );
   806         }
   793         }
   807     }
   794     }
   808 
   795 
   809 // ----------------------------------------------------------------------------
   796 // ----------------------------------------------------------------------------
   937         }
   924         }
   938     else // other case use apparc to fetch and set mimetype
   925     else // other case use apparc to fetch and set mimetype
   939         {
   926         {
   940         TDataType dataType;
   927         TDataType dataType;
   941         TUid dummyUid(KNullUid);
   928         TUid dummyUid(KNullUid);
   942         // File handle based mime type recogniton required , because AppArc does 
   929         iAppArc.AppForDocument(iFileName, dummyUid, dataType);
   943         // not have All Files capa required for files in private folders 
       
   944         TDataRecognitionResult result;
       
   945         RFs fs;
       
   946 		RFile rFile;
       
   947         User::LeaveIfError(fs.Connect());
       
   948 		CleanupClosePushL(fs);
       
   949         User::LeaveIfError(fs.ShareProtected());
       
   950         User::LeaveIfError(rFile.Open(fs, iFileName, EFileShareReadersOrWriters));
       
   951 		CleanupClosePushL(rFile);
       
   952         User::LeaveIfError(iAppArc.RecognizeData(rFile, result)); 
       
   953         CleanupStack::PopAndDestroy(&rFile);
       
   954         CleanupStack::PopAndDestroy(&fs);
       
   955         dataType = result.iDataType;
       
   956         iMedia->SetTextValueL( KMPXMediaGeneralMimeType,dataType.Des() );
   930         iMedia->SetTextValueL( KMPXMediaGeneralMimeType,dataType.Des() );
   957         }
   931         }
   958 
   932         
   959     // Initially set default tags.
   933     // Initially set default tags.
   960     SetDefaultL( *iMedia );
   934     SetDefaultL( *iMedia );
   961     }
   935     }
   962 
   936 
   963 // ----------------------------------------------------------------------------
   937 // ----------------------------------------------------------------------------
  1005     if ( iArrayTasks.Count() )
   979     if ( iArrayTasks.Count() )
  1006         {
   980         {
  1007         MPX_DEBUG1("CMPXMetadataExtractor::CreateMediaAsyncL Request ongoing. Abort!" );
   981         MPX_DEBUG1("CMPXMetadataExtractor::CreateMediaAsyncL Request ongoing. Abort!" );
  1008         User::Leave( KErrAbort );
   982         User::Leave( KErrAbort );
  1009         }
   983         }
  1010 
   984     
  1011     iCancelled = EFalse;
   985     iCancelled = EFalse;
  1012     iFileOpenError = KErrNone;
   986     iFileOpenError = KErrNone;
  1013     iFileName = aFile;
   987     iFileName = aFile;
  1014     iObs = aObs;
   988     iObs = aObs;
  1015     iMetadataOnly = aMetadataOnly;
   989     iMetadataOnly = aMetadataOnly;
  1016 
   990     
  1017     // populate the task array
   991     // populate the task array
  1018     AddTasksL();
   992     AddTasksL();
  1019 
   993     
  1020     // Start task timer to execute task
   994     // Start task timer to execute task
  1021     if ( iArrayTasks.Count() )
   995     if ( iArrayTasks.Count() )
  1022         {
   996         {
  1023         if ( iTaskTimer->IsActive() )
   997         if ( iTaskTimer->IsActive() )
  1024             {
   998             {
  1025             iTaskTimer->Cancel();
   999             iTaskTimer->Cancel();
  1026             }
  1000             }   
  1027         iTaskTimer->Start( 0, 0, TCallBack(TaskTimerCallback, this ));
  1001         iTaskTimer->Start( 0, 0, TCallBack(TaskTimerCallback, this ));
  1028         }
  1002         }
  1029     }
  1003     }
  1030 
  1004 
  1031 // ---------------------------------------------------------------------------
  1005 // ---------------------------------------------------------------------------
  1033 // ---------------------------------------------------------------------------
  1007 // ---------------------------------------------------------------------------
  1034 //
  1008 //
  1035 TInt CMPXMetadataExtractor::OpenFile()
  1009 TInt CMPXMetadataExtractor::OpenFile()
  1036     {
  1010     {
  1037     MPX_FUNC("CMPXMetadataExtractor::OpenFile()");
  1011     MPX_FUNC("CMPXMetadataExtractor::OpenFile()");
  1038 
  1012     
  1039     // Open the file
  1013     // Open the file
  1040     iFile.Close();
  1014     iFile.Close();
  1041     TInt error = iFile.Open( iFs, iFileName, EFileRead | EFileShareReadersOrWriters );
  1015     TInt error = iFile.Open( iFs, iFileName, EFileRead | EFileShareReadersOrWriters );
  1042     MPX_DEBUG2("CMPXMetadataExtractor::OpenFile open error = %d", error );
  1016     MPX_DEBUG2("CMPXMetadataExtractor::OpenFile open error = %d", error );
  1043     return error;
  1017     return error;
  1049 //
  1023 //
  1050 void CMPXMetadataExtractor::AddTasksL()
  1024 void CMPXMetadataExtractor::AddTasksL()
  1051     {
  1025     {
  1052     MPX_FUNC("CMPXMetadataExtractor::AddTasks()");
  1026     MPX_FUNC("CMPXMetadataExtractor::AddTasks()");
  1053     iFileOpenError = OpenFile();
  1027     iFileOpenError = OpenFile();
  1054 
  1028     
  1055     // Do not change the order of the task below.
  1029     // Do not change the order of the task below.
  1056     iArrayTasks.Reset();
  1030     iArrayTasks.Reset();
  1057     if ( iFileOpenError == KErrNone )
  1031     if ( iFileOpenError == KErrNone )
  1058         {
  1032         {
  1059         // to avoid resources contention (i.e. accessing sql, file system, etc)
  1033         // to avoid resources contention (i.e. accessing sql, file system, etc)
  1090 // Handle task timer expired
  1064 // Handle task timer expired
  1091 // ----------------------------------------------------------------------------
  1065 // ----------------------------------------------------------------------------
  1092 void CMPXMetadataExtractor::HandleTaskTimerExpired()
  1066 void CMPXMetadataExtractor::HandleTaskTimerExpired()
  1093     {
  1067     {
  1094     MPX_FUNC("CMPXMetadataExtractor::HandleTaskTimerExpired()");
  1068     MPX_FUNC("CMPXMetadataExtractor::HandleTaskTimerExpired()");
  1095 
  1069     
  1096     if ( iTaskTimer && iTaskTimer->IsActive() )
  1070     if ( iTaskTimer && iTaskTimer->IsActive() )
  1097         {
  1071         {
  1098         iTaskTimer->Cancel();
  1072         iTaskTimer->Cancel();
  1099         }
  1073         }
  1100     // execute task at index 0
  1074     // execute task at index 0
  1107             delete iMedia;
  1081             delete iMedia;
  1108             iMedia = NULL;
  1082             iMedia = NULL;
  1109             }
  1083             }
  1110         iArrayTasks.Reset();
  1084         iArrayTasks.Reset();
  1111         }
  1085         }
  1112 
  1086     
  1113     // Remove task at index 0.
  1087     // Remove task at index 0.
  1114     if ( iArrayTasks.Count() )
  1088     if ( iArrayTasks.Count() )
  1115         {
  1089         {
  1116         iArrayTasks.Remove( 0 );
  1090         iArrayTasks.Remove( 0 );
  1117         }
  1091         }
  1118 
  1092     
  1119     // check if we have any more task to run
  1093     // check if we have any more task to run
  1120     if ( iArrayTasks.Count() )
  1094     if ( iArrayTasks.Count() )
  1121         {
  1095         {
  1122         // start task timer
  1096         // start task timer
  1123         iTaskTimer->Start( 0, 0, TCallBack(TaskTimerCallback, this ));
  1097         iTaskTimer->Start( 0, 0, TCallBack(TaskTimerCallback, this ));
  1128         if ( iObs && !iCancelled )
  1102         if ( iObs && !iCancelled )
  1129             {
  1103             {
  1130             iObs->HandleCreateMediaComplete( iMedia, error );
  1104             iObs->HandleCreateMediaComplete( iMedia, error );
  1131             iMedia = NULL;  // ownership transferred.
  1105             iMedia = NULL;  // ownership transferred.
  1132             }
  1106             }
  1133 
  1107         
  1134         CleanUp();
  1108         CleanUp();
  1135         }
  1109         }
  1136     }
  1110     }
  1137 
  1111 
  1138 // ----------------------------------------------------------------------------
  1112 // ----------------------------------------------------------------------------
  1159     // DB Flags to set
  1133     // DB Flags to set
  1160     TUint dbFlags(KMPXMediaGeneralFlagsSetOrUnsetBit);
  1134     TUint dbFlags(KMPXMediaGeneralFlagsSetOrUnsetBit);
  1161     // Validate the objects to be used
  1135     // Validate the objects to be used
  1162     MPX_ASSERT(iMedia);
  1136     MPX_ASSERT(iMedia);
  1163     MPX_ASSERT(iDrmMediaUtility);
  1137     MPX_ASSERT(iDrmMediaUtility);
  1164 
  1138     
  1165     // File Path
  1139     // File Path
  1166     TParsePtrC parse( iFileName );
  1140     TParsePtrC parse( iFileName );
  1167     iMedia->SetTextValueL( KMPXMediaGeneralUri, iFileName );
  1141     iMedia->SetTextValueL( KMPXMediaGeneralUri, iFileName );
  1168     iMedia->SetTextValueL( KMPXMediaGeneralDrive, parse.Drive() );
  1142     iMedia->SetTextValueL( KMPXMediaGeneralDrive, parse.Drive() );
  1169     MPX_DEBUG2("CMPXMetadataExtractor::SetDrmMediaPropertiesL - Filename=%S", &iFileName);
  1143     MPX_DEBUG2("CMPXMetadataExtractor::SetDrmMediaPropertiesL - Filename=%S", &iFileName);
  1170 
  1144 
  1171     // get the protected flag from MetadataUtility Container
  1145     // get the protected flag from MetadataUtility Container
  1172     TPtrC ptr = aMetaCont.Field( EMetaDataProtected );
  1146     TPtrC ptr = aMetaCont.Field( EMetaDataProtected );  
  1173     MPX_DEBUG2("CMPXMetadataExtractor::SetDrmMediaPropertiesL -- status=%S", &ptr);
  1147     MPX_DEBUG2("CMPXMetadataExtractor::SetDrmMediaPropertiesL -- status=%S", &ptr);
  1174     _LIT( KNonProtected, "0" );
  1148     _LIT( KNonProtected, "0" );
  1175     if ( ptr.Compare( KNonProtected ) == 0 )
  1149     if ( ptr.Compare( KNonProtected ) == 0 )
  1176         {
  1150         {
  1177         // this is non-protected file
  1151         // this is non-protected file
  1178         // prot = EFalse
  1152         // prot = EFalse
  1179         MPX_DEBUG1("CMPXMetadataExtractor::SetDrmMediaPropertiesL - non protected");
  1153         MPX_DEBUG1("CMPXMetadataExtractor::SetDrmMediaPropertiesL - non protected");
  1180         iMedia->SetTObjectValueL<TBool>( KMPXMediaDrmProtected, prot );
  1154         iMedia->SetTObjectValueL<TBool>( KMPXMediaDrmProtected, prot );
  1181         iMedia->SetTObjectValueL<TUint16>( KMPXMediaMTPDrmStatus, (TUint16)prot );
  1155         iMedia->SetTObjectValueL<TUint16>( KMPXMediaMTPDrmStatus, (TUint16)prot );
  1182         }
  1156         }
  1183     else
  1157     else  
  1184         {  // DRM file
  1158         {  // DRM file
  1185 
  1159 
  1186         // DRM Rights
  1160         // DRM Rights
  1187         //
  1161         //
  1188         CMPXMedia* drm = NULL;
  1162         CMPXMedia* drm = NULL;
  1230             User::LeaveIfError( drmError );
  1204             User::LeaveIfError( drmError );
  1231             }
  1205             }
  1232 
  1206 
  1233         iMedia->SetTObjectValueL<TBool>( KMPXMediaDrmProtected, prot );
  1207         iMedia->SetTObjectValueL<TBool>( KMPXMediaDrmProtected, prot );
  1234         iMedia->SetTObjectValueL<TUint16>( KMPXMediaMTPDrmStatus, (TUint16)prot );
  1208         iMedia->SetTObjectValueL<TUint16>( KMPXMediaMTPDrmStatus, (TUint16)prot );
  1235 
  1209     
  1236         iDrmMediaUtility->Close();
  1210         iDrmMediaUtility->Close();
  1237 
  1211     
  1238         }  // DRM file
  1212         }  // DRM file
  1239 
  1213 
  1240 
  1214     
  1241     // verify the file open status
  1215     // verify the file open status
  1242     if( iFileOpenError == KErrNotFound || iFileOpenError == KErrPathNotFound )
  1216     if( iFileOpenError == KErrNotFound || iFileOpenError == KErrPathNotFound )
  1243         {
  1217         {
  1244         dbFlags |= KMPXMediaGeneralFlagsIsInvalid;
  1218         dbFlags |= KMPXMediaGeneralFlagsIsInvalid;
  1245         }
  1219         }
  1246 
  1220     
  1247     // Finally set the db flag
  1221     // Finally set the db flag
  1248     //
  1222     //
  1249     iMedia->SetTObjectValueL( KMPXMediaGeneralFlags, dbFlags );
  1223     iMedia->SetTObjectValueL( KMPXMediaGeneralFlags, dbFlags );
  1250 
  1224    
  1251     }
  1225     }