|
1 /* |
|
2 * Copyright (c) 2007 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: File search utility active agent for use within browser ui |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CFEEDSFILESEARCHAGENT_H |
|
21 #define CFEEDSFILESEARCHAGENT_H |
|
22 |
|
23 // INCLUDES |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <f32file.h> |
|
27 |
|
28 // CONSTANTS |
|
29 |
|
30 // MACROS |
|
31 |
|
32 // FUNCTION PROTOTYPES |
|
33 #define FEEDS_FILE_SEARCH_AGENT_MAX_RESULTS 64 |
|
34 |
|
35 // FORWARD DECLARATIONS |
|
36 |
|
37 // CLASS DECLARATION |
|
38 |
|
39 // DATA TYPES |
|
40 |
|
41 // CLASS DECLARATION |
|
42 |
|
43 /** |
|
44 * Encapsulate drive entry info |
|
45 * @since 3.2 |
|
46 */ |
|
47 class TDriveEntry |
|
48 { |
|
49 public: |
|
50 TChar iLetter; |
|
51 TInt iNumber; |
|
52 }; |
|
53 |
|
54 /** |
|
55 * Encapsulate File entry info |
|
56 * @since 3.2 |
|
57 */ |
|
58 class TFileEntry |
|
59 { |
|
60 public: |
|
61 TFileName iPath; |
|
62 TEntry iEntry; |
|
63 }; |
|
64 |
|
65 typedef CArrayFixSeg<TDriveEntry> CDriveEntryList; |
|
66 typedef CArrayFixSeg<TFileEntry> CFileEntryList; |
|
67 |
|
68 /** |
|
69 * A Callback mixin for search Agent |
|
70 * @since 3.2 |
|
71 */ |
|
72 |
|
73 class MFeedsFileSearchAgentCallback |
|
74 { |
|
75 public: |
|
76 virtual void FeedsFileSearchCompleteL(TInt aCount) = 0; |
|
77 }; |
|
78 |
|
79 // CLASS DECLARATION |
|
80 |
|
81 /** |
|
82 * An Active Agent used to search the filesystem for feeds files |
|
83 * @since 3.2 |
|
84 */ |
|
85 |
|
86 class CFeedsFileSearchAgent : public CBase |
|
87 { |
|
88 public: // Constructor & destructor |
|
89 |
|
90 /** |
|
91 * Two-phased constructor. |
|
92 */ |
|
93 static CFeedsFileSearchAgent* NewL(MFeedsFileSearchAgentCallback& aCallback); |
|
94 |
|
95 /** |
|
96 * Destructor. |
|
97 */ |
|
98 virtual ~CFeedsFileSearchAgent(); |
|
99 |
|
100 public: // New Functions |
|
101 |
|
102 /** |
|
103 * Once the search agent has been setup via its constructor, begin |
|
104 * the search process |
|
105 * @since 3.2 |
|
106 * @return void |
|
107 */ |
|
108 void StartSearchingL(); |
|
109 |
|
110 /** |
|
111 * After the search has completed, allows client to retrieve a |
|
112 * File entry pointer corresponding to the passed-in index |
|
113 * @since 3.2 |
|
114 * @return File entry pointer or NULL if invalid index |
|
115 */ |
|
116 TFileEntry* GetFileEntry(const TInt aIndex); |
|
117 |
|
118 private: // Search Functions |
|
119 |
|
120 /** |
|
121 * Populate the list of available drives on the phone within this class |
|
122 * @since 3.2 |
|
123 */ |
|
124 void GetDriveListL(); |
|
125 |
|
126 /** |
|
127 * Given a directory, search for a wildcard-included filename within |
|
128 * that directory |
|
129 * @since 3.2 |
|
130 * @param a filename, a path |
|
131 */ |
|
132 TInt DoSearchFiles(const TDesC& aFileName, const TDesC& aPath); |
|
133 |
|
134 /** |
|
135 * Given a directory, search recursively for a wildcard-included filename |
|
136 * within the hierarchy below that directory |
|
137 * @since 3.2 |
|
138 * @param a filename, a path |
|
139 */ |
|
140 TInt DoSearchFilesRecursive(const TDesC& aFileName); |
|
141 |
|
142 private: |
|
143 |
|
144 /** |
|
145 * C++ constructor. |
|
146 */ |
|
147 CFeedsFileSearchAgent(MFeedsFileSearchAgentCallback& aCallback); |
|
148 |
|
149 /** |
|
150 * By default Symbian 2nd phase constructor is private. |
|
151 */ |
|
152 void ConstructL(); |
|
153 |
|
154 public: |
|
155 /** |
|
156 * This method is a call back; |
|
157 * |
|
158 * @since 7.1 |
|
159 * @return The TBool. |
|
160 */ |
|
161 static TBool LazyCallBack(TAny* aPtr); |
|
162 |
|
163 /** |
|
164 * This method Cancels the ongoing search; |
|
165 * |
|
166 * @since 7.1 |
|
167 * @return Void. |
|
168 */ |
|
169 void CancelSearch(); |
|
170 |
|
171 /** |
|
172 * This method Starts the search; |
|
173 * |
|
174 * @since 7.1 |
|
175 * @return TBool. |
|
176 */ |
|
177 TBool StartSearchFile(); |
|
178 |
|
179 private: // Data |
|
180 |
|
181 RFs iFs; |
|
182 |
|
183 MFeedsFileSearchAgentCallback* iCallback; // not owned (callee owns) |
|
184 CDriveEntryList* iDriveEntryList; // owned |
|
185 |
|
186 TInt iSearchDriveIndex; |
|
187 |
|
188 CFileEntryList* iFileEntryList; // owned |
|
189 TBool iCancelSearch; |
|
190 CIdle* iLazyCaller; |
|
191 CDirScan* iScan; |
|
192 }; |
|
193 |
|
194 #endif // CFEEDSFILESEARCHAGENT_H |
|
195 |
|
196 // End of File |