|
1 /* |
|
2 * Copyright (c) 2008-2009 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: Thumbnail save task implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 * @internal reviewed 30/07/2007 by Simon Brooks |
|
23 */ |
|
24 |
|
25 #ifndef GLXTNSAVETHUMBNAILTASK_H |
|
26 #define GLXTNSAVETHUMBNAILTASK_H |
|
27 |
|
28 // INCLUDES |
|
29 |
|
30 #include "glxtntask.h" |
|
31 |
|
32 // CONSTANTS |
|
33 |
|
34 // MACROS |
|
35 |
|
36 // DATA TYPES |
|
37 |
|
38 // FUNCTION PROTOTYPES |
|
39 |
|
40 // FORWARD DECLARATIONS |
|
41 |
|
42 class CFbsBitmap; |
|
43 class CImageEncoder; |
|
44 class CGlxtnFileInfo; |
|
45 |
|
46 // CLASS DECLARATION |
|
47 |
|
48 /** |
|
49 * Task to save a generated thumbnail in persistent storage. |
|
50 * |
|
51 * @author Dan Rhodes |
|
52 * @ingroup glx_thumbnail_creator |
|
53 */ |
|
54 NONSHARABLE_CLASS(CGlxtnSaveThumbnailTask) : public CGlxtnTask |
|
55 { |
|
56 public: // Constructors and destructor |
|
57 |
|
58 /** |
|
59 * Two-phased constructor. |
|
60 * @param iItemId Media ID of item whose thumbnail is to be saved. |
|
61 * @param aFileInfo Information about the media file. |
|
62 * @param aSize Requested thumbnail size. |
|
63 * @param aThumbnail Thumbnail bitmap to save. |
|
64 * @param aStorage Client's storage interface. |
|
65 */ |
|
66 static CGlxtnSaveThumbnailTask* NewL( |
|
67 const TGlxMediaId& aItemId, |
|
68 CGlxtnFileInfo* aFileInfo, const TSize& aSize, |
|
69 CFbsBitmap* aThumbnail, MGlxtnThumbnailStorage* aStorage); |
|
70 |
|
71 /** |
|
72 * Destructor. |
|
73 */ |
|
74 virtual ~CGlxtnSaveThumbnailTask(); |
|
75 |
|
76 protected: // From CGlxtnTask |
|
77 TBool DoStartL(TRequestStatus& aStatus); |
|
78 void DoCancel(); |
|
79 TBool DoRunL(TRequestStatus& aStatus); |
|
80 TBool DoRunError(TInt aError); |
|
81 |
|
82 protected: |
|
83 /** |
|
84 * Constructor for derived classes. |
|
85 * @param aId Task type ID. |
|
86 * @param iItemId Media ID of item whose thumbnail is to be saved. |
|
87 * @param aStorage Client's storage interface. |
|
88 */ |
|
89 CGlxtnSaveThumbnailTask(const TGlxtnTaskId& aId, |
|
90 const TGlxMediaId& aItemId, MGlxtnThumbnailStorage* aStorage); |
|
91 |
|
92 /** |
|
93 * Encode the bitmap to a data buffer. |
|
94 * @param aStatus Request status for the asynchronous operation. |
|
95 */ |
|
96 void EncodeThumbnailL(TRequestStatus& aStatus); |
|
97 /** |
|
98 * Save buffer to storage. |
|
99 * @param aStatus Request status for the asynchronous operation. |
|
100 */ |
|
101 void SaveThumbnailL(TRequestStatus& aStatus); |
|
102 |
|
103 private: |
|
104 /** |
|
105 * Constructor. |
|
106 * @param iItemId Media ID of item whose thumbnail is to be saved. |
|
107 * @param aSize Requested thumbnail size. |
|
108 * @param aStorage Client's storage interface. |
|
109 */ |
|
110 CGlxtnSaveThumbnailTask(const TGlxMediaId& aItemId, const TSize& aSize, |
|
111 MGlxtnThumbnailStorage* aStorage); |
|
112 |
|
113 /** |
|
114 * By default Symbian 2nd phase constructor is private. |
|
115 * @param aFileInfo Information about the media file. |
|
116 * @param aThumbnail Thumbnail bitmap to save. |
|
117 */ |
|
118 void ConstructL(CGlxtnFileInfo* aFileInfo, CFbsBitmap* aThumbnail); |
|
119 |
|
120 protected: // Data |
|
121 /** |
|
122 * States for the task's state machine. |
|
123 */ |
|
124 enum TSaveState |
|
125 { |
|
126 EStateEncoding, EStateSaving, EStateFetchingUri, |
|
127 EStateDecoding, EStateChecking, EStateScaling, EStateFiltering |
|
128 }; |
|
129 |
|
130 /** Requested thumbnail size */ |
|
131 TSize iSize; |
|
132 /** Information about the item's media file */ |
|
133 CGlxtnFileInfo* iFileInfo; |
|
134 /** Thumbnail bitmap to save (owned) */ |
|
135 CFbsBitmap* iThumbnail; |
|
136 /** Current task state */ |
|
137 TSaveState iState; |
|
138 |
|
139 private: // Data |
|
140 /** Format in which the bitmap was encoded */ |
|
141 TGlxImageDataFormat iFormat; |
|
142 /** Encoder for the bitmap (owned) */ |
|
143 CImageEncoder* iEncoder; |
|
144 /** Buffer for encoded data (owned) */ |
|
145 HBufC8* iData; |
|
146 }; |
|
147 |
|
148 #endif // GLXTNSAVETHUMBNAILTASK_H |
|
149 |
|
150 // End of File |