30 #include "ainativeuiplugins.h" |
30 #include "ainativeuiplugins.h" |
31 #ifdef __COVER_DISPLAY |
31 #ifdef __COVER_DISPLAY |
32 #include "aisecondarydisplayapi.h" |
32 #include "aisecondarydisplayapi.h" |
33 #endif |
33 #endif |
34 |
34 |
|
35 |
|
36 // AVKON headers |
|
37 #include <AknNoteWrappers.h> // for Note Wrappers |
|
38 #include <AknPopup.h> // for Popup menus |
|
39 #include <AknWaitDialog.h> // for CAknWaitDialog |
|
40 #include <StringLoader.h> // for StringLoader |
|
41 #include <eiktxlbm.h> // for CTextListBoxModel |
|
42 #include <AknLists.h> // for AknPopupListEmpty |
|
43 #include <bautils.h> // for BaflUtils |
|
44 |
|
45 // Phonesettings headers |
|
46 #include <PsetContainer.h> // for CPsetContainer |
|
47 #include <PsetNetwork.h> // for CPsetNetwork |
|
48 #include <PsetSAObserver.h> // for CPsetSAObserver |
|
49 #include <gsmerror.h> // for GSM-specific error messages |
|
50 |
|
51 #include <GsNetworkPluginRsc.rsg> // for resource IDs |
|
52 #include <CoreApplicationUIsSDKCRKeys.h> // for KCRUidCoreApplicationUIs, TCoreAppUIsNetworkConnectionAllowed |
|
53 #include <featmgr.h> |
|
54 |
|
55 const TInt KAIAlphaTagIconAdditionalChars = 5; |
|
56 // Length of long network name. |
|
57 const TInt KAIAlphaTagLongNameLength = 20; |
|
58 // Length of short network name. |
|
59 const TInt KAIAlphaTagShortNameLength = 10; |
|
60 |
|
61 // array granularity |
|
62 const TInt KAINetworkInfoArrayGranularity = 10; |
|
63 |
|
64 // Error note type ID - for Net view internal usage only |
|
65 const TInt KAIPPErrorNote = 5001; |
|
66 // Confirmation note type ID - for Net view internal usage only |
|
67 const TInt KAIPPConfirmationNote = 5002; |
|
68 //Information note type ID - for Net view internal usage only |
|
69 const TInt KAIPPInformationNote = 5003; |
|
70 |
|
71 const TInt KAIPLMNListPopupMenuItems = 3; |
|
72 |
|
73 // Some resources defined for GSNetworkPlugin are used |
|
74 _LIT(KGSNetworkPluginResource, "z:\\resource\\GsNetworkPluginRsc.rsc"); |
|
75 |
|
76 enum TGSSoftKeys |
|
77 { |
|
78 EGSSoftkeyQuit = 1, |
|
79 EGSSoftkeyEmpty |
|
80 }; |
|
81 |
|
82 |
35 using namespace AiNativeUiController; |
83 using namespace AiNativeUiController; |
36 |
84 |
37 // ======== MEMBER FUNCTIONS ======== |
85 // ======== MEMBER FUNCTIONS ======== |
38 // ---------------------------------------------------------------------------- |
86 // ---------------------------------------------------------------------------- |
39 // CAiDialogRenderer::NewLC() |
87 // CAiDialogRenderer::NewLC() |
191 { |
322 { |
192 ShowDialogL(); |
323 ShowDialogL(); |
193 } |
324 } |
194 } |
325 } |
195 |
326 |
|
327 void CAiDialogRenderer::PopulatePLMNListL() |
|
328 { |
|
329 // Ignore any subsequent EAiDeviceStatusResourcePLMNListPopulateShow content while one is handling |
|
330 if ( iPLMNListPopulateShowIsHandling ) |
|
331 { |
|
332 return; |
|
333 } |
|
334 |
|
335 iPLMNListPopulateShowIsHandling = ETrue; |
|
336 iSearchForNetworksActive = ETrue; |
|
337 iNetwork->GetAvailableNetworksL(); |
|
338 } |
|
339 |
|
340 // --------------------------------------------------------------------------- |
|
341 // |
|
342 // While request to find networks is processed |
|
343 // |
|
344 // --------------------------------------------------------------------------- |
|
345 void CAiDialogRenderer::HandleSearchingNetworksL( |
|
346 MPsetNetworkInfoObserver::TServiceRequest aRequest ) |
|
347 { |
|
348 // Create a network info array if doesn't exist |
|
349 if ( !iNetworkArray ) |
|
350 { |
|
351 iNetworkArray = new ( ELeave ) |
|
352 CNetworkInfoArray( KAINetworkInfoArrayGranularity ); |
|
353 } |
|
354 |
|
355 if ( aRequest != MPsetNetworkInfoObserver::EServiceRequestNone ) |
|
356 { |
|
357 CheckAndCreateDlgL( EFalse ); |
|
358 iSearchForNetworksActive = ETrue; |
|
359 TInt res = iDlg->ExecuteLD( R_SEARCHING_NOTE ); |
|
360 if ( res == EGSSoftkeyQuit ) |
|
361 { |
|
362 iNetwork->CancelProcess(); |
|
363 iPLMNListPopulateShowIsHandling = EFalse; |
|
364 } |
|
365 } |
|
366 else // If EServiceRequestNone received, hide the "Searching..." note |
|
367 { |
|
368 delete iDlg; |
|
369 iDlg = NULL; |
|
370 } |
|
371 } |
|
372 |
|
373 // --------------------------------------------------------------------------- |
|
374 // |
|
375 // Handles network info |
|
376 // |
|
377 // --------------------------------------------------------------------------- |
|
378 void CAiDialogRenderer::HandleNetworkInfoReceivedL( |
|
379 const CNetworkInfoArray* aInfoArray, const TInt /* aResult */ ) |
|
380 { |
|
381 const TInt itemsCount = aInfoArray->Count(); |
|
382 |
|
383 // First delete old ones |
|
384 iNetworkArray->Delete( 0, iNetworkArray->Count() ); |
|
385 |
|
386 // Then insert found networks |
|
387 for ( TInt i = 0; i < itemsCount; i++ ) |
|
388 { |
|
389 MPsetNetworkSelect::TNetworkInfo info = aInfoArray->At( i ); |
|
390 iNetworkArray->InsertL( i, info ); |
|
391 } |
|
392 |
|
393 NetworkListL(); // After search complete, show results |
|
394 } |
|
395 |
|
396 // --------------------------------------------------------------------------- |
|
397 // |
|
398 // While request to change network is processed, a note is shown |
|
399 // |
|
400 // --------------------------------------------------------------------------- |
|
401 void CAiDialogRenderer::HandleRequestingSelectedNetworkL( TBool aOngoing ) |
|
402 { |
|
403 if ( aOngoing ) |
|
404 { |
|
405 CheckAndCreateDlgL( ETrue ); |
|
406 |
|
407 if ( iDlg->ExecuteLD( R_REQUESTING_NOTE ) == EGSSoftkeyQuit ) |
|
408 { |
|
409 iNetwork->CancelProcess(); |
|
410 |
|
411 CAknNoteDialog* dlg = new ( ELeave ) CAknNoteDialog( |
|
412 CAknNoteDialog::EConfirmationTone, |
|
413 CAknNoteDialog::EShortTimeout ); |
|
414 dlg->ExecuteLD( R_REGISTRATION_INTERRUPTED ); |
|
415 iApprovedNetwork = EFalse; |
|
416 iPLMNListPopulateShowIsHandling = EFalse; |
|
417 } |
|
418 } |
|
419 else |
|
420 { |
|
421 delete iDlg; |
|
422 iDlg = NULL; |
|
423 } |
|
424 } |
|
425 |
|
426 // --------------------------------------------------------------------------- |
|
427 // |
|
428 // Handle network change |
|
429 // |
|
430 // --------------------------------------------------------------------------- |
|
431 void CAiDialogRenderer::HandleNetworkChangedL( |
|
432 const MPsetNetworkSelect::TNetworkInfo& aCurrentInfo, |
|
433 const RMobilePhone::TMobilePhoneRegistrationStatus& aStatus, |
|
434 const TInt aResult ) |
|
435 { |
|
436 switch ( aStatus ) |
|
437 { |
|
438 case RMobilePhone::ERegisteredOnHomeNetwork: |
|
439 { |
|
440 ShowNoteL( R_HOME_NETWORK_SELECTED, KAIPPConfirmationNote ); |
|
441 PurgeNetworkList(); |
|
442 break; |
|
443 } |
|
444 case RMobilePhone::ERegisteredRoaming: |
|
445 { |
|
446 HBufC* stringholder = NULL; |
|
447 if ( aCurrentInfo.iLongName.Length() > 0 && |
|
448 aCurrentInfo.iLongName.Length() <= |
|
449 MPsetNetworkSelect::ENetLongNameSize ) |
|
450 { |
|
451 stringholder = StringLoader::LoadLC( R_NETSL_NETWORKSELECTED, |
|
452 aCurrentInfo.iLongName ); |
|
453 } |
|
454 else if (aCurrentInfo.iShortName.Length() > 0 && |
|
455 aCurrentInfo.iShortName.Length() <= |
|
456 MPsetNetworkSelect::ENetShortNameSize ) |
|
457 { |
|
458 stringholder = StringLoader::LoadLC( R_NETSL_NETWORKSELECTED, |
|
459 aCurrentInfo.iShortName ); |
|
460 } |
|
461 |
|
462 CAknConfirmationNote* note = new ( ELeave ) CAknConfirmationNote( ETrue ); |
|
463 if ( stringholder ) |
|
464 { |
|
465 note->ExecuteLD( *stringholder ); |
|
466 CleanupStack::PopAndDestroy( stringholder ); |
|
467 } |
|
468 |
|
469 //After list has been used, clear it. |
|
470 PurgeNetworkList(); |
|
471 break; |
|
472 } |
|
473 case RMobilePhone::ERegistrationUnknown: |
|
474 case RMobilePhone::ENotRegisteredNoService: |
|
475 case RMobilePhone::ENotRegisteredEmergencyOnly: |
|
476 case RMobilePhone::ENotRegisteredSearching: |
|
477 case RMobilePhone::ERegisteredBusy: |
|
478 case RMobilePhone::ERegistrationDenied: |
|
479 default: |
|
480 break; |
|
481 } |
|
482 |
|
483 iPLMNListPopulateShowIsHandling = EFalse; |
|
484 iSearchForNetworksActive = EFalse; |
|
485 } |
|
486 |
|
487 // --------------------------------------------------------------------------- |
|
488 // |
|
489 // Handles errors. |
|
490 // |
|
491 // --------------------------------------------------------------------------- |
|
492 void CAiDialogRenderer::HandleNetworkErrorL( |
|
493 const MPsetNetworkInfoObserver::TServiceRequest aRequest, |
|
494 const TInt aError ) |
|
495 { |
|
496 TInt resourceTxt = KErrNone; |
|
497 |
|
498 switch ( aRequest ) |
|
499 { |
|
500 case MPsetNetworkInfoObserver::EServiceRequestGetNetworkInfo: |
|
501 { |
|
502 iNetwork->CancelProcess(); |
|
503 iApprovedNetwork = EFalse; |
|
504 break; |
|
505 } |
|
506 case MPsetNetworkInfoObserver::EServiceRequestSetNetwork: |
|
507 { |
|
508 } |
|
509 default: |
|
510 { |
|
511 break; |
|
512 } |
|
513 } |
|
514 |
|
515 TBool ignore = EFalse; |
|
516 |
|
517 switch ( aError ) |
|
518 { |
|
519 case KErrGsmNetCauseCallActive: |
|
520 { |
|
521 ignore = ETrue; // Do not show an error |
|
522 break; |
|
523 } |
|
524 case KErrGsm0707NoNetworkService: |
|
525 { |
|
526 resourceTxt = R_NO_NETWORK_FOUND; |
|
527 break; |
|
528 } |
|
529 case KErrGsmOfflineOpNotAllowed: |
|
530 { |
|
531 resourceTxt = R_OFFLINE_MODE; |
|
532 break; |
|
533 } |
|
534 default: |
|
535 { |
|
536 resourceTxt = R_NO_NETWORK_ACCESS; |
|
537 break; |
|
538 } |
|
539 } |
|
540 |
|
541 if ( !ignore ) |
|
542 { |
|
543 ShowNoteL( resourceTxt, KAIPPErrorNote ); |
|
544 iApprovedNetwork = EFalse; |
|
545 } |
|
546 } |
|
547 |
|
548 // --------------------------------------------------------------------------- |
|
549 // |
|
550 // Creates list of Network providers |
|
551 // |
|
552 // --------------------------------------------------------------------------- |
|
553 void CAiDialogRenderer::NetworkListL() |
|
554 { |
|
555 //if no net items were found, do not show list |
|
556 if ( iNetworkArray->Count() > 0 ) |
|
557 { |
|
558 while ( !iApprovedNetwork ) |
|
559 { |
|
560 AknPopupListEmpty<CEikFormattedCellListBox>* list; |
|
561 list = new ( ELeave ) CAknSinglePopupMenuStyleListBox; |
|
562 CleanupStack::PushL( list ); |
|
563 |
|
564 if ( iNetworkPopupList ) |
|
565 { |
|
566 iNetworkPopupList->CancelPopup(); |
|
567 iNetworkPopupList = NULL; |
|
568 } // |
|
569 |
|
570 iNetworkPopupList = |
|
571 CAknPopupList::NewL( list, R_AVKON_SOFTKEYS_OK_CANCEL ); |
|
572 |
|
573 list->ConstructL( iNetworkPopupList, |
|
574 CEikListBox::ELeftDownInViewRect ); |
|
575 list->CreateScrollBarFrameL( ETrue ); |
|
576 list->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
577 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
578 |
|
579 // Fill in the list texts |
|
580 CDesCArrayFlat* items = |
|
581 new ( ELeave ) CDesCArrayFlat( KAIPLMNListPopupMenuItems ); |
|
582 CleanupStack::PushL( items ); |
|
583 |
|
584 const TInt itemsCount = iNetworkArray->Count(); |
|
585 |
|
586 for ( TInt loop = 0; loop < itemsCount; loop++ ) |
|
587 { |
|
588 HBufC* insertString = |
|
589 HBufC::NewLC( |
|
590 KAIAlphaTagLongNameLength + KAIAlphaTagIconAdditionalChars ); |
|
591 MPsetNetworkSelect::TNetworkInfo info = |
|
592 iNetworkArray->At( loop ); |
|
593 |
|
594 if ( info.iLongName.Length() <= 0 || |
|
595 info.iLongName.Length() > KAIAlphaTagLongNameLength ) |
|
596 { |
|
597 // Short name received |
|
598 if ( info.iShortName.Length() > 0 && |
|
599 info.iShortName.Length() <= KAIAlphaTagShortNameLength ) |
|
600 { |
|
601 insertString->Des().Append( info.iShortName ); |
|
602 } // |
|
603 } // |
|
604 // Long name received |
|
605 else |
|
606 { |
|
607 insertString->Des().Append( info.iLongName ); |
|
608 } // |
|
609 |
|
610 items->AppendL( *insertString ); |
|
611 CleanupStack::PopAndDestroy(); |
|
612 } |
|
613 |
|
614 CTextListBoxModel* model = list->Model(); |
|
615 model->SetItemTextArray( items ); |
|
616 model->SetOwnershipType( ELbmOwnsItemArray ); |
|
617 CleanupStack::Pop( items ); // Listbox model now owns this |
|
618 |
|
619 // Set title for list |
|
620 SetTitleToPopupL( *iNetworkPopupList, R_NETSL_FOUNDOPERATORS ); |
|
621 |
|
622 TInt res = 0; |
|
623 // Show the PLMN list |
|
624 if ( items->Count() ) |
|
625 { |
|
626 res = iNetworkPopupList->ExecuteLD(); |
|
627 } // |
|
628 |
|
629 iNetworkPopupList = NULL; |
|
630 iApprovedNetwork = ETrue; // User might want to quit |
|
631 TInt selection = list->CurrentItemIndex(); |
|
632 |
|
633 CleanupStack::PopAndDestroy( list ); |
|
634 |
|
635 if ( res ) |
|
636 { |
|
637 MPsetNetworkSelect::TNetworkInfo info = |
|
638 iNetworkArray->At( selection ); |
|
639 info.iMode = MPsetNetworkSelect::ENetSelectModeManual; |
|
640 iNetwork->SelectNetworkL( info ); |
|
641 } // |
|
642 else // User selected "Cancel" |
|
643 { |
|
644 // Reset back to previously used network |
|
645 iNetwork->ResetNetworkSearch(); |
|
646 iSearchForNetworksActive = EFalse; |
|
647 // After list has been used, clear it |
|
648 PurgeNetworkList(); |
|
649 iPLMNListPopulateShowIsHandling = EFalse; |
|
650 } // |
|
651 } |
|
652 } |
|
653 |
|
654 iApprovedNetwork = EFalse; // Initialize before new search |
|
655 } |
|
656 |
|
657 // --------------------------------------------------------------------------- |
|
658 // |
|
659 // Creates dialog, if it is does not exist yet. |
|
660 // |
|
661 // --------------------------------------------------------------------------- |
|
662 // |
|
663 void CAiDialogRenderer::CheckAndCreateDlgL( TBool aDelayOff ) |
|
664 { |
|
665 if ( !iDlg ) |
|
666 { |
|
667 iDlg = new ( ELeave ) CAknWaitDialog( |
|
668 reinterpret_cast<CEikDialog**> ( &iDlg ), aDelayOff ); |
|
669 } |
|
670 } |
|
671 |
|
672 // --------------------------------------------------------------------------- |
|
673 // |
|
674 // Sets a title to a given popup list. |
|
675 // |
|
676 // --------------------------------------------------------------------------- |
|
677 void CAiDialogRenderer::SetTitleToPopupL( CAknPopupList& aList, TInt aTitleID ) |
|
678 { |
|
679 HBufC* text = StringLoader::LoadLC( aTitleID ); |
|
680 |
|
681 aList.SetTitleL( *text ); |
|
682 |
|
683 CleanupStack::PopAndDestroy( text ); |
|
684 text = NULL; |
|
685 } |
|
686 |
|
687 // --------------------------------------------------------------------------- |
|
688 // |
|
689 // Shows note. |
|
690 // |
|
691 // --------------------------------------------------------------------------- |
|
692 // |
|
693 void CAiDialogRenderer::ShowNoteL( TInt aResourceId, TInt aType ) |
|
694 { |
|
695 HBufC* string = StringLoader::LoadLC( aResourceId ); |
|
696 |
|
697 switch ( aType ) |
|
698 { |
|
699 case KAIPPErrorNote: |
|
700 { |
|
701 CAknErrorNote* note = new ( ELeave ) CAknErrorNote ( ETrue ); |
|
702 note->ExecuteLD( *string ); |
|
703 break; |
|
704 } |
|
705 case KAIPPConfirmationNote: |
|
706 { |
|
707 CAknConfirmationNote* note = |
|
708 new ( ELeave ) CAknConfirmationNote( ETrue ); |
|
709 note->ExecuteLD( *string ); |
|
710 break; |
|
711 } |
|
712 case KAIPPInformationNote: |
|
713 { |
|
714 CAknInformationNote* note = |
|
715 new ( ELeave ) CAknInformationNote( ETrue ); |
|
716 note->ExecuteLD( *string ); |
|
717 break; |
|
718 } |
|
719 default: |
|
720 break; |
|
721 } |
|
722 |
|
723 CleanupStack::PopAndDestroy( string ); |
|
724 } |
|
725 |
|
726 // --------------------------------------------------------------------------- |
|
727 // |
|
728 // Empties fetched network provider's list |
|
729 // |
|
730 // --------------------------------------------------------------------------- |
|
731 // |
|
732 void CAiDialogRenderer::PurgeNetworkList() |
|
733 { |
|
734 if ( iNetworkArray ) |
|
735 { |
|
736 iNetworkArray->Reset(); |
|
737 delete iNetworkArray; |
|
738 iNetworkArray = NULL; |
|
739 } |
|
740 } |
|
741 |
196 // End of file |
742 // End of file |