mpengine/src/mpmpxisolatedcollectionhelper.cpp
changeset 51 560ce2306a17
parent 38 b93f525c9244
child 55 f3930dda3342
equal deleted inserted replaced
47:4cc1412daed0 51:560ce2306a17
    19 #include <mpxcollectionhelperfactory.h>
    19 #include <mpxcollectionhelperfactory.h>
    20 #include <mpxcollectionuihelper.h>
    20 #include <mpxcollectionuihelper.h>
    21 #include <mpxcollectionopenutility.h>
    21 #include <mpxcollectionopenutility.h>
    22 
    22 
    23 #include "mpmpxisolatedcollectionhelper.h"
    23 #include "mpmpxisolatedcollectionhelper.h"
    24 #include "mpxlog.h"
    24 #include "mptrace.h"
    25 
    25 
    26 
    26 const TInt KIncrementalDelay = 0;
    27 
    27 const TInt KIncrementalFetchBlockSize = 1000;
    28 const TInt KIncrementalDelayNone = 0;
       
    29 const TInt KIncrementalDelayHalfSecond = 1000000;
       
    30 const TInt KIncrementalFetchBlockSize = 20;
       
    31 
       
    32 
    28 
    33 
    29 
    34 /*!
    30 /*!
    35     \class CMpMpxIsolatedCollectionHelper
    31     \class CMpMpxIsolatedCollectionHelper
    36     \brief Helper class to open an isolated collection.
    32     \brief Helper class to open an isolated collection.
    40 
    36 
    41 /*!
    37 /*!
    42  \internal
    38  \internal
    43  Two-phased constructor.
    39  Two-phased constructor.
    44  */
    40  */
    45 CMpMpxIsolatedCollectionHelper* CMpMpxIsolatedCollectionHelper::NewL( 
    41 CMpMpxIsolatedCollectionHelper* CMpMpxIsolatedCollectionHelper::NewL(
    46         MMpMpxIsolatedCollectionHelperObserver* aObserver )
    42         MMpMpxIsolatedCollectionHelperObserver* aObserver )
    47     {
    43 {
    48     CMpMpxIsolatedCollectionHelper* self = NewLC( aObserver );
    44     CMpMpxIsolatedCollectionHelper* self = NewLC( aObserver );
    49     CleanupStack::Pop( self );
    45     CleanupStack::Pop( self );
    50     return self;
    46     return self;
    51     }
    47 }
    52 
    48 
    53 /*!
    49 /*!
    54  \internal
    50  \internal
    55  Two-phased constructor.
    51  Two-phased constructor.
    56  */
    52  */
    57 CMpMpxIsolatedCollectionHelper* CMpMpxIsolatedCollectionHelper::NewLC( 
    53 CMpMpxIsolatedCollectionHelper* CMpMpxIsolatedCollectionHelper::NewLC(
    58         MMpMpxIsolatedCollectionHelperObserver* aObserver )
    54         MMpMpxIsolatedCollectionHelperObserver* aObserver )
    59     {
    55 {
    60     CMpMpxIsolatedCollectionHelper* self =
    56     CMpMpxIsolatedCollectionHelper* self =
    61             new ( ELeave ) CMpMpxIsolatedCollectionHelper( aObserver );
    57             new ( ELeave ) CMpMpxIsolatedCollectionHelper( aObserver );
    62     CleanupStack::PushL( self );
    58     CleanupStack::PushL( self );
    63     self->ConstructL();
    59     self->ConstructL();
    64     return self;
    60     return self;
    65     }
    61 }
    66 
    62 
    67 /*!
    63 /*!
    68  \internal
    64  \internal
    69  Destructor
    65  Destructor
    70  */
    66  */
    71 CMpMpxIsolatedCollectionHelper::~CMpMpxIsolatedCollectionHelper()
    67 CMpMpxIsolatedCollectionHelper::~CMpMpxIsolatedCollectionHelper()
    72     {
    68 {
    73     delete iIncrementalOpenUtil;
    69     delete iIncrementalOpenUtil;
    74     }
    70 }
    75     
    71 
    76 
    72 
    77 /*!
    73 /*!
    78  \internal
    74  \internal
    79  Opens an isolated collection with the /a path.
    75  Opens an isolated collection with the /a path.
    80  */
    76  */
    81 void CMpMpxIsolatedCollectionHelper::OpenCollectionL( CMPXCollectionPath& aPath, TInt aIndex, MpOpenMode aMode )
    77 void CMpMpxIsolatedCollectionHelper::OpenCollectionL( CMPXCollectionPath& aPath, TInt aIndex, MpOpenMode aMode )
    82     {
    78 {
       
    79     TX_ENTRY
    83     //Using incremental open to open the collection.
    80     //Using incremental open to open the collection.
    84     iOpenMode = aMode;
    81     iOpenMode = aMode;
    85     // Cancel any reads
    82     // Cancel any reads
    86     iIncrementalOpenUtil->Stop();
    83     iIncrementalOpenUtil->Stop();
    87 
    84 
    88     // Start the read
    85     // Start the read
    89     iFirstIncrementalOpen = ETrue;
    86     iFirstIncrementalOpen = ETrue;
    90     RArray<TMPXAttribute> attrs;
    87     RArray<TMPXAttribute> attrs;
    91     CleanupClosePushL( attrs );
    88     CleanupClosePushL( attrs );
    92     TArray<TMPXAttribute> ary = attrs.Array();
    89     TArray<TMPXAttribute> ary = attrs.Array();
    93     iIncrementalOpenUtil->SetDelay( KIncrementalDelayNone );
    90     iIncrementalOpenUtil->SetDelay( KIncrementalDelay );
    94     iIncrementalOpenUtil->StartL( aPath, ary, KIncrementalFetchBlockSize,
    91     iIncrementalOpenUtil->StartL( aPath, ary, KIncrementalFetchBlockSize,
    95                                   aIndex, CMPXCollectionOpenUtility::EFetchNormal );
    92                                   aIndex, CMPXCollectionOpenUtility::EFetchDown );
    96     iIncrementalOpenUtil->SetDelay( KIncrementalDelayHalfSecond );
       
    97     CleanupStack::PopAndDestroy( &attrs );
    93     CleanupStack::PopAndDestroy( &attrs );
    98     }
    94     TX_EXIT
       
    95 }
    99 
    96 
   100 /*!
    97 /*!
   101  \internal
    98  \internal
   102  c++ Contructor
    99  c++ Contructor
   103  */
   100  */
   104 CMpMpxIsolatedCollectionHelper::CMpMpxIsolatedCollectionHelper( MMpMpxIsolatedCollectionHelperObserver* aObserver )
   101 CMpMpxIsolatedCollectionHelper::CMpMpxIsolatedCollectionHelper( MMpMpxIsolatedCollectionHelperObserver* aObserver )
   105     : iObserver( aObserver ),
   102     : iObserver( aObserver ),
   106       iIncrementalOpenUtil( 0 ),
   103       iIncrementalOpenUtil( 0 ),
   107       iFirstIncrementalOpen( EFalse )
   104       iFirstIncrementalOpen( EFalse )
   108     {
   105 {
   109     }
   106 }
   110 
   107 
   111 /*!
   108 /*!
   112  \internal
   109  \internal
   113  Leaving constructor
   110  Leaving constructor
   114  */
   111  */
   115 void CMpMpxIsolatedCollectionHelper::ConstructL()
   112 void CMpMpxIsolatedCollectionHelper::ConstructL()
   116     {
   113 {
   117     iIncrementalOpenUtil = CMPXCollectionOpenUtility::NewL( this, KMcModeIsolated );
   114     iIncrementalOpenUtil = CMPXCollectionOpenUtility::NewL( this, KMcModeIsolated );
   118 
   115 }
   119     }
       
   120 
   116 
   121 
   117 
   122 /*!
   118 /*!
   123  \internal
   119  \internal
   124  reimp
   120  reimp
   125  */
   121  */
   126 void CMpMpxIsolatedCollectionHelper::HandleOpenL( 
   122 void CMpMpxIsolatedCollectionHelper::HandleOpenL(
   127     const CMPXMedia& aEntries,
   123     const CMPXMedia& aEntries,
   128     TInt /*aIndex*/,
   124     TInt aIndex,
   129     TBool /*aComplete*/,
   125     TBool aComplete,
   130     TInt aError )
   126     TInt aError )
   131     {
   127 {
   132     if ( iFirstIncrementalOpen )
   128     Q_UNUSED( aIndex );
   133         {
   129     Q_UNUSED( aComplete );
       
   130     TX_ENTRY_ARGS( "aError=" << aError << "aComplete=" << aComplete );
       
   131     if ( iFirstIncrementalOpen ) {
   134         CMPXCollectionPath* cPath = NULL;
   132         CMPXCollectionPath* cPath = NULL;
   135         iFirstIncrementalOpen = EFalse;
   133         iFirstIncrementalOpen = EFalse;
   136         switch( iOpenMode ) {
   134         switch( iOpenMode ) {
   137         case RestorePathMode:
   135             case RestorePathMode:
   138             cPath = iIncrementalOpenUtil->PathL();
   136                 cPath = iIncrementalOpenUtil->PathL();
   139             CleanupStack::PushL( cPath );
   137                 CleanupStack::PushL( cPath );
   140             iObserver->HandleIsolatedOpenRestorePathL( *cPath, aError );
   138                 iObserver->HandleIsolatedOpenRestorePathL( *cPath, aError );
   141             CleanupStack::PopAndDestroy( cPath );
   139                 CleanupStack::PopAndDestroy( cPath );
   142 
   140                 break;
   143             break;
   141             case DefaultMode:
   144         case DefaultMode:
   142             default:
   145         default:
   143                 iObserver->HandleIsolatedOpenL( aEntries, aError );
   146             iObserver->HandleIsolatedOpenL( aEntries, aError );
   144                 break;
   147             break;
   145             }
   148         }
       
   149         
       
   150         }
       
   151     }
   146     }
       
   147     TX_EXIT
       
   148 }
   152 
   149 
   153 /*!
   150 /*!
   154  \internal
   151  \internal
   155   reimp
   152   reimp
   156  */
   153  */
   157 void CMpMpxIsolatedCollectionHelper::HandleOpenL( 
   154 void CMpMpxIsolatedCollectionHelper::HandleOpenL(
   158     const CMPXCollectionPlaylist& /*aPlaylist*/,
   155     const CMPXCollectionPlaylist& aPlaylist,
   159     TInt /*aError*/ )
   156     TInt aError )
   160     {
   157 {
   161     }
   158     Q_UNUSED( aPlaylist );
       
   159     Q_UNUSED( aError );
       
   160 }
   162 
   161 
   163 /*!
   162 /*!
   164  \internal
   163  \internal
   165   reimp
   164   reimp
   166  */
   165  */
   167 void CMpMpxIsolatedCollectionHelper::HandleCollectionMessage( 
   166 void CMpMpxIsolatedCollectionHelper::HandleCollectionMessage(
   168     CMPXMessage* /*aMsg*/,
   167     CMPXMessage* aMsg,
   169     TInt /*aErr*/ )
   168     TInt aErr )
   170     {
   169 {
   171     }
   170     Q_UNUSED( aMsg );
       
   171     Q_UNUSED( aErr );
       
   172 }
   172 
   173 
   173 /*!
   174 /*!
   174  \internal
   175  \internal
   175   reimp
   176   reimp
   176  */
   177  */
   177 void CMpMpxIsolatedCollectionHelper::HandleCollectionMediaL( 
   178 void CMpMpxIsolatedCollectionHelper::HandleCollectionMediaL(
   178     const CMPXMedia& /*aMedia*/,
   179     const CMPXMedia& aMedia,
   179     TInt /*aError*/ )
   180     TInt aError )
   180     {
   181 {
   181     }
   182     Q_UNUSED( aMedia );
   182     
   183     Q_UNUSED( aError );
   183 //EOF
   184 }
       
   185