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