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 #ifdef LOC_GEOTAGGING_CELLID |
|
25 #include <lbslocationinfo.h> |
|
26 #endif //LOC_GEOTAGGING_CELLID |
24 |
27 |
25 #include "rlocationtrail.h" |
28 #include "rlocationtrail.h" |
26 #include "clocationrecord.h" |
29 #include "clocationrecord.h" |
27 #include "cnetworkinfo.h" |
30 #include "cnetworkinfo.h" |
28 #include "locationmanagerdebug.h" |
31 #include "locationmanagerdebug.h" |
199 #ifdef LOC_REVERSEGEOCODE |
203 #ifdef LOC_REVERSEGEOCODE |
200 iLocationItems.ResetAndDestroy(); |
204 iLocationItems.ResetAndDestroy(); |
201 iLocationItems.Close(); |
205 iLocationItems.Close(); |
202 #endif |
206 #endif |
203 delete iNetworkInfoChangeListener; |
207 delete iNetworkInfoChangeListener; |
|
208 iNetworkInfoChangeListener = NULL; |
204 delete iPositionInfo; |
209 delete iPositionInfo; |
|
210 iPositionInfo = NULL; |
205 delete iNetworkInfoTimer; |
211 delete iNetworkInfoTimer; |
|
212 iNetworkInfoTimer = NULL; |
206 #ifdef LOC_GEOTAGGING_CELLID |
213 #ifdef LOC_GEOTAGGING_CELLID |
207 if(iGeoConverter) |
214 if(iGeoConverter) |
208 { |
215 { |
209 delete iGeoConverter; |
216 delete iGeoConverter; |
210 iGeoConverter = NULL; |
217 iGeoConverter = NULL; |
705 iNetwork = aNetworkInfo; |
712 iNetwork = aNetworkInfo; |
706 if (iNetwork.iAccess == CTelephony::ENetworkAccessUtran) |
713 if (iNetwork.iAccess == CTelephony::ENetworkAccessUtran) |
707 { |
714 { |
708 iNetwork.iLocationAreaCode = 0; |
715 iNetwork.iLocationAreaCode = 0; |
709 } |
716 } |
|
717 #ifdef LOC_GEOTAGGING_CELLID |
710 if ( iState == RLocationTrail::ETrailStarting && iTrailStarted ) |
718 if ( iState == RLocationTrail::ETrailStarting && iTrailStarted ) |
711 { |
719 { |
712 SetCurrentState( RLocationTrail::ETrailStarted ); |
720 SetCurrentState( RLocationTrail::ETrailStarted ); |
713 } |
721 } |
|
722 #endif |
714 } |
723 } |
715 else |
724 else |
716 { |
725 { |
717 LOG1("CLocationRecord::NetworkInfo - %d", aError ); |
726 LOG1("CLocationRecord::NetworkInfo - %d", aError ); |
718 iNetwork = CTelephony::TNetworkInfoV1(); |
727 iNetwork = CTelephony::TNetworkInfoV1(); |
795 LOG1( "CLocationRecord::SetCurrentState(), begin, state:%d", aState ); |
804 LOG1( "CLocationRecord::SetCurrentState(), begin, state:%d", aState ); |
796 iState = aState; |
805 iState = aState; |
797 if( iTrailStarted ) |
806 if( iTrailStarted ) |
798 { |
807 { |
799 // Set the property only when trail is started to avoid icon flickering and wrong icon update in UI |
808 // Set the property only when trail is started to avoid icon flickering and wrong icon update in UI |
800 if( iGpsDataAvailableFlag || |
809 if( iGpsDataAvailableFlag |
801 iNetwork.iCellId > 0 && |
810 #ifdef LOC_GEOTAGGING_CELLID |
|
811 || ( iNetwork.iCellId > 0 && |
802 ((iNetwork.iLocationAreaCode == 0 && iNetwork.iAccess == CTelephony::ENetworkAccessUtran) || // 3G |
812 ((iNetwork.iLocationAreaCode == 0 && iNetwork.iAccess == CTelephony::ENetworkAccessUtran) || // 3G |
803 (iNetwork.iLocationAreaCode > 0 && (iNetwork.iAccess == CTelephony::ENetworkAccessGsm || // 2G |
813 (iNetwork.iLocationAreaCode > 0 && (iNetwork.iAccess == CTelephony::ENetworkAccessGsm || // 2G |
804 iNetwork.iAccess == CTelephony::ENetworkAccessGsmCompact))) && |
814 iNetwork.iAccess == CTelephony::ENetworkAccessGsmCompact))) && |
805 iNetwork.iCountryCode.Length() > 0 && |
815 iNetwork.iCountryCode.Length() > 0 && |
806 iNetwork.iNetworkId.Length() > 0 ) |
816 iNetwork.iNetworkId.Length() > 0 ) |
|
817 #endif // LOC_GEOTAGGING_CELLID |
|
818 ) |
807 { |
819 { |
808 // set the value 3 to have Geo tag available icon else not available. |
820 // set the value 3 to have Geo tag available icon else not available. |
809 iProperty.Set( KPSUidLocationTrail, KLocationTrailState, |
821 iProperty.Set( KPSUidLocationTrail, KLocationTrailState, |
810 (TInt) RLocationTrail::ETrailStarted ); |
822 (TInt) RLocationTrail::ETrailStarted ); |
811 } |
823 } |
1051 lastnet->iCountryCode == net->iCountryCode && |
1063 lastnet->iCountryCode == net->iCountryCode && |
1052 lastnet->iNetworkId == net->iNetworkId ) |
1064 lastnet->iNetworkId == net->iNetworkId ) |
1053 { |
1065 { |
1054 |
1066 |
1055 // if both locations have valid coordinates, calculate distance between points |
1067 // if both locations have valid coordinates, calculate distance between points |
1056 if ( !Math::IsNaN( lastLocationData.iPosition.Latitude() ) && |
1068 if ( |
|
1069 #ifdef LOC_REVERSEGEOCODE |
|
1070 !iLastReverseGeocodeFails && |
|
1071 #endif //LOC_REVERSEGEOCODE |
|
1072 !Math::IsNaN( lastLocationData.iPosition.Latitude() ) && |
1057 !Math::IsNaN( lastLocationData.iPosition.Longitude() ) && |
1073 !Math::IsNaN( lastLocationData.iPosition.Longitude() ) && |
1058 !Math::IsNaN( locationData.iPosition.Latitude() ) && |
1074 !Math::IsNaN( locationData.iPosition.Latitude() ) && |
1059 !Math::IsNaN( locationData.iPosition.Longitude() )) |
1075 !Math::IsNaN( locationData.iPosition.Longitude() )) |
1060 { |
1076 { |
1061 TReal32 distance; |
1077 TReal32 distance; |
1320 |
1336 |
1321 // location related properties |
1337 // location related properties |
1322 if ( !Math::IsNaN( aLocationData.iPosition.Latitude() ) && |
1338 if ( !Math::IsNaN( aLocationData.iPosition.Latitude() ) && |
1323 !Math::IsNaN( aLocationData.iPosition.Longitude() )) |
1339 !Math::IsNaN( aLocationData.iPosition.Longitude() )) |
1324 { |
1340 { |
|
1341 LOG1("Lan - %f", aLocationData.iPosition.Latitude()); |
|
1342 LOG1("Lon - %f", aLocationData.iPosition.Longitude()); |
1325 locationObject->AddReal64PropertyL( *iLatitudeDef, aLocationData.iPosition.Latitude() ); |
1343 locationObject->AddReal64PropertyL( *iLatitudeDef, aLocationData.iPosition.Latitude() ); |
1326 locationObject->AddReal64PropertyL( *iLongitudeDef, aLocationData.iPosition.Longitude() ); |
1344 locationObject->AddReal64PropertyL( *iLongitudeDef, aLocationData.iPosition.Longitude() ); |
1327 |
1345 |
1328 } |
1346 } |
1329 if ( !Math::IsNaN( aLocationData.iPosition.Altitude() ) ) |
1347 if ( !Math::IsNaN( aLocationData.iPosition.Altitude() ) ) |
1342 { |
1360 { |
1343 locationObject->AddReal32PropertyL( qualityDef, aLocationData.iQuality ); |
1361 locationObject->AddReal32PropertyL( qualityDef, aLocationData.iQuality ); |
1344 } |
1362 } |
1345 |
1363 |
1346 // network related properties |
1364 // network related properties |
1347 if ( aLocationData.iNetworkInfo.iAreaKnown ) |
1365 if ( aLocationData.iNetworkInfo.iAccess != CTelephony::ENetworkAccessUnknown ) |
1348 { |
1366 { |
1349 if ( aLocationData.iNetworkInfo.iAccess != CTelephony::ENetworkAccessUnknown ) |
1367 LOG1("Cell id - %d", aLocationData.iNetworkInfo.iCellId); |
1350 { |
1368 locationObject->AddUint32PropertyL( cellIdDef, aLocationData.iNetworkInfo.iCellId ); |
1351 locationObject->AddUint32PropertyL( cellIdDef, aLocationData.iNetworkInfo.iCellId ); |
1369 } |
1352 |
1370 if ( aLocationData.iNetworkInfo.iAreaKnown && |
1353 } |
1371 aLocationData.iNetworkInfo.iLocationAreaCode != 0 && |
1354 if ( aLocationData.iNetworkInfo.iLocationAreaCode != 0 && |
1372 aLocationData.iNetworkInfo.iAccess != CTelephony::ENetworkAccessUnknown ) |
1355 aLocationData.iNetworkInfo.iAccess != CTelephony::ENetworkAccessUnknown ) |
1373 { |
1356 { |
1374 LOG1("Areacode - %d", aLocationData.iNetworkInfo.iLocationAreaCode); |
1357 locationObject->AddUint32PropertyL( locationCodeDef, |
1375 locationObject->AddUint32PropertyL( locationCodeDef, |
1358 aLocationData.iNetworkInfo.iLocationAreaCode ); |
1376 aLocationData.iNetworkInfo.iLocationAreaCode ); |
1359 |
1377 } |
1360 } |
1378 #ifdef _DEBUG |
1361 if ( aLocationData.iNetworkInfo.iCountryCode.Length() > 0 ) |
1379 TLex lexer( aLocationData.iNetworkInfo.iCountryCode ); |
1362 { |
1380 TUint countryCode = 0; |
1363 locationObject->AddTextPropertyL( countryCodeDef, |
1381 |
1364 aLocationData.iNetworkInfo.iCountryCode ); |
1382 User::LeaveIfError( lexer.Val( countryCode, EDecimal) ); |
1365 |
1383 LOG1("Country code - %d", countryCode); |
1366 } |
1384 |
1367 if ( aLocationData.iNetworkInfo.iNetworkId.Length() > 0 ) |
1385 //Set mobile network code |
1368 { |
1386 lexer = aLocationData.iNetworkInfo.iNetworkId; |
1369 locationObject->AddTextPropertyL(networkCodeDef, aLocationData.iNetworkInfo.iNetworkId); |
1387 TUint networkCode = 0; |
1370 |
1388 User::LeaveIfError( lexer.Val( networkCode, EDecimal) ); |
1371 } |
1389 LOG1("Network id - %d", networkCode); |
|
1390 #endif |
|
1391 if ( aLocationData.iNetworkInfo.iCountryCode.Length() > 0 ) |
|
1392 { |
|
1393 locationObject->AddTextPropertyL( countryCodeDef, |
|
1394 aLocationData.iNetworkInfo.iCountryCode ); |
|
1395 } |
|
1396 |
|
1397 if ( aLocationData.iNetworkInfo.iNetworkId.Length() > 0 ) |
|
1398 { |
|
1399 locationObject->AddTextPropertyL(networkCodeDef, aLocationData.iNetworkInfo.iNetworkId); |
1372 } |
1400 } |
1373 |
1401 |
1374 // Add the location object to the database. |
1402 // Add the location object to the database. |
1375 locationObjectId = iMdeSession->AddObjectL( *locationObject ); |
1403 locationObjectId = iMdeSession->AddObjectL( *locationObject ); |
1376 |
1404 LOG1("Location id - %d", locationObjectId); |
1377 CleanupStack::PopAndDestroy( locationObject ); |
1405 CleanupStack::PopAndDestroy( locationObject ); |
1378 LOG( "CLocationRecord::DoCreateLocationL(), end" ); |
1406 LOG( "CLocationRecord::DoCreateLocationL(), end" ); |
1379 |
1407 |
1380 return locationObjectId; |
1408 return locationObjectId; |
1381 } |
1409 } |
1950 iRemapState = ERemapProgressNone; |
1978 iRemapState = ERemapProgressNone; |
1951 } |
1979 } |
1952 else if ( iMediaItems.Count() > 0 ) |
1980 else if ( iMediaItems.Count() > 0 ) |
1953 { |
1981 { |
1954 TLocationSnapshotItem* item = iMediaItems[0]; |
1982 TLocationSnapshotItem* item = iMediaItems[0]; |
|
1983 // Fails may be becuase of n/w reason..create location + relation so that we can handle at 3:00 AM. |
|
1984 TItemId locationId = DoCreateLocationL( iMediaItems[0]->iLocationData ); |
|
1985 iMediaItems[0]->iLocationId = locationId; |
|
1986 CreateRelationL( iMediaItems[0]->iObjectId, locationId ); |
|
1987 |
1955 iMediaItems.Remove(0); |
1988 iMediaItems.Remove(0); |
1956 iMediaItems.Compress(); |
1989 iMediaItems.Compress(); |
1957 iMediaHandlingFlag &= ~KLocationQueryInProgress; |
1990 iMediaHandlingFlag &= ~KLocationQueryInProgress; |
1958 delete item; |
1991 delete item; |
1959 } |
1992 } |
2459 TItemId countryTagId(0); |
2492 TItemId countryTagId(0); |
2460 TItemId cityTagId(0); |
2493 TItemId cityTagId(0); |
2461 |
2494 |
2462 iMediaHandlingFlag &= (~KReverseGeoCodingInProgress); |
2495 iMediaHandlingFlag &= (~KReverseGeoCodingInProgress); |
2463 TLocationSnapshotItem* snapshotItem = NULL; |
2496 TLocationSnapshotItem* snapshotItem = NULL; |
|
2497 LOG1("Error - %d", aErrorcode); |
2464 if( aErrorcode == KErrNone ) |
2498 if( aErrorcode == KErrNone ) |
2465 { |
2499 { |
|
2500 iLastReverseGeocodeFails = EFalse; |
2466 TPtrC countryPtr( aAddressInfo.GetCountryName() ); |
2501 TPtrC countryPtr( aAddressInfo.GetCountryName() ); |
2467 TPtrC cityPtr( aAddressInfo.GetCity() ); |
2502 TPtrC cityPtr( aAddressInfo.GetCity() ); |
2468 TRAP_IGNORE( iTagCreator->CreateLocationTagsL( countryPtr, countryTagId, |
2503 TRAP_IGNORE( iTagCreator->CreateLocationTagsL( countryPtr, countryTagId, |
2469 cityPtr, cityTagId ) ); |
2504 cityPtr, cityTagId ) ); |
2470 if ( iRemapState == ERemapRevGeoCodeInProgress) |
2505 if ( iRemapState == ERemapRevGeoCodeInProgress) |
2480 iLocationItems[0]->iCityTagId = cityTagId; |
2515 iLocationItems[0]->iCityTagId = cityTagId; |
2481 iLastLocationItem = (*iLocationItems[0]); |
2516 iLastLocationItem = (*iLocationItems[0]); |
2482 |
2517 |
2483 TRAP_IGNORE( iTagCreator->AttachTagsL( |
2518 TRAP_IGNORE( iTagCreator->AttachTagsL( |
2484 iLocationItems[0]->iObjectId, countryTagId, cityTagId ) ); |
2519 iLocationItems[0]->iObjectId, countryTagId, cityTagId ) ); |
|
2520 if ( (iLastMediaItem.iFlag & KSnapMediaFile) > 0 |
|
2521 && iLastMediaItem.iLocationId == iLastLocationItem.iLocationId ) |
|
2522 { |
|
2523 LOG("Updating country/city\n"); |
|
2524 iLastMediaItem.iCountryTagId = countryTagId; |
|
2525 iLastMediaItem.iCityTagId = cityTagId; |
|
2526 } |
|
2527 |
2485 } |
2528 } |
2486 } |
2529 } |
2487 if(iLastMediaItem.iFlag == 0) |
|
2488 { |
|
2489 LOG("Last media item is null\n"); |
|
2490 } |
|
2491 if ( iLastMediaItem.iFlag > 0 && iLastMediaItem.iLocationId == iLastLocationItem.iLocationId ) |
|
2492 { |
|
2493 LOG("Updating country/city\n"); |
|
2494 iLastMediaItem.iCountryTagId = countryTagId; |
|
2495 iLastMediaItem.iCityTagId = cityTagId; |
|
2496 } |
|
2497 |
|
2498 //check other items in the array has same location |
2530 //check other items in the array has same location |
2499 for ( TInt index = iLocationItems.Count() - 1; index > 0; index--) |
2531 for ( TInt index = iLocationItems.Count() - 1; index > 0; index--) |
2500 { |
2532 { |
2501 if ( iLocationItems[index]->iLocationId == iLastLocationItem.iLocationId ) |
2533 if ( iLocationItems[index]->iLocationId == iLastLocationItem.iLocationId ) |
2502 { |
2534 { |