568 |
568 |
569 // -------------------------------------------------------------------------- |
569 // -------------------------------------------------------------------------- |
570 // CPmapCmd::EditorShowMapL |
570 // CPmapCmd::EditorShowMapL |
571 // -------------------------------------------------------------------------- |
571 // -------------------------------------------------------------------------- |
572 // |
572 // |
573 void CPmapCmd::EditorShowOnMapsL(TVPbkFieldTypeParameter aAddressType) |
573 void CPmapCmd::EditorShowOnMapsL( TVPbkFieldTypeParameter aAddressType ) |
574 { |
574 { |
575 CMnMapView* mapview = CMnMapView::NewL( *iMapViewProvider ); |
575 CMnMapView* mapview = CMnMapView::NewL( *iMapViewProvider ); |
576 CleanupStack::PushL( mapview ); |
576 CleanupStack::PushL( mapview ); |
577 |
577 |
578 RPointerArray<CPosLandmark> landmarks; |
578 RPointerArray<CPosLandmark> landmarks; |
579 CleanupClosePushL( landmarks ); |
579 CleanupClosePushL( landmarks ); |
580 |
580 |
581 CPosLandmark* landmark = CPosLandmark::NewL(); |
581 CPosLandmark* landmark = CPosLandmark::NewL(); |
582 CleanupStack::PushL( landmark ); |
582 CleanupStack::PushL( landmark ); |
583 |
583 |
584 if ( !FillGeoLandmarkL( *landmark, aAddressType ) ) |
584 if ( !FillGeoLandmarkL( *landmark, aAddressType ) ) |
585 { |
585 { |
586 FillLandmarkL( *landmark, aAddressType ); |
586 FillLandmarkL( *landmark, aAddressType ); |
587 } |
587 } |
588 TLocality locality; |
588 TLocality locality; |
589 if( landmark->NumOfAvailablePositionFields() > 0 || landmark->GetPosition( locality ) == KErrNone ) |
589 if ( landmark->NumOfAvailablePositionFields() > 0 |
590 { |
590 || landmark->GetPosition( locality ) == KErrNone ) |
591 landmarks.AppendL( landmark ); |
591 { |
592 mapview->AddLandmarksToShowL( landmarks ); |
592 landmarks.AppendL( landmark ); |
593 } |
593 mapview->AddLandmarksToShowL( landmarks ); |
594 mapview->ShowMapL(); |
594 } |
595 |
595 |
596 CleanupStack::PopAndDestroy( landmark ); |
596 if ( landmark->GetPosition( locality ) == KErrNone ) |
597 CleanupStack::PopAndDestroy( &landmarks ); |
597 { |
598 CleanupStack::PopAndDestroy( mapview ); |
598 mapview->ShowMapL(); |
599 } |
599 CleanupStack::PopAndDestroy( landmark ); |
|
600 CleanupStack::PopAndDestroy( &landmarks ); |
|
601 CleanupStack::PopAndDestroy( mapview ); |
|
602 } |
|
603 else |
|
604 { |
|
605 TRequestStatus status; |
|
606 mapview->SelectFromMapL( status ); |
|
607 User::WaitForRequest( status ); |
|
608 TBool update = EFalse; |
|
609 TBool geocoordsExist = EFalse; |
|
610 |
|
611 CPosLandmark* result = NULL; |
|
612 if ( status.Int() == KErrNone ) |
|
613 { |
|
614 result = mapview->RetrieveSelectionResultL(); |
|
615 if ( result->GetPosition( locality ) == KErrNone ) |
|
616 { |
|
617 geocoordsExist = ETrue; |
|
618 } |
|
619 if ( result->IsPositionFieldAvailable( EPositionFieldStreet ) |
|
620 || result->IsPositionFieldAvailable( EPositionFieldCity ) |
|
621 || result->IsPositionFieldAvailable( EPositionFieldCountry ) ) |
|
622 { |
|
623 update = ETrue; |
|
624 } |
|
625 |
|
626 } |
|
627 CleanupStack::PopAndDestroy( landmark ); |
|
628 CleanupStack::PopAndDestroy( &landmarks ); |
|
629 CleanupStack::PopAndDestroy( mapview ); |
|
630 if ( result ) |
|
631 { |
|
632 CleanupStack::PushL( result ); |
|
633 } |
|
634 |
|
635 if ( update ) |
|
636 { |
|
637 |
|
638 const TInt KGranularity = 4; |
|
639 CDesCArrayFlat* arrFields = new (ELeave) CDesCArrayFlat( |
|
640 KGranularity ); |
|
641 CleanupStack::PushL( arrFields ); |
|
642 HBufC* addrLebel = NULL; |
|
643 |
|
644 switch ( aAddressType ) |
|
645 { |
|
646 case EVPbkVersitParamPREF: |
|
647 addrLebel = StringLoader::LoadLC( |
|
648 R_QTN_PHOB_HEADER_ADDRESS ); |
|
649 break; |
|
650 case EVPbkVersitParamHOME: |
|
651 addrLebel = StringLoader::LoadLC( |
|
652 R_QTN_PHOB_HEADER_ADDRESS_HOME ); |
|
653 break; |
|
654 case EVPbkVersitParamWORK: |
|
655 addrLebel = StringLoader::LoadLC( |
|
656 R_QTN_PHOB_HEADER_ADDRESS_WORK ); |
|
657 break; |
|
658 default: |
|
659 User::Leave( KErrArgument ); |
|
660 } |
|
661 arrFields->AppendL( addrLebel->Des() ); |
|
662 _LIT(KComma, ","); |
|
663 _LIT(KSpace, " "); |
|
664 TInt lenght = 0; |
|
665 TPtrC street; |
|
666 if ( result->IsPositionFieldAvailable( EPositionFieldStreet ) ) |
|
667 { |
|
668 result->GetPositionField( EPositionFieldStreet, street ); |
|
669 lenght += street.Length(); |
|
670 } |
|
671 |
|
672 TPtrC city; |
|
673 if ( result->IsPositionFieldAvailable( EPositionFieldCity ) ) |
|
674 { |
|
675 result->GetPositionField( EPositionFieldCity, city ); |
|
676 if ( lenght ) |
|
677 { |
|
678 lenght += KComma().Length() + KSpace().Length(); |
|
679 } |
|
680 lenght += city.Length(); |
|
681 } |
|
682 |
|
683 TPtrC country; |
|
684 if ( result->IsPositionFieldAvailable( EPositionFieldCountry ) ) |
|
685 { |
|
686 result->GetPositionField( EPositionFieldCountry, country ); |
|
687 if ( lenght ) |
|
688 { |
|
689 lenght += KComma().Length() + KSpace().Length(); |
|
690 } |
|
691 lenght += country.Length(); |
|
692 } |
|
693 |
|
694 RBuf newAddr; |
|
695 newAddr.CreateL( lenght ); |
|
696 CleanupClosePushL( newAddr ); |
|
697 |
|
698 if ( street.Length() ) |
|
699 { |
|
700 newAddr += street; |
|
701 } |
|
702 |
|
703 if ( city.Length() ) |
|
704 { |
|
705 if ( newAddr.Length() > 0 ) |
|
706 { |
|
707 newAddr += KComma(); |
|
708 newAddr += KSpace(); |
|
709 } |
|
710 newAddr += city; |
|
711 } |
|
712 |
|
713 if ( country.Length() ) |
|
714 { |
|
715 if ( newAddr.Length() > 0 ) |
|
716 { |
|
717 newAddr += KComma(); |
|
718 newAddr += KSpace(); |
|
719 } |
|
720 newAddr += country; |
|
721 } |
|
722 |
|
723 arrFields->AppendL( newAddr ); |
|
724 HBufC* prompt = StringLoader::LoadLC( |
|
725 R_QTN_PHOB_CONFIRM_CHANGE_ADDRESS, *arrFields ); |
|
726 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
727 if ( !dlg->ExecuteLD( R_PBK2_GENERAL_CONFIRMATION_QUERY, *prompt ) ) |
|
728 { |
|
729 update = EFalse; |
|
730 } |
|
731 CleanupStack::PopAndDestroy( prompt ); |
|
732 CleanupStack::PopAndDestroy( &newAddr ); |
|
733 CleanupStack::PopAndDestroy( addrLebel ); |
|
734 CleanupStack::PopAndDestroy( arrFields ); |
|
735 |
|
736 } |
|
737 if ( update ) |
|
738 { |
|
739 if ( !iEditorControl ) |
|
740 { |
|
741 iContact->LockL( *this ); |
|
742 CActiveScheduler::Start(); |
|
743 } |
|
744 UpdateFieldL( *result, EPositionFieldCountry, |
|
745 EVPbkVersitSubFieldCountry, aAddressType ); |
|
746 UpdateFieldL( *result, EPositionFieldCity, |
|
747 EVPbkVersitSubFieldLocality, aAddressType ); |
|
748 UpdateFieldL( *result, EPositionFieldStreet, |
|
749 EVPbkVersitSubFieldStreet, aAddressType ); |
|
750 UpdateFieldL( *result, EPositionFieldPostalCode, |
|
751 EVPbkVersitSubFieldPostalCode, aAddressType ); |
|
752 UpdateFieldL( *result, EPositionFieldLocality, |
|
753 EVPbkVersitSubFieldRegion, aAddressType ); |
|
754 UpdateFieldL( *result, EPositionFieldNone, |
|
755 EVPbkVersitSubFieldPostOfficeAddress, aAddressType ); |
|
756 UpdateFieldL( *result, EPositionFieldNone, |
|
757 EVPbkVersitSubFieldExtendedAddress, aAddressType ); |
|
758 |
|
759 if ( geocoordsExist ) |
|
760 { |
|
761 UpdateCoordsL( locality, aAddressType ); |
|
762 } |
|
763 if ( !iEditorControl ) |
|
764 { |
|
765 iContact->CommitL( *this ); |
|
766 CActiveScheduler::Start(); |
|
767 } |
|
768 if ( ControlExtension() ) |
|
769 { |
|
770 ControlExtension()->UpdateControlsL(); |
|
771 } |
|
772 |
|
773 HBufC* text = StringLoader::LoadLC( |
|
774 R_QTN_PHOB_NOTE_ADDRESS_UPDATED ); |
|
775 CAknInformationNote* note = new (ELeave) CAknInformationNote( |
|
776 ETrue ); |
|
777 note->ExecuteLD( *text ); |
|
778 CleanupStack::PopAndDestroy( text ); |
|
779 } |
|
780 |
|
781 if ( result ) |
|
782 { |
|
783 CleanupStack::PopAndDestroy( result ); |
|
784 } |
|
785 } |
|
786 } |
600 |
787 |
601 // -------------------------------------------------------------------------- |
788 // -------------------------------------------------------------------------- |
602 // CPmapCmd::FillLandmarkL |
789 // CPmapCmd::FillLandmarkL |
603 // -------------------------------------------------------------------------- |
790 // -------------------------------------------------------------------------- |
604 // |
791 // |