|
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: Contanct handler implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include <AknQueryDialog.h> |
|
21 #include <aknlists.h> |
|
22 #include <StringLoader.h> |
|
23 |
|
24 |
|
25 //Virtual Phonebook |
|
26 #include <CVPbkContactManager.h> |
|
27 #include <CVPbkContactStoreUriArray.h> |
|
28 #include <VPbkContactStoreUris.h> // VPbkContactStoreUris |
|
29 #include <TVPbkContactStoreUriPtr.h> // TVPbkContactStoreUriPtr |
|
30 #include <MVPbkContactOperationBase.h> |
|
31 #include <MVPbkStoreContact.h> |
|
32 #include <MVPbkFieldType.h> |
|
33 #include <VPbkEng.rsg> |
|
34 #include <CVPbkContactFieldIterator.h> |
|
35 #include <MVPbkContactFieldTextData.h> |
|
36 #include <MVPbkContactStoreList.h> |
|
37 |
|
38 // CCA Launcher view |
|
39 #include <mccaparameter.h> |
|
40 #include <ccafactory.h> |
|
41 #include <ccapbkcontextlauncher.h> |
|
42 |
|
43 |
|
44 // Phonebook 2 |
|
45 #include <CPbk2SortOrderManager.h> |
|
46 #include <MPbk2ContactNameFormatter.h> |
|
47 #include <Pbk2ContactNameFormatterFactory.h> |
|
48 |
|
49 // Send UI |
|
50 #include <sendui.h> |
|
51 #include <SendUiConsts.h> |
|
52 #include <CMessageData.h> |
|
53 |
|
54 #include <aiwdialdataext.h> |
|
55 #include <MVPbkContactLink.h> |
|
56 |
|
57 // Remote Contact Lookup |
|
58 #include <cpbk2remotecontactlookupaccounts.h> |
|
59 #include <pbk2remotecontactlookupfactory.h> |
|
60 |
|
61 |
|
62 #include <MPbkGlobalSetting.h> // Global setting data |
|
63 #include <PbkGlobalSettingFactory.h> |
|
64 |
|
65 // Aiw launcher |
|
66 #include <AiwDialDataTypes.h> |
|
67 #include <AiwContactAssignDataTypes.h> |
|
68 #include <AiwContactSelectionDataTypes.h> |
|
69 #include <AiwServiceHandler.h> |
|
70 |
|
71 // FS Email framework |
|
72 #include "cfsmailbox.h" |
|
73 |
|
74 #include <FreestyleEmailUi.rsg> |
|
75 |
|
76 #include "FreestyleEmailUiContactHandler.h" |
|
77 #include "FreestyleEmailUiCLSListsHandler.h" |
|
78 #include "FreestyleEmailUiUtilities.h" |
|
79 #include "FreestyleEmailUiLiterals.h" |
|
80 #include "FreestyleEmailUiContactHandlerObserver.h" |
|
81 #include "FreestyleEmailUiCLSItem.h" |
|
82 #include "FreestyleEmailUiAppui.h" |
|
83 |
|
84 //Constants |
|
85 const TInt KInternetCallPreferred = 1; |
|
86 |
|
87 |
|
88 CFSEmailUiContactHandler* CFSEmailUiContactHandler::NewL( RFs& aSession ) |
|
89 { |
|
90 FUNC_LOG; |
|
91 CFSEmailUiContactHandler* self = CFSEmailUiContactHandler::NewLC( aSession ); |
|
92 CleanupStack::Pop(self); |
|
93 return self; |
|
94 } |
|
95 |
|
96 CFSEmailUiContactHandler* CFSEmailUiContactHandler::NewLC( RFs& aSession ) |
|
97 { |
|
98 FUNC_LOG; |
|
99 CFSEmailUiContactHandler* self = new (ELeave) CFSEmailUiContactHandler( aSession ); |
|
100 CleanupStack::PushL(self); |
|
101 self->ConstructL( aSession ); |
|
102 return self; |
|
103 } |
|
104 |
|
105 CFSEmailUiContactHandler::~CFSEmailUiContactHandler() |
|
106 { |
|
107 FUNC_LOG; |
|
108 delete iContactForMsgCreation; |
|
109 if (iPersistentSetting) |
|
110 { |
|
111 iPersistentSetting->Close(); |
|
112 delete iPersistentSetting; |
|
113 } |
|
114 delete iClsListHandler; |
|
115 delete iContactManager; |
|
116 delete iServiceHandler; |
|
117 |
|
118 ResetFieldIds(); |
|
119 |
|
120 delete iPreviousEmailAddress; |
|
121 delete iSearchMatch; |
|
122 |
|
123 iContactObjects.ResetAndDestroy(); |
|
124 |
|
125 delete iLinksSet; |
|
126 delete iLinkOperation; |
|
127 delete iLinkOperationFetch; |
|
128 delete iCurrentLink; |
|
129 delete iLastClsItem; |
|
130 |
|
131 if ( iConnection ) |
|
132 { |
|
133 iConnection->Close(); |
|
134 } |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CFSEmailUiContactHandler::AddToContactL |
|
139 // ----------------------------------------------------------------------------- |
|
140 void CFSEmailUiContactHandler::AddToContactL( const TDesC& aDes, |
|
141 TContactUpdateType aUpdateType, |
|
142 TAddToContactsType aAddToContactsType, |
|
143 MFSEmailUiContactHandlerObserver* aObserver ) |
|
144 { |
|
145 FUNC_LOG; |
|
146 if ( iState == EContactHandlerIdle ) //Check that there are no other request on going |
|
147 { |
|
148 iState = EContactHandlerAddToContacts; |
|
149 iHandlerObserver = aObserver; //Can be null |
|
150 TUint assignFlags = 0; |
|
151 if ( aAddToContactsType == EContactHandlerCreateNewContact ) |
|
152 { |
|
153 // In case of EUpdateExisting, we don't have to do anything as default is updateexisting |
|
154 assignFlags = AiwContactAssign::ECreateNewContact; |
|
155 } |
|
156 |
|
157 CAiwGenericParamList& inParamList = |
|
158 iServiceHandler->InParamListL(); |
|
159 |
|
160 inParamList.AppendL( |
|
161 TAiwGenericParam( |
|
162 EGenericParamContactAssignData, |
|
163 TAiwVariant(AiwContactAssign::TAiwSingleContactAssignDataV1Pckg( |
|
164 AiwContactAssign::TAiwSingleContactAssignDataV1().SetFlags(assignFlags))))); |
|
165 |
|
166 TGenericParamIdValue updateType; |
|
167 if ( aUpdateType == EContactUpdateEmail ) |
|
168 { |
|
169 updateType = EGenericParamEmailAddress; |
|
170 } |
|
171 else // EContactUpdateNumber |
|
172 { |
|
173 updateType = EGenericParamPhoneNumber; |
|
174 } |
|
175 |
|
176 inParamList.AppendL( |
|
177 TAiwGenericParam( |
|
178 updateType, |
|
179 TAiwVariant(aDes) |
|
180 )); |
|
181 |
|
182 //Async call, CallBack is HandleNotify |
|
183 iServiceHandler->ExecuteServiceCmdL( |
|
184 KAiwCmdAssign, |
|
185 inParamList, |
|
186 iServiceHandler->OutParamListL(), |
|
187 0, |
|
188 this); |
|
189 } |
|
190 } |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CFSEmailUiContactHandler::AddToContactsQueryL |
|
194 // ----------------------------------------------------------------------------- |
|
195 TBool CFSEmailUiContactHandler::AddtoContactsQueryL( TAddToContactsType& aType ) |
|
196 { |
|
197 FUNC_LOG; |
|
198 // create popup list dialog asking new/update |
|
199 // Costruct listbox and popup list |
|
200 CEikTextListBox* listbox = new ( ELeave ) CAknSinglePopupMenuStyleListBox(); |
|
201 CleanupStack::PushL( listbox ); |
|
202 |
|
203 CAknPopupList* popupList = CAknPopupList::NewL( listbox, |
|
204 R_AVKON_SOFTKEYS_SELECT_BACK ); |
|
205 |
|
206 CleanupStack::PushL( popupList ); |
|
207 listbox->ConstructL( popupList, CEikListBox::ELeftDownInViewRect ); |
|
208 |
|
209 listbox->CreateScrollBarFrameL(ETrue); |
|
210 listbox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
211 CEikScrollBarFrame::EOff, |
|
212 CEikScrollBarFrame::EAuto ); |
|
213 |
|
214 // Get list item array and put all removable theme names in it. |
|
215 MDesCArray* itemList = listbox->Model()->ItemTextArray(); |
|
216 CDesCArray* listitems = static_cast< CDesCArray* >( itemList ); |
|
217 |
|
218 // Load title for popup list. |
|
219 HBufC* resource = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_VIEWER_ADD_TO_CONTACTS ); |
|
220 popupList->SetTitleL( *resource ); |
|
221 CleanupStack::PopAndDestroy( resource ); |
|
222 |
|
223 // Load and append actual selection lines |
|
224 resource = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_VIEWER_CREATE_NEW_CONTACT ); |
|
225 listitems->AppendL( *resource ); |
|
226 CleanupStack::PopAndDestroy( resource ); |
|
227 |
|
228 resource = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_VIEWER_UPDATE_EXISTING ); |
|
229 listitems->AppendL( *resource ); |
|
230 CleanupStack::PopAndDestroy( resource ); |
|
231 |
|
232 TBool returnValue = EFalse; |
|
233 // Execute popup list. |
|
234 if ( popupList->ExecuteLD() ) |
|
235 { |
|
236 if ( !listbox->CurrentItemIndex() ) |
|
237 { |
|
238 aType = EContactHandlerCreateNewContact; |
|
239 } |
|
240 else |
|
241 { |
|
242 //UpdateExisting is "default" so no flags are needed |
|
243 aType = EContactHandlerUpdateExisting; |
|
244 } |
|
245 returnValue = ETrue; //User pressed OK |
|
246 } |
|
247 CleanupStack::Pop( popupList ); |
|
248 CleanupStack::PopAndDestroy( listbox ); |
|
249 |
|
250 return returnValue; |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------------------------- |
|
254 // CFSEmailUiContactHandler::FindAndCallToContactByEmailL |
|
255 // --------------------------------------------------------------------------- |
|
256 // |
|
257 void CFSEmailUiContactHandler::FindAndCallToContactByEmailL( |
|
258 const TDesC& aEmailAddress, CFSMailBox* aMailBox, |
|
259 MFSEmailUiContactHandlerObserver* aObserver, TBool aUseSenderText ) |
|
260 { |
|
261 FUNC_LOG; |
|
262 if ( iOpenComplete && (iState == EContactHandlerIdle) ) //If contact stores all ready |
|
263 { |
|
264 |
|
265 iState = EContactHandlerCallToContactByEmail; |
|
266 iHandlerObserver = aObserver; |
|
267 iUseSenderText = aUseSenderText; |
|
268 iMailBox = aMailBox; |
|
269 |
|
270 FindContactLinkL( aEmailAddress ); |
|
271 |
|
272 } |
|
273 } |
|
274 |
|
275 |
|
276 // ----------------------------------------------------------------------------- |
|
277 // CFSEmailUiContactHandler::FindAndCreateMsgToContactByEmailL |
|
278 // ----------------------------------------------------------------------------- |
|
279 void CFSEmailUiContactHandler::FindAndCreateMsgToContactByEmailL( const TDesC& aEmailAddress, |
|
280 CFSMailBox* aMailBox ) |
|
281 { |
|
282 FUNC_LOG; |
|
283 if ( iOpenComplete && (iState == EContactHandlerIdle) ) //If contact stores all ready |
|
284 { |
|
285 |
|
286 iState = EContactHandlerCreateMessage; |
|
287 iMailBox = aMailBox; |
|
288 |
|
289 FindContactLinkL( aEmailAddress ); |
|
290 |
|
291 } |
|
292 } |
|
293 |
|
294 |
|
295 |
|
296 // --------------------------------------------------------------------------- |
|
297 // Searches for the contact if necessary and shows the contact details. |
|
298 // --------------------------------------------------------------------------- |
|
299 // |
|
300 void CFSEmailUiContactHandler::ShowContactDetailsL( const TDesC& aAddress, |
|
301 TContactUpdateType /*aType*/, MFSEmailUiContactHandlerObserver* aObserver ) |
|
302 { |
|
303 FUNC_LOG; |
|
304 iHandlerObserver = aObserver; |
|
305 iState = EContactHandlerShowContactDetails; |
|
306 |
|
307 FindContactLinkL( aAddress ); |
|
308 |
|
309 } |
|
310 |
|
311 |
|
312 void CFSEmailUiContactHandler::MakeAiwCallL(MVPbkContactLink* aContactLink, |
|
313 const TDesC& aContactNumber, |
|
314 TBool aVoipOverride ) |
|
315 { |
|
316 FUNC_LOG; |
|
317 CAiwDialDataExt* dialData = CAiwDialDataExt::NewLC(); |
|
318 dialData->SetWindowGroup( CCoeEnv::Static()->RootWin().Identifier() ); |
|
319 |
|
320 HBufC8* linkBuffer(NULL); |
|
321 |
|
322 if( aContactLink ) |
|
323 { |
|
324 linkBuffer = aContactLink->PackLC(); |
|
325 dialData->SetContactLinkL( *linkBuffer ); |
|
326 // Contact link exists, check if voip is preferred |
|
327 // Create iPersistentSetting here only when needed for the first time |
|
328 if ( !iPersistentSetting ) |
|
329 { |
|
330 iPersistentSetting = |
|
331 PbkGlobalSettingFactory::CreatePersistentSettingL(); |
|
332 iPersistentSetting-> |
|
333 ConnectL(MPbkGlobalSetting::ERichCallSettingsCategory); |
|
334 } |
|
335 if ( aVoipOverride || SelectBetweenCsAndVoip() == EAiwVoIPCall ) |
|
336 { |
|
337 dialData->SetCallType( CAiwDialData::EAIWVoiP ); |
|
338 } |
|
339 // <cmail> video call |
|
340 else if ( iVideoCall ) |
|
341 { |
|
342 iVideoCall = EFalse; |
|
343 dialData->SetCallType( CAiwDialData::EAIWForcedVideo ); |
|
344 } |
|
345 // </cmail> |
|
346 else |
|
347 { |
|
348 dialData->SetCallType( CAiwDialData::EAIWVoice ); |
|
349 } |
|
350 } |
|
351 else |
|
352 { |
|
353 if ( aVoipOverride ) |
|
354 { |
|
355 dialData->SetCallType( CAiwDialData::EAIWVoiP ); |
|
356 } |
|
357 // <cmail> video call |
|
358 else if ( iVideoCall ) |
|
359 { |
|
360 iVideoCall = EFalse; |
|
361 dialData->SetCallType( CAiwDialData::EAIWForcedVideo ); |
|
362 } |
|
363 // </cmail> |
|
364 else |
|
365 { |
|
366 dialData->SetCallType( CAiwDialData::EAIWVoice ); |
|
367 } |
|
368 dialData->SetPhoneNumberL( aContactNumber ); |
|
369 } |
|
370 |
|
371 CAiwGenericParamList& inParamList = iServiceHandler->InParamListL(); |
|
372 dialData->FillInParamListL( inParamList ); |
|
373 if( aContactLink ) |
|
374 { |
|
375 CleanupStack::PopAndDestroy( linkBuffer ); |
|
376 } |
|
377 |
|
378 CleanupStack::PopAndDestroy( dialData ); |
|
379 |
|
380 iServiceHandler->ExecuteServiceCmdL( |
|
381 KAiwCmdCall, |
|
382 inParamList, |
|
383 iServiceHandler->OutParamListL(), |
|
384 0, |
|
385 NULL ); |
|
386 if ( iHandlerObserver ) |
|
387 { |
|
388 RPointerArray<CFSEmailUiClsItem> emptyArray; |
|
389 iHandlerObserver->OperationCompleteL( EFindAndCallToContactByEmailL, emptyArray ); |
|
390 emptyArray.Close(); |
|
391 iHandlerObserver = NULL; |
|
392 } |
|
393 iState = EContactHandlerIdle; |
|
394 } |
|
395 |
|
396 |
|
397 TInt CFSEmailUiContactHandler::SelectBetweenCsAndVoip() const |
|
398 { |
|
399 FUNC_LOG; |
|
400 // Default to voice call |
|
401 TInt ret = EAiwVoice; |
|
402 |
|
403 TInt preferred = KErrNotFound; |
|
404 if ( iPersistentSetting ) |
|
405 { |
|
406 iPersistentSetting->Get |
|
407 (MPbkGlobalSetting::EPreferredTelephony, preferred); |
|
408 } |
|
409 |
|
410 // VoIP type is preferred only if the setting is, |
|
411 // KInternetCallPreferred. In other cases, like when the setting |
|
412 // is not found, voice call is preferred. |
|
413 switch (preferred) |
|
414 { |
|
415 case KInternetCallPreferred: |
|
416 { |
|
417 ret = EAiwVoIPCall; |
|
418 break; |
|
419 } |
|
420 default: |
|
421 { |
|
422 break; |
|
423 } |
|
424 } |
|
425 return ret; |
|
426 } |
|
427 |
|
428 // --------------------------------------------------------------------------- |
|
429 // Searches contacts matching the given address |
|
430 // --------------------------------------------------------------------------- |
|
431 // |
|
432 void CFSEmailUiContactHandler::SearchMatchesL( const TDesC& aText, |
|
433 MFSEmailUiContactHandlerObserver* aObserver, CFSMailBox* aMailBox, |
|
434 TInt aMode ) |
|
435 { |
|
436 FUNC_LOG; |
|
437 if ( (iState == EContactHandlerIdle) || |
|
438 (iState == EContactHandlerSearchMatches) ) |
|
439 { |
|
440 iState = EContactHandlerSearchMatches; |
|
441 iHandlerObserver = aObserver; |
|
442 |
|
443 iClsListHandler->SetCurrentMailboxL( aMailBox ); |
|
444 |
|
445 if( aMode != EModeUndefined ) |
|
446 { |
|
447 iClsListHandler->InputModeChangedL( (TKeyboardModes)aMode ); |
|
448 } |
|
449 //Async call, CallBack is ArrayUpdatedL (when error: OperationErrorL) |
|
450 iClsListHandler->SearchMatchesL( aText ); |
|
451 } |
|
452 } |
|
453 |
|
454 TBool CFSEmailUiContactHandler::IsLanguageSupportedL() |
|
455 { |
|
456 FUNC_LOG; |
|
457 return iClsListHandler->IsLanguageSupportedL(); |
|
458 } |
|
459 |
|
460 CVPbkContactManager* CFSEmailUiContactHandler::GetContactManager() |
|
461 { |
|
462 FUNC_LOG; |
|
463 return iContactManager; |
|
464 } |
|
465 |
|
466 |
|
467 void CFSEmailUiContactHandler::GetAddressesFromPhonebookL( |
|
468 MFSEmailUiContactHandlerObserver* aObserver ) |
|
469 { |
|
470 FUNC_LOG; |
|
471 if ( iState == EContactHandlerIdle ) |
|
472 { |
|
473 if ( !aObserver ) |
|
474 { |
|
475 //Request can't be fulfilled without observer |
|
476 return; |
|
477 } |
|
478 iHandlerObserver = aObserver; |
|
479 iState = EContactHandlerGetAddressesFromPhonebook; |
|
480 TUint fetchFlags = 0; |
|
481 |
|
482 iContactObjects.ResetAndDestroy(); |
|
483 |
|
484 CAiwGenericParamList& inParamList = iServiceHandler->InParamListL(); |
|
485 inParamList.AppendL( |
|
486 TAiwGenericParam( |
|
487 EGenericParamContactSelectionData, |
|
488 TAiwVariant(TAiwMultipleItemSelectionDataV1Pckg( |
|
489 TAiwMultipleItemSelectionDataV1(). |
|
490 SetAddressSelectType(EAiwEMailSelect). |
|
491 SetFlags( fetchFlags ))))); |
|
492 |
|
493 |
|
494 //Async call, CallBack is HandleNotify |
|
495 iServiceHandler->ExecuteServiceCmdL( |
|
496 KAiwCmdSelect, |
|
497 inParamList, |
|
498 iServiceHandler->OutParamListL(), |
|
499 0, |
|
500 this); |
|
501 } |
|
502 } |
|
503 |
|
504 // <cmail> video call |
|
505 // --------------------------------------------------------------------------- |
|
506 // Enables/disables video call. |
|
507 // --------------------------------------------------------------------------- |
|
508 // |
|
509 void CFSEmailUiContactHandler::SetVideoCall( TBool aState ) |
|
510 { |
|
511 iVideoCall = aState; |
|
512 } |
|
513 // </cmail> |
|
514 |
|
515 ///////////////////////////////////////////////////////////////////////////// |
|
516 // CFSEmailUiContactHandler::GetSmsAddressFromPhonebookAndSendL |
|
517 // |
|
518 ///////////////////////////////////////////////////////////////////////////// |
|
519 void CFSEmailUiContactHandler::GetSmsAddressFromPhonebookAndSendL( MVPbkContactLink* aContactLink ) |
|
520 { |
|
521 FUNC_LOG; |
|
522 if ( iState == EContactHandlerIdle ) |
|
523 { |
|
524 iState = EContactHandlerGetSmsAddressFromPhonebook; |
|
525 |
|
526 CAiwGenericParamList& inParamList = iServiceHandler->InParamListL(); |
|
527 // Set data type select |
|
528 TAiwSingleItemSelectionDataV3 dataSelect; |
|
529 dataSelect.SetAddressSelectType( EAiwPhoneNumberSelect ); |
|
530 TAiwSingleItemSelectionDataV3Pckg dataPckg( dataSelect ); |
|
531 inParamList.AppendL( TAiwGenericParam( EGenericParamContactSelectionData, |
|
532 TAiwVariant( dataPckg ))); |
|
533 |
|
534 // Append contact links |
|
535 CVPbkContactLinkArray* links = CVPbkContactLinkArray::NewLC(); |
|
536 links->AppendL( aContactLink ); // Clone ownership is transferred |
|
537 HBufC8* packedLinks = links->PackLC(); |
|
538 inParamList.AppendL( TAiwGenericParam( EGenericParamContactLinkArray, |
|
539 TAiwVariant(*packedLinks))); |
|
540 CleanupStack::PopAndDestroy( packedLinks ); |
|
541 CleanupStack::PopAndDestroy( links ); |
|
542 |
|
543 //Async call, CallBack is HandleNotify |
|
544 iServiceHandler->ExecuteServiceCmdL( |
|
545 KAiwCmdSelect, |
|
546 inParamList, |
|
547 iServiceHandler->OutParamListL(), |
|
548 0, |
|
549 this); |
|
550 } |
|
551 } |
|
552 |
|
553 ///////////////////////////////////////////////////////////////////////////// |
|
554 // CFSEmailUiContactHandler::GetMmsAddressFromPhonebookAndSendL |
|
555 // |
|
556 ///////////////////////////////////////////////////////////////////////////// |
|
557 void CFSEmailUiContactHandler::GetMmsAddressFromPhonebookAndSendL( MVPbkContactLink* aContactLink, |
|
558 TBool aIsVoiceMessage ) |
|
559 { |
|
560 FUNC_LOG; |
|
561 if ( iState == EContactHandlerIdle ) |
|
562 { |
|
563 if ( aIsVoiceMessage ) |
|
564 { |
|
565 iState = EContactHandlerGetVoiceMsgAddressFromPhonebook; |
|
566 } |
|
567 else |
|
568 { |
|
569 iState = EContactHandlerGetMmsAddressFromPhonebook; |
|
570 } |
|
571 |
|
572 CAiwGenericParamList& inParamList = iServiceHandler->InParamListL(); |
|
573 // Set data type select |
|
574 TAiwSingleItemSelectionDataV3 dataSelect; |
|
575 dataSelect.SetAddressSelectType( EAiwMMSSelect ); |
|
576 TAiwSingleItemSelectionDataV3Pckg dataPckg( dataSelect ); |
|
577 inParamList.AppendL( TAiwGenericParam( EGenericParamContactSelectionData, |
|
578 TAiwVariant( dataPckg ))); |
|
579 |
|
580 // Append contact links |
|
581 CVPbkContactLinkArray* links = CVPbkContactLinkArray::NewLC(); |
|
582 links->AppendL( aContactLink ); // Clone ownership is transferred |
|
583 HBufC8* packedLinks = links->PackLC(); |
|
584 inParamList.AppendL( TAiwGenericParam( EGenericParamContactLinkArray, |
|
585 TAiwVariant(*packedLinks))); |
|
586 CleanupStack::PopAndDestroy( packedLinks ); |
|
587 CleanupStack::PopAndDestroy( links ); |
|
588 |
|
589 //Async call, CallBack is HandleNotify |
|
590 iServiceHandler->ExecuteServiceCmdL( |
|
591 KAiwCmdSelect, |
|
592 inParamList, |
|
593 iServiceHandler->OutParamListL(), |
|
594 0, |
|
595 this); |
|
596 } |
|
597 } |
|
598 |
|
599 ///////////////////////////////////////////////////////////////////////////// |
|
600 // CFSEmailUiContactHandler::ArrayUpdatedL |
|
601 // |
|
602 ///////////////////////////////////////////////////////////////////////////// |
|
603 void CFSEmailUiContactHandler::ArrayUpdatedL( |
|
604 const RPointerArray<CFSEmailUiClsItem>& aMatchingItems ) |
|
605 { |
|
606 FUNC_LOG; |
|
607 |
|
608 switch ( iState ) |
|
609 { |
|
610 case EContactHandlerCreateMessage: |
|
611 CreateMessageL( aMatchingItems ); |
|
612 break; |
|
613 case EContactHandlerCallToContactByEmail: |
|
614 if ( aMatchingItems.Count() ) |
|
615 { |
|
616 delete iLastClsItem; |
|
617 iLastClsItem = NULL; |
|
618 iLastClsItem = aMatchingItems[0]->CloneLC(); |
|
619 CleanupStack::Pop(); |
|
620 } |
|
621 HandleCallL( aMatchingItems ); |
|
622 break; |
|
623 case EContactHandlerShowContactDetails: |
|
624 ShowDetailsL( aMatchingItems ); |
|
625 break; |
|
626 case EContactHandlerSearchMatches: |
|
627 if ( aMatchingItems.Count() == 1 ) |
|
628 { |
|
629 if ( !iSearchMatch ) |
|
630 { |
|
631 iSearchMatch = CFSEmailUiClsItem::NewL(); |
|
632 } |
|
633 iSearchMatch->SetDisplayNameL( aMatchingItems[0]->DisplayName() ); |
|
634 iSearchMatch->SetEmailAddressL( aMatchingItems[0]->EmailAddress() ); |
|
635 } |
|
636 else |
|
637 { |
|
638 delete iSearchMatch; |
|
639 iSearchMatch = NULL; |
|
640 } |
|
641 |
|
642 // The ownership of the array content is transferred to observer. |
|
643 iState = EContactHandlerIdle; |
|
644 if ( iHandlerObserver ) |
|
645 { |
|
646 iHandlerObserver->OperationCompleteL( ESearchContacts, aMatchingItems ); |
|
647 } |
|
648 break; |
|
649 default: |
|
650 break; |
|
651 } |
|
652 |
|
653 } |
|
654 |
|
655 void CFSEmailUiContactHandler::OperationErrorL( TInt aErrorCode ) |
|
656 { |
|
657 FUNC_LOG; |
|
658 if ( iHandlerObserver ) |
|
659 { |
|
660 // KerrNotReady --> caching in progress, KErrNotFound --> caching not started yet |
|
661 if ( (aErrorCode == KErrNotReady) || (aErrorCode == KErrNotFound) ) |
|
662 { |
|
663 iCachingInProgressError = ETrue; |
|
664 iState = EContactHandlerIdle; |
|
665 iHandlerObserver->OperationErrorL( ESearchContacts, aErrorCode ); |
|
666 } |
|
667 else if ( aErrorCode == KErrNone ) |
|
668 { |
|
669 // handle only if caching was in progress |
|
670 if ( iCachingInProgressError ) |
|
671 { |
|
672 iCachingInProgressError = EFalse; |
|
673 iState = EContactHandlerIdle; |
|
674 iHandlerObserver->OperationErrorL( ESearchContacts, aErrorCode ); |
|
675 } |
|
676 } |
|
677 else |
|
678 { |
|
679 iState = EContactHandlerIdle; |
|
680 iHandlerObserver->OperationErrorL( ESearchContacts, aErrorCode ); |
|
681 } |
|
682 } |
|
683 else |
|
684 { |
|
685 iState = EContactHandlerIdle; |
|
686 } |
|
687 } |
|
688 |
|
689 |
|
690 void CFSEmailUiContactHandler::VPbkSingleContactOperationComplete( |
|
691 MVPbkContactOperationBase& aOperation, |
|
692 MVPbkStoreContact* aContact ) |
|
693 { |
|
694 FUNC_LOG; |
|
695 //inform also client in case of error to enable client's actions (i.e. return search priority) |
|
696 // TRAP_IGNORE( VPbkSingleContactOperationCompleteL( aOperation, aContact) ); |
|
697 TRAPD(error, VPbkSingleContactOperationCompleteL( aOperation, aContact) ); |
|
698 if ( error != KErrNone ) |
|
699 { |
|
700 TRAP_IGNORE(ObserverOperationErrorL( CurrentCommand(), error )); |
|
701 } |
|
702 // |
|
703 } |
|
704 |
|
705 void CFSEmailUiContactHandler::VPbkSingleContactOperationCompleteL( |
|
706 MVPbkContactOperationBase& aOperation, |
|
707 MVPbkStoreContact* aContact ) |
|
708 { |
|
709 FUNC_LOG; |
|
710 |
|
711 if ( (iLinkOperationFetch == &aOperation) && iState == EContactHandlerGetAddressesFromPhonebook ) |
|
712 { |
|
713 CleanupDeletePushL( aContact ); |
|
714 |
|
715 RPointerArray<HBufC> firstname; |
|
716 CleanupResetAndDestroyClosePushL( firstname ); |
|
717 RPointerArray<HBufC> lastname; |
|
718 CleanupResetAndDestroyClosePushL( lastname ); |
|
719 RPointerArray<HBufC> emailAddresses; |
|
720 CleanupResetAndDestroyClosePushL( emailAddresses ); |
|
721 GetContactFieldsL( iFirstnameFields, firstname, aContact ); |
|
722 GetContactFieldsL( iLastnameFields, lastname, aContact ); |
|
723 |
|
724 // Create display name, this will be used in UI. |
|
725 TInt dispNameLength = 1; |
|
726 if ( firstname.Count() ) dispNameLength += firstname[0]->Length(); |
|
727 if ( lastname.Count() ) dispNameLength += lastname[0]->Length(); |
|
728 HBufC* displayname = HBufC::NewLC( dispNameLength ); |
|
729 |
|
730 if ( firstname.Count() ) |
|
731 { |
|
732 displayname->Des().Copy( *firstname[0] ); |
|
733 displayname->Des().Append( KSpace ); |
|
734 } |
|
735 if ( lastname.Count() ) |
|
736 { |
|
737 displayname->Des().Append( *lastname[0] ); |
|
738 } |
|
739 |
|
740 // retrieve selected email address |
|
741 MVPbkStoreContactFieldCollection& fields = aContact->Fields(); |
|
742 MVPbkBaseContactField* selectedField = fields.RetrieveField( *iCurrentLink ); |
|
743 HBufC* selectedEmailAddress = MVPbkContactFieldTextData::Cast( |
|
744 selectedField->FieldData() ).Text().AllocLC(); |
|
745 |
|
746 //check number of email addreses |
|
747 GetContactFieldsL( iEmailFields, emailAddresses, aContact ); |
|
748 // create contact object |
|
749 CFSEmailUiClsItem* item = CFSEmailUiClsItem::NewLC(); |
|
750 |
|
751 if ( emailAddresses.Count() > 1 ) |
|
752 { |
|
753 item->SetMultipleEmails( ETrue ); |
|
754 } |
|
755 |
|
756 item->SetDisplayNameL( displayname->Des() ); |
|
757 item->SetEmailAddressL( *selectedEmailAddress ); |
|
758 CleanupStack::Pop( item ); |
|
759 iContactObjects.Append( item ); |
|
760 |
|
761 CleanupStack::PopAndDestroy( selectedEmailAddress ); |
|
762 selectedEmailAddress = NULL; |
|
763 |
|
764 |
|
765 CleanupStack::PopAndDestroy( displayname ); |
|
766 CleanupStack::PopAndDestroy( &emailAddresses ); |
|
767 CleanupStack::PopAndDestroy( &lastname ); |
|
768 CleanupStack::PopAndDestroy( &firstname ); |
|
769 CleanupStack::PopAndDestroy( aContact ); |
|
770 |
|
771 // Get index of Next ContactLink if there's no LinkSet |
|
772 // or iCurrenLink index is set to 0 |
|
773 TInt index = (iLinksSet && iCurrentLink ? iLinksSet->Find |
|
774 (*iCurrentLink) + 1 : 0); |
|
775 |
|
776 if (iLinksSet && index < iLinksSet->Count()) |
|
777 { |
|
778 iCurrentLink = &iLinksSet->At(index); |
|
779 delete iLinkOperationFetch; |
|
780 iLinkOperationFetch = NULL; |
|
781 |
|
782 //Async operation, callback VPbkSingleContactOperationCompleteL |
|
783 //Error situations: VPbkSingleContactOperationFailed |
|
784 iLinkOperationFetch = iContactManager->RetrieveContactL( |
|
785 *iCurrentLink, *this); |
|
786 } |
|
787 else |
|
788 { |
|
789 delete iLinkOperationFetch; |
|
790 iLinkOperationFetch = NULL; |
|
791 |
|
792 iCurrentLink = NULL; |
|
793 iState = EContactHandlerIdle; |
|
794 delete iLinksSet; |
|
795 iLinksSet = NULL; |
|
796 |
|
797 if ( iHandlerObserver ) |
|
798 { |
|
799 iHandlerObserver->OperationCompleteL( EGetAddressesFromPhonebook, iContactObjects ); |
|
800 iContactObjects.ResetAndDestroy(); |
|
801 iHandlerObserver = NULL; |
|
802 } |
|
803 } |
|
804 } |
|
805 |
|
806 else if ( (iLinkOperationFetch == &aOperation) && (iState == EContactHandlerCallToContactByEmail ) ) |
|
807 { |
|
808 CleanupDeletePushL( aContact ); |
|
809 |
|
810 RPointerArray<HBufC> phonenumbers; |
|
811 CleanupResetAndDestroyClosePushL( phonenumbers ); |
|
812 GetContactFieldsL( iPhoneNumberFields, phonenumbers, aContact ); |
|
813 TInt phoneNumbersAvailable = phonenumbers.Count(); |
|
814 CleanupStack::PopAndDestroy( &phonenumbers ); |
|
815 |
|
816 if ( phoneNumbersAvailable ) |
|
817 { |
|
818 if ( CallQueryL( iLastClsItem->DisplayName() ) ) |
|
819 { |
|
820 MakeAiwCallL( iLastClsItem->ContactLink(), KNullDesC ); |
|
821 } |
|
822 else |
|
823 { |
|
824 // user cancelled operation - inform client to enable its actions (i.e. return search priority) |
|
825 ObserverOperationErrorL( EFindAndCallToContactByEmailL, KErrCancel ); |
|
826 iState = EContactHandlerIdle; |
|
827 } |
|
828 } |
|
829 else |
|
830 { |
|
831 if ( IsRemoteLookupSupported() ) |
|
832 { |
|
833 RemoteContactQueryL(); |
|
834 } |
|
835 else |
|
836 { |
|
837 TFsEmailUiUtility::ShowErrorNoteL( R_FREESTYLE_EMAIL_UI_VIEWER_NO_PHONE_NUMBER ); |
|
838 //no phone number found - inform client to enable its actions (i.e. return search priority) |
|
839 ObserverOperationErrorL( EFindAndCallToContactByEmailL, KErrNotFound ); |
|
840 } |
|
841 iState = EContactHandlerIdle; |
|
842 } |
|
843 |
|
844 CleanupStack::PopAndDestroy( aContact ); |
|
845 } |
|
846 // Addition to get contact for message creation. |
|
847 else if ( (iLinkOperationFetch == &aOperation) && ( iMsgCreationHelperState == EContactHandlerGetSmsAddressFromPhonebook || |
|
848 iMsgCreationHelperState == EContactHandlerGetMmsAddressFromPhonebook || iMsgCreationHelperState == EContactHandlerGetVoiceMsgAddressFromPhonebook ) ) |
|
849 { |
|
850 if ( iContactForMsgCreation ) |
|
851 { |
|
852 delete iContactForMsgCreation; |
|
853 iContactForMsgCreation = NULL; |
|
854 } |
|
855 // Check that we have a contact for message creatiun |
|
856 if ( aContact ) |
|
857 { |
|
858 // State is now idle. |
|
859 iState = EContactHandlerIdle; |
|
860 // Store contact |
|
861 iContactForMsgCreation = aContact; |
|
862 // Create clonelink for address selection |
|
863 MVPbkContactLink* cloneLink = iCurrentLink->CloneLC(); |
|
864 CleanupStack::Pop(); |
|
865 switch ( iMsgCreationHelperState ) |
|
866 { |
|
867 case EContactHandlerGetSmsAddressFromPhonebook: |
|
868 // Select SMS address, sending is done when callback completes |
|
869 GetSmsAddressFromPhonebookAndSendL( cloneLink ); |
|
870 break; |
|
871 case EContactHandlerGetMmsAddressFromPhonebook: |
|
872 // Select MMS address, sending is done when callback completes |
|
873 GetMmsAddressFromPhonebookAndSendL( cloneLink, EFalse ); |
|
874 break; |
|
875 case EContactHandlerGetVoiceMsgAddressFromPhonebook: |
|
876 // Select Voice MSG address, sending is done when callback completes |
|
877 GetMmsAddressFromPhonebookAndSendL( cloneLink, ETrue ); |
|
878 break; |
|
879 default: |
|
880 iState = EContactHandlerIdle; |
|
881 iMsgCreationHelperState = EContactHandlerIdle; |
|
882 break; |
|
883 } |
|
884 } |
|
885 else |
|
886 { |
|
887 iMsgCreationHelperState = EContactHandlerIdle; |
|
888 iState = EContactHandlerIdle; |
|
889 } |
|
890 } |
|
891 |
|
892 } |
|
893 |
|
894 void CFSEmailUiContactHandler::VPbkSingleContactOperationFailed( |
|
895 MVPbkContactOperationBase& aOperation, TInt aError ) |
|
896 { |
|
897 FUNC_LOG; |
|
898 TRAP_IGNORE( VPbkSingleContactOperationFailedL( aOperation, aError ) ); |
|
899 } |
|
900 |
|
901 void CFSEmailUiContactHandler::VPbkSingleContactOperationFailedL( |
|
902 MVPbkContactOperationBase& /*aOperation*/, TInt aError ) |
|
903 { |
|
904 FUNC_LOG; |
|
905 iState = EContactHandlerIdle; |
|
906 if ( iHandlerObserver ) |
|
907 { |
|
908 iHandlerObserver->OperationErrorL( EFindAndCallToContactByEmailL, aError ); |
|
909 iHandlerObserver = NULL; |
|
910 } |
|
911 } |
|
912 |
|
913 |
|
914 void CFSEmailUiContactHandler::OpenComplete() |
|
915 { |
|
916 FUNC_LOG; |
|
917 if ( iStoreReady ) |
|
918 { |
|
919 iOpenComplete = ETrue; |
|
920 } |
|
921 } |
|
922 |
|
923 void CFSEmailUiContactHandler::StoreReady(MVPbkContactStore& /*aContactStore*/) |
|
924 { |
|
925 FUNC_LOG; |
|
926 iStoreReady = ETrue; |
|
927 } |
|
928 |
|
929 |
|
930 void CFSEmailUiContactHandler::StoreUnavailable(MVPbkContactStore& /*aContactStore*/, TInt /*aReason*/) |
|
931 { |
|
932 FUNC_LOG; |
|
933 iStoreReady = EFalse; |
|
934 } |
|
935 |
|
936 |
|
937 void CFSEmailUiContactHandler::HandleStoreEventL( MVPbkContactStore& /*aContactStore*/, |
|
938 TVPbkContactStoreEvent /*aStoreEvent*/) |
|
939 { |
|
940 FUNC_LOG; |
|
941 |
|
942 } |
|
943 |
|
944 // ----------------------------------------------------------------------------- |
|
945 // CFSEmailUiContactHandler::HandleNotifyL |
|
946 // ----------------------------------------------------------------------------- |
|
947 TInt CFSEmailUiContactHandler::HandleNotifyL( TInt aCmdId, TInt aEventId, |
|
948 CAiwGenericParamList& aEventParamList, |
|
949 const CAiwGenericParamList& /*aInParamList*/) |
|
950 { |
|
951 FUNC_LOG; |
|
952 TInt result = 0; |
|
953 if ( (aCmdId == KAiwCmdAssign) && (iState == EContactHandlerAddToContacts) && |
|
954 (aEventId == KAiwEventCompleted) ) |
|
955 { |
|
956 // Add to contacts function is completed |
|
957 iState = EContactHandlerIdle; |
|
958 if ( iHandlerObserver ) |
|
959 { |
|
960 RPointerArray<CFSEmailUiClsItem> emptyItems; |
|
961 iHandlerObserver->OperationCompleteL( EAddToContactL, emptyItems ); |
|
962 emptyItems.Close(); |
|
963 iHandlerObserver = NULL; |
|
964 } |
|
965 |
|
966 } |
|
967 else if ( (aCmdId == KAiwCmdSelect) && (iState == EContactHandlerGetAddressesFromPhonebook) && |
|
968 (aEventId == KAiwEventCompleted)) |
|
969 { |
|
970 |
|
971 TInt index = 0; |
|
972 const TAiwGenericParam* param = |
|
973 aEventParamList.FindFirst(index, EGenericParamContactLinkArray); |
|
974 if (param) |
|
975 { |
|
976 TPtrC8 contactLinks = param->Value().AsData(); |
|
977 |
|
978 iLinksSet = iContactManager->CreateLinksLC(contactLinks); |
|
979 CleanupStack::Pop(); |
|
980 if ( iLinksSet->Count() ) |
|
981 { |
|
982 iCurrentLink = &iLinksSet->At(0); |
|
983 //Async operation, callback VPbkSingleContactOperationCompleteL |
|
984 //Error situations: VPbkSingleContactOperationFailed |
|
985 iLinkOperationFetch = iContactManager->RetrieveContactL( iLinksSet->At(0), *this ); |
|
986 } |
|
987 |
|
988 iContactManager->ContactStoresL().OpenAllL( *this ); |
|
989 } |
|
990 |
|
991 } |
|
992 else if ( (aCmdId == KAiwCmdSelect) && (iState == EContactHandlerGetSmsAddressFromPhonebook) && |
|
993 (aEventId == KAiwEventCompleted)) |
|
994 { |
|
995 iState = EContactHandlerIdle; |
|
996 SendMessageL( aEventParamList, EContactHandlerGetSmsAddressFromPhonebook ); |
|
997 } |
|
998 else if ( (aCmdId == KAiwCmdSelect) && (iState == EContactHandlerGetMmsAddressFromPhonebook) && |
|
999 (aEventId == KAiwEventCompleted)) |
|
1000 { |
|
1001 iState = EContactHandlerIdle; |
|
1002 // Send SMS to contact address |
|
1003 SendMessageL( aEventParamList, EContactHandlerGetMmsAddressFromPhonebook ); |
|
1004 } |
|
1005 else if ( (aCmdId == KAiwCmdSelect) && (iState == EContactHandlerGetVoiceMsgAddressFromPhonebook) && |
|
1006 (aEventId == KAiwEventCompleted)) |
|
1007 { |
|
1008 iState = EContactHandlerIdle; |
|
1009 // Send Voice MSG to contact address |
|
1010 SendMessageL( aEventParamList, EContactHandlerGetVoiceMsgAddressFromPhonebook ); |
|
1011 } |
|
1012 |
|
1013 //Notify caller of the error |
|
1014 else if ( aEventId == KAiwEventError ) |
|
1015 { |
|
1016 iState = EContactHandlerIdle; |
|
1017 if ( iHandlerObserver ) |
|
1018 { |
|
1019 iHandlerObserver->OperationErrorL( CurrentCommand(), KErrGeneral ); |
|
1020 iHandlerObserver = NULL; |
|
1021 } |
|
1022 } |
|
1023 |
|
1024 // We don't need to check outParams, or do anything special during the exit |
|
1025 else if ( (aEventId == KAiwEventQueryExit) ) |
|
1026 { |
|
1027 result = ETrue; |
|
1028 } |
|
1029 |
|
1030 else if ( aEventId == KAiwEventOutParamCheck ) |
|
1031 { |
|
1032 result = 1; |
|
1033 } |
|
1034 else if ( aEventId == KAiwEventCanceled ) |
|
1035 { |
|
1036 iState = EContactHandlerIdle; |
|
1037 if ( iHandlerObserver ) |
|
1038 { |
|
1039 RPointerArray<CFSEmailUiClsItem> emptyItems; |
|
1040 iHandlerObserver->OperationCompleteL( CurrentCommand(), emptyItems ); |
|
1041 emptyItems.Close(); |
|
1042 iHandlerObserver = NULL; |
|
1043 } |
|
1044 } |
|
1045 |
|
1046 return result; |
|
1047 } |
|
1048 |
|
1049 |
|
1050 CFSEmailUiContactHandler::CFSEmailUiContactHandler( RFs& aSession ): |
|
1051 iState(EContactHandlerIdle), |
|
1052 iHandlerObserver(NULL), |
|
1053 iOpenComplete(EFalse), |
|
1054 iStoreReady(EFalse), |
|
1055 iUseSenderText(EFalse), |
|
1056 iFs( aSession ), |
|
1057 iCachingInProgressError(EFalse), |
|
1058 // <cmail> video call |
|
1059 iVideoCall( EFalse ) |
|
1060 // </cmail> |
|
1061 { |
|
1062 FUNC_LOG; |
|
1063 } |
|
1064 |
|
1065 void CFSEmailUiContactHandler::ConstructL( RFs& aSession ) |
|
1066 { |
|
1067 FUNC_LOG; |
|
1068 CVPbkContactStoreUriArray* uriArray = CVPbkContactStoreUriArray::NewL(); |
|
1069 CleanupStack::PushL( uriArray ); |
|
1070 TVPbkContactStoreUriPtr phoneMemoryUri( VPbkContactStoreUris::DefaultCntDbUri() ); |
|
1071 uriArray->AppendL( phoneMemoryUri ); //default contact database store uri |
|
1072 iContactManager = CVPbkContactManager::NewL( *uriArray ); |
|
1073 |
|
1074 CleanupStack::PopAndDestroy( uriArray ); |
|
1075 |
|
1076 // Open all the contact stores |
|
1077 iContactManager->ContactStoresL().OpenAllL( *this ); |
|
1078 |
|
1079 iClsListHandler = CFSEmailUiClsListsHandler::NewL( aSession, iContactManager ); |
|
1080 iClsListHandler->SetObserver( this ); |
|
1081 iServiceHandler = CAiwServiceHandler::NewL(); |
|
1082 |
|
1083 iServiceHandler->AttachL( R_FSE_CONTACT_SELECTION_INTEREST ); |
|
1084 iServiceHandler->AttachL( R_FSE_CONTACT_ASSIGNMENT_INTEREST ); |
|
1085 iServiceHandler->AttachL( R_FSE_CALL_INTEREST ); |
|
1086 |
|
1087 FormatFieldIds(); |
|
1088 } |
|
1089 |
|
1090 |
|
1091 void CFSEmailUiContactHandler::HandleCallL( |
|
1092 const RPointerArray<CFSEmailUiClsItem>& aMatchingItems ) |
|
1093 { |
|
1094 FUNC_LOG; |
|
1095 |
|
1096 if ( aMatchingItems.Count() == 0 ) |
|
1097 { |
|
1098 if ( IsRemoteLookupSupported() ) |
|
1099 { |
|
1100 RemoteContactQueryL(); |
|
1101 } |
|
1102 else |
|
1103 { |
|
1104 TFsEmailUiUtility::ShowErrorNoteL( R_FREESTYLE_EMAIL_UI_VIEWER_NO_PHONE_NUMBER ); |
|
1105 } |
|
1106 // <cmail> video call flag needs to be cleared |
|
1107 iVideoCall = EFalse; |
|
1108 // </cmail> |
|
1109 iState = EContactHandlerIdle; |
|
1110 } |
|
1111 else if ( aMatchingItems.Count() > 0 ) // Call to one directly |
|
1112 { |
|
1113 // Create contact item in which to copy number or address, async operation. |
|
1114 delete iCurrentLink; |
|
1115 iCurrentLink = NULL; |
|
1116 |
|
1117 iCurrentLink = aMatchingItems[0]->ContactLink()->CloneLC(); |
|
1118 CleanupStack::Pop(); |
|
1119 if ( iLinkOperationFetch ) |
|
1120 { |
|
1121 delete iLinkOperationFetch; |
|
1122 iLinkOperationFetch = NULL; |
|
1123 } |
|
1124 |
|
1125 //Async operation, callback VPbkSingleContactOperationCompleteL |
|
1126 //Error situations: VPbkSingleContactOperationFailed |
|
1127 iLinkOperationFetch = iContactManager->RetrieveContactL |
|
1128 (*iCurrentLink, *this); |
|
1129 |
|
1130 } |
|
1131 } |
|
1132 |
|
1133 void CFSEmailUiContactHandler::CreateMessageL( const RPointerArray<CFSEmailUiClsItem>& aMatchingItems ) |
|
1134 { |
|
1135 FUNC_LOG; |
|
1136 iState = EContactHandlerIdle; |
|
1137 |
|
1138 if ( aMatchingItems.Count() == 0 ) |
|
1139 { |
|
1140 // <cmail> |
|
1141 /*if ( IsRemoteLookupSupported() ) |
|
1142 { |
|
1143 TInt answer = TFsEmailUiUtility::ShowConfirmationQueryL( R_FREESTYLE_EMAIL_FETCH_FROM_REMOTE_QUERY ); |
|
1144 if ( answer ) |
|
1145 { |
|
1146 LaunchRemoteLookupWithQueryL( *iMailBox, *iPreviousEmailAddress ); |
|
1147 } |
|
1148 } |
|
1149 else |
|
1150 { |
|
1151 // No email address found and no RCL available, send MMS to email addres |
|
1152 // using utilities class. MMS Service is validated in utilities class. |
|
1153 TFsEmailUiUtility::ShowCreateMessageQueryL( *iPreviousEmailAddress, ETrue ); |
|
1154 }*/ |
|
1155 // phone number not found for email address in contacts - |
|
1156 // no Text message available - subset of Multimedia and Voice message is displayed |
|
1157 TFsEmailUiUtility::ShowCreateMessageQueryL( *iPreviousEmailAddress, ETrue ); |
|
1158 // </cmail> |
|
1159 iState = EContactHandlerIdle; |
|
1160 } |
|
1161 else if ( aMatchingItems.Count() > 0 ) |
|
1162 { |
|
1163 CSendUi* sendUi = CSendUi::NewLC(); |
|
1164 |
|
1165 CArrayFix<TUid>* showedServicesUidArray = new( ELeave ) CArrayFixFlat<TUid>(4); |
|
1166 CleanupStack::PushL( showedServicesUidArray ); |
|
1167 |
|
1168 CDesCArrayFlat* array = new ( ELeave ) CDesCArrayFlat( 2 ); |
|
1169 CleanupStack::PushL( array ); |
|
1170 |
|
1171 TSendingCapabilities noCapabilities(0,0,0); |
|
1172 |
|
1173 if( sendUi->ValidateServiceL( KSenduiMtmSmsUid, noCapabilities ) ) |
|
1174 { |
|
1175 HBufC* textMessage = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_VIEWER_TEXT_MESSAGE ); |
|
1176 array->AppendL( *textMessage ); |
|
1177 CleanupStack::PopAndDestroy( textMessage ); |
|
1178 showedServicesUidArray->AppendL( KSenduiMtmSmsUid ); |
|
1179 } |
|
1180 if( sendUi->ValidateServiceL( KSenduiMtmMmsUid, noCapabilities ) ) |
|
1181 { |
|
1182 HBufC* multimediaMessage = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_VIEWER_MULTIMEDIA_MESSAGE ); |
|
1183 array->AppendL( *multimediaMessage ); |
|
1184 CleanupStack::PopAndDestroy( multimediaMessage ); |
|
1185 showedServicesUidArray->AppendL( KSenduiMtmMmsUid ); |
|
1186 } |
|
1187 if( sendUi->ValidateServiceL( KSenduiMtmAudioMessageUid, noCapabilities ) ) |
|
1188 { |
|
1189 HBufC* voiceMessage = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_VIEWER_VOICE_MESSAGE ); |
|
1190 array->AppendL( *voiceMessage ); |
|
1191 CleanupStack::PopAndDestroy( voiceMessage ); |
|
1192 showedServicesUidArray->AppendL( KSenduiMtmAudioMessageUid ); |
|
1193 } |
|
1194 |
|
1195 TInt selectedOption; |
|
1196 CAknListQueryDialog* dlg = new ( ELeave ) CAknListQueryDialog( &selectedOption ); |
|
1197 dlg->PrepareLC( R_MAIL_VIEWER_CREATE_MESSAGE_DIALOG ); |
|
1198 |
|
1199 dlg->SetItemTextArray( array ); |
|
1200 dlg->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
1201 TInt ret = dlg->RunLD(); |
|
1202 CleanupStack::PopAndDestroy( array ); |
|
1203 CleanupStack::PopAndDestroy( showedServicesUidArray ); |
|
1204 CleanupStack::PopAndDestroy( sendUi ); |
|
1205 |
|
1206 // Continue sending process if query is not cancelled |
|
1207 if( ret ) |
|
1208 { |
|
1209 switch ( selectedOption ) |
|
1210 { |
|
1211 case 0: |
|
1212 // Select SMS address, sending is done when callback completes |
|
1213 iMsgCreationHelperState = EContactHandlerGetSmsAddressFromPhonebook; |
|
1214 break; |
|
1215 case 1: |
|
1216 // Select MMS address, sending is done when callback completes |
|
1217 iMsgCreationHelperState = EContactHandlerGetMmsAddressFromPhonebook; |
|
1218 break; |
|
1219 case 2: |
|
1220 // Select Voice MSG address, sending is done when callback completes |
|
1221 iMsgCreationHelperState = EContactHandlerGetVoiceMsgAddressFromPhonebook; |
|
1222 break; |
|
1223 default: |
|
1224 iMsgCreationHelperState = EContactHandlerIdle; |
|
1225 break; |
|
1226 } |
|
1227 // Create contact item in which to copy number or address, async operation. |
|
1228 delete iCurrentLink; |
|
1229 iCurrentLink = NULL; |
|
1230 |
|
1231 iCurrentLink = aMatchingItems[0]->ContactLink()->CloneLC(); |
|
1232 CleanupStack::Pop(); |
|
1233 if ( iLinkOperationFetch ) |
|
1234 { |
|
1235 delete iLinkOperationFetch; |
|
1236 iLinkOperationFetch = NULL; |
|
1237 } |
|
1238 |
|
1239 //Async operation, callback VPbkSingleContactOperationCompleteL |
|
1240 //Error situations: VPbkSingleContactOperationFailed |
|
1241 iLinkOperationFetch = iContactManager->RetrieveContactL |
|
1242 (*iCurrentLink, *this); |
|
1243 } |
|
1244 } |
|
1245 } |
|
1246 |
|
1247 // ----------------------------------------------------------------------------- |
|
1248 // CFSEmailUiContactHandler::SendMessageL |
|
1249 // ----------------------------------------------------------------------------- |
|
1250 void CFSEmailUiContactHandler::SendMessageL( CAiwGenericParamList& aEventParamList, TInt aServiceType ) |
|
1251 { |
|
1252 FUNC_LOG; |
|
1253 TInt paramIndex(0); |
|
1254 iState = EContactHandlerIdle; |
|
1255 |
|
1256 const TAiwGenericParam* param = |
|
1257 aEventParamList.FindFirst( paramIndex, EGenericParamContactLinkArray ); |
|
1258 if ( param ) |
|
1259 { |
|
1260 TPtrC8 packedLinks = param->Value().AsData(); |
|
1261 if ( packedLinks.Length() > 0 ) |
|
1262 { |
|
1263 CSendUi* sendUi = CSendUi::NewLC(); |
|
1264 CMessageData* messageData = CMessageData::NewLC(); |
|
1265 MVPbkContactLinkArray* linkArray = GetContactManager()->CreateLinksLC(packedLinks); |
|
1266 MVPbkStoreContactField* field = iContactForMsgCreation->Fields().RetrieveField(linkArray->At(0)); |
|
1267 MVPbkContactFieldData& data = field->FieldData(); |
|
1268 if (data.DataType() == EVPbkFieldStorageTypeText) |
|
1269 { |
|
1270 const TDesC& dataText = MVPbkContactFieldTextData::Cast(data).Text(); |
|
1271 // Get contact alias to message data if there is name data |
|
1272 //RFs& rFs = CEikonEnv::Static()->FsSession(); |
|
1273 //User::LeaveIfError(rFs.Connect()); |
|
1274 CPbk2SortOrderManager* sortOrderManager = |
|
1275 CPbk2SortOrderManager::NewL(iContactManager->FieldTypes(), &iFs); |
|
1276 MPbk2ContactNameFormatter* nameFormatter = |
|
1277 Pbk2ContactNameFormatterFactory::CreateL(iContactManager->FieldTypes(), *sortOrderManager, &iFs); |
|
1278 HBufC* nameBuffer = nameFormatter->GetContactTitleL( iContactForMsgCreation->Fields(), 0); |
|
1279 |
|
1280 delete sortOrderManager; |
|
1281 sortOrderManager = NULL; |
|
1282 delete nameFormatter; |
|
1283 nameFormatter = NULL; |
|
1284 |
|
1285 //rFs.Close(); |
|
1286 if ( nameBuffer ) |
|
1287 { |
|
1288 CleanupStack::PushL( nameBuffer ); |
|
1289 messageData->AppendToAddressL( dataText, *nameBuffer ); |
|
1290 CleanupStack::PopAndDestroy( nameBuffer ); |
|
1291 } |
|
1292 else |
|
1293 { |
|
1294 messageData->AppendToAddressL( dataText ); |
|
1295 } |
|
1296 // Send selected message |
|
1297 TSendingCapabilities noCapabilities(0,0,0); |
|
1298 switch ( aServiceType ) |
|
1299 { |
|
1300 case EContactHandlerGetSmsAddressFromPhonebook: |
|
1301 { |
|
1302 if( sendUi->ValidateServiceL( KSenduiMtmSmsUid, noCapabilities ) ) |
|
1303 { |
|
1304 sendUi->CreateAndSendMessageL( KSenduiMtmSmsUid, messageData, KNullUid, EFalse ); |
|
1305 } |
|
1306 } |
|
1307 break; |
|
1308 case EContactHandlerGetMmsAddressFromPhonebook: |
|
1309 { |
|
1310 if( sendUi->ValidateServiceL( KSenduiMtmMmsUid, noCapabilities ) ) |
|
1311 { |
|
1312 sendUi->CreateAndSendMessageL( KSenduiMtmMmsUid, messageData, KNullUid, EFalse ); |
|
1313 } |
|
1314 } |
|
1315 break; |
|
1316 case EContactHandlerGetVoiceMsgAddressFromPhonebook: |
|
1317 { |
|
1318 if( sendUi->ValidateServiceL( KSenduiMtmAudioMessageUid, noCapabilities ) ) |
|
1319 { |
|
1320 sendUi->CreateAndSendMessageL( KSenduiMtmAudioMessageUid, messageData, KNullUid, EFalse ); |
|
1321 } |
|
1322 } |
|
1323 break; |
|
1324 default: |
|
1325 break; |
|
1326 } |
|
1327 } |
|
1328 CleanupStack::PopAndDestroy( 3 ); // Sendui, messageData and linkArray. |
|
1329 } |
|
1330 } |
|
1331 } |
|
1332 // --------------------------------------------------------------------------- |
|
1333 // CFSEmailUiContactHandler::IsRemoteLookupSupported |
|
1334 // --------------------------------------------------------------------------- |
|
1335 // |
|
1336 TBool CFSEmailUiContactHandler::IsRemoteLookupSupported() |
|
1337 { |
|
1338 FUNC_LOG; |
|
1339 TBool supported = iMailBox && |
|
1340 iMailBox->HasCapability( EFSMBoxCapaSupportsRCL ); |
|
1341 return supported; |
|
1342 } |
|
1343 |
|
1344 |
|
1345 void CFSEmailUiContactHandler::GetContactFieldsL( RArray<TInt>& aFieldIds, |
|
1346 RPointerArray<HBufC>& aNumbers, MVPbkStoreContact* aContact) |
|
1347 { |
|
1348 FUNC_LOG; |
|
1349 for (TInt i = 0; i < aFieldIds.Count(); i++ ) |
|
1350 { |
|
1351 const MVPbkFieldType* myContactDataField = |
|
1352 iContactManager->FieldTypes().Find( aFieldIds[i] ); |
|
1353 |
|
1354 CVPbkBaseContactFieldTypeIterator* itrNumber = |
|
1355 CVPbkBaseContactFieldTypeIterator::NewLC( *myContactDataField, |
|
1356 aContact->Fields() ); |
|
1357 |
|
1358 // Iterate through each of the data fields |
|
1359 while ( itrNumber->HasNext() ) |
|
1360 { |
|
1361 const MVPbkBaseContactField* field = itrNumber->Next(); |
|
1362 |
|
1363 if ( (field->FieldData()).DataType() == EVPbkFieldStorageTypeText ) |
|
1364 { |
|
1365 HBufC* toAppend = MVPbkContactFieldTextData::Cast( |
|
1366 field->FieldData() ).Text().AllocL(); |
|
1367 |
|
1368 aNumbers.Append( toAppend ); |
|
1369 } |
|
1370 } |
|
1371 CleanupStack::PopAndDestroy( itrNumber ); |
|
1372 } |
|
1373 } |
|
1374 |
|
1375 // --------------------------------------------------------------------------- |
|
1376 // Activates phonebook view to show details of give contact |
|
1377 // --------------------------------------------------------------------------- |
|
1378 // |
|
1379 void CFSEmailUiContactHandler::ShowDetailsL( |
|
1380 const RPointerArray<CFSEmailUiClsItem>& aMatchingItems ) |
|
1381 { |
|
1382 FUNC_LOG; |
|
1383 if ( aMatchingItems.Count() && |
|
1384 aMatchingItems[0]->ContactLink() ) |
|
1385 { |
|
1386 MVPbkContactLink* contact = aMatchingItems[0]->ContactLink(); |
|
1387 HBufC8* packed = contact->PackLC(); |
|
1388 |
|
1389 HBufC16* link16 = HBufC16::NewLC(packed->Length()); |
|
1390 link16->Des().Copy(packed->Des()); |
|
1391 |
|
1392 MCCAParameter* param = TCCAFactory::NewParameterL(); |
|
1393 CleanupClosePushL( *param ); |
|
1394 |
|
1395 delete iConnection; |
|
1396 iConnection = NULL; |
|
1397 iConnection = TCCAFactory::NewConnectionL(); |
|
1398 |
|
1399 // Setting up the contact link parameter, ownership transfers |
|
1400 param->SetConnectionFlag(MCCAParameter::ENormal); |
|
1401 param->SetContactDataFlag(MCCAParameter::EContactLink); |
|
1402 param->SetContactDataL( link16->Des() ); |
|
1403 |
|
1404 // switch to details view |
|
1405 const TUid uid = TUid::Uid( 0x200159E7 ); |
|
1406 param->SetLaunchedViewUid( uid); |
|
1407 |
|
1408 // Launching the CCA application |
|
1409 iConnection->LaunchAppL( *param, this ); |
|
1410 |
|
1411 CleanupStack::Pop( param ); // parameter is taken care by MCCAConnection |
|
1412 CleanupStack::PopAndDestroy( link16 ); |
|
1413 CleanupStack::PopAndDestroy( packed ); |
|
1414 } |
|
1415 else |
|
1416 { |
|
1417 TFsEmailUiUtility::ShowErrorNoteL( |
|
1418 R_FREESTYLE_EMAIL_UI_VIEWER_NO_EMAIL_ADDRESS, EFalse ); |
|
1419 } |
|
1420 |
|
1421 iState = EContactHandlerIdle; |
|
1422 } |
|
1423 |
|
1424 // --------------------------------------------------------------------------- |
|
1425 // CFSEmailUiContactHandler::FindContactLinkL |
|
1426 // Searches contacts matching with the given email address |
|
1427 // --------------------------------------------------------------------------- |
|
1428 // |
|
1429 void CFSEmailUiContactHandler::FindContactLinkL( const TDesC& aDes ) |
|
1430 { |
|
1431 FUNC_LOG; |
|
1432 |
|
1433 // Replace email address to match with the new search |
|
1434 SetPreviousEmailAddressL( aDes ); |
|
1435 |
|
1436 // Get contact links matching the given address |
|
1437 iClsListHandler->SetCurrentMailboxL( NULL ); |
|
1438 iClsListHandler->SearchMatchesL( aDes ); |
|
1439 } |
|
1440 |
|
1441 void CFSEmailUiContactHandler::FormatFieldIds() |
|
1442 { |
|
1443 FUNC_LOG; |
|
1444 iEmailFields.Append( R_VPBK_FIELD_TYPE_EMAILGEN ); |
|
1445 iEmailFields.Append( R_VPBK_FIELD_TYPE_EMAILWORK ); |
|
1446 iEmailFields.Append( R_VPBK_FIELD_TYPE_EMAILHOME ); |
|
1447 |
|
1448 iFirstnameFields.Append( R_VPBK_FIELD_TYPE_FIRSTNAME ); |
|
1449 iLastnameFields.Append( R_VPBK_FIELD_TYPE_LASTNAME ); |
|
1450 |
|
1451 iPhoneNumberFields.Append( R_VPBK_FIELD_TYPE_LANDPHONEHOME ); |
|
1452 iPhoneNumberFields.Append( R_VPBK_FIELD_TYPE_MOBILEPHONEWORK ); |
|
1453 iPhoneNumberFields.Append( R_VPBK_FIELD_TYPE_MOBILEPHONEHOME ); |
|
1454 iPhoneNumberFields.Append( R_VPBK_FIELD_TYPE_LANDPHONEWORK ); |
|
1455 iPhoneNumberFields.Append( R_VPBK_FIELD_TYPE_LANDPHONEGEN ); |
|
1456 iPhoneNumberFields.Append( R_VPBK_FIELD_TYPE_MOBILEPHONEGEN ); |
|
1457 |
|
1458 } |
|
1459 |
|
1460 void CFSEmailUiContactHandler::ResetFieldIds() |
|
1461 { |
|
1462 FUNC_LOG; |
|
1463 iLastnameFields.Reset(); |
|
1464 iFirstnameFields.Reset(); |
|
1465 iEmailFields.Reset(); |
|
1466 iPhoneNumberFields.Reset(); |
|
1467 } |
|
1468 |
|
1469 |
|
1470 // ----------------------------------------------------------------------------- |
|
1471 // CFSEmailUiContactHandler::LaunchRemoteLookupL |
|
1472 // ----------------------------------------------------------------------------- |
|
1473 TBool CFSEmailUiContactHandler::GetNameAndEmailFromRemoteLookupL( CFSMailBox& aMailBox, |
|
1474 const TDesC& aQueryString, TDes& aDisplayname, TDes& aEmailAddress ) |
|
1475 { |
|
1476 FUNC_LOG; |
|
1477 |
|
1478 CPbkxRemoteContactLookupServiceUiContext::TResult result; |
|
1479 DoRemoteLookupL( aMailBox, aQueryString, result, |
|
1480 CPbkxRemoteContactLookupServiceUiContext::EModeContactSelector); |
|
1481 |
|
1482 if ( result.iExitReason == |
|
1483 CPbkxRemoteContactLookupServiceUiContext::TResult::EExitContactSelected ) |
|
1484 { |
|
1485 GetNameAndEmail( aDisplayname, aEmailAddress, *(result.iSelectedContactItem) ); |
|
1486 return ETrue; |
|
1487 } |
|
1488 |
|
1489 return EFalse; |
|
1490 } |
|
1491 |
|
1492 // ----------------------------------------------------------------------------- |
|
1493 // CFSEmailUiContactHandler::LaunchRemoteLookupL |
|
1494 // ----------------------------------------------------------------------------- |
|
1495 void CFSEmailUiContactHandler::LaunchRemoteLookupL( CFSMailBox& aMailBox ) |
|
1496 { |
|
1497 FUNC_LOG; |
|
1498 |
|
1499 CPbkxRemoteContactLookupServiceUiContext::TResult result; |
|
1500 DoRemoteLookupL( aMailBox, KNullDesC , result, |
|
1501 CPbkxRemoteContactLookupServiceUiContext::EModeNormal ); |
|
1502 |
|
1503 } |
|
1504 |
|
1505 // ----------------------------------------------------------------------------- |
|
1506 // CFSEmailUiContactHandler::LaunchRemoteLookupL |
|
1507 // ----------------------------------------------------------------------------- |
|
1508 HBufC* CFSEmailUiContactHandler::GetNameAndNumberFromRemoteLookupL( |
|
1509 CFSMailBox& aMailBox, const TDesC& aQuery, RBuf& aPhoneNumber ) |
|
1510 { |
|
1511 FUNC_LOG; |
|
1512 |
|
1513 CPbkxRemoteContactLookupServiceUiContext::TResult result; |
|
1514 DoRemoteLookupL( aMailBox, aQuery , result, |
|
1515 CPbkxRemoteContactLookupServiceUiContext::EModeContactSelector ); |
|
1516 |
|
1517 HBufC* displayName = NULL; |
|
1518 if ( result.iExitReason == |
|
1519 CPbkxRemoteContactLookupServiceUiContext::TResult::EExitContactSelected ) |
|
1520 { |
|
1521 displayName = GetPhoneNumberAndNameL( aPhoneNumber, *(result.iSelectedContactItem) ); |
|
1522 } |
|
1523 return displayName; |
|
1524 } |
|
1525 |
|
1526 void CFSEmailUiContactHandler::LaunchRemoteLookupWithQueryL( |
|
1527 CFSMailBox& aMailBox, const TDesC& aQuery ) |
|
1528 { |
|
1529 FUNC_LOG; |
|
1530 CPbkxRemoteContactLookupServiceUiContext::TResult result; |
|
1531 DoRemoteLookupL( aMailBox, aQuery , result, |
|
1532 CPbkxRemoteContactLookupServiceUiContext::EModeExistingCriteria ); |
|
1533 } |
|
1534 |
|
1535 HBufC* CFSEmailUiContactHandler::GetLastSearchNameL( const TDesC& aEmailAddress ) |
|
1536 { |
|
1537 FUNC_LOG; |
|
1538 HBufC* name(NULL); |
|
1539 if ( iSearchMatch ) |
|
1540 { |
|
1541 if ( !iSearchMatch->EmailAddress().CompareF( aEmailAddress ) ) |
|
1542 { |
|
1543 if ( iSearchMatch->DisplayName() != KNullDesC ) |
|
1544 { |
|
1545 name = iSearchMatch->DisplayName().AllocL(); |
|
1546 } |
|
1547 } |
|
1548 } |
|
1549 return name; |
|
1550 } |
|
1551 |
|
1552 void CFSEmailUiContactHandler::Reset() |
|
1553 { |
|
1554 FUNC_LOG; |
|
1555 iContactObjects.ResetAndDestroy(); |
|
1556 iState = EContactHandlerIdle; |
|
1557 delete iLinksSet; |
|
1558 iLinksSet = NULL; |
|
1559 delete iLinkOperation; |
|
1560 iLinkOperation = NULL; |
|
1561 delete iLinkOperationFetch; |
|
1562 iLinkOperationFetch = NULL; |
|
1563 iHandlerObserver = NULL; |
|
1564 } |
|
1565 |
|
1566 |
|
1567 // --------------------------------------------------------------------------- |
|
1568 // Gets the name and email address from given contact item |
|
1569 // --------------------------------------------------------------------------- |
|
1570 // |
|
1571 void CFSEmailUiContactHandler::GetNameAndEmail( TDes& aName, TDes& aEmail, |
|
1572 CContactItem& aItem ) const |
|
1573 { |
|
1574 FUNC_LOG; |
|
1575 CContactItemFieldSet& fieldSet = aItem.CardFields(); |
|
1576 aName.Zero(); |
|
1577 |
|
1578 RBuf familyName; |
|
1579 RBuf givenName; |
|
1580 TInt pos; |
|
1581 |
|
1582 pos = fieldSet.Find(KUidContactFieldFamilyName); |
|
1583 if (pos >= 0) |
|
1584 { |
|
1585 CContactItemField& itemField=fieldSet[pos]; |
|
1586 if (!(itemField.IsHidden()) && !(itemField.IsDisabled())) |
|
1587 { |
|
1588 CContactTextField* textField = itemField.TextStorage(); |
|
1589 familyName.Create( textField->Text() ); |
|
1590 } |
|
1591 } |
|
1592 pos = fieldSet.Find(KUidContactFieldGivenName); |
|
1593 if (pos >= 0) |
|
1594 { |
|
1595 CContactItemField& itemField=fieldSet[pos]; |
|
1596 if (!(itemField.IsHidden()) && !(itemField.IsDisabled())) |
|
1597 { |
|
1598 CContactTextField* textField = itemField.TextStorage(); |
|
1599 givenName.Create( textField->Text() ); |
|
1600 } |
|
1601 } |
|
1602 RBuf email; |
|
1603 pos = fieldSet.Find(KUidContactFieldEMail); |
|
1604 if (pos >= 0) |
|
1605 { |
|
1606 CContactItemField& itemField=fieldSet[pos]; |
|
1607 if (!(itemField.IsHidden()) && !(itemField.IsDisabled())) |
|
1608 { |
|
1609 CContactTextField* textField = itemField.TextStorage(); |
|
1610 email.Create( textField->Text() ); |
|
1611 aEmail.Copy( email ); |
|
1612 } |
|
1613 } |
|
1614 email.Close(); |
|
1615 |
|
1616 |
|
1617 if ( familyName.Length() ) |
|
1618 { |
|
1619 aName.Append(givenName); |
|
1620 aName.Trim(); |
|
1621 } |
|
1622 |
|
1623 if ( givenName.Length() ) |
|
1624 { |
|
1625 aName.Append(' '); |
|
1626 aName.Append(familyName); |
|
1627 aName.Trim(); |
|
1628 } |
|
1629 |
|
1630 givenName.Close(); |
|
1631 familyName.Close(); |
|
1632 } |
|
1633 |
|
1634 // --------------------------------------------------------------------------- |
|
1635 // Gets the phone number from given contact item |
|
1636 // --------------------------------------------------------------------------- |
|
1637 // |
|
1638 HBufC* CFSEmailUiContactHandler::GetPhoneNumberAndNameL( RBuf& aPhoneNumber, CContactItem& aItem ) const |
|
1639 { |
|
1640 FUNC_LOG; |
|
1641 TInt pos; |
|
1642 CContactItemFieldSet& fieldSet = aItem.CardFields(); |
|
1643 |
|
1644 pos = fieldSet.Find(KUidContactFieldPhoneNumber); |
|
1645 if (pos >= 0) |
|
1646 { |
|
1647 CContactItemField& itemField=fieldSet[pos]; |
|
1648 if (!(itemField.IsHidden()) && !(itemField.IsDisabled())) |
|
1649 { |
|
1650 CContactTextField* textField = itemField.TextStorage(); |
|
1651 //aPhoneNumber.Create( textField->Text()->Length() ); |
|
1652 //aPhoneNumber.Copy( textField->Text() ); |
|
1653 aPhoneNumber.Create( textField->Text() ); |
|
1654 } |
|
1655 } |
|
1656 |
|
1657 HBufC* firstname = NULL; |
|
1658 |
|
1659 pos = fieldSet.Find( KUidContactFieldGivenName ); |
|
1660 if ( pos >= 0 ) |
|
1661 { |
|
1662 CContactItemField& itemField=fieldSet[pos]; |
|
1663 if ( !itemField.IsHidden() && !itemField.IsDisabled() ) |
|
1664 { |
|
1665 CContactTextField* textField = itemField.TextStorage(); |
|
1666 firstname = textField->Text().AllocLC(); |
|
1667 } |
|
1668 } |
|
1669 if ( !firstname ) |
|
1670 { |
|
1671 firstname = KNullDesC().AllocLC(); |
|
1672 } |
|
1673 |
|
1674 HBufC* lastname = NULL; |
|
1675 |
|
1676 pos = fieldSet.Find( KUidContactFieldFamilyName ); |
|
1677 if ( pos >= 0 ) |
|
1678 { |
|
1679 CContactItemField& itemField=fieldSet[pos]; |
|
1680 if ( !itemField.IsHidden() && !itemField.IsDisabled() ) |
|
1681 { |
|
1682 CContactTextField* textField = itemField.TextStorage(); |
|
1683 lastname = textField->Text().AllocLC(); |
|
1684 } |
|
1685 } |
|
1686 if ( !lastname ) |
|
1687 { |
|
1688 lastname = KNullDesC().AllocLC(); |
|
1689 } |
|
1690 |
|
1691 HBufC* name = TFsEmailUiUtility::CreateDisplayNameLC( *firstname, *lastname, KNullDesC ); |
|
1692 CleanupStack::Pop( name ); |
|
1693 CleanupStack::PopAndDestroy( lastname ); |
|
1694 CleanupStack::PopAndDestroy( firstname ); |
|
1695 |
|
1696 return name; |
|
1697 } |
|
1698 |
|
1699 // --------------------------------------------------------------------------- |
|
1700 // CFSEmailUiContactHandler::DoRemoteLookupL |
|
1701 // --------------------------------------------------------------------------- |
|
1702 // |
|
1703 void CFSEmailUiContactHandler::DoRemoteLookupL( CFSMailBox& aMailBox, |
|
1704 const TDesC& aQueryString, |
|
1705 CPbkxRemoteContactLookupServiceUiContext::TResult& aResult, |
|
1706 CPbkxRemoteContactLookupServiceUiContext::TMode aLookupMode ) |
|
1707 { |
|
1708 FUNC_LOG; |
|
1709 TUid protocolUid = TUid::Null(); |
|
1710 TUint accountUid = 0; |
|
1711 aMailBox.GetRCLInfo( protocolUid, accountUid ); |
|
1712 const TPbkxRemoteContactLookupProtocolAccountId accountId = |
|
1713 TPbkxRemoteContactLookupProtocolAccountId( protocolUid, accountUid ); |
|
1714 |
|
1715 CPbkxRemoteContactLookupServiceUiContext::TContextParams params = |
|
1716 { accountId, aLookupMode }; |
|
1717 |
|
1718 CPbkxRemoteContactLookupServiceUiContext* context = |
|
1719 Pbk2RemoteContactLookupFactory::NewContextL( params ); |
|
1720 CleanupStack::PushL( context ); |
|
1721 |
|
1722 if ( !iEnv ) |
|
1723 { |
|
1724 iEnv = CEikonEnv::Static(); |
|
1725 } |
|
1726 |
|
1727 CFreestyleEmailUiAppUi* fsAppUi = |
|
1728 static_cast<CFreestyleEmailUiAppUi*>( iEnv->AppUi() ); |
|
1729 |
|
1730 TBool indicatorsWereOn = EFalse; |
|
1731 CCustomStatuspaneIndicators* indicators = fsAppUi->GetStatusPaneIndicatorContainer(); |
|
1732 |
|
1733 if ( indicators->IsVisible() ) |
|
1734 { |
|
1735 indicatorsWereOn = ETrue; |
|
1736 // hide message indicators |
|
1737 indicators->HideStatusPaneIndicators(); |
|
1738 } |
|
1739 |
|
1740 context->ExecuteL( aQueryString, aResult ); |
|
1741 if ( indicatorsWereOn ) |
|
1742 { |
|
1743 // show message indicators |
|
1744 indicators->ShowStatusPaneIndicators(); |
|
1745 } |
|
1746 |
|
1747 CleanupStack::PopAndDestroy( context ); |
|
1748 } |
|
1749 |
|
1750 |
|
1751 // --------------------------------------------------------------------------- |
|
1752 // Displays call query |
|
1753 // --------------------------------------------------------------------------- |
|
1754 // |
|
1755 TBool CFSEmailUiContactHandler::CallQueryL( |
|
1756 const TDesC& aDisplayName ) |
|
1757 { |
|
1758 FUNC_LOG; |
|
1759 TInt answer = 0; |
|
1760 |
|
1761 if ( aDisplayName.Length() ) |
|
1762 { |
|
1763 if ( iUseSenderText ) |
|
1764 { |
|
1765 answer = TFsEmailUiUtility::ShowConfirmationQueryL( R_FREESTYLE_EMAIL_CALL_SENDER_QUERY, |
|
1766 aDisplayName ); |
|
1767 } |
|
1768 else |
|
1769 { |
|
1770 answer = TFsEmailUiUtility::ShowConfirmationQueryL( R_FREESTYLE_EMAIL_UI_VIEWER_CALL_HOTSPOT, |
|
1771 aDisplayName ); |
|
1772 } |
|
1773 } |
|
1774 else // Show basic note if display name is not available. |
|
1775 { |
|
1776 _LIT(KEmpty, ""); |
|
1777 // Create dialog |
|
1778 CFSEmailUiCallDialog* queryNote = new ( ELeave ) CFSEmailUiCallDialog(); |
|
1779 CleanupStack::PushL( queryNote ); |
|
1780 // Createa and set text |
|
1781 HBufC* querytext = StringLoader::LoadLC( R_FREESTYLE_EMAIL_UI_VIEWER_CALL_HOTSPOT, KEmpty ); |
|
1782 TPtr pointer = querytext->Des(); |
|
1783 _LIT(KLineBreak, "\n"); |
|
1784 AknTextUtils::StripCharacters( pointer, KLineBreak ); |
|
1785 queryNote->SetPromptL( *querytext ); |
|
1786 CleanupStack::PopAndDestroy( querytext ); |
|
1787 CleanupStack::Pop( queryNote ); |
|
1788 // Show note. |
|
1789 answer = queryNote->ExecuteLD( R_FSEMAIL_QUERY_DIALOG ); |
|
1790 } |
|
1791 |
|
1792 return answer; |
|
1793 } |
|
1794 |
|
1795 |
|
1796 |
|
1797 // --------------------------------------------------------------------------- |
|
1798 // Creates copy of given CLS items and appends them to given array. |
|
1799 // --------------------------------------------------------------------------- |
|
1800 // |
|
1801 void CFSEmailUiContactHandler::CopyItemsL( |
|
1802 const RPointerArray<CFSEmailUiClsItem>& aItems, |
|
1803 RPointerArray<CFSEmailUiClsItem>& aArray ) |
|
1804 { |
|
1805 FUNC_LOG; |
|
1806 for ( TInt ii = 0; ii < aItems.Count(); ++ii ) |
|
1807 { |
|
1808 CFSEmailUiClsItem* clone = aItems[ii]->CloneLC(); |
|
1809 aArray.AppendL( clone ); |
|
1810 CleanupStack::Pop( clone ); |
|
1811 } |
|
1812 } |
|
1813 |
|
1814 // --------------------------------------------------------------------------- |
|
1815 // Sets the address used for previous contact search |
|
1816 // --------------------------------------------------------------------------- |
|
1817 // |
|
1818 void CFSEmailUiContactHandler::SetPreviousEmailAddressL( const TDesC& aAddress ) |
|
1819 { |
|
1820 FUNC_LOG; |
|
1821 delete iPreviousEmailAddress; |
|
1822 iPreviousEmailAddress = NULL; |
|
1823 iPreviousEmailAddress = aAddress.AllocL(); |
|
1824 } |
|
1825 |
|
1826 void CFSEmailUiContactHandler::RemoteContactQueryL() |
|
1827 { |
|
1828 FUNC_LOG; |
|
1829 TInt answer = TFsEmailUiUtility::ShowConfirmationQueryL( R_FREESTYLE_EMAIL_FETCH_FROM_REMOTE_QUERY ); |
|
1830 if ( answer ) |
|
1831 { |
|
1832 LaunchRemoteLookupWithQueryL( *iMailBox, *iPreviousEmailAddress ); |
|
1833 } |
|
1834 else // user cancelled operation inform client to enable its actions (i.e. return search priority) |
|
1835 { |
|
1836 ObserverOperationErrorL( CurrentCommand(), KErrCancel ); |
|
1837 } |
|
1838 |
|
1839 } |
|
1840 |
|
1841 TContactHandlerCmd CFSEmailUiContactHandler::CurrentCommand() |
|
1842 { |
|
1843 FUNC_LOG; |
|
1844 switch (iState) |
|
1845 { |
|
1846 case EContactHandlerAddToContacts: |
|
1847 return EAddToContactL; |
|
1848 case EContactHandlerSearchMatches: |
|
1849 return ESearchContacts; |
|
1850 case EContactHandlerShowContactDetails: |
|
1851 return EShowContactDetailsL; |
|
1852 case EContactHandlerGetAddressesFromPhonebook: |
|
1853 return EGetAddressesFromPhonebook; |
|
1854 case EContactHandlerCallToContactByEmail: |
|
1855 return ECallToContact; |
|
1856 case EContactHandlerCreateMessage: |
|
1857 return ECreateMessage; |
|
1858 default: |
|
1859 break; |
|
1860 } |
|
1861 return EIdle; |
|
1862 } |
|
1863 |
|
1864 void CFSEmailUiContactHandler::ClearObservers() |
|
1865 { |
|
1866 iHandlerObserver = NULL; |
|
1867 } |
|
1868 |
|
1869 // <cmail> call observer's MFSEmailUiContactHandlerObserver::OperationErrorL( TContactHandlerCmd aCmd, TInt aError ) |
|
1870 void CFSEmailUiContactHandler::ObserverOperationErrorL( TContactHandlerCmd aCmd, TInt aErrorCode ) |
|
1871 { |
|
1872 if( ( iHandlerObserver ) && ( KErrNone != aErrorCode ) ) |
|
1873 { |
|
1874 iHandlerObserver->OperationErrorL( aCmd, aErrorCode ); |
|
1875 iHandlerObserver = NULL; |
|
1876 } |
|
1877 } |
|
1878 |
|
1879 void CFSEmailUiContactHandler::CCASimpleNotifyL( TNotifyType aType, TInt /*aReason*/ ) |
|
1880 { |
|
1881 if ( MCCAObserver::EExitEvent == aType ) |
|
1882 { |
|
1883 // Calling Close() for iConnection will close the running |
|
1884 // CCApplication, so be careful when using it |
|
1885 if ( iConnection ) |
|
1886 { |
|
1887 iConnection->Close(); |
|
1888 iConnection = NULL; |
|
1889 } |
|
1890 } |
|
1891 } |