mmappcomponents/mmmtpdataprovider/src/cmmmtpdpmetadatavideoaccess.cpp
branchRCL_3
changeset 23 e42293e811d8
parent 11 780c925249c1
child 24 6c1dfe4da5dd
equal deleted inserted replaced
22:b034b1c214c2 23:e42293e811d8
    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();
   704     //open database if not opened
   710     //open database if not opened
   705     if ( !IsDatabaseOpened() )
   711     if ( !IsDatabaseOpened() )
   706         OpenDatabaseL();
   712         OpenDatabaseL();
   707 
   713 
   708     // File Path
   714     // File Path
   709     HBufC* suid = aObjectMetaData.DesC( CMTPObjectMetaData::ESuid ).AllocLC();  // + suid
   715     const TDesC& suid = aObjectMetaData.DesC( CMTPObjectMetaData::ESuid );
   710     SetRecordL( *suid, ERecordRead );
   716     SetRecordL( suid, ERecordRead );
   711     CleanupStack::PopAndDestroy( suid ); // - suid
       
   712 
   717 
   713     HBufC* data = NULL;
   718     HBufC* data = NULL;
   714     TDbColNo num;
   719     TDbColNo num;
   715     TUint32 uInt32 = 0;
   720     TUint32 uInt32 = 0;
   716     TUint16 uInt16 = 0;
   721     TUint16 uInt16 = 0;
   777 
   782 
   778         case EMTPObjectPropCodeDescription:
   783         case EMTPObjectPropCodeDescription:
   779             {
   784             {
   780             PRINT( _L( "MM MTP <> EMTPObjectPropCodeDescription-MD" ) );
   785             PRINT( _L( "MM MTP <> EMTPObjectPropCodeDescription-MD" ) );
   781             data = ReadLongTextL( KMtpVideoComment );
   786             data = ReadLongTextL( KMtpVideoComment );
       
   787             CleanupStack::PushL( data ); // + data
   782 
   788 
   783             TInt len = data->Length();
   789             TInt len = data->Length();
   784             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::GetObjectMetadataValue len = %d" ),len );
   790             PRINT1( _L( "MM MTP <> CMmMtpDpMetadataMpxAccess::GetObjectMetadataValue len = %d" ),len );
   785             if ( len != 0 )
   791             for ( TInt i = 0; i < len; i++ )
   786                 {
   792                 ( ( CMTPTypeArray& ) aNewData ).AppendUintL( ( *data )[i] );
   787                 for ( TInt i = 0; i < len; i++ )
   793 
   788                     ( ( CMTPTypeArray& ) aNewData ).AppendUintL( ( *data )[i] );
   794             CleanupStack::PopAndDestroy( data ); // - data
   789                 }
       
   790 
       
   791             delete data;
       
   792             data = NULL;
   795             data = NULL;
   793             }
   796             }
   794             break;
   797             break;
   795 
   798 
   796         case EMTPObjectPropCodeWidth:
   799         case EMTPObjectPropCodeWidth:
  1023         }
  1026         }
  1024 
  1027 
  1025     // Pack the info to aNewData
  1028     // Pack the info to aNewData
  1026     if ( data )
  1029     if ( data )
  1027         {
  1030         {
       
  1031         CleanupStack::PushL( data ); // + data
  1028 #ifdef _DEBUG
  1032 #ifdef _DEBUG
  1029         if ( data->Length() > KMtpMaxStringDescLength )   // Have to concatenate for MTP
  1033         if ( data->Length() > KMtpMaxStringDescLength )   // Have to concatenate for MTP
  1030             {
  1034             {
  1031             PRINT1( _L( "MM MTP <> Descriptor will be concatenated from length %d to KMtpMaxStringLength" ), data->Length() );
  1035             PRINT1( _L( "MM MTP <> Descriptor will be concatenated from length %d to KMtpMaxStringLength" ), data->Length() );
  1032             }
  1036             }
  1038             }
  1042             }
  1039         else
  1043         else
  1040             {
  1044             {
  1041             User::Leave( KErrArgument );
  1045             User::Leave( KErrArgument );
  1042             }
  1046             }
  1043         delete data;
  1047         CleanupStack::PopAndDestroy( data ); // - data
  1044         data = NULL;
       
  1045         }
  1048         }
  1046 
  1049 
  1047     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::GetObjectMetadataValue" ) );
  1050     PRINT( _L( "MM MTP <= CMmMtpDpMetadataVideoAccess::GetObjectMetadataValue" ) );
  1048     }
  1051     }
  1049 
  1052