mpengine/src/mpmpxisolatedcollectionhelper.cpp
changeset 22 ecf06a08d4d9
child 38 b93f525c9244
equal deleted inserted replaced
20:82baf59ce8dd 22:ecf06a08d4d9
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: isolated collection helper.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <mpxcollectionhelperfactory.h>
       
    20 #include <mpxcollectionuihelper.h>
       
    21 #include <mpxcollectionopenutility.h>
       
    22 
       
    23 #include "mpmpxisolatedcollectionhelper.h"
       
    24 #include "mpxlog.h"
       
    25 
       
    26 
       
    27 
       
    28 const TInt KIncrementalDelayNone = 0;
       
    29 const TInt KIncrementalDelayHalfSecond = 1000000;
       
    30 const TInt KIncrementalFetchBlockSize = 20;
       
    31 const TInt KIncrementalNullOffset = 0;
       
    32 
       
    33 
       
    34 /*!
       
    35     \class CMpMpxIsolatedCollectionHelper
       
    36     \brief Helper class to open an isolated collection.
       
    37 
       
    38     This is a helper class to open an insolated collection.
       
    39 */
       
    40 
       
    41 /*!
       
    42  \internal
       
    43  Two-phased constructor.
       
    44  */
       
    45 CMpMpxIsolatedCollectionHelper* CMpMpxIsolatedCollectionHelper::NewL( 
       
    46         MMpMpxIsolatedCollectionHelperObserver* aObserver )
       
    47     {
       
    48     CMpMpxIsolatedCollectionHelper* self = NewLC( aObserver );
       
    49     CleanupStack::Pop( self );
       
    50     return self;
       
    51     }
       
    52 
       
    53 /*!
       
    54  \internal
       
    55  Two-phased constructor.
       
    56  */
       
    57 CMpMpxIsolatedCollectionHelper* CMpMpxIsolatedCollectionHelper::NewLC( 
       
    58         MMpMpxIsolatedCollectionHelperObserver* aObserver )
       
    59     {
       
    60     CMpMpxIsolatedCollectionHelper* self =
       
    61             new ( ELeave ) CMpMpxIsolatedCollectionHelper( aObserver );
       
    62     CleanupStack::PushL( self );
       
    63     self->ConstructL();
       
    64     return self;
       
    65     }
       
    66 
       
    67 /*!
       
    68  \internal
       
    69  Destructor
       
    70  */
       
    71 CMpMpxIsolatedCollectionHelper::~CMpMpxIsolatedCollectionHelper()
       
    72     {
       
    73     delete iIncrementalOpenUtil;
       
    74     }
       
    75     
       
    76 
       
    77 /*!
       
    78  \internal
       
    79  Opens an isolated collection with the /a path.
       
    80  */
       
    81 void CMpMpxIsolatedCollectionHelper::OpenCollectionL( CMPXCollectionPath& aPath )
       
    82     {
       
    83     //Using incremental open to open the collection.
       
    84     
       
    85     // Cancel any reads
       
    86     iIncrementalOpenUtil->Stop();
       
    87 
       
    88     // Start the read
       
    89     iFirstIncrementalOpen = ETrue;
       
    90     RArray<TMPXAttribute> attrs;
       
    91     CleanupClosePushL( attrs );
       
    92     TArray<TMPXAttribute> ary = attrs.Array();
       
    93     iIncrementalOpenUtil->SetDelay( KIncrementalDelayNone );
       
    94     iIncrementalOpenUtil->StartL( aPath, ary, KIncrementalFetchBlockSize,
       
    95                                   KIncrementalNullOffset, CMPXCollectionOpenUtility::EFetchNormal );
       
    96     iIncrementalOpenUtil->SetDelay( KIncrementalDelayHalfSecond );
       
    97     CleanupStack::PopAndDestroy( &attrs );
       
    98     }
       
    99 
       
   100 /*!
       
   101  \internal
       
   102  c++ Contructor
       
   103  */
       
   104 CMpMpxIsolatedCollectionHelper::CMpMpxIsolatedCollectionHelper( MMpMpxIsolatedCollectionHelperObserver* aObserver )
       
   105     : iObserver( aObserver ),
       
   106       iIncrementalOpenUtil( 0 ),
       
   107       iFirstIncrementalOpen( EFalse )
       
   108     {
       
   109     }
       
   110 
       
   111 /*!
       
   112  \internal
       
   113  Leaving constructor
       
   114  */
       
   115 void CMpMpxIsolatedCollectionHelper::ConstructL()
       
   116     {
       
   117     iIncrementalOpenUtil = CMPXCollectionOpenUtility::NewL( this, KMcModeIsolated );
       
   118 
       
   119     }
       
   120 
       
   121 
       
   122 /*!
       
   123  \internal
       
   124  reimp
       
   125  */
       
   126 void CMpMpxIsolatedCollectionHelper::HandleOpenL( 
       
   127     const CMPXMedia& aEntries,
       
   128     TInt /*aIndex*/,
       
   129     TBool /*aComplete*/,
       
   130     TInt aError )
       
   131     {
       
   132     if ( iFirstIncrementalOpen )
       
   133         {
       
   134         iObserver->HandleIsolatedOpenL( aEntries, aError );
       
   135         iFirstIncrementalOpen = EFalse;
       
   136         }
       
   137     }
       
   138 
       
   139 /*!
       
   140  \internal
       
   141   reimp
       
   142  */
       
   143 void CMpMpxIsolatedCollectionHelper::HandleOpenL( 
       
   144     const CMPXCollectionPlaylist& /*aPlaylist*/,
       
   145     TInt /*aError*/ )
       
   146     {
       
   147     }
       
   148 
       
   149 /*!
       
   150  \internal
       
   151   reimp
       
   152  */
       
   153 void CMpMpxIsolatedCollectionHelper::HandleCollectionMessage( 
       
   154     CMPXMessage* /*aMsg*/,
       
   155     TInt /*aErr*/ )
       
   156     {
       
   157     }
       
   158 
       
   159 /*!
       
   160  \internal
       
   161   reimp
       
   162  */
       
   163 void CMpMpxIsolatedCollectionHelper::HandleCollectionMediaL( 
       
   164     const CMPXMedia& /*aMedia*/,
       
   165     TInt /*aError*/ )
       
   166     {
       
   167     }
       
   168     
       
   169 //EOF