mpxplugins/serviceplugins/collectionplugins/mpxsqlitedbhgplugin/src/mpxdbhandler.cpp
branchRCL_3
changeset 9 13afc0e517bd
parent 4 beaa16f65879
child 11 943ff5625028
equal deleted inserted replaced
5:2a40e88564c8 9:13afc0e517bd
  1354             {
  1354             {
  1355             iOutOfDisk = ETrue;
  1355             iOutOfDisk = ETrue;
  1356             }
  1356             }
  1357     }
  1357     }
  1358     
  1358     
       
  1359 #ifdef __RAMDISK_PERF_ENABLE
       
  1360 	iDbManager->CopyDBsToRamL();
       
  1361 #endif //__RAMDISK_PERF_ENABLE
  1359     iDbMusic->RefreshStartL();
  1362     iDbMusic->RefreshStartL();
  1360 
  1363 
  1361     BeginTransactionL();
  1364     BeginTransactionL();
  1362     iRefresh = ETrue;
  1365     iRefresh = ETrue;
  1363     }
  1366     }
  1384     //Next time the collection is opened the music basic table must be updated
  1387     //Next time the collection is opened the music basic table must be updated
  1385     if (iCollectionOpen )
  1388     if (iCollectionOpen )
  1386         {
  1389         {
  1387         iSynchronizeBasicTable = EFalse;
  1390         iSynchronizeBasicTable = EFalse;
  1388         }
  1391         }
       
  1392 
       
  1393 #ifdef __RAMDISK_PERF_ENABLE
       
  1394     iDbManager->CopyDBsFromRamL();
       
  1395 #endif //__RAMDISK_PERF_ENABLE
  1389     }
  1396     }
  1390 
  1397 
  1391 // ----------------------------------------------------------------------------
  1398 // ----------------------------------------------------------------------------
  1392 // Notification of Mtp status change
  1399 // Notification of Mtp status change
  1393 // ----------------------------------------------------------------------------
  1400 // ----------------------------------------------------------------------------
  1394 //
  1401 //
  1395 void CMPXDbHandler::MtpStartL()
  1402 void CMPXDbHandler::MtpStartL()
  1396     {
  1403     {
       
  1404     MPX_DEBUG1("-->CMPXDbHandler::MtpStartL");
  1397     iMtpInUse = ETrue;
  1405     iMtpInUse = ETrue;
  1398     iOpOnDbCount = 0;
  1406     iOpOnDbCount = 0;
       
  1407 
       
  1408 #ifdef __RAMDISK_PERF_ENABLE
       
  1409 	TRAPD(err, iDbManager->CopyDBsToRamL(iMtpInUse));
       
  1410 	if ( err != KErrNone )
       
  1411 	    {
       
  1412         MPX_DEBUG2("CMPXDbHandler::MtpStartL error=%d", err);
       
  1413 	    }
       
  1414 #endif //__RAMDISK_PERF_ENABLE
       
  1415 
  1399     iDbManager->BeginL();
  1416     iDbManager->BeginL();
       
  1417     MPX_DEBUG1("<--CMPXDbHandler::MtpStartL");
  1400     }
  1418     }
  1401 
  1419 
  1402 // ----------------------------------------------------------------------------
  1420 // ----------------------------------------------------------------------------
  1403 // Notification of Mtp status change
  1421 // Notification of Mtp status change
  1404 // ----------------------------------------------------------------------------
  1422 // ----------------------------------------------------------------------------
  1405 //
  1423 //
  1406 void CMPXDbHandler::MtpEndL()
  1424 void CMPXDbHandler::MtpEndL()
  1407     {
  1425     {
       
  1426     MPX_DEBUG1("-->CMPXDbHandler::MtpEndL");
  1408     iMtpInUse = EFalse;
  1427     iMtpInUse = EFalse;
  1409     iOpOnDbCount = 0;
  1428     iOpOnDbCount = 0;
  1410     iDbManager->CommitL();
  1429     iDbManager->CommitL();
       
  1430 
       
  1431 #ifdef __RAMDISK_PERF_ENABLE
       
  1432     TRAPD(err, iDbManager->CopyDBsFromRamL());
       
  1433 	if ( err != KErrNone )
       
  1434 	    {
       
  1435         MPX_DEBUG2("CMPXDbHandler::MtpEndL error=%d", err);
       
  1436 	    }
       
  1437 #endif //__RAMDISK_PERF_ENABLE
       
  1438     
       
  1439     MPX_DEBUG1("<--CMPXDbHandler::MtpEndL");
  1411     }
  1440     }
  1412 
  1441 
  1413 // ----------------------------------------------------------------------------
  1442 // ----------------------------------------------------------------------------
  1414 // Get all records count for music
  1443 // Get all records count for music
  1415 // ----------------------------------------------------------------------------
  1444 // ----------------------------------------------------------------------------
  1486 // ----------------------------------------------------------------------------
  1515 // ----------------------------------------------------------------------------
  1487 //
  1516 //
  1488 void CMPXDbHandler::BeginTransactionL()
  1517 void CMPXDbHandler::BeginTransactionL()
  1489     {
  1518     {
  1490     MPX_FUNC("CMPXDbHandler::BeginTransactionL");
  1519     MPX_FUNC("CMPXDbHandler::BeginTransactionL");
       
  1520 
       
  1521 #ifdef __RAMDISK_PERF_ENABLE
       
  1522     // EnsureRamSpaceL will copy dbs from ram if ram space is low or dbs exceeded
       
  1523     // max space.
       
  1524 	TRAPD(err, iDbManager->EnsureRamSpaceL());
       
  1525 	if (err)
       
  1526 		{
       
  1527 		//error but continue
       
  1528 		}
       
  1529 #endif //__RAMDISK_PERF_ENABLE
  1491 
  1530 
  1492     if(!iMtpInUse)
  1531     if(!iMtpInUse)
  1493         {
  1532         {
  1494         iDbManager->BeginL();
  1533         iDbManager->BeginL();
  1495         }
  1534         }
  2936 
  2975 
  2937 TInt CMPXDbHandler::HandlePlaylistDurationL(TUint32 aPlaylistId)
  2976 TInt CMPXDbHandler::HandlePlaylistDurationL(TUint32 aPlaylistId)
  2938 	{
  2977 	{
  2939 	return GetPlaylistDurationL(aPlaylistId);
  2978 	return GetPlaylistDurationL(aPlaylistId);
  2940 	}
  2979 	}
       
  2980 void CMPXDbHandler::HandlePlaylistInfoL(
       
  2981     TUint32 aPlaylistId, 
       
  2982     TInt& aCount, 
       
  2983     TInt& aDuration)
       
  2984     {
       
  2985     MPX_FUNC("CMPXDbHandler::HandlePlaylistInfoL");
       
  2986     MPX_DEBUG2("CMPXDbHandler::HandlePlaylistInfoL(0x%x)", aPlaylistId);
       
  2987 
       
  2988     RArray<TMPXAttribute> attributes;
       
  2989     CleanupClosePushL(attributes);
       
  2990     attributes.AppendL(KMPXMediaGeneralId);    
       
  2991     attributes.AppendL(TMPXAttribute(KMPXMediaIdGeneral, EMPXMediaGeneralDuration));
       
  2992 
       
  2993     CMPXMediaArray* mediaArray = CMPXMediaArray::NewL();
       
  2994     CleanupStack::PushL(mediaArray);    
       
  2995     
       
  2996     GetPlaylistSongsL(aPlaylistId, attributes.Array(), *mediaArray);
       
  2997     
       
  2998     aCount = mediaArray->Count();
       
  2999     for (TInt index = 0; index < aCount; ++index)
       
  3000         {
       
  3001         CMPXMedia* media((*mediaArray)[index]);
       
  3002         if (media->IsSupported(KMPXMediaGeneralDuration))
       
  3003             {
       
  3004             aDuration += media->ValueTObjectL<TInt>(KMPXMediaGeneralDuration);
       
  3005             }
       
  3006         }
       
  3007 
       
  3008     CleanupStack::PopAndDestroy(mediaArray);
       
  3009     CleanupStack::PopAndDestroy(&attributes);        
       
  3010     }
  2941 
  3011 
  2942 TInt CMPXDbHandler::HandleGetAlbumsCountForArtistL(TUint32 aArtistId)
  3012 TInt CMPXDbHandler::HandleGetAlbumsCountForArtistL(TUint32 aArtistId)
  2943 	{
  3013 	{
  2944 	return iDbAlbum->GetAlbumsCountForArtistL(aArtistId);
  3014 	return iDbAlbum->GetAlbumsCountForArtistL(aArtistId);
  2945 	}
  3015 	}