os/security/contentmgmt/referencedrmagent/contentiterator/contentiteratordata.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 /**
    20  @file
    21  @internalComponent
    22  @released
    23 */
    24 
    25 
    26 #ifndef __CAF_CONTENTITERATORDATA_H__
    27 #define __CAF_CONTENTITERATORDATA_H__
    28 
    29 #include <e32base.h>
    30 #include <apmstd.h>
    31 #include <caf/caftypes.h>
    32 
    33 namespace ContentAccess
    34 	{
    35 	/** Operations that can be performed by the thread owned by CContentIterator
    36 	
    37 	@internalComponent
    38 	@released
    39 	*/
    40 	enum TFileIteratorOperation
    41 		{
    42 		EIteratorShutdownThread			= 1,	///< The iterator thread must be shut down
    43 		EIteratorFindNextContentObject	= 2		///< Find the next content object matching the requested mime type
    44 		};
    45 
    46 	/** Manages data shared between CContentIterator and the thread it uses to
    47 	search for content.
    48 	
    49 	This class also includes a locking mechanism to ensure the data is thread-safe
    50 
    51 	@internalComponent
    52 	@released
    53 	*/
    54 	NONSHARABLE_CLASS(CContentIteratorData) : public CBase
    55 		{
    56 	public:
    57 		/** Create a new CContentIteratorData object
    58 		
    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 
    63 		*/
    64 		static CContentIteratorData* NewL(const TDesC& aSearchPath, TBool aRecursive, const TDesC8& aMimeType);
    65 		
    66 		/** Destructor 
    67 		*/
    68 		virtual ~CContentIteratorData();
    69 		
    70 		/** Lock member data within this class. 
    71 		
    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
    74 		before continuing.
    75 		*/
    76 		void Lock();
    77 
    78 		/** Releases the mutex lock for the data within the class
    79 
    80 		ie. enables another Lock() function to continue
    81 		*/
    82 		void Unlock();
    83 		
    84 		/** Complete a request in a client thread 
    85 		
    86 		@param aError The error code to complete the client
    87 		*/
    88 		void CompleteClientRequest(TInt aError);
    89 		
    90 		/** Set the thread Id and client request to complete when 
    91 		content is found
    92 		
    93 		@param aClientThreadId The thread making the request
    94 		@param aStatus The TRequestStatus to signal when content is found
    95 		*/
    96 		void SetClientRequest(TThreadId& aClientThreadId, TRequestStatus& aStatus);
    97 		
    98 		/** Allow the CContentIterator thread function to run
    99 		
   100 		@param aFunction The operation for the CContentIterator thread function to perform
   101 		*/
   102 		void RunThreadFunction(TFileIteratorOperation aFunction);		
   103 		
   104 		
   105 		/** Wait for a call to RunThreadFunction()
   106 		
   107 		@return The function to execute in CContentIterators thread function 
   108 		*/
   109 		TFileIteratorOperation ThreadWait();		
   110 		
   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
   116 		*/
   117 		void SetData(const TDesC& aPath, const TDesC& aUniqueId, const TDesC& aName, const TDesC8& aMimeType);
   118 		
   119 		/** The path of the file containing content
   120 		*/
   121 		const TDesC& Path() const;
   122 		
   123 		/** The uniqueId of the content within the file found using Next()
   124 		*/
   125 		const TDesC& UniqueId() const;
   126 		
   127 		/** The name of the content object 
   128 		*/
   129 		const TDesC& Name() const;
   130 
   131 		/** The mime type of the content
   132 		*/
   133 		const TDesC8& MimeType() const;
   134 		
   135 		/** Whether to perform a recursive search
   136 		*/
   137 		TBool IsRecursive() const;
   138 		
   139 	private:
   140 	
   141 		void ConstructL(const TDesC& aSearchPath, TBool aRecursive, const TDesC8& aMimeType);
   142 		CContentIteratorData();
   143 		
   144 		TThreadId iClientThreadId;
   145 		TRequestStatus* iClientRequest;
   146 		
   147 		RSemaphore iDataLockSemaphore;
   148 		RSemaphore iThreadSemaphore;
   149 		
   150 		TFileIteratorOperation iFunction;
   151 		TFileName iPath;
   152 		TBuf8 <KMaxDataTypeLength> iMimeType;
   153 		TBuf <KMaxCafUniqueId> iUniqueId;		
   154 		TBuf <KMaxCafContentName> iName;		
   155 		TBool iRecursive;
   156 		};
   157 	}
   158 	
   159 #endif