94 // CPmapCmd::CPmapCmd |
94 // CPmapCmd::CPmapCmd |
95 // -------------------------------------------------------------------------- |
95 // -------------------------------------------------------------------------- |
96 // |
96 // |
97 CPmapCmd::CPmapCmd( MPbk2ContactEditorControl& aEditorControl, |
97 CPmapCmd::CPmapCmd( MPbk2ContactEditorControl& aEditorControl, |
98 MVPbkStoreContact& aContact, TInt aCommandId ) : |
98 MVPbkStoreContact& aContact, TInt aCommandId ) : |
|
99 CActive( CActive::EPriorityStandard ), |
99 iEditorControl( &aEditorControl ), |
100 iEditorControl( &aEditorControl ), |
100 iContact( &aContact ), |
101 iContact( &aContact ), |
101 iCommandId( aCommandId ) |
102 iCommandId( aCommandId ) |
102 { |
103 { |
|
104 CActiveScheduler::Add( this ); |
103 iAddressUpdatePrompt = ETrue; |
105 iAddressUpdatePrompt = ETrue; |
|
106 iCurrentMapLaunchedByState = EMapNone; |
104 } |
107 } |
105 |
108 |
106 // -------------------------------------------------------------------------- |
109 // -------------------------------------------------------------------------- |
107 // CPmapCmd::CPmapCmd |
110 // CPmapCmd::CPmapCmd |
108 // -------------------------------------------------------------------------- |
111 // -------------------------------------------------------------------------- |
109 // |
112 // |
110 CPmapCmd::CPmapCmd( MPbk2ContactUiControl& aUiControl, TInt aCommandId ) : |
113 CPmapCmd::CPmapCmd( MPbk2ContactUiControl& aUiControl, TInt aCommandId ) : |
|
114 CActive( CActive::EPriorityStandard ), |
111 iUiControl( &aUiControl ), |
115 iUiControl( &aUiControl ), |
112 iCommandId( aCommandId ) |
116 iCommandId( aCommandId ) |
113 { |
117 { |
|
118 CActiveScheduler::Add( this ); |
114 iAddressUpdatePrompt = ETrue; |
119 iAddressUpdatePrompt = ETrue; |
|
120 iCurrentMapLaunchedByState = EMapNone; |
115 } |
121 } |
116 |
122 |
117 // -------------------------------------------------------------------------- |
123 // -------------------------------------------------------------------------- |
118 // CPmapCmd::~CPmapCmd |
124 // CPmapCmd::~CPmapCmd |
119 // -------------------------------------------------------------------------- |
125 // -------------------------------------------------------------------------- |
120 // |
126 // |
121 CPmapCmd::~CPmapCmd() |
127 CPmapCmd::~CPmapCmd() |
122 { |
128 { |
|
129 Cancel(); |
|
130 if(iMapView) |
|
131 { |
|
132 iMapView->ResetLandmarksToShow(); |
|
133 delete iMapView; |
|
134 iMapView = NULL; |
|
135 } |
|
136 ReleaseLandmarkResources(); |
123 if( iUiControl ) |
137 if( iUiControl ) |
124 { |
138 { |
125 iUiControl->RegisterCommand( NULL ); |
139 iUiControl->RegisterCommand( NULL ); |
126 } |
140 } |
127 delete iMapViewProvider; |
141 delete iMapViewProvider; |
584 TLocality locality; |
583 TLocality locality; |
585 if ( landmark->NumOfAvailablePositionFields() > 0 |
584 if ( landmark->NumOfAvailablePositionFields() > 0 |
586 || landmark->GetPosition( locality ) == KErrNone ) |
585 || landmark->GetPosition( locality ) == KErrNone ) |
587 { |
586 { |
588 landmarks.AppendL( landmark ); |
587 landmarks.AppendL( landmark ); |
589 mapview->AddLandmarksToShowL( landmarks ); |
|
590 } |
588 } |
591 |
589 |
592 if ( landmark->GetPosition( locality ) == KErrNone ) |
590 if ( landmark->GetPosition( locality ) == KErrNone ) |
593 { |
591 { |
594 mapview->ShowMapL(); |
592 if(iMapView) |
|
593 { |
|
594 delete iMapView; |
|
595 iMapView = NULL; |
|
596 } |
|
597 iMapView = CMnMapView::NewL( *iMapViewProvider ); |
|
598 iMapView->AddLandmarksToShowL( landmarks ); |
|
599 iMapView->ShowMapL(); |
595 CleanupStack::PopAndDestroy( landmark ); |
600 CleanupStack::PopAndDestroy( landmark ); |
596 CleanupStack::PopAndDestroy( &landmarks ); |
601 CleanupStack::PopAndDestroy( &landmarks ); |
597 CleanupStack::PopAndDestroy( mapview ); |
602 delete iMapView; |
|
603 iMapView = NULL; |
|
604 FinishProcess(); |
598 } |
605 } |
599 else |
606 else |
600 { |
607 { |
601 TRequestStatus status; |
608 if(iMapView) |
602 mapview->SelectFromMapL( status ); |
609 { |
603 User::WaitForRequest( status ); |
610 delete iMapView; |
604 TBool update = EFalse; |
611 iMapView = NULL; |
605 TBool geocoordsExist = EFalse; |
612 } |
606 |
613 iMapView = CMnMapView::NewChainedL( *iMapViewProvider ); |
607 CPosLandmark* result = NULL; |
614 iMapView->AddLandmarksToShowL( landmarks ); |
608 if ( status.Int() == KErrNone ) |
615 iMapView->SelectFromMapL( iStatus ); |
609 { |
616 iCurrentMapLaunchedByState = EMapShowOnMaps; |
610 result = mapview->RetrieveSelectionResultL(); |
617 SetActive(); |
611 if ( result->GetPosition( locality ) == KErrNone ) |
|
612 { |
|
613 geocoordsExist = ETrue; |
|
614 } |
|
615 if ( result->IsPositionFieldAvailable( EPositionFieldStreet ) |
|
616 || result->IsPositionFieldAvailable( EPositionFieldCity ) |
|
617 || result->IsPositionFieldAvailable( EPositionFieldCountry ) ) |
|
618 { |
|
619 update = ETrue; |
|
620 } |
|
621 |
|
622 } |
|
623 CleanupStack::PopAndDestroy( landmark ); |
618 CleanupStack::PopAndDestroy( landmark ); |
624 CleanupStack::PopAndDestroy( &landmarks ); |
619 CleanupStack::PopAndDestroy( &landmarks ); |
625 CleanupStack::PopAndDestroy( mapview ); |
|
626 if ( result ) |
|
627 { |
|
628 CleanupStack::PushL( result ); |
|
629 } |
|
630 |
|
631 if ( update ) |
|
632 { |
|
633 |
|
634 const TInt KGranularity = 4; |
|
635 CDesCArrayFlat* arrFields = new (ELeave) CDesCArrayFlat( |
|
636 KGranularity ); |
|
637 CleanupStack::PushL( arrFields ); |
|
638 HBufC* addrLebel = NULL; |
|
639 |
|
640 switch ( aAddressType ) |
|
641 { |
|
642 case EVPbkVersitParamPREF: |
|
643 addrLebel = StringLoader::LoadLC( |
|
644 R_QTN_PHOB_HEADER_ADDRESS ); |
|
645 break; |
|
646 case EVPbkVersitParamHOME: |
|
647 addrLebel = StringLoader::LoadLC( |
|
648 R_QTN_PHOB_HEADER_ADDRESS_HOME ); |
|
649 break; |
|
650 case EVPbkVersitParamWORK: |
|
651 addrLebel = StringLoader::LoadLC( |
|
652 R_QTN_PHOB_HEADER_ADDRESS_WORK ); |
|
653 break; |
|
654 default: |
|
655 User::Leave( KErrArgument ); |
|
656 } |
|
657 arrFields->AppendL( addrLebel->Des() ); |
|
658 _LIT(KComma, ","); |
|
659 _LIT(KSpace, " "); |
|
660 TInt lenght = 0; |
|
661 TPtrC street; |
|
662 if ( result->IsPositionFieldAvailable( EPositionFieldStreet ) ) |
|
663 { |
|
664 result->GetPositionField( EPositionFieldStreet, street ); |
|
665 lenght += street.Length(); |
|
666 } |
|
667 |
|
668 TPtrC city; |
|
669 if ( result->IsPositionFieldAvailable( EPositionFieldCity ) ) |
|
670 { |
|
671 result->GetPositionField( EPositionFieldCity, city ); |
|
672 if ( lenght ) |
|
673 { |
|
674 lenght += KComma().Length() + KSpace().Length(); |
|
675 } |
|
676 lenght += city.Length(); |
|
677 } |
|
678 |
|
679 TPtrC country; |
|
680 if ( result->IsPositionFieldAvailable( EPositionFieldCountry ) ) |
|
681 { |
|
682 result->GetPositionField( EPositionFieldCountry, country ); |
|
683 if ( lenght ) |
|
684 { |
|
685 lenght += KComma().Length() + KSpace().Length(); |
|
686 } |
|
687 lenght += country.Length(); |
|
688 } |
|
689 |
|
690 RBuf newAddr; |
|
691 newAddr.CreateL( lenght ); |
|
692 CleanupClosePushL( newAddr ); |
|
693 |
|
694 if ( street.Length() ) |
|
695 { |
|
696 newAddr += street; |
|
697 } |
|
698 |
|
699 if ( city.Length() ) |
|
700 { |
|
701 if ( newAddr.Length() > 0 ) |
|
702 { |
|
703 newAddr += KComma(); |
|
704 newAddr += KSpace(); |
|
705 } |
|
706 newAddr += city; |
|
707 } |
|
708 |
|
709 if ( country.Length() ) |
|
710 { |
|
711 if ( newAddr.Length() > 0 ) |
|
712 { |
|
713 newAddr += KComma(); |
|
714 newAddr += KSpace(); |
|
715 } |
|
716 newAddr += country; |
|
717 } |
|
718 |
|
719 arrFields->AppendL( newAddr ); |
|
720 HBufC* prompt = StringLoader::LoadLC( |
|
721 R_QTN_PHOB_CONFIRM_CHANGE_ADDRESS, *arrFields ); |
|
722 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
723 if ( !dlg->ExecuteLD( R_PBK2_GENERAL_CONFIRMATION_QUERY, *prompt ) ) |
|
724 { |
|
725 update = EFalse; |
|
726 } |
|
727 CleanupStack::PopAndDestroy( prompt ); |
|
728 CleanupStack::PopAndDestroy( &newAddr ); |
|
729 CleanupStack::PopAndDestroy( addrLebel ); |
|
730 CleanupStack::PopAndDestroy( arrFields ); |
|
731 |
|
732 } |
|
733 if ( update ) |
|
734 { |
|
735 if ( !iEditorControl ) |
|
736 { |
|
737 iContact->LockL( *this ); |
|
738 CActiveScheduler::Start(); |
|
739 } |
|
740 UpdateFieldL( *result, EPositionFieldCountry, |
|
741 EVPbkVersitSubFieldCountry, aAddressType ); |
|
742 UpdateFieldL( *result, EPositionFieldCity, |
|
743 EVPbkVersitSubFieldLocality, aAddressType ); |
|
744 UpdateFieldL( *result, EPositionFieldStreet, |
|
745 EVPbkVersitSubFieldStreet, aAddressType ); |
|
746 UpdateFieldL( *result, EPositionFieldPostalCode, |
|
747 EVPbkVersitSubFieldPostalCode, aAddressType ); |
|
748 UpdateFieldL( *result, EPositionFieldLocality, |
|
749 EVPbkVersitSubFieldRegion, aAddressType ); |
|
750 UpdateFieldL( *result, EPositionFieldNone, |
|
751 EVPbkVersitSubFieldPostOfficeAddress, aAddressType ); |
|
752 UpdateFieldL( *result, EPositionFieldNone, |
|
753 EVPbkVersitSubFieldExtendedAddress, aAddressType ); |
|
754 |
|
755 if ( geocoordsExist ) |
|
756 { |
|
757 UpdateCoordsL( locality, aAddressType ); |
|
758 } |
|
759 if ( !iEditorControl ) |
|
760 { |
|
761 iContact->CommitL( *this ); |
|
762 CActiveScheduler::Start(); |
|
763 } |
|
764 if ( ControlExtension() ) |
|
765 { |
|
766 ControlExtension()->UpdateControlsL(); |
|
767 } |
|
768 |
|
769 HBufC* text = StringLoader::LoadLC( |
|
770 R_QTN_PHOB_NOTE_ADDRESS_UPDATED ); |
|
771 CAknInformationNote* note = new (ELeave) CAknInformationNote( |
|
772 ETrue ); |
|
773 note->ExecuteLD( *text ); |
|
774 CleanupStack::PopAndDestroy( text ); |
|
775 } |
|
776 |
|
777 if ( result ) |
|
778 { |
|
779 CleanupStack::PopAndDestroy( result ); |
|
780 } |
|
781 } |
620 } |
782 } |
621 } |
783 |
622 |
784 // -------------------------------------------------------------------------- |
623 // -------------------------------------------------------------------------- |
785 // CPmapCmd::FillLandmarkL |
624 // CPmapCmd::FillLandmarkL |
1040 if ( !FillGeoLandmarkL( *landmark, aAddressType ) ) |
885 if ( !FillGeoLandmarkL( *landmark, aAddressType ) ) |
1041 { |
886 { |
1042 FillLandmarkL( *landmark, aAddressType ); |
887 FillLandmarkL( *landmark, aAddressType ); |
1043 } |
888 } |
1044 TLocality locality; |
889 TLocality locality; |
1045 TBool noAddress = ETrue; |
890 iNoAddress = ETrue; |
1046 if( landmark->NumOfAvailablePositionFields() > 0 || landmark->GetPosition( locality ) == KErrNone ) |
891 if( landmark->NumOfAvailablePositionFields() > 0 || landmark->GetPosition( locality ) == KErrNone ) |
1047 { |
892 { |
1048 landmarks.AppendL( landmark ); |
893 landmarks.AppendL( landmark ); |
1049 mapview->AddLandmarksToShowL( landmarks ); |
894 iMapView->AddLandmarksToShowL( landmarks ); |
1050 noAddress = EFalse; |
895 iNoAddress = EFalse; |
1051 } |
896 } |
1052 |
897 |
1053 TRequestStatus status; |
898 iMapView->SelectFromMapL( iStatus ); |
1054 mapview->SelectFromMapL( status ); |
899 iCurrentMapLaunchedByState = EMapAssignFromMaps; |
1055 User::WaitForRequest( status ); |
900 SetActive(); |
1056 |
901 CleanupStack::PopAndDestroy( landmark ); |
1057 TBool update = EFalse; |
902 CleanupStack::PopAndDestroy( &landmarks ); |
1058 TBool geocoordsExist = EFalse; |
|
1059 |
|
1060 CPosLandmark* result = NULL; |
|
1061 if ( status.Int() == KErrNone ) |
|
1062 { |
|
1063 result = mapview->RetrieveSelectionResultL(); |
|
1064 if ( result->GetPosition( locality ) == KErrNone ) |
|
1065 { |
|
1066 geocoordsExist = ETrue; |
|
1067 } |
|
1068 |
|
1069 if( result->IsPositionFieldAvailable( EPositionFieldStreet ) || |
|
1070 result->IsPositionFieldAvailable( EPositionFieldCity ) || |
|
1071 result->IsPositionFieldAvailable( EPositionFieldCountry ) ) |
|
1072 { |
|
1073 update= ETrue; |
|
1074 } |
|
1075 |
|
1076 } |
|
1077 CleanupStack::PopAndDestroy( landmark ); |
|
1078 CleanupStack::PopAndDestroy( &landmarks ); |
|
1079 CleanupStack::PopAndDestroy( mapview ); |
|
1080 if( result ) |
|
1081 { |
|
1082 CleanupStack::PushL( result ); |
|
1083 } |
|
1084 |
|
1085 if( update ) |
|
1086 { |
|
1087 if( iAddressUpdatePrompt && !noAddress ) |
|
1088 { |
|
1089 const TInt KGranularity = 4; |
|
1090 CDesCArrayFlat* arrFields = new ( ELeave ) CDesCArrayFlat |
|
1091 ( KGranularity ); |
|
1092 CleanupStack::PushL(arrFields); |
|
1093 |
|
1094 HBufC* addrLebel = NULL; |
|
1095 |
|
1096 switch( aAddressType ) |
|
1097 { |
|
1098 case EVPbkVersitParamPREF: |
|
1099 addrLebel = StringLoader::LoadLC(R_QTN_PHOB_HEADER_ADDRESS ); |
|
1100 break; |
|
1101 case EVPbkVersitParamHOME: |
|
1102 addrLebel = StringLoader::LoadLC( R_QTN_PHOB_HEADER_ADDRESS_HOME ); |
|
1103 break; |
|
1104 case EVPbkVersitParamWORK: |
|
1105 addrLebel = StringLoader::LoadLC( R_QTN_PHOB_HEADER_ADDRESS_WORK ); |
|
1106 break; |
|
1107 default: |
|
1108 User::Leave(KErrArgument); |
|
1109 } |
|
1110 arrFields->AppendL( addrLebel->Des() ); |
|
1111 |
|
1112 _LIT(KComma, ","); |
|
1113 _LIT(KSpace, " "); |
|
1114 |
|
1115 TInt lenght = 0; |
|
1116 TPtrC street; |
|
1117 if( result->IsPositionFieldAvailable( EPositionFieldStreet ) ) |
|
1118 { |
|
1119 result->GetPositionField( EPositionFieldStreet, street ); |
|
1120 lenght += street.Length(); |
|
1121 } |
|
1122 |
|
1123 TPtrC city; |
|
1124 if( result->IsPositionFieldAvailable( EPositionFieldCity ) ) |
|
1125 { |
|
1126 result->GetPositionField( EPositionFieldCity, city ); |
|
1127 if( lenght ) |
|
1128 { |
|
1129 lenght += KComma().Length() + KSpace().Length(); |
|
1130 } |
|
1131 lenght += city.Length(); |
|
1132 } |
|
1133 |
|
1134 TPtrC country; |
|
1135 if( result->IsPositionFieldAvailable( EPositionFieldCountry ) ) |
|
1136 { |
|
1137 result->GetPositionField( EPositionFieldCountry, country ); |
|
1138 if( lenght ) |
|
1139 { |
|
1140 lenght += KComma().Length() + KSpace().Length(); |
|
1141 } |
|
1142 lenght += country.Length(); |
|
1143 } |
|
1144 |
|
1145 RBuf newAddr; |
|
1146 newAddr.CreateL( lenght ); |
|
1147 CleanupClosePushL( newAddr ); |
|
1148 |
|
1149 if( street.Length() ) |
|
1150 { |
|
1151 newAddr += street; |
|
1152 } |
|
1153 |
|
1154 if( city.Length() ) |
|
1155 { |
|
1156 if( newAddr.Length() > 0 ) |
|
1157 { |
|
1158 newAddr += KComma(); |
|
1159 newAddr += KSpace(); |
|
1160 } |
|
1161 newAddr += city; |
|
1162 } |
|
1163 |
|
1164 if( country.Length() ) |
|
1165 { |
|
1166 if( newAddr.Length() > 0 ) |
|
1167 { |
|
1168 newAddr += KComma(); |
|
1169 newAddr += KSpace(); |
|
1170 } |
|
1171 newAddr += country; |
|
1172 } |
|
1173 |
|
1174 arrFields->AppendL( newAddr ); |
|
1175 HBufC* prompt = StringLoader::LoadLC( R_QTN_PHOB_CONFIRM_CHANGE_ADDRESS, *arrFields ); |
|
1176 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
1177 if( !dlg->ExecuteLD( R_PBK2_GENERAL_CONFIRMATION_QUERY, *prompt ) ) |
|
1178 { |
|
1179 update = EFalse; |
|
1180 } |
|
1181 CleanupStack::PopAndDestroy( prompt ); |
|
1182 CleanupStack::PopAndDestroy( &newAddr ); |
|
1183 CleanupStack::PopAndDestroy( addrLebel ); |
|
1184 CleanupStack::PopAndDestroy( arrFields ); |
|
1185 } |
|
1186 |
|
1187 if( update ) |
|
1188 { |
|
1189 if ( !iEditorControl ) |
|
1190 { |
|
1191 iContact->LockL( *this ); |
|
1192 CActiveScheduler::Start(); |
|
1193 } |
|
1194 UpdateFieldL( *result, EPositionFieldCountry, |
|
1195 EVPbkVersitSubFieldCountry, aAddressType ); |
|
1196 UpdateFieldL( *result, EPositionFieldCity, |
|
1197 EVPbkVersitSubFieldLocality, aAddressType ); |
|
1198 UpdateFieldL( *result, EPositionFieldStreet, |
|
1199 EVPbkVersitSubFieldStreet, aAddressType ); |
|
1200 UpdateFieldL( *result, EPositionFieldPostalCode, |
|
1201 EVPbkVersitSubFieldPostalCode, aAddressType ); |
|
1202 UpdateFieldL( *result, EPositionFieldLocality, |
|
1203 EVPbkVersitSubFieldRegion, aAddressType ); |
|
1204 UpdateFieldL( *result, EPositionFieldNone, |
|
1205 EVPbkVersitSubFieldPostOfficeAddress, aAddressType ); |
|
1206 UpdateFieldL( *result, EPositionFieldNone, |
|
1207 EVPbkVersitSubFieldExtendedAddress, aAddressType ); |
|
1208 |
|
1209 if( geocoordsExist ) |
|
1210 { |
|
1211 UpdateCoordsL( locality, aAddressType ); |
|
1212 } |
|
1213 if ( !iEditorControl ) |
|
1214 { |
|
1215 iContact->CommitL( *this ); |
|
1216 CActiveScheduler::Start(); |
|
1217 } |
|
1218 if( ControlExtension() ) |
|
1219 { |
|
1220 ControlExtension()->UpdateControlsL(); |
|
1221 } |
|
1222 |
|
1223 HBufC* text = StringLoader::LoadLC( R_QTN_PHOB_NOTE_ADDRESS_UPDATED ); |
|
1224 CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue ); |
|
1225 note->ExecuteLD( *text ); |
|
1226 CleanupStack::PopAndDestroy( text ); |
|
1227 } |
|
1228 } |
|
1229 |
|
1230 if( result ) |
|
1231 { |
|
1232 CleanupStack::PopAndDestroy( result ); |
|
1233 } |
|
1234 } |
903 } |
1235 |
904 |
1236 // -------------------------------------------------------------------------- |
905 // -------------------------------------------------------------------------- |
1237 // CPmapCmd::UpdateCoordsL |
906 // CPmapCmd::UpdateCoordsL |
1238 // -------------------------------------------------------------------------- |
907 // -------------------------------------------------------------------------- |
1537 |
1206 |
1538 CActiveScheduler::Stop(); |
1207 CActiveScheduler::Stop(); |
1539 } |
1208 } |
1540 |
1209 |
1541 // -------------------------------------------------------------------------- |
1210 // -------------------------------------------------------------------------- |
|
1211 // CPmapCmd::HandleSelectiOnAssignFromMapsL |
|
1212 // -------------------------------------------------------------------------- |
|
1213 // |
|
1214 void CPmapCmd::HandleSelectiOnAssignFromMapsL() |
|
1215 { |
|
1216 TBool update = EFalse; |
|
1217 TBool geocoordsExist = EFalse; |
|
1218 |
|
1219 TLocality locality; |
|
1220 CPosLandmark* result = NULL; |
|
1221 TInt currentstatus = iStatus.Int(); |
|
1222 if ( iStatus.Int() == KErrNone && iMapView) |
|
1223 { |
|
1224 result = iMapView->RetrieveSelectionResultL(); |
|
1225 // Get the location name if available |
|
1226 //-----------------Emulator Hack------------------------------- |
|
1227 // result->SetLandmarkNameL(_L("Jupiter Tech Park")); |
|
1228 // result->SetPositionFieldL(EPositionFieldCity, _L("Bangalore")); |
|
1229 // result->SetPositionFieldL(EPositionFieldCountry, _L("India")); |
|
1230 //------------------------------------------------------------- |
|
1231 if(result->GetPosition( locality ) == KErrNone ) |
|
1232 { |
|
1233 geocoordsExist = ETrue; |
|
1234 } |
|
1235 |
|
1236 if( result->IsPositionFieldAvailable( EPositionFieldStreet ) || |
|
1237 result->IsPositionFieldAvailable( EPositionFieldCity ) || |
|
1238 result->IsPositionFieldAvailable( EPositionFieldCountry ) ) |
|
1239 { |
|
1240 update= ETrue; |
|
1241 } |
|
1242 } |
|
1243 delete iMapView; |
|
1244 iMapView = NULL; |
|
1245 if( result ) |
|
1246 { |
|
1247 CleanupStack::PushL( result ); |
|
1248 } |
|
1249 |
|
1250 if( update ) |
|
1251 { |
|
1252 if( iAddressUpdatePrompt && !iNoAddress ) |
|
1253 { |
|
1254 const TInt KGranularity = 4; |
|
1255 CDesCArrayFlat* arrFields = new ( ELeave ) CDesCArrayFlat |
|
1256 ( KGranularity ); |
|
1257 CleanupStack::PushL(arrFields); |
|
1258 |
|
1259 HBufC* addrLebel = NULL; |
|
1260 |
|
1261 switch( iAddressType ) |
|
1262 { |
|
1263 case EVPbkVersitParamPREF: |
|
1264 addrLebel = StringLoader::LoadLC(R_QTN_PHOB_HEADER_ADDRESS ); |
|
1265 break; |
|
1266 case EVPbkVersitParamHOME: |
|
1267 addrLebel = StringLoader::LoadLC( R_QTN_PHOB_HEADER_ADDRESS_HOME ); |
|
1268 break; |
|
1269 case EVPbkVersitParamWORK: |
|
1270 addrLebel = StringLoader::LoadLC( R_QTN_PHOB_HEADER_ADDRESS_WORK ); |
|
1271 break; |
|
1272 default: |
|
1273 User::Leave(KErrArgument); |
|
1274 } |
|
1275 arrFields->AppendL( addrLebel->Des() ); |
|
1276 |
|
1277 _LIT(KComma, ","); |
|
1278 _LIT(KSpace, " "); |
|
1279 |
|
1280 TInt lenght = 0; |
|
1281 TPtrC street; |
|
1282 if( result->IsPositionFieldAvailable( EPositionFieldStreet ) ) |
|
1283 { |
|
1284 result->GetPositionField( EPositionFieldStreet, street ); |
|
1285 lenght += street.Length(); |
|
1286 } |
|
1287 |
|
1288 TPtrC city; |
|
1289 if( result->IsPositionFieldAvailable( EPositionFieldCity ) ) |
|
1290 { |
|
1291 result->GetPositionField( EPositionFieldCity, city ); |
|
1292 if( lenght ) |
|
1293 { |
|
1294 lenght += KComma().Length() + KSpace().Length(); |
|
1295 } |
|
1296 lenght += city.Length(); |
|
1297 } |
|
1298 |
|
1299 TPtrC country; |
|
1300 if( result->IsPositionFieldAvailable( EPositionFieldCountry ) ) |
|
1301 { |
|
1302 result->GetPositionField( EPositionFieldCountry, country ); |
|
1303 if( lenght ) |
|
1304 { |
|
1305 lenght += KComma().Length() + KSpace().Length(); |
|
1306 } |
|
1307 lenght += country.Length(); |
|
1308 } |
|
1309 |
|
1310 RBuf newAddr; |
|
1311 newAddr.CreateL( lenght ); |
|
1312 CleanupClosePushL( newAddr ); |
|
1313 |
|
1314 if( street.Length() ) |
|
1315 { |
|
1316 newAddr += street; |
|
1317 } |
|
1318 |
|
1319 if( city.Length() ) |
|
1320 { |
|
1321 if( newAddr.Length() > 0 ) |
|
1322 { |
|
1323 newAddr += KComma(); |
|
1324 newAddr += KSpace(); |
|
1325 } |
|
1326 newAddr += city; |
|
1327 } |
|
1328 |
|
1329 if( country.Length() ) |
|
1330 { |
|
1331 if( newAddr.Length() > 0 ) |
|
1332 { |
|
1333 newAddr += KComma(); |
|
1334 newAddr += KSpace(); |
|
1335 } |
|
1336 newAddr += country; |
|
1337 } |
|
1338 |
|
1339 arrFields->AppendL( newAddr ); |
|
1340 HBufC* prompt = StringLoader::LoadLC( R_QTN_PHOB_CONFIRM_CHANGE_ADDRESS, *arrFields ); |
|
1341 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
1342 if( !dlg->ExecuteLD( R_PBK2_GENERAL_CONFIRMATION_QUERY, *prompt ) ) |
|
1343 { |
|
1344 update = EFalse; |
|
1345 } |
|
1346 CleanupStack::PopAndDestroy( prompt ); |
|
1347 CleanupStack::PopAndDestroy( &newAddr ); |
|
1348 CleanupStack::PopAndDestroy( addrLebel ); |
|
1349 CleanupStack::PopAndDestroy( arrFields ); |
|
1350 } |
|
1351 |
|
1352 if( update ) |
|
1353 { |
|
1354 if ( !iEditorControl ) |
|
1355 { |
|
1356 iContact->LockL( *this ); |
|
1357 CActiveScheduler::Start(); |
|
1358 } |
|
1359 UpdateFieldL( *result, EPositionFieldCountry, |
|
1360 EVPbkVersitSubFieldCountry, iAddressType ); |
|
1361 UpdateFieldL( *result, EPositionFieldCity, |
|
1362 EVPbkVersitSubFieldLocality, iAddressType ); |
|
1363 UpdateFieldL( *result, EPositionFieldStreet, |
|
1364 EVPbkVersitSubFieldStreet, iAddressType ); |
|
1365 UpdateFieldL( *result, EPositionFieldPostalCode, |
|
1366 EVPbkVersitSubFieldPostalCode, iAddressType ); |
|
1367 UpdateFieldL( *result, EPositionFieldLocality, |
|
1368 EVPbkVersitSubFieldRegion, iAddressType ); |
|
1369 UpdateFieldL( *result, EPositionFieldNone, |
|
1370 EVPbkVersitSubFieldPostOfficeAddress, iAddressType ); |
|
1371 UpdateFieldL( *result, EPositionFieldNone, |
|
1372 EVPbkVersitSubFieldExtendedAddress, iAddressType ); |
|
1373 |
|
1374 if( geocoordsExist ) |
|
1375 { |
|
1376 UpdateCoordsL( locality, iAddressType ); |
|
1377 } |
|
1378 if ( !iEditorControl ) |
|
1379 { |
|
1380 iContact->CommitL( *this ); |
|
1381 CActiveScheduler::Start(); |
|
1382 } |
|
1383 if( ControlExtension() ) |
|
1384 { |
|
1385 ControlExtension()->UpdateControlsL(); |
|
1386 } |
|
1387 |
|
1388 HBufC* text = StringLoader::LoadLC( R_QTN_PHOB_NOTE_ADDRESS_UPDATED ); |
|
1389 CAknInformationNote* note = new ( ELeave ) CAknInformationNote( ETrue ); |
|
1390 note->ExecuteLD( *text ); |
|
1391 CleanupStack::PopAndDestroy( text ); |
|
1392 } |
|
1393 } |
|
1394 |
|
1395 if( result ) |
|
1396 { |
|
1397 CleanupStack::PopAndDestroy( result ); |
|
1398 } |
|
1399 } |
|
1400 |
|
1401 // -------------------------------------------------------------------------- |
|
1402 // CPmapCmd::HandleSelectiOnAssignFromMapsL |
|
1403 // -------------------------------------------------------------------------- |
|
1404 // |
|
1405 void CPmapCmd::HandleSelectiOnShowOnMapsL() |
|
1406 { |
|
1407 TBool update = EFalse; |
|
1408 TBool geocoordsExist = EFalse; |
|
1409 |
|
1410 TLocality locality; |
|
1411 CPosLandmark* result = NULL; |
|
1412 if ( iStatus.Int() == KErrNone && iMapView) |
|
1413 { |
|
1414 result = iMapView->RetrieveSelectionResultL(); |
|
1415 if ( result->GetPosition( locality ) == KErrNone ) |
|
1416 { |
|
1417 geocoordsExist = ETrue; |
|
1418 } |
|
1419 if ( result->IsPositionFieldAvailable( EPositionFieldStreet ) |
|
1420 || result->IsPositionFieldAvailable( EPositionFieldCity ) |
|
1421 || result->IsPositionFieldAvailable( EPositionFieldCountry ) ) |
|
1422 { |
|
1423 update = ETrue; |
|
1424 } |
|
1425 |
|
1426 } |
|
1427 |
|
1428 delete iMapView; |
|
1429 iMapView = NULL; |
|
1430 if ( result ) |
|
1431 { |
|
1432 CleanupStack::PushL( result ); |
|
1433 } |
|
1434 |
|
1435 if ( update ) |
|
1436 { |
|
1437 |
|
1438 const TInt KGranularity = 4; |
|
1439 CDesCArrayFlat* arrFields = new (ELeave) CDesCArrayFlat( |
|
1440 KGranularity ); |
|
1441 CleanupStack::PushL( arrFields ); |
|
1442 HBufC* addrLebel = NULL; |
|
1443 |
|
1444 switch ( iAddressType ) |
|
1445 { |
|
1446 case EVPbkVersitParamPREF: |
|
1447 addrLebel = StringLoader::LoadLC( |
|
1448 R_QTN_PHOB_HEADER_ADDRESS ); |
|
1449 break; |
|
1450 case EVPbkVersitParamHOME: |
|
1451 addrLebel = StringLoader::LoadLC( |
|
1452 R_QTN_PHOB_HEADER_ADDRESS_HOME ); |
|
1453 break; |
|
1454 case EVPbkVersitParamWORK: |
|
1455 addrLebel = StringLoader::LoadLC( |
|
1456 R_QTN_PHOB_HEADER_ADDRESS_WORK ); |
|
1457 break; |
|
1458 default: |
|
1459 User::Leave( KErrArgument ); |
|
1460 } |
|
1461 arrFields->AppendL( addrLebel->Des() ); |
|
1462 _LIT(KComma, ","); |
|
1463 _LIT(KSpace, " "); |
|
1464 TInt lenght = 0; |
|
1465 TPtrC street; |
|
1466 if ( result->IsPositionFieldAvailable( EPositionFieldStreet ) ) |
|
1467 { |
|
1468 result->GetPositionField( EPositionFieldStreet, street ); |
|
1469 lenght += street.Length(); |
|
1470 } |
|
1471 |
|
1472 TPtrC city; |
|
1473 if ( result->IsPositionFieldAvailable( EPositionFieldCity ) ) |
|
1474 { |
|
1475 result->GetPositionField( EPositionFieldCity, city ); |
|
1476 if ( lenght ) |
|
1477 { |
|
1478 lenght += KComma().Length() + KSpace().Length(); |
|
1479 } |
|
1480 lenght += city.Length(); |
|
1481 } |
|
1482 |
|
1483 TPtrC country; |
|
1484 if ( result->IsPositionFieldAvailable( EPositionFieldCountry ) ) |
|
1485 { |
|
1486 result->GetPositionField( EPositionFieldCountry, country ); |
|
1487 if ( lenght ) |
|
1488 { |
|
1489 lenght += KComma().Length() + KSpace().Length(); |
|
1490 } |
|
1491 lenght += country.Length(); |
|
1492 } |
|
1493 |
|
1494 RBuf newAddr; |
|
1495 newAddr.CreateL( lenght ); |
|
1496 CleanupClosePushL( newAddr ); |
|
1497 |
|
1498 if ( street.Length() ) |
|
1499 { |
|
1500 newAddr += street; |
|
1501 } |
|
1502 |
|
1503 if ( city.Length() ) |
|
1504 { |
|
1505 if ( newAddr.Length() > 0 ) |
|
1506 { |
|
1507 newAddr += KComma(); |
|
1508 newAddr += KSpace(); |
|
1509 } |
|
1510 newAddr += city; |
|
1511 } |
|
1512 |
|
1513 if ( country.Length() ) |
|
1514 { |
|
1515 if ( newAddr.Length() > 0 ) |
|
1516 { |
|
1517 newAddr += KComma(); |
|
1518 newAddr += KSpace(); |
|
1519 } |
|
1520 newAddr += country; |
|
1521 } |
|
1522 |
|
1523 arrFields->AppendL( newAddr ); |
|
1524 HBufC* prompt = StringLoader::LoadLC( |
|
1525 R_QTN_PHOB_CONFIRM_CHANGE_ADDRESS, *arrFields ); |
|
1526 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
1527 if ( !dlg->ExecuteLD( R_PBK2_GENERAL_CONFIRMATION_QUERY, *prompt ) ) |
|
1528 { |
|
1529 update = EFalse; |
|
1530 } |
|
1531 CleanupStack::PopAndDestroy( prompt ); |
|
1532 CleanupStack::PopAndDestroy( &newAddr ); |
|
1533 CleanupStack::PopAndDestroy( addrLebel ); |
|
1534 CleanupStack::PopAndDestroy( arrFields ); |
|
1535 |
|
1536 } |
|
1537 if ( update ) |
|
1538 { |
|
1539 if ( !iEditorControl ) |
|
1540 { |
|
1541 iContact->LockL( *this ); |
|
1542 CActiveScheduler::Start(); |
|
1543 } |
|
1544 UpdateFieldL( *result, EPositionFieldCountry, |
|
1545 EVPbkVersitSubFieldCountry, iAddressType ); |
|
1546 UpdateFieldL( *result, EPositionFieldCity, |
|
1547 EVPbkVersitSubFieldLocality, iAddressType ); |
|
1548 UpdateFieldL( *result, EPositionFieldStreet, |
|
1549 EVPbkVersitSubFieldStreet, iAddressType ); |
|
1550 UpdateFieldL( *result, EPositionFieldPostalCode, |
|
1551 EVPbkVersitSubFieldPostalCode, iAddressType ); |
|
1552 UpdateFieldL( *result, EPositionFieldLocality, |
|
1553 EVPbkVersitSubFieldRegion, iAddressType ); |
|
1554 UpdateFieldL( *result, EPositionFieldNone, |
|
1555 EVPbkVersitSubFieldPostOfficeAddress, iAddressType ); |
|
1556 UpdateFieldL( *result, EPositionFieldNone, |
|
1557 EVPbkVersitSubFieldExtendedAddress, iAddressType ); |
|
1558 |
|
1559 if ( geocoordsExist ) |
|
1560 { |
|
1561 UpdateCoordsL( locality, iAddressType ); |
|
1562 } |
|
1563 if ( !iEditorControl ) |
|
1564 { |
|
1565 iContact->CommitL( *this ); |
|
1566 CActiveScheduler::Start(); |
|
1567 } |
|
1568 if ( ControlExtension() ) |
|
1569 { |
|
1570 ControlExtension()->UpdateControlsL(); |
|
1571 } |
|
1572 |
|
1573 HBufC* text = StringLoader::LoadLC( |
|
1574 R_QTN_PHOB_NOTE_ADDRESS_UPDATED ); |
|
1575 CAknInformationNote* note = new (ELeave) CAknInformationNote( |
|
1576 ETrue ); |
|
1577 note->ExecuteLD( *text ); |
|
1578 CleanupStack::PopAndDestroy( text ); |
|
1579 } |
|
1580 |
|
1581 if ( result ) |
|
1582 { |
|
1583 CleanupStack::PopAndDestroy( result ); |
|
1584 } |
|
1585 } |
|
1586 |
|
1587 // -------------------------------------------------------------------------- |
1542 // CPmapCmd::ContactOperationFailed |
1588 // CPmapCmd::ContactOperationFailed |
1543 // -------------------------------------------------------------------------- |
1589 // -------------------------------------------------------------------------- |
1544 // |
1590 // |
1545 void CPmapCmd::ContactOperationFailed |
1591 void CPmapCmd::ContactOperationFailed |
1546 (TContactOp /*aOpCode*/, TInt /*aErrorCode*/, TBool /*aErrorNotified*/) |
1592 (TContactOp /*aOpCode*/, TInt /*aErrorCode*/, TBool /*aErrorNotified*/) |
1547 { |
1593 { |
1548 CActiveScheduler::Stop(); |
1594 CActiveScheduler::Stop(); |
1549 } |
1595 } |
1550 |
1596 |
|
1597 // ---------------------------------------------------------------------------- |
|
1598 // CPmapCmd::RunL |
|
1599 // RunL method to handle the user selection |
|
1600 // (other items were commented in a header). |
|
1601 // ---------------------------------------------------------------------------- |
|
1602 // |
|
1603 void CPmapCmd::RunL() |
|
1604 { |
|
1605 // request is completed, inform observer |
|
1606 TInt maperror = iStatus.Int(); |
|
1607 if(iStatus.Int() == KErrNone) |
|
1608 { |
|
1609 switch(iCurrentMapLaunchedByState) |
|
1610 { |
|
1611 case EMapAssignFromMaps: |
|
1612 { |
|
1613 HandleSelectiOnAssignFromMapsL(); |
|
1614 } |
|
1615 break; |
|
1616 case EMapShowOnMaps: |
|
1617 { |
|
1618 HandleSelectiOnShowOnMapsL(); |
|
1619 } |
|
1620 break; |
|
1621 default: |
|
1622 break; |
|
1623 } |
|
1624 } |
|
1625 FinishProcess(); |
|
1626 |
|
1627 if(!iUiControl) |
|
1628 { |
|
1629 // delete this; |
|
1630 } |
|
1631 iCurrentMapLaunchedByState = EMapNone; |
|
1632 } |
|
1633 |
|
1634 // ---------------------------------------------------------------------------- |
|
1635 // CPmapCmd::RunError |
|
1636 // Function to handle any errors in async request |
|
1637 // (other items were commented in a header). |
|
1638 // ---------------------------------------------------------------------------- |
|
1639 // |
|
1640 TInt CPmapCmd::RunError( TInt /*aError*/ ) |
|
1641 { |
|
1642 Reset(); |
|
1643 return KErrNone; |
|
1644 } |
|
1645 |
|
1646 // ---------------------------------------------------------------------------- |
|
1647 // CPmapCmd::DoCancel |
|
1648 // Cancel method to handle the user selection |
|
1649 // (other items were commented in a header). |
|
1650 // ---------------------------------------------------------------------------- |
|
1651 // |
|
1652 void CPmapCmd::DoCancel() |
|
1653 { |
|
1654 if ( IsActive() && iMapView ) |
|
1655 { |
|
1656 iMapView->Cancel(); |
|
1657 } |
|
1658 Reset(); |
|
1659 } |
|
1660 |
|
1661 // ---------------------------------------------------------------------------- |
|
1662 // CPmapCmd::Reset |
|
1663 // Disconnects from provider, when operation is completed |
|
1664 // (other items were commented in a header). |
|
1665 // ---------------------------------------------------------------------------- |
|
1666 // |
|
1667 void CPmapCmd::Reset() |
|
1668 { |
|
1669 if(iMapView) |
|
1670 { |
|
1671 iMapView->ResetLandmarksToShow(); |
|
1672 delete iMapView; |
|
1673 iMapView = NULL; |
|
1674 } |
|
1675 ReleaseLandmarkResources(); |
|
1676 } |
|
1677 |
1551 // End of File |
1678 // End of File |