mmappcomponents/mmmtpdataprovider/src/cmmmtpdpmetadatavideoaccess.cpp
changeset 51 e61a04404bdf
parent 25 d881023c13eb
child 58 c76ea6caa649
equal deleted inserted replaced
44:d141fc1ad77b 51:e61a04404bdf
    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, iStoreNum );
    91     TInt err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, iStoreNum );
       
    92     PRINT1( _L( "MM MTP <> CMmMtpDpMetadataVideoAccess::ConstructL, EDefaultPhoneMemory err = %d" ), err );
       
    93     User::LeaveIfError( err );
    92 
    94 
    93     err = OpenDatabase();
    95     err = OpenDatabase();
    94 
    96 
    95     if ( KErrNone != err )
    97     if ( KErrNone != err )
    96         {
    98         {
   151                     }
   153                     }
   152                 }
   154                 }
   153             }
   155             }
   154         }
   156         }
   155 
   157 
       
   158     if ( err == KErrNone )
       
   159         {
       
   160         iDbOpened = ETrue;
       
   161         }
       
   162 
   156     TBuf<KStorageRootMaxLength> storeRoot;
   163     TBuf<KStorageRootMaxLength> storeRoot;
   157     err = PathInfo::GetRootPath( storeRoot, iStoreNum );
   164     if( PathInfo::GetRootPath( storeRoot, iStoreNum ) == KErrNone )
   158     iRfs.SetSessionPath( storeRoot );
   165         {
   159 
   166         iRfs.SetSessionPath( storeRoot );
   160     if ( err == KErrNone )
       
   161         {
       
   162         iDbOpened = ETrue;
       
   163         }
   167         }
   164 
   168 
   165     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::OpenDatabase" ) );
   169     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::OpenDatabase" ) );
   166     return err;
   170     return err;
   167     }
   171     }
   347     ExecuteQueryL( KAllColumns, KMtpVideoTable, KMtpVideoDeleted, KTrue, EFalse, EFalse );
   351     ExecuteQueryL( KAllColumns, KMtpVideoTable, KMtpVideoDeleted, KTrue, EFalse, EFalse );
   348     PRINT1( _L( "MM MTP <> CleanupDbIfNecessaryL Database deleted count = %d" ), iRecordSet.CountL() );
   352     PRINT1( _L( "MM MTP <> CleanupDbIfNecessaryL Database deleted count = %d" ), iRecordSet.CountL() );
   349 
   353 
   350     for ( iRecordSet.FirstL(); iRecordSet.AtRow(); iRecordSet.NextL() )
   354     for ( iRecordSet.FirstL(); iRecordSet.AtRow(); iRecordSet.NextL() )
   351         {
   355         {
       
   356 #ifdef _DEBUG
   352         HBufC* data = ReadLongTextL( KMtpVideoLocation );
   357         HBufC* data = ReadLongTextL( KMtpVideoLocation );
   353         CleanupStack::PushL( data );
       
   354 
   358 
   355         PRINT1( _L( "MM MTP <> CleanupDbIfNecessaryL removing %S from database" ), data );
   359         PRINT1( _L( "MM MTP <> CleanupDbIfNecessaryL removing %S from database" ), data );
       
   360         delete data;
       
   361         data = NULL;
       
   362 #endif
   356         iRecordSet.DeleteL();
   363         iRecordSet.DeleteL();
   357         CleanupStack::PopAndDestroy( data );
       
   358         }
   364         }
   359 
   365 
   360     delete iColSet;
   366     delete iColSet;
   361     iColSet = NULL;
   367     iColSet = NULL;
   362     iRecordSet.Close();
   368     iRecordSet.Close();
   472     iColSet = NULL;
   478     iColSet = NULL;
   473     iRecordSet.Close();
   479     iRecordSet.Close();
   474     //__ASSERT_DEBUG(!iColSet, _MTP_PANIC(KMtpPrtPncCat, ENullPointer)); // Must have iColSet == NULL
   480     //__ASSERT_DEBUG(!iColSet, _MTP_PANIC(KMtpPrtPncCat, ENullPointer)); // Must have iColSet == NULL
   475 
   481 
   476     // Make sure any quotes in the aMatchCriteria are doubled...
   482     // Make sure any quotes in the aMatchCriteria are doubled...
       
   483     // coverity[incorrect_multiplication]
       
   484     // coverity[buffer_alloc]
   477     HBufC* matchText = HBufC::NewLC( 2 * aMatchCriteria.Length() );
   485     HBufC* matchText = HBufC::NewLC( 2 * aMatchCriteria.Length() );
   478     TPtr pMatchText( matchText->Des() );
   486     TPtr pMatchText( matchText->Des() );
   479     TInt srcLen = aMatchCriteria.Length();
   487     TInt srcLen = aMatchCriteria.Length();
   480     TPtrC ch;
   488     TPtrC ch;
   481 
   489 
   704     //open database if not opened
   712     //open database if not opened
   705     if ( !IsDatabaseOpened() )
   713     if ( !IsDatabaseOpened() )
   706         OpenDatabaseL();
   714         OpenDatabaseL();
   707 
   715 
   708     // File Path
   716     // File Path
   709     HBufC* suid = aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ).AllocLC();  // + suid
   717     const TDesC& suid = aObjectMetaData.DesC( CMTPObjectMetaData::ESuid );
   710     SetRecordL( *suid, ERecordRead );
   718     SetRecordL( suid, ERecordRead );
   711     CleanupStack::PopAndDestroy( suid ); // - suid
       
   712 
   719 
   713     HBufC* data = NULL;
   720     HBufC* data = NULL;
   714     TDbColNo num;
   721     TDbColNo num;
   715     TUint32 uInt32 = 0;
   722     TUint32 uInt32 = 0;
   716     TUint16 uInt16 = 0;
   723     TUint16 uInt16 = 0;
   777 
   784 
   778         case EMTPObjectPropCodeDescription:
   785         case EMTPObjectPropCodeDescription:
   779             {
   786             {
   780             PRINT( _L( "MM MTP <> EMTPObjectPropCodeDescription-MD" ) );
   787             PRINT( _L( "MM MTP <> EMTPObjectPropCodeDescription-MD" ) );
   781             data = ReadLongTextL( KMtpVideoComment );
   788             data = ReadLongTextL( KMtpVideoComment );
       
   789             CleanupStack::PushL( data ); // + data
   782 
   790 
   783             TInt len = data->Length();
   791             TInt len = data->Length();
   784             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::GetObjectMetadataValue len = %d" ),len );
   792             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::GetObjectMetadataValue len = %d" ),len );
   785             if ( len != 0 )
   793             for ( TInt i = 0; i < len; i++ )
   786                 {
   794                 ( ( CMTPTypeArray& ) aNewData ).AppendUintL( ( *data )[i] );
   787                 for ( TInt i = 0; i < len; i++ )
   795 
   788                     ( ( CMTPTypeArray& ) aNewData ).AppendUintL( ( *data )[i] );
   796             CleanupStack::PopAndDestroy( data ); // - data
   789                 }
       
   790 
       
   791             delete data;
       
   792             data = NULL;
   797             data = NULL;
   793             }
   798             }
   794             break;
   799             break;
   795 
   800 
   796         case EMTPObjectPropCodeWidth:
   801         case EMTPObjectPropCodeWidth:
  1023         }
  1028         }
  1024 
  1029 
  1025     // Pack the info to aNewData
  1030     // Pack the info to aNewData
  1026     if ( data )
  1031     if ( data )
  1027         {
  1032         {
       
  1033         CleanupStack::PushL( data ); // + data
  1028 #ifdef _DEBUG
  1034 #ifdef _DEBUG
  1029         if ( data->Length() > KMtpMaxStringDescLength )   // Have to concatenate for MTP
  1035         if ( data->Length() > KMtpMaxStringDescLength )   // Have to concatenate for MTP
  1030             {
  1036             {
  1031             PRINT1( _L( "MM MTP <> Descriptor will be concatenated from length %d to KMtpMaxStringLength" ), data->Length() );
  1037             PRINT1( _L( "MM MTP <> Descriptor will be concatenated from length %d to KMtpMaxStringLength" ), data->Length() );
  1032             }
  1038             }
  1038             }
  1044             }
  1039         else
  1045         else
  1040             {
  1046             {
  1041             User::Leave( KErrArgument );
  1047             User::Leave( KErrArgument );
  1042             }
  1048             }
  1043         delete data;
  1049         CleanupStack::PopAndDestroy( data ); // - data
  1044         data = NULL;
       
  1045         }
  1050         }
  1046 
  1051 
  1047     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::GetObjectMetadataValue" ) );
  1052     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::GetObjectMetadataValue" ) );
  1048     }
  1053     }
  1049 
  1054