|
1 /* |
|
2 * Copyright (c) 2002-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: Main view handling for Call Divert. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "GSCallDivertContainer.h" |
|
21 #include "GSCallDivertModel.h" |
|
22 #include "GSCallDivertQuery.h" |
|
23 #include "GSCallDivertView.h" |
|
24 #include "GsLogger.h" |
|
25 #include "GSPhoneSettingConstants.h" |
|
26 #include "GSRestrictedDivertContainer.h" |
|
27 #include "LocalViewId.h" |
|
28 |
|
29 |
|
30 #include <AiwContactSelectionDataTypes.h> |
|
31 #include <AiwGenericParam.h> |
|
32 #include <aknnotewrappers.h> //for AknErrorNote |
|
33 #include <AknUtils.h> |
|
34 #include <aknViewAppUi.h> |
|
35 #include <CPbk2SortOrderManager.h> |
|
36 #include <CPbk2StoreConfiguration.h> |
|
37 #include <CPbkContactItem.h> |
|
38 #include <CPbkSingleItemFetchDlg.h> |
|
39 #include <CVPbkContactLinkArray.h> |
|
40 #include <CVPbkContactManager.h> |
|
41 #include <featmgr.h> |
|
42 #include <gscommon.hrh> |
|
43 #include <gsfwviewuids.h> // for restricted call forward |
|
44 #include <GSCallDivertPluginRsc.rsg> |
|
45 #include <MPbk2ContactNameFormatter.h> |
|
46 #include <MVPbkContactFieldData.h> |
|
47 #include <MVPbkContactFieldTextData.h> |
|
48 #include <MVPbkContactLink.h> |
|
49 #include <MVPbkContactOperationBase.h> |
|
50 #include <MVPbkContactStoreList.h> |
|
51 #include <MVPbkStoreContact.h> |
|
52 #include <NumberGrouping.h> // for Number Grouping |
|
53 #include <Pbk2ContactNameFormatterFactory.h> |
|
54 #include <PsetCallDiverting.h> |
|
55 #include <PsuiConstants.h> |
|
56 #include <RPbkViewResourceFile.h> |
|
57 #include <AiwServiceHandler.h> |
|
58 #include <coeaui.h> |
|
59 #include <CVPbkContactStoreUriArray.h> |
|
60 #include <CVPbkFieldTypeSelector.h> |
|
61 #include <hlplch.h> // for Help Launcher |
|
62 #include <hlplch.h> // For HlpLauncher |
|
63 #include <RVPbkContactFieldDefaultPriorities.h> |
|
64 #include <StringLoader.h> |
|
65 #include <VPbkContactViewFilterBuilder.h> |
|
66 #include <voicemailboxdomaincrkeys.h> |
|
67 #include <centralrepository.h> |
|
68 |
|
69 using namespace AiwContactAssign; |
|
70 |
|
71 // LOCAL CONSTANTS |
|
72 _LIT( KGSDivertClassName, "CGSCallDivertView" ); |
|
73 |
|
74 |
|
75 // ========================= MEMBER FUNCTIONS ================================ |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CGSCallDivertView::CGSCallDivertView |
|
79 // |
|
80 // C++ constructor. |
|
81 // --------------------------------------------------------------------------- |
|
82 CGSCallDivertView::CGSCallDivertView( CGSCallDivertModel* aModel ) |
|
83 : iModel( aModel ) |
|
84 { |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CGSCallDivertView::ConstructL |
|
89 // |
|
90 // Symbian OS two-phased constructor. |
|
91 // --------------------------------------------------------------------------- |
|
92 void CGSCallDivertView::ConstructL() |
|
93 { |
|
94 if( FeatureManager::FeatureSupported( KFeatureIdRestrictedCallDivert ) ) |
|
95 { |
|
96 iModel->SetDivertServiceGroup( EGSSettIdVoiceDivert ); |
|
97 } |
|
98 iModel->SetDivertView( this ); |
|
99 |
|
100 iStoresOpened = EFalse; |
|
101 iNumberFetchedAsynchronously = EFalse; |
|
102 |
|
103 BaseConstructL( R_CF_DIV_VIEW ); |
|
104 |
|
105 iTitles = iCoeEnv->ReadDesCArrayResourceL( R_TITLE_ARRAY ); |
|
106 iRockerPress = EFalse; |
|
107 |
|
108 //Check video mailbox suppport from cenrep |
|
109 //Since it is static feature, needs to be checked only once |
|
110 CRepository* videoMailboxRepository = |
|
111 CRepository::NewLC( KCRUidVideoMailbox ); |
|
112 videoMailboxRepository->Get( KVideoMbxSupport, iVideoMailboxSupported ); |
|
113 CleanupStack::PopAndDestroy( videoMailboxRepository ); |
|
114 |
|
115 // AIW for pbk2 contact selection functionality. Construct contact manager |
|
116 // with the same store configuration as in Phonebook currently. |
|
117 iServiceHandler = CAiwServiceHandler::NewL(); |
|
118 iServiceHandler->AttachL( R_CALL_DIVERT_CONTACT_SELECTION_INTEREST ); |
|
119 CPbk2StoreConfiguration* configuration = CPbk2StoreConfiguration::NewL(); |
|
120 CleanupStack::PushL( configuration ); |
|
121 CVPbkContactStoreUriArray* uriArray = configuration->CurrentConfigurationL(); |
|
122 CleanupStack::PushL( uriArray ); |
|
123 iContactManager = CVPbkContactManager::NewL( *uriArray ); |
|
124 iContactManager->ContactStoresL().OpenAllL( *this ); |
|
125 CleanupStack::PopAndDestroy( uriArray ); |
|
126 CleanupStack::PopAndDestroy( configuration ); |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------------------------- |
|
130 // CGSCallDivertView::~CGSCallDivertView |
|
131 // |
|
132 // Destructor. |
|
133 // --------------------------------------------------------------------------- |
|
134 CGSCallDivertView::~CGSCallDivertView() |
|
135 { |
|
136 if ( iTitles ) |
|
137 { |
|
138 delete iTitles; |
|
139 } |
|
140 if( iRetrieveOperation ) |
|
141 { |
|
142 delete iRetrieveOperation; |
|
143 iRetrieveOperation = NULL; |
|
144 } |
|
145 if( iContactLinks ) |
|
146 { |
|
147 delete iContactLinks; |
|
148 iContactLinks = NULL; |
|
149 } |
|
150 |
|
151 TRAP_IGNORE |
|
152 ( |
|
153 if( iContactManager ) |
|
154 { |
|
155 iContactManager->ContactStoresL().CloseAll( *this ); |
|
156 iStoresOpened = EFalse; |
|
157 delete iContactManager; |
|
158 } |
|
159 ); |
|
160 delete iServiceHandler; |
|
161 |
|
162 |
|
163 if( iContextMenuItems ) |
|
164 { |
|
165 delete iContextMenuItems; |
|
166 iContextMenuItems = NULL; |
|
167 } |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // CGSCallDivertView::NewLC |
|
172 // |
|
173 // 1st phase constructor. |
|
174 // --------------------------------------------------------------------------- |
|
175 CGSCallDivertView* CGSCallDivertView::NewLC( CGSCallDivertModel* aModel ) |
|
176 { |
|
177 CGSCallDivertView* self; |
|
178 self = new ( ELeave ) CGSCallDivertView( aModel ); |
|
179 CleanupStack::PushL( self ); |
|
180 self->ConstructL(); |
|
181 return self; |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // CGSCallDivertView::NewContainerL |
|
186 // |
|
187 // Creates new iContainer. |
|
188 // --------------------------------------------------------------------------- |
|
189 void CGSCallDivertView::NewContainerL() |
|
190 { |
|
191 if( FeatureManager::FeatureSupported( KFeatureIdRestrictedCallDivert ) ) |
|
192 { |
|
193 iContainer = new (ELeave) CGSRestrictedDivertContainer(); |
|
194 } |
|
195 else |
|
196 { |
|
197 iContainer = new (ELeave) CGSCallDivertContainer( |
|
198 iModel->DivertServiceGroup() ); |
|
199 } |
|
200 } |
|
201 |
|
202 |
|
203 // --------------------------------------------------------------------------- |
|
204 // CGSCallDivertView::Id |
|
205 // |
|
206 // implementation of the frameworks virtual function, closely related with view |
|
207 // architecture and has little or no relevance here |
|
208 // --------------------------------------------------------------------------- |
|
209 TUid CGSCallDivertView::Id() const |
|
210 { |
|
211 if( FeatureManager::FeatureSupported( KFeatureIdRestrictedCallDivert ) ) |
|
212 { |
|
213 return KCallDivertPluginId; |
|
214 } |
|
215 else |
|
216 { |
|
217 return KCallDivertViewId; |
|
218 } |
|
219 } |
|
220 |
|
221 // --------------------------------------------------------------------------- |
|
222 // CGSCallDivertView::HandleCommandL |
|
223 // |
|
224 // Handles the received commands |
|
225 // --------------------------------------------------------------------------- |
|
226 void CGSCallDivertView::HandleCommandL( TInt aCommand ) |
|
227 { |
|
228 iVoiceMailboxDivert = EFalse; |
|
229 TBool sendRequest = EFalse; |
|
230 RMobilePhone::TMobilePhoneServiceAction info = |
|
231 RMobilePhone::EServiceActionRegister; |
|
232 TCallDivertSetting divertRequest; |
|
233 |
|
234 if ( aCommand != ECFCmdCancelAll && iContainer ) |
|
235 { |
|
236 if( FeatureManager::FeatureSupported( KFeatureIdRestrictedCallDivert ) ) |
|
237 { |
|
238 CGSRestrictedDivertContainer& container = |
|
239 *static_cast<CGSRestrictedDivertContainer*>( iContainer ); |
|
240 iCurrentItem = container.CurrentFeatureId(); |
|
241 } |
|
242 else |
|
243 { |
|
244 CGSCallDivertContainer& container = |
|
245 *static_cast<CGSCallDivertContainer*>( iContainer ); |
|
246 iCurrentItem = container.CurrentFeatureId(); |
|
247 } |
|
248 __GSLOGSTRING1("[CGSCallDivertView::HandleCommandL] iCurrentItem: %d", iCurrentItem); |
|
249 |
|
250 __ASSERT_ALWAYS( iCurrentItem != KErrNotFound, Panic( KGSDivertClassName, |
|
251 EInvalidCurrentItem ) ); |
|
252 } |
|
253 |
|
254 switch ( aCommand ) |
|
255 { |
|
256 case EGSCmdAppChange: |
|
257 iRockerPress = EFalse; |
|
258 HandleListBoxEventL( iContainer->iListBox, EEventEnterKeyPressed ); |
|
259 break; |
|
260 case EAknSoftkeyBack: |
|
261 if( FeatureManager::FeatureSupported( KFeatureIdRestrictedCallDivert ) ) |
|
262 { |
|
263 iAppUi->ActivateLocalViewL( KGSTelPluginUid ); |
|
264 } |
|
265 else |
|
266 { |
|
267 iAppUi->ActivateLocalViewL( KCallDivertPluginId ); |
|
268 } |
|
269 break; |
|
270 case EAknSoftkeyExit: |
|
271 AppUi()->HandleCommandL( EEikCmdExit ); |
|
272 break; |
|
273 case ECFCmdActivate: |
|
274 divertRequest.iSetting = EActivateDiverting; |
|
275 info = RMobilePhone::EServiceActionRegister; |
|
276 |
|
277 // Activate depends on the selected call type (voice/data/fax) |
|
278 switch( iModel->DivertServiceGroup() ) |
|
279 { |
|
280 case EGSSettIdVoiceDivert: |
|
281 // Handle voice divert. Fetch used numbers and show it in query. |
|
282 ExecuteDivertQueryL( |
|
283 divertRequest.iNumber, |
|
284 iTitles->MdcaPoint( iCurrentItem ), |
|
285 iVoiceMailboxDivert ); |
|
286 sendRequest = ETrue; |
|
287 break; |
|
288 case EGSSettIdVideoDivert: |
|
289 if( iVideoMailboxSupported ) |
|
290 { |
|
291 // Fetch used data divert number and show it in query. |
|
292 ExecuteDivertQueryL( |
|
293 divertRequest.iNumber, |
|
294 iTitles->MdcaPoint( iCurrentItem ), |
|
295 iVoiceMailboxDivert ); |
|
296 sendRequest = ETrue; |
|
297 } |
|
298 else |
|
299 { |
|
300 DisplayDataCallDivertNumberQueryL( divertRequest.iNumber ); |
|
301 sendRequest = ETrue; |
|
302 } |
|
303 break; |
|
304 default: |
|
305 User::Panic( KGSDivertClassName, KErrArgument ); |
|
306 break; |
|
307 } |
|
308 break; |
|
309 case ECFCmdCancel: |
|
310 if( FeatureManager::FeatureSupported( KFeatureIdRestrictedCallDivert ) ) |
|
311 { |
|
312 sendRequest = EFalse; |
|
313 iModel->CancelRestrictedCallDivertL(); |
|
314 } |
|
315 else |
|
316 { |
|
317 sendRequest = ETrue; |
|
318 divertRequest.iSetting = ECancelDiverting; |
|
319 info = RMobilePhone::EServiceActionErase; |
|
320 } |
|
321 break; |
|
322 case ECFCmdCheckStatus: |
|
323 if( FeatureManager::FeatureSupported( KFeatureIdRestrictedCallDivert ) ) |
|
324 { |
|
325 sendRequest = EFalse; |
|
326 iModel->CheckStatusRestrictedCallDivertL(); |
|
327 } |
|
328 else |
|
329 { |
|
330 sendRequest = ETrue; |
|
331 divertRequest.iSetting = ECheckStatus; |
|
332 info = RMobilePhone::EServiceActionUnspecified; |
|
333 } |
|
334 break; |
|
335 case ECFCmdCancelAll: |
|
336 sendRequest = ETrue; |
|
337 divertRequest.iSetting = EEraseDiverting; |
|
338 info = RMobilePhone::EServiceActionErase; |
|
339 break; |
|
340 case EAknCmdHelp: |
|
341 { |
|
342 if( FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
343 { |
|
344 HlpLauncher::LaunchHelpApplicationL( |
|
345 iEikonEnv->WsSession(), iAppUi->AppHelpContextL() ); |
|
346 } |
|
347 break; |
|
348 } |
|
349 default: |
|
350 iAppUi->HandleCommandL( aCommand ); |
|
351 break; |
|
352 } |
|
353 |
|
354 // If a request needs to be sent. |
|
355 if ( sendRequest ) |
|
356 { |
|
357 // will not divert in case empty number |
|
358 iModel->SendCallDivertRequestL( divertRequest, |
|
359 info, |
|
360 iVoiceMailboxDivert, |
|
361 aCommand, |
|
362 (TGSCallDivertServices) iCurrentItem ); |
|
363 } |
|
364 } |
|
365 |
|
366 |
|
367 // --------------------------------------------------------------------------- |
|
368 // CGSCallDivertView::HandleListBoxSelectionL |
|
369 // |
|
370 // Handles List box selection |
|
371 // --------------------------------------------------------------------------- |
|
372 void CGSCallDivertView::HandleListBoxSelectionL() |
|
373 { |
|
374 iRockerPress = ETrue; |
|
375 CEikMenuBar* menuBar = MenuBar(); |
|
376 if ( iRockerPress ) |
|
377 { |
|
378 menuBar->SetMenuTitleResourceId( R_CF_MENUBAR_OPTIONS_VIEW ); |
|
379 menuBar->SetMenuType( CEikMenuBar::EMenuContext ); |
|
380 } |
|
381 else |
|
382 { |
|
383 menuBar->SetMenuTitleResourceId( R_CF_MENUBAR_DIV_VIEW ); |
|
384 menuBar->SetMenuType( CEikMenuBar::EMenuOptions ); |
|
385 } |
|
386 |
|
387 // Display menu bar. |
|
388 menuBar->TryDisplayMenuBarL(); |
|
389 |
|
390 // Reset menu type to original default (EMenuOptions). |
|
391 menuBar->SetMenuType( CEikMenuBar::EMenuOptions ); |
|
392 |
|
393 iRockerPress = EFalse; |
|
394 } |
|
395 |
|
396 |
|
397 // --------------------------------------------------------------------------- |
|
398 // CGSCallDivertView::ExecuteDivertQueryL |
|
399 // |
|
400 // --> voice calls -> all voice calls -> activate -> this popup. |
|
401 // OR |
|
402 // --> video calls -> all video calls -> activate -> this popup. |
|
403 // |
|
404 // ---Example--- |
|
405 // All [voice/]video calls: |
|
406 // To [voice/]video mailbox |
|
407 // [050512345678] |
|
408 // [543454545435] |
|
409 // [342343242343] |
|
410 // To other number |
|
411 // --------------------------------------------------------------------------- |
|
412 // |
|
413 void CGSCallDivertView::ExecuteDivertQueryL( TTelNumber& aTelNumber, |
|
414 const TPtrC& aTitle, |
|
415 TBool& aVmbxValidNumber ) |
|
416 { |
|
417 __GSLOGSTRING("[CGSCallDivertView::ExecuteDivertQueryL]"); |
|
418 |
|
419 CAknSinglePopupMenuStyleListBox* list = |
|
420 new ( ELeave ) CAknSinglePopupMenuStyleListBox; |
|
421 CleanupStack::PushL( list ); |
|
422 |
|
423 CDesC16ArrayFlat* defNumbers = |
|
424 new ( ELeave ) CDesC16ArrayFlat( KCFDefaultNumbers ); |
|
425 CleanupStack::PushL( defNumbers ); |
|
426 |
|
427 CAknPopupList* divertPopup = |
|
428 CAknPopupList::NewL( list, R_AVKON_SOFTKEYS_OK_CANCEL__OK ); |
|
429 CleanupStack::PushL( divertPopup ); |
|
430 |
|
431 list->ConstructL( divertPopup,CEikListBox::ELeftDownInViewRect ); |
|
432 list->CreateScrollBarFrameL( ETrue ); |
|
433 list->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
434 CEikScrollBarFrame::EOff, |
|
435 CEikScrollBarFrame::EAuto ); |
|
436 divertPopup->SetTitleL( aTitle ); |
|
437 if( iContextMenuItems ) |
|
438 { |
|
439 delete iContextMenuItems; |
|
440 iContextMenuItems = NULL; |
|
441 } |
|
442 iContextMenuItems = new ( ELeave ) CDesCArrayFlat( KCFMaxNrOfTargets ); |
|
443 if( iModel->DivertServiceGroup() == EGSSettIdVoiceDivert ) |
|
444 { |
|
445 CreateVoiceDivertItemsL( *iContextMenuItems, *defNumbers ); |
|
446 } |
|
447 else |
|
448 { |
|
449 CreateVideoDivertItemsL( *iContextMenuItems ); |
|
450 } |
|
451 __GSLOGSTRING2( "[CGSCallDivertView::ExecuteDivertQueryL] ItemCount: %d, defNumCount: %d", |
|
452 iContextMenuItems->Count(), |
|
453 defNumbers->Count() ); |
|
454 CTextListBoxModel* model = list->Model(); |
|
455 model->SetItemTextArray( iContextMenuItems ); |
|
456 model->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
457 |
|
458 // Executeld handles the events in the list |
|
459 TBool modified = divertPopup->ExecuteLD(); |
|
460 __GSLOGSTRING1("[CGSCallDivertView::ExecuteDivertQueryL] modified: %d", modified); |
|
461 CleanupStack::Pop(); //voiceDivertPopup |
|
462 |
|
463 if ( modified ) |
|
464 { |
|
465 if( iModel->DivertServiceGroup() == EGSSettIdVoiceDivert ) |
|
466 { |
|
467 aTelNumber = HandleVoiceDivertSelectionL( *list, |
|
468 *defNumbers, |
|
469 aVmbxValidNumber ); |
|
470 } |
|
471 else |
|
472 { |
|
473 aTelNumber = HandleVideoDivertSelectionL( *list ); |
|
474 } |
|
475 } |
|
476 __GSLOGSTRING1( "[CGSCallDivertView::ExecuteVoiceDivertQueryL] aTelNumber: %S", |
|
477 &aTelNumber); |
|
478 CleanupStack::PopAndDestroy( 2 ); //defNumbers, list |
|
479 __GSLOGSTRING( "[CGSCallDivertView::ExecuteVoiceDivertQueryL] End." ); |
|
480 } |
|
481 |
|
482 |
|
483 // --------------------------------------------------------------------------- |
|
484 // CGSCallDivertView::HandleVoiceDivertSelectionL |
|
485 // |
|
486 // Handles user's choice in the Target list. |
|
487 // --------------------------------------------------------------------------- |
|
488 TTelNumber CGSCallDivertView::HandleVoiceDivertSelectionL( |
|
489 CAknSinglePopupMenuStyleListBox& aList, |
|
490 CDesC16ArrayFlat& aDefNumbers, |
|
491 TBool& aVmbxDivert ) |
|
492 { |
|
493 __GSLOGSTRING("[CGSCallDivertView::HandleVoiceDivertSelectionL] Start..."); |
|
494 TTelNumber telNumber; |
|
495 telNumber.Zero(); |
|
496 TInt index = aList.CurrentItemIndex(); |
|
497 __GSLOGSTRING1("[CGSCallDivertView::HandleVoiceDivertSelectionL] index: %d", index); |
|
498 |
|
499 if ( index == KCFDivertToMailBox ) |
|
500 { |
|
501 if ( iModel->VoiceMailActivationL( telNumber ) == KErrNone ) |
|
502 { |
|
503 if ( telNumber == KNullDesC ) |
|
504 { |
|
505 ShowErrorNoteL(); |
|
506 } |
|
507 aVmbxDivert = ETrue; |
|
508 } |
|
509 } |
|
510 //To other number - make a dataquery |
|
511 else if ( index == ( aList.Model()->NumberOfItems() - 1 ) ) |
|
512 { |
|
513 ExecuteDivertNumberQueryL( telNumber, R_TEXT_PRMPT_NUMBER ); |
|
514 __GSLOGSTRING1("[CGSCallDivertView::HandleVoiceDivertSelectionL] telNumber: %S", &telNumber); |
|
515 |
|
516 UpdateDefaultVoiceDivertNumbersL( telNumber ); |
|
517 } |
|
518 //To pre-defined default number |
|
519 else |
|
520 { |
|
521 telNumber = aDefNumbers.MdcaPoint( index - 1 ); |
|
522 iModel->DivertHandler()->SwapDefaultNumberL( index ); |
|
523 } |
|
524 __GSLOGSTRING("[CGSCallDivertView::HandleVoiceDivertSelectionL] End."); |
|
525 return telNumber; |
|
526 } |
|
527 |
|
528 |
|
529 // --------------------------------------------------------------------------- |
|
530 // CGSCallDivertView::HandleVideoDivertSelectionL |
|
531 // |
|
532 // Handles user's choice in the video Target list. |
|
533 // --------------------------------------------------------------------------- |
|
534 TTelNumber CGSCallDivertView::HandleVideoDivertSelectionL( |
|
535 CAknSinglePopupMenuStyleListBox& aList ) |
|
536 { |
|
537 __GSLOGSTRING("[GSCallDivertView::HandleVideoDivertSelectionL] Start"); |
|
538 TTelNumber telNumber( 0 ); |
|
539 TInt index = aList.CurrentItemIndex(); |
|
540 if ( index == KCFDivertToMailBox ) |
|
541 { |
|
542 if ( iModel->VideoMailActivationL( telNumber ) == KErrNone ) |
|
543 { |
|
544 if ( telNumber == KNullDesC ) |
|
545 { |
|
546 ShowErrorNoteL(); |
|
547 } |
|
548 } |
|
549 } |
|
550 else if( index == ( aList.Model()->NumberOfItems() - 1 ) ) |
|
551 { // To other number - make a dataquery (Last item in list) |
|
552 DisplayDataCallDivertNumberQueryL( telNumber ); |
|
553 __GSLOGSTRING1("[GSCallDivertView::HandleVideoDivertSelectionL] telNumber: %S", &telNumber ); |
|
554 } |
|
555 __GSLOGSTRING("[GSCallDivertView::HandleVideoDivertSelectionL] Finished"); |
|
556 return telNumber; |
|
557 } |
|
558 |
|
559 |
|
560 // --------------------------------------------------------------------------- |
|
561 // CGSCallDivertView::DisplayDataCallDivertNumberQueryL |
|
562 // |
|
563 // Displays data call number query and sets call divert |
|
564 // --------------------------------------------------------------------------- |
|
565 void CGSCallDivertView::DisplayDataCallDivertNumberQueryL( TTelNumber& aTelNumber ) |
|
566 { |
|
567 aTelNumber = *iModel->DivertHandler()->GetUsedDataNumberLC(); |
|
568 ExecuteDivertNumberQueryL( aTelNumber, R_TEXT_PRMPT_DATA_NUMBER ); |
|
569 if( aTelNumber != KNullDesC ) |
|
570 { |
|
571 iModel->DivertHandler()->SetUsedDataNumberL( aTelNumber ); |
|
572 } |
|
573 CleanupStack::PopAndDestroy(); // aTelNumber from GetUsedDataNumberLC() |
|
574 } |
|
575 |
|
576 |
|
577 // --------------------------------------------------------------------------- |
|
578 // CGSCallDivertView::ExecuteDivertNumberQueryL |
|
579 // |
|
580 // Executes general number query dialog used by all diverts (voice/data/fax) |
|
581 // --------------------------------------------------------------------------- |
|
582 // |
|
583 void CGSCallDivertView::ExecuteDivertNumberQueryL( TDes& aValue, TInt aType ) |
|
584 { |
|
585 TBool accepted = EFalse; |
|
586 while ( !accepted ) |
|
587 { |
|
588 if ( aValue.Length() > KGSMaxDataLength ) |
|
589 { |
|
590 //Chop the first extra digits and keep the last KGSMaxDataLength |
|
591 //digits intact. This is according to the spec. |
|
592 aValue.Delete( 0, aValue.Length() - KGSMaxDataLength ); |
|
593 } |
|
594 |
|
595 __GSLOGSTRING1("[CGSCallDivertView] ExecuteDivertNumberQueryL: aValue: %S", &aValue); |
|
596 |
|
597 if( AknTextUtils::DigitModeQuery( AknTextUtils::EDigitModeEditorDefault ) ) |
|
598 { |
|
599 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( aValue ); |
|
600 } |
|
601 CGSCallDivertQuery* query = CGSCallDivertQuery::NewL( aValue, |
|
602 CAknQueryDialog::ENoTone, |
|
603 R_AVKON_SOFTKEYS_OK_CANCEL__OK, R_CF_SOFTKEYS_SEARCH_CANCEL ); |
|
604 CleanupStack::PushL( query ); |
|
605 SetPromptToQueryL( *query, aType ); |
|
606 TInt queryAction = query->ExecuteLD( R_DATA_QUERY ); |
|
607 CleanupStack::Pop( query ); |
|
608 AknTextUtils::ConvertDigitsTo( aValue, EDigitTypeWestern ); |
|
609 switch ( queryAction ) |
|
610 { |
|
611 case EAknSoftkeySearch: |
|
612 if( iStoresOpened ) |
|
613 { |
|
614 // Reset the number selection because 'search' is selected. |
|
615 aValue.Zero(); |
|
616 StartAsyncPhoneNumberFetchL(); |
|
617 accepted = ETrue;// Change to asynchronous mode |
|
618 } |
|
619 break; |
|
620 case EAknSoftkeyOk: |
|
621 accepted = ETrue; |
|
622 if ( ValidatePhoneNumberL( aValue ) > KCFValidPhoneNumber || |
|
623 aValue.Length() == 0 ) |
|
624 { |
|
625 accepted = EFalse; |
|
626 } |
|
627 if ( iNumberFetchedAsynchronously ) |
|
628 { |
|
629 switch( iModel->DivertServiceGroup() ) |
|
630 { |
|
631 case EGSSettIdVoiceDivert: |
|
632 UpdateDefaultVoiceDivertNumbersL( aValue ); |
|
633 break; |
|
634 case EGSSettIdVideoDivert: |
|
635 { |
|
636 TTelNumber dataNumber( aValue );// Convert to TTelNumber |
|
637 iModel->DivertHandler()->SetUsedDataNumberL( dataNumber ); |
|
638 break; |
|
639 } |
|
640 default: |
|
641 break; |
|
642 } |
|
643 iNumberFetchedAsynchronously = EFalse; |
|
644 } |
|
645 break; |
|
646 case EAknSoftkeyBack: |
|
647 case EAknSoftkeyCancel: |
|
648 default: |
|
649 accepted = ETrue; |
|
650 aValue.Zero(); |
|
651 break; |
|
652 } |
|
653 } |
|
654 } |
|
655 |
|
656 |
|
657 // --------------------------------------------------------------------------- |
|
658 // CGSCallDivertView::StartAsyncPhoneNumberFetchL |
|
659 // |
|
660 // Fetches values from phonebook ASYNCHRONOUSLY (pbk2 requirement). |
|
661 // --------------------------------------------------------------------------- |
|
662 // |
|
663 void CGSCallDivertView::StartAsyncPhoneNumberFetchL() |
|
664 { |
|
665 TUint fetchFlags = 0; |
|
666 |
|
667 // Construct empty filter |
|
668 CVPbkFieldTypeSelector* contactViewFilter = |
|
669 CVPbkFieldTypeSelector::NewL(iContactManager->FieldTypes()); |
|
670 CleanupStack::PushL(contactViewFilter); |
|
671 |
|
672 // Append the filter object with suitable criteria (only contacts with |
|
673 // phone number shown) |
|
674 VPbkContactViewFilterBuilder::BuildContactViewFilterL(*contactViewFilter, |
|
675 EVPbkContactViewFilterPhoneNumber, *iContactManager); |
|
676 RVPbkContactFieldDefaultPriorities array; |
|
677 CleanupClosePushL(array); |
|
678 |
|
679 TAiwSingleItemSelectionDataV3 data = TAiwSingleItemSelectionDataV3(); |
|
680 // Details selection shows only phone numbers |
|
681 data.SetAddressSelectType(EAiwPhoneNumberSelect); |
|
682 data.SetDefaultPriorities(array); |
|
683 // Contact list shows only contacts that have phone number(s) |
|
684 data.SetFetchFilter(contactViewFilter); |
|
685 data.SetFlags(fetchFlags); |
|
686 |
|
687 CAiwGenericParamList& inParamList = iServiceHandler->InParamListL(); |
|
688 TAiwGenericParam param(EGenericParamContactSelectionData, |
|
689 TAiwVariant(TAiwSingleItemSelectionDataV3Pckg(data))); |
|
690 inParamList.AppendL(param); |
|
691 |
|
692 iServiceHandler->ExecuteServiceCmdL( |
|
693 KAiwCmdSelect, |
|
694 inParamList, |
|
695 iServiceHandler->OutParamListL(), |
|
696 0, |
|
697 this); |
|
698 |
|
699 CleanupStack::PopAndDestroy(); // array |
|
700 CleanupStack::PopAndDestroy( contactViewFilter ); |
|
701 } |
|
702 |
|
703 |
|
704 // --------------------------------------------------------------------------- |
|
705 // CGSCallDivertView::ValidatePhoneNumberL |
|
706 // |
|
707 // Puts a single resource string into a list. |
|
708 // --------------------------------------------------------------------------- |
|
709 TInt CGSCallDivertView::ValidatePhoneNumberL( const TDesC& aDivertTo ) |
|
710 { |
|
711 TInt enteredNumber = KErrNone; |
|
712 TInt noOfInvalidChars = KCFInvalidChars().Length(); |
|
713 |
|
714 // Plus is a special case, as it is accepted as first character. |
|
715 // FindPlus returns KCFErrIllegalNumber(1) if the number is not |
|
716 // acceptable. |
|
717 enteredNumber += FindPlus( aDivertTo ); |
|
718 for ( TInt index = 0; index < noOfInvalidChars; index++ ) |
|
719 { |
|
720 enteredNumber += aDivertTo.Find( |
|
721 KCFInvalidChars().Mid( index, 1 ) ); |
|
722 } |
|
723 // Find returns KErrNotFound(-1), if character(s) is not found. |
|
724 // Therefore, after four searches for special characters in the |
|
725 // number, all results that have greater than -5 as result are not |
|
726 // acceptable. |
|
727 if ( enteredNumber > KCFValidPhoneNumber ) |
|
728 { |
|
729 ShowErrorNoteL(); |
|
730 __GSLOGSTRING( "[CGSCallDivertView::ValidatePhoneNumberL] Invalid phone number. " ); |
|
731 } |
|
732 return enteredNumber; |
|
733 } |
|
734 |
|
735 |
|
736 // --------------------------------------------------------------------------- |
|
737 // CGSCallDivertView::AppendDelayItemL |
|
738 // |
|
739 // Appends items to delay time list. |
|
740 // --------------------------------------------------------------------------- |
|
741 void CGSCallDivertView::AppendDelayItemL( CDesCArrayFlat& aArrayToAppend, |
|
742 TInt aIndex ) |
|
743 { |
|
744 //Delay times are defined as 5,10,15,20,25,30. |
|
745 //Append each of these to a list. |
|
746 TInt delaySeconds = KCFDelayStep * ( aIndex + 1); |
|
747 HBufC* string = StringLoader::LoadLC( R_TEXT_SLIST_SECONDS, delaySeconds ); |
|
748 |
|
749 TPtr bufPtr = string->Des(); |
|
750 if( AknTextUtils::DigitModeQuery( AknTextUtils::EDigitModeShownToUser ) ) |
|
751 { |
|
752 AknTextUtils::LanguageSpecificNumberConversion( bufPtr ); |
|
753 } |
|
754 aArrayToAppend.AppendL( *string ); |
|
755 CleanupStack::PopAndDestroy( string ); |
|
756 } |
|
757 |
|
758 |
|
759 // --------------------------------------------------------------------------- |
|
760 // CGSCallDivertView::CreateVoiceDivertItemsL |
|
761 // |
|
762 // Creates items for the targert list. |
|
763 // --------------------------------------------------------------------------- |
|
764 void CGSCallDivertView::CreateVoiceDivertItemsL( |
|
765 CDesCArray& aItems, |
|
766 CDesC16ArrayFlat& aDefaultNumbers ) |
|
767 { |
|
768 HBufC* item = StringLoader::LoadLC( R_TEXT_DIVERT_TO_VOICE_MAIL ); |
|
769 aItems.AppendL( *item ); |
|
770 CleanupStack::PopAndDestroy( item ); |
|
771 ReadDefaultVoiceDivertNumbersL( aItems, aDefaultNumbers ); |
|
772 HBufC* string = StringLoader::LoadLC( R_TEXT_DIVERT_TO_NUMBER ); |
|
773 aItems.AppendL( *string ); |
|
774 CleanupStack::PopAndDestroy( string ); |
|
775 } |
|
776 |
|
777 |
|
778 // --------------------------------------------------------------------------- |
|
779 // CGSCallDivertView::CreateVideoDivertItemsL |
|
780 // |
|
781 // Creates items for the data target list. |
|
782 // --------------------------------------------------------------------------- |
|
783 void CGSCallDivertView::CreateVideoDivertItemsL( CDesCArray& aItems ) |
|
784 { |
|
785 HBufC* item = StringLoader::LoadLC( R_QTN_SS_DIVERT_TO_VIDEO_MAILBOX ); |
|
786 aItems.AppendL( *item ); |
|
787 CleanupStack::PopAndDestroy( item ); |
|
788 HBufC* string = StringLoader::LoadLC( R_QTN_SS_DIVERT_VCALL_TO_OTHER_NUMBER ); |
|
789 aItems.AppendL( *string ); |
|
790 CleanupStack::PopAndDestroy( string ); |
|
791 } |
|
792 |
|
793 |
|
794 // --------------------------------------------------------------------------- |
|
795 // |
|
796 // Seeks '+' from given number. If '+' is first character, it is ignored. |
|
797 // |
|
798 // --------------------------------------------------------------------------- |
|
799 TInt CGSCallDivertView::FindPlus( const TDesC& aDivertTo ) |
|
800 { |
|
801 TInt seekPlus = aDivertTo.Find( KCFPlusSign ); |
|
802 if ( seekPlus == KErrNotFound ) |
|
803 { |
|
804 //no '+' in the number |
|
805 return KErrNone; |
|
806 } |
|
807 //first char '+', but there can additional '+'s |
|
808 if ( seekPlus == 0 ) |
|
809 { |
|
810 //ignore first '+' |
|
811 TPtrC concat = aDivertTo.Right( aDivertTo.Length() - 1 ); |
|
812 seekPlus = concat.Find( KCFPlusSign ); |
|
813 if ( seekPlus != KErrNotFound ) |
|
814 { |
|
815 return KCFErrIllegalNumber; //two '+'s in number |
|
816 } |
|
817 return KErrNone; |
|
818 } |
|
819 //'+' in number, but not first char |
|
820 else |
|
821 { |
|
822 return KCFErrIllegalNumber; |
|
823 } |
|
824 } |
|
825 |
|
826 |
|
827 // --------------------------------------------------------------------------- |
|
828 // CGSCallDivertView::SetPromptToQueryL |
|
829 // Sets prompt to a query. |
|
830 // |
|
831 // --------------------------------------------------------------------------- |
|
832 void CGSCallDivertView::SetPromptToQueryL( CGSCallDivertQuery& aQuery, |
|
833 const TInt& aType ) |
|
834 { |
|
835 HBufC* title = StringLoader::LoadLC( aType ); |
|
836 aQuery.SetPromptL( *title ); |
|
837 CleanupStack::PopAndDestroy( title ); |
|
838 } |
|
839 |
|
840 |
|
841 // --------------------------------------------------------------------------- |
|
842 // CGSCallDivertView::CreateDelayTimeItemsL |
|
843 // Creates items for delay time list. |
|
844 // |
|
845 // --------------------------------------------------------------------------- |
|
846 // |
|
847 void CGSCallDivertView::CreateDelayTimeItemsL( CDesCArrayFlat& aItems) |
|
848 { |
|
849 for ( TInt index = 0; index < KGSNrOfDelays; index++ ) |
|
850 { |
|
851 AppendDelayItemL( aItems, index ); |
|
852 } |
|
853 } |
|
854 |
|
855 |
|
856 // --------------------------------------------------------------------------- |
|
857 // CGSCallDivertView::CreateRestrictedCallDivertDelayTimeItemsL |
|
858 // Creates items for Delay time list for restricted call divert. |
|
859 // |
|
860 // --------------------------------------------------------------------------- |
|
861 // |
|
862 void CGSCallDivertView::CreateRestrictedCallDivertDelayTimeItemsL( |
|
863 CDesCArrayFlat& aItems ) |
|
864 { |
|
865 // first item is 0 seconds |
|
866 AppendDelayItemL( aItems, -1); |
|
867 for ( TInt index = 0; index < KGSNrOfDelays; index++ ) |
|
868 { |
|
869 AppendDelayItemL( aItems, index ); |
|
870 } |
|
871 AppendDelayItemL( aItems, ( 60 / KCFDelayStep ) - 1); |
|
872 AppendDelayItemL( aItems, ( 90 / KCFDelayStep ) - 1); |
|
873 AppendDelayItemL( aItems, ( 120 / KCFDelayStep ) - 1); |
|
874 } |
|
875 |
|
876 // ----------------------------------------------------------------------------- |
|
877 // CGSCallDivertView::ProcessCommandL |
|
878 // ----------------------------------------------------------------------------- |
|
879 void CGSCallDivertView::ProcessCommandL( TInt aCommand ) |
|
880 { |
|
881 MenuBar()->SetContextMenuTitleResourceId( R_CALL_DIVERT_MSK_CONTEXTMENUBAR ); |
|
882 // Call base class |
|
883 CAknView::ProcessCommandL( aCommand ); |
|
884 } |
|
885 |
|
886 |
|
887 // --------------------------------------------------------------------------- |
|
888 // |
|
889 // Before showing a options menu, delete options key specific settings if |
|
890 // rocker key has been pressed. |
|
891 // --------------------------------------------------------------------------- |
|
892 // |
|
893 void CGSCallDivertView::DynInitMenuPaneL( TInt aResourceId, |
|
894 CEikMenuPane* aMenuPane ) |
|
895 { |
|
896 TInt currentItem; |
|
897 CEikMenuBar* menuBar = MenuBar(); |
|
898 if( FeatureManager::FeatureSupported( KFeatureIdRestrictedCallDivert ) ) |
|
899 { |
|
900 CGSRestrictedDivertContainer &container = |
|
901 *static_cast<CGSRestrictedDivertContainer*>( iContainer ); |
|
902 currentItem = container.CurrentFeatureId(); |
|
903 } |
|
904 else |
|
905 { |
|
906 CGSCallDivertContainer& container = |
|
907 *static_cast<CGSCallDivertContainer*>( iContainer ); |
|
908 currentItem = container.CurrentFeatureId(); |
|
909 } |
|
910 |
|
911 if ( aResourceId == R_CF_DIV_VIEW_MENU ) |
|
912 { |
|
913 if (!menuBar->ItemSpecificCommandsEnabled() && menuBar->GetMenuType() == CEikMenuBar::EMenuOptions) |
|
914 { |
|
915 aMenuPane->SetItemDimmed( ECFCmdActivate, ETrue ); |
|
916 aMenuPane->SetItemDimmed( ECFCmdCancel, ETrue ); |
|
917 aMenuPane->SetItemDimmed( ECFCmdCheckStatus, ETrue ); |
|
918 } |
|
919 //remove help, if not supported from the main divert view |
|
920 //in this step, help is added to context menu too, which |
|
921 //is deleted in the next conditional stmt |
|
922 if ( FeatureManager::FeatureSupported ( KFeatureIdHelp ) ) |
|
923 { |
|
924 aMenuPane->SetItemDimmed( EAknCmdHelp, EFalse ); |
|
925 } |
|
926 else |
|
927 { |
|
928 aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); |
|
929 } |
|
930 |
|
931 if ( iRockerPress ) |
|
932 { |
|
933 //remove Exit & Help from the menu |
|
934 aMenuPane->SetItemDimmed( EAknCmdExit, ETrue ); |
|
935 aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); |
|
936 } |
|
937 else |
|
938 { |
|
939 iRockerPress = EFalse; |
|
940 } |
|
941 } |
|
942 |
|
943 if ( aResourceId == R_CF_MSK_DIV_VIEW_MENU || |
|
944 aResourceId == R_CF_DIV_VIEW_MENU ) |
|
945 { |
|
946 // when not available does not have check status |
|
947 if ( currentItem == ECFDivertWhenNotAvailable ) |
|
948 { |
|
949 aMenuPane->SetItemDimmed( ECFCmdCheckStatus, ETrue ); |
|
950 } |
|
951 } |
|
952 } |
|
953 |
|
954 // --------------------------------------------------------- |
|
955 // CGSCallDivertView::ShowErrorNote |
|
956 // |
|
957 // --------------------------------------------------------- |
|
958 void CGSCallDivertView::ShowErrorNoteL() |
|
959 { |
|
960 HBufC* string = StringLoader::LoadLC( R_INVALID_NUMBER ); |
|
961 CAknErrorNote* note = new ( ELeave ) CAknErrorNote ( ETrue ); |
|
962 note->ExecuteLD( *string ); |
|
963 CleanupStack::PopAndDestroy( string ); |
|
964 } |
|
965 |
|
966 // --------------------------------------------------------------------------- |
|
967 // CGSCallDivertView::ReadDefaultVoiceDivertNumbersL |
|
968 // |
|
969 // Creates defcault items for the target list. |
|
970 // --------------------------------------------------------------------------- |
|
971 void CGSCallDivertView::ReadDefaultVoiceDivertNumbersL( |
|
972 CDesCArray& aItems, |
|
973 CDesC16ArrayFlat& aDefaultNumbers ) |
|
974 { |
|
975 TInt amount = KErrNone; |
|
976 |
|
977 // this is for fetching name to a number from phonebook |
|
978 HBufC* defaultName = NULL; |
|
979 |
|
980 //Default numbers are fetched from shared data |
|
981 amount = iModel->DivertHandler()->GetDefaultNumbersL( aDefaultNumbers ); |
|
982 __ASSERT_ALWAYS( amount == aDefaultNumbers.MdcaCount(), |
|
983 Panic( KGSDivertClassName, ECFDefaultNumberCountError ) ); |
|
984 |
|
985 for ( TInt i = 0; i < amount; i++ ) |
|
986 { |
|
987 //Default numbers should be checked, if there is a contact name associated |
|
988 // with it. |
|
989 defaultName = NULL; |
|
990 defaultName = iModel->MatchNumberToContactLC( aDefaultNumbers.MdcaPoint( i ) ); |
|
991 __GSLOGSTRING1("[CGSCallDivertView] ReadDefaultVoiceDivertNumbersL: defaultName: %S", &defaultName); |
|
992 if ( defaultName ) |
|
993 { |
|
994 aItems.AppendL( *defaultName ); |
|
995 } |
|
996 else |
|
997 { |
|
998 TTelNumber string; |
|
999 if ( iModel->NumberGroupingSupportedL() ) |
|
1000 { |
|
1001 CPNGNumberGrouping* numberGrouping = CPNGNumberGrouping::NewL( |
|
1002 KPSUIMaxPSUIItemLength ); |
|
1003 CleanupStack::PushL( numberGrouping ); |
|
1004 |
|
1005 if ( aDefaultNumbers.MdcaPoint( i ).Length() <= |
|
1006 numberGrouping->MaxDisplayLength() ) |
|
1007 { |
|
1008 numberGrouping->Set( aDefaultNumbers.MdcaPoint( i ) ); |
|
1009 string = numberGrouping->FormattedNumber(); |
|
1010 } |
|
1011 CleanupStack::PopAndDestroy( numberGrouping ); |
|
1012 } |
|
1013 if ( !string.Length() ) |
|
1014 { |
|
1015 string = aDefaultNumbers.MdcaPoint(i); |
|
1016 } |
|
1017 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( string ); |
|
1018 aItems.AppendL( string ); |
|
1019 __GSLOGSTRING1("[CGSCallDivertView] ReadDefaultVoiceDivertNumbersL: string: %S", &string); |
|
1020 } |
|
1021 CleanupStack::PopAndDestroy(); //defaultName |
|
1022 } |
|
1023 } |
|
1024 |
|
1025 // --------------------------------------------------------------------------- |
|
1026 // CGSCallDivertView::UpdateDefaultVoiceDivertNumbersL |
|
1027 // |
|
1028 // Updates most recently used numbers to cenrep |
|
1029 // --------------------------------------------------------------------------- |
|
1030 void CGSCallDivertView::UpdateDefaultVoiceDivertNumbersL( TDes& aNumber ) |
|
1031 |
|
1032 { |
|
1033 if ( aNumber != KNullDesC && iContextMenuItems ) |
|
1034 { |
|
1035 //If activation is done to already existing default number, |
|
1036 //but using the "Other number" selection, this must be verified. |
|
1037 HBufC* contactName = iModel->MatchNumberToContactLC( aNumber ); |
|
1038 |
|
1039 TInt found = KErrNone; |
|
1040 TInt loc = KErrNotFound; |
|
1041 |
|
1042 if ( contactName ) |
|
1043 { |
|
1044 found = iContextMenuItems->Find( *contactName, loc ); |
|
1045 } |
|
1046 else |
|
1047 { |
|
1048 found = iContextMenuItems->Find( aNumber, loc ); |
|
1049 } |
|
1050 CleanupStack::PopAndDestroy(); //contactName |
|
1051 |
|
1052 if ( found > 0 ) //number is not part of current def.numbers |
|
1053 { |
|
1054 iModel->DivertHandler()->SetNewDefaultNumberL( aNumber ); |
|
1055 } |
|
1056 else |
|
1057 { |
|
1058 iModel->DivertHandler()->SwapDefaultNumberL( loc ); |
|
1059 } |
|
1060 } |
|
1061 else |
|
1062 { |
|
1063 __GSLOGSTRING( "[CGSCallDivertView::UpdateDefaultVoiceDivertNumbersL] iContextMenuItems == NULL!!" ); |
|
1064 } |
|
1065 |
|
1066 } |
|
1067 |
|
1068 // --------------------------------------------------------------------------- |
|
1069 // CGSCallDivertView::HandleNotifyL |
|
1070 // |
|
1071 // AIW callback function. |
|
1072 // --------------------------------------------------------------------------- |
|
1073 TInt CGSCallDivertView::HandleNotifyL( |
|
1074 TInt aCmdId, |
|
1075 TInt aEventId, |
|
1076 CAiwGenericParamList& aEventParamList, |
|
1077 const CAiwGenericParamList& /*aInParamList*/ ) |
|
1078 { |
|
1079 TInt err = KErrNone; |
|
1080 if( ( aCmdId == KAiwCmdSelect ) || ( aCmdId == KAiwCmdAssign ) ) |
|
1081 { |
|
1082 if( aEventId == KAiwEventCompleted ) |
|
1083 { |
|
1084 TInt index = 0; |
|
1085 iNumberFetchedAsynchronously = ETrue; |
|
1086 const TAiwGenericParam* param = aEventParamList.FindFirst( |
|
1087 index, EGenericParamContactLinkArray ); |
|
1088 |
|
1089 if( param && iStoresOpened ) |
|
1090 { |
|
1091 if( iContactLinks ) |
|
1092 { |
|
1093 delete iContactLinks; |
|
1094 iContactLinks = NULL; |
|
1095 } |
|
1096 TPtrC8 contactLinks = param->Value().AsData(); |
|
1097 |
|
1098 CVPbkContactLinkArray* localContactLinks = |
|
1099 CVPbkContactLinkArray::NewLC( |
|
1100 contactLinks, |
|
1101 iContactManager->ContactStoresL() ); |
|
1102 |
|
1103 CleanupStack::Pop( localContactLinks ); |
|
1104 iContactLinks = localContactLinks; |
|
1105 |
|
1106 if( iContactLinks->Count() > 0 ) |
|
1107 { |
|
1108 iRetrieveOperation = iContactManager->RetrieveContactL( iContactLinks->At( 0 ), *this ); |
|
1109 } |
|
1110 } |
|
1111 } |
|
1112 else if (aEventId == KAiwEventCanceled) |
|
1113 { |
|
1114 // Do nothing. |
|
1115 } |
|
1116 else if (aEventId == KAiwEventOutParamCheck) |
|
1117 { |
|
1118 // This is needed as PBK2 mysteriously crashes if check is not |
|
1119 // acccepted. There's no actual need to check anything but to go |
|
1120 // ahead here so setting to ETrue. |
|
1121 err = ETrue; |
|
1122 } |
|
1123 else if (aEventId == KAiwEventQueryExit) |
|
1124 { |
|
1125 err = ETrue; |
|
1126 } |
|
1127 } |
|
1128 return err; |
|
1129 } |
|
1130 |
|
1131 |
|
1132 // -------------------------------------------------------------------------- |
|
1133 // CGSCallDivertView::VPbkSingleContactOperationComplete |
|
1134 // -------------------------------------------------------------------------- |
|
1135 // |
|
1136 void CGSCallDivertView::VPbkSingleContactOperationComplete( |
|
1137 MVPbkContactOperationBase& /*aOperation*/, |
|
1138 MVPbkStoreContact* aContact ) |
|
1139 { |
|
1140 if( iRetrieveOperation ) |
|
1141 { |
|
1142 delete iRetrieveOperation; |
|
1143 iRetrieveOperation = NULL; |
|
1144 } |
|
1145 TRAP_IGNORE |
|
1146 ( |
|
1147 MVPbkStoreContactField* field = aContact->Fields().RetrieveField( iContactLinks->At( 0 ) ); |
|
1148 if ( field && field->FieldData().DataType() == EVPbkFieldStorageTypeText ) |
|
1149 { |
|
1150 // aContact has selected phone number from Pbk2 dialog. Set this as |
|
1151 // a text for ExecuteDivertNumberQueryL. |
|
1152 TCallDivertSetting setting; |
|
1153 setting.iSetting = EActivateDiverting; |
|
1154 setting.iNumber = MVPbkContactFieldTextData::Cast( field->FieldData() ).Text(); |
|
1155 |
|
1156 //Ask for user input. |
|
1157 ExecuteDivertNumberQueryL( setting.iNumber, R_TEXT_PRMPT_NUMBER ); |
|
1158 |
|
1159 // ExecuteDivertNumberQueryL() will set setting.iNumber to KNullDesC if user |
|
1160 // selected 'search'. In this case program execution is moved to |
|
1161 // pbk2 asynchronous dialog and this function can exit without |
|
1162 // sending call divert request. |
|
1163 if( setting.iNumber != KNullDesC ) |
|
1164 { |
|
1165 // Send divert request. |
|
1166 iModel->SendCallDivertRequestL( setting, |
|
1167 RMobilePhone::EServiceActionRegister, |
|
1168 iVoiceMailboxDivert, |
|
1169 ECFCmdActivate, |
|
1170 (TGSCallDivertServices) iCurrentItem ); |
|
1171 } |
|
1172 } |
|
1173 ); |
|
1174 delete aContact;// Ownership is taken by this |
|
1175 } |
|
1176 |
|
1177 |
|
1178 // -------------------------------------------------------------------------- |
|
1179 // CGSCallDivertView::VPbkSingleContactOperationFailed |
|
1180 // -------------------------------------------------------------------------- |
|
1181 // |
|
1182 void CGSCallDivertView::VPbkSingleContactOperationFailed( |
|
1183 MVPbkContactOperationBase& /*aOperation*/, |
|
1184 TInt /*aError*/) |
|
1185 { |
|
1186 if( iRetrieveOperation ) |
|
1187 { |
|
1188 delete iRetrieveOperation; |
|
1189 iRetrieveOperation = NULL; |
|
1190 } |
|
1191 |
|
1192 } |
|
1193 |
|
1194 // -------------------------------------------------------------------------- |
|
1195 // CGSCallDivertView::OpenComplete |
|
1196 // -------------------------------------------------------------------------- |
|
1197 // |
|
1198 void CGSCallDivertView::OpenComplete() |
|
1199 { |
|
1200 iStoresOpened = ETrue; |
|
1201 } |
|
1202 |
|
1203 // -------------------------------------------------------------------------- |
|
1204 // CGSCallDivertView::StoreReady |
|
1205 // -------------------------------------------------------------------------- |
|
1206 // |
|
1207 void CGSCallDivertView::StoreReady( MVPbkContactStore& /*aContactStore*/ ) |
|
1208 { |
|
1209 // Do nothing |
|
1210 } |
|
1211 |
|
1212 // -------------------------------------------------------------------------- |
|
1213 // CGSCallDivertView::StoreUnavailable |
|
1214 // -------------------------------------------------------------------------- |
|
1215 // |
|
1216 void CGSCallDivertView::StoreUnavailable |
|
1217 ( MVPbkContactStore& /*aContactStore*/, TInt /*aReason*/ ) |
|
1218 { |
|
1219 // Do nothing |
|
1220 } |
|
1221 |
|
1222 // -------------------------------------------------------------------------- |
|
1223 // CGSCallDivertView::HandleStoreEventL |
|
1224 // -------------------------------------------------------------------------- |
|
1225 // |
|
1226 void CGSCallDivertView::HandleStoreEventL( MVPbkContactStore& /*aContactStore*/, |
|
1227 TVPbkContactStoreEvent /*aStoreEvent*/ ) |
|
1228 { |
|
1229 // Do nothing |
|
1230 } |
|
1231 |
|
1232 |
|
1233 |
|
1234 // --------------------------------------------------------------------------- |
|
1235 // CGSCallDivertView::CreateTimeListL |
|
1236 // |
|
1237 // Activates this view's popup list in order to change time-setting. |
|
1238 // --------------------------------------------------------------------------- |
|
1239 TInt CGSCallDivertView::CreateTimeListL() |
|
1240 { |
|
1241 CAknSinglePopupMenuStyleListBox* list = |
|
1242 new ( ELeave ) CAknSinglePopupMenuStyleListBox; |
|
1243 CleanupStack::PushL( list ); |
|
1244 |
|
1245 CAknPopupList* popupList = |
|
1246 CAknPopupList::NewL( list, R_AVKON_SOFTKEYS_OK_CANCEL__OK ); |
|
1247 CleanupStack::PushL( popupList ); |
|
1248 |
|
1249 HBufC* title = StringLoader::LoadLC( R_TEXT_DELAY_HEADER ); |
|
1250 popupList->SetTitleL( *title ); |
|
1251 CleanupStack::PopAndDestroy( title ); |
|
1252 |
|
1253 list->ConstructL( popupList,CEikListBox::ELeftDownInViewRect ); |
|
1254 list->CreateScrollBarFrameL( ETrue ); |
|
1255 list->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
1256 CEikScrollBarFrame::EOff, |
|
1257 CEikScrollBarFrame::EAuto ); |
|
1258 |
|
1259 CDesCArrayFlat* items; |
|
1260 if( FeatureManager::FeatureSupported( KFeatureIdRestrictedCallDivert ) ) |
|
1261 { |
|
1262 items = new ( ELeave ) CDesCArrayFlat( KGSNrOfDelays + 4 ); |
|
1263 CleanupStack::PushL( items ); |
|
1264 CreateRestrictedCallDivertDelayTimeItemsL( *items ); |
|
1265 } |
|
1266 else |
|
1267 { |
|
1268 items = new ( ELeave ) CDesCArrayFlat( KGSNrOfDelays ); |
|
1269 CleanupStack::PushL( items ); |
|
1270 CreateDelayTimeItemsL( *items ); |
|
1271 } |
|
1272 CTextListBoxModel* model = list->Model(); |
|
1273 model->SetItemTextArray( items ); |
|
1274 model->SetOwnershipType( ELbmOwnsItemArray ); |
|
1275 CleanupStack::Pop(); //items |
|
1276 list->HandleItemAdditionL(); |
|
1277 |
|
1278 //set focus according to file read by phonesettings |
|
1279 //set delay timer field value |
|
1280 TInt currIndex = KErrNone; |
|
1281 if( FeatureManager::FeatureSupported( KFeatureIdRestrictedCallDivert ) ) |
|
1282 { |
|
1283 TInt itemCount = items->Count(); |
|
1284 if (( iModel->DivertHandler()->GetTimerValueL() / KCFDelayStep ) > ( itemCount - 4)) |
|
1285 { |
|
1286 // Within 60, 90, 120 range |
|
1287 switch ( iModel->DivertHandler()->GetTimerValueL() ) |
|
1288 { |
|
1289 case 60: |
|
1290 currIndex = itemCount - 3; |
|
1291 break; |
|
1292 case 90: |
|
1293 currIndex = itemCount - 2; |
|
1294 break; |
|
1295 case 120: |
|
1296 currIndex = itemCount - 1; |
|
1297 break; |
|
1298 } |
|
1299 } |
|
1300 else |
|
1301 { |
|
1302 currIndex = iModel->DivertHandler()->GetTimerValueL() / KCFDelayStep; |
|
1303 } |
|
1304 } |
|
1305 else |
|
1306 { |
|
1307 currIndex = ( iModel->DivertHandler()->GetTimerValueL() / KCFDelayStep ) - 1; |
|
1308 } |
|
1309 __GSLOGSTRING1( "[CGSCallDivertView::CreateTimeListL] currIndex: %d", currIndex ); |
|
1310 |
|
1311 list->SetCurrentItemIndex( currIndex ); |
|
1312 //if possible show topmost item |
|
1313 list->SetTopItemIndex(0); |
|
1314 |
|
1315 TInt keyPress = popupList->ExecuteLD(); |
|
1316 CleanupStack::Pop( popupList ); |
|
1317 if ( keyPress ) |
|
1318 { |
|
1319 TInt index = list->CurrentItemIndex(); |
|
1320 __GSLOGSTRING1( "[CGSCallDivertView::CreateTimeListL] index: %d", index ); |
|
1321 |
|
1322 if( FeatureManager::FeatureSupported( KFeatureIdRestrictedCallDivert ) ) |
|
1323 { |
|
1324 TInt itemCount = items->Count(); |
|
1325 if ( index > ( itemCount - 4)) |
|
1326 { |
|
1327 // Within 60, 90, 120 range |
|
1328 if ( index == itemCount - 3) |
|
1329 { |
|
1330 iModel->DivertHandler()->SetTimerValueL( 60 ); |
|
1331 } |
|
1332 else if ( index == itemCount - 2 ) |
|
1333 { |
|
1334 iModel->DivertHandler()->SetTimerValueL( 90 ); |
|
1335 } |
|
1336 else if ( index == itemCount - 1 ) |
|
1337 { |
|
1338 iModel->DivertHandler()->SetTimerValueL( 120 ); |
|
1339 } |
|
1340 } |
|
1341 else |
|
1342 { |
|
1343 // first entry is 0 seconds |
|
1344 currIndex = iModel->DivertHandler()->SetTimerValueL( index * KCFDelayStep ); |
|
1345 } |
|
1346 } |
|
1347 else |
|
1348 { |
|
1349 //save to file the correct value calculated from index |
|
1350 iModel->DivertHandler()->SetTimerValueL( ( index + 1 ) * KCFDelayStep ); |
|
1351 } |
|
1352 } |
|
1353 CleanupStack::PopAndDestroy( list ); |
|
1354 return keyPress; |
|
1355 } |
|
1356 |
|
1357 |
|
1358 // End of File |