contentmgmt/referencedrmagent/contentiterator/contentIterator.h
changeset 15 da2ae96f639b
equal deleted inserted replaced
10:afc583cfa176 15:da2ae96f639b
       
     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  @publishedPartner
       
    22  @released
       
    23 */
       
    24 
       
    25 
       
    26 #ifndef __CAF_CONTENTITERATOR_H__
       
    27 #define __CAF_CONTENTITERATOR_H__
       
    28 
       
    29 #include <e32base.h>
       
    30 #include <apmstd.h>
       
    31 #include <caf/caftypes.h>
       
    32 
       
    33 namespace ContentAccess 
       
    34 	{
       
    35 	class CContentIteratorData;
       
    36 	class TVirtualPathPtr;
       
    37 	
       
    38 	/** This class can be used to asynchronously search through directories
       
    39 	on the files system to find content with a particular mime type
       
    40 	
       
    41 	This class creates a thread that is used to search recursively. It uses
       
    42 	a considerable amount of memory and should be destroyed as soon as it
       
    43 	is no longer needed.
       
    44 	 
       
    45 	It must work in a thread rather than as a server so the CAF agents can
       
    46 	perform capability checking against the client process. It uses a thread
       
    47 	because it is recursive and could lead to a stack overflow if the recursion
       
    48 	occurred in the client thread
       
    49 	
       
    50 	Since CContentIterator is an active object clients should not 
       
    51 	use the User::WaitForRequest() API since it will not give 
       
    52 	CContentIterator::RunL() a chance to run.
       
    53 	
       
    54 	@publishedPartner
       
    55 	@released
       
    56 	*/
       
    57 	class CContentIterator : public CActive
       
    58 		{
       
    59 	public:
       
    60 	
       
    61 		/** Create a CContentIterator
       
    62 		
       
    63 		@param aPath The path to search for content
       
    64 		@param aRecursive ETrue to recursively search within directories
       
    65 		@param aMimeType The mime type to search for, a zero length descriptor can be used as a wildcard to find all content
       
    66 		@return a new CContentIterator
       
    67 		*/
       
    68 		IMPORT_C static CContentIterator* NewL(const TDesC& aPath, TBool aRecursive, const TDesC8& aMimeType);
       
    69 
       
    70 		/** Destructor */
       
    71 		virtual ~CContentIterator();
       
    72 
       
    73 		/** Find the next content object
       
    74 		
       
    75 		Clients should not use the User::WaitForRequest() API when calling 
       
    76 		the Next() function since it will not give CContentIterator's RunL() 
       
    77 		a chance to run.
       
    78 		
       
    79 		@param aStatus Request to complete when the next content item is found or KErrNotFound if no further content was found
       
    80 		*/
       
    81 		IMPORT_C void Next(TRequestStatus &aStatus);
       
    82 
       
    83 		/** The name of the file containing the content object found in the most recent call to Next()
       
    84 	
       
    85 		@return The name of the file
       
    86 		*/
       
    87 		IMPORT_C TVirtualPathPtr VirtualPath();
       
    88 
       
    89 		/** The mime type of the content object found in the most recent call to Next()
       
    90 	
       
    91 		@return The name of the file
       
    92 		*/
       
    93 		IMPORT_C const TDesC8& MimeType();
       
    94 
       
    95 		/** The name of the content object found in the most recent call to Next()
       
    96 	
       
    97 		@return The name of the content object
       
    98 		*/
       
    99 		IMPORT_C const TDesC& Name();
       
   100 
       
   101 
       
   102 	protected:
       
   103 		virtual void DoCancel();
       
   104 		virtual void RunL();
       
   105 			
       
   106 	private:
       
   107 		CContentIterator();
       
   108 		void ConstructL(const TDesC& aPath, TBool aRecursive, const TDesC8& aMimeType);
       
   109 		
       
   110 		static TInt ThreadEntry(TAny* aAny);
       
   111 	
       
   112 	private:
       
   113 		TBuf8 <KMaxDataTypeLength> iMimeType;
       
   114 		TFileName iFileName;
       
   115 		TBuf <KMaxCafContentName> iName;
       
   116 		TBuf <KMaxCafUniqueId> iUniqueId;
       
   117 	
       
   118 		RThread iWorkerThread;	
       
   119 		CContentIteratorData* info;
       
   120 		};
       
   121 	}
       
   122 
       
   123 #endif