|
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 "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: Incremental OpenL() utility |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_CMPXCOLLECTIONOPENUTILITY_H |
|
20 #define C_CMPXCOLLECTIONOPENUTILITY_H |
|
21 |
|
22 #include <mpxcollectionobserver.h> |
|
23 #include <mpxcollectionframeworkdefs.h> |
|
24 #include <mpxcollectionopenlresultdef.h> |
|
25 |
|
26 // FORWARD DECLARTIONS |
|
27 class MMPXCollectionUtility; |
|
28 class CMPXCollectionPath; |
|
29 |
|
30 /** |
|
31 * CMPXCollectionOpenUtility |
|
32 * |
|
33 * Incremental OpenL() utility to open data in chunks |
|
34 * |
|
35 * @lib mpxcollectionutility.lib |
|
36 */ |
|
37 class CMPXCollectionOpenUtility : public CBase, |
|
38 public MMPXCollectionObserver |
|
39 { |
|
40 public: |
|
41 |
|
42 /** |
|
43 * Two phased constructor. |
|
44 * |
|
45 * @since S60 5.0 |
|
46 * @param aObs observer |
|
47 * @param aMode mode of the utility |
|
48 */ |
|
49 IMPORT_C static CMPXCollectionOpenUtility* NewL( MMPXCollectionObserver* aObs, TUid aMode = KMcModeDefault ); |
|
50 |
|
51 /** |
|
52 * virtual destructor. |
|
53 * |
|
54 * @since S60 5.0 |
|
55 */ |
|
56 virtual ~CMPXCollectionOpenUtility(); |
|
57 |
|
58 public: // Enumerations |
|
59 /** |
|
60 * Direction of the fetch |
|
61 */ |
|
62 enum TDirection |
|
63 { |
|
64 EFetchNormal, |
|
65 EFetchUp, |
|
66 EFetchDown |
|
67 }; |
|
68 |
|
69 public: // Public functions |
|
70 |
|
71 /** |
|
72 * Start the incremental read operation. |
|
73 * |
|
74 * @since S60 5.0 |
|
75 * @param aAttrs array of attributes |
|
76 * @param aChunkSize size of each chunk to fetch |
|
77 * @param aOffset offset to start fetching from |
|
78 * @param aDirection fetching direction, normal, up or down |
|
79 * @param aKeyAttribute key attribute to speed up open operation |
|
80 */ |
|
81 IMPORT_C void StartL( TArray<TMPXAttribute> aAttrs, |
|
82 TInt aChunkSize, |
|
83 TInt aOffset = 0, |
|
84 TDirection aDirection = EFetchNormal, |
|
85 TMPXAttribute aKeyAttribute = KMPXMediaNullAttribute ); |
|
86 |
|
87 /** |
|
88 * Start the incremental read operation. |
|
89 * |
|
90 * @since S60 5.0 |
|
91 * @param aPath path to have to open to |
|
92 * @param aAttrs array of attributes |
|
93 * @param aChunkSize size of each chunk to fetch |
|
94 * @param aOffset offset to start fetching from |
|
95 * @param aDirection fetching direction, normal, up or down |
|
96 * @param aKeyAttribute key attribute to speed up open operation |
|
97 */ |
|
98 IMPORT_C void StartL( const CMPXCollectionPath& aPath, |
|
99 TArray<TMPXAttribute> aAttrs, |
|
100 TInt aChunkSize, |
|
101 TInt aOffset = 0, |
|
102 TDirection aDirection = EFetchNormal, |
|
103 TMPXAttribute aKeyAttribute = KMPXMediaNullAttribute ); |
|
104 |
|
105 /** |
|
106 * Cancel the incremental reading procedure. |
|
107 * |
|
108 * @since S60 5.0 |
|
109 */ |
|
110 IMPORT_C void Stop(); |
|
111 |
|
112 /** |
|
113 * Set the fetching direction. |
|
114 * |
|
115 * @since S60 5.0 |
|
116 * @param aDirection a direction to start fetching from |
|
117 */ |
|
118 IMPORT_C void SetDirection( TDirection aDirection ); |
|
119 |
|
120 /** |
|
121 * Set the fetching delay in between subsequent fetches. |
|
122 * |
|
123 * @since S60 5.0 |
|
124 * @param aDelay delay in microseconds, default is 0 |
|
125 */ |
|
126 IMPORT_C void SetDelay( TInt aDelay ); |
|
127 |
|
128 /** |
|
129 * Returns a copy of the collection path. |
|
130 * |
|
131 * @since S60 5.0 |
|
132 * @return CMPXCollectionpath* ownership transferred |
|
133 */ |
|
134 IMPORT_C CMPXCollectionPath* PathL(); |
|
135 |
|
136 protected: // From Base Class |
|
137 |
|
138 /** |
|
139 * From MMPXCollectionObserver |
|
140 * |
|
141 * @since S60 5.0 |
|
142 */ |
|
143 void HandleCollectionMessage(CMPXMessage* aMsg, TInt aErr); |
|
144 |
|
145 /** |
|
146 * From MMPXCollectionObserver |
|
147 * |
|
148 * @since S60 5.0 |
|
149 */ |
|
150 void HandleOpenL(const CMPXMedia& aEntries, |
|
151 TInt aIndex,TBool aComplete,TInt aError); |
|
152 |
|
153 /** |
|
154 * From MMPXCollectionObserver |
|
155 * |
|
156 * @since S60 5.0 |
|
157 */ |
|
158 void HandleOpenL(const CMPXCollectionPlaylist& aPlaylist,TInt aError); |
|
159 |
|
160 /** |
|
161 * From MMPXCollectionObserver |
|
162 * |
|
163 * @since S60 5.0 |
|
164 */ |
|
165 void HandleCommandComplete(CMPXCommand* aCommandResult, |
|
166 TInt aError); |
|
167 |
|
168 /** |
|
169 * From MMPXCollectionObserver |
|
170 * |
|
171 * @since S60 5.0 |
|
172 */ |
|
173 void HandleCollectionMediaL(const CMPXMedia& aMedia, |
|
174 TInt aError); |
|
175 |
|
176 private: |
|
177 /** |
|
178 * Handle collection messages. |
|
179 * |
|
180 * @since S60 5.0 |
|
181 * @param aMsg CMPXMessage to handle |
|
182 */ |
|
183 void DoHandleCollectionMessageL( const CMPXMessage& aMsg ); |
|
184 |
|
185 /** |
|
186 * Handle command complete. |
|
187 * |
|
188 * @since S60 5.0 |
|
189 * @param aCommand result of the command |
|
190 * @param aError any errors |
|
191 */ |
|
192 void DoHandleCommandCompleteL(CMPXCommand& aCommandResult, |
|
193 TInt aError); |
|
194 /** |
|
195 * Fetch Count step. |
|
196 * |
|
197 * @since S60 5.0 |
|
198 */ |
|
199 void DoFetchCountL(); |
|
200 |
|
201 /** |
|
202 * Handle completion of count step. |
|
203 * |
|
204 * @since S60 5.0 |
|
205 * @param aMedia media returned from the collection |
|
206 * @param aIndex item focus from the collection |
|
207 * @param aError error of the operation |
|
208 */ |
|
209 void DoHandleCountL(const CMPXMedia& aMedia, |
|
210 TInt aIndex, |
|
211 TInt aError); |
|
212 |
|
213 /** |
|
214 * Fetch items step. |
|
215 * |
|
216 * @since S60 5.0 |
|
217 */ |
|
218 void DoFetchItemsL(); |
|
219 |
|
220 /** |
|
221 * Handle completion of fetch item step. |
|
222 * |
|
223 * @since S60 5.0 |
|
224 * @param aMedia media returned from the collection |
|
225 * @param aIndex item focus from the collection |
|
226 * @param aError error of the operation |
|
227 * @leave IfNull |
|
228 */ |
|
229 void DoHandleFetchItemsL( const CMPXMedia& aMedia, |
|
230 TInt aIndex, |
|
231 TInt aError); |
|
232 |
|
233 /** |
|
234 * Run the next step. |
|
235 * |
|
236 * @since S60 5.0 |
|
237 */ |
|
238 void RunNext(); |
|
239 |
|
240 /** |
|
241 * Callback function for the periodic timer. |
|
242 * |
|
243 * @since S60 5.0 |
|
244 */ |
|
245 static TInt Callback( TAny* aAny ); |
|
246 |
|
247 /** |
|
248 * Handle callback from the timer. |
|
249 * |
|
250 * @since S60 5.0 |
|
251 */ |
|
252 void HandleCallbackL(); |
|
253 |
|
254 /** |
|
255 * Setup the chunks. |
|
256 * |
|
257 * @since S60 5.0 |
|
258 * @param aCount total number of items |
|
259 */ |
|
260 void DoSetupChunksL( TInt aCount ); |
|
261 |
|
262 /** |
|
263 * Sort ascending. |
|
264 * |
|
265 * @since S60 5.0 |
|
266 * @param aSkipFirst do not order the first item |
|
267 */ |
|
268 void DoSortAscend( TBool aSkipFirst = EFalse ); |
|
269 |
|
270 /** |
|
271 * Sort decending do not order the first item. |
|
272 * |
|
273 * @since S60 5.0 |
|
274 * @param aSkipFirst do not order the first item |
|
275 */ |
|
276 void DoSortDescend( TBool aSkipFirst = EFalse ); |
|
277 |
|
278 /** |
|
279 * Sort normal. |
|
280 * |
|
281 * @since S60 5.0 |
|
282 * @param aSkipFirst do not order the first item |
|
283 */ |
|
284 void DoSortNormalL( TBool aSkipFirst = EFalse ); |
|
285 |
|
286 /** |
|
287 * Compact the task list given partial results may have been fetched. |
|
288 * |
|
289 * @since S60 5.0 |
|
290 * @param aMedia media containing the fetched sections |
|
291 */ |
|
292 void DoCompactTaskListL( const CMPXMedia& aMedia ); |
|
293 |
|
294 /** |
|
295 * Send a command to the collection to update selection index. |
|
296 * |
|
297 * @since S60 5.0 |
|
298 */ |
|
299 void DoSelectIndexL(); |
|
300 |
|
301 private: |
|
302 |
|
303 /** |
|
304 * Constructor. |
|
305 * |
|
306 * @since S60 5.0 |
|
307 * @param aObs observer |
|
308 * @param aMode mode of the utility |
|
309 */ |
|
310 CMPXCollectionOpenUtility( MMPXCollectionObserver* aObs, TUid aMode ); |
|
311 |
|
312 /** |
|
313 * 2nd phase constructor. |
|
314 * |
|
315 * @since S60 5.0 |
|
316 */ |
|
317 void ConstructL(); |
|
318 |
|
319 private: |
|
320 |
|
321 /** |
|
322 * Enum fo rthe different states of this object |
|
323 */ |
|
324 enum TFetchingStep |
|
325 { |
|
326 EFetchPath, |
|
327 EFetchCount, |
|
328 EFetchItems, |
|
329 EFetchCommand, |
|
330 EFetchNone |
|
331 }; |
|
332 |
|
333 private: // data |
|
334 CPeriodic* iTimer; |
|
335 MMPXCollectionUtility* iCollection; |
|
336 |
|
337 TDirection iFetchDirection; |
|
338 TMPXOpenDataBlock iFetchInfo; |
|
339 TMPXAttribute iKeyAttribute; |
|
340 TInt iFetchDelay; |
|
341 |
|
342 TFetchingStep iFetchStep; |
|
343 MMPXCollectionObserver* iObs; |
|
344 RArray<TMPXOpenDataBlock> iIncrementalChunks; |
|
345 |
|
346 CMPXMedia* iMedia; // handle to the current data retrieved from handleopen |
|
347 CMPXMediaArray* iData; // not owned, media array inside of iMedia |
|
348 CMPXCollectionPath* iPath; // Current working path |
|
349 |
|
350 TUid iMode; |
|
351 TBool iFirstOpen; |
|
352 TBool iSelecting; |
|
353 }; |
|
354 |
|
355 #endif // C_CMPXCOLLECTIONOPENUTILITY_H |