19 #include <lbserrors.h> |
19 #include <lbserrors.h> |
20 #include <lbssatellite.h> |
20 #include <lbssatellite.h> |
21 #include <ecom.h> |
21 #include <ecom.h> |
22 #include <centralrepository.h> |
22 #include <centralrepository.h> |
23 #include <hwrmpowerstatesdkpskeys.h> |
23 #include <hwrmpowerstatesdkpskeys.h> |
|
24 #include <MProfileEngine.h> //profile enum |
24 #ifdef LOC_GEOTAGGING_CELLID |
25 #ifdef LOC_GEOTAGGING_CELLID |
25 #include <lbslocationinfo.h> |
26 #include <lbslocationinfo.h> |
26 #endif //LOC_GEOTAGGING_CELLID |
27 #endif //LOC_GEOTAGGING_CELLID |
27 |
28 |
28 #include "rlocationtrail.h" |
29 #include "rlocationtrail.h" |
102 ,iTagQuery(NULL) |
103 ,iTagQuery(NULL) |
103 ,iTagCreator( NULL ) |
104 ,iTagCreator( NULL ) |
104 ,iLastReverseGeocodeFails(EFalse) |
105 ,iLastReverseGeocodeFails(EFalse) |
105 ,iRevGeocoderPlugin( NULL ) |
106 ,iRevGeocoderPlugin( NULL ) |
106 #endif |
107 #endif |
|
108 ,iProfileHandler(NULL) |
|
109 ,iOfflineCheck(ETrue) |
107 { |
110 { |
108 iMaxTrailSize = KMaxTrailLength / KUpdateInterval; |
111 iMaxTrailSize = KMaxTrailLength / KUpdateInterval; |
109 } |
112 } |
110 |
113 |
111 // -------------------------------------------------------------------------- |
114 // -------------------------------------------------------------------------- |
127 |
130 |
128 iNetworkInfoChangeListener = CNetworkInfo::NewL( this ); |
131 iNetworkInfoChangeListener = CNetworkInfo::NewL( this ); |
129 iPositionInfo = CPositionInfo::NewL( this ); |
132 iPositionInfo = CPositionInfo::NewL( this ); |
130 iRemapper = CLocationRemappingAO::NewL(); |
133 iRemapper = CLocationRemappingAO::NewL(); |
131 iNetworkInfoTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
134 iNetworkInfoTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
135 iProfileHandler = CProfileChangeNotifyHandler::NewL(this); |
132 |
136 |
133 #ifdef LOC_REVERSEGEOCODE |
137 #ifdef LOC_REVERSEGEOCODE |
134 iTagCreator = CTagCreator::NewL(); |
138 iTagCreator = CTagCreator::NewL(); |
135 |
139 |
136 TInt pluginerr = KErrNone; |
140 TInt pluginerr = KErrNone; |
168 iLastMediaItem.iFlag = 0; |
172 iLastMediaItem.iFlag = 0; |
169 iLastMediaItem.iLocationId = 0; |
173 iLastMediaItem.iLocationId = 0; |
170 #ifdef LOC_REVERSEGEOCODE |
174 #ifdef LOC_REVERSEGEOCODE |
171 iLastMediaItem.iCityTagId= 0; |
175 iLastMediaItem.iCityTagId= 0; |
172 iLastMediaItem.iCountryTagId = 0; |
176 iLastMediaItem.iCountryTagId = 0; |
|
177 iLastMediaItem.iReverseGeocodeSuccess = 0; |
173 |
178 |
174 iLastLocationItem.iFlag = 0; |
179 iLastLocationItem.iFlag = 0; |
175 iLastLocationItem.iCityTagId= 0; |
180 iLastLocationItem.iCityTagId= 0; |
176 iLastLocationItem.iCountryTagId = 0; |
181 iLastLocationItem.iCountryTagId = 0; |
177 iLastLocationItem.iLocationId = 0; |
182 iLastLocationItem.iLocationId = 0; |
|
183 iLastLocationItem.iReverseGeocodeSuccess = 0; |
178 #endif |
184 #endif |
179 LOG( "CLocationRecord::ConstructL(), end" ); |
185 LOG( "CLocationRecord::ConstructL(), end" ); |
180 } |
186 } |
181 |
187 |
182 // -------------------------------------------------------------------------- |
188 // -------------------------------------------------------------------------- |
246 iTagQuery->RemoveObserver(*this); |
252 iTagQuery->RemoveObserver(*this); |
247 iTagQuery->Cancel(); |
253 iTagQuery->Cancel(); |
248 delete iTagQuery; |
254 delete iTagQuery; |
249 iTagQuery = NULL; |
255 iTagQuery = NULL; |
250 } |
256 } |
251 delete iTagCreator; |
257 if(iTagCreator) |
252 // set the pointer to NULL, ECOM will destroy object. |
258 { |
253 delete iRevGeocoderPlugin; |
259 delete iTagCreator; |
254 iRevGeocoderPlugin = NULL; |
260 iTagCreator = NULL; |
|
261 } |
|
262 |
|
263 if(iRevGeocoderPlugin) |
|
264 { |
|
265 // set the pointer to NULL, ECOM will destroy object. |
|
266 delete iRevGeocoderPlugin; |
|
267 iRevGeocoderPlugin = NULL; |
|
268 } |
255 #endif |
269 #endif |
|
270 if(iProfileHandler) |
|
271 { |
|
272 delete iProfileHandler; |
|
273 iProfileHandler = NULL; |
|
274 } |
256 LOG( "CLocationRecord::~CLocationRecord(), end" ); |
275 LOG( "CLocationRecord::~CLocationRecord(), end" ); |
257 } |
276 } |
258 |
277 |
259 // -------------------------------------------------------------------------- |
278 // -------------------------------------------------------------------------- |
260 // CLocationRecord::CurrentState |
279 // CLocationRecord::CurrentState |
298 } |
317 } |
299 |
318 |
300 StartTimerL(); |
319 StartTimerL(); |
301 } |
320 } |
302 |
321 |
303 iTrailStarted = ETrue; |
322 iTrailStarted = ETrue; |
304 SetCurrentState( RLocationTrail::ETrailStarting ); |
323 iState = RLocationTrail::ETrailStopped; |
|
324 SetCurrentState( RLocationTrail::ETrailStarting ); |
305 |
325 |
306 LOG( "CLocationRecord::StartL(), end" ); |
326 LOG( "CLocationRecord::StartL(), end" ); |
307 } |
327 } |
308 |
328 |
309 // -------------------------------------------------------------------------- |
329 // -------------------------------------------------------------------------- |
697 // |
717 // |
698 void CLocationRecord::NetworkInfo( const CTelephony::TNetworkInfoV1 &aNetworkInfo, |
718 void CLocationRecord::NetworkInfo( const CTelephony::TNetworkInfoV1 &aNetworkInfo, |
699 const TInt aError ) |
719 const TInt aError ) |
700 { |
720 { |
701 LOG("CLocationRecord::NetworkInfo, begin"); |
721 LOG("CLocationRecord::NetworkInfo, begin"); |
702 if ( aError == KErrNone ) |
722 if ( aError == KErrNone && iOfflineCheck) |
703 { |
723 { |
704 LOG("CLocationRecord::NetworkInfo - KErrNone"); |
724 LOG("CLocationRecord::NetworkInfo - KErrNone"); |
705 iNetwork = aNetworkInfo; |
725 iNetwork = aNetworkInfo; |
706 if (iNetwork.iAccess == CTelephony::ENetworkAccessUtran) |
726 if (iNetwork.iAccess == CTelephony::ENetworkAccessUtran) |
707 { |
727 { |
944 newItem->iFlag = KSnapMediaFile; |
964 newItem->iFlag = KSnapMediaFile; |
945 |
965 |
946 iMediaItems.Append( newItem ); |
966 iMediaItems.Append( newItem ); |
947 |
967 |
948 TItemId lastLocationId = 0; |
968 TItemId lastLocationId = 0; |
949 if ( (iLastMediaItem.iFlag & KSnapMediaFile) > 0) |
969 |
|
970 #ifdef LOC_REVERSEGEOCODE |
|
971 if ( ( iLastMediaItem.iReverseGeocodeSuccess == 1 ) && (iLastMediaItem.iFlag & KSnapMediaFile) > 0 ) |
950 { |
972 { |
951 lastLocationId = iLastMediaItem.iLocationId; |
973 lastLocationId = iLastMediaItem.iLocationId; |
952 } |
974 } |
|
975 #else |
|
976 if ( (iLastMediaItem.iFlag & KSnapMediaFile) > 0 ) |
|
977 { |
|
978 lastLocationId = iLastMediaItem.iLocationId; |
|
979 } |
|
980 #endif |
953 |
981 |
954 CTelephony::TNetworkInfoV1* net = &locationData.iNetworkInfo; |
982 CTelephony::TNetworkInfoV1* net = &locationData.iNetworkInfo; |
955 // capture only network data |
983 // capture only network data |
956 if ( iTrailCaptureSetting == RLocationTrail::ECaptureNetworkInfo ) |
984 if ( iTrailCaptureSetting == RLocationTrail::ECaptureNetworkInfo ) |
957 { |
985 { |
1011 delete firstPtr; |
1039 delete firstPtr; |
1012 firstPtr = NULL; |
1040 firstPtr = NULL; |
1013 } |
1041 } |
1014 // check match for last created locationobject |
1042 // check match for last created locationobject |
1015 #ifdef LOC_REVERSEGEOCODE |
1043 #ifdef LOC_REVERSEGEOCODE |
1016 else if ( (iLastMediaItem.iFlag & KSnapMediaFile) > 0 && |
1044 else if ( (iLastMediaItem.iFlag & KSnapMediaFile) > 0 && |
1017 iLastMediaItem.iCountryTagId > 0) |
1045 iLastMediaItem.iCountryTagId > 0 && ( iLastMediaItem.iReverseGeocodeSuccess == 1 ) ) |
1018 #else |
1046 #else |
1019 else if ( (iLastMediaItem.iFlag & KSnapMediaFile) > 0) |
1047 else if ( (iLastMediaItem.iFlag & KSnapMediaFile) > 0) |
1020 #endif //LOC_REVERSEGEOCODE |
1048 #endif //LOC_REVERSEGEOCODE |
1021 { |
1049 { |
1022 LOG("CLocationRecord::LocationSnapshotL(), last created locationobject match" ); |
1050 LOG("CLocationRecord::LocationSnapshotL(), last created locationobject match" ); |
1032 // same network. |
1060 // same network. |
1033 previousMatch = ETrue; |
1061 previousMatch = ETrue; |
1034 CreateRelationL( aObjectId, lastLocationId ); |
1062 CreateRelationL( aObjectId, lastLocationId ); |
1035 // attach same tags associated to last location |
1063 // attach same tags associated to last location |
1036 #ifdef LOC_REVERSEGEOCODE |
1064 #ifdef LOC_REVERSEGEOCODE |
1037 if ( iLastMediaItem.iCountryTagId ) //found from DB last time |
1065 if ( iLastMediaItem.iCountryTagId && ( iLastMediaItem.iReverseGeocodeSuccess == 1 ) ) //found from DB last time |
1038 { |
1066 { |
1039 iTagCreator->AttachTagsL( aObjectId, |
1067 iTagCreator->AttachTagsL( aObjectId, |
1040 iLastMediaItem.iCountryTagId, iLastMediaItem.iCityTagId ); |
1068 iLastMediaItem.iCountryTagId, iLastMediaItem.iCityTagId ); |
1041 } |
1069 } |
1042 #endif //LOC_REVERSEGEOCODE |
1070 #endif //LOC_REVERSEGEOCODE |
1094 previousMatch = ETrue; |
1122 previousMatch = ETrue; |
1095 CreateRelationL( aObjectId, lastLocationId ); |
1123 CreateRelationL( aObjectId, lastLocationId ); |
1096 |
1124 |
1097 #ifdef LOC_REVERSEGEOCODE |
1125 #ifdef LOC_REVERSEGEOCODE |
1098 // attach same tags associated to last location |
1126 // attach same tags associated to last location |
1099 if ( iLastMediaItem.iCountryTagId ) |
1127 if ( iLastMediaItem.iCountryTagId && ( iLastMediaItem.iReverseGeocodeSuccess == 1 ) ) |
1100 { |
1128 { |
1101 iTagCreator->AttachTagsL( |
1129 iTagCreator->AttachTagsL( |
1102 aObjectId, iLastMediaItem.iCountryTagId, iLastMediaItem.iCityTagId ); |
1130 aObjectId, iLastMediaItem.iCountryTagId, iLastMediaItem.iCityTagId ); |
1103 TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1]; |
1131 TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1]; |
1104 iMediaItems.Remove(iMediaItems.Count() - 1); |
1132 iMediaItems.Remove(iMediaItems.Count() - 1); |
2582 { |
2610 { |
2583 if(iLocationItems.Count() > 0) |
2611 if(iLocationItems.Count() > 0) |
2584 { |
2612 { |
2585 iLocationItems[0]->iCountryTagId = countryTagId; |
2613 iLocationItems[0]->iCountryTagId = countryTagId; |
2586 iLocationItems[0]->iCityTagId = cityTagId; |
2614 iLocationItems[0]->iCityTagId = cityTagId; |
|
2615 iLocationItems[0]->iReverseGeocodeSuccess = 1 ; |
|
2616 |
2587 iLastLocationItem = (*iLocationItems[0]); |
2617 iLastLocationItem = (*iLocationItems[0]); |
2588 |
2618 |
2589 TRAP_IGNORE( iTagCreator->AttachTagsL( |
2619 TRAP_IGNORE( iTagCreator->AttachTagsL( |
2590 iLocationItems[0]->iObjectId, countryTagId, cityTagId ) ); |
2620 iLocationItems[0]->iObjectId, countryTagId, cityTagId ) ); |
2591 if ( (iLastMediaItem.iFlag & KSnapMediaFile) > 0 |
2621 if ( (iLastMediaItem.iFlag & KSnapMediaFile) > 0 |
2592 && iLastMediaItem.iLocationId == iLastLocationItem.iLocationId ) |
2622 && iLastMediaItem.iLocationId == iLastLocationItem.iLocationId && (iLastLocationItem.iReverseGeocodeSuccess == 1)) |
2593 { |
2623 { |
2594 LOG("Updating country/city\n"); |
2624 LOG("Updating country/city\n"); |
2595 iLastMediaItem.iCountryTagId = countryTagId; |
2625 iLastMediaItem.iCountryTagId = countryTagId; |
2596 iLastMediaItem.iCityTagId = cityTagId; |
2626 iLastMediaItem.iCityTagId = cityTagId; |
|
2627 iLastMediaItem.iReverseGeocodeSuccess = 1; |
2597 } |
2628 } |
2598 |
2629 |
2599 } |
2630 } |
2600 } |
2631 } |
2601 //check other items in the array has same location |
2632 //check other items in the array has same location |
2859 filterCond.RightL().AddObjectConditionL( tagObjectDef ); |
2890 filterCond.RightL().AddObjectConditionL( tagObjectDef ); |
2860 |
2891 |
2861 iTagQuery->FindL(); // results to a call to HandleQueryCompleted() |
2892 iTagQuery->FindL(); // results to a call to HandleQueryCompleted() |
2862 LOG( "CLocationRecord::GetTagsL(), end" ); |
2893 LOG( "CLocationRecord::GetTagsL(), end" ); |
2863 } |
2894 } |
2864 |
2895 |
2865 |
|
2866 #endif //LOC_REVERSEGEOCODE |
2896 #endif //LOC_REVERSEGEOCODE |
2867 |
2897 |
|
2898 |
|
2899 // -------------------------------------------------------------------------- |
|
2900 // CLocationRecord::HandleActiveProfileEventL() |
|
2901 // -------------------------------------------------------------------------- |
|
2902 // |
|
2903 void CLocationRecord::HandleActiveProfileEventL( TProfileEvent aProfileEvent,TInt aProfileId ) |
|
2904 { |
|
2905 LOG( "CLocationRecord::HandleActiveProfileEventL(), begin" ); |
|
2906 ARG_USED(aProfileEvent); |
|
2907 iOfflineCheck = ETrue; |
|
2908 |
|
2909 |
|
2910 if ( EProfileOffLineId == aProfileId ) |
|
2911 { |
|
2912 LOG( "HandleActiveProfileEventL() if condition to stop trail, begin" ); |
|
2913 iNetwork.iAreaKnown = EFalse; |
|
2914 iNetwork.iAccess = CTelephony::ENetworkAccessUnknown; |
|
2915 iNetwork.iCellId = 0; |
|
2916 iNetwork.iLocationAreaCode = 0; |
|
2917 iNetwork.iCountryCode.Zero(); |
|
2918 iNetwork.iNetworkId.Zero(); |
|
2919 iOfflineCheck = EFalse; |
|
2920 LOG( "HandleActiveProfileEventL() if condition to stop trail, end" ); |
|
2921 } |
|
2922 LOG( "CLocationRecord::HandleActiveProfileEventL(), end" ); |
|
2923 } |
|
2924 |
2868 // End of file |
2925 // End of file |
2869 |
2926 |
2870 |
2927 |