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