mmappcomponents/mmmtpdataprovider/mmmtpdpplugins/abstractmediamtpdataprovider/inc/cabstractmediamtpdataproviderenumerator.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Feb 2010 23:18:32 +0200
branchRCL_3
changeset 9 bee149131e4b
parent 0 a2952bb97e68
child 17 780c925249c1
permissions -rw-r--r--
Revision: 201003 Kit: 201007

/*
* 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:  Enumerator objects
*
*/


#ifndef CABSTRACTMEDIAMTPDATAPROVIDERENUMERATOR_H
#define CABSTRACTMEDIAMTPDATAPROVIDERENUMERATOR_H

#include <e32base.h>
#include <d32dbms.h>

#include "mmmtpenumerationcallback.h"
#include "cmmmtpdpperflog.h"

// Forward declarations
class MMTPDataProviderFramework;
class MMTPObjectMgr;
class CAbstractMediaMtpDataProvider;
class CMTPObjectMetaData;
class CMmMtpDpMetadataAccessWrapper;
class CMPXMediaArray;

/**
* Defines file enumerator.  Enumerates all files/directories under a
* specified path or storage
*/
class CAbstractMediaMtpDataProviderEnumerator: public CActive
    {
public:
    /**
    * Two phase constructor
    * @param aFramework Reference to MMTPDataProviderFramework
    * @param aDataProvider Reference to Abstract Media DataProvider
    * @return A pointer to a new instance of the object
    */
    static CAbstractMediaMtpDataProviderEnumerator* NewL( MMTPDataProviderFramework& aFramework,
        CAbstractMediaMtpDataProvider& aDataProvider );

    /**
    * destructor
    */
    ~CAbstractMediaMtpDataProviderEnumerator();

    /**
    * Kick off the enumeration on the specified storage
    * @param aStorageId storage to be enumerated
    */
    void StartL( TUint32 aStorageId );

protected: // from CActive
    /**
    * Cancel the enumeration process
    */
    void DoCancel();

    void RunL();

    /**
    * Ignore the error, continue with the next one
    */
    TInt RunError( TInt aError );

private:
    /**
    * Standard C++ Constructor
    * @param aFramework Reference to MMTPDataProviderFramework
    * @param aDataProvider Reference to Abstract Media DataProvider
    */
    CAbstractMediaMtpDataProviderEnumerator( MMTPDataProviderFramework& aFramework,
        CAbstractMediaMtpDataProvider& aDataProvider );

    void ConstructL();

    /**
    * Called when the enumeration is completed
    */
    void SignalCompleteL( MMTPEnumerationCallback& aCallback,
        TInt aError = KErrNone );

    void ScanStorageL( TUint32 aStorageId );

    /**
    * Scan next storage
    */
    void ScanNextL();

    /**
    * Add a file entry to the object store
    * @param aPath current scanned file path
    */
    void AddEntryL( const TDesC& aSuid );

    /**
    * Add references of specified abstract media into reference db
    * @param aAbstractMediaName, specify the abstract media of which references should be added into db
    * @param aReferences, suid array which stored references
    */
    void AddReferencesL( const TDesC& aAbstractMediaName, CDesCArray& aReferences );

private:
    // Owned
    /** MMTPDataProviderFramework used to access MTP components*/
    MMTPDataProviderFramework& iFramework;

    /** MTP Object Manager */
    MMTPObjectMgr& iObjectMgr;

    /** MTP Data Provider ID */
    TUint iDataProviderId;

    /** Provides Callback mechanism for completion of enumeration*/
    CAbstractMediaMtpDataProvider& iDataProvider;

    TParse iPath;
    TEntryArray iEntries;
    TInt iFirstUnprocessed;
    RArray<TUint> iStorages;
    TUint32 iStorageId;
    TUint32 iParentHandle;

    CMPXMediaArray* iAbstractMedias;
    TInt iCount;
    TInt iCurrentIndex;

#if defined(_DEBUG) || defined(MMMTPDP_PERFLOG)
    CMmMtpDpPerfLog* iPerfLog;
#endif

    };

#endif // CABSTRACTMEDIAMTPDATAPROVIDERENUMERATOR_H