33 #include <MVPbkContactFieldData.h> |
33 #include <MVPbkContactFieldData.h> |
34 #include <VPbkEng.rsg> |
34 #include <VPbkEng.rsg> |
35 #include <CVPbkTopContactManager.h> |
35 #include <CVPbkTopContactManager.h> |
36 #include <Pbk2InternalUID.h> |
36 #include <Pbk2InternalUID.h> |
37 #include <mpbk2commanditemupdater.h> |
37 #include <mpbk2commanditemupdater.h> |
|
38 #include <StringLoader.h> |
|
39 #include <Pbk2ExNamesListRes.rsg> |
38 |
40 |
39 //ECE |
41 //ECE |
40 #include <gulicon.h> |
42 #include <gulicon.h> |
41 #include <fbs.h> |
43 #include <fbs.h> |
42 #include <AknUtils.h> |
44 #include <AknUtils.h> |
84 ( CVPbkContactManager& aContactManager, |
86 ( CVPbkContactManager& aContactManager, |
85 CSpbContentProvider& aContentProvider, |
87 CSpbContentProvider& aContentProvider, |
86 CPbk2MyCard* aMyCard ) : |
88 CPbk2MyCard* aMyCard ) : |
87 iContactManager( aContactManager ), |
89 iContactManager( aContactManager ), |
88 iContentProvider( aContentProvider ), |
90 iContentProvider( aContentProvider ), |
89 iMyCard( aMyCard ), |
91 iMyCard( aMyCard ) |
90 iIconId( TPbk2IconId() ) |
|
91 { |
92 { |
92 } |
93 } |
93 |
94 |
94 // ----------------------------------------------------------------------------- |
95 // ----------------------------------------------------------------------------- |
95 // CPbk2NameslistUiControlExtension::ConstructL |
96 // CPbk2NameslistUiControlExtension::ConstructL |
101 if( iMyCard ) |
102 if( iMyCard ) |
102 { |
103 { |
103 // set this to be observer of the my card |
104 // set this to be observer of the my card |
104 iMyCard->SetObserverL( *this ); |
105 iMyCard->SetObserverL( *this ); |
105 // check if the mycard has already a thumbnail |
106 // check if the mycard has already a thumbnail |
106 iBitmap = iMyCard->MyCardBitmap(); |
107 iBitmap = iMyCard->MyCardBitmapL(); |
107 } |
108 } |
108 |
109 |
109 iPresenceEngine = CPbk2EcePresenceEngine::NewL( |
110 iPresenceEngine = CPbk2EcePresenceEngine::NewL( |
110 iContactManager, |
111 iContactManager, |
111 *this, |
112 *this, |
143 // if my card is provided |
144 // if my card is provided |
144 if( iMyCard ) |
145 if( iMyCard ) |
145 { |
146 { |
146 iMyCard->RemoveObserver( *this ); |
147 iMyCard->RemoveObserver( *this ); |
147 } |
148 } |
|
149 delete iBitmap; |
148 } |
150 } |
149 |
151 |
150 // ----------------------------------------------------------------------------- |
152 // ----------------------------------------------------------------------------- |
151 // CPbk2NameslistUiControlExtension::DoRelease |
153 // CPbk2NameslistUiControlExtension::DoRelease |
152 // ----------------------------------------------------------------------------- |
154 // ----------------------------------------------------------------------------- |
245 { |
247 { |
246 iIconArray = &aIconArray; |
248 iIconArray = &aIconArray; |
247 // if bitmap is allready set. MyCardEvent - event has come before this one or there was an image on creation |
249 // if bitmap is allready set. MyCardEvent - event has come before this one or there was an image on creation |
248 if( iBitmap && iMyCard ) |
250 if( iBitmap && iMyCard ) |
249 { |
251 { |
250 AddThumbnailToIconArrayL(); |
252 TRAP_IGNORE( AddMyCardThumbnailToIconArrayL() ); |
251 } |
253 } |
252 } |
254 } |
253 |
255 |
254 // ----------------------------------------------------------------------------- |
256 // ----------------------------------------------------------------------------- |
255 // CPbk2NameslistUiControlExtension::ContactPresenceChanged |
257 // CPbk2NameslistUiControlExtension::ContactPresenceChanged |
284 MPbk2DoubleListboxDataElement::TTextDataType elemType = |
286 MPbk2DoubleListboxDataElement::TTextDataType elemType = |
285 MPbk2DoubleListboxDataElement::ETypeGenericText; |
287 MPbk2DoubleListboxDataElement::ETypeGenericText; |
286 if( type == CSpbContentProvider::ETypePhoneNumber ) |
288 if( type == CSpbContentProvider::ETypePhoneNumber ) |
287 { |
289 { |
288 elemType = MPbk2DoubleListboxDataElement::ETypePhoneNumber; |
290 elemType = MPbk2DoubleListboxDataElement::ETypePhoneNumber; |
|
291 } |
|
292 else if( type == CSpbContentProvider::ETypePhoneNumberMultiple && txt ) |
|
293 { |
|
294 // if we get multiple phone numbers from content provider, then |
|
295 // the string only contains the count (as text). We need to format |
|
296 // that into proper UI text. |
|
297 TInt num = 0; |
|
298 TLex16 lex( *txt ); |
|
299 TInt err = lex.Val( num ); |
|
300 if( !err ) |
|
301 { |
|
302 delete txt; |
|
303 txt = StringLoader::LoadL( R_QTN_PHOB_N_NUMBERS, num ); |
|
304 } |
|
305 else |
|
306 { |
|
307 // in case of convert error |
|
308 txt->Des().Zero(); |
|
309 } |
289 } |
310 } |
290 |
311 |
291 aDataElement.SetText( |
312 aDataElement.SetText( |
292 MPbk2DoubleListboxDataElement::EStatusText, txt, elemType ); |
313 MPbk2DoubleListboxDataElement::EStatusText, txt, elemType ); |
293 |
314 |
341 { |
362 { |
342 // thumbnail is loaded |
363 // thumbnail is loaded |
343 if( aEvent == EStateThumbnailLoaded && iMyCard ) |
364 if( aEvent == EStateThumbnailLoaded && iMyCard ) |
344 { |
365 { |
345 // get bitmap |
366 // get bitmap |
346 iBitmap = iMyCard->MyCardBitmap(); |
367 delete iBitmap; |
|
368 iBitmap = NULL; |
|
369 TRAP_IGNORE( iBitmap = iMyCard->MyCardBitmapL() ); |
347 |
370 |
348 // if icon array is already set, add icon |
371 // if icon array is already set, add icon |
349 if( iIconArray ) |
372 if( iIconArray ) |
350 { |
373 { |
351 AddThumbnailToIconArrayL(); |
374 TRAP_IGNORE( AddMyCardThumbnailToIconArrayL() ); |
352 } |
375 } |
353 } |
376 } |
354 } |
377 } |
355 |
378 |
356 // ----------------------------------------------------------------------------- |
379 // ----------------------------------------------------------------------------- |
357 // CPbk2NameslistUiControlExtension::AddThumbnailToIconArrayL |
380 // CPbk2NameslistUiControlExtension::AddThumbnailToIconArrayL |
358 // ----------------------------------------------------------------------------- |
381 // ----------------------------------------------------------------------------- |
359 // |
382 // |
360 void CPbk2NameslistUiControlExtension::AddThumbnailToIconArrayL( ) |
383 void CPbk2NameslistUiControlExtension::AddMyCardThumbnailToIconArrayL( ) |
361 { |
384 { |
362 if( iMyCard ) |
385 if( !iMyCard ) |
363 { |
386 { |
364 iIconId = iMyCard->MyCardIconId(); |
387 return; |
365 } |
388 } |
366 |
389 |
|
390 const TPbk2IconId& iconId = iMyCard->MyCardIconId(); |
367 // if thumb icon is not created, create it and append to array |
391 // if thumb icon is not created, create it and append to array |
368 if( !iThumbIcon ) |
392 if( !iThumbIcon ) |
369 { |
393 { |
370 iThumbIcon = CGulIcon::NewLC(); |
394 CGulIcon* icon = CGulIcon::NewLC(); |
371 CleanupStack::Pop( iThumbIcon ); |
395 icon->SetBitmap( iBitmap ); |
372 iThumbIcon->SetBitmap( iBitmap ); |
|
373 iBitmap = NULL; |
396 iBitmap = NULL; |
374 // takes ownership |
397 // takes ownership |
375 iIconArray->AppendIconL( iThumbIcon, iIconId ); |
398 iIconArray->AppendIconL( icon, iconId ); |
|
399 CleanupStack::Pop( icon ); |
|
400 iThumbIcon = icon; // cache icon pointer |
376 } |
401 } |
377 |
402 |
378 // else change the bitmap. This is to prevent |
403 // else change the bitmap. This is to prevent |
379 // thumbnail indexes on thumbnail manager to get out of sync |
404 // thumbnail indexes on thumbnail manager to get out of sync |
380 else |
405 else |
381 { |
406 { |
382 iThumbIcon->SetBitmap( iBitmap ); |
407 iThumbIcon->SetBitmap( iBitmap ); |
383 iBitmap = NULL; |
408 iBitmap = NULL; |
384 } |
409 } |
385 } |
410 } |
386 |
411 |
387 |
412 |
388 // End of File |
413 // End of File |