41 #include <mnproviderfinder.h> |
41 #include <mnproviderfinder.h> |
42 #include <EPos_CPosLandmark.h> |
42 #include <EPos_CPosLandmark.h> |
43 #include <lbsposition.h> |
43 #include <lbsposition.h> |
44 #include <e32math.h> |
44 #include <e32math.h> |
45 #include <calencontext.h> |
45 #include <calencontext.h> |
|
46 #include <AknUtils.h> |
46 |
47 |
47 // CONSTANTS and MACROS |
48 // CONSTANTS and MACROS |
48 _LIT(KComma, ","); |
49 _LIT(KComma, ","); |
49 _LIT(KNokiaVendorName, "Nokia gate5 GmbH"); |
50 _LIT(KNokiaVendorName, "Nokia gate5 GmbH"); |
50 const TInt KCalenMaxTextEditorLength(160); |
51 const TInt KCalenMaxTextEditorLength(160); |
|
52 _LIT( KReplaceWhitespaceChars, "\x0009\x000A\x000B\x000C\x000D\x2028\x2029" ); |
51 |
53 |
52 // ---------------------------------------------------------------------------- |
54 // ---------------------------------------------------------------------------- |
53 // CCalenLocationUi::NewL |
55 // CCalenLocationUi::NewL |
54 // First stage construction |
56 // First stage construction |
55 // (other items were commented in a header). |
57 // (other items were commented in a header). |
411 iLocationSelector->SelectL( *iProvider, landmarkToShow ); |
415 iLocationSelector->SelectL( *iProvider, landmarkToShow ); |
412 delete landmarkToShow; |
416 delete landmarkToShow; |
413 } |
417 } |
414 else if(location.Length()) |
418 else if(location.Length()) |
415 { |
419 { |
|
420 TBuf<KCalenMaxTextEditorLength> locationBuf; |
|
421 locationBuf.Copy(location); |
|
422 AknTextUtils::ReplaceCharacters(locationBuf, KReplaceWhitespaceChars, TChar(' ')); |
416 // Add dummy landmark, so that Maps search box will get filled |
423 // Add dummy landmark, so that Maps search box will get filled |
417 CPosLandmark* landmarkToShow = CPosLandmark::NewL(); |
424 CPosLandmark* landmarkToShow = CPosLandmark::NewL(); |
418 landmarkToShow->SetLandmarkNameL(location); |
425 landmarkToShow->SetLandmarkNameL(locationBuf); |
419 iLocationSelector->SelectL( *iProvider, landmarkToShow ); |
426 iLocationSelector->SelectL( *iProvider, landmarkToShow ); |
420 delete landmarkToShow; |
427 delete landmarkToShow; |
421 } |
428 } |
422 else{ |
429 else{ |
423 iLocationSelector->SelectL( *iProvider, NULL ); |
430 iLocationSelector->SelectL( *iProvider, NULL ); |
763 // ----------------------------------------------------------------------------- |
770 // ----------------------------------------------------------------------------- |
764 // CCalenLocationUi::ShowDefineLocationQuery |
771 // CCalenLocationUi::ShowDefineLocationQuery |
765 // Queries user to validate the location frm maps or not |
772 // Queries user to validate the location frm maps or not |
766 // ----------------------------------------------------------------------------- |
773 // ----------------------------------------------------------------------------- |
767 // |
774 // |
768 TInt CCalenLocationUi::ShowDefineLocationQuery() |
775 TInt CCalenLocationUi::ShowDefineLocationQueryL() |
769 { |
776 { |
770 TRACE_ENTRY_POINT; |
777 TRACE_ENTRY_POINT; |
771 |
778 |
772 CAknQueryDialog *dialog = CAknQueryDialog::NewL( ); |
779 CAknQueryDialog *dialog = CAknQueryDialog::NewL( ); |
773 CleanupStack::PushL( dialog ); |
780 CleanupStack::PushL( dialog ); |
797 TRACE_ENTRY_POINT; |
804 TRACE_ENTRY_POINT; |
798 |
805 |
799 MCalenContext& context = iGlobalData->Context(); |
806 MCalenContext& context = iGlobalData->Context(); |
800 // Get the entry |
807 // Get the entry |
801 TCalLocalUid instanceId = context.InstanceId().iEntryLocalUid; |
808 TCalLocalUid instanceId = context.InstanceId().iEntryLocalUid; |
802 CCalEntry* entry = iGlobalData->EntryViewL()->FetchL(instanceId); |
809 CCalEntry* entry = iGlobalData->EntryViewL(context.InstanceId().iColId)->FetchL(instanceId); |
803 |
810 |
804 TPtrC existingLocationInfo = entry->LocationL(); |
811 if(entry) |
805 TBuf<2*KCalenMaxTextEditorLength> locationInfo; |
|
806 TPtrC landmarkname; |
|
807 landmark->GetLandmarkName(landmarkname); |
|
808 CCalGeoValue* entryGeoValue = entry->GeoValueL(); |
|
809 if(entryGeoValue || isReplaceLocation) |
|
810 { |
|
811 isReplaceLocation = EFalse; |
|
812 // Query user to replace |
|
813 TInt userResponse = ShowLocationReplaceNoticeL(landmarkname); |
|
814 if(!userResponse) |
|
815 { |
|
816 delete entryGeoValue; |
|
817 delete entry; |
|
818 return; |
|
819 } |
|
820 else |
|
821 { |
|
822 locationInfo.Append(landmarkname); |
|
823 delete entryGeoValue; |
|
824 } |
|
825 } |
|
826 else if(existingLocationInfo.Length() && !isReplaceLocation) |
|
827 { |
812 { |
828 RPointerArray<HBufC> locationStrings; |
813 TPtrC existingLocationInfo = entry->LocationL(); |
829 HBufC* oldLocation = HBufC::NewL(KCalenMaxTextEditorLength); |
814 TBuf<2*KCalenMaxTextEditorLength> locationInfo; |
830 oldLocation->Des().Copy(existingLocationInfo); |
815 TPtrC landmarkname; |
831 |
816 landmark->GetLandmarkName(landmarkname); |
832 HBufC* oldNewLocation = HBufC::NewL(KCalenMaxTextEditorLength); |
817 CCalGeoValue* entryGeoValue = entry->GeoValueL(); |
833 TBuf<2*KCalenMaxTextEditorLength> combLocation; |
818 if(entryGeoValue || isReplaceLocation) |
834 combLocation.Append(existingLocationInfo); |
819 { |
835 combLocation.Append(KComma); |
820 isReplaceLocation = EFalse; |
836 combLocation.Append(landmarkname); |
821 // Query user to replace |
837 oldNewLocation->Des().Copy(combLocation.Left(KCalenMaxTextEditorLength)); |
822 TInt userResponse = ShowLocationReplaceNoticeL(landmarkname); |
838 |
823 if(!userResponse) |
|
824 { |
|
825 delete entryGeoValue; |
|
826 delete entry; |
|
827 return; |
|
828 } |
|
829 else |
|
830 { |
|
831 locationInfo.Append(landmarkname); |
|
832 delete entryGeoValue; |
|
833 } |
|
834 } |
|
835 else if(existingLocationInfo.Length() && !isReplaceLocation) |
|
836 { |
|
837 RPointerArray<HBufC> locationStrings; |
|
838 HBufC* oldLocation = HBufC::NewL(KCalenMaxTextEditorLength); |
|
839 oldLocation->Des().Copy(existingLocationInfo); |
|
840 |
|
841 HBufC* oldNewLocation = HBufC::NewL(KCalenMaxTextEditorLength); |
|
842 TBuf<2*KCalenMaxTextEditorLength> combLocation; |
|
843 combLocation.Append(existingLocationInfo); |
|
844 combLocation.Append(KComma); |
|
845 combLocation.Append(landmarkname); |
|
846 oldNewLocation->Des().Copy(combLocation.Left(KCalenMaxTextEditorLength)); |
|
847 |
839 HBufC* newLocation = HBufC::NewL(KCalenMaxTextEditorLength); |
848 HBufC* newLocation = HBufC::NewL(KCalenMaxTextEditorLength); |
840 newLocation->Des().Copy(landmarkname); |
849 newLocation->Des().Copy(landmarkname); |
841 |
850 |
842 locationStrings.Append(oldNewLocation); |
851 locationStrings.Append(oldNewLocation); |
843 locationStrings.Append(newLocation); |
852 locationStrings.Append(newLocation); |
844 locationStrings.Append(oldLocation); |
853 locationStrings.Append(oldLocation); |
845 TInt userResponse = CCalenLocationUtil::ShowLocationAppendOrReplaceL(locationStrings); |
854 TInt userResponse = CCalenLocationUtil::ShowLocationAppendOrReplaceL(locationStrings); |
846 locationStrings.ResetAndDestroy(); |
855 locationStrings.ResetAndDestroy(); |
847 if(userResponse == KErrCancel) |
856 if(userResponse == KErrCancel) |
848 { |
857 { |
849 delete entry; |
858 delete entry; |
850 return; |
859 return; |
851 } |
860 } |
867 } |
876 } |
868 break; |
877 break; |
869 default: |
878 default: |
870 break; |
879 break; |
871 } |
880 } |
|
881 } |
|
882 else // for isReplaceLocation |
|
883 { |
|
884 locationInfo.Append(landmarkname); |
|
885 } |
|
886 TPtrC landmarkDesc; |
|
887 landmark->GetLandmarkDescription(landmarkDesc); |
|
888 if(landmarkDesc.Size()) |
|
889 { |
|
890 locationInfo.Append(KComma); |
|
891 locationInfo.Append(landmarkDesc); |
|
892 } |
|
893 |
|
894 // Get the geo coordinates |
|
895 TLocality position; |
|
896 landmark->GetPosition(position); |
|
897 CCalGeoValue* geoValue = CCalGeoValue::NewL(); |
|
898 geoValue->SetLatLongL(position.Latitude(), position.Longitude()); |
|
899 |
|
900 // Get the context |
|
901 entry->SetLocationL(locationInfo); |
|
902 entry->SetGeoValueL(*geoValue); |
|
903 delete geoValue; |
|
904 |
|
905 if(existingLocationInfo.Length()) |
|
906 { |
|
907 ShowAddressUpdatedNoticeL(); |
|
908 } |
|
909 // Save entry into Agenda server |
|
910 CCalenInterimUtils2::StoreL( *(iGlobalData->EntryViewL(context.InstanceId().iColId)), *entry, ETrue ); |
|
911 delete entry; |
872 } |
912 } |
873 else // for isReplaceLocation |
913 |
874 { |
|
875 locationInfo.Append(landmarkname); |
|
876 } |
|
877 TPtrC landmarkDesc; |
|
878 landmark->GetLandmarkDescription(landmarkDesc); |
|
879 if(landmarkDesc.Size()) |
|
880 { |
|
881 locationInfo.Append(KComma); |
|
882 locationInfo.Append(landmarkDesc); |
|
883 } |
|
884 |
|
885 // Get the geo coordinates |
|
886 TLocality position; |
|
887 landmark->GetPosition(position); |
|
888 CCalGeoValue* geoValue = CCalGeoValue::NewL(); |
|
889 geoValue->SetLatLongL(position.Latitude(), position.Longitude()); |
|
890 |
|
891 // Get the context |
|
892 entry->SetLocationL(locationInfo); |
|
893 entry->SetGeoValueL(*geoValue); |
|
894 delete geoValue; |
|
895 |
|
896 if(existingLocationInfo.Length()) |
|
897 { |
|
898 ShowAddressUpdatedNoticeL(); |
|
899 } |
|
900 // Save entry into Agenda server |
|
901 CCalenInterimUtils2::StoreL( *(iGlobalData->EntryViewL()), *entry, ETrue ); |
|
902 delete entry; |
|
903 |
914 |
904 TRACE_EXIT_POINT; |
915 TRACE_EXIT_POINT; |
905 } |
916 } |
906 |
917 |
907 // End Of File |
918 // End Of File |