os/security/contentmgmt/referencedrmagent/contentiterator/contentiteratordata.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/contentmgmt/referencedrmagent/contentiterator/contentiteratordata.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,159 @@
     1.4 +/*
     1.5 +* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +/**
    1.23 + @file
    1.24 + @internalComponent
    1.25 + @released
    1.26 +*/
    1.27 +
    1.28 +
    1.29 +#ifndef __CAF_CONTENTITERATORDATA_H__
    1.30 +#define __CAF_CONTENTITERATORDATA_H__
    1.31 +
    1.32 +#include <e32base.h>
    1.33 +#include <apmstd.h>
    1.34 +#include <caf/caftypes.h>
    1.35 +
    1.36 +namespace ContentAccess
    1.37 +	{
    1.38 +	/** Operations that can be performed by the thread owned by CContentIterator
    1.39 +	
    1.40 +	@internalComponent
    1.41 +	@released
    1.42 +	*/
    1.43 +	enum TFileIteratorOperation
    1.44 +		{
    1.45 +		EIteratorShutdownThread			= 1,	///< The iterator thread must be shut down
    1.46 +		EIteratorFindNextContentObject	= 2		///< Find the next content object matching the requested mime type
    1.47 +		};
    1.48 +
    1.49 +	/** Manages data shared between CContentIterator and the thread it uses to
    1.50 +	search for content.
    1.51 +	
    1.52 +	This class also includes a locking mechanism to ensure the data is thread-safe
    1.53 +
    1.54 +	@internalComponent
    1.55 +	@released
    1.56 +	*/
    1.57 +	NONSHARABLE_CLASS(CContentIteratorData) : public CBase
    1.58 +		{
    1.59 +	public:
    1.60 +		/** Create a new CContentIteratorData object
    1.61 +		
    1.62 +		@param aSearchPath The path to search for content
    1.63 +		@param aRecursive ETrue to recursively search within directories
    1.64 +		@param aMimeType The mime type of content to search for, zero length indicates a wildcard
    1.65 +		@return a newCContentIteratorData object 
    1.66 +		*/
    1.67 +		static CContentIteratorData* NewL(const TDesC& aSearchPath, TBool aRecursive, const TDesC8& aMimeType);
    1.68 +		
    1.69 +		/** Destructor 
    1.70 +		*/
    1.71 +		virtual ~CContentIteratorData();
    1.72 +		
    1.73 +		/** Lock member data within this class. 
    1.74 +		
    1.75 +		Obtains a mutex lock representing the data within the class. If the data
    1.76 +		is already locked this function will wait until the lock is released
    1.77 +		before continuing.
    1.78 +		*/
    1.79 +		void Lock();
    1.80 +
    1.81 +		/** Releases the mutex lock for the data within the class
    1.82 +
    1.83 +		ie. enables another Lock() function to continue
    1.84 +		*/
    1.85 +		void Unlock();
    1.86 +		
    1.87 +		/** Complete a request in a client thread 
    1.88 +		
    1.89 +		@param aError The error code to complete the client
    1.90 +		*/
    1.91 +		void CompleteClientRequest(TInt aError);
    1.92 +		
    1.93 +		/** Set the thread Id and client request to complete when 
    1.94 +		content is found
    1.95 +		
    1.96 +		@param aClientThreadId The thread making the request
    1.97 +		@param aStatus The TRequestStatus to signal when content is found
    1.98 +		*/
    1.99 +		void SetClientRequest(TThreadId& aClientThreadId, TRequestStatus& aStatus);
   1.100 +		
   1.101 +		/** Allow the CContentIterator thread function to run
   1.102 +		
   1.103 +		@param aFunction The operation for the CContentIterator thread function to perform
   1.104 +		*/
   1.105 +		void RunThreadFunction(TFileIteratorOperation aFunction);		
   1.106 +		
   1.107 +		
   1.108 +		/** Wait for a call to RunThreadFunction()
   1.109 +		
   1.110 +		@return The function to execute in CContentIterators thread function 
   1.111 +		*/
   1.112 +		TFileIteratorOperation ThreadWait();		
   1.113 +		
   1.114 +		/** Set data relating to the content that was found 
   1.115 +		@param aFileName The name of the file where the content was found
   1.116 +		@param aUniqueId The uniqueId of the content within the file
   1.117 +		@param aName The name of the content object
   1.118 +		@param aMimeType The mime type of the content
   1.119 +		*/
   1.120 +		void SetData(const TDesC& aPath, const TDesC& aUniqueId, const TDesC& aName, const TDesC8& aMimeType);
   1.121 +		
   1.122 +		/** The path of the file containing content
   1.123 +		*/
   1.124 +		const TDesC& Path() const;
   1.125 +		
   1.126 +		/** The uniqueId of the content within the file found using Next()
   1.127 +		*/
   1.128 +		const TDesC& UniqueId() const;
   1.129 +		
   1.130 +		/** The name of the content object 
   1.131 +		*/
   1.132 +		const TDesC& Name() const;
   1.133 +
   1.134 +		/** The mime type of the content
   1.135 +		*/
   1.136 +		const TDesC8& MimeType() const;
   1.137 +		
   1.138 +		/** Whether to perform a recursive search
   1.139 +		*/
   1.140 +		TBool IsRecursive() const;
   1.141 +		
   1.142 +	private:
   1.143 +	
   1.144 +		void ConstructL(const TDesC& aSearchPath, TBool aRecursive, const TDesC8& aMimeType);
   1.145 +		CContentIteratorData();
   1.146 +		
   1.147 +		TThreadId iClientThreadId;
   1.148 +		TRequestStatus* iClientRequest;
   1.149 +		
   1.150 +		RSemaphore iDataLockSemaphore;
   1.151 +		RSemaphore iThreadSemaphore;
   1.152 +		
   1.153 +		TFileIteratorOperation iFunction;
   1.154 +		TFileName iPath;
   1.155 +		TBuf8 <KMaxDataTypeLength> iMimeType;
   1.156 +		TBuf <KMaxCafUniqueId> iUniqueId;		
   1.157 +		TBuf <KMaxCafContentName> iName;		
   1.158 +		TBool iRecursive;
   1.159 +		};
   1.160 +	}
   1.161 +	
   1.162 +#endif