1 /* |
|
2 * Copyright (c) 2006-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: Active object for an asynchronous thumbnail request |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef THUMBNAILREQUESTACTIVE_H |
|
20 #define THUMBNAILREQUESTACTIVE_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 #include "thumbnailpanic.h" |
|
25 #include "thumbnailmanager.h" |
|
26 #include "thumbnailmanagerconstants.h" |
|
27 #include "thumbnaillog.h" |
|
28 |
|
29 class RFs; |
|
30 class CFbsBitmap; |
|
31 class RThumbnailSession; |
|
32 class CThumbnailDataImpl; |
|
33 class CThumbnailRequestQueue; |
|
34 |
|
35 enum TThumbnailReqType |
|
36 { |
|
37 EReqGetThumbnailHandle = 0, |
|
38 EReqGetThumbnailPath = 1, |
|
39 EReqSetThumbnailBuffer = 2, |
|
40 EReqSetThumbnailBitmap = 3, |
|
41 EReqUpdateThumbnails = 4, |
|
42 EReqGetThumbnailHandleLater = 5, |
|
43 EReqDeleteThumbnails = 6, |
|
44 EReqRenameThumbnails = 7, |
|
45 EReqSetThumbnailPath = 8 |
|
46 }; |
|
47 |
|
48 /** |
|
49 * Active object for an asynchronous thumbnail request. |
|
50 * |
|
51 * @since S60 v5.0 |
|
52 */ |
|
53 NONSHARABLE_CLASS( CThumbnailRequestActive ): public CActive |
|
54 { |
|
55 public: |
|
56 |
|
57 /** |
|
58 * Destructor |
|
59 * |
|
60 * @since S60 v5.0 |
|
61 */ |
|
62 virtual ~CThumbnailRequestActive(); |
|
63 |
|
64 /** |
|
65 * Two-phased constructor |
|
66 * |
|
67 * @since S60 v5.0 |
|
68 * @param aFs Fileserver used. |
|
69 * @param aThumbnailSession Session used. |
|
70 * @param aObserver Observer to receive notifications about completed operations. |
|
71 * @param aRequestObserver Observer to receive notifications about completed requests. |
|
72 * @param aId Assigned ID of the request, session specific. |
|
73 * @param aPriority assigned processing priority |
|
74 * @param aQueue request processor |
|
75 * @return New CThumbnailRequestActive object. |
|
76 */ |
|
77 static CThumbnailRequestActive* NewL( RFs& aFs, RThumbnailSession& |
|
78 aThumbnailSession, MThumbnailManagerObserver& aObserver, |
|
79 MThumbnailManagerRequestObserver* aRequestObserver, TThumbnailRequestId aId, |
|
80 TInt aPriority, CThumbnailRequestQueue* aQueue ); |
|
81 |
|
82 /** |
|
83 * Get a thumbnail created from file object. |
|
84 * |
|
85 * @since S60 v5.0 |
|
86 * @param aFile File from which the thumbnail is to be created. |
|
87 * @param aFlags Flags that control the creation of thumbnail. |
|
88 * @param aQualityPreference Quality preference value |
|
89 * @param aSize Requested size of the thumbnail. |
|
90 * @param aDisplayMode Display mode. |
|
91 * @param aPriority Priority of the request. |
|
92 * @param aClientData Pointer to arbitrary client data. |
|
93 * This pointer is not used by the API for |
|
94 * anything other than returning it in the |
|
95 * ThumbnailReady callback. |
|
96 * @param aTargetUri Target URI to which the imported thumbnail is linked. |
|
97 */ |
|
98 void GetThumbnailL( const RFile64& aFile, TThumbnailId aThumbnailId, const TDesC8& aMimeType, |
|
99 CThumbnailManager::TThumbnailFlags aFlags, CThumbnailManager::TThumbnailQualityPreference |
|
100 aQualityPreference, const TSize& aSize, const TDisplayMode aDisplayMode, |
|
101 const TInt aPriority, TAny* aClientData, TBool aGeneratePersistentSizesOnly, const TDesC& aTargetUri = KNullDesC, |
|
102 TThumbnailSize aThumbnailSize = EUnknownThumbnailSize ); |
|
103 |
|
104 /** |
|
105 * Get a thumbnail opening file object later. |
|
106 * |
|
107 * @since S60 v5.0 |
|
108 * @param aPath Path to file from which the thumbnail is to be created. |
|
109 * @param aFlags Flags that control the creation of thumbnail. |
|
110 * @param aQualityPreference Quality preference value |
|
111 * @param aSize Requested size of the thumbnail. |
|
112 * @param aDisplayMode Display mode. |
|
113 * @param aPriority Priority of the request. |
|
114 * @param aClientData Pointer to arbitrary client data. |
|
115 * This pointer is not used by the API for |
|
116 * anything other than returning it in the |
|
117 * ThumbnailReady callback. |
|
118 * @param aTargetUri Target URI to which the imported thumbnail is linked. |
|
119 */ |
|
120 void GetThumbnailL( TThumbnailId aThumbnailId, const TDesC& aPath, const TDesC8& aMimeType, |
|
121 CThumbnailManager::TThumbnailFlags aFlags, CThumbnailManager::TThumbnailQualityPreference |
|
122 aQualityPreference, const TSize& aSize, const TDisplayMode aDisplayMode, |
|
123 const TInt aPriority, TAny* aClientData, TBool aGeneratePersistentSizesOnly, const TDesC& aTargetUri = KNullDesC, |
|
124 TThumbnailSize aThumbnailSize = EUnknownThumbnailSize ); |
|
125 |
|
126 /** |
|
127 * Get a thumbnail created from file path. |
|
128 * |
|
129 * @since S60 v5.0 |
|
130 * @param aPath Path to file from which the thumbnail is to be created. |
|
131 * @param aFlags Flags that control the creation of thumbnail. |
|
132 * @param aQualityPreference Quality preference value |
|
133 * @param aSize Requested size of the thumbnail. |
|
134 * @param aDisplayMode Display mode. |
|
135 * @param aPriority Priority of the request. |
|
136 * @param aClientData Pointer to arbitrary client data. |
|
137 * This pointer is not used by the API for |
|
138 * anything other than returning it in the |
|
139 * ThumbnailReady callback. |
|
140 * @param aGeneratePersistentSizesOnly |
|
141 * @param aTargetUri Target URI to which the imported thumbnail is linked. |
|
142 * @param aThumbnailSize Relative thumbnail size |
|
143 */ |
|
144 void GetThumbnailL( const TDesC& aPath, TThumbnailId aThumbnailId, |
|
145 const TDesC8& aMimeType, CThumbnailManager::TThumbnailFlags aFlags, |
|
146 CThumbnailManager::TThumbnailQualityPreference aQualityPreference, |
|
147 const TSize& aSize, const TDisplayMode aDisplayMode, const TInt aPriority, |
|
148 TAny* aClientData, TBool aGeneratePersistentSizesOnly, |
|
149 const TDesC& aTargetUri = KNullDesC, TThumbnailSize aThumbnailSize = EUnknownThumbnailSize ); |
|
150 |
|
151 /** |
|
152 * Set a thumbnail |
|
153 * |
|
154 * @since S60 v5.0 |
|
155 * @param aBuffer Buffer containing image where the thumbnail is to be created. |
|
156 * @param aFlags Flags that control the creation of thumbnail. |
|
157 * @param aQualityPreference Quality preference value |
|
158 * @param aSize Requested size of the thumbnail. |
|
159 * @param aDisplayMode Display mode. |
|
160 * @param aPriority Priority of the request. |
|
161 * @param aClientData Pointer to arbitrary client data. |
|
162 * This pointer is not used by the API for |
|
163 * anything other than returning it in the |
|
164 * ThumbnailReady callback. |
|
165 * @param aGeneratePersistentSizesOnly |
|
166 * @param aTargetUri Target URI to which the imported thumbnail is linked. |
|
167 * @param aThumbnailSize Requested thumbnail size |
|
168 * @param aOverwrite Overwrite old existing thumbs |
|
169 */ |
|
170 void SetThumbnailL( TDesC8* aBuffer, TThumbnailId aThumbnailId, const TDesC8& aMimeType, |
|
171 CThumbnailManager::TThumbnailFlags aFlags, CThumbnailManager |
|
172 ::TThumbnailQualityPreference aQualityPreference, const TSize& aSize, const |
|
173 TDisplayMode aDisplayMode, const TInt aPriority, TAny* aClientData, TBool aGeneratePersistentSizesOnly, |
|
174 const TDesC& aTargetUri, TThumbnailSize aThumbnailSize, TBool aOverwrite); |
|
175 |
|
176 /** |
|
177 * Set a thumbnail |
|
178 * |
|
179 * @since S60 v5.0 |
|
180 * @param aBitmap Bitmap |
|
181 * @param aFlags Flags that control the creation of thumbnail. |
|
182 * @param aQualityPreference Quality preference value |
|
183 * @param aSize Requested size of the thumbnail. |
|
184 * @param aDisplayMode Display mode. |
|
185 * @param aPriority Priority of the request. |
|
186 * @param aClientData Pointer to arbitrary client data. |
|
187 * This pointer is not used by the API for |
|
188 * anything other than returning it in the |
|
189 * ThumbnailReady callback. |
|
190 * @param aGeneratePersistentSizesOnly |
|
191 * @param aTargetUri Target URI to which the imported thumbnail is linked. |
|
192 * @param aThumbnailSize Requested thumbnail size |
|
193 * @param aOverwrite Overwrite old existing thumbs |
|
194 */ |
|
195 void SetThumbnailL( CFbsBitmap* aBitmap, TThumbnailId aThumbnailId, const TDesC8& aMimeType, |
|
196 CThumbnailManager::TThumbnailFlags aFlags, CThumbnailManager |
|
197 ::TThumbnailQualityPreference aQualityPreference, const TSize& aSize, const |
|
198 TDisplayMode aDisplayMode, const TInt aPriority, TAny* aClientData, TBool aGeneratePersistentSizesOnly, |
|
199 const TDesC& aTargetUri, TThumbnailSize aThumbnailSize, TBool aOverwrite); |
|
200 |
|
201 /** |
|
202 * Update thumbnails by Id. |
|
203 * |
|
204 * @since S60 v5.0 |
|
205 * @param aPath Path to file from which the thumbnail is to be created. |
|
206 * @param aFlags Flags that control the creation of thumbnail. |
|
207 * @param aQualityPreference Quality preference value |
|
208 * @param aSize Requested size of the thumbnail. |
|
209 * @param aDisplayMode Display mode. |
|
210 * @param aPriority Priority of the request. |
|
211 * @param aOrientation Thumbnail orientation |
|
212 * @param aModified Last modified |
|
213 */ |
|
214 void UpdateThumbnailsL( const TDesC& aPath, const TThumbnailId aThumbnailId, |
|
215 CThumbnailManager::TThumbnailFlags aFlags, |
|
216 CThumbnailManager::TThumbnailQualityPreference aQualityPreference, |
|
217 const TDisplayMode aDisplayMode, const TInt aPriority, const TInt aOrientation, |
|
218 const TInt64 aModified ); |
|
219 |
|
220 /** |
|
221 * Delete thumbnails. |
|
222 * |
|
223 * @since S60 v5.0 |
|
224 * @param aPath Path to file from which the thumbnail is to be created. |
|
225 * @param aPriority Priority of the request. |
|
226 */ |
|
227 void DeleteThumbnails( const TDesC& aPath, const TThumbnailId aThumbnailId, |
|
228 const TInt aPriority ); |
|
229 |
|
230 /** |
|
231 * Rename thumbnails. |
|
232 * |
|
233 * @since S60 v5.0 |
|
234 * @param aCurrentPath Current path of the Thumbnail |
|
235 * @param aNewPath New path for the Thumbnail |
|
236 * @param aPriority Priority for this operation |
|
237 */ |
|
238 void RenameThumbnails( const TDesC& aCurrentPath, const TDesC& aNewPath, |
|
239 const TInt aPriority ); |
|
240 |
|
241 /** |
|
242 * Set thumbnail from file path. |
|
243 * |
|
244 * @param aPath Path to file from which the thumbnail is to be created. |
|
245 * @param aFile File from which the thumbnail is to be created. |
|
246 * @param aFlags Flags that control the creation of thumbnail. |
|
247 * @param aQualityPreference Quality preference value |
|
248 * @param aSize Requested size of the thumbnail. |
|
249 * @param aDisplayMode Display mode. |
|
250 * @param aPriority Priority of the request. |
|
251 * @param aClientData Pointer to arbitrary client data. |
|
252 * This pointer is not used by the API for |
|
253 * anything other than returning it in the |
|
254 * ThumbnailReady callback. |
|
255 * @param aGeneratePersistentSizesOnly |
|
256 * @param aOverwrite Overwrite old existing thumbs |
|
257 * @param aTargetUri Target URI to which the imported thumbnail is linked. |
|
258 * @param aThumbnailSize Relative thumbnail size |
|
259 */ |
|
260 void SetThumbnailL( const TDesC& aPath, const TDesC8& aMimeType, |
|
261 CThumbnailManager::TThumbnailFlags aFlags, |
|
262 CThumbnailManager::TThumbnailQualityPreference aQualityPreference, |
|
263 const TSize& aSize, const TDisplayMode aDisplayMode, const TInt aPriority, |
|
264 TAny* aClientData, TBool aGeneratePersistentSizesOnly, const TDesC& aTargetUri, |
|
265 TThumbnailSize aThumbnailSize, TBool aOverwrite); |
|
266 |
|
267 /** |
|
268 * Start active request. |
|
269 * |
|
270 * @since S60 v5.0 |
|
271 */ |
|
272 void StartL(); |
|
273 |
|
274 /** |
|
275 * Change priority of a request. |
|
276 * |
|
277 * @since S60 v5.0 |
|
278 * @param aNewPriority New priority. |
|
279 * @return Error code. |
|
280 */ |
|
281 void ChangePriority( const TInt aNewPriority ); |
|
282 |
|
283 /** |
|
284 * Returns ID of thumbnail request. |
|
285 * |
|
286 * @since S60 v5.0 |
|
287 * @return Request ID |
|
288 */ |
|
289 TThumbnailRequestId RequestId()const; |
|
290 |
|
291 /** |
|
292 * Is thumbnail request completed |
|
293 * |
|
294 * @since S60 v5.0 |
|
295 */ |
|
296 TBool RequestCompleted()const; |
|
297 |
|
298 /** |
|
299 * Is thumbnail request active |
|
300 * |
|
301 * @since S60 v5.0 |
|
302 */ |
|
303 TBool IsRequestActive()const; |
|
304 |
|
305 /** |
|
306 * Error handling function. |
|
307 * |
|
308 * @since S60 v5.0 |
|
309 */ |
|
310 void StartError( const TInt aErr ); |
|
311 |
|
312 /** |
|
313 * Async cancel |
|
314 * |
|
315 * @since S60 v5.0 |
|
316 */ |
|
317 void AsyncCancel(); |
|
318 |
|
319 private: |
|
320 |
|
321 /** |
|
322 * C++ default constructor |
|
323 * |
|
324 * @since S60 v5.0 |
|
325 * @param aFs Fileserver used. |
|
326 * @param aThumbnailSession Session used. |
|
327 * @param aObserver Observer to receive notifications about completed operations. |
|
328 * @param aRequestObserver Observer to receive notifications about completed requests. |
|
329 * @param aId Assigned ID of the request, session specific. |
|
330 * @param aPriority assigned processing priority |
|
331 * @param aQueue request processor |
|
332 * @return New CThumbnailRequestActive object. |
|
333 */ |
|
334 CThumbnailRequestActive( RFs& aFs, RThumbnailSession& aThumbnailSession, |
|
335 MThumbnailManagerObserver& aObserver, MThumbnailManagerRequestObserver* aRequestObserver, |
|
336 TThumbnailRequestId aId, TInt aPriority, CThumbnailRequestQueue* aQueue); |
|
337 |
|
338 /** |
|
339 * Symbian 2nd phase constructor can leave. |
|
340 * |
|
341 * @since S60 v5.0 |
|
342 */ |
|
343 void ConstructL(); |
|
344 |
|
345 /** |
|
346 * Handles an active object's request completion event. |
|
347 * |
|
348 * @since S60 v5.0 |
|
349 */ |
|
350 void RunL(); |
|
351 |
|
352 /** |
|
353 * Handles a leave occurring in the request completion event handler |
|
354 * RunL(). |
|
355 * |
|
356 * @since S60 v5.0 |
|
357 * @param aError The leave code. |
|
358 * @return Error code. |
|
359 */ |
|
360 TInt RunError( TInt aError ); |
|
361 |
|
362 /** |
|
363 * Implements cancellation of an outstanding request. |
|
364 * |
|
365 * @since S60 v5.0 |
|
366 */ |
|
367 void DoCancel(); |
|
368 |
|
369 /** |
|
370 * Release bitmap instance kept by server process. |
|
371 * |
|
372 * @since S60 v5.0 |
|
373 */ |
|
374 void ReleaseServerBitmap(); |
|
375 |
|
376 /** |
|
377 * Error handling function. |
|
378 * |
|
379 * @since S60 v5.0 |
|
380 */ |
|
381 void HandleError(); |
|
382 |
|
383 /** |
|
384 * Request 2nd phase thumbnail |
|
385 * |
|
386 * @since S60 v5.0 |
|
387 */ |
|
388 void Get2ndPhaseThumbnailL(); |
|
389 |
|
390 /** |
|
391 * Callback for timeout timer |
|
392 * |
|
393 * @since S60 v5.0 |
|
394 */ |
|
395 static TInt TimerCallBack(TAny* aAny); |
|
396 |
|
397 /** |
|
398 * Checks if URI is virtual. |
|
399 */ |
|
400 TBool IsVirtualUri( const TDesC& aPath ); |
|
401 |
|
402 private: |
|
403 // data |
|
404 |
|
405 /** |
|
406 * Session. |
|
407 */ |
|
408 RThumbnailSession& iSession; |
|
409 |
|
410 /** |
|
411 * Request parameters. |
|
412 */ |
|
413 TThumbnailRequestParams iParams; |
|
414 |
|
415 /** |
|
416 * Package for request parameters. |
|
417 */ |
|
418 TThumbnailRequestParamsPckg iParamsPckg; |
|
419 |
|
420 /** |
|
421 * Observer to receive notifications about completed operations. |
|
422 */ |
|
423 MThumbnailManagerObserver& iObserver; |
|
424 |
|
425 /** |
|
426 * Observer to receive notifications about completed requests. |
|
427 */ |
|
428 MThumbnailManagerRequestObserver* iRequestObserver; |
|
429 |
|
430 /** |
|
431 * Fileserver, not own |
|
432 */ |
|
433 RFs& iFs; |
|
434 |
|
435 /** |
|
436 * Client data. |
|
437 */ |
|
438 TAny* iClientData; |
|
439 |
|
440 /** |
|
441 * Callback, own. |
|
442 */ |
|
443 CThumbnailDataImpl* iCallbackThumbnail; |
|
444 |
|
445 /** |
|
446 * Handle to bitmap, own. |
|
447 */ |
|
448 TInt iBitmapHandle; |
|
449 |
|
450 /** |
|
451 * Error code. |
|
452 */ |
|
453 TInt iError; |
|
454 |
|
455 /** |
|
456 * Request id of thumbnail request, session specific. |
|
457 */ |
|
458 TThumbnailRequestId iRequestId; |
|
459 |
|
460 /** |
|
461 * Duplicated file handle for two phase operation |
|
462 */ |
|
463 RFile64 iMyFileHandle; |
|
464 |
|
465 /** |
|
466 * If set, we are currently processing the preview thumbnail |
|
467 * of a two phase operation. If an error occurs, we can skip |
|
468 * directly to 2nd phase. |
|
469 */ |
|
470 TBool iProcessingPreview; |
|
471 |
|
472 /** |
|
473 * If set, this request object can be deleted. |
|
474 */ |
|
475 TBool iRequestCompleted; |
|
476 |
|
477 /** |
|
478 * If set, this request object is under processing |
|
479 */ |
|
480 TBool iRequestActive; |
|
481 |
|
482 /** |
|
483 * Bitmap that is passed to server |
|
484 */ |
|
485 CFbsBitmap* iBitmap; |
|
486 |
|
487 // for activating requests |
|
488 RFile64 iFile; |
|
489 TFileName iPath; |
|
490 TFileName iTargetUri; |
|
491 TInt iOrientation; |
|
492 TInt64 iModified; |
|
493 |
|
494 // not own |
|
495 CThumbnailRequestQueue* iRequestQueue; |
|
496 |
|
497 TThumbnailReqType iRequestType; |
|
498 |
|
499 // request timeout timer |
|
500 CPeriodic* iTimer; |
|
501 TInt iStartError; |
|
502 |
|
503 // request already canceled by client |
|
504 TBool iCanceled; |
|
505 |
|
506 #ifdef __RETRY_ON_SERVERCRASH |
|
507 //request retry count |
|
508 TUint iRetry; |
|
509 #endif |
|
510 |
|
511 #ifdef _DEBUG |
|
512 TTime iStartExecTime; |
|
513 #endif |
|
514 }; |
|
515 |
|
516 #endif // THUMBNAILREQUESTACTIVE_H |
|
517 |
|
518 |
|
519 |
|
520 // INLINE FUNCTIONS |
|
521 |
|
522 inline TBool CThumbnailRequestActive::RequestCompleted()const |
|
523 { |
|
524 return iRequestCompleted; |
|
525 } |
|
526 |
|
527 inline TBool CThumbnailRequestActive::IsRequestActive()const |
|
528 { |
|
529 if(IsActive()) |
|
530 { |
|
531 return ETrue; |
|
532 } |
|
533 return iRequestActive; |
|
534 } |
|
535 |
|
536 inline TThumbnailRequestId CThumbnailRequestActive::RequestId()const |
|
537 { |
|
538 __ASSERT_DEBUG(( iRequestId > 0 ), ThumbnailPanic( EThumbnailWrongId )); |
|
539 |
|
540 return iRequestId; |
|
541 } |
|