First public contribution.
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
26 #ifndef __CAF_CONTENTITERATORDATA_H__
27 #define __CAF_CONTENTITERATORDATA_H__
31 #include <caf/caftypes.h>
33 namespace ContentAccess
35 /** Operations that can be performed by the thread owned by CContentIterator
40 enum TFileIteratorOperation
42 EIteratorShutdownThread = 1, ///< The iterator thread must be shut down
43 EIteratorFindNextContentObject = 2 ///< Find the next content object matching the requested mime type
46 /** Manages data shared between CContentIterator and the thread it uses to
49 This class also includes a locking mechanism to ensure the data is thread-safe
54 NONSHARABLE_CLASS(CContentIteratorData) : public CBase
57 /** Create a new CContentIteratorData object
59 @param aSearchPath The path to search for content
60 @param aRecursive ETrue to recursively search within directories
61 @param aMimeType The mime type of content to search for, zero length indicates a wildcard
62 @return a newCContentIteratorData object
64 static CContentIteratorData* NewL(const TDesC& aSearchPath, TBool aRecursive, const TDesC8& aMimeType);
68 virtual ~CContentIteratorData();
70 /** Lock member data within this class.
72 Obtains a mutex lock representing the data within the class. If the data
73 is already locked this function will wait until the lock is released
78 /** Releases the mutex lock for the data within the class
80 ie. enables another Lock() function to continue
84 /** Complete a request in a client thread
86 @param aError The error code to complete the client
88 void CompleteClientRequest(TInt aError);
90 /** Set the thread Id and client request to complete when
93 @param aClientThreadId The thread making the request
94 @param aStatus The TRequestStatus to signal when content is found
96 void SetClientRequest(TThreadId& aClientThreadId, TRequestStatus& aStatus);
98 /** Allow the CContentIterator thread function to run
100 @param aFunction The operation for the CContentIterator thread function to perform
102 void RunThreadFunction(TFileIteratorOperation aFunction);
105 /** Wait for a call to RunThreadFunction()
107 @return The function to execute in CContentIterators thread function
109 TFileIteratorOperation ThreadWait();
111 /** Set data relating to the content that was found
112 @param aFileName The name of the file where the content was found
113 @param aUniqueId The uniqueId of the content within the file
114 @param aName The name of the content object
115 @param aMimeType The mime type of the content
117 void SetData(const TDesC& aPath, const TDesC& aUniqueId, const TDesC& aName, const TDesC8& aMimeType);
119 /** The path of the file containing content
121 const TDesC& Path() const;
123 /** The uniqueId of the content within the file found using Next()
125 const TDesC& UniqueId() const;
127 /** The name of the content object
129 const TDesC& Name() const;
131 /** The mime type of the content
133 const TDesC8& MimeType() const;
135 /** Whether to perform a recursive search
137 TBool IsRecursive() const;
141 void ConstructL(const TDesC& aSearchPath, TBool aRecursive, const TDesC8& aMimeType);
142 CContentIteratorData();
144 TThreadId iClientThreadId;
145 TRequestStatus* iClientRequest;
147 RSemaphore iDataLockSemaphore;
148 RSemaphore iThreadSemaphore;
150 TFileIteratorOperation iFunction;
152 TBuf8 <KMaxDataTypeLength> iMimeType;
153 TBuf <KMaxCafUniqueId> iUniqueId;
154 TBuf <KMaxCafContentName> iName;