|
1 /* |
|
2 * Copyright (c) 2006-2008 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: account creation plugin params source file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <bitmaptransforms.h> |
|
20 #include <fbs.h> |
|
21 #include <gulicon.h> |
|
22 |
|
23 #include "acpimagehandler.h" |
|
24 #include "accountcreationpluginlogger.h" |
|
25 #include "macpimagehandlerobserver.h" |
|
26 #include "accountcreationengineconstants.h" |
|
27 |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // CAcpImageHandler::NewL |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 CAcpImageHandler* CAcpImageHandler::NewL( MImageHandlerObserver& aController ) |
|
34 { |
|
35 ACPLOG( "CAcpImageHandler::NewL begin" ); |
|
36 CAcpImageHandler* self = new(ELeave) CAcpImageHandler( aController ); |
|
37 CleanupStack::PushL( self ); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop(self); |
|
40 ACPLOG( "CAcpImageHandler::NewL end" ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // CAcpImageHandler::CAcpImageHandler |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 CAcpImageHandler::CAcpImageHandler( MImageHandlerObserver& aController ) |
|
49 : CActive( EPriorityStandard ), |
|
50 iController( aController ) |
|
51 { |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // CAcpImageHandler::ConstructL() |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 void CAcpImageHandler::ConstructL() |
|
59 { |
|
60 ACPLOG( "CAcpImageHandler::ConstructL begin" ); |
|
61 |
|
62 // Create file server connection. |
|
63 User::LeaveIfError( iFs.Connect() ); |
|
64 |
|
65 // Create a new active object scheduler for this objects. |
|
66 CActiveScheduler::Add( this ); |
|
67 |
|
68 ACPLOG( "CAcpImageHandler::ConstructL end" ); |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // CAcpImageHandler::~CAcpImageHandler() |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 CAcpImageHandler::~CAcpImageHandler() |
|
76 { |
|
77 ACPLOG( "CAcpImageHandler::~CAcpImageHandler begin" ); |
|
78 |
|
79 Cancel(); |
|
80 iFs.Close(); |
|
81 |
|
82 delete iImageDecoder; |
|
83 delete iBitmap; |
|
84 delete iMask; |
|
85 |
|
86 ACPLOG( "CAcpImageHandler::~CAcpImageHandler end" ); |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CAcpImageHandler::DoCancel |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 void CAcpImageHandler::DoCancel() |
|
94 { |
|
95 ACPLOG( "CAcpImageHandler::DoCancel begin" ); |
|
96 |
|
97 if ( iImageDecoder ) |
|
98 { |
|
99 iImageDecoder->Cancel(); |
|
100 } |
|
101 |
|
102 ACPLOG( "CAcpImageHandler::DoCancel end" ); |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // CAcpImageHandler::RunL |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 void CAcpImageHandler::RunL() |
|
110 { |
|
111 ACPLOG( "CAcpImageHandler::RunL begin" ); |
|
112 |
|
113 if ( iStatus == KErrUnderflow ) |
|
114 { |
|
115 // Converting continues.. |
|
116 iImageDecoder->ContinueConvert( &iStatus ); |
|
117 |
|
118 // Requests of the active object outstanding. |
|
119 SetActive(); |
|
120 } |
|
121 else |
|
122 { |
|
123 iState = EIdle; // Bitmap done and decoder state is idle. |
|
124 // Send a client notify about that. |
|
125 iController.NotifyImageCompletion( iStatus.Int() ); |
|
126 |
|
127 // Now it's safe to delete image decoder and close file system handle. |
|
128 Cancel(); |
|
129 delete iImageDecoder; |
|
130 iImageDecoder = NULL; |
|
131 |
|
132 iFs.Close(); |
|
133 } |
|
134 |
|
135 ACPLOG( "CAcpImageHandler::RunL end" ); |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // CAcpImageHandler::StartToDecodeL |
|
140 // Decodes a received image to the bitmap |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void CAcpImageHandler::StartToDecodeL( const TDesC8& aSourceData, |
|
144 const TDesC8& aContentType ) |
|
145 { |
|
146 ACPLOG( "CAcpImageHandler::StartToDecodeL begin"); |
|
147 |
|
148 ACPLOG2( " - Data length: %d", aSourceData.Length() ); |
|
149 |
|
150 if ( aSourceData.Length() > KErrNone ) |
|
151 { |
|
152 // Encoding the image |
|
153 iState = EDecoding; |
|
154 |
|
155 // Delete decoder |
|
156 delete iImageDecoder; |
|
157 iImageDecoder = NULL; |
|
158 |
|
159 // Create new image decoder. |
|
160 iImageDecoder = CImageDecoder::DataNewL( iFs, aSourceData, |
|
161 aContentType, CImageDecoder::EAllowGeneratedMask ); |
|
162 |
|
163 // Recreate bitmap. |
|
164 delete iBitmap; |
|
165 iBitmap = NULL; |
|
166 iBitmap = new (ELeave) CFbsBitmap(); |
|
167 |
|
168 // Delete old mask. |
|
169 delete iMask; |
|
170 iMask = NULL; |
|
171 |
|
172 // Check if a mask is present. |
|
173 if ( iImageDecoder->FrameInfo().iFlags & |
|
174 TFrameInfo::ETransparencyPossible ) |
|
175 { |
|
176 iMask = new (ELeave) CFbsBitmap(); |
|
177 } |
|
178 |
|
179 TSize frameinfo = iImageDecoder->FrameInfo().iOverallSizeInPixels; |
|
180 TDisplayMode frameDisplayMode = |
|
181 iImageDecoder->FrameInfo().iFrameDisplayMode; |
|
182 |
|
183 ACPLOG2( " - Converted data length: %d bytes", |
|
184 iImageDecoder->FrameInfo().iBitsPerPixel * |
|
185 frameinfo.iWidth * frameinfo.iHeight / KBitsPerByte ); |
|
186 |
|
187 // Creates a bitmap and mask with the image sizes and display mode. |
|
188 iBitmap->Create( frameinfo, frameDisplayMode ); |
|
189 |
|
190 if ( iMask ) |
|
191 { |
|
192 iMask->Create( frameinfo, EGray256 ); |
|
193 ACPLOG( " - created mask with 8-bit transparency" ); |
|
194 |
|
195 iImageDecoder->Convert( &iStatus, *iBitmap, *iMask ); |
|
196 } |
|
197 else |
|
198 { |
|
199 iImageDecoder->Convert( &iStatus, *iBitmap ); |
|
200 } |
|
201 |
|
202 // The active object has requested. |
|
203 SetActive(); |
|
204 } |
|
205 |
|
206 ACPLOG( "CAcpImageHandler::StartToDecodeL end" ); |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // CAcpImageHandler::GetBitmap |
|
211 // Reference to already converted bitmap |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 CFbsBitmap* CAcpImageHandler::GetBitmap() |
|
215 { |
|
216 return iBitmap; // Bitmap already converted from given image file. |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------------------------- |
|
220 // CAcpImageHandler::GetMask |
|
221 // Reference to already converted mask |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 CFbsBitmap* CAcpImageHandler::GetMask() |
|
225 { |
|
226 return iMask; |
|
227 } |
|
228 |
|
229 // End of file. |