|
1 /*------------------------------------------------------------------ |
|
2 - |
|
3 * Software Name : UserEmulator |
|
4 * Version : v4.2.1309 |
|
5 * |
|
6 * Copyright (c) 2009 France Telecom. All rights reserved. |
|
7 * This software is distributed under the License |
|
8 * "Eclipse Public License - v 1.0" the text of which is available |
|
9 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
10 * |
|
11 * Initial Contributors: |
|
12 * France Telecom |
|
13 * |
|
14 * Contributors: |
|
15 *------------------------------------------------------------------ |
|
16 - |
|
17 * File Name: ScanFolders.h |
|
18 * |
|
19 * Created: 13/08/2009 |
|
20 * Author(s): Marcell Kiss, Reshma Sandeep Das |
|
21 * |
|
22 * Description: |
|
23 * Active object implementation for folder scanning operation |
|
24 *------------------------------------------------------------------ |
|
25 - |
|
26 * |
|
27 */ |
|
28 #ifndef SCANFOLDERS_H__ |
|
29 #define SCANFOLDERS_H__ |
|
30 |
|
31 //System includes |
|
32 #include <E32Base.h> |
|
33 #include <EikEnv.h> |
|
34 #include <F32File.h> |
|
35 |
|
36 //User Includes |
|
37 #include "Constants.h" |
|
38 |
|
39 //Forward Declarations |
|
40 class MFolderContentsListener; |
|
41 class CUserEmulatorScriptsView; |
|
42 |
|
43 |
|
44 /** |
|
45 * CScanFolders |
|
46 * Active object implementation for scanning for script files in a folder |
|
47 */ |
|
48 class CScanFolders : public CActive |
|
49 { |
|
50 public: |
|
51 /** |
|
52 * Static constructor |
|
53 * @return CScanFolders* A pointer to the newly alocated CScanFolders class. |
|
54 * NULL, if the class cannot be created |
|
55 */ |
|
56 static CScanFolders * NewL(); |
|
57 /** |
|
58 * Static constructor |
|
59 * @return CScanFolders* A pointer to the newly alocated CScanFolders class. |
|
60 * NULL, if the class cannot be created |
|
61 */ |
|
62 static CScanFolders * NewLC(); |
|
63 /** |
|
64 * Destructor |
|
65 */ |
|
66 ~CScanFolders(); |
|
67 |
|
68 public: |
|
69 /** |
|
70 * Function to add listener |
|
71 * @param aListener Reference to the folder listener object |
|
72 */ |
|
73 void AddListenerL( CUserEmulatorScriptsView* aListener ); |
|
74 /** |
|
75 * Function to remove listeners |
|
76 * @param aListener Reference to the folder listener object |
|
77 */ |
|
78 void RemoveListener( CUserEmulatorScriptsView * aListener ); |
|
79 |
|
80 public: |
|
81 /** |
|
82 * Function to set filters for folder scan |
|
83 * @param aFilter 16 bit filter descriptor |
|
84 */ |
|
85 void SetFilter( const TDesC & aFilter ); |
|
86 /** |
|
87 * Function to set filters for folder scan |
|
88 * @param aFilter 8 bit filter descriptor |
|
89 */ |
|
90 void SetFilter( const TDesC8 & aFilter ); |
|
91 |
|
92 /** |
|
93 * Scan the folder specified by the path asynchronously. Results will |
|
94 * be delivered through the listener interface. |
|
95 * @param aPath 8 bit path descriptor |
|
96 */ |
|
97 void ScanFolderL( const TDesC & aPath ); |
|
98 /** |
|
99 * Scan the folder specified by the path asynchronously. Results will |
|
100 * be delivered through the listener interface. |
|
101 * @param aPath 16 bit path descriptor |
|
102 */ |
|
103 void ScanFolderL( const TDesC8 & aPath ); |
|
104 |
|
105 protected: |
|
106 /** |
|
107 * Constructor |
|
108 */ |
|
109 CScanFolders(); |
|
110 /** |
|
111 * ConstructL |
|
112 */ |
|
113 void ConstructL(); |
|
114 |
|
115 protected: |
|
116 /** |
|
117 * Function to start folder scan |
|
118 */ |
|
119 void StartScanningL(); |
|
120 /** |
|
121 * Function to continue folder scan |
|
122 */ |
|
123 void ContinueScanning(); |
|
124 /** |
|
125 * Function to stop folder scan |
|
126 */ |
|
127 void StopScanning(); |
|
128 /** |
|
129 * Deliver Drives |
|
130 */ |
|
131 void DeliverDrivesL(); |
|
132 /** |
|
133 * Reset operation |
|
134 */ |
|
135 void Reset(); |
|
136 |
|
137 protected: |
|
138 /** |
|
139 * Function that notifies any error during folder scan |
|
140 * @param aReasonCode error code |
|
141 */ |
|
142 void FireError( TInt aReasonCode ); |
|
143 /** |
|
144 * Function that notifies on any new entry in the folder |
|
145 */ |
|
146 void FireEntriesL(); |
|
147 /** |
|
148 * Function that notifies any directory or file changes in the |
|
149 * folder |
|
150 * @param aEntry entry type |
|
151 */ |
|
152 void FireEntry( const TEntry & aEntry ); |
|
153 /** |
|
154 * Function that notifies on any folder changes |
|
155 * @param aFolder folder name |
|
156 */ |
|
157 void FireFolder( const TDesC & aFolder ); |
|
158 /** |
|
159 * Function that notifies on any file changes |
|
160 * @param aFile File name |
|
161 */ |
|
162 void FireFile( const TDesC & aFile ); |
|
163 /** |
|
164 * Function that notifies at the beginning of folder scan |
|
165 * @param aIsDriveListFlag |
|
166 */ |
|
167 void FireFolderStarting( TBool aIsDriveListFlag ); |
|
168 /** |
|
169 * Function that indicates folder scan complete |
|
170 */ |
|
171 void FireFolderCompleteL(); |
|
172 |
|
173 protected: |
|
174 /** |
|
175 * Helper function that checks for file types and notifies |
|
176 * on any file changes |
|
177 * @param aFilename file name |
|
178 */ |
|
179 TBool IsMatch( const TDesC & aFilename ); |
|
180 |
|
181 private: //From CActive |
|
182 void DoCancel(); |
|
183 void RunL(); |
|
184 |
|
185 private: |
|
186 /** |
|
187 * Enumeration with the folder scanner states |
|
188 */ |
|
189 enum TScanState |
|
190 { |
|
191 EIdle, |
|
192 EScanning, |
|
193 EStartNewScan, |
|
194 EAbortScan |
|
195 }; |
|
196 |
|
197 //Data Members |
|
198 TBool iAbortScan; |
|
199 TBool iStartNewScan; |
|
200 TBool iContinued; |
|
201 TBool iComplete; |
|
202 TScanState iScanState; |
|
203 TBuf<KBuffer256> iFileFilter; |
|
204 TParse iCurrentPath; |
|
205 RDir iCurrentDir; |
|
206 TEntryArray iEntries; |
|
207 CDesCArrayFlat * iDirectories; |
|
208 CDesCArrayFlat * iFileNames; |
|
209 RFs iFs; |
|
210 RArray< CUserEmulatorScriptsView * > iListeners; |
|
211 }; |
|
212 |
|
213 #endif |