sl@0: /* sl@0: * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: @released sl@0: */ sl@0: sl@0: sl@0: #ifndef __CAF_CONTENTITERATORDATA_H__ sl@0: #define __CAF_CONTENTITERATORDATA_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: namespace ContentAccess sl@0: { sl@0: /** Operations that can be performed by the thread owned by CContentIterator sl@0: sl@0: @internalComponent sl@0: @released sl@0: */ sl@0: enum TFileIteratorOperation sl@0: { sl@0: EIteratorShutdownThread = 1, ///< The iterator thread must be shut down sl@0: EIteratorFindNextContentObject = 2 ///< Find the next content object matching the requested mime type sl@0: }; sl@0: sl@0: /** Manages data shared between CContentIterator and the thread it uses to sl@0: search for content. sl@0: sl@0: This class also includes a locking mechanism to ensure the data is thread-safe sl@0: sl@0: @internalComponent sl@0: @released sl@0: */ sl@0: NONSHARABLE_CLASS(CContentIteratorData) : public CBase sl@0: { sl@0: public: sl@0: /** Create a new CContentIteratorData object sl@0: sl@0: @param aSearchPath The path to search for content sl@0: @param aRecursive ETrue to recursively search within directories sl@0: @param aMimeType The mime type of content to search for, zero length indicates a wildcard sl@0: @return a newCContentIteratorData object sl@0: */ sl@0: static CContentIteratorData* NewL(const TDesC& aSearchPath, TBool aRecursive, const TDesC8& aMimeType); sl@0: sl@0: /** Destructor sl@0: */ sl@0: virtual ~CContentIteratorData(); sl@0: sl@0: /** Lock member data within this class. sl@0: sl@0: Obtains a mutex lock representing the data within the class. If the data sl@0: is already locked this function will wait until the lock is released sl@0: before continuing. sl@0: */ sl@0: void Lock(); sl@0: sl@0: /** Releases the mutex lock for the data within the class sl@0: sl@0: ie. enables another Lock() function to continue sl@0: */ sl@0: void Unlock(); sl@0: sl@0: /** Complete a request in a client thread sl@0: sl@0: @param aError The error code to complete the client sl@0: */ sl@0: void CompleteClientRequest(TInt aError); sl@0: sl@0: /** Set the thread Id and client request to complete when sl@0: content is found sl@0: sl@0: @param aClientThreadId The thread making the request sl@0: @param aStatus The TRequestStatus to signal when content is found sl@0: */ sl@0: void SetClientRequest(TThreadId& aClientThreadId, TRequestStatus& aStatus); sl@0: sl@0: /** Allow the CContentIterator thread function to run sl@0: sl@0: @param aFunction The operation for the CContentIterator thread function to perform sl@0: */ sl@0: void RunThreadFunction(TFileIteratorOperation aFunction); sl@0: sl@0: sl@0: /** Wait for a call to RunThreadFunction() sl@0: sl@0: @return The function to execute in CContentIterators thread function sl@0: */ sl@0: TFileIteratorOperation ThreadWait(); sl@0: sl@0: /** Set data relating to the content that was found sl@0: @param aFileName The name of the file where the content was found sl@0: @param aUniqueId The uniqueId of the content within the file sl@0: @param aName The name of the content object sl@0: @param aMimeType The mime type of the content sl@0: */ sl@0: void SetData(const TDesC& aPath, const TDesC& aUniqueId, const TDesC& aName, const TDesC8& aMimeType); sl@0: sl@0: /** The path of the file containing content sl@0: */ sl@0: const TDesC& Path() const; sl@0: sl@0: /** The uniqueId of the content within the file found using Next() sl@0: */ sl@0: const TDesC& UniqueId() const; sl@0: sl@0: /** The name of the content object sl@0: */ sl@0: const TDesC& Name() const; sl@0: sl@0: /** The mime type of the content sl@0: */ sl@0: const TDesC8& MimeType() const; sl@0: sl@0: /** Whether to perform a recursive search sl@0: */ sl@0: TBool IsRecursive() const; sl@0: sl@0: private: sl@0: sl@0: void ConstructL(const TDesC& aSearchPath, TBool aRecursive, const TDesC8& aMimeType); sl@0: CContentIteratorData(); sl@0: sl@0: TThreadId iClientThreadId; sl@0: TRequestStatus* iClientRequest; sl@0: sl@0: RSemaphore iDataLockSemaphore; sl@0: RSemaphore iThreadSemaphore; sl@0: sl@0: TFileIteratorOperation iFunction; sl@0: TFileName iPath; sl@0: TBuf8 iMimeType; sl@0: TBuf iUniqueId; sl@0: TBuf iName; sl@0: TBool iRecursive; sl@0: }; sl@0: } sl@0: sl@0: #endif