|
1 /* |
|
2 * Copyright (c) 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: Class for handlind the launchpad related data |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ccappcommlauncherheaders.h" |
|
20 #include <phonebook2ece.mbg> |
|
21 |
|
22 #include <CPbk2ApplicationServices.h> |
|
23 #include <CPbk2ServiceManager.h> |
|
24 |
|
25 #include <aknlayoutscalable_avkon.cdl.h> |
|
26 //SpSettings |
|
27 #include <spsettings.h> |
|
28 #include <spentry.h> |
|
29 #include <mnproviderfinder.h> |
|
30 #include <StringLoader.h> |
|
31 |
|
32 #include <spproperty.h> |
|
33 #include <spnotifychange.h> |
|
34 |
|
35 //Bitmap |
|
36 #include <bitdev.h> |
|
37 #include <cbsbitmap.h> |
|
38 #include <AknIconUtils.h> |
|
39 |
|
40 |
|
41 namespace { |
|
42 |
|
43 #define KOneVOIPServiceAvailable 1 |
|
44 #define KVOIPButtonImageSet 0x1 |
|
45 #define KVOIPButtonTextSet 0x2 |
|
46 const TText KCCASpaceChar = ' '; |
|
47 |
|
48 /** |
|
49 * Compares entry service name to scheme. |
|
50 * |
|
51 * @param aEntry entry to be analyzed |
|
52 * @param aScheme to be compared with |
|
53 */ |
|
54 TBool CompareService(CSPEntry& aEntry, const TDesC& aScheme) |
|
55 { |
|
56 const TDesC& name = aEntry.GetServiceName(); |
|
57 if (name.CompareF(aScheme) == KErrNone) |
|
58 { |
|
59 return ETrue; |
|
60 } |
|
61 return EFalse; |
|
62 } |
|
63 |
|
64 TPtrC ParseService(const TDesC& aData) |
|
65 { |
|
66 TPtrC result = KNullDesC(); |
|
67 TInt index = aData.Locate(':'); |
|
68 if (index > 0) |
|
69 { |
|
70 result.Set(aData.Left(index)); |
|
71 } |
|
72 return result; |
|
73 } |
|
74 |
|
75 /** |
|
76 * Returns index of a first IM field. |
|
77 */ |
|
78 TInt SelectIMIndexL(const CCmsContactField& aContactField) |
|
79 { |
|
80 TInt result = 0; // by default returns 0 |
|
81 CSPSettings* settings = CSPSettings::NewLC(); |
|
82 RIdArray idArray; |
|
83 TBool found = EFalse; |
|
84 CleanupClosePushL(idArray); |
|
85 |
|
86 TInt error = settings->FindServiceIdsL(idArray); |
|
87 if (error == KErrNone) |
|
88 { |
|
89 for (TInt i = 0; !found && i < idArray.Count(); ++i) |
|
90 { |
|
91 CSPEntry* entry = CSPEntry::NewLC(); |
|
92 settings->FindEntryL(idArray[i], *entry); |
|
93 |
|
94 const CSPProperty* prop = NULL; |
|
95 if (entry->GetProperty(prop, ESubPropertyIMLaunchUid) == KErrNone) |
|
96 { |
|
97 for (TInt i = 0; i < aContactField.ItemCount(); ++i) |
|
98 { |
|
99 const CCmsContactFieldItem& item = aContactField.ItemL(i); |
|
100 TPtrC data = item.Data(); |
|
101 TPtrC scheme = ParseService(data); |
|
102 if (CompareService(*entry, scheme)) |
|
103 { |
|
104 result = i; |
|
105 found = ETrue; |
|
106 break; |
|
107 } |
|
108 } |
|
109 } |
|
110 CleanupStack::PopAndDestroy(); // entry |
|
111 } |
|
112 } |
|
113 |
|
114 CleanupStack::PopAndDestroy(2); // idArray, settings |
|
115 return result; |
|
116 } |
|
117 /** |
|
118 * Clones the Bitmap |
|
119 * This is better than Duplicating the bitmap |
|
120 */ |
|
121 CFbsBitmap* CloneBitmapLC(TSize aSize, CFbsBitmap* aBitmap) |
|
122 { |
|
123 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap(); |
|
124 CleanupStack::PushL( bitmap ); |
|
125 bitmap->Create( aSize, aBitmap->DisplayMode() ); |
|
126 CFbsBitmapDevice* bitmapDevice = CFbsBitmapDevice::NewL( bitmap ); |
|
127 CleanupStack::PushL( bitmapDevice ); |
|
128 CFbsBitGc* graphicsContext = NULL; |
|
129 User::LeaveIfError( bitmapDevice->CreateContext( graphicsContext ) ); |
|
130 CleanupStack::PushL( graphicsContext ); |
|
131 graphicsContext->BitBlt( TPoint(0, 0), aBitmap ); |
|
132 CleanupStack::PopAndDestroy( 2 );//graphicsContext,bitmapDevice |
|
133 return bitmap; |
|
134 } |
|
135 |
|
136 |
|
137 } |
|
138 |
|
139 // ======== MEMBER FUNCTIONS ======== |
|
140 |
|
141 // --------------------------------------------------------------------------- |
|
142 // CCCAppCommLauncherLPadModel::CCCAppCommLauncherLPadModel |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 CCCAppCommLauncherLPadModel::CCCAppCommLauncherLPadModel( |
|
146 CCCAppCommLauncherContainer& aContainer, |
|
147 CEikListBox& aListBox, |
|
148 CCCAppCommLauncherPlugin& aPlugin ) |
|
149 : |
|
150 iContainer ( aContainer ), |
|
151 iPerfLauncherCalled(EFalse), |
|
152 iCoeEnv(*CCoeEnv::Static()), |
|
153 iListBox(aListBox), |
|
154 iPlugin(aPlugin) |
|
155 { |
|
156 CCA_DP( KCommLauncherLogFile, CCA_L("CCCAppCommLauncherLPadModel::CCCAppCommLauncherLPadModel")); |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // CCCAppCommLauncherLPadModel::~CCCAppCommLauncherLPadModel |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 CCCAppCommLauncherLPadModel::~CCCAppCommLauncherLPadModel() |
|
164 { |
|
165 CCA_DP( KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherLPadModel::~CCCAppCommLauncherLPadModel")); |
|
166 |
|
167 if(iSPNotifyChange) |
|
168 { |
|
169 iSPNotifyChange->NotifyChangeCancel(); |
|
170 } |
|
171 |
|
172 delete iSPNotifyChange; |
|
173 delete iSettings; |
|
174 |
|
175 delete iPbkCmd; |
|
176 |
|
177 iButtonDataArray.Reset(); |
|
178 delete iTempText; |
|
179 iAddressFields.Close(); |
|
180 |
|
181 |
|
182 delete iTextBuf; |
|
183 |
|
184 CCA_DP( KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherLPadModel::~CCCAppCommLauncherLPadModel")); |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // CCCAppCommLauncherLPadModel::NewL |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 CCCAppCommLauncherLPadModel* CCCAppCommLauncherLPadModel::NewL( |
|
192 CCCAppCommLauncherContainer& aContainer, CEikListBox& aListBox, CCCAppCommLauncherPlugin& aPlugin ) |
|
193 { |
|
194 CCA_DP( KCommLauncherLogFile, CCA_L("->CCCAppCommLauncherLPadModel::NewL")); |
|
195 CCCAppCommLauncherLPadModel* self = |
|
196 new( ELeave ) CCCAppCommLauncherLPadModel( aContainer, aListBox, aPlugin ); |
|
197 CleanupStack::PushL( self ); |
|
198 self->ConstructL(); |
|
199 CleanupStack::Pop( self ); |
|
200 CCA_DP( KCommLauncherLogFile, CCA_L("<-CCCAppCommLauncherLPadModel::NewL")); |
|
201 return self; |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // CCCAppCommLauncherLPadModel::ConstructL |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 void CCCAppCommLauncherLPadModel::ConstructL() |
|
209 { |
|
210 CCA_DP( KCommLauncherLogFile, CCA_L("CCCAppCommLauncherLPadModel::ConstructL")); |
|
211 iTempText = HBufC::NewL( KCCAppCommLauncherMaxButtonDataTextLength ); |
|
212 iTextBuf = HBufC::NewL( KCCAppCommLauncherMaxButtonDataTextLength ); |
|
213 iAddressFields.Close(); |
|
214 iButtonIconArray = new (ELeave) CAknIconArray( 2 ); |
|
215 iAddressesValidated = EFalse; |
|
216 iPbkCmd = CCCAppCommLauncherPbkCmd::NewL( iPlugin ); |
|
217 iSettings = CSPSettings::NewL(); |
|
218 iSPNotifyChange = CSPNotifyChange::NewL(*this); |
|
219 RIdArray idArray; |
|
220 CleanupClosePushL(idArray); |
|
221 User::LeaveIfError( iSettings->FindServiceIdsL(idArray) ); |
|
222 //Listen for any changes to these settings |
|
223 iSPNotifyChange->NotifyChangeL( idArray ); |
|
224 CleanupStack::PopAndDestroy(); //idArray |
|
225 } |
|
226 |
|
227 // --------------------------------------------------------------------------- |
|
228 // CCCAppCommLauncherLPadModel::MdcaCount |
|
229 // --------------------------------------------------------------------------- |
|
230 // |
|
231 TInt CCCAppCommLauncherLPadModel::MdcaCount() const |
|
232 { |
|
233 return iButtonDataArray.Count(); |
|
234 } |
|
235 |
|
236 // --------------------------------------------------------------------------- |
|
237 // CCCAppCommLauncherLPadModel::MdcaPoint |
|
238 // --------------------------------------------------------------------------- |
|
239 // |
|
240 TPtrC CCCAppCommLauncherLPadModel::MdcaPoint( TInt aIndex ) const |
|
241 { |
|
242 TPtr tempText = iTempText->Des(); |
|
243 tempText.Zero(); |
|
244 |
|
245 if ( iButtonDataArray.Count() > aIndex ) |
|
246 { |
|
247 TPtr textPtr(iTextBuf->Des()); |
|
248 textPtr.Zero(); |
|
249 textPtr.Copy(iButtonDataArray[ aIndex ].iPopupText); |
|
250 if ( iButtonDataArray[ aIndex ].iClipFromBegining ) |
|
251 { |
|
252 // Clip for second row text |
|
253 ClipFromBeginning( textPtr, aIndex, 2 ); |
|
254 } |
|
255 |
|
256 tempText.AppendNum( MapCommMethodToIcon( |
|
257 iButtonDataArray[ aIndex ].iContactAction )); |
|
258 tempText.Append( KColumnListSeparator ); |
|
259 tempText.Append( iButtonDataArray[ aIndex ].iText ); |
|
260 tempText.Append( KColumnListSeparator ); |
|
261 tempText.Append( textPtr ); |
|
262 tempText.Append( KColumnListSeparator ); |
|
263 |
|
264 // Check if show multi icon at the right end of second row |
|
265 if ( IfShowMultiIcon( aIndex ) ) |
|
266 { |
|
267 tempText.AppendNum( EMultiIconIndex ); |
|
268 tempText.Append( KColumnListSeparator ); |
|
269 } |
|
270 } |
|
271 |
|
272 return tempText; |
|
273 } |
|
274 |
|
275 // --------------------------------------------------------------------------- |
|
276 // CCCAppCommLauncherLPadModel::MapCommMethodToIcon |
|
277 // --------------------------------------------------------------------------- |
|
278 // |
|
279 TInt CCCAppCommLauncherLPadModel::MapCommMethodToIcon( |
|
280 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction ) const |
|
281 { |
|
282 TInt iconIndex = KErrNotFound; |
|
283 |
|
284 switch( aContactAction ) |
|
285 { |
|
286 case VPbkFieldTypeSelectorFactory::EVoiceCallSelector: |
|
287 iconIndex = ECallIconIndex; |
|
288 break; |
|
289 case VPbkFieldTypeSelectorFactory::EUniEditorSelector: |
|
290 iconIndex = EMsgIconIndex; |
|
291 break; |
|
292 case VPbkFieldTypeSelectorFactory::EEmailEditorSelector: |
|
293 iconIndex = EEmailIconIndex; |
|
294 break; |
|
295 case VPbkFieldTypeSelectorFactory::EVOIPCallSelector: |
|
296 iconIndex = EVoipIconIndex; |
|
297 break; |
|
298 case VPbkFieldTypeSelectorFactory::EInstantMessagingSelector: |
|
299 iconIndex = EInstMsgIconIndex; |
|
300 break; |
|
301 case VPbkFieldTypeSelectorFactory::EURLSelector: |
|
302 iconIndex = EUrlIconIndex; |
|
303 break; |
|
304 case VPbkFieldTypeSelectorFactory::EVideoCallSelector: |
|
305 iconIndex = EVideocallIconIndex; |
|
306 break; |
|
307 case VPbkFieldTypeSelectorFactory::EFindOnMapSelector: |
|
308 if ( iAddressesValidated ) |
|
309 { |
|
310 iconIndex = EAddressValIconIndex; |
|
311 } |
|
312 else |
|
313 { |
|
314 iconIndex = EAddressNotValIconIndex; |
|
315 } |
|
316 break; |
|
317 default: |
|
318 break; |
|
319 } |
|
320 |
|
321 return iconIndex; |
|
322 } |
|
323 |
|
324 // --------------------------------------------------------------------------- |
|
325 // CCCAppCommLauncherLPadModel::FillButtonArrayL |
|
326 // --------------------------------------------------------------------------- |
|
327 // |
|
328 void CCCAppCommLauncherLPadModel::FillButtonArrayL() |
|
329 { |
|
330 RArray<VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector>& |
|
331 preferredCommMethods = iContainer.Plugin().PreferredCommMethods();//not owned |
|
332 const TInt buttonCount = preferredCommMethods.Count(); |
|
333 |
|
334 for ( TInt i = 0; i < buttonCount; i++ ) |
|
335 { |
|
336 const TInt numberOfAddresses = |
|
337 iContainer.Plugin().ContactHandler().AddressAmount( |
|
338 preferredCommMethods[i] ); |
|
339 |
|
340 if ( numberOfAddresses ) |
|
341 { |
|
342 TBool isServiceAvailable = |
|
343 iContainer.Plugin().ContactHandler().IsServiceAvailable( |
|
344 preferredCommMethods[i] ); |
|
345 if (isServiceAvailable) |
|
346 { |
|
347 if ( preferredCommMethods[i] == |
|
348 VPbkFieldTypeSelectorFactory::EFindOnMapSelector ) |
|
349 { |
|
350 |
|
351 AddressButtonL( numberOfAddresses, i ); |
|
352 |
|
353 } |
|
354 else |
|
355 { |
|
356 TCommLauncherButtonData buttonData = |
|
357 TCommLauncherButtonData( preferredCommMethods[i] ); |
|
358 ButtonTextL(preferredCommMethods[i], buttonData.iText); |
|
359 buttonData.iNumberOfAddresses = numberOfAddresses; |
|
360 iButtonDataArray.AppendL( buttonData ); |
|
361 } |
|
362 } |
|
363 } |
|
364 } |
|
365 |
|
366 LoadIconArrayL(); |
|
367 |
|
368 //Load Specialised Voip Icons if only one voip service is available |
|
369 //CCA spec will be updated with this necessary change |
|
370 |
|
371 //Usecase : If we have only one voip service, the voip(Internet Call) |
|
372 //button should have the Branded Icon of that Service and the label |
|
373 //must be "ServiceName" appended with "Call". |
|
374 //eg : If we have a service named SKYPE installed in the Phone |
|
375 //and if SKYPE supports VOIP, then the VOIP Button Icon should be |
|
376 //the Branded Icon of SKYPE and the Button Label should be |
|
377 //"SKYPE CALL". |
|
378 //If we have more than one voip service, then the VOIP button should |
|
379 //show the default voip button EMbmPhonebook2eceQgn_prop_pb_comm_voip |
|
380 //(Globe with Phone) and the Button label should be r_qtn_cca_voip_call |
|
381 //as defined in the rss |
|
382 LoadVoipButtonInfoL(); |
|
383 |
|
384 // Update CBA with MSK "Select" if there are communication methods available. |
|
385 TBool communicationMethodsAvailable = ( iButtonDataArray.Count() > 0 ); |
|
386 iContainer.Plugin().UpdateMSKinCbaL( communicationMethodsAvailable ); |
|
387 |
|
388 } |
|
389 |
|
390 // --------------------------------------------------------------------------- |
|
391 // CCCAppCommLauncherLPadModel::ButtonTextL |
|
392 // --------------------------------------------------------------------------- |
|
393 // |
|
394 void CCCAppCommLauncherLPadModel::ButtonTextL( |
|
395 VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction, |
|
396 TDes& aText) |
|
397 { |
|
398 TInt resId = KErrNotFound; |
|
399 switch( aContactAction ) |
|
400 { |
|
401 case VPbkFieldTypeSelectorFactory::EVoiceCallSelector: |
|
402 resId = R_QTN_CCA_CALL; |
|
403 break; |
|
404 case VPbkFieldTypeSelectorFactory::EUniEditorSelector: |
|
405 resId = R_QTN_CCA_MESSAGE; |
|
406 break; |
|
407 case VPbkFieldTypeSelectorFactory::EEmailEditorSelector: |
|
408 resId = R_QTN_CCA_EMAIL; |
|
409 break; |
|
410 case VPbkFieldTypeSelectorFactory::EInstantMessagingSelector: |
|
411 resId = R_QTN_CCA_CHAT; |
|
412 break; |
|
413 case VPbkFieldTypeSelectorFactory::EVOIPCallSelector: |
|
414 resId = R_QTN_CCA_VOIP_CALL; |
|
415 break; |
|
416 case VPbkFieldTypeSelectorFactory::EURLSelector: |
|
417 resId = R_QTN_CCA_URL; |
|
418 break; |
|
419 case VPbkFieldTypeSelectorFactory::EVideoCallSelector: |
|
420 resId = R_QTN_CCA_VIDEO_CALL; |
|
421 break; |
|
422 case VPbkFieldTypeSelectorFactory::EFindOnMapSelector: |
|
423 if ( iAddressesValidated ) |
|
424 { |
|
425 resId = R_QTN_PHOB_COMLAUNCHER_SHOW_ON_MAP; |
|
426 } |
|
427 else |
|
428 { |
|
429 resId = R_QTN_PHOB_COMLAUNCHER_FIND_ON_MAP; |
|
430 } |
|
431 break; |
|
432 default: |
|
433 break; |
|
434 } |
|
435 |
|
436 if ( KErrNotFound != resId ) |
|
437 { |
|
438 aText.Copy( StringLoader::LoadLC( resId, &iCoeEnv ) |
|
439 ->Left( KCCAppCommLauncherMaxButtonDataTextLength )); |
|
440 CleanupStack::PopAndDestroy(); |
|
441 } |
|
442 } |
|
443 |
|
444 // ----------------------------------------------------------------------------- |
|
445 // CCCAppCommLauncherLPadModel::ContactFieldFetchedNotifyL() |
|
446 // ----------------------------------------------------------------------------- |
|
447 // |
|
448 void CCCAppCommLauncherLPadModel::ContactFieldFetchedNotifyL( |
|
449 const CCmsContactField& aContactField ) |
|
450 { |
|
451 const TInt count = iButtonDataArray.Count(); |
|
452 CCmsContactFieldItem::TCmsContactField dataType = aContactField.Type(); |
|
453 CCCAppCommLauncherContactHandler& contactHandler = |
|
454 iContainer.Plugin().ContactHandler();//not owned |
|
455 |
|
456 if ( contactHandler.ContactFieldTypeAndContactActionMatch( dataType, |
|
457 VPbkFieldTypeSelectorFactory::EVoiceCallSelector )) |
|
458 {// voice call |
|
459 for ( TInt i = 0; i < count; i++ ) |
|
460 { |
|
461 CheckPopupTextL( |
|
462 i, VPbkFieldTypeSelectorFactory::EVoiceCallSelector, aContactField ); |
|
463 } |
|
464 |
|
465 //PERFORMANCE LOGGING: 11. Phonenumber data received & consumed |
|
466 WriteToPerfLog(); |
|
467 |
|
468 RunLaunchLogger(); |
|
469 |
|
470 } |
|
471 if ( contactHandler.ContactFieldTypeAndContactActionMatch( dataType, |
|
472 VPbkFieldTypeSelectorFactory::EUniEditorSelector )) |
|
473 {// unieditor |
|
474 for ( TInt i = 0; i < count; i++ ) |
|
475 { |
|
476 CheckPopupTextL( |
|
477 i, VPbkFieldTypeSelectorFactory::EUniEditorSelector, aContactField ); |
|
478 } |
|
479 } |
|
480 if ( contactHandler.ContactFieldTypeAndContactActionMatch( dataType, |
|
481 VPbkFieldTypeSelectorFactory::EEmailEditorSelector )) |
|
482 {// email |
|
483 for ( TInt i = 0; i < count; i++ ) |
|
484 { |
|
485 CheckPopupTextL( |
|
486 i, VPbkFieldTypeSelectorFactory::EEmailEditorSelector, aContactField ); |
|
487 } |
|
488 } |
|
489 if ( contactHandler.ContactFieldTypeAndContactActionMatch( dataType, |
|
490 VPbkFieldTypeSelectorFactory::EVOIPCallSelector )) |
|
491 {// voip |
|
492 for ( TInt i = 0; i < count; i++ ) |
|
493 { |
|
494 CheckPopupTextL( |
|
495 i, VPbkFieldTypeSelectorFactory::EVOIPCallSelector, aContactField ); |
|
496 } |
|
497 } |
|
498 if ( contactHandler.ContactFieldTypeAndContactActionMatch( dataType, |
|
499 VPbkFieldTypeSelectorFactory::EInstantMessagingSelector )) |
|
500 {// im |
|
501 for ( TInt i = 0; i < count; i++ ) |
|
502 { |
|
503 CheckPopupTextL( |
|
504 i, VPbkFieldTypeSelectorFactory::EInstantMessagingSelector, aContactField ); |
|
505 } |
|
506 } |
|
507 if ( contactHandler.ContactFieldTypeAndContactActionMatch( dataType, |
|
508 VPbkFieldTypeSelectorFactory::EURLSelector )) |
|
509 {// url |
|
510 for ( TInt i = 0; i < count; i++ ) |
|
511 { |
|
512 CheckPopupTextL( |
|
513 i, VPbkFieldTypeSelectorFactory::EURLSelector, aContactField ); |
|
514 } |
|
515 } |
|
516 if ( contactHandler.ContactFieldTypeAndContactActionMatch( dataType, |
|
517 VPbkFieldTypeSelectorFactory::EFindOnMapSelector )) |
|
518 {// address |
|
519 for ( TInt i = 0; i < count; i++ ) |
|
520 { |
|
521 CheckPopupTextL( i, |
|
522 VPbkFieldTypeSelectorFactory::EFindOnMapSelector, |
|
523 aContactField ); |
|
524 } |
|
525 } |
|
526 if ( contactHandler.ContactFieldTypeAndContactActionMatch( dataType, |
|
527 VPbkFieldTypeSelectorFactory::EVideoCallSelector )) |
|
528 {// video call |
|
529 for ( TInt i = 0; i < count; i++ ) |
|
530 { |
|
531 CheckPopupTextL( |
|
532 i, VPbkFieldTypeSelectorFactory::EVideoCallSelector, aContactField ); |
|
533 } |
|
534 } |
|
535 |
|
536 // Presence data |
|
537 if (dataType == CCmsContactFieldItem::ECmsPresenceData) |
|
538 {// Presence is one of the most complex data types and |
|
539 // not always working. TRAPping this is just a precaution |
|
540 // to ensure that other fields are updated correctly to |
|
541 // to the screen.. |
|
542 TRAP_IGNORE( ContactPresenceChangedL( aContactField )); |
|
543 } |
|
544 } |
|
545 |
|
546 // --------------------------------------------------------------------------- |
|
547 // CCCAppCommLauncherLPadModel::CheckPopupTextL |
|
548 // --------------------------------------------------------------------------- |
|
549 // |
|
550 void CCCAppCommLauncherLPadModel::CheckPopupTextL( |
|
551 const TInt aButtonIndex, |
|
552 const VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction, |
|
553 const CCmsContactField& aContactField ) |
|
554 { |
|
555 CCA_DP( KCommLauncherLogFile, CCA_L("CCCAppCommLauncherLPadModel::CheckPopupTextL")); |
|
556 TCommLauncherButtonData& buttonData = iButtonDataArray[ aButtonIndex ]; |
|
557 |
|
558 if ( aContactAction == buttonData.iContactAction ) |
|
559 { |
|
560 CCA_DP( KCommLauncherLogFile, CCA_L("buttonData.iContactAction: %d"), buttonData.iContactAction); |
|
561 |
|
562 CCCAppCommLauncherContactHandler& contactHandler = |
|
563 iContainer.Plugin().ContactHandler();//not owned |
|
564 buttonData.iNumberOfAddresses = |
|
565 contactHandler.AddressAmount( buttonData.iContactAction ); |
|
566 |
|
567 CCA_DP( KCommLauncherLogFile, CCA_L("buttonData.iNumberOfAddresses: %d"), buttonData.iNumberOfAddresses); |
|
568 |
|
569 const CCmsContactFieldItem::TCmsDefaultAttributeTypes cmsDefault = |
|
570 contactHandler.MapContactorTypeToCMSDefaultType( buttonData.iContactAction ); |
|
571 |
|
572 |
|
573 if ( contactHandler.ContactFieldTypeAndContactActionMatch( |
|
574 aContactField.Type(), |
|
575 VPbkFieldTypeSelectorFactory::EFindOnMapSelector ) ) |
|
576 {// addresses case is handled here |
|
577 CheckAddressesPopupTextL( |
|
578 aButtonIndex, aContactAction, aContactField ); |
|
579 return; |
|
580 } |
|
581 |
|
582 // has default, multiple entries |
|
583 if ( aContactField.HasDefaultAttribute( cmsDefault ) && 1 < buttonData.iNumberOfAddresses ) |
|
584 {// has default, multiple entries |
|
585 CCA_DP( KCommLauncherLogFile, CCA_L("aContactField.HasDefaultAttribute(): true")); |
|
586 |
|
587 const CCmsContactFieldItem& item = aContactField.ItemL( cmsDefault );//not own |
|
588 buttonData.iPopupText.Zero(); |
|
589 buttonData.iFlags |= TCommLauncherButtonData::EDefaultSet; |
|
590 buttonData.iPopupText.Append(item.Data().Left( |
|
591 KCCAppCommLauncherMaxButtonDataTextLength )); |
|
592 |
|
593 SetTextClipDirection(aContactAction, aButtonIndex); |
|
594 } |
|
595 |
|
596 // no default, multiple entries |
|
597 else if ( 1 < buttonData.iNumberOfAddresses |
|
598 && !( buttonData.iFlags & TCommLauncherButtonData::EDefaultSet )) |
|
599 { |
|
600 CCA_DP( KCommLauncherLogFile, CCA_L("no default, multiple numbers")); |
|
601 |
|
602 buttonData.iPopupText.Zero(); |
|
603 if ( contactHandler.IsItNumberAddress( aContactAction )) |
|
604 { |
|
605 if ( aContactAction == VPbkFieldTypeSelectorFactory::EUniEditorSelector ) |
|
606 { |
|
607 // x numbers/addresses |
|
608 buttonData.iPopupText.Append(*StringLoader::LoadLC( |
|
609 R_QTN_CCA_MULTIPLE_NUMBERS_ADDRESSES, |
|
610 buttonData.iNumberOfAddresses, |
|
611 &iCoeEnv)); |
|
612 } |
|
613 else |
|
614 { |
|
615 // x numbers |
|
616 buttonData.iPopupText.Append(*StringLoader::LoadLC( |
|
617 R_QTN_CCA_MULTIPLE_NUMBERS, |
|
618 buttonData.iNumberOfAddresses, |
|
619 &iCoeEnv)); |
|
620 } |
|
621 } |
|
622 else if ( aContactAction == VPbkFieldTypeSelectorFactory::EInstantMessagingSelector ) |
|
623 { |
|
624 buttonData.iPopupText.Append(*StringLoader::LoadLC( |
|
625 R_QTN_CCA_MULTIPLE_ACCOUNTS, |
|
626 buttonData.iNumberOfAddresses, |
|
627 &iCoeEnv)); |
|
628 } |
|
629 else |
|
630 { |
|
631 buttonData.iPopupText.Append(*StringLoader::LoadLC( |
|
632 R_QTN_CCA_MULTIPLE_ADDRESSES, |
|
633 buttonData.iNumberOfAddresses, |
|
634 &iCoeEnv)); |
|
635 } |
|
636 CleanupStack::PopAndDestroy(); |
|
637 } |
|
638 |
|
639 // one entry |
|
640 else if ( 1 == buttonData.iNumberOfAddresses ) |
|
641 { |
|
642 CCA_DP( KCommLauncherLogFile, CCA_L("one address")); |
|
643 |
|
644 SetTextClipDirection(aContactAction, aButtonIndex); |
|
645 |
|
646 |
|
647 TInt index = 0; // by default select first |
|
648 if ( aContactAction == VPbkFieldTypeSelectorFactory::EInstantMessagingSelector ) |
|
649 { |
|
650 // in IM case IMPP field might contain voip and im service |
|
651 // fields. Need to filter out voip fields in case of IM |
|
652 // commmunication type |
|
653 index = SelectIMIndexL(aContactField); |
|
654 } |
|
655 |
|
656 if ( aContactAction == VPbkFieldTypeSelectorFactory::EUniEditorSelector |
|
657 && buttonData.iPopupText.Length() > 0 |
|
658 && aContactField.Type() != CCmsContactFieldItem::ECmsMobilePhoneGeneric |
|
659 && aContactField.Type() != CCmsContactFieldItem::ECmsMobilePhoneHome |
|
660 && aContactField.Type() != CCmsContactFieldItem::ECmsMobilePhoneWork ) |
|
661 { |
|
662 // Already has a number |
|
663 } |
|
664 else |
|
665 { |
|
666 buttonData.iPopupText.Zero(); |
|
667 buttonData.iPopupText.Append( |
|
668 aContactField.ItemL( index ).Data().Left( |
|
669 KCCAppCommLauncherMaxButtonDataTextLength )); |
|
670 } |
|
671 } |
|
672 } |
|
673 } |
|
674 |
|
675 // --------------------------------------------------------------------------- |
|
676 // CCCAppCommLauncherLPadModel::LoadIconArrayL |
|
677 // --------------------------------------------------------------------------- |
|
678 // |
|
679 void CCCAppCommLauncherLPadModel::LoadIconArrayL() |
|
680 { |
|
681 // todo; currently icons are just temporary/hardcoded, but they |
|
682 // could be loaded directly from resources (or dynamically based on |
|
683 // what icons are needed). |
|
684 |
|
685 // ECallIconIndex |
|
686 iButtonIconArray->AppendL( LoadIconLC( |
|
687 EMbmPhonebook2eceQgn_prop_pb_comm_call, |
|
688 EMbmPhonebook2eceQgn_prop_pb_comm_call_mask )); |
|
689 CleanupStack::Pop(); // icon |
|
690 |
|
691 // EMsgIconIndex |
|
692 iButtonIconArray->AppendL( LoadIconLC( |
|
693 EMbmPhonebook2eceQgn_prop_pb_comm_message, |
|
694 EMbmPhonebook2eceQgn_prop_pb_comm_message_mask )); |
|
695 CleanupStack::Pop(); // icon |
|
696 |
|
697 // EEmailIconIndex |
|
698 iButtonIconArray->AppendL( LoadIconLC( |
|
699 EMbmPhonebook2eceQgn_prop_pb_comm_email, |
|
700 EMbmPhonebook2eceQgn_prop_pb_comm_email_mask )); |
|
701 CleanupStack::Pop(); // icon |
|
702 |
|
703 // EVoipIconIndex |
|
704 iButtonIconArray->AppendL( LoadIconLC( |
|
705 EMbmPhonebook2eceQgn_prop_pb_comm_voip, |
|
706 EMbmPhonebook2eceQgn_prop_pb_comm_voip_mask )); |
|
707 CleanupStack::Pop(); // icon |
|
708 |
|
709 // EIMIconIndex |
|
710 iButtonIconArray->AppendL( LoadIconLC( |
|
711 EMbmPhonebook2eceQgn_prop_pb_comm_chat, |
|
712 EMbmPhonebook2eceQgn_prop_pb_comm_chat_mask )); |
|
713 CleanupStack::Pop(); // icon |
|
714 |
|
715 // EUrlIconIndex |
|
716 iButtonIconArray->AppendL( LoadIconLC( |
|
717 EMbmPhonebook2eceQgn_prop_pb_comm_url, |
|
718 EMbmPhonebook2eceQgn_prop_pb_comm_url_mask )); |
|
719 CleanupStack::Pop(); // icon |
|
720 |
|
721 // EVideocallIconIndex |
|
722 iButtonIconArray->AppendL( LoadIconLC( |
|
723 EMbmPhonebook2eceQgn_prop_pb_comm_vcall, |
|
724 EMbmPhonebook2eceQgn_prop_pb_comm_vcall_mask )); |
|
725 CleanupStack::Pop(); // icon |
|
726 |
|
727 // EAddressValIconIndex |
|
728 iButtonIconArray->AppendL( LoadIconLC( |
|
729 EMbmPhonebook2eceQgn_prop_pb_comm_valid_lm, |
|
730 EMbmPhonebook2eceQgn_prop_pb_comm_valid_lm_mask )); |
|
731 CleanupStack::Pop(); // icon |
|
732 |
|
733 // EAddressNotValIconIndex |
|
734 iButtonIconArray->AppendL( LoadIconLC( |
|
735 EMbmPhonebook2eceQgn_prop_pb_comm_no_valid_lm, |
|
736 EMbmPhonebook2eceQgn_prop_pb_comm_no_valid_lm_mask )); |
|
737 CleanupStack::Pop(); // icon |
|
738 |
|
739 // EMultiIconIndex |
|
740 iButtonIconArray->AppendL( LoadIconLC( |
|
741 EMbmPhonebook2eceQgn_indi_many_items_add, |
|
742 EMbmPhonebook2eceQgn_indi_many_items_add_mask )); |
|
743 CleanupStack::Pop(); // icon |
|
744 |
|
745 } |
|
746 |
|
747 // --------------------------------------------------------------------------- |
|
748 // CCCAppCommLauncherLPadModel::LoadIconLC |
|
749 // --------------------------------------------------------------------------- |
|
750 // |
|
751 CGulIcon* CCCAppCommLauncherLPadModel::LoadIconLC( TInt aBmpId, TInt aMaskId ) |
|
752 { |
|
753 CFbsBitmap* bmp = NULL; |
|
754 CFbsBitmap* mask = NULL; |
|
755 CGulIcon* icon = CGulIcon::NewLC(); |
|
756 |
|
757 AknIconUtils::CreateIconLC( |
|
758 bmp, mask, KPbk2ECEIconFileName, aBmpId, aMaskId ); |
|
759 |
|
760 icon->SetBitmap( bmp ); |
|
761 icon->SetMask( mask ); |
|
762 CleanupStack::Pop( 2 ); // bmp, mask |
|
763 |
|
764 return icon; |
|
765 } |
|
766 |
|
767 // --------------------------------------------------------------------------- |
|
768 // CCCAppCommLauncherLPadModel::IconArray |
|
769 // --------------------------------------------------------------------------- |
|
770 // |
|
771 CAknIconArray* CCCAppCommLauncherLPadModel::IconArray() |
|
772 { |
|
773 return iButtonIconArray; |
|
774 } |
|
775 |
|
776 // --------------------------------------------------------------------------- |
|
777 // CCCAppCommLauncherLPadModel::ButtonData |
|
778 // --------------------------------------------------------------------------- |
|
779 // |
|
780 TCommLauncherButtonData& CCCAppCommLauncherLPadModel::ButtonData( TInt aIndex ) |
|
781 { |
|
782 return iButtonDataArray[ aIndex ]; |
|
783 } |
|
784 |
|
785 // --------------------------------------------------------------------------- |
|
786 // CCCAppCommLauncherLPadModel::TextForPopUpL |
|
787 // --------------------------------------------------------------------------- |
|
788 // |
|
789 TPtrC CCCAppCommLauncherLPadModel::TextForPopUpL( TInt aButtonIndex ) |
|
790 { |
|
791 TPtr tempText = iTempText->Des(); |
|
792 tempText.Zero(); |
|
793 if ( iButtonDataArray[ aButtonIndex ].iContactAction |
|
794 == VPbkFieldTypeSelectorFactory::EFindOnMapSelector |
|
795 && iButtonDataArray[ aButtonIndex ].iNumberOfAddresses == 1 ) |
|
796 { |
|
797 return AddressTextForPopUpL(); |
|
798 } |
|
799 else |
|
800 { |
|
801 tempText.Append( iButtonDataArray[ aButtonIndex ].iPopupText ); |
|
802 } |
|
803 |
|
804 return *iTempText; |
|
805 } |
|
806 |
|
807 // --------------------------------------------------------------------------- |
|
808 // CCCAppCommLauncherLPadModel::Reset |
|
809 // --------------------------------------------------------------------------- |
|
810 // |
|
811 void CCCAppCommLauncherLPadModel::Reset() |
|
812 { |
|
813 iButtonDataArray.Reset(); |
|
814 } |
|
815 |
|
816 // --------------------------------------------------------------------------- |
|
817 // CCCAppCommLauncherLPadModel::ReplaceWithDefaultIconL |
|
818 // --------------------------------------------------------------------------- |
|
819 // |
|
820 void CCCAppCommLauncherLPadModel::ReplaceWithDefaultIconL( |
|
821 CFbsBitmap*& aBitmap, |
|
822 CFbsBitmap*& aMask, |
|
823 const TUint32 aServiceType ) |
|
824 { |
|
825 delete aBitmap; |
|
826 delete aMask; |
|
827 CGulIcon* icon = NULL; |
|
828 |
|
829 switch ( aServiceType ) |
|
830 { |
|
831 /* The VOIP Button doesnt show presence CCA UI Spec will be |
|
832 * updated with this info. |
|
833 * Thats why this part of code is commeneted |
|
834 case CCmsContactFieldItem::ECmsPresenceVoIPNotification: |
|
835 icon = LoadIconLC( |
|
836 EMbmPhonebook2eceQgn_prop_nrtyp_voip, |
|
837 EMbmPhonebook2eceQgn_prop_nrtyp_voip_mask ); |
|
838 break;*/ |
|
839 case CCmsContactFieldItem::ECmsPresenceChatNotification: |
|
840 icon = LoadIconLC( |
|
841 EMbmPhonebook2eceQgn_prop_nrtyp_chat, |
|
842 EMbmPhonebook2eceQgn_prop_nrtyp_chat_mask ); |
|
843 break; |
|
844 default: |
|
845 // Only ECmsPresenceVoIPNotification and |
|
846 // ECmsPresenceChatNotification supported |
|
847 User::Leave( KErrArgument ); |
|
848 break; |
|
849 } |
|
850 |
|
851 aBitmap = icon->Bitmap(); |
|
852 aMask = icon->Mask(); |
|
853 icon->SetBitmapsOwnedExternally( ETrue ); |
|
854 CleanupStack::PopAndDestroy( icon ); |
|
855 } |
|
856 |
|
857 // --------------------------------------------------------------------------- |
|
858 // CCCAppCommLauncherLPadModel::ContactPresenceChangedL |
|
859 // --------------------------------------------------------------------------- |
|
860 // |
|
861 void CCCAppCommLauncherLPadModel::ContactPresenceChangedL( |
|
862 const CCmsContactField& aContactField ) |
|
863 { |
|
864 //Get the size of icon for Voip presence |
|
865 TRect mainPane = iPlugin.ClientRect(); |
|
866 TAknLayoutRect listLayoutRect; |
|
867 listLayoutRect.LayoutRect( |
|
868 mainPane, |
|
869 AknLayoutScalable_Avkon::list_single_large_graphic_pane_g1(0).LayoutLine() ); |
|
870 TSize size(listLayoutRect.Rect().Size()); |
|
871 |
|
872 const TInt count = aContactField.ItemCount(); |
|
873 for (TUint i=0; i < count; i++) |
|
874 { |
|
875 CCmsPresenceData& presData = ( CCmsPresenceData& )aContactField.ItemL( i ); |
|
876 presData.PreparePresenceDataL( size ); |
|
877 TUint32 serviceType = presData.ServiceType(); |
|
878 TInt iconInd = KErrNotFound; |
|
879 switch (serviceType) |
|
880 { |
|
881 /* The VOIP Button doesnt show presence CCA UI Spec will be |
|
882 * updated with this info. |
|
883 * Thats why this part of code is commeneted |
|
884 case CCmsContactFieldItem::ECmsPresenceVoIPNotification: |
|
885 iconInd = MapCommMethodToIcon( |
|
886 VPbkFieldTypeSelectorFactory::EVOIPCallSelector ); |
|
887 break;*/ |
|
888 case CCmsContactFieldItem::ECmsPresenceChatNotification: |
|
889 iconInd = MapCommMethodToIcon( |
|
890 VPbkFieldTypeSelectorFactory::EInstantMessagingSelector ); |
|
891 break; |
|
892 } |
|
893 if (iconInd > 0 && iconInd < iButtonIconArray->Count()) |
|
894 { |
|
895 CFbsBitmap* mask = presData.Mask(); |
|
896 CFbsBitmap* bitmap = presData.Bitmap(); |
|
897 |
|
898 if ( bitmap && NULL == bitmap->Handle() ) |
|
899 { |
|
900 // There should not be a case with empty bitmaps, so |
|
901 // replace with the default icons. |
|
902 ReplaceWithDefaultIconL( bitmap, mask, serviceType ); |
|
903 } |
|
904 |
|
905 if ( bitmap || mask ) |
|
906 { |
|
907 iButtonIconArray->At(iconInd)->SetBitmap(bitmap); |
|
908 iButtonIconArray->At(iconInd)->SetMask(mask); |
|
909 } |
|
910 } |
|
911 else |
|
912 { |
|
913 delete presData.Bitmap(); |
|
914 delete presData.Mask(); |
|
915 } |
|
916 } |
|
917 } |
|
918 |
|
919 // --------------------------------------------------------------------------- |
|
920 // CCCAppCommLauncherLPadModel::AddressButtonL |
|
921 // --------------------------------------------------------------------------- |
|
922 // |
|
923 void CCCAppCommLauncherLPadModel::AddressButtonL( |
|
924 const TInt aNumberOfAddresses, const TInt aIndex ) |
|
925 { |
|
926 RArray<VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector>& |
|
927 preferredCommMethods = iContainer.Plugin().PreferredCommMethods();//not owned |
|
928 |
|
929 RPointerArray<CMnProvider> providers; |
|
930 CleanupClosePushL( providers ); |
|
931 MnProviderFinder::FindProvidersL( providers, |
|
932 CMnProvider::EServiceMapView ); |
|
933 if (providers.Count() > 0) |
|
934 { |
|
935 TCommLauncherButtonData buttonData = |
|
936 TCommLauncherButtonData( preferredCommMethods[aIndex] ); |
|
937 ButtonTextL(preferredCommMethods[aIndex], buttonData.iText); |
|
938 buttonData.iNumberOfAddresses = aNumberOfAddresses; |
|
939 iButtonDataArray.AppendL( buttonData ); |
|
940 } |
|
941 providers.ResetAndDestroy(); |
|
942 CleanupStack::PopAndDestroy( &providers ); |
|
943 } |
|
944 |
|
945 // --------------------------------------------------------------------------- |
|
946 // CCCAppCommLauncherLPadModel::UpdateAddressesValidationL |
|
947 // --------------------------------------------------------------------------- |
|
948 // |
|
949 void CCCAppCommLauncherLPadModel::UpdateAddressesValidationL( |
|
950 const CCmsContactFieldInfo& aContactFieldInfo ) |
|
951 { |
|
952 TInt count = aContactFieldInfo.Fields().Count(); |
|
953 if ( count ) |
|
954 { |
|
955 TBool generalAddress = EFalse; |
|
956 TBool homeAddress = EFalse; |
|
957 TBool workAddress = EFalse; |
|
958 TBool generalGeo = EFalse; |
|
959 TBool homeGeo = EFalse; |
|
960 TBool workGeo = EFalse; |
|
961 for ( TInt i = 0; i < count; i++ ) |
|
962 { |
|
963 switch ( aContactFieldInfo.Fields().operator []( i ) ) |
|
964 { |
|
965 case CCmsContactFieldItem::ECmsAddrPOGeneric: |
|
966 case CCmsContactFieldItem::ECmsAddrExtGeneric: |
|
967 case CCmsContactFieldItem::ECmsAddrStreetGeneric: |
|
968 case CCmsContactFieldItem::ECmsAddrLocalGeneric: |
|
969 case CCmsContactFieldItem::ECmsAddrRegionGeneric: |
|
970 case CCmsContactFieldItem::ECmsAddrPostcodeGeneric: |
|
971 case CCmsContactFieldItem::ECmsAddrCountryGeneric: |
|
972 { |
|
973 generalAddress = ETrue; |
|
974 break; |
|
975 } |
|
976 case CCmsContactFieldItem::ECmsAddrPOHome: |
|
977 case CCmsContactFieldItem::ECmsAddrExtHome: |
|
978 case CCmsContactFieldItem::ECmsAddrStreetHome: |
|
979 case CCmsContactFieldItem::ECmsAddrLocalHome: |
|
980 case CCmsContactFieldItem::ECmsAddrRegionHome: |
|
981 case CCmsContactFieldItem::ECmsAddrPostcodeHome: |
|
982 case CCmsContactFieldItem::ECmsAddrCountryHome: |
|
983 { |
|
984 homeAddress = ETrue; |
|
985 break; |
|
986 } |
|
987 case CCmsContactFieldItem::ECmsAddrPOWork: |
|
988 case CCmsContactFieldItem::ECmsAddrExtWork: |
|
989 case CCmsContactFieldItem::ECmsAddrStreetWork: |
|
990 case CCmsContactFieldItem::ECmsAddrLocalWork: |
|
991 case CCmsContactFieldItem::ECmsAddrRegionWork: |
|
992 case CCmsContactFieldItem::ECmsAddrPostcodeWork: |
|
993 case CCmsContactFieldItem::ECmsAddrCountryWork: |
|
994 { |
|
995 workAddress = ETrue; |
|
996 break; |
|
997 } |
|
998 case CCmsContactFieldItem::ECmsAddrGeoGeneric: |
|
999 { |
|
1000 generalGeo = ETrue; |
|
1001 break; |
|
1002 } |
|
1003 case CCmsContactFieldItem::ECmsAddrGeoHome: |
|
1004 { |
|
1005 homeGeo = ETrue; |
|
1006 break; |
|
1007 } |
|
1008 case CCmsContactFieldItem::ECmsAddrGeoWork: |
|
1009 { |
|
1010 workGeo = ETrue; |
|
1011 break; |
|
1012 } |
|
1013 default: |
|
1014 { |
|
1015 // do nothing |
|
1016 break; |
|
1017 } |
|
1018 } |
|
1019 } |
|
1020 if ( ( generalAddress && !generalGeo ) |
|
1021 || ( homeAddress && !homeGeo ) |
|
1022 || ( workAddress && !workGeo ) ) |
|
1023 { |
|
1024 iAddressesValidated = EFalse; |
|
1025 } |
|
1026 else |
|
1027 { |
|
1028 iAddressesValidated = ETrue; |
|
1029 } |
|
1030 } |
|
1031 } |
|
1032 |
|
1033 // --------------------------------------------------------------------------- |
|
1034 // CCCAppCommLauncherLPadModel::CheckAddressesPopupTextL |
|
1035 // --------------------------------------------------------------------------- |
|
1036 // |
|
1037 void CCCAppCommLauncherLPadModel::CheckAddressesPopupTextL( |
|
1038 const TInt aButtonIndex, |
|
1039 const VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector |
|
1040 aContactAction, |
|
1041 const CCmsContactField& aContactField ) |
|
1042 { |
|
1043 CCA_DP( KCommLauncherLogFile, CCA_L( |
|
1044 "CCCAppCommLauncherLPadModel::CheckAddressesPopupTextL" ) ); |
|
1045 TCommLauncherButtonData& buttonData = iButtonDataArray[ aButtonIndex ]; |
|
1046 |
|
1047 if ( aContactAction == buttonData.iContactAction ) |
|
1048 { |
|
1049 CCCAppCommLauncherContactHandler& contactHandler = |
|
1050 iContainer.Plugin().ContactHandler();//not owned |
|
1051 buttonData.iNumberOfAddresses = |
|
1052 contactHandler.AddressAmount( buttonData.iContactAction ); |
|
1053 |
|
1054 if ( contactHandler.ContactFieldTypeAndContactActionMatch( |
|
1055 aContactField.Type(), |
|
1056 VPbkFieldTypeSelectorFactory::EFindOnMapSelector ) ) |
|
1057 { |
|
1058 if ( buttonData.iNumberOfAddresses == 1 ) |
|
1059 {// one address case handled here |
|
1060 TInt index = 0; // by default select first |
|
1061 |
|
1062 switch ( aContactField.Type() ) |
|
1063 { |
|
1064 case CCmsContactFieldItem::ECmsAddrPOGeneric: |
|
1065 case CCmsContactFieldItem::ECmsAddrPOHome: |
|
1066 case CCmsContactFieldItem::ECmsAddrPOWork: |
|
1067 { |
|
1068 iAddressFields.InsertL( EAddressPO, |
|
1069 aContactField.ItemL( index ).Data().Left( |
|
1070 KCCAppCommLauncherMaxButtonDataTextLength ) ); |
|
1071 break; |
|
1072 } |
|
1073 case CCmsContactFieldItem::ECmsAddrExtGeneric: |
|
1074 case CCmsContactFieldItem::ECmsAddrExtHome: |
|
1075 case CCmsContactFieldItem::ECmsAddrExtWork: |
|
1076 { |
|
1077 iAddressFields.InsertL( EAddressExt, |
|
1078 aContactField.ItemL( index ).Data().Left( |
|
1079 KCCAppCommLauncherMaxButtonDataTextLength ) ); |
|
1080 break; |
|
1081 } |
|
1082 case CCmsContactFieldItem::ECmsAddrStreetGeneric: |
|
1083 case CCmsContactFieldItem::ECmsAddrStreetHome: |
|
1084 case CCmsContactFieldItem::ECmsAddrStreetWork: |
|
1085 { |
|
1086 iAddressFields.InsertL( EAddressStreet, |
|
1087 aContactField.ItemL( index ).Data().Left( |
|
1088 KCCAppCommLauncherMaxButtonDataTextLength ) ); |
|
1089 break; |
|
1090 } |
|
1091 case CCmsContactFieldItem::ECmsAddrLocalGeneric: |
|
1092 case CCmsContactFieldItem::ECmsAddrLocalHome: |
|
1093 case CCmsContactFieldItem::ECmsAddrLocalWork: |
|
1094 { |
|
1095 iAddressFields.InsertL( EAddressLocal, |
|
1096 aContactField.ItemL( index ).Data().Left( |
|
1097 KCCAppCommLauncherMaxButtonDataTextLength ) ); |
|
1098 break; |
|
1099 } |
|
1100 case CCmsContactFieldItem::ECmsAddrRegionGeneric: |
|
1101 case CCmsContactFieldItem::ECmsAddrRegionHome: |
|
1102 case CCmsContactFieldItem::ECmsAddrRegionWork: |
|
1103 { |
|
1104 iAddressFields.InsertL( EAddressRegion, |
|
1105 aContactField.ItemL( index ).Data().Left( |
|
1106 KCCAppCommLauncherMaxButtonDataTextLength ) ); |
|
1107 break; |
|
1108 } |
|
1109 case CCmsContactFieldItem::ECmsAddrPostcodeGeneric: |
|
1110 case CCmsContactFieldItem::ECmsAddrPostcodeHome: |
|
1111 case CCmsContactFieldItem::ECmsAddrPostcodeWork: |
|
1112 { |
|
1113 iAddressFields.InsertL( EAddressPostcode, |
|
1114 aContactField.ItemL( index ).Data().Left( |
|
1115 KCCAppCommLauncherMaxButtonDataTextLength ) ); |
|
1116 break; |
|
1117 } |
|
1118 case CCmsContactFieldItem::ECmsAddrCountryGeneric: |
|
1119 case CCmsContactFieldItem::ECmsAddrCountryHome: |
|
1120 case CCmsContactFieldItem::ECmsAddrCountryWork: |
|
1121 { |
|
1122 iAddressFields.InsertL( EAddressCountry, |
|
1123 aContactField.ItemL( index ).Data().Left( |
|
1124 KCCAppCommLauncherMaxButtonDataTextLength ) ); |
|
1125 break; |
|
1126 } |
|
1127 default: |
|
1128 { |
|
1129 // nothing to do |
|
1130 return; |
|
1131 } |
|
1132 } |
|
1133 } |
|
1134 else |
|
1135 {// multiple addresses case handled here |
|
1136 buttonData.iPopupText.Zero(); |
|
1137 buttonData.iPopupText.Append(*StringLoader::LoadLC( |
|
1138 R_QTN_CCA_MULTIPLE_ADDRESSES, |
|
1139 buttonData.iNumberOfAddresses)); |
|
1140 CleanupStack::PopAndDestroy(); |
|
1141 } |
|
1142 } |
|
1143 } |
|
1144 } |
|
1145 |
|
1146 // --------------------------------------------------------------------------- |
|
1147 // CCCAppCommLauncherLPadModel::AddressTextForPopUpL |
|
1148 // --------------------------------------------------------------------------- |
|
1149 // |
|
1150 TPtrC CCCAppCommLauncherLPadModel::AddressTextForPopUpL() |
|
1151 { |
|
1152 const TInt KGranularity = 4; |
|
1153 CDesCArrayFlat* fields = new ( ELeave ) CDesCArrayFlat( KGranularity ); |
|
1154 CleanupStack::PushL( fields ); |
|
1155 |
|
1156 TPtr tempText = iTempText->Des(); |
|
1157 tempText.Zero(); |
|
1158 |
|
1159 HBufC* formattedText = NULL; |
|
1160 TBool street = EFalse; |
|
1161 TBool local = EFalse; |
|
1162 |
|
1163 TPtrC* text = iAddressFields.Find( EAddressStreet ); |
|
1164 if ( text ) |
|
1165 { |
|
1166 fields->AppendL( *text ); |
|
1167 street = ETrue; |
|
1168 } |
|
1169 text = iAddressFields.Find( EAddressLocal ); |
|
1170 if ( text ) |
|
1171 { |
|
1172 fields->AppendL( *text ); |
|
1173 local = ETrue; |
|
1174 } |
|
1175 |
|
1176 if ( street && local ) |
|
1177 { |
|
1178 formattedText = StringLoader::LoadLC( |
|
1179 R_QTN_PHOB_COMMLAUNCHER_ONELINEPREVIEW, *fields ); |
|
1180 } |
|
1181 else |
|
1182 { |
|
1183 formattedText = StringLoader::LoadLC( |
|
1184 R_QTN_PHOB_POPUP_INCOMPLETE_ADDRESS ); |
|
1185 } |
|
1186 |
|
1187 tempText.Append( *formattedText ); |
|
1188 CleanupStack::PopAndDestroy( formattedText ); |
|
1189 CleanupStack::PopAndDestroy( fields ); |
|
1190 |
|
1191 return *iTempText; |
|
1192 } |
|
1193 |
|
1194 // --------------------------------------------------------------------------- |
|
1195 // CCCAppCommLauncherLPadModel::LoadVoipButtonInfoL |
|
1196 // --------------------------------------------------------------------------- |
|
1197 // |
|
1198 TInt CCCAppCommLauncherLPadModel::LoadVoipButtonInfoL() |
|
1199 { |
|
1200 TInt returnVal (0); |
|
1201 TServiceId serviceId; //Stores the last found Service Id of VOIP Service |
|
1202 TInt availableVoipServices = GetSupportedVOIPServicesL( serviceId ); |
|
1203 |
|
1204 if ( KOneVOIPServiceAvailable == availableVoipServices ) |
|
1205 { |
|
1206 HBufC* serviceName = NULL; |
|
1207 CFbsBitmap* bitmap(NULL); |
|
1208 CFbsBitmap* mask(NULL); |
|
1209 //Now we have only 1 service which supports VOIP |
|
1210 //hence load the VOIP Button Icon & corresponding label |
|
1211 LoadVoipButtonInfoFromPbkL( serviceId, bitmap, mask, serviceName ); |
|
1212 |
|
1213 CleanupStack::PushL( serviceName ); |
|
1214 |
|
1215 //Replace the default icons with the branded icon |
|
1216 if ( bitmap || mask ) |
|
1217 { |
|
1218 TInt iconInd = MapCommMethodToIcon( |
|
1219 VPbkFieldTypeSelectorFactory::EVOIPCallSelector ); |
|
1220 //we have found the branded icon for voip button |
|
1221 iButtonIconArray->At(iconInd)->SetBitmap(bitmap); |
|
1222 iButtonIconArray->At(iconInd)->SetMask(mask); |
|
1223 |
|
1224 returnVal |= KVOIPButtonImageSet; |
|
1225 } |
|
1226 |
|
1227 //Replace the default button text with the branded servicename |
|
1228 for ( TInt i = 0; i < iButtonDataArray.Count() && serviceName ; i++ ) |
|
1229 { |
|
1230 TCommLauncherButtonData& buttonData ( iButtonDataArray[i] ); |
|
1231 |
|
1232 if ( VPbkFieldTypeSelectorFactory::EVOIPCallSelector == |
|
1233 iButtonDataArray[i].iContactAction ) |
|
1234 { |
|
1235 HBufC* str = StringLoader::LoadLC( R_QTN_CCA_VOIP_CALL_WITH_SERVICENAME, |
|
1236 *serviceName, |
|
1237 &iCoeEnv ); |
|
1238 |
|
1239 buttonData.iText.Copy( str->Left( KCCAppCommLauncherMaxButtonDataTextLength ) ); |
|
1240 CleanupStack::PopAndDestroy(); //str |
|
1241 //Button Text has been set |
|
1242 returnVal |= KVOIPButtonTextSet; |
|
1243 break; |
|
1244 } |
|
1245 } |
|
1246 |
|
1247 CleanupStack::PopAndDestroy(); //serviceName |
|
1248 } |
|
1249 |
|
1250 return returnVal; |
|
1251 } |
|
1252 |
|
1253 |
|
1254 // --------------------------------------------------------------------------- |
|
1255 // CCCAppCommLauncherLPadModel::GetSupportedVOIPServicesL |
|
1256 // --------------------------------------------------------------------------- |
|
1257 // |
|
1258 TInt CCCAppCommLauncherLPadModel::GetSupportedVOIPServicesL( TServiceId& aServiceId ) |
|
1259 { |
|
1260 //Find all services which are voip enabled |
|
1261 TInt availableVoipService (0); |
|
1262 RIdArray idArray; |
|
1263 CleanupClosePushL(idArray); |
|
1264 |
|
1265 User::LeaveIfError( iSettings->FindServiceIdsL(idArray) ); |
|
1266 |
|
1267 for (TInt i = 0; i < idArray.Count(); ++i) |
|
1268 { |
|
1269 TBool supported( EFalse ); |
|
1270 CSPEntry* entry = CSPEntry::NewLC(); |
|
1271 TServiceId id = idArray[i]; |
|
1272 User::LeaveIfError( iSettings->FindEntryL(id, *entry) ); |
|
1273 const CSPProperty* property = NULL; |
|
1274 |
|
1275 if (entry->GetProperty(property, EPropertyServiceAttributeMask) == KErrNone) |
|
1276 { |
|
1277 TInt value = 0; |
|
1278 property->GetValue(value); |
|
1279 supported = value & ESupportsInternetCall; |
|
1280 } |
|
1281 |
|
1282 if ( supported ) |
|
1283 { |
|
1284 availableVoipService++; |
|
1285 aServiceId = id; |
|
1286 } |
|
1287 CleanupStack::PopAndDestroy(); // entry |
|
1288 } |
|
1289 CleanupStack::PopAndDestroy(); //idArray |
|
1290 |
|
1291 return availableVoipService; |
|
1292 } |
|
1293 |
|
1294 // --------------------------------------------------------------------------- |
|
1295 // CCCAppCommLauncherLPadModel::LoadVoipButtonInfoFromPbkL |
|
1296 // --------------------------------------------------------------------------- |
|
1297 // |
|
1298 void CCCAppCommLauncherLPadModel::LoadVoipButtonInfoFromPbkL( |
|
1299 TServiceId aServiceId, |
|
1300 CFbsBitmap*& aBitmap, CFbsBitmap*& aMask, HBufC*& aLocalisedServiceName ) |
|
1301 { |
|
1302 // get the XSP ServiceName |
|
1303 // CPbk2ServiceManager stores all the brandinfo |
|
1304 // related to the services configured to the phone |
|
1305 // use this to show uniform icon & name throughout PhoneBook |
|
1306 CPbk2ApplicationServices& appServices = iPbkCmd->ApplicationServices(); |
|
1307 CPbk2ServiceManager& servMan = appServices.ServiceManager(); |
|
1308 const CPbk2ServiceManager::RServicesArray& services = servMan.Services(); |
|
1309 for ( TInt i = 0; i < services.Count(); i++ ) |
|
1310 { |
|
1311 const CPbk2ServiceManager::TService& service = services[i]; |
|
1312 //Found the appropriate service info |
|
1313 if ( service.iServiceId == aServiceId ) |
|
1314 { |
|
1315 //Calculate the Size of the Bitmap for Comm Launcher |
|
1316 TRect mainPane = iPlugin.ClientRect(); |
|
1317 TAknLayoutRect listLayoutRect; |
|
1318 listLayoutRect.LayoutRect( |
|
1319 mainPane, |
|
1320 AknLayoutScalable_Avkon::list_single_large_graphic_pane_g1(0).LayoutLine() ); |
|
1321 TSize size(listLayoutRect.Rect().Size()); |
|
1322 |
|
1323 //Set the size of this bitmap. |
|
1324 //without this Cloning of bitmap will not happen |
|
1325 AknIconUtils::SetSize( service.iBitmap, size ); |
|
1326 AknIconUtils::SetSize( service.iMask, size ); |
|
1327 |
|
1328 //Trickiest Bitmap cloning |
|
1329 //No direct way of cloning a bitmap |
|
1330 aBitmap = CloneBitmapLC(size, service.iBitmap); |
|
1331 aMask = CloneBitmapLC(size, service.iMask); |
|
1332 |
|
1333 //Calculate preferred size for xsp service icons |
|
1334 AknLayoutUtils::LayoutMetricsRect( |
|
1335 AknLayoutUtils::EMainPane, mainPane ); |
|
1336 listLayoutRect.LayoutRect( |
|
1337 mainPane, |
|
1338 AknLayoutScalable_Avkon::list_single_graphic_pane_g2(0).LayoutLine() ); |
|
1339 TSize xspIconSize(listLayoutRect.Rect().Size()); |
|
1340 AknIconUtils::SetSize( service.iBitmap, xspIconSize ); |
|
1341 AknIconUtils::SetSize( service.iMask, xspIconSize ); |
|
1342 |
|
1343 aLocalisedServiceName = service.iDisplayName.AllocL(); |
|
1344 |
|
1345 CleanupStack::Pop( 2 ); //aBitmap, aMask |
|
1346 break; |
|
1347 } |
|
1348 } |
|
1349 } |
|
1350 |
|
1351 |
|
1352 // --------------------------------------------------------------------------- |
|
1353 // CCCAppCommLauncherLPadModel::HandleNotifyChange |
|
1354 // --------------------------------------------------------------------------- |
|
1355 // |
|
1356 // from MSPNotifyChangeObserver |
|
1357 void CCCAppCommLauncherLPadModel::HandleNotifyChange( TUint /*aServiceId*/ ) |
|
1358 { |
|
1359 TRAP_IGNORE ( DoHandleNotifyChangeL() ); |
|
1360 } |
|
1361 |
|
1362 // --------------------------------------------------------------------------- |
|
1363 // CCCAppCommLauncherLPadModel::DoHandleNotifyChangeL |
|
1364 // --------------------------------------------------------------------------- |
|
1365 // |
|
1366 void CCCAppCommLauncherLPadModel::DoHandleNotifyChangeL() |
|
1367 { |
|
1368 TInt buttonInfoSet = LoadVoipButtonInfoL(); |
|
1369 |
|
1370 if (!( buttonInfoSet && KVOIPButtonImageSet )) |
|
1371 { |
|
1372 //VOIP Button Image has not been set |
|
1373 //reason could be Branding ServerIssue or something else |
|
1374 //replace with default icon if this is the case |
|
1375 TInt iconInd = MapCommMethodToIcon( |
|
1376 VPbkFieldTypeSelectorFactory::EVOIPCallSelector ); |
|
1377 CGulIcon* icon = LoadIconLC( |
|
1378 EMbmPhonebook2eceQgn_prop_nrtyp_voip, |
|
1379 EMbmPhonebook2eceQgn_prop_nrtyp_voip_mask ); |
|
1380 |
|
1381 icon->SetBitmapsOwnedExternally( ETrue ); |
|
1382 |
|
1383 iButtonIconArray->At(iconInd)->SetBitmap(icon->Bitmap()); |
|
1384 iButtonIconArray->At(iconInd)->SetMask(icon->Mask()); |
|
1385 |
|
1386 CleanupStack::PopAndDestroy( icon ); |
|
1387 } |
|
1388 |
|
1389 if (!( buttonInfoSet && KVOIPButtonTextSet )) |
|
1390 { |
|
1391 //VOIP Button Text has not been set |
|
1392 //reason could be Branding ServerIssue or something else |
|
1393 //replace with default Text if this is the case |
|
1394 |
|
1395 //Replace the default button text with the branded servicename |
|
1396 for ( TInt i = 0; i < iButtonDataArray.Count(); i++ ) |
|
1397 { |
|
1398 TCommLauncherButtonData& buttonData ( iButtonDataArray[i] ); |
|
1399 |
|
1400 if ( VPbkFieldTypeSelectorFactory::EVOIPCallSelector == |
|
1401 iButtonDataArray[i].iContactAction ) |
|
1402 { |
|
1403 HBufC* str = StringLoader::LoadLC( R_QTN_CCA_VOIP_CALL, |
|
1404 &iCoeEnv ); |
|
1405 |
|
1406 buttonData.iText.Copy( str->Left( KCCAppCommLauncherMaxButtonDataTextLength ) ); |
|
1407 CleanupStack::PopAndDestroy(); //str |
|
1408 break; |
|
1409 } |
|
1410 } |
|
1411 } |
|
1412 |
|
1413 iContainer.DrawDeferred(); |
|
1414 } |
|
1415 |
|
1416 |
|
1417 // --------------------------------------------------------------------------- |
|
1418 // CCCAppCommLauncherLPadModel::HandleError |
|
1419 // --------------------------------------------------------------------------- |
|
1420 // |
|
1421 // from MSPNotifyChangeObserver |
|
1422 void CCCAppCommLauncherLPadModel::HandleError( TInt /*aError*/ ) |
|
1423 { |
|
1424 } |
|
1425 |
|
1426 // --------------------------------------------------------------------------- |
|
1427 // CCCAppCommLauncherLPadModel::IfShowMultiIcon |
|
1428 // --------------------------------------------------------------------------- |
|
1429 // |
|
1430 TBool CCCAppCommLauncherLPadModel::IfShowMultiIcon(TInt aButtonIndex) const |
|
1431 { |
|
1432 TBool result = EFalse; |
|
1433 if ( iButtonDataArray[ aButtonIndex ].iNumberOfAddresses > 1 ) |
|
1434 { |
|
1435 result = ETrue; |
|
1436 } |
|
1437 return result; |
|
1438 } |
|
1439 |
|
1440 |
|
1441 // ---------------------------------------------------------- |
|
1442 // CCCAppCommLauncherLPadModel::SetTextClipDirection |
|
1443 // |
|
1444 // ---------------------------------------------------------- |
|
1445 // |
|
1446 void CCCAppCommLauncherLPadModel::SetTextClipDirection( VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aContactAction, |
|
1447 TInt aButtonIndex |
|
1448 /*CCmsContactFieldItem::TCmsContactField aCmsFieldType*/ ) |
|
1449 { |
|
1450 TCommLauncherButtonData& buttonData = iButtonDataArray[ aButtonIndex ]; |
|
1451 |
|
1452 // Phone number, email address, and sip address, clip from begining |
|
1453 if ( VPbkFieldTypeSelectorFactory::EVoiceCallSelector == aContactAction |
|
1454 || VPbkFieldTypeSelectorFactory::EUniEditorSelector == aContactAction |
|
1455 || VPbkFieldTypeSelectorFactory::EVOIPCallSelector == aContactAction |
|
1456 || VPbkFieldTypeSelectorFactory::EVideoCallSelector == aContactAction |
|
1457 || VPbkFieldTypeSelectorFactory::EEmailEditorSelector == aContactAction |
|
1458 || VPbkFieldTypeSelectorFactory::EInstantMessagingSelector == aContactAction ) |
|
1459 { |
|
1460 buttonData.iClipFromBegining = ETrue; |
|
1461 } |
|
1462 else |
|
1463 { |
|
1464 buttonData.iClipFromBegining = EFalse; |
|
1465 } |
|
1466 } |
|
1467 |
|
1468 // ---------------------------------------------------------- |
|
1469 // CCCAppCommLauncherLPadModel::ClipFromBeginning |
|
1470 // |
|
1471 // ---------------------------------------------------------- |
|
1472 // |
|
1473 TBool CCCAppCommLauncherLPadModel::ClipFromBeginning( |
|
1474 TDes& aBuffer, |
|
1475 TInt aItemIndex, |
|
1476 TInt aSubCellNumber) const |
|
1477 { |
|
1478 CAknDoubleLargeStyleListBox* listbox = |
|
1479 static_cast<CAknDoubleLargeStyleListBox*>(&iListBox); |
|
1480 |
|
1481 return AknTextUtils::ClipToFit( |
|
1482 aBuffer, |
|
1483 AknTextUtils::EClipFromBeginning, |
|
1484 listbox, |
|
1485 aItemIndex, |
|
1486 aSubCellNumber); |
|
1487 } |
|
1488 |
|
1489 |
|
1490 // End of File |