mpengine/src/mpmpxisolatedcollectionhelper.cpp
branchRCL_3
changeset 52 14979e23cb5e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mpengine/src/mpmpxisolatedcollectionhelper.cpp	Tue Aug 31 15:12:29 2010 +0300
@@ -0,0 +1,185 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: isolated collection helper.
+*
+*/
+
+
+#include <mpxcollectionhelperfactory.h>
+#include <mpxcollectionuihelper.h>
+#include <mpxcollectionopenutility.h>
+
+#include "mpmpxisolatedcollectionhelper.h"
+#include "mptrace.h"
+
+const TInt KIncrementalDelay = 0;
+const TInt KIncrementalFetchBlockSize = 1000;
+
+
+/*!
+    \class CMpMpxIsolatedCollectionHelper
+    \brief Helper class to open an isolated collection.
+
+    This is a helper class to open an insolated collection.
+*/
+
+/*!
+ \internal
+ Two-phased constructor.
+ */
+CMpMpxIsolatedCollectionHelper* CMpMpxIsolatedCollectionHelper::NewL(
+        MMpMpxIsolatedCollectionHelperObserver* aObserver )
+{
+    CMpMpxIsolatedCollectionHelper* self = NewLC( aObserver );
+    CleanupStack::Pop( self );
+    return self;
+}
+
+/*!
+ \internal
+ Two-phased constructor.
+ */
+CMpMpxIsolatedCollectionHelper* CMpMpxIsolatedCollectionHelper::NewLC(
+        MMpMpxIsolatedCollectionHelperObserver* aObserver )
+{
+    CMpMpxIsolatedCollectionHelper* self =
+            new ( ELeave ) CMpMpxIsolatedCollectionHelper( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+}
+
+/*!
+ \internal
+ Destructor
+ */
+CMpMpxIsolatedCollectionHelper::~CMpMpxIsolatedCollectionHelper()
+{
+    delete iIncrementalOpenUtil;
+}
+
+
+/*!
+ \internal
+ Opens an isolated collection with the /a path.
+ */
+void CMpMpxIsolatedCollectionHelper::OpenCollectionL( CMPXCollectionPath& aPath, TInt aIndex, MpOpenMode aMode )
+{
+    TX_ENTRY
+    //Using incremental open to open the collection.
+    iOpenMode = aMode;
+    // Cancel any reads
+    iIncrementalOpenUtil->Stop();
+
+    // Start the read
+    iFirstIncrementalOpen = ETrue;
+    RArray<TMPXAttribute> attrs;
+    CleanupClosePushL( attrs );
+    TArray<TMPXAttribute> ary = attrs.Array();
+    iIncrementalOpenUtil->SetDelay( KIncrementalDelay );
+    iIncrementalOpenUtil->StartL( aPath, ary, KIncrementalFetchBlockSize,
+                                  aIndex, CMPXCollectionOpenUtility::EFetchDown );
+    CleanupStack::PopAndDestroy( &attrs );
+    TX_EXIT
+}
+
+/*!
+ \internal
+ c++ Contructor
+ */
+CMpMpxIsolatedCollectionHelper::CMpMpxIsolatedCollectionHelper( MMpMpxIsolatedCollectionHelperObserver* aObserver )
+    : iObserver( aObserver ),
+      iIncrementalOpenUtil( 0 ),
+      iFirstIncrementalOpen( EFalse )
+{
+}
+
+/*!
+ \internal
+ Leaving constructor
+ */
+void CMpMpxIsolatedCollectionHelper::ConstructL()
+{
+    iIncrementalOpenUtil = CMPXCollectionOpenUtility::NewL( this, KMcModeIsolated );
+}
+
+
+/*!
+ \internal
+ reimp
+ */
+void CMpMpxIsolatedCollectionHelper::HandleOpenL(
+    const CMPXMedia& aEntries,
+    TInt aIndex,
+    TBool aComplete,
+    TInt aError )
+{
+    Q_UNUSED( aIndex );
+    Q_UNUSED( aComplete );
+    TX_ENTRY_ARGS( "aError=" << aError << "aComplete=" << aComplete );
+    if ( iFirstIncrementalOpen ) {
+        CMPXCollectionPath* cPath = NULL;
+        iFirstIncrementalOpen = EFalse;
+        switch( iOpenMode ) {
+            case RestorePathMode:
+                cPath = iIncrementalOpenUtil->PathL();
+                CleanupStack::PushL( cPath );
+                iObserver->HandleIsolatedOpenRestorePathL( *cPath, aError );
+                CleanupStack::PopAndDestroy( cPath );
+                break;
+            case DefaultMode:
+            default:
+                iObserver->HandleIsolatedOpenL( aEntries, aError );
+                break;
+            }
+    }
+    TX_EXIT
+}
+
+/*!
+ \internal
+  reimp
+ */
+void CMpMpxIsolatedCollectionHelper::HandleOpenL(
+    const CMPXCollectionPlaylist& aPlaylist,
+    TInt aError )
+{
+    Q_UNUSED( aPlaylist );
+    Q_UNUSED( aError );
+}
+
+/*!
+ \internal
+  reimp
+ */
+void CMpMpxIsolatedCollectionHelper::HandleCollectionMessage(
+    CMPXMessage* aMsg,
+    TInt aErr )
+{
+    Q_UNUSED( aMsg );
+    Q_UNUSED( aErr );
+}
+
+/*!
+ \internal
+  reimp
+ */
+void CMpMpxIsolatedCollectionHelper::HandleCollectionMediaL(
+    const CMPXMedia& aMedia,
+    TInt aError )
+{
+    Q_UNUSED( aMedia );
+    Q_UNUSED( aError );
+}
+