mmappcomponents/mmmtpdataprovider/src/cmmmtpdpmetadatavideoaccess.cpp
changeset 25 d881023c13eb
parent 20 b1fb57be53fe
child 50 762d760dcfdf
equal deleted inserted replaced
21:a05c44bc3c61 25:d881023c13eb
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  *
    14 * Description:  Meta data Video access
    14  * Description:  Meta data Video access
    15 *
    15  *
    16 */
    16  */
    17 
    17 
    18 #include <ContentListingFactory.h>
    18 #include <ContentListingFactory.h>
    19 #include <MCLFContentListingEngine.h>
    19 #include <MCLFContentListingEngine.h>
    20 #include <driveinfo.h>
    20 #include <driveinfo.h>
    21 #include <pathinfo.h>
    21 #include <pathinfo.h>
    36 #include "cmmmtpdpmetadatavideoaccess.h"
    36 #include "cmmmtpdpmetadatavideoaccess.h"
    37 #include "mmmtpdplogger.h"
    37 #include "mmmtpdplogger.h"
    38 #include "mmmtpdputility.h"
    38 #include "mmmtpdputility.h"
    39 #include "tmmmtpdppanic.h"
    39 #include "tmmmtpdppanic.h"
    40 #include "mmmtpvideodbdefs.h"
    40 #include "mmmtpvideodbdefs.h"
    41 
    41 #include "tobjectdescription.h"
    42 static const TInt KMtpMaxStringLength = 255;
    42 
    43 static const TInt KMtpMaxDescriptionLength = 0x200;
       
    44 const TInt KStorageRootMaxLength = 10;
    43 const TInt KStorageRootMaxLength = 10;
    45 
    44 
    46 #ifdef _DEBUG
    45 #ifdef _DEBUG
    47 static const TInt KMtpMaxStringDescLength = KMtpMaxStringLength - 1;
    46 static const TInt KMtpMaxStringDescLength = KMtpMaxStringLength - 1;
    48 #endif
    47 #endif
    60 const TInt KMaxQueryLength = 512;
    59 const TInt KMaxQueryLength = 512;
    61 const TInt KMtpCompactInterval = 50;  // Compact every ....
    60 const TInt KMtpCompactInterval = 50;  // Compact every ....
    62 
    61 
    63 CMmMtpDpMetadataVideoAccess* CMmMtpDpMetadataVideoAccess::NewL( RFs& aRfs )
    62 CMmMtpDpMetadataVideoAccess* CMmMtpDpMetadataVideoAccess::NewL( RFs& aRfs )
    64     {
    63     {
    65     CMmMtpDpMetadataVideoAccess* me = new(ELeave) CMmMtpDpMetadataVideoAccess( aRfs );
    64     CMmMtpDpMetadataVideoAccess* me = new( ELeave ) CMmMtpDpMetadataVideoAccess( aRfs );
    66     CleanupStack::PushL(me);
    65     CleanupStack::PushL( me );
    67     me->ConstructL();
    66     me->ConstructL();
    68     CleanupStack::Pop(me);
    67     CleanupStack::Pop( me );
    69 
    68 
    70     return me;
    69     return me;
    71     }
    70     }
    72 
    71 
    73 CMmMtpDpMetadataVideoAccess::CMmMtpDpMetadataVideoAccess( RFs& aRfs ) : iRfs(aRfs),
    72 CMmMtpDpMetadataVideoAccess::CMmMtpDpMetadataVideoAccess( RFs& aRfs ) :
    74                                                     iDbState(ENoRecord),
    73     iRfs( aRfs ),
    75                                                     iDbOpened(EFalse)
    74     iDbState( ENoRecord ),
    76     {
    75     iDbOpened( EFalse )
    77     
    76     {
    78     }
    77     // Do nothing
    79 
    78     }
    80 // ---------------------------------------------------------------------------
    79 
    81 // CMmMtpDpMetadataMpxAccess::ConstructL
    80 // ---------------------------------------------------------------------------
       
    81 // CMmMtpDpMetadataVideoAccess::ConstructL
    82 // Second-phase
    82 // Second-phase
    83 // ---------------------------------------------------------------------------
    83 // ---------------------------------------------------------------------------
    84 //
    84 //
    85 void CMmMtpDpMetadataVideoAccess::ConstructL()
    85 void CMmMtpDpMetadataVideoAccess::ConstructL()
    86     {
    86     {
    87     iQueryText = HBufC::NewL( KMaxQueryLength );
    87     iQueryText = HBufC::NewL( KMaxQueryLength );
    88 
    88 
    89     User::LeaveIfError( iDbsSession.Connect() );
    89     User::LeaveIfError( iDbsSession.Connect() );
    90 
    90 
    91     TInt err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory,
    91     TInt err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, iStoreNum );
    92         iStoreNum );
       
    93 
    92 
    94     err = OpenDatabase();
    93     err = OpenDatabase();
    95 
    94 
    96     if ( KErrNone != err )
    95     if ( KErrNone != err )
    97         {
    96         {
    98         PRINT1( _L( "CMmMtpDpMetadataVideoAccess::ConstructL OpenDatabase err = %d" ), err );
    97         PRINT1( _L( "CMmMtpDpMetadataVideoAccess::ConstructL OpenDatabase err = %d" ), err );
    99         }
    98         }
   100     }
    99     }
   101 
   100 
   102 // ---------------------------------------------------------------------------
   101 // ---------------------------------------------------------------------------
   103 // CMmMtpDpMetadataMpxAccess::OpenDatabase
   102 // CMmMtpDpMetadataVideoAccess::OpenDatabase
   104 // Open data base
   103 // Open data base
   105 // ---------------------------------------------------------------------------
   104 // ---------------------------------------------------------------------------
   106 //
   105 //
   107 TInt CMmMtpDpMetadataVideoAccess::OpenDatabase()
   106 TInt CMmMtpDpMetadataVideoAccess::OpenDatabase()
   108     {
   107     {
   166     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::OpenDatabase" ) );
   165     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::OpenDatabase" ) );
   167     return err;
   166     return err;
   168     }
   167     }
   169 
   168 
   170 // ---------------------------------------------------------------------------
   169 // ---------------------------------------------------------------------------
   171 // CMmMtpDpMetadataMpxAccess::OpenDatabaseL
   170 // CMmMtpDpMetadataVideoAccess::OpenDatabaseL
   172 // Open data base
   171 // Open data base
   173 // ---------------------------------------------------------------------------
   172 // ---------------------------------------------------------------------------
   174 //
   173 //
   175 void CMmMtpDpMetadataVideoAccess::OpenDatabaseL()
   174 void CMmMtpDpMetadataVideoAccess::OpenDatabaseL()
   176     {
   175     {
   179         User::Leave( KErrGeneral );
   178         User::Leave( KErrGeneral );
   180     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::OpenDatabaseL" ) );
   179     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::OpenDatabaseL" ) );
   181     }
   180     }
   182 
   181 
   183 // ---------------------------------------------------------------------------
   182 // ---------------------------------------------------------------------------
   184 // CMmMtpDpMetadataMpxAccess::~CMmMtpDpMetadataVideoAccess
   183 // CMmMtpDpMetadataVideoAccess::~CMmMtpDpMetadataVideoAccess
   185 // Destructor
   184 // Destructor
   186 // ---------------------------------------------------------------------------
   185 // ---------------------------------------------------------------------------
   187 //
   186 //
   188 CMmMtpDpMetadataVideoAccess::~CMmMtpDpMetadataVideoAccess()
   187 CMmMtpDpMetadataVideoAccess::~CMmMtpDpMetadataVideoAccess()
   189     {
   188     {
   194     iDbsSession.Close();
   193     iDbsSession.Close();
   195     delete iFileStore;
   194     delete iFileStore;
   196     }
   195     }
   197 
   196 
   198 // ---------------------------------------------------------------------------
   197 // ---------------------------------------------------------------------------
   199 // CMmMtpDpMetadataMpxAccess::CreateDatabaseTablesL
   198 // CMmMtpDpMetadataVideoAccess::CreateDatabaseTablesL
   200 // Case where a new memory card is used and the player has not been opened
   199 // Case where a new memory card is used and the player has not been opened
   201 // ---------------------------------------------------------------------------
   200 // ---------------------------------------------------------------------------
   202 //
   201 //
   203 void CMmMtpDpMetadataVideoAccess::CreateDatabaseTablesL()
   202 void CMmMtpDpMetadataVideoAccess::CreateDatabaseTablesL()
   204     {
   203     {
   302 
   301 
   303     formatBuf.Append( KMtpVideoParentalRating );
   302     formatBuf.Append( KMtpVideoParentalRating );
   304     formatBuf.Append( KMtpVideoParentalRatingType );
   303     formatBuf.Append( KMtpVideoParentalRatingType );
   305     formatBuf.Append( KMtpVideoCommaSign );
   304     formatBuf.Append( KMtpVideoCommaSign );
   306 
   305 
   307     formatBuf.Append( KMtpVideoUseCount );
       
   308     formatBuf.Append( KMtpVideoUseCountType );
       
   309     formatBuf.Append( KMtpVideoCommaSign );
       
   310 
       
   311     formatBuf.Append( KMtpVideoDRM );
   306     formatBuf.Append( KMtpVideoDRM );
   312     formatBuf.Append( KMtpVideoDRMType );
   307     formatBuf.Append( KMtpVideoDRMType );
   313     formatBuf.Append( KMtpVideoCommaSign );
   308     formatBuf.Append( KMtpVideoCommaSign );
   314 
   309 
   315     formatBuf.Append( KMtpVideoDeleted );
   310     formatBuf.Append( KMtpVideoDeleted );
   339             User::LeaveIfError( iDatabase.Compact() );
   334             User::LeaveIfError( iDatabase.Compact() );
   340         }
   335         }
   341     }
   336     }
   342 
   337 
   343 // ---------------------------------------------------------------------------
   338 // ---------------------------------------------------------------------------
   344 // CMmMtpDpMetadataMpxAccess::CleanupDbIfNecessaryL
   339 // CMmMtpDpMetadataVideoAccess::CleanupDbIfNecessaryL
   345 // Cleanup Database
   340 // Cleanup Database
   346 // ---------------------------------------------------------------------------
   341 // ---------------------------------------------------------------------------
   347 //
   342 //
   348 void CMmMtpDpMetadataVideoAccess::CleanupDbIfNecessaryL()
   343 void CMmMtpDpMetadataVideoAccess::CleanupDbIfNecessaryL()
   349     {
   344     {
   367     iRecordSet.Close();
   362     iRecordSet.Close();
   368     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::CleanupDbIfNecessaryL" ) );
   363     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::CleanupDbIfNecessaryL" ) );
   369     }
   364     }
   370 
   365 
   371 // ---------------------------------------------------------------------------
   366 // ---------------------------------------------------------------------------
   372 // CMmMtpDpMetadataMpxAccess::IdentifyDeletedFilesL
   367 // CMmMtpDpMetadataVideoAccess::IdentifyDeletedFilesL
   373 // Identify deleted files
   368 // Identify deleted files
   374 // ---------------------------------------------------------------------------
   369 // ---------------------------------------------------------------------------
   375 //
   370 //
   376 void CMmMtpDpMetadataVideoAccess::IdentifyDeletedFilesL()
   371 void CMmMtpDpMetadataVideoAccess::IdentifyDeletedFilesL()
   377     {
   372     {
   378     PRINT( _L( "MM MTP => CMmMtpDpMetadataVideoAccess::IdentifyDeletedFilesL" ) );
   373     PRINT( _L( "MM MTP => CMmMtpDpMetadataVideoAccess::IdentifyDeletedFilesL" ) );
   379 
   374 
   380     ExecuteQueryL( KAllColumns, KMtpVideoTable, KMtpVideoLocation, KNullDesC, ETrue );
   375     ExecuteQueryL( KAllColumns, KMtpVideoTable, KMtpVideoLocation, KNullDesC, ETrue );
   381     PRINT1( _L( "MM MTP <> CleanupDbIfNecessaryL Database total count = %d" ), iRecordSet.CountL() );
   376     PRINT1( _L( "MM MTP <> CleanupDbIfNecessaryL Database total count = %d" ), iRecordSet.CountL() );
   382 
   377 
   383     for ( iRecordSet.FirstL(); iRecordSet.AtRow(); iRecordSet.NextL( ))
   378     for ( iRecordSet.FirstL(); iRecordSet.AtRow(); iRecordSet.NextL() )
   384         {
   379         {
   385         HBufC* data = ReadLongTextL( KMtpVideoLocation );
   380         HBufC* data = ReadLongTextL( KMtpVideoLocation );
   386         CleanupStack::PushL( data );
   381         CleanupStack::PushL( data );
   387 
   382 
   388         if ( !FileExists( *data ) )
   383         if ( !FileExists( *data ) )
   405 
   400 
   406     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::IdentifyDeletedFilesL" ) );
   401     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::IdentifyDeletedFilesL" ) );
   407     }
   402     }
   408 
   403 
   409 // ---------------------------------------------------------------------------
   404 // ---------------------------------------------------------------------------
   410 // CMmMtpDpMetadataMpxAccess::ReadLongTextL
   405 // CMmMtpDpMetadataVideoAccess::ReadLongTextL
   411 // Read from Data base
   406 // Read from Data base
   412 // ---------------------------------------------------------------------------
   407 // ---------------------------------------------------------------------------
   413 //
   408 //
   414 HBufC* CMmMtpDpMetadataVideoAccess::ReadLongTextL( const TDesC& aColumn )
   409 HBufC* CMmMtpDpMetadataVideoAccess::ReadLongTextL( const TDesC& aColumn )
   415     {
   410     {
   441     PRINT2( _L( "MM MTP <> ReadLongTextL Metadata value for %S is \"%S\"" ), &aColumn, buf );
   436     PRINT2( _L( "MM MTP <> ReadLongTextL Metadata value for %S is \"%S\"" ), &aColumn, buf );
   442     return buf;
   437     return buf;
   443     }
   438     }
   444 
   439 
   445 // ---------------------------------------------------------------------------
   440 // ---------------------------------------------------------------------------
   446 // CMmMtpDpMetadataMpxAccess::WriteLongTextL
   441 // CMmMtpDpMetadataVideoAccess::WriteLongTextL
   447 // Utility to write to the database
   442 // Utility to write to the database
   448 // ---------------------------------------------------------------------------
   443 // ---------------------------------------------------------------------------
   449 //
   444 //
   450 void CMmMtpDpMetadataVideoAccess::WriteLongTextL( const TDesC& aColumn, const TDesC& aValue )
   445 void CMmMtpDpMetadataVideoAccess::WriteLongTextL( const TDesC& aColumn,
       
   446     const TDesC& aValue )
   451     {
   447     {
   452     PRINT2( _L( "MM MTP <> WriteLongTextL Metadata value for %S is \"%S\"" ), &aColumn, &aValue );
   448     PRINT2( _L( "MM MTP <> WriteLongTextL Metadata value for %S is \"%S\"" ), &aColumn, &aValue );
   453     TDbColNo num = iColSet->ColNo( aColumn );
   449     TDbColNo num = iColSet->ColNo( aColumn );
   454     RDbColWriteStream strm;
   450     RDbColWriteStream strm;
   455     strm.OpenLC( iRecordSet, num );
   451     strm.OpenLC( iRecordSet, num );
   457     strm.Close();
   453     strm.Close();
   458     CleanupStack::PopAndDestroy( &strm );
   454     CleanupStack::PopAndDestroy( &strm );
   459     }
   455     }
   460 
   456 
   461 // ---------------------------------------------------------------------------
   457 // ---------------------------------------------------------------------------
   462 // CMmMtpDpMetadataMpxAccess::ExecuteQueryL
   458 // CMmMtpDpMetadataVideoAccess::ExecuteQueryL
   463 // Executes a query on the database and sets the cursor at the start of the recordset
   459 // Executes a query on the database and sets the cursor at the start of the recordset
   464 // ---------------------------------------------------------------------------
   460 // ---------------------------------------------------------------------------
   465 //
   461 //
   466 void CMmMtpDpMetadataVideoAccess::ExecuteQueryL( const TDesC& aSelectThese, const TDesC& aFromTable,
   462 void CMmMtpDpMetadataVideoAccess::ExecuteQueryL( const TDesC& aSelectThese,
   467                                        const TDesC& aColumnToMatch, const TDesC& aMatchCriteria,
   463     const TDesC& aFromTable,
   468                                        const TBool aIfNot, const TBool aNeedQuotes )
   464     const TDesC& aColumnToMatch,
       
   465     const TDesC& aMatchCriteria,
       
   466     const TBool aIfNot,
       
   467     const TBool aNeedQuotes )
   469     {
   468     {
   470     PRINT( _L( "MM MTP => CMmMtpDpMetadataVideoAccess::ExecuteQueryL" ) );
   469     PRINT( _L( "MM MTP => CMmMtpDpMetadataVideoAccess::ExecuteQueryL" ) );
   471 
   470 
   472     delete iColSet;
   471     delete iColSet;
   473     iColSet = NULL;
   472     iColSet = NULL;
   529 
   528 
   530     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::ExecuteQueryL" ) );
   529     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::ExecuteQueryL" ) );
   531     }
   530     }
   532 
   531 
   533 // ---------------------------------------------------------------------------
   532 // ---------------------------------------------------------------------------
   534 // CMmMtpDpMetadataMpxAccess::OpenSessionL
   533 // CMmMtpDpMetadataVideoAccess::OpenSessionL
   535 // Called when the MTP session is initialised
   534 // Called when the MTP session is initialised
   536 // ---------------------------------------------------------------------------
   535 // ---------------------------------------------------------------------------
   537 //
   536 //
   538 void CMmMtpDpMetadataVideoAccess::OpenSessionL()
   537 void CMmMtpDpMetadataVideoAccess::OpenSessionL()
   539     {
   538     {
   540 
   539     // Do nothing
   541     }
   540     }
   542 
   541 
   543 // ---------------------------------------------------------------------------
   542 // ---------------------------------------------------------------------------
   544 // CMmMtpDpMetadataMpxAccess::CloseSessionL
   543 // CMmMtpDpMetadataVideoAccess::CloseSessionL
   545 // Called when the MTP session is closed
   544 // Called when the MTP session is closed
   546 // ---------------------------------------------------------------------------
   545 // ---------------------------------------------------------------------------
   547 //
   546 //
   548 void CMmMtpDpMetadataVideoAccess::CloseSessionL()
   547 void CMmMtpDpMetadataVideoAccess::CloseSessionL()
   549     {
   548     {
   560 
   559 
   561     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::CloseSessionL" ) )
   560     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::CloseSessionL" ) )
   562     }
   561     }
   563 
   562 
   564 // ---------------------------------------------------------------------------
   563 // ---------------------------------------------------------------------------
   565 // CMmMtpDpMetadataMpxAccess::AddVideoL
   564 // CMmMtpDpMetadataVideoAccess::AddVideoL
   566 // Adds video info to the database
   565 // Adds video info to the database
   567 // ---------------------------------------------------------------------------
   566 // ---------------------------------------------------------------------------
   568 //
   567 //
   569 void CMmMtpDpMetadataVideoAccess::AddVideoL( const TDesC& aFullFileName )
   568 void CMmMtpDpMetadataVideoAccess::AddVideoL( const TDesC& aFullFileName )
   570     {
   569     {
   591         // Defaults
   590         // Defaults
   592         num = iColSet->ColNo( KMtpVideoLocation );
   591         num = iColSet->ColNo( KMtpVideoLocation );
   593         iRecordSet.SetColL( num, aFullFileName );
   592         iRecordSet.SetColL( num, aFullFileName );
   594 
   593 
   595         num = iColSet->ColNo( KMtpVideoName );
   594         num = iColSet->ColNo( KMtpVideoName );
   596         iRecordSet.SetColL( num, aFullFileName );     // Default name is the filename.
   595         TParsePtrC parser( aFullFileName );
       
   596         iRecordSet.SetColL( num, parser.Name() ); // Default name is the filename.
   597 
   597 
   598         num = iColSet->ColNo( KMtpVideoArtist );
   598         num = iColSet->ColNo( KMtpVideoArtist );
   599         iRecordSet.SetColL( num, KNullDesC );
   599         iRecordSet.SetColL( num, KNullDesC );
   600 
   600 
   601         num = iColSet->ColNo( KMtpVideoTrack );
   601         num = iColSet->ColNo( KMtpVideoTrack );
   620         iRecordSet.SetColL( num, 0 );
   620         iRecordSet.SetColL( num, 0 );
   621 
   621 
   622         num = iColSet->ColNo( KMtpVideoHeight );
   622         num = iColSet->ColNo( KMtpVideoHeight );
   623         iRecordSet.SetColL( num, 0 );
   623         iRecordSet.SetColL( num, 0 );
   624 
   624 
   625         num = iColSet->ColNo(KMtpVideoDuration);
   625         num = iColSet->ColNo( KMtpVideoDuration );
   626         iRecordSet.SetColL(num, 0);
   626         iRecordSet.SetColL( num, 0 );
   627 
   627 
   628         num = iColSet->ColNo( KMtpVideoSampleRate );
   628         num = iColSet->ColNo( KMtpVideoSampleRate );
   629         iRecordSet.SetColL( num, 0 );
   629         iRecordSet.SetColL( num, 0 );
   630 
   630 
   631         num = iColSet->ColNo( KMtpVideoNumberOfChannels );
   631         num = iColSet->ColNo( KMtpVideoNumberOfChannels );
   641         iRecordSet.SetColL( num, 0 );
   641         iRecordSet.SetColL( num, 0 );
   642 
   642 
   643         num = iColSet->ColNo( KMtpVideoVideoBitrate );
   643         num = iColSet->ColNo( KMtpVideoVideoBitrate );
   644         iRecordSet.SetColL( num, 0 );
   644         iRecordSet.SetColL( num, 0 );
   645 
   645 
   646         num = iColSet->ColNo(KMtpVideoFramesPer1000Sec);
   646         num = iColSet->ColNo( KMtpVideoFramesPer1000Sec );
   647         iRecordSet.SetColL(num, 0);
   647         iRecordSet.SetColL( num, 0 );
   648 
   648 
   649         num = iColSet->ColNo( KMtpVideoKeyFrameDistance );
   649         num = iColSet->ColNo( KMtpVideoKeyFrameDistance );
   650         iRecordSet.SetColL( num, 0 );
   650         iRecordSet.SetColL( num, 0 );
   651 
   651 
   652         num = iColSet->ColNo( KMtpVideoScanType );
   652         num = iColSet->ColNo( KMtpVideoScanType );
   655         num = iColSet->ColNo( KMtpVideoEncodingProfile );
   655         num = iColSet->ColNo( KMtpVideoEncodingProfile );
   656         iRecordSet.SetColL( num, KNullDesC );
   656         iRecordSet.SetColL( num, KNullDesC );
   657 
   657 
   658         num = iColSet->ColNo( KMtpVideoParentalRating );
   658         num = iColSet->ColNo( KMtpVideoParentalRating );
   659         iRecordSet.SetColL( num, KNullDesC );
   659         iRecordSet.SetColL( num, KNullDesC );
   660 
       
   661         num = iColSet->ColNo( KMtpVideoUseCount );
       
   662         iRecordSet.SetColL( num, 0 );
       
   663 
   660 
   664         num = iColSet->ColNo( KMtpVideoDRM );
   661         num = iColSet->ColNo( KMtpVideoDRM );
   665         iRecordSet.SetColL( num, 0 );
   662         iRecordSet.SetColL( num, 0 );
   666         }
   663         }
   667     else
   664     else
   692     CompactDbIfNecessaryL();
   689     CompactDbIfNecessaryL();
   693     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::AddVideoL" ) );
   690     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::AddVideoL" ) );
   694     }
   691     }
   695 
   692 
   696 // ---------------------------------------------------------------------------
   693 // ---------------------------------------------------------------------------
   697 // CMmMtpDpMetadataMpxAccess::GetObjectMetadataValueL
   694 // CMmMtpDpMetadataVideoAccess::GetObjectMetadataValueL
   698 //  Gets a piece of metadata from the collection
   695 //  Gets a piece of metadata from the collection
   699 // ---------------------------------------------------------------------------
   696 // ---------------------------------------------------------------------------
   700 //
   697 //
   701 void CMmMtpDpMetadataVideoAccess::GetObjectMetadataValueL( const TUint16 aPropCode,
   698 void CMmMtpDpMetadataVideoAccess::GetObjectMetadataValueL( const TUint16 aPropCode,
   702         MMTPType& aNewData,
   699     MMTPType& aNewData,
   703         const CMTPObjectMetaData& aObjectMetaData )
   700     const CMTPObjectMetaData& aObjectMetaData )
   704     {
   701     {
   705     PRINT1( _L( "MM MTP => CMmMtpDpMetadataVideoAccess::GetObjectMetadataValue aPropCode = 0x%x" ), aPropCode );
   702     PRINT1( _L( "MM MTP => CMmMtpDpMetadataVideoAccess::GetObjectMetadataValue aPropCode = 0x%x" ), aPropCode );
   706 
   703 
   707     //open database if not opened
   704     //open database if not opened
   708     if ( !IsDatabaseOpened() )
   705     if ( !IsDatabaseOpened() )
   716     HBufC* data = NULL;
   713     HBufC* data = NULL;
   717     TDbColNo num;
   714     TDbColNo num;
   718     TUint32 uInt32 = 0;
   715     TUint32 uInt32 = 0;
   719     TUint16 uInt16 = 0;
   716     TUint16 uInt16 = 0;
   720 
   717 
   721     switch (aPropCode)
   718     switch ( aPropCode )
   722         {
   719         {
   723         case EMTPObjectPropCodeName:
   720         case EMTPObjectPropCodeName:
   724             {
   721             {
   725             PRINT( _L( "MM MTP <> EMTPObjectPropCodeName-MD" ) );
   722             PRINT( _L( "MM MTP <> EMTPObjectPropCodeName-MD" ) );
   726             data = ReadLongTextL( KMtpVideoName );
   723             data = ReadLongTextL( KMtpVideoName );
   781         case EMTPObjectPropCodeDescription:
   778         case EMTPObjectPropCodeDescription:
   782             {
   779             {
   783             PRINT( _L( "MM MTP <> EMTPObjectPropCodeDescription-MD" ) );
   780             PRINT( _L( "MM MTP <> EMTPObjectPropCodeDescription-MD" ) );
   784             data = ReadLongTextL( KMtpVideoComment );
   781             data = ReadLongTextL( KMtpVideoComment );
   785 
   782 
   786             if ( data->Length() != 0 )
   783             TInt len = data->Length();
   787                 ( ( CMTPTypeString& ) aNewData ).SetL( *data ) ;
   784             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::GetObjectMetadataValue len = %d" ),len );
   788             else
   785             if ( len != 0 )
   789                 ( ( TMTPTypeUint32 & ) aNewData ).Set( 0 );  // return zero if description is empty
   786                 {
       
   787                 for ( TInt i = 0; i < len; i++ )
       
   788                     ( ( CMTPTypeArray& ) aNewData ).AppendUintL( ( *data )[i] );
       
   789                 }
   790 
   790 
   791             delete data;
   791             delete data;
   792             data = NULL;
   792             data = NULL;
   793             }
   793             }
   794             break;
   794             break;
   861             {
   861             {
   862             PRINT( _L( "MM MTP <> EMTPObjectPropCodeNumberOfChannels-MD" ) );
   862             PRINT( _L( "MM MTP <> EMTPObjectPropCodeNumberOfChannels-MD" ) );
   863             num = iColSet->ColNo( KMtpVideoNumberOfChannels );
   863             num = iColSet->ColNo( KMtpVideoNumberOfChannels );
   864             uInt16 = iRecordSet.ColUint16( num );
   864             uInt16 = iRecordSet.ColUint16( num );
   865             if ( EMTPTypeUINT16 == aNewData.Type() )
   865             if ( EMTPTypeUINT16 == aNewData.Type() )
   866                  {
   866                 {
   867                  ( ( TMTPTypeUint16 & ) aNewData ).Set( uInt16 );
   867                 ( ( TMTPTypeUint16 & ) aNewData ).Set( uInt16 );
   868                  }
   868                 }
   869              else
   869             else
   870                  {
   870                 {
   871                  User::Leave( KErrArgument );
   871                 User::Leave( KErrArgument );
   872                  }
   872                 }
   873             }
   873             }
   874             break;
   874             break;
   875 
   875 
   876         case EMTPObjectPropCodeAudioWAVECodec:
   876         case EMTPObjectPropCodeAudioWAVECodec:
   877             {
   877             {
   973             {
   973             {
   974             PRINT( _L( "MM MTP <> EMTPObjectPropCodeScanType-MD" ) );
   974             PRINT( _L( "MM MTP <> EMTPObjectPropCodeScanType-MD" ) );
   975             num = iColSet->ColNo( KMtpVideoScanType );
   975             num = iColSet->ColNo( KMtpVideoScanType );
   976             uInt16 = iRecordSet.ColUint16( num );
   976             uInt16 = iRecordSet.ColUint16( num );
   977             if ( EMTPTypeUINT16 == aNewData.Type() )
   977             if ( EMTPTypeUINT16 == aNewData.Type() )
   978                  {
   978                 {
   979                  ( ( TMTPTypeUint16 & ) aNewData ).Set( uInt16 );
   979                 ( ( TMTPTypeUint16 & ) aNewData ).Set( uInt16 );
   980                  }
   980                 }
   981              else
   981             else
   982                  {
   982                 {
   983                  User::Leave( KErrArgument );
   983                 User::Leave( KErrArgument );
   984                  }
   984                 }
   985             }
   985             }
   986             break;
   986             break;
   987 
   987 
   988         case EMTPObjectPropCodeEncodingProfile:
   988         case EMTPObjectPropCodeEncodingProfile:
   989             {
   989             {
   994 
   994 
   995         case EMTPObjectPropCodeParentalRating:
   995         case EMTPObjectPropCodeParentalRating:
   996             {
   996             {
   997             PRINT( _L( "MM MTP <> EMTPObjectPropCodeParentalRating-MD" ) );
   997             PRINT( _L( "MM MTP <> EMTPObjectPropCodeParentalRating-MD" ) );
   998             data = ReadLongTextL( KMtpVideoParentalRating );
   998             data = ReadLongTextL( KMtpVideoParentalRating );
   999             }
       
  1000             break;
       
  1001 
       
  1002         case EMTPObjectPropCodeUseCount:
       
  1003             {
       
  1004             PRINT( _L( "MM MTP <> EMTPObjectPropCodeUseCount-MD" ) );
       
  1005             num = iColSet->ColNo( KMtpVideoUseCount );
       
  1006             uInt32 = iRecordSet.ColUint32( num );
       
  1007             if ( EMTPTypeUINT32 == aNewData.Type() )
       
  1008                 {
       
  1009                 ( ( TMTPTypeUint32 & ) aNewData ).Set( uInt32 );
       
  1010                 }
       
  1011             else
       
  1012                 {
       
  1013                 User::Leave( KErrArgument );
       
  1014                 }
       
  1015             }
   999             }
  1016             break;
  1000             break;
  1017 
  1001 
  1018         case EMTPObjectPropCodeDRMStatus:
  1002         case EMTPObjectPropCodeDRMStatus:
  1019             {
  1003             {
  1020             PRINT( _L( "MM MTP <> EMTPObjectPropCodeDRMStatus-MD" ) );
  1004             PRINT( _L( "MM MTP <> EMTPObjectPropCodeDRMStatus-MD" ) );
  1021             num = iColSet->ColNo( KMtpVideoDRM );
  1005             num = iColSet->ColNo( KMtpVideoDRM );
  1022             uInt16 = iRecordSet.ColUint16( num );
  1006             uInt16 = iRecordSet.ColUint16( num );
  1023             if ( EMTPTypeUINT16 == aNewData.Type() )
  1007             if ( EMTPTypeUINT16 == aNewData.Type() )
  1024                  {
  1008                 {
  1025                  ( ( TMTPTypeUint16 & ) aNewData ).Set( uInt16 );
  1009                 ( ( TMTPTypeUint16 & ) aNewData ).Set( uInt16 );
  1026                  }
  1010                 }
  1027              else
  1011             else
  1028                  {
  1012                 {
  1029                  User::Leave( KErrArgument );
  1013                 User::Leave( KErrArgument );
  1030                  }
  1014                 }
  1031             }
  1015             }
  1032             break;
  1016             break;
  1033 
  1017 
  1034         default:
  1018         default:
  1035             {
  1019             {
  1037             }
  1021             }
  1038             break;
  1022             break;
  1039         }
  1023         }
  1040 
  1024 
  1041     // Pack the info to aNewData
  1025     // Pack the info to aNewData
  1042     if (data)
  1026     if ( data )
  1043         {
  1027         {
  1044 #ifdef _DEBUG
  1028 #ifdef _DEBUG
  1045         if ( data->Length() > KMtpMaxStringDescLength )   // Have to concatenate for MTP
  1029         if ( data->Length() > KMtpMaxStringDescLength )   // Have to concatenate for MTP
  1046             {
  1030             {
  1047             PRINT1( _L( "MM MTP <> Descriptor will be concatenated from length %d to KMtpMaxStringLength" ), data->Length() );
  1031             PRINT1( _L( "MM MTP <> Descriptor will be concatenated from length %d to KMtpMaxStringLength" ), data->Length() );
  1062 
  1046 
  1063     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::GetObjectMetadataValue" ) );
  1047     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::GetObjectMetadataValue" ) );
  1064     }
  1048     }
  1065 
  1049 
  1066 // ---------------------------------------------------------------------------
  1050 // ---------------------------------------------------------------------------
  1067 // CMmMtpDpMetadataMpxAccess::SetObjectMetadataValueL
  1051 // CMmMtpDpMetadataVideoAccess::SetObjectMetadataValueL
  1068 // Sets a piece of metadata in the collection
  1052 // Sets a piece of metadata in the collection
  1069 // ---------------------------------------------------------------------------
  1053 // ---------------------------------------------------------------------------
  1070 //
  1054 //
  1071 void CMmMtpDpMetadataVideoAccess::SetObjectMetadataValueL( const TUint16 aPropCode,
  1055 void CMmMtpDpMetadataVideoAccess::SetObjectMetadataValueL( const TUint16 aPropCode,
  1072     const MMTPType& aNewData,
  1056     const MMTPType& aNewData,
  1077     if ( !IsDatabaseOpened() )
  1061     if ( !IsDatabaseOpened() )
  1078         OpenDatabaseL();
  1062         OpenDatabaseL();
  1079 
  1063 
  1080     // Get file path
  1064     // Get file path
  1081     TPtrC suid( aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ) );
  1065     TPtrC suid( aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ) );
  1082     TParsePtrC parse( suid );
       
  1083     SetRecordL( suid, ERecordWrite );
  1066     SetRecordL( suid, ERecordWrite );
  1084     TRAPD( err, SetMetadataL( aPropCode, aNewData ) );
  1067     SetMetadataL( aPropCode, aNewData );
  1085 
       
  1086     if ( err < KErrNone ) // EPOC error condition
       
  1087         {
       
  1088         PRINT1( _L( "MM MTP <> Metadata write failed, with error %d" ), err );
       
  1089         SetRecordL( suid, EFailedWrite );
       
  1090         }
       
  1091 
       
  1092     if ( err != KErrNone )
       
  1093         User::Leave( err );
       
  1094 
  1068 
  1095     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::SetObjectMetadataValueL" ) );
  1069     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::SetObjectMetadataValueL" ) );
  1096     }
  1070     }
  1097 
  1071 
  1098 // ---------------------------------------------------------------------------
  1072 // ---------------------------------------------------------------------------
  1099 // CMmMtpDpMetadataMpxAccess::SetMetadataL
  1073 // CMmMtpDpMetadataVideoAccess::SetMetadataL
  1100 // Set meta data.
  1074 // Set meta data.
  1101 // ---------------------------------------------------------------------------
  1075 // ---------------------------------------------------------------------------
  1102 //
  1076 //
  1103 void CMmMtpDpMetadataVideoAccess::SetMetadataL( const TUint16 aObjPropCode,
  1077 void CMmMtpDpMetadataVideoAccess::SetMetadataL( const TUint16 aObjPropCode,
  1104     const MMTPType& aNewData )
  1078     const MMTPType& aNewData )
  1121         case EMTPObjectPropCodeComposer:
  1095         case EMTPObjectPropCodeComposer:
  1122         case EMTPObjectPropCodeOriginalReleaseDate:
  1096         case EMTPObjectPropCodeOriginalReleaseDate:
  1123         case EMTPObjectPropCodeEncodingProfile:
  1097         case EMTPObjectPropCodeEncodingProfile:
  1124         case EMTPObjectPropCodeParentalRating:
  1098         case EMTPObjectPropCodeParentalRating:
  1125             {
  1099             {
  1126             if( EMTPTypeString != aNewData.Type())
  1100             if ( EMTPTypeString != aNewData.Type() )
  1127                 {
  1101                 {
  1128                 User::Leave( KErrArgument );
  1102                 User::Leave( KErrArgument );
  1129                 }
  1103                 }
  1130             TPtrC string( ( ( CMTPTypeString& ) aNewData ).StringChars() );
  1104             TPtrC string( ( ( CMTPTypeString& ) aNewData ).StringChars() );
  1131             WriteLongTextL( colName, string );
  1105             WriteLongTextL( colName, string );
  1135 
  1109 
  1136         case EMTPObjectPropCodeDescription:
  1110         case EMTPObjectPropCodeDescription:
  1137             {
  1111             {
  1138             PRINT( _L( "MM MTP <> EMTPObjectPropCodeDescription-MD" ) );
  1112             PRINT( _L( "MM MTP <> EMTPObjectPropCodeDescription-MD" ) );
  1139 #ifdef __MUSIC_ID_SUPPORT
  1113 #ifdef __MUSIC_ID_SUPPORT
  1140             //WriteMusicIdsL(*longString);
  1114             // WriteMusicIdsL(*longString);
  1141 #else
  1115 #else
  1142             desData = CMTPTypeArray::NewLC( EMTPTypeAUINT16 ); // + desData
  1116             desData = CMTPTypeArray::NewLC( EMTPTypeAUINT16 ); // + desData
  1143             MMTPType::CopyL( aNewData, *desData );
  1117             MMTPType::CopyL( aNewData, *desData );
  1144             TUint length = desData->NumElements();
  1118             TUint length = desData->NumElements();
  1145             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::SetMetadataValueL length = %d" ), length );
  1119             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::SetMetadataValueL length = %d" ),
       
  1120                 length );
  1146             if ( length != 0 )
  1121             if ( length != 0 )
  1147                 {
  1122                 {
  1148                 TBuf<KMtpMaxDescriptionLength> text;
  1123                 length = ( length < KMTPMaxDescriptionLen ) ? length : KMTPMaxDescriptionLen;
  1149                 text.Zero();
  1124                 HBufC* text = HBufC::NewLC( length );    // + text
       
  1125                 TPtr ptr = text->Des();
       
  1126 
  1150                 for ( TUint i = 0; i < length; i++ )
  1127                 for ( TUint i = 0; i < length; i++ )
  1151                     {
  1128                     ptr.Append( desData->ElementUint( i ) );
  1152                     text.Append( desData->ElementUint( i ) );
       
  1153                     }
       
  1154                 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::SetMetadataValueL text = %S" ),
  1129                 PRINT1( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::SetMetadataValueL text = %S" ),
  1155                     &text );
  1130                     text );
  1156                 WriteLongTextL( KMtpVideoComment, text );
  1131 
       
  1132                 WriteLongTextL( KMtpVideoComment, *text );
       
  1133                 CleanupStack::PopAndDestroy( text );    // - text
  1157                 }
  1134                 }
  1158             else
  1135             else
  1159                 {
  1136                 {
  1160                 WriteLongTextL( KMtpVideoComment, KEmptyText );
  1137                 WriteLongTextL( KMtpVideoComment, KEmptyText );
  1161                 }
  1138                 }
  1172         case EMTPObjectPropCodeAudioBitRate:
  1149         case EMTPObjectPropCodeAudioBitRate:
  1173         case EMTPObjectPropCodeVideoFourCCCodec:
  1150         case EMTPObjectPropCodeVideoFourCCCodec:
  1174         case EMTPObjectPropCodeVideoBitRate:
  1151         case EMTPObjectPropCodeVideoBitRate:
  1175         case EMTPObjectPropCodeFramesPerThousandSeconds:
  1152         case EMTPObjectPropCodeFramesPerThousandSeconds:
  1176         case EMTPObjectPropCodeKeyFrameDistance:
  1153         case EMTPObjectPropCodeKeyFrameDistance:
  1177         case EMTPObjectPropCodeUseCount:
       
  1178             {
  1154             {
  1179             if ( EMTPTypeUINT32 != aNewData.Type() )
  1155             if ( EMTPTypeUINT32 != aNewData.Type() )
  1180                 {
  1156                 {
  1181                 User::Leave( KErrArgument );
  1157                 User::Leave( KErrArgument );
  1182                 }
  1158                 }
  1208 
  1184 
  1209     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::SetMetadataL" ) );
  1185     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::SetMetadataL" ) );
  1210     }
  1186     }
  1211 
  1187 
  1212 // ---------------------------------------------------------------------------
  1188 // ---------------------------------------------------------------------------
  1213 // CMmMtpDpMetadataMpxAccess::RenameRecordL
  1189 // CMmMtpDpMetadataVideoAccess::RenameRecordL
  1214 // Renames the file part of a record in the collection database.
  1190 // Renames the file part of a record in the collection database.
  1215 // ---------------------------------------------------------------------------
  1191 // ---------------------------------------------------------------------------
  1216 //
  1192 //
  1217 void CMmMtpDpMetadataVideoAccess::RenameRecordL(const TDesC& aOldFileName, const TDesC& aNewFileName)
  1193 void CMmMtpDpMetadataVideoAccess::RenameRecordL( const TDesC& aOldFileName,
       
  1194     const TDesC& aNewFileName )
  1218     {
  1195     {
  1219     PRINT( _L( "MM MTP => CMmMtpDpMetadataVideoAccess::RenameRecordL()" ) );
  1196     PRINT( _L( "MM MTP => CMmMtpDpMetadataVideoAccess::RenameRecordL()" ) );
  1220 
  1197 
  1221     //open database if not opened
  1198     //open database if not opened
  1222     if ( !IsDatabaseOpened() )
  1199     if ( !IsDatabaseOpened() )
  1228 
  1205 
  1229     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::RenameRecordL()" ) );
  1206     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::RenameRecordL()" ) );
  1230     }
  1207     }
  1231 
  1208 
  1232 // ---------------------------------------------------------------------------
  1209 // ---------------------------------------------------------------------------
  1233 // CMmMtpDpMetadataMpxAccess::DeleteRecordL
  1210 // CMmMtpDpMetadataVideoAccess::DeleteRecordL
  1234 // Deletes metadata information associated with the object
  1211 // Deletes metadata information associated with the object
  1235 // ---------------------------------------------------------------------------
  1212 // ---------------------------------------------------------------------------
  1236 //
  1213 //
  1237 void CMmMtpDpMetadataVideoAccess::DeleteRecordL( const TDesC& aFullFileName )
  1214 void CMmMtpDpMetadataVideoAccess::DeleteRecordL( const TDesC& aFullFileName )
  1238     {
  1215     {
  1265         }
  1242         }
  1266     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::DeleteRecordL" ) );
  1243     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::DeleteRecordL" ) );
  1267     }
  1244     }
  1268 
  1245 
  1269 // ---------------------------------------------------------------------------
  1246 // ---------------------------------------------------------------------------
  1270 // CMmMtpDpMetadataMpxAccess::DeleteAllRecordsL
  1247 // CMmMtpDpMetadataVideoAccess::DeleteAllRecordsL
  1271 // Empties the database - used by the FormatStore command
  1248 // Empties the database - used by the FormatStore command
  1272 // ---------------------------------------------------------------------------
  1249 // ---------------------------------------------------------------------------
  1273 //
  1250 //
  1274 void CMmMtpDpMetadataVideoAccess::DeleteAllRecordsL()
  1251 void CMmMtpDpMetadataVideoAccess::DeleteAllRecordsL()
  1275     {
  1252     {
  1276     PRINT( _L( "MM MTP => CMmMtpDpMetadataVideoAccess::DeleteAllRecordsL()" ) );
  1253     PRINT( _L( "MM MTP => CMmMtpDpMetadataVideoAccess::DeleteAllRecordsL()" ) );
  1277 
  1254 
  1278     //open database if not opened
  1255     //open database if not opened
  1279     if (!IsDatabaseOpened())
  1256     if ( !IsDatabaseOpened() )
  1280         OpenDatabaseL();
  1257         OpenDatabaseL();
  1281 
  1258 
  1282     SetRecordL( KNullDesC, ENoRecord );   // Commit any other changes to the DB
  1259     SetRecordL( KNullDesC, ENoRecord );   // Commit any other changes to the DB
  1283 
  1260 
  1284     PRINT( _L( "MM MTP <> Deleting music files" ) );
  1261     PRINT( _L( "MM MTP <> Deleting music files" ) );
  1296     iDatabase.Compact();
  1273     iDatabase.Compact();
  1297     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::DeleteAllRecordsL()" ) );
  1274     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::DeleteAllRecordsL()" ) );
  1298     }
  1275     }
  1299 
  1276 
  1300 // ---------------------------------------------------------------------------
  1277 // ---------------------------------------------------------------------------
  1301 // CMmMtpDpMetadataMpxAccess::SetRecordL
  1278 // CMmMtpDpMetadataVideoAccess::SetRecordL
  1302 // Set Record
  1279 // Set Record
  1303 // ---------------------------------------------------------------------------
  1280 // ---------------------------------------------------------------------------
  1304 //
  1281 //
  1305 void CMmMtpDpMetadataVideoAccess::SetRecordL( const TDesC& aFullFileName, TMtpDbState aState )
  1282 void CMmMtpDpMetadataVideoAccess::SetRecordL( const TDesC& aFullFileName,
       
  1283     TMtpDbState aState )
  1306     {
  1284     {
  1307     PRINT( _L( "MM MTP => CMmMtpDpMetadataVideoAccess::SetRecordL()" ) );
  1285     PRINT( _L( "MM MTP => CMmMtpDpMetadataVideoAccess::SetRecordL()" ) );
  1308 
  1286 
  1309     if ( ( aState == iDbState )
  1287     if ( ( aState == iDbState )
  1310             && ( 0 == aFullFileName.Compare( iCurrentFileName ) ) )    // Already have it
  1288         && ( 0 == aFullFileName.Compare( iCurrentFileName ) ) )    // Already have it
  1311         {
  1289         {
  1312         if (iDbState == ERecordRead)
  1290         if ( iDbState == ERecordRead )
  1313             iRecordSet.GetL();
  1291             iRecordSet.GetL();
  1314 
  1292 
  1315         PRINT1( _L( "MM MTP <> Cached recordset, filename is '%S'" ), &iCurrentFileName );
  1293         PRINT1( _L( "MM MTP <> Cached recordset, filename is '%S'" ), &iCurrentFileName );
  1316         return;
  1294         return;
  1317         }
  1295         }
  1330         case ERecordWrite:              // intentionally fallthrough
  1308         case ERecordWrite:              // intentionally fallthrough
  1331             // We wrote some stuff to the db, now needs comitting
  1309             // We wrote some stuff to the db, now needs comitting
  1332             PRINT( _L( "MM MTP <> SetRecordL ERecordWrite" ) );
  1310             PRINT( _L( "MM MTP <> SetRecordL ERecordWrite" ) );
  1333             TRAPD( err, iRecordSet.PutL() );
  1311             TRAPD( err, iRecordSet.PutL() );
  1334 
  1312 
  1335             if (KErrNone != err)
  1313             if ( KErrNone != err )
  1336                 {
  1314                 {
  1337                 iRecordSet.Cancel();
  1315                 iRecordSet.Cancel();
  1338                 User::Leave( err );
  1316                 User::Leave( err );
  1339                 }
  1317                 }
  1340         //lint -fallthrough
  1318             //lint -fallthrough
  1341         case ENoRecord:                 // intentionally fallthrough
  1319         case ENoRecord:                 // intentionally fallthrough
  1342             // We need to just close the open record
  1320             // We need to just close the open record
  1343             PRINT( _L( "MM MTP <> SetRecordL ENoRecord" ) );
  1321             PRINT( _L( "MM MTP <> SetRecordL ENoRecord" ) );
  1344         //lint -fallthrough
  1322             //lint -fallthrough
  1345         case ERecordRead:               // intentionally fallthrough
  1323         case ERecordRead:               // intentionally fallthrough
  1346             // We need to open a row for reading
  1324             // We need to open a row for reading
  1347             PRINT( _L( "MM MTP <> SetRecordL ERecordRead" ) );
  1325             PRINT( _L( "MM MTP <> SetRecordL ERecordRead" ) );
  1348         //lint -fallthrough
  1326             //lint -fallthrough
  1349         default:                        // intentionally fallthrough
  1327         default:                        // intentionally fallthrough
  1350             PRINT( _L( "MM MTP <> SetRecordL Closing recordset" ) );
  1328             PRINT( _L( "MM MTP <> SetRecordL Closing recordset" ) );
  1351             delete iColSet;
  1329             delete iColSet;
  1352             iColSet = NULL;
  1330             iColSet = NULL;
  1353             iRecordSet.Close();
  1331             iRecordSet.Close();
  1354             iDbState = ENoRecord;
  1332             iDbState = ENoRecord;
  1355             break;
  1333             break;
  1356         }
  1334         }
  1357 
  1335 
  1358     if ( aState == ENoRecord )    // We are closing the session if this is the case
  1336     if ( aState == ENoRecord ) // We are closing the session if this is the case
  1359         {
  1337         {
  1360         PRINT( _L( "MM MTP <> SetRecordL Record closed, no request to open" ) );
  1338         PRINT( _L( "MM MTP <> SetRecordL Record closed, no request to open" ) );
  1361         return;
  1339         return;
  1362         }
  1340         }
  1363 
  1341 
  1364     // if we have a music format, we can open the database...
  1342     // if we have a music format, we can open the database...
  1365     TUint16 format = MmMtpDpUtility::FormatFromFilename( iCurrentFileName );
  1343     TUint16 format = MmMtpDpUtility::FormatFromFilename( iCurrentFileName );
  1366     PRINT1( _L( "MM MTP <> SetRecordL format = 0x%x" ), format );
  1344     PRINT1( _L( "MM MTP <> SetRecordL format = 0x%x" ), format );
  1367 
       
  1368 
  1345 
  1369     if ( MmMtpDpUtility::HasMetadata( format ) )
  1346     if ( MmMtpDpUtility::HasMetadata( format ) )
  1370         {
  1347         {
  1371         // Get the record
  1348         // Get the record
  1372         ExecuteQueryL( KAllColumns, KMtpVideoTable, KMtpVideoLocation, aFullFileName );
  1349         ExecuteQueryL( KAllColumns, KMtpVideoTable, KMtpVideoLocation, aFullFileName );
  1407 
  1384 
  1408     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::SetRecordL()" ) );
  1385     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::SetRecordL()" ) );
  1409     }
  1386     }
  1410 
  1387 
  1411 // ---------------------------------------------------------------------------
  1388 // ---------------------------------------------------------------------------
  1412 // CMmMtpDpMetadataMpxAccess::SetImageObjPropL
  1389 // CMmMtpDpMetadataVideoAccess::SetImageObjPropL
  1413 // set image specific properties specific to videos
  1390 // set image specific properties specific to videos
  1414 // ---------------------------------------------------------------------------
  1391 // ---------------------------------------------------------------------------
  1415 //
  1392 //
  1416 void CMmMtpDpMetadataVideoAccess::SetImageObjPropL( const TDesC& aFullFileName,
  1393 void CMmMtpDpMetadataVideoAccess::SetImageObjPropL( const TDesC& aFullFileName,
  1417     const TUint32 aWidth,
  1394     const TUint32 aWidth,
  1428     SetRecordL( aFullFileName, ERecordWrite );
  1405     SetRecordL( aFullFileName, ERecordWrite );
  1429     num = iColSet->ColNo( KMtpVideoWidth );
  1406     num = iColSet->ColNo( KMtpVideoWidth );
  1430     TRAP( err, iRecordSet.SetColL( num, aWidth ) );
  1407     TRAP( err, iRecordSet.SetColL( num, aWidth ) );
  1431 
  1408 
  1432     if ( err != KErrNone )
  1409     if ( err != KErrNone )
  1433        {
  1410         {
  1434        SetRecordL( aFullFileName, EFailedWrite );
  1411         SetRecordL( aFullFileName, EFailedWrite );
  1435        User::Leave( err );
  1412         User::Leave( err );
  1436        }
  1413         }
  1437 
  1414 
  1438     num = iColSet->ColNo( KMtpVideoHeight );
  1415     num = iColSet->ColNo( KMtpVideoHeight );
  1439     TRAP( err, iRecordSet.SetColL( num, aHeight ) );
  1416     TRAP( err, iRecordSet.SetColL( num, aHeight ) );
  1440 
  1417 
  1441     if ( err != KErrNone )
  1418     if ( err != KErrNone )
  1442        {
  1419         {
  1443        SetRecordL( aFullFileName, EFailedWrite );
  1420         SetRecordL( aFullFileName, EFailedWrite );
  1444        User::Leave( err );
  1421         User::Leave( err );
  1445        }
  1422         }
  1446     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::SetImageObjPropL()" ) );
  1423     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::SetImageObjPropL()" ) );
  1447     }
  1424     }
  1448 
  1425 
  1449 // ---------------------------------------------------------------------------
  1426 // ---------------------------------------------------------------------------
  1450 // CMmMtpDpMetadataMpxAccess::GetImageObjPropL
  1427 // CMmMtpDpMetadataVideoAccess::GetImageObjPropL
  1451 // Get image specific properties specific to videos
  1428 // Get image specific properties specific to videos
  1452 // ---------------------------------------------------------------------------
  1429 // ---------------------------------------------------------------------------
  1453 //
  1430 //
  1454 void CMmMtpDpMetadataVideoAccess::GetImageObjPropL( const TDesC& aFullFileName,
  1431 void CMmMtpDpMetadataVideoAccess::GetImageObjPropL( const TDesC& aFullFileName,
  1455     TUint32& aWidth,
  1432     TUint32& aWidth,
  1474     }
  1451     }
  1475 
  1452 
  1476 const TDesC& CMmMtpDpMetadataVideoAccess::ColumnNameFromPropCodeL( const TUint16 aPropCode )
  1453 const TDesC& CMmMtpDpMetadataVideoAccess::ColumnNameFromPropCodeL( const TUint16 aPropCode )
  1477     {
  1454     {
  1478     const TColumnNameTable KColumnTable[] =
  1455     const TColumnNameTable KColumnTable[] =
  1479     {
  1456         {
  1480         { EMTPObjectPropCodeName,                    KMtpVideoName },
  1457             { EMTPObjectPropCodeName,                    KMtpVideoName },
  1481         { EMTPObjectPropCodeArtist,                  KMtpVideoArtist },
  1458             { EMTPObjectPropCodeArtist,                  KMtpVideoArtist },
  1482         { EMTPObjectPropCodeTrack,                   KMtpVideoTrack },
  1459             { EMTPObjectPropCodeTrack,                   KMtpVideoTrack },
  1483         { EMTPObjectPropCodeGenre,                   KMtpVideoGenre },
  1460             { EMTPObjectPropCodeGenre,                   KMtpVideoGenre },
  1484         { EMTPObjectPropCodeAlbumName,               KMtpVideoAlbumName },
  1461             { EMTPObjectPropCodeAlbumName,               KMtpVideoAlbumName },
  1485         { EMTPObjectPropCodeComposer,                KMtpVideoComposer },
  1462             { EMTPObjectPropCodeComposer,                KMtpVideoComposer },
  1486         { EMTPObjectPropCodeOriginalReleaseDate,     KMtpVideoOrigReleaseDate },
  1463             { EMTPObjectPropCodeOriginalReleaseDate,     KMtpVideoOrigReleaseDate },
  1487         { EMTPObjectPropCodeDescription,             KMtpVideoComment },
  1464             { EMTPObjectPropCodeDescription,             KMtpVideoComment },
  1488         { EMTPObjectPropCodeWidth,                   KMtpVideoWidth },
  1465             { EMTPObjectPropCodeWidth,                   KMtpVideoWidth },
  1489         { EMTPObjectPropCodeHeight,                  KMtpVideoHeight },
  1466             { EMTPObjectPropCodeHeight,                  KMtpVideoHeight },
  1490         { EMTPObjectPropCodeDuration,                KMtpVideoDuration },
  1467             { EMTPObjectPropCodeDuration,                KMtpVideoDuration },
  1491         { EMTPObjectPropCodeSampleRate,              KMtpVideoSampleRate },
  1468             { EMTPObjectPropCodeSampleRate,              KMtpVideoSampleRate },
  1492         { EMTPObjectPropCodeNumberOfChannels,        KMtpVideoNumberOfChannels },
  1469             { EMTPObjectPropCodeNumberOfChannels,        KMtpVideoNumberOfChannels },
  1493         { EMTPObjectPropCodeAudioBitRate,            KMtpVideoAudioBitrate },
  1470             { EMTPObjectPropCodeAudioBitRate,            KMtpVideoAudioBitrate },
  1494         { EMTPObjectPropCodeVideoFourCCCodec,        KMtpVideoVideoCodec },
  1471             { EMTPObjectPropCodeVideoFourCCCodec,        KMtpVideoVideoCodec },
  1495         { EMTPObjectPropCodeVideoBitRate,            KMtpVideoVideoBitrate },
  1472             { EMTPObjectPropCodeVideoBitRate,            KMtpVideoVideoBitrate },
  1496         { EMTPObjectPropCodeFramesPerThousandSeconds,KMtpVideoFramesPer1000Sec },
  1473             { EMTPObjectPropCodeFramesPerThousandSeconds,KMtpVideoFramesPer1000Sec },
  1497         { EMTPObjectPropCodeKeyFrameDistance,        KMtpVideoKeyFrameDistance },
  1474             { EMTPObjectPropCodeKeyFrameDistance,        KMtpVideoKeyFrameDistance },
  1498         { EMTPObjectPropCodeScanType,                KMtpVideoScanType },
  1475             { EMTPObjectPropCodeScanType,                KMtpVideoScanType },
  1499         { EMTPObjectPropCodeEncodingProfile,         KMtpVideoEncodingProfile },
  1476             { EMTPObjectPropCodeEncodingProfile,         KMtpVideoEncodingProfile },
  1500         { EMTPObjectPropCodeParentalRating,          KMtpVideoParentalRating },
  1477             { EMTPObjectPropCodeParentalRating,          KMtpVideoParentalRating },
  1501         { EMTPObjectPropCodeUseCount,                KMtpVideoUseCount },
  1478             { EMTPObjectPropCodeAudioWAVECodec,          KMtpVideoAudioCodec },
  1502         { EMTPObjectPropCodeAudioWAVECodec,          KMtpVideoAudioCodec },
  1479             { EMTPObjectPropCodeDRMStatus,               KMtpVideoDRM },
  1503         { EMTPObjectPropCodeDRMStatus,               KMtpVideoDRM },
  1480         };
  1504     };
       
  1505 
  1481 
  1506     TInt i = 0;
  1482     TInt i = 0;
  1507     TInt count = sizeof ( KColumnTable ) / sizeof ( KColumnTable[0] );
  1483     TInt count = sizeof( KColumnTable ) / sizeof( KColumnTable[0] );
  1508     while ( ( KColumnTable[i].iPropCode != aPropCode ) && ( i < count ) )
  1484     while ( ( KColumnTable[i].iPropCode != aPropCode ) && ( i < count ) )
  1509         {
  1485         {
  1510         i++;
  1486         i++;
  1511         }
  1487         }
  1512 
  1488 
  1513     if ( i == count )
  1489     if ( i == count )
  1514         {
  1490         {
  1515         // Not supported by MPX, shouldn't call this function
  1491         // Not supported by MPX, shouldn't call this function
  1516         PRINT( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::MpxAttribFromPropL NOT SUPPORTED ATTRIBUTE" ) );
  1492         PRINT( _L( "MM MTP <> CMmMtpDpMetadataVideoAccess::ColumnNameFromPropCodeL NOT SUPPORTED ATTRIBUTE" ) );
  1517         User::Leave( KErrNotSupported );
  1493         User::Leave( KErrNotSupported );
  1518         }
  1494         }
  1519     return KColumnTable[i].iDbColumnName;
  1495     return KColumnTable[i].iDbColumnName;
  1520     }
  1496     }
  1521 
  1497 
  1522 void CMmMtpDpMetadataVideoAccess::SetStorageRootL( const TDesC& aStorageRoot )
  1498 void CMmMtpDpMetadataVideoAccess::SetStorageRootL( const TDesC& aStorageRoot )
  1523     {
  1499     {
  1524     PRINT1( _L( "MM MTP => CMmMtpDpMetadataMpxAccess::SetStorageRoot aStoreRoot = %S" ), &aStorageRoot );
  1500     PRINT1( _L( "MM MTP => CMmMtpDpMetadataVideoAccess::SetStorageRoot aStoreRoot = %S" ), &aStorageRoot );
  1525 
  1501 
  1526     // get the drive number
  1502     // get the drive number
  1527     TParse pathParser;
  1503     TParsePtrC pathParser( aStorageRoot );
  1528     User::LeaveIfError( pathParser.Set( aStorageRoot, NULL, NULL ) );
       
  1529     TChar driveChar( pathParser.Drive()[0] );
  1504     TChar driveChar( pathParser.Drive()[0] );
  1530 
  1505 
  1531     User::LeaveIfError( RFs::CharToDrive( driveChar, iStoreNum ) );
  1506     User::LeaveIfError( RFs::CharToDrive( driveChar, iStoreNum ) );
  1532     PRINT1( _L( "MM MTP <= CMmMtpDpMetadataMpxAccess::SetStorageRoot drive number = %d" ), iStoreNum );
  1507     PRINT1( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::SetStorageRoot drive number = %d" ), iStoreNum );
  1533     }
  1508     }
  1534 
  1509 
  1535 void CMmMtpDpMetadataVideoAccess::CleanupDatabaseL()
  1510 void CMmMtpDpMetadataVideoAccess::CleanupDatabaseL()
  1536     {
  1511     {
  1537     PRINT( _L( "MM MTP => CMmMtpDpMetadataVideoAccess::CleanupDatabaseL" ) );
  1512     PRINT( _L( "MM MTP => CMmMtpDpMetadataVideoAccess::CleanupDatabaseL" ) );