493 // CPbk2ContactEditorDlgImpl::HandleResourceChange |
510 // CPbk2ContactEditorDlgImpl::HandleResourceChange |
494 // -------------------------------------------------------------------------- |
511 // -------------------------------------------------------------------------- |
495 // |
512 // |
496 void CPbk2ContactEditorDlgImpl::HandleResourceChange( TInt aType ) |
513 void CPbk2ContactEditorDlgImpl::HandleResourceChange( TInt aType ) |
497 { |
514 { |
498 // Handle change in layout orientation |
515 switch ( aType ) |
499 if ( aType == KEikDynamicLayoutVariantSwitch ) |
516 { |
500 { |
517 case KEikDynamicLayoutVariantSwitch: // Handle change in layout orientation |
501 // Set status pane layout to the Phonebook 2 one |
518 { |
502 CEikStatusPane* statusPane = iAvkonAppUi->StatusPane(); |
519 // Set status pane layout to the Phonebook 2 one |
503 if ( statusPane ) |
520 CEikStatusPane* statusPane = iAvkonAppUi->StatusPane(); |
504 { |
521 if ( statusPane ) |
505 iCurrentstatuspane = statusPane->CurrentLayoutResId(); |
522 { |
506 if( iCurrentstatuspane != R_AVKON_STATUS_PANE_LAYOUT_USUAL ) |
523 iCurrentstatuspane = statusPane->CurrentLayoutResId(); |
507 { |
524 if( iCurrentstatuspane != R_AVKON_STATUS_PANE_LAYOUT_USUAL ) |
508 TRAP_IGNORE( statusPane->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL) ); |
525 { |
509 } |
526 TRAP_IGNORE( |
510 } |
527 statusPane->SwitchLayoutL( |
|
528 R_AVKON_STATUS_PANE_LAYOUT_USUAL ) |
|
529 ); |
|
530 } |
|
531 } |
|
532 } |
|
533 break; |
|
534 case KAknSplitInputEnabled: // Handle split input keyboard |
|
535 { |
|
536 // Sometimes this function will be called continuously |
|
537 // with the same parameter. |
|
538 // Add a flag iIsInputPaneOpen to ensure the dialog |
|
539 // only draw one time. |
|
540 if( !iIsInputPaneOpen ) |
|
541 { |
|
542 Layout(); |
|
543 DrawNow(); |
|
544 iIsInputPaneOpen = ETrue; |
|
545 } |
|
546 } |
|
547 break; |
|
548 case KAknSplitInputDisabled: |
|
549 { |
|
550 // Sometimes this function will be called continuously |
|
551 // with the same parameter. |
|
552 // Add a flag iIsInputPaneOpen to ensure the dialog |
|
553 // only draw one time. |
|
554 if( iIsInputPaneOpen ) |
|
555 { |
|
556 // Set status pane layout to the Phonebook 2 one |
|
557 Layout(); |
|
558 DrawNow(); |
|
559 CEikStatusPane* statusPane = iAvkonAppUi->StatusPane(); |
|
560 if ( statusPane ) |
|
561 { |
|
562 TRAP_IGNORE( |
|
563 statusPane->SwitchLayoutL( |
|
564 R_AVKON_STATUS_PANE_LAYOUT_USUAL ) |
|
565 ); |
|
566 } |
|
567 iIsInputPaneOpen = EFalse; |
|
568 } |
|
569 } |
|
570 break; |
|
571 default: |
|
572 break; |
511 } |
573 } |
512 |
574 |
513 CAknForm::HandleResourceChange( aType ); |
575 CAknForm::HandleResourceChange( aType ); |
514 } |
576 } |
515 |
577 |
520 void CPbk2ContactEditorDlgImpl::AddItemToContactL |
582 void CPbk2ContactEditorDlgImpl::AddItemToContactL |
521 ( TInt aFieldTypeResourceId, |
583 ( TInt aFieldTypeResourceId, |
522 const TDesC& aFieldTypeXspName, |
584 const TDesC& aFieldTypeXspName, |
523 TBool aSetFocus ) |
585 TBool aSetFocus ) |
524 { |
586 { |
|
587 // For knowing whether the destructor has been called |
|
588 TBool destroyed = EFalse; |
|
589 iDestroyedPtrForAddItem = &destroyed; |
525 // Store the original parameter value, since it is |
590 // Store the original parameter value, since it is |
526 // changed by AddFieldsL |
591 // changed by AddFieldsL |
527 TInt origParam = aFieldTypeResourceId; |
592 TInt origParam = aFieldTypeResourceId; |
528 TPtrC xSpName = aFieldTypeXspName; |
593 TPtrC xSpName = aFieldTypeXspName; |
529 |
594 |
530 CPbk2AddItemManager* addItemManager = CPbk2AddItemManager::NewL |
595 CPbk2AddItemManager* addItemManager = CPbk2AddItemManager::NewL |
531 (iContact, *iUiFieldArray, iParams, iAppServices ); |
596 (iContact, *iUiFieldArray, iParams, iAppServices ); |
532 CleanupStack::PushL(addItemManager); |
597 CleanupStack::PushL(addItemManager); |
533 CPbk2AddItemManager::TReturnValue ret = addItemManager->AddFieldsL( |
598 CPbk2AddItemManager::TReturnValue ret = addItemManager->AddFieldsL( |
534 aFieldTypeResourceId, xSpName); |
599 aFieldTypeResourceId, xSpName); |
535 |
600 |
536 if (ret.iControlId == KErrAlreadyExists) |
601 // In case that pop list for adding item is closed by FSW, this object |
537 { |
602 // will be destructed by CPbk2ContactEditorOperator::ForceExit(). |
538 // cannot add more than one of this field type |
603 // If this object is destructed, don't execute the following anymore. |
539 // find and focus that |
604 if ( !destroyed ) |
540 TInt fieldArrayCount( iUiFieldArray->Count() ); |
605 { |
541 for (TInt i(0); i < fieldArrayCount && ret.iControlId |
606 if (ret.iControlId == KErrAlreadyExists) |
542 == KErrAlreadyExists; ++i) |
607 { |
543 { |
608 // cannot add more than one of this field type |
544 if (!iUiFieldArray->At(i).ContactEditorField()) |
609 // find and focus that |
545 { |
610 TInt fieldArrayCount( iUiFieldArray->Count() ); |
546 continue; |
611 for (TInt i(0); i < fieldArrayCount && ret.iControlId |
547 } |
612 == KErrAlreadyExists; ++i) |
548 const MVPbkFieldType* fieldType = |
613 { |
549 iUiFieldArray->At(i).ContactEditorField()->ContactField(). |
614 if (!iUiFieldArray->At(i).ContactEditorField()) |
550 BestMatchingFieldType(); |
|
551 if(fieldType && fieldType->FieldTypeResId() == aFieldTypeResourceId) |
|
552 { |
|
553 ret.iControlId = iUiFieldArray->At(i).ControlId(); |
|
554 } |
|
555 } |
|
556 } |
|
557 |
|
558 if (ret.iControlId > 0) |
|
559 { |
|
560 if (aSetFocus) |
|
561 { |
|
562 TryChangeFocusL(ret.iControlId); |
|
563 MPbk2ContactEditorField* editorField = iUiFieldArray->Find( ret.iControlId )->ContactEditorField(); |
|
564 MVPbkStoreContactField& storeContactField = editorField->ContactField(); |
|
565 iParams.iFocusedContactField = &storeContactField; |
|
566 // Call this after adding or deleting lines |
|
567 UpdatePageL( ETrue ); |
|
568 // Must be DrawNow and not DrawDeferred otherwise field label |
|
569 // and content of the following field will be incorrect |
|
570 DrawNow(); |
|
571 } |
|
572 } |
|
573 else if (ret.iControlId == KErrNotSupported && origParam == KErrNotFound) |
|
574 { |
|
575 iUiFieldArray->SaveFieldsL(); |
|
576 iRelocator.RelocateContactL(aFieldTypeResourceId, xSpName, |
|
577 Pbk2ContactRelocator::EPbk2DisplayStoreDoesNotSupportQuery); |
|
578 } |
|
579 else if ( iParams.iActiveView == TPbk2ContactEditorParams::EEditorView ) |
|
580 { |
|
581 switch( ret.iGruopId ) |
|
582 { |
|
583 case EPbk2FieldGroupIdPostalAddress: |
|
584 if(iUiFieldArray->Count()) |
|
585 { |
615 { |
|
616 continue; |
|
617 } |
|
618 const MVPbkFieldType* fieldType = |
|
619 iUiFieldArray->At(i).ContactEditorField()->ContactField(). |
|
620 BestMatchingFieldType(); |
|
621 if(fieldType && fieldType->FieldTypeResId() == aFieldTypeResourceId) |
|
622 { |
|
623 ret.iControlId = iUiFieldArray->At(i).ControlId(); |
|
624 } |
|
625 } |
|
626 } |
|
627 |
|
628 if (ret.iControlId > 0) |
|
629 { |
|
630 if (aSetFocus) |
|
631 { |
|
632 TryChangeFocusL(ret.iControlId); |
|
633 MPbk2ContactEditorField* editorField = iUiFieldArray->Find( ret.iControlId )->ContactEditorField(); |
|
634 MVPbkStoreContactField& storeContactField = editorField->ContactField(); |
|
635 iParams.iFocusedContactField = &storeContactField; |
|
636 // Call this after adding or deleting lines |
|
637 UpdatePageL( ETrue ); |
|
638 // Must be DrawNow and not DrawDeferred otherwise field label |
|
639 // and content of the following field will be incorrect |
|
640 DrawNow(); |
|
641 } |
|
642 } |
|
643 else if (ret.iControlId == KErrNotSupported && origParam == KErrNotFound) |
|
644 { |
|
645 iUiFieldArray->SaveFieldsL(); |
|
646 iRelocator.RelocateContactL(aFieldTypeResourceId, xSpName, |
|
647 Pbk2ContactRelocator::EPbk2DisplayStoreDoesNotSupportQuery); |
|
648 } |
|
649 else if ( iParams.iActiveView == TPbk2ContactEditorParams::EEditorView ) |
|
650 { |
|
651 switch( ret.iGruopId ) |
|
652 { |
|
653 case EPbk2FieldGroupIdPostalAddress: |
|
654 if(iUiFieldArray->Count()) |
|
655 { |
|
656 iUiFieldArray->AddNewFieldL( ret.iGruopId ); |
|
657 ExecuteAddressDlgL( TPbk2ContactEditorParams::EEditorAddressView ); |
|
658 } |
|
659 break; |
|
660 case EPbk2FieldGroupIdHomeAddress: |
586 iUiFieldArray->AddNewFieldL( ret.iGruopId ); |
661 iUiFieldArray->AddNewFieldL( ret.iGruopId ); |
587 ExecuteAddressDlgL( TPbk2ContactEditorParams::EEditorAddressView ); |
662 ExecuteAddressDlgL( TPbk2ContactEditorParams::EEditorAddressHomeView ); |
588 } |
663 break; |
589 break; |
664 case EPbk2FieldGroupIdCompanyAddress: |
590 case EPbk2FieldGroupIdHomeAddress: |
665 iUiFieldArray->AddNewFieldL( ret.iGruopId ); |
591 iUiFieldArray->AddNewFieldL( ret.iGruopId ); |
666 ExecuteAddressDlgL( TPbk2ContactEditorParams::EEditorAddressOfficeView ); |
592 ExecuteAddressDlgL( TPbk2ContactEditorParams::EEditorAddressHomeView ); |
667 break; |
593 break; |
668 } |
594 case EPbk2FieldGroupIdCompanyAddress: |
669 } |
595 iUiFieldArray->AddNewFieldL( ret.iGruopId ); |
670 iDestroyedPtrForAddItem = NULL; |
596 ExecuteAddressDlgL( TPbk2ContactEditorParams::EEditorAddressOfficeView ); |
|
597 break; |
|
598 } |
|
599 } |
671 } |
600 CleanupStack::PopAndDestroy(addItemManager); |
672 CleanupStack::PopAndDestroy(addItemManager); |
601 } |
673 } |
602 |
674 |
603 // -------------------------------------------------------------------------- |
675 // -------------------------------------------------------------------------- |
714 { |
794 { |
715 iContextMenuBar->TryDisplayMenuBarL(); |
795 iContextMenuBar->TryDisplayMenuBarL(); |
716 ret = EKeyWasConsumed; |
796 ret = EKeyWasConsumed; |
717 } |
797 } |
718 |
798 |
719 if ( ret != EKeyWasConsumed && !iEndKeyWasPressed ) |
799 if ( ret != EKeyWasConsumed ) |
720 { |
800 { |
721 if ( aKeyEvent.iCode == EKeyEscape ) |
801 // If the iEndKeyWasPressed equels to true, which illustrates |
722 { |
802 // the EditorDlgImpl get the Escape key event one more time |
723 iEditorStrategy.StopQuery(); |
803 // for the case that Exit phonebook2 with the EditorDlg opened, |
724 iEndKeyWasPressed = ETrue; |
804 // sush as save VOIP settings,there will be two event, |
725 } |
805 // one is to close dialog and the other is to exit phonebook2. |
726 ret = CAknForm::OfferKeyEventL( aKeyEvent, aType ); |
806 if ( iEndKeyWasPressed ) |
727 if ( ret == EKeyWasConsumed && |
807 { |
728 aKeyEvent.iCode != EKeyPhoneEnd && aKeyEvent.iCode != EKeyEscape ) |
808 if ( aKeyEvent.iCode == EKeyEscape && iAvkonAppUi->IsAppShutterRunning() ) |
729 { |
809 { |
730 UpdateCbasL(); |
810 // Use the iExitApp to record whether the AppShutter is running. |
731 } |
811 // According to the value of iExitApp to Exit Phonebook2 app ui |
|
812 // after the EditorDlg close completely. |
|
813 iExitApp = ETrue; |
|
814 } |
|
815 } |
|
816 else |
|
817 { |
|
818 if ( aKeyEvent.iCode == EKeyEscape ) |
|
819 { |
|
820 iEditorStrategy.StopQuery(); |
|
821 iEndKeyWasPressed = ETrue; |
|
822 } |
|
823 ret = CAknForm::OfferKeyEventL( aKeyEvent, aType ); |
|
824 if ( ret == EKeyWasConsumed && aKeyEvent.iCode != EKeyPhoneEnd |
|
825 && aKeyEvent.iCode != EKeyEscape ) |
|
826 { |
|
827 UpdateCbasL(); |
|
828 } |
|
829 } |
732 } |
830 } |
733 |
831 |
734 return ret; |
832 return ret; |
735 } |
833 } |
736 |
834 |
2696 } |
2799 } |
2697 |
2800 |
2698 // In VOIP/new contacts/exit case, this object will be destructed by |
2801 // In VOIP/new contacts/exit case, this object will be destructed by |
2699 // iContactObserver.ContactEditingComplete() above. |
2802 // iContactObserver.ContactEditingComplete() above. |
2700 // If this object is destructed, don't excute the following anymore |
2803 // If this object is destructed, don't excute the following anymore |
2701 if ( destroyed ) |
2804 if ( !destroyed ) |
2702 { |
2805 { |
2703 return; |
2806 // Don't save any contact data (already saved) |
2704 } |
2807 iExitRecord.Set(EOkToExitWithoutHandlingIt); |
2705 |
2808 iExitRecord.Clear(EExitOrdered); |
2706 // Don't save any contact data (already saved) |
2809 |
2707 iExitRecord.Set(EOkToExitWithoutHandlingIt); |
2810 // Close dialog using TryExitL and returning ETrue from OkToExit |
2708 iExitRecord.Clear(EExitOrdered); |
2811 TInt err = KErrNone; |
2709 |
2812 TRAP( err, TryExitL( EAknSoftkeyBack ) ); |
2710 // Close dialog using TryExitL and returning ETrue from OkToExit |
2813 if (err != KErrNone) |
2711 TInt err = KErrNone; |
2814 { |
2712 TRAP( err, TryExitL( EAknSoftkeyBack ) ); |
2815 // If not nicely then use the force. |
2713 if (err != KErrNone) |
2816 delete this; |
2714 { |
2817 } |
2715 // If not nicely then use the force. |
2818 iDestroyedPtrForCloseDlg = NULL; |
2716 delete this; |
|
2717 } |
2819 } |
2718 } |
2820 } |
2719 |
2821 |
2720 // -------------------------------------------------------------------------- |
2822 // -------------------------------------------------------------------------- |
2721 // CPbk2ContactEditorDlgImpl::ExitApplication |
2823 // CPbk2ContactEditorDlgImpl::ExitApplication |
2861 switch(uiField->UIField()->CtrlType()) |
2963 switch(uiField->UIField()->CtrlType()) |
2862 { |
2964 { |
2863 case EPbk2FieldCtrlTypeExtAddressEditor: |
2965 case EPbk2FieldCtrlTypeExtAddressEditor: |
2864 case EPbk2FieldCtrlTypeExtAddressHomeEditor: |
2966 case EPbk2FieldCtrlTypeExtAddressHomeEditor: |
2865 case EPbk2FieldCtrlTypeExtAddressOfficeEditor: |
2967 case EPbk2FieldCtrlTypeExtAddressOfficeEditor: |
2866 if(IsAddressValidated(Pbk2AddressTools::MapCtrlTypeToAddress( |
2968 { |
2867 uiField->UIField()->CtrlType()))) |
2969 TInt iconId = 0; |
|
2970 // UnSync feature indicator flag and chinese flag |
|
2971 TBool supportUnSyncFeature = |
|
2972 FeatureManager::FeatureSupported( |
|
2973 KFeatureIdFfTdUnSyncabPbfieldsInd ); |
|
2974 TBool supportChinese = |
|
2975 FeatureManager::FeatureSupported( KFeatureIdChinese ); |
|
2976 // Valid address |
|
2977 TBool addressValidated = |
|
2978 IsAddressValidated( |
|
2979 Pbk2AddressTools::MapCtrlTypeToAddress( |
|
2980 uiField->UIField()->CtrlType())); |
|
2981 if(supportChinese && supportUnSyncFeature) |
2868 { |
2982 { |
2869 TPbk2IconId iconID(TUid::Uid(KPbk2UID3), EPbk2qgn_prop_locev_map); |
2983 // Unsync icon |
2870 uiField->LoadBitmapToFieldL(iconID); |
2984 iconId = EPbk2qgn_prop_phonebook2_unsync; |
2871 } |
2985 } |
2872 else |
2986 else |
2873 { |
2987 { |
2874 TPbk2IconId iconID(TUid::Uid(KPbk2UID3), EPbk2qgn_prop_pb_no_valid_lm); |
2988 iconId = addressValidated ? |
2875 uiField->LoadBitmapToFieldL(iconID); |
2989 EPbk2qgn_prop_locev_map : EPbk2qgn_prop_pb_no_valid_lm; |
2876 } |
2990 } |
|
2991 TPbk2IconId pbkIconId(TUid::Uid(KPbk2UID3),iconId); |
|
2992 uiField->LoadBitmapToFieldL(pbkIconId); |
|
2993 } |
2877 break; |
2994 break; |
2878 case EPbk2FieldCtrlTypeExtAssignFromMapsEditor: |
2995 case EPbk2FieldCtrlTypeExtAssignFromMapsEditor: |
2879 if(IsAddressValidated( Pbk2AddressTools::MapViewTypeToAddress(iParams.iActiveView))) |
2996 { |
|
2997 // UnSync feature indicator flag and chinese flag |
|
2998 TBool supportUnSyncFeature = |
|
2999 FeatureManager::FeatureSupported( |
|
3000 KFeatureIdFfTdUnSyncabPbfieldsInd ); |
|
3001 TBool supportChinese = |
|
3002 FeatureManager::FeatureSupported( KFeatureIdChinese ); |
|
3003 |
|
3004 TBool addressValidated = |
|
3005 IsAddressValidated( |
|
3006 Pbk2AddressTools::MapViewTypeToAddress( iParams.iActiveView )); |
|
3007 TInt iconId = 0; |
|
3008 if( supportChinese && supportUnSyncFeature ) |
2880 { |
3009 { |
2881 TPbk2IconId iconID(TUid::Uid(KPbk2UID3), EPbk2qgn_prop_locev_map); |
3010 iconId = EPbk2qgn_prop_phonebook2_unsync; |
2882 uiField->LoadBitmapToFieldL(iconID); |
3011 } |
2883 } |
3012 else |
2884 else |
3013 { |
2885 { |
3014 iconId = addressValidated ? |
2886 TPbk2IconId iconID(TUid::Uid(KPbk2UID3), EPbk2qgn_prop_pb_no_valid_lm); |
3015 EPbk2qgn_prop_locev_map : EPbk2qgn_prop_pb_no_valid_lm; |
2887 uiField->LoadBitmapToFieldL(iconID); |
3016 } |
2888 } |
3017 TPbk2IconId pbkIconId(TUid::Uid(KPbk2UID3),iconId); |
2889 break; |
3018 uiField->LoadBitmapToFieldL(pbkIconId); |
|
3019 } |
|
3020 break; |
2890 default: |
3021 default: |
2891 return; |
3022 return; |
2892 } |
3023 } |
2893 } |
3024 } |
2894 } |
3025 } |