1 /* |
|
2 * Copyright (c) 2007-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: Implements CAcpProvider methods |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <fbs.h> |
|
20 #include <gulicon.h> |
|
21 |
|
22 #include "acpprovider.h" |
|
23 #include "accountcreationpluginlogger.h" |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // CAcpProvider::CAcpProvider |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 CAcpProvider::CAcpProvider() |
|
30 { |
|
31 } |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CAcpProvider::NewL |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 CAcpProvider* CAcpProvider::NewL() |
|
38 { |
|
39 CAcpProvider* self = CAcpProvider::NewLC(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // CAcpProvider::NewLC |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 CAcpProvider* CAcpProvider::NewLC() |
|
49 { |
|
50 CAcpProvider* self = new ( ELeave ) CAcpProvider(); |
|
51 CleanupStack::PushL( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // CAcpProvider::~CAcpProvider |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 CAcpProvider::~CAcpProvider() |
|
60 { |
|
61 ACPLOG( "CAcpProvider::~CAcpProvider begin" ); |
|
62 |
|
63 delete iProviderName; |
|
64 delete iIconUrl; |
|
65 delete iSisUrl; |
|
66 delete iCreationUrl; |
|
67 delete iActivationUrl; |
|
68 delete iBitmap; |
|
69 delete iMask; |
|
70 delete iProviderDescription; |
|
71 delete iProviderType; |
|
72 delete iMimeType; |
|
73 |
|
74 ACPLOG( "CAcpProvider::~CAcpProvider end" ); |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CAcpProvider::CopyL |
|
79 // Copies provider data from given parameter to member data. |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 void CAcpProvider::CopyL( const CAcpProvider& aProvider ) |
|
83 { |
|
84 ACPLOG( "CAcpProvider::CopyL begin" ); |
|
85 |
|
86 SetProviderNameL( aProvider.ProviderName() ); |
|
87 SetIconUrlL( aProvider.IconUrl() ); |
|
88 SetPriority( aProvider.Priority() ); |
|
89 SetSisUrlL( aProvider.SisUrl() ); |
|
90 SetCreationUrlL( aProvider.CreationUrl() ); |
|
91 SetActivationUrlL( aProvider.ActivationUrl() ); |
|
92 SetProviderTypeL( aProvider.ProviderType() ); |
|
93 SetProviderDescriptionL( aProvider.ProviderDescription() ); |
|
94 |
|
95 ACPLOG( "CAcpProvider::CopyL end" ); |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CAcpProvider::ProviderName |
|
100 // Returns name of the provider. |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 TPtrC CAcpProvider::ProviderName() const |
|
104 { |
|
105 if ( !iProviderName ) |
|
106 { |
|
107 return KNullDesC(); |
|
108 } |
|
109 return *iProviderName; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // CAcpProvider::SetProviderNameL |
|
114 // Sets name of the provider. |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 void CAcpProvider::SetProviderNameL( const TDesC& aProviderName ) |
|
118 { |
|
119 ACPLOG2( "CAcpProvider::SetProviderNameL: %S", &aProviderName ); |
|
120 |
|
121 // Check whether the provider name defined or not. |
|
122 if ( !aProviderName.Length() ) |
|
123 { |
|
124 return; |
|
125 } |
|
126 |
|
127 if ( !iProviderName ) |
|
128 { |
|
129 iProviderName = HBufC::NewL( aProviderName.Length() ); |
|
130 } |
|
131 else |
|
132 { |
|
133 iProviderName = iProviderName->ReAllocL( |
|
134 iProviderName->Length() + aProviderName.Length() ); |
|
135 } |
|
136 iProviderName->Des().Append( aProviderName ); |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // CAcpProvider::IconUrl |
|
141 // Returns the location of icons. |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 TPtrC8 CAcpProvider::IconUrl() const |
|
145 { |
|
146 if ( !iIconUrl ) |
|
147 { |
|
148 return KNullDesC8(); |
|
149 } |
|
150 |
|
151 return *iIconUrl; |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // CAcpProvider::SetIconUrlL |
|
156 // Sets the location of icons. |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 void CAcpProvider::SetIconUrlL( const TDesC8& aIconUrl ) |
|
160 { |
|
161 ACPLOG2( "CAcpProvider::SetIconUrlL: %S", &aIconUrl ); |
|
162 |
|
163 // Check whether the icon address is defined or not. |
|
164 if ( !aIconUrl.Length() ) |
|
165 { |
|
166 return; |
|
167 } |
|
168 |
|
169 if ( !iIconUrl ) |
|
170 { |
|
171 iIconUrl = HBufC8::NewL( aIconUrl.Length() ); |
|
172 } |
|
173 else |
|
174 { |
|
175 iIconUrl = iIconUrl->ReAllocL( |
|
176 iIconUrl->Length() + aIconUrl.Length() ); |
|
177 } |
|
178 |
|
179 iIconUrl->Des().Append( aIconUrl ); |
|
180 } |
|
181 |
|
182 // --------------------------------------------------------------------------- |
|
183 // CAcpProvider::Priority |
|
184 // Returns priority of the provider. |
|
185 // --------------------------------------------------------------------------- |
|
186 // |
|
187 TInt CAcpProvider::Priority() const |
|
188 { |
|
189 return iPriority; |
|
190 } |
|
191 |
|
192 // --------------------------------------------------------------------------- |
|
193 // CAcpProvider::SetPriority |
|
194 // Sets priority of the provider. |
|
195 // --------------------------------------------------------------------------- |
|
196 // |
|
197 void CAcpProvider::SetPriority( TInt aPriority ) |
|
198 { |
|
199 ACPLOG2( "CAcpProvider::SetPriority: %d", aPriority ); |
|
200 iPriority = aPriority; |
|
201 } |
|
202 |
|
203 // --------------------------------------------------------------------------- |
|
204 // CAcpProvider::SisUrl |
|
205 // Returns the location of SIS file. |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 TPtrC8 CAcpProvider::SisUrl() const |
|
209 { |
|
210 if ( iSisUrl ) |
|
211 { |
|
212 return *iSisUrl; |
|
213 } |
|
214 |
|
215 return KNullDesC8(); |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // CAcpProvider::SetSisUrlL |
|
220 // Sets the location of SIS file. |
|
221 // --------------------------------------------------------------------------- |
|
222 // |
|
223 void CAcpProvider::SetSisUrlL( const TDesC8& aSisUrl ) |
|
224 { |
|
225 ACPLOG2( "CAcpProvider::SetSisUrlL: %S", &aSisUrl ); |
|
226 |
|
227 // Check whether the SIS address defined or not. |
|
228 if ( !aSisUrl.Length() ) |
|
229 { |
|
230 return; |
|
231 } |
|
232 |
|
233 if ( !iSisUrl ) |
|
234 { |
|
235 iSisUrl = HBufC8::NewL( aSisUrl.Length() ); |
|
236 } |
|
237 else |
|
238 { |
|
239 iSisUrl = iSisUrl->ReAllocL( iSisUrl->Length() + aSisUrl.Length() ); |
|
240 } |
|
241 iSisUrl->Des().Append( aSisUrl ); |
|
242 |
|
243 ACPLOG( "CAcpProvider::SetSisUrlL: end" ); |
|
244 } |
|
245 |
|
246 // --------------------------------------------------------------------------- |
|
247 // CAcpProvider::CreationUrl |
|
248 // Returns the location of creation URL. |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 TPtrC8 CAcpProvider::CreationUrl() const |
|
252 { |
|
253 if ( iCreationUrl ) |
|
254 { |
|
255 return *iCreationUrl; |
|
256 } |
|
257 return KNullDesC8(); |
|
258 } |
|
259 |
|
260 // --------------------------------------------------------------------------- |
|
261 // CAcpProvider::SetCreationUrlL |
|
262 // Sets the location of creation URL. |
|
263 // --------------------------------------------------------------------------- |
|
264 // |
|
265 void CAcpProvider::SetCreationUrlL( const TDesC8& aCreationUrl ) |
|
266 { |
|
267 ACPLOG( "CAcpProvider::SetCreationUrlL: begin "); |
|
268 |
|
269 // Check whether the creation address defined or not |
|
270 if ( !aCreationUrl.Length() ) |
|
271 { |
|
272 return; |
|
273 } |
|
274 |
|
275 if ( !iCreationUrl ) |
|
276 { |
|
277 iCreationUrl = HBufC8::NewL( aCreationUrl.Length() ); |
|
278 } |
|
279 else |
|
280 { |
|
281 iCreationUrl = iCreationUrl->ReAllocL( |
|
282 iCreationUrl->Length() + aCreationUrl.Length() ); |
|
283 } |
|
284 iCreationUrl->Des().Append( aCreationUrl ); |
|
285 |
|
286 ACPLOG( "CAcpProvider::SetCreationUrlL end") |
|
287 } |
|
288 |
|
289 // --------------------------------------------------------------------------- |
|
290 // CAcpProvider::ActivationUrl |
|
291 // Returns the location of activation URL. |
|
292 // --------------------------------------------------------------------------- |
|
293 // |
|
294 TPtrC8 CAcpProvider::ActivationUrl() const |
|
295 { |
|
296 if ( iActivationUrl ) |
|
297 { |
|
298 return *iActivationUrl; |
|
299 } |
|
300 |
|
301 return KNullDesC8(); |
|
302 } |
|
303 |
|
304 // --------------------------------------------------------------------------- |
|
305 // CAcpProvider::SetActivationUrlL |
|
306 // Sets the location of activation URL. |
|
307 // --------------------------------------------------------------------------- |
|
308 // |
|
309 void CAcpProvider::SetActivationUrlL( const TDesC8& aActivationUrl ) |
|
310 { |
|
311 ACPLOG2( "CAcpProvider::SetActivationUrlL: %S", &aActivationUrl ); |
|
312 |
|
313 // Check whether the activation address defined or not. |
|
314 if ( !aActivationUrl.Length() ) |
|
315 { |
|
316 return; |
|
317 } |
|
318 |
|
319 if ( !iActivationUrl ) |
|
320 { |
|
321 iActivationUrl = HBufC8::NewL( aActivationUrl.Length() ); |
|
322 } |
|
323 else |
|
324 { |
|
325 iActivationUrl = iActivationUrl->ReAllocL( |
|
326 iActivationUrl->Length() + aActivationUrl.Length() ); |
|
327 } |
|
328 |
|
329 iActivationUrl->Des().Append( aActivationUrl ); |
|
330 } |
|
331 |
|
332 // --------------------------------------------------------------------------- |
|
333 // CAcpProvider::ContentData |
|
334 // Returns the mime type of image file. |
|
335 // --------------------------------------------------------------------------- |
|
336 // |
|
337 TPtrC8 CAcpProvider::ContentData() const |
|
338 { |
|
339 if ( iMimeType ) |
|
340 { |
|
341 return *iMimeType; |
|
342 } |
|
343 return KNullDesC8(); |
|
344 } |
|
345 |
|
346 // --------------------------------------------------------------------------- |
|
347 // CAcpProvider::SetContentDataL |
|
348 // Sets the content type of image file. |
|
349 // --------------------------------------------------------------------------- |
|
350 // |
|
351 void CAcpProvider::SetContentDataL( const TDesC8& aContentData ) |
|
352 { |
|
353 ACPLOG2( "CAcpProvider::SetContentDataL: %S", &aContentData ); |
|
354 |
|
355 // Check whether content data defined or not. |
|
356 if ( !aContentData.Length() ) |
|
357 { |
|
358 return; |
|
359 } |
|
360 |
|
361 if ( !iMimeType ) |
|
362 { |
|
363 iMimeType = HBufC8::NewL( aContentData.Length() ); |
|
364 } |
|
365 else |
|
366 { |
|
367 iMimeType = iMimeType->ReAllocL( |
|
368 iMimeType->Length() + aContentData.Length() ); |
|
369 } |
|
370 iMimeType->Des().Append( aContentData ); |
|
371 } |
|
372 |
|
373 // --------------------------------------------------------------------------- |
|
374 // CAcpProvider::ProviderType |
|
375 // Returns the provider type |
|
376 // --------------------------------------------------------------------------- |
|
377 // |
|
378 TPtrC CAcpProvider::ProviderType() const |
|
379 { |
|
380 if ( iProviderType ) |
|
381 { |
|
382 return *iProviderType; |
|
383 } |
|
384 return KNullDesC(); |
|
385 } |
|
386 |
|
387 // --------------------------------------------------------------------------- |
|
388 // CAcpProvider::SetProviderTypeL |
|
389 // Sets the provider type |
|
390 // --------------------------------------------------------------------------- |
|
391 // |
|
392 void CAcpProvider::SetProviderTypeL( const TDesC& aProviderType ) |
|
393 { |
|
394 ACPLOG2( "CAcpProvider::SetProviderTypeL: %S", &aProviderType ); |
|
395 |
|
396 // Check whether provider type defined or not. |
|
397 if ( !aProviderType.Length() ) |
|
398 { |
|
399 return; |
|
400 } |
|
401 |
|
402 if ( !iProviderType ) |
|
403 { |
|
404 iProviderType = HBufC::NewL( aProviderType.Length() ); |
|
405 } |
|
406 else |
|
407 { |
|
408 iProviderType = iProviderType->ReAllocL( |
|
409 iProviderType->Length() + aProviderType.Length() ); |
|
410 } |
|
411 iProviderType->Des().Append( aProviderType ); |
|
412 } |
|
413 |
|
414 // --------------------------------------------------------------------------- |
|
415 // CAcpProvider::ProviderDescription |
|
416 // Returns the provider description |
|
417 // --------------------------------------------------------------------------- |
|
418 // |
|
419 TPtrC CAcpProvider::ProviderDescription() const |
|
420 { |
|
421 if ( iProviderDescription ) |
|
422 { |
|
423 return *iProviderDescription; |
|
424 } |
|
425 return KNullDesC(); |
|
426 } |
|
427 |
|
428 // --------------------------------------------------------------------------- |
|
429 // CAcpProvider::SetProviderDescriptionL |
|
430 // Sets the provider description |
|
431 // --------------------------------------------------------------------------- |
|
432 // |
|
433 void CAcpProvider::SetProviderDescriptionL( const TDesC& aProviderDescription ) |
|
434 { |
|
435 ACPLOG2( "CAcpProvider::SetProviderDescriptionL: %S", &aProviderDescription ); |
|
436 |
|
437 // Check whether the provider description defined or not. |
|
438 if ( !aProviderDescription.Length() ) |
|
439 { |
|
440 return; |
|
441 } |
|
442 |
|
443 if ( !iProviderDescription ) |
|
444 { |
|
445 iProviderDescription = HBufC::NewL( aProviderDescription.Length() ); |
|
446 } |
|
447 else |
|
448 { |
|
449 iProviderDescription = iProviderDescription->ReAllocL( |
|
450 iProviderDescription->Length() + aProviderDescription.Length() ); |
|
451 } |
|
452 |
|
453 iProviderDescription->Des().Append( aProviderDescription ); |
|
454 } |
|
455 |
|
456 // --------------------------------------------------------------------------- |
|
457 // CAcpProvider::SetBitmapL |
|
458 // Copies a bitmap. |
|
459 // --------------------------------------------------------------------------- |
|
460 // |
|
461 void CAcpProvider::SetBitmapL( CFbsBitmap* aBitmap, CFbsBitmap* aMask ) |
|
462 { |
|
463 ACPLOG( "CAcpProvider::SetBitmapL begin" ); |
|
464 |
|
465 if ( !aBitmap ) // Mask is not needed. |
|
466 { |
|
467 User::Leave( KErrArgument ); |
|
468 } |
|
469 |
|
470 const TSize bitmapSize = aBitmap->SizeInPixels(); |
|
471 if ( bitmapSize.iHeight > 0 && bitmapSize.iWidth > 0 ) |
|
472 { |
|
473 ACPLOG3( " - bitmap size %d x %d pixels", bitmapSize.iWidth, |
|
474 bitmapSize.iHeight ); |
|
475 |
|
476 delete iBitmap; |
|
477 iBitmap = NULL; |
|
478 delete iMask; |
|
479 iMask = NULL; |
|
480 |
|
481 ACPLOG( " - deleted bitmaps" ); |
|
482 |
|
483 // Create new bitmap. |
|
484 iBitmap = new (ELeave) CFbsBitmap(); |
|
485 iBitmap->Create( bitmapSize, aBitmap->DisplayMode() ); |
|
486 ACPLOG( " - created new bitmap" ); |
|
487 |
|
488 // Calculate data length. |
|
489 TInt stride = CFbsBitmap::ScanLineLength( bitmapSize.iWidth, |
|
490 aBitmap->DisplayMode() ); |
|
491 TInt length = stride * bitmapSize.iHeight; |
|
492 ACPLOG2( " - actual data length: %d", length ); |
|
493 |
|
494 aBitmap->LockHeap(); |
|
495 Mem::Copy( iBitmap->DataAddress(), aBitmap->DataAddress(), length ); |
|
496 aBitmap->UnlockHeap(); |
|
497 |
|
498 // Create mask if needed. |
|
499 if ( aMask ) |
|
500 { |
|
501 iMask = new (ELeave) CFbsBitmap(); |
|
502 iMask->Create( aMask->SizeInPixels(), aMask->DisplayMode() ); |
|
503 ACPLOG( " - created new mask" ); |
|
504 |
|
505 // Calculate data length. |
|
506 TSize maskSize = aMask->SizeInPixels(); |
|
507 TInt stride = CFbsBitmap::ScanLineLength( maskSize.iWidth, |
|
508 aMask->DisplayMode() ); |
|
509 TInt length = stride * maskSize.iHeight; |
|
510 ACPLOG2( " - actual mask data length: %d", length ); |
|
511 |
|
512 aMask->LockHeap(); |
|
513 Mem::Copy( iMask->DataAddress(), aMask->DataAddress(), length ); |
|
514 aMask->UnlockHeap(); |
|
515 } |
|
516 } |
|
517 |
|
518 ACPLOG( "CAcpProvider::SetBitmapL end" ); |
|
519 } |
|
520 |
|
521 // --------------------------------------------------------------------------- |
|
522 // CAcpProvider::BitMap |
|
523 // Reference to bitmap and mask. |
|
524 // --------------------------------------------------------------------------- |
|
525 // |
|
526 void CAcpProvider::GetBitmaps( CFbsBitmap*& aBitmap, CFbsBitmap*& aMask ) |
|
527 { |
|
528 aBitmap = iBitmap; |
|
529 aMask = iMask; |
|
530 } |
|
531 |
|
532 // End of file. |
|