author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:15:33 +0300 | |
branch | RCL_3 |
changeset 85 | 38bb213f60ba |
parent 68 | 9da50d567e3c |
permissions | -rw-r--r-- |
63 | 1 |
/* |
2 |
* Copyright (c) 2002-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: Phonebook 2 Nameslist UI control composite UI extension. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include "CPbk2NameslistUiControlExtension.h" |
|
20 |
||
21 |
#include <CPbk2IconArray.h> |
|
22 |
#include <TPbk2IconId.h> |
|
23 |
#include <Pbk2IconId.hrh> |
|
24 |
#include <Pbk2Commands.hrh> |
|
25 |
#include <Pbk2UID.h> |
|
26 |
#include <MPbk2ContactUiControlUpdate.h> |
|
27 |
#include <MVPbkViewContact.h> |
|
28 |
#include <MVPbkContactLink.h> |
|
29 |
#include <CVPbkContactManager.h> |
|
30 |
#include <MVPbkBaseContactFieldCollection.h> |
|
31 |
#include <MVPbkBaseContactField.h> |
|
32 |
#include <MVPbkFieldType.h> |
|
33 |
#include <MVPbkContactFieldData.h> |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
34 |
#include <VPbkEng.rsg> |
63 | 35 |
#include <CVPbkTopContactManager.h> |
36 |
#include <Pbk2InternalUID.h> |
|
37 |
#include <mpbk2commanditemupdater.h> |
|
38 |
#include <StringLoader.h> |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
39 |
#include <Pbk2ExNamesListRes.rsg> |
63 | 40 |
|
41 |
//ECE |
|
42 |
#include <gulicon.h> |
|
43 |
#include <fbs.h> |
|
44 |
#include <AknUtils.h> |
|
45 |
#include <aknlayoutscalable_avkon.cdl.h> |
|
46 |
#include <aknlayoutscalable_apps.cdl.h> |
|
47 |
||
48 |
#include "CPbk2UIExtensionInformation.h" |
|
49 |
#include <CPbk2UIExtensionPlugin.h> |
|
50 |
#include <Pbk2UIExtension.hrh> |
|
51 |
#include <TPbk2IconId.h> |
|
52 |
#include "Pbk2NamesListExUID.h" |
|
53 |
#include "CPbk2EcePresenceEngine.h" |
|
54 |
||
55 |
enum TNlxPanicCodes |
|
56 |
{ |
|
57 |
ENlxPanicEmptyPackage, |
|
58 |
ENlxPanicIconNull, |
|
59 |
ENlxPanicNoLinks, |
|
60 |
ENlxPanicStrayIcon, |
|
61 |
ENlxPanicStrayIconInfo |
|
62 |
}; |
|
63 |
||
64 |
/// Unnamed namespace for local definitions |
|
65 |
namespace { |
|
66 |
||
67 |
TSize CalculateListIconSize() |
|
68 |
{ |
|
69 |
TRect mainPane; |
|
70 |
AknLayoutUtils::LayoutMetricsRect( |
|
71 |
AknLayoutUtils::EMainPane, mainPane ); |
|
72 |
TAknLayoutRect listLayoutRect; |
|
73 |
listLayoutRect.LayoutRect( |
|
74 |
mainPane, |
|
75 |
AknLayoutScalable_Apps::list_double_large_graphic_phob2_pane_g2( 0 ).LayoutLine() ); |
|
76 |
return listLayoutRect.Rect().Size(); |
|
77 |
} |
|
78 |
} |
|
79 |
||
80 |
||
81 |
// ----------------------------------------------------------------------------- |
|
82 |
// CPbk2NameslistUiControlExtension::CPbk2NameslistUiControlExtension |
|
83 |
// ----------------------------------------------------------------------------- |
|
84 |
// |
|
85 |
CPbk2NameslistUiControlExtension::CPbk2NameslistUiControlExtension |
|
86 |
( CVPbkContactManager& aContactManager, |
|
87 |
CSpbContentProvider& aContentProvider, |
|
88 |
CPbk2MyCard* aMyCard ) : |
|
89 |
iContactManager( aContactManager ), |
|
90 |
iContentProvider( aContentProvider ), |
|
91 |
iMyCard( aMyCard ) |
|
92 |
{ |
|
93 |
} |
|
94 |
||
95 |
// ----------------------------------------------------------------------------- |
|
96 |
// CPbk2NameslistUiControlExtension::ConstructL |
|
97 |
// ----------------------------------------------------------------------------- |
|
98 |
// |
|
99 |
void CPbk2NameslistUiControlExtension::ConstructL() |
|
100 |
{ |
|
101 |
// if my card is provided |
|
102 |
if( iMyCard ) |
|
103 |
{ |
|
104 |
// set this to be observer of the my card |
|
105 |
iMyCard->SetObserverL( *this ); |
|
106 |
// check if the mycard has already a thumbnail |
|
107 |
iBitmap = iMyCard->MyCardBitmapL(); |
|
108 |
} |
|
109 |
||
110 |
iPresenceEngine = CPbk2EcePresenceEngine::NewL( |
|
111 |
iContactManager, |
|
112 |
*this, |
|
113 |
CalculateListIconSize() ); |
|
114 |
iContentProvider.AddObserverL( *this ); |
|
115 |
} |
|
116 |
||
117 |
// ----------------------------------------------------------------------------- |
|
118 |
// CPbk2NameslistUiControlExtension::NewL |
|
119 |
// ----------------------------------------------------------------------------- |
|
120 |
// |
|
121 |
CPbk2NameslistUiControlExtension* CPbk2NameslistUiControlExtension::NewL |
|
122 |
( CVPbkContactManager& aContactManager, |
|
123 |
CSpbContentProvider& aContentProvider, |
|
124 |
CPbk2MyCard* aMyCard ) |
|
125 |
{ |
|
126 |
CPbk2NameslistUiControlExtension* self = |
|
127 |
new ( ELeave ) CPbk2NameslistUiControlExtension |
|
128 |
( aContactManager, aContentProvider, aMyCard ); |
|
129 |
CleanupStack::PushL( self ); |
|
130 |
self->ConstructL(); |
|
131 |
CleanupStack::Pop( self ); |
|
132 |
return self; |
|
133 |
} |
|
134 |
||
135 |
// ----------------------------------------------------------------------------- |
|
136 |
// CPbk2NameslistUiControlExtension::~CPbk2NameslistUiControlExtension |
|
137 |
// ----------------------------------------------------------------------------- |
|
138 |
// |
|
139 |
CPbk2NameslistUiControlExtension::~CPbk2NameslistUiControlExtension() |
|
140 |
{ |
|
141 |
delete iPresenceEngine; |
|
142 |
iDummyArray.Close(); |
|
143 |
iContentProvider.RemoveObserver( *this ); |
|
144 |
// if my card is provided |
|
145 |
if( iMyCard ) |
|
146 |
{ |
|
147 |
iMyCard->RemoveObserver( *this ); |
|
148 |
} |
|
149 |
delete iBitmap; |
|
150 |
} |
|
151 |
||
152 |
// ----------------------------------------------------------------------------- |
|
153 |
// CPbk2NameslistUiControlExtension::DoRelease |
|
154 |
// ----------------------------------------------------------------------------- |
|
155 |
// |
|
156 |
void CPbk2NameslistUiControlExtension::DoRelease() |
|
157 |
{ |
|
158 |
delete this; |
|
159 |
} |
|
160 |
||
161 |
// ----------------------------------------------------------------------------- |
|
162 |
// CPbk2NameslistUiControlExtension::GetDynamicIconsL |
|
163 |
// ----------------------------------------------------------------------------- |
|
164 |
// |
|
165 |
const TArray<TPbk2IconId> CPbk2NameslistUiControlExtension::GetDynamicIconsL |
|
166 |
( const MVPbkViewContact* aContactHandle ) |
|
167 |
{ |
|
168 |
//Add here the values of TPbk2IconId that are preferred to be shown |
|
169 |
//in the list. Icons must already be present in the icon array. |
|
170 |
iDummyArray.Reset(); |
|
171 |
||
172 |
if ( aContactHandle ) |
|
173 |
{ |
|
174 |
// first check presence icon, highest priority |
|
175 |
MVPbkContactLink* link = aContactHandle->CreateLinkLC(); |
|
176 |
if ( link ) |
|
177 |
{ |
|
178 |
// Requests presence notifications, if hasn't already done so. |
|
179 |
iPresenceEngine->SubscribeContactPresenceL( *link ); |
|
180 |
||
181 |
TPbk2IconId iconId; |
|
182 |
TBool found = iPresenceEngine->GetIconIdForContact( *link, iconId ); |
|
183 |
if ( found ) |
|
184 |
{ |
|
185 |
// The icon has already been fetched from the presence server etc. |
|
186 |
if ( iIconArray->FindIcon( iconId ) == KErrNotFound ) |
|
187 |
{ |
|
188 |
// The icon is not yet in the array. Add it. |
|
189 |
CGulIcon* gulIcon = iPresenceEngine->CreateIconCopyLC( iconId ); |
|
190 |
iIconArray->AppendIconL( gulIcon, iconId ); |
|
191 |
CleanupStack::Pop( gulIcon ); |
|
192 |
} |
|
193 |
iDummyArray.AppendL( iconId ); |
|
194 |
} |
|
195 |
CleanupStack::PopAndDestroy(); // link |
|
196 |
} |
|
197 |
||
198 |
//Top contact indicator |
|
199 |
if ( CVPbkTopContactManager::IsTopContact( *aContactHandle ) ) |
|
200 |
{ |
|
201 |
iDummyArray.AppendL( TPbk2IconId( |
|
202 |
TUid::Uid(KPbk2UID3), EPbk2qgn_prop_pb_topc )); |
|
203 |
} |
|
204 |
} |
|
205 |
||
206 |
//Presence indicator |
|
207 |
return iDummyArray.Array(); |
|
208 |
} |
|
209 |
||
210 |
// ----------------------------------------------------------------------------- |
|
211 |
// CPbk2NameslistUiControlExtension::SetContactUiControlUpdate |
|
212 |
// ----------------------------------------------------------------------------- |
|
213 |
// |
|
214 |
void CPbk2NameslistUiControlExtension::SetContactUiControlUpdate |
|
215 |
( MPbk2ContactUiControlUpdate* aContactUpdator ) |
|
216 |
{ |
|
217 |
//Register observer interface (MPbk2ContactUiControlUpdate) of aContactUpdator |
|
218 |
//In case changes in data, call UpdateContact(const MVPbkContactLink& aContactLink ) |
|
219 |
iContactUpdator = aContactUpdator; |
|
220 |
} |
|
221 |
||
222 |
// ----------------------------------------------------------------------------- |
|
223 |
// CPbk2NameslistUiControlExtension::ContactUiControlExtensionExtension |
|
224 |
// ----------------------------------------------------------------------------- |
|
225 |
// |
|
226 |
TAny* CPbk2NameslistUiControlExtension::ContactUiControlExtensionExtension( |
|
227 |
TUid aExtensionUid ) |
|
228 |
{ |
|
229 |
if ( aExtensionUid == KMPbk2ContactUiControlExtensionExtension2Uid ) |
|
230 |
{ |
|
231 |
return static_cast<MPbk2ContactUiControlExtension2*>( this ); |
|
232 |
} |
|
233 |
else if( aExtensionUid == TUid::Uid( KPbk2ContactUiControlExtensionExtensionUID ) ) |
|
234 |
{ |
|
235 |
return static_cast<MPbk2ContactUiControlDoubleListboxExtension*>( this ); |
|
236 |
} |
|
237 |
return NULL; |
|
238 |
} |
|
239 |
||
240 |
// ----------------------------------------------------------------------------- |
|
241 |
// CPbk2NameslistUiControlExtension::SetIconArray |
|
242 |
// |
|
243 |
// For use via ContactUiControlExtensionExtension |
|
244 |
// ----------------------------------------------------------------------------- |
|
245 |
// |
|
246 |
void CPbk2NameslistUiControlExtension::SetIconArray(CPbk2IconArray& aIconArray) |
|
247 |
{ |
|
248 |
iIconArray = &aIconArray; |
|
249 |
// if bitmap is allready set. MyCardEvent - event has come before this one or there was an image on creation |
|
250 |
if( iBitmap && iMyCard ) |
|
251 |
{ |
|
252 |
TRAP_IGNORE( AddMyCardThumbnailToIconArrayL() ); |
|
253 |
} |
|
254 |
} |
|
255 |
||
256 |
// ----------------------------------------------------------------------------- |
|
257 |
// CPbk2NameslistUiControlExtension::ContactPresenceChanged |
|
258 |
// ----------------------------------------------------------------------------- |
|
259 |
// |
|
260 |
void CPbk2NameslistUiControlExtension::ContactPresenceChanged( |
|
261 |
const MVPbkContactLink& aLink ) |
|
262 |
{ |
|
263 |
if ( iContactUpdator ) |
|
264 |
{ |
|
265 |
iContactUpdator->UpdateContact( aLink ); |
|
266 |
} |
|
267 |
} |
|
268 |
||
269 |
// ----------------------------------------------------------------------------- |
|
270 |
// CPbk2NameslistUiControlExtension::FormatDataL |
|
271 |
// ----------------------------------------------------------------------------- |
|
272 |
// |
|
273 |
void CPbk2NameslistUiControlExtension::FormatDataL( |
|
274 |
const MVPbkContactLink& aContactLink, |
|
275 |
MPbk2DoubleListboxDataElement& aDataElement ) |
|
276 |
{ |
|
277 |
HBufC* txt = NULL; |
|
278 |
TPbk2IconId iconId; |
|
279 |
CSpbContentProvider::TSpbContentType type = CSpbContentProvider::ETypeNone; |
|
280 |
||
281 |
iContentProvider.GetContentL( |
|
282 |
*(const_cast<MVPbkContactLink*>(&aContactLink)), txt, iconId, type ); |
|
283 |
||
284 |
// select proper element type based on content type |
|
285 |
MPbk2DoubleListboxDataElement::TTextDataType elemType = |
|
286 |
MPbk2DoubleListboxDataElement::ETypeGenericText; |
|
287 |
if( type == CSpbContentProvider::ETypePhoneNumber ) |
|
288 |
{ |
|
289 |
elemType = MPbk2DoubleListboxDataElement::ETypePhoneNumber; |
|
290 |
} |
|
291 |
else if( type == CSpbContentProvider::ETypePhoneNumberMultiple && txt ) |
|
292 |
{ |
|
293 |
// if we get multiple phone numbers from content provider, then |
|
294 |
// the string only contains the count (as text). We need to format |
|
295 |
// that into proper UI text. |
|
296 |
TInt num = 0; |
|
297 |
TLex16 lex( *txt ); |
|
298 |
TInt err = lex.Val( num ); |
|
299 |
if( !err ) |
|
300 |
{ |
|
301 |
delete txt; |
|
302 |
txt = StringLoader::LoadL( R_QTN_PHOB_N_NUMBERS, num ); |
|
303 |
} |
|
304 |
else |
|
305 |
{ |
|
306 |
// in case of convert error |
|
307 |
txt->Des().Zero(); |
|
308 |
} |
|
309 |
} |
|
310 |
||
311 |
aDataElement.SetText( |
|
312 |
MPbk2DoubleListboxDataElement::EStatusText, txt, elemType ); |
|
313 |
||
314 |
} |
|
315 |
||
316 |
// ----------------------------------------------------------------------------- |
|
317 |
// CPbk2NameslistUiControlExtension::SetCommandItemUpdater |
|
318 |
// ----------------------------------------------------------------------------- |
|
319 |
// |
|
320 |
void CPbk2NameslistUiControlExtension::SetCommandItemUpdater( |
|
321 |
MPbk2CommandItemUpdater* aCommandUpdater ) |
|
322 |
{ |
|
323 |
// Register command item updater interface |
|
324 |
iCommandUpdater = aCommandUpdater; |
|
325 |
} |
|
326 |
||
327 |
// ----------------------------------------------------------------------------- |
|
328 |
// CPbk2NameslistUiControlExtension::ContentUpdated |
|
329 |
// ----------------------------------------------------------------------------- |
|
330 |
// |
|
331 |
void CPbk2NameslistUiControlExtension::ContentUpdated( |
|
332 |
MVPbkContactLink& aLink, |
|
333 |
MSpbContentProviderObserver::TSpbContentEvent aEvent ) |
|
334 |
{ |
|
335 |
if( aEvent == MSpbContentProviderObserver::EContentChanged ) |
|
336 |
{ |
|
337 |
MVPbkContactLink* mylink = iMyCard ? iMyCard->MyCardLink() : NULL; |
|
338 |
if( mylink && mylink->IsSame( aLink ) ) |
|
339 |
{ |
|
340 |
// mycard updated -> update mycard command item instead of contact |
|
341 |
if( iCommandUpdater ) |
|
342 |
{ |
|
343 |
iCommandUpdater->UpdateCommandItem( EPbk2CmdOpenMyCard ); |
|
344 |
} |
|
345 |
} |
|
346 |
else if( iContactUpdator ) |
|
347 |
{ |
|
348 |
// some other contactB |
|
349 |
iContactUpdator->UpdateContact( aLink ); |
|
350 |
} |
|
351 |
} |
|
352 |
} |
|
353 |
||
354 |
// ----------------------------------------------------------------------------- |
|
355 |
// CPbk2NameslistUiControlExtension::MyCardEvent |
|
356 |
// ----------------------------------------------------------------------------- |
|
357 |
// |
|
358 |
void CPbk2NameslistUiControlExtension::MyCardEvent( TMyCardStatusEvent aEvent ) |
|
359 |
{ |
|
360 |
// thumbnail is loaded |
|
361 |
if( aEvent == EStateThumbnailLoaded && iMyCard ) |
|
362 |
{ |
|
363 |
// get bitmap |
|
364 |
delete iBitmap; |
|
365 |
iBitmap = NULL; |
|
366 |
TRAP_IGNORE( iBitmap = iMyCard->MyCardBitmapL() ); |
|
367 |
||
368 |
// if icon array is already set, add icon |
|
369 |
if( iIconArray ) |
|
370 |
{ |
|
371 |
TRAP_IGNORE( AddMyCardThumbnailToIconArrayL() ); |
|
372 |
} |
|
373 |
} |
|
374 |
} |
|
375 |
||
376 |
// ----------------------------------------------------------------------------- |
|
377 |
// CPbk2NameslistUiControlExtension::AddThumbnailToIconArrayL |
|
378 |
// ----------------------------------------------------------------------------- |
|
379 |
// |
|
380 |
void CPbk2NameslistUiControlExtension::AddMyCardThumbnailToIconArrayL( ) |
|
381 |
{ |
|
382 |
if( !iMyCard ) |
|
383 |
{ |
|
384 |
return; |
|
385 |
} |
|
386 |
||
387 |
const TPbk2IconId& iconId = iMyCard->MyCardIconId(); |
|
388 |
// if thumb icon is not created, create it and append to array |
|
389 |
if( !iThumbIcon ) |
|
390 |
{ |
|
391 |
CGulIcon* icon = CGulIcon::NewLC(); |
|
392 |
icon->SetBitmap( iBitmap ); |
|
393 |
iBitmap = NULL; |
|
394 |
// takes ownership |
|
395 |
iIconArray->AppendIconL( icon, iconId ); |
|
396 |
CleanupStack::Pop( icon ); |
|
397 |
iThumbIcon = icon; // cache icon pointer |
|
398 |
} |
|
399 |
||
400 |
// else change the bitmap. This is to prevent |
|
401 |
// thumbnail indexes on thumbnail manager to get out of sync |
|
402 |
else |
|
403 |
{ |
|
404 |
iThumbIcon->SetBitmap( iBitmap ); |
|
405 |
iBitmap = NULL; |
|
406 |
} |
|
407 |
} |
|
408 |
||
409 |
||
410 |
// End of File |