mmappcomponents/collectionhelper/src/mpxcollectioncachedhelper.cpp
changeset 32 edd273b3192a
parent 27 cbb1bfb7ebfb
child 50 762d760dcfdf
equal deleted inserted replaced
27:cbb1bfb7ebfb 32:edd273b3192a
    28 #include <mpxmediacontainerdefs.h>
    28 #include <mpxmediacontainerdefs.h>
    29 #include <mpxcommandgeneraldefs.h>
    29 #include <mpxcommandgeneraldefs.h>
    30 #include <mpxcollectioncommanddefs.h>
    30 #include <mpxcollectioncommanddefs.h>
    31 #include <mpxmediamtpdefs.h>
    31 #include <mpxmediamtpdefs.h>
    32 
    32 
       
    33 #include <e32property.h>    // for RProperty
       
    34 #include <UsbWatcherInternalPSKeys.h>
       
    35 #include <usbpersonalityids.h>
       
    36 
    33 #include <mpxcollectionutility.h>
    37 #include <mpxcollectionutility.h>
    34 #include <mpxharvesterutility.h>
    38 #include <mpxharvesterutility.h>
    35 
    39 
    36 #include <mpxlog.h>
    40 #include <mpxlog.h>
    37 
    41 
   151 void CMPXCollectionCachedHelper::AddL( CMPXMedia* aMedia )
   155 void CMPXCollectionCachedHelper::AddL( CMPXMedia* aMedia )
   152     {
   156     {
   153     MPX_FUNC("CMPXCollectionCachedHelper::::AddL");    
   157     MPX_FUNC("CMPXCollectionCachedHelper::::AddL");    
   154     // Commit when we have cached more than a set amount
   158     // Commit when we have cached more than a set amount
   155     //
   159     //
   156     if( iCache->Count() >= KCacheCount)
   160     
   157         {
   161     TInt cacheCount = KCacheCount;
       
   162     TInt usbStatus;
       
   163     RProperty::Get( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality, usbStatus );
       
   164     
       
   165     // if MTP is not connected via USB, disable caching mechanism and flush immediately
       
   166     // in case UI is not blocked and need to reflect the change in real time
       
   167     // this logic is hardly invoked during MTP, because ::FindAllL (which flush) is always called before AddL
       
   168     if ((usbStatus != KUsbPersonalityIdMTP) && (usbStatus != KUsbPersonalityIdPCSuiteMTP))
       
   169         cacheCount = 1;            
       
   170     
       
   171     if( iCache->Count() >= cacheCount)
   158         Commit();
   172         Commit();
   159         }
   173 
   160 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
   174     #ifdef ABSTRACTAUDIOALBUM_INCLUDED
   161     TBool extract = ETrue;
   175     TBool extract = ETrue;
   162     if( aMedia->IsSupported( KMPXMediaMTPSampleDataFlag ) )
   176     if( aMedia->IsSupported( KMPXMediaMTPSampleDataFlag ) )
   163         {
   177         {
   164         
   178         
   165         extract = aMedia->ValueTObjectL<TBool>( KMPXMediaMTPSampleDataFlag );
   179         extract = aMedia->ValueTObjectL<TBool>( KMPXMediaMTPSampleDataFlag );
   744     return *iFoundMedia;
   758     return *iFoundMedia;
   745     
   759     
   746 #else  //RD_MPX_COLLECTION_CACHE
   760 #else  //RD_MPX_COLLECTION_CACHE
   747 
   761 
   748     MPX_DEBUG1("CMPXCollectionCachedHelper::GetL <--");
   762     MPX_DEBUG1("CMPXCollectionCachedHelper::GetL <--");
       
   763     
       
   764     TInt usbStatus;
       
   765     RProperty::Get( KPSUidUsbWatcher, KUsbWatcherSelectedPersonality, usbStatus );
       
   766     
       
   767     // if MTP is not connected via USB, flush immediately
       
   768     // in case UI is not blocked and need to reflect the change in real time
       
   769     if ((usbStatus != KUsbPersonalityIdMTP) && (usbStatus != KUsbPersonalityIdPCSuiteMTP))
       
   770         Commit();
   749 
   771 
   750 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
   772 #ifdef ABSTRACTAUDIOALBUM_INCLUDED
   751     if (aItemCat != EMPXSong && aItemCat != EMPXPlaylist && aItemCat != EMPXAbstractAlbum)
   773     if (aItemCat != EMPXSong && aItemCat != EMPXPlaylist && aItemCat != EMPXAbstractAlbum)
   752 #else
   774 #else
   753     if (aItemCat != EMPXSong && aItemCat != EMPXPlaylist)
   775     if (aItemCat != EMPXSong && aItemCat != EMPXPlaylist)