locationmanager/locationtrail/src/clocationrecord.cpp
branchRCL_3
changeset 50 85f623e1ef41
parent 49 f23c07ec56e2
child 53 29d87345eaeb
equal deleted inserted replaced
49:f23c07ec56e2 50:85f623e1ef41
   507     
   507     
   508     iGpsDataAvailableFlag = EFalse;
   508     iGpsDataAvailableFlag = EFalse;
   509     
   509     
   510     if ( !iTrailStarted || iState == RLocationTrail::ETrailStopped)
   510     if ( !iTrailStarted || iState == RLocationTrail::ETrailStopped)
   511         {
   511         {
   512     	LOG("CLocationRecord::Position(), trail not started/stopped");
   512     	LOG("trail not started/stopped");
   513         iPositionInfo->Stop();
   513         iPositionInfo->Stop();
   514         return;
   514         return;
   515         }
   515         }
   516     // all cases store the location..
   516     // all cases store the location..
   517     StoreLocation( positionSatelliteInfo );
   517     StoreLocation( positionSatelliteInfo );
   531         {
   531         {
   532         case KPositionPartialUpdate: // fall through
   532         case KPositionPartialUpdate: // fall through
   533         case KPositionQualityLoss: 
   533         case KPositionQualityLoss: 
   534             {
   534             {
   535             // Location is stored, even if it may not be valid.
   535             // Location is stored, even if it may not be valid.
   536             LOG("CLocationRecord::Position(), Partial update");
   536             LOG("Partial update");
   537             if ( iState != RLocationTrail::EWaitingGPSData && 
   537             if ( iState != RLocationTrail::EWaitingGPSData && 
   538             	 iState != RLocationTrail::ETrailStopping ) 
   538             	 iState != RLocationTrail::ETrailStopping ) 
   539                 {
   539                 {
   540                 SetCurrentState( RLocationTrail::EWaitingGPSData );
   540                 SetCurrentState( RLocationTrail::EWaitingGPSData );
   541             	LOG("CLocationRecord::Position(), Trail waiting for gps");
   541             	LOG("Trail waiting for gps");
   542                 }
   542                 }
   543             break;
   543             break;
   544             }
   544             }
   545         case KErrNone:
   545         case KErrNone:
   546             {
   546             {
   547             LOG("CLocationRecord::Position(), Good GPS coordinates");
   547             LOG("Good GPS coordinates");
   548             iGpsDataAvailableFlag = ETrue;
   548             iGpsDataAvailableFlag = ETrue;
   549             if ( iState != RLocationTrail::ETrailStarted ) 
   549             if ( iState != RLocationTrail::ETrailStarted ) 
   550                 {
   550                 {
   551                 if ( iRemapper )
   551                 if ( iRemapper )
   552                 	{
   552                 	{
   553                 	LOG("CLocationRecord::Position(), Start remapping");
   553                 	LOG("Start remapping");
   554                		iRemapper->StartRemappingObjects( iNewItem.iLocationData );
   554                		iRemapper->StartRemappingObjects( iNewItem.iLocationData );
   555 
   555 
   556                     if( iObserver->WaitForPositioningStopTimeout() && !RemappingNeeded() )                                
   556                     if( iObserver->WaitForPositioningStopTimeout() && !RemappingNeeded() )                                
   557                		    {                                                
   557                		    {                                                
   558                         iObserver->RemapedCompleted();
   558                         iObserver->RemapedCompleted();
   569                 }
   569                 }
   570             break;
   570             break;
   571             }
   571             }
   572         default:
   572         default:
   573             {
   573             {
   574             LOG1("CLocationRecord::Position(), Searching GPS, aError %d", aError );
   574             LOG1("Searching GPS, aError %d", aError );
   575             if ( iState != RLocationTrail::ESearchingGPS &&
   575             if ( iState != RLocationTrail::ESearchingGPS &&
   576                	 iState != RLocationTrail::ETrailStopping ) 
   576                	 iState != RLocationTrail::ETrailStopping ) 
   577                 {
   577                 {
   578                 SetCurrentState( RLocationTrail::ESearchingGPS );
   578                 SetCurrentState( RLocationTrail::ESearchingGPS );
   579             	LOG("Trail searching gps");
   579             	LOG("Trail searching gps");
   580                 }
   580                 }
   581             break;
   581             break;
   582             }      
   582             }      
   583         }
   583         }
   584     TBool fixState = CheckGPSFix( positionSatelliteInfo );
   584     TBool fixState = CheckGPSFix( positionSatelliteInfo );
   585     LOG1( "CLocationRecord::Position(), fixState %d", fixState );
   585     LOG1( "fixState %d", fixState );
   586     LOG1( "CLocationRecord::Position(), iLastGPSFixState %d", iLastGPSFixState );
   586     LOG1( "iLastGPSFixState %d", iLastGPSFixState );
   587     
   587     
   588     if ( iObserver && iLastGPSFixState != fixState )
   588     if ( iObserver && iLastGPSFixState != fixState )
   589     	{
   589     	{
   590     	LOG("CLocationRecord::Position(), Quality changed");
   590     	LOG("Quality changed");
   591     	iObserver->GPSSignalQualityChanged( positionSatelliteInfo );
   591     	iObserver->GPSSignalQualityChanged( positionSatelliteInfo );
   592     	}
   592     	}
   593     
   593     
   594    	iLastGPSFixState = fixState;
   594    	iLastGPSFixState = fixState;
   595     
   595     
   966              net->iCountryCode.Length() == 0 &&
   966              net->iCountryCode.Length() == 0 &&
   967              net->iNetworkId.Length() == 0 )
   967              net->iNetworkId.Length() == 0 )
   968             {
   968             {
   969             // no n/w info... put it into remap.
   969             // no n/w info... put it into remap.
   970             // remove the last appended element.
   970             // remove the last appended element.
   971             LOG("CLocationRecord::LocationSnapshotL(), No network info (offline mode + no GPS fix), keep for remapping");
   971             LOG("No network info (offline mode + no GPS fix), keep for remapping");
   972 			TRemapItem remapItem;
   972 			TRemapItem remapItem;
   973 			remapItem.iObjectId = aObjectId;
   973 			remapItem.iObjectId = aObjectId;
   974 			remapItem.iTime = timestamp;
   974 			remapItem.iTime = timestamp;
   975 			iRemapper->Append( remapItem );
   975 			iRemapper->Append( remapItem );
   976 		
   976 		
   977 			TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1];
   977 			TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1];
   978 			iMediaItems.Remove(iMediaItems.Count() - 1);
   978 			iMediaItems.Remove(iMediaItems.Count() - 1);
   979 			iMediaItems.Compress();
   979 			iMediaItems.Compress();
   980             if( firstPtr == newItem)
   980 			delete firstPtr;
   981                 {                
       
   982                 newItem = NULL;
       
   983                 }           
       
   984             delete firstPtr;            
       
   985             firstPtr = NULL;
       
   986             }   
   981             }   
   987         else
   982         else
   988             {
   983             {
   989             // n/w info available
   984             // n/w info available
   990             NetworkInfoSnapshotL();
   985             NetworkInfoSnapshotL();
   991             }
   986             }
   992 		}
   987 		}
   993 	else if ( Math::IsNaN( locationData.iPosition.Latitude() ) && 
   988 	else if ( Math::IsNaN( locationData.iPosition.Latitude() ) && 
   994 			Math::IsNaN( locationData.iPosition.Longitude() ))
   989 			Math::IsNaN( locationData.iPosition.Longitude() ))
   995 		{
   990 		{
   996         LOG("CLocationRecord::LocationSnapshotL(), coordinates empty with or without cellular info")
       
   997 	    // coordinates empty, with or without cellular info
   991 	    // coordinates empty, with or without cellular info
   998 
   992 
   999 		if ( net->iCellId == 0 && 
   993 		if ( net->iCellId == 0 && 
  1000 				net->iLocationAreaCode == 0 &&
   994 				net->iLocationAreaCode == 0 &&
  1001 				net->iCountryCode.Length() == 0 &&
   995 				net->iCountryCode.Length() == 0 &&
  1002 				net->iNetworkId.Length() == 0 )
   996 				net->iNetworkId.Length() == 0 )
  1003 			{
   997 			{
  1004             LOG("CLocationRecord::LocationSnapshotL(), No network info (offline mode + no GPS fix), keep for remapping");
   998             LOG("No network info (offline mode + no GPS fix), keep for remapping");
  1005 			TRemapItem remapItem;
   999 			TRemapItem remapItem;
  1006 			remapItem.iObjectId = aObjectId;
  1000 			remapItem.iObjectId = aObjectId;
  1007 			remapItem.iTime = timestamp;
  1001 			remapItem.iTime = timestamp;
  1008 			iRemapper->Append( remapItem );
  1002 			iRemapper->Append( remapItem );
  1009 		
  1003 		
  1010 			TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1];
  1004 			TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1];
  1011 			iMediaItems.Remove(iMediaItems.Count() - 1);
  1005 			iMediaItems.Remove(iMediaItems.Count() - 1);
  1012 			iMediaItems.Compress();
  1006 			iMediaItems.Compress();
  1013             if( firstPtr == newItem)
  1007 			delete firstPtr;
  1014                 {                
       
  1015                 newItem = NULL;
       
  1016                 }           
       
  1017             delete firstPtr;            
       
  1018             firstPtr = NULL;
       
  1019 			}
  1008 			}
  1020 		// check match for last created locationobject
  1009 		// check match for last created locationobject
  1021 #ifdef LOC_REVERSEGEOCODE
  1010 #ifdef LOC_REVERSEGEOCODE
  1022 		else if ( (iLastMediaItem.iFlag & KSnapMediaFile) > 0 &&
  1011 		else if ( (iLastMediaItem.iFlag & KSnapMediaFile) > 0 &&
  1023             iLastMediaItem.iCountryTagId > 0)
  1012             iLastMediaItem.iCountryTagId > 0)
  1024 #else
  1013 #else
  1025         else if ( (iLastMediaItem.iFlag & KSnapMediaFile) > 0)
  1014         else if ( (iLastMediaItem.iFlag & KSnapMediaFile) > 0)
  1026 #endif //LOC_REVERSEGEOCODE
  1015 #endif //LOC_REVERSEGEOCODE
  1027 			{
  1016 			{
  1028             LOG("CLocationRecord::LocationSnapshotL(), last created locationobject match" );
       
  1029 			TLocationData lastLocationData = iLastMediaItem.iLocationData;
  1017 			TLocationData lastLocationData = iLastMediaItem.iLocationData;
  1030 			CTelephony::TNetworkInfoV1* lastnet = &lastLocationData.iNetworkInfo;
  1018 			CTelephony::TNetworkInfoV1* lastnet = &lastLocationData.iNetworkInfo;
  1031 
  1019 
  1032 			// networkinfo changed from last location
  1020 			// networkinfo changed from last location
  1033 			if ( lastnet->iCellId == net->iCellId &&
  1021 			if ( lastnet->iCellId == net->iCellId &&
  1048 #endif //LOC_REVERSEGEOCODE
  1036 #endif //LOC_REVERSEGEOCODE
  1049                 // remove the current item.
  1037                 // remove the current item.
  1050 				TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1];
  1038 				TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1];
  1051 				iMediaItems.Remove(iMediaItems.Count() - 1);
  1039 				iMediaItems.Remove(iMediaItems.Count() - 1);
  1052 				iMediaItems.Compress();
  1040 				iMediaItems.Compress();
  1053 	            if( firstPtr == newItem)
  1041 				delete firstPtr;
  1054 	                {                
       
  1055 	                newItem = NULL;
       
  1056 	                }           
       
  1057 	            delete firstPtr;            
       
  1058 	            firstPtr = NULL;
       
  1059 				}
  1042 				}
  1060 			}
  1043 			}
  1061 		
  1044 		
  1062         if (  newItem && !previousMatch )
  1045 		if ( !previousMatch )
  1063 		    {
  1046 		    {
  1064 			// go for n/w based
  1047 			// go for n/w based
  1065             newItem->iFlag |= KNetQueryBit;
  1048             newItem->iFlag |= KNetQueryBit;
  1066 		    }
  1049 		    }
  1067 		}
  1050 		}
  1068        
  1051        
  1069 	// valid coordinates found
  1052 	// valid coordinates found
  1070 	else if ( lastLocationId != 0 && 
  1053 	else if ( lastLocationId != 0 && 
  1071         ((iLastMediaItem.iFlag & KSnapMediaFile) > 0))
  1054         ((iLastMediaItem.iFlag & KSnapMediaFile) > 0))
  1072 		{
  1055 		{
  1073         LOG("CLocationRecord::LocationSnapshotL(), valid coordinates found");
       
  1074         TLocationData lastLocationData = iLastMediaItem.iLocationData;
  1056         TLocationData lastLocationData = iLastMediaItem.iLocationData;
  1075 		CTelephony::TNetworkInfoV1* lastnet = &lastLocationData.iNetworkInfo;
  1057 		CTelephony::TNetworkInfoV1* lastnet = &lastLocationData.iNetworkInfo;
  1076 		
  1058 		
  1077 		// first check if networkinfo matches last created location
  1059 		// first check if networkinfo matches last created location
  1078 		if ( lastnet->iCellId == net->iCellId &&
  1060 		if ( lastnet->iCellId == net->iCellId &&
  1094 				TReal32 distance;
  1076 				TReal32 distance;
  1095 				TInt err = locationData.iPosition.Distance(lastLocationData.iPosition, distance);
  1077 				TInt err = locationData.iPosition.Distance(lastLocationData.iPosition, distance);
  1096 				
  1078 				
  1097 				if ( distance < iLocationDelta )
  1079 				if ( distance < iLocationDelta )
  1098 					{
  1080 					{
  1099 					LOG("CLocationRecord::LocationSnapshotL(), location close to the previous one");
  1081 					LOG("location close to the previous one");
  1100 					previousMatch = ETrue;
  1082 					previousMatch = ETrue;
  1101 					CreateRelationL( aObjectId, lastLocationId );
  1083 					CreateRelationL( aObjectId, lastLocationId );
  1102 					
  1084 					
  1103 #ifdef LOC_REVERSEGEOCODE
  1085 #ifdef LOC_REVERSEGEOCODE
  1104 					// attach same tags associated to last location
  1086 					// attach same tags associated to last location
  1107 					    iTagCreator->AttachTagsL( 
  1089 					    iTagCreator->AttachTagsL( 
  1108 					          aObjectId, iLastMediaItem.iCountryTagId, iLastMediaItem.iCityTagId );
  1090 					          aObjectId, iLastMediaItem.iCountryTagId, iLastMediaItem.iCityTagId );
  1109                         TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1];
  1091                         TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1];
  1110                         iMediaItems.Remove(iMediaItems.Count() - 1);
  1092                         iMediaItems.Remove(iMediaItems.Count() - 1);
  1111                         iMediaItems.Compress();
  1093                         iMediaItems.Compress();
  1112                         if( firstPtr == newItem)
  1094                         delete firstPtr;
  1113                             {                
       
  1114                             newItem = NULL;
       
  1115                             }           
       
  1116                         delete firstPtr;            
       
  1117                         firstPtr = NULL;
       
  1118 					    }
  1095 					    }
  1119 					else if (newItem)
  1096 					else 
  1120 					    {
  1097 					    {
  1121 					    // country tag not found.. go for reverse geocoding..
  1098 					    // country tag not found.. go for reverse geocoding..
  1122 					    newItem->iLocationId = lastLocationId;
  1099 					    newItem->iLocationId = lastLocationId;
  1123 					    iLocationItems.Append( newItem );
  1100 					    iLocationItems.Append( newItem );
  1124 						iMediaItems.Remove(iMediaItems.Count() - 1);
  1101 						iMediaItems.Remove(iMediaItems.Count() - 1);
  1138 #else
  1115 #else
  1139                     // remove from the queue
  1116                     // remove from the queue
  1140                     TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1];
  1117                     TLocationSnapshotItem* firstPtr = iMediaItems[iMediaItems.Count() - 1];
  1141                     iMediaItems.Remove(iMediaItems.Count() - 1);
  1118                     iMediaItems.Remove(iMediaItems.Count() - 1);
  1142                     iMediaItems.Compress();
  1119                     iMediaItems.Compress();
  1143                     if( firstPtr == newItem)
  1120                     delete firstPtr;
  1144                         {                
       
  1145                         newItem = NULL;
       
  1146                         }           
       
  1147                     delete firstPtr;            
       
  1148                     firstPtr = NULL;
       
  1149 
  1121 
  1150 #endif //LOC_REVERSEGEOCODE
  1122 #endif //LOC_REVERSEGEOCODE
  1151 					}
  1123 					}
  1152 				}
  1124 				}
  1153 			}
  1125 			}
  1219     LOG( "CLocationRecord::FindLocationFromDBL(), begin" );    
  1191     LOG( "CLocationRecord::FindLocationFromDBL(), begin" );    
  1220     if(((iMediaHandlingFlag & KLocationQueryInProgress)> 0)
  1192     if(((iMediaHandlingFlag & KLocationQueryInProgress)> 0)
  1221 	     || (iMediaItems.Count() <= 0))
  1193 	     || (iMediaItems.Count() <= 0))
  1222         {
  1194         {
  1223 		// query is in progress or queue is empty
  1195 		// query is in progress or queue is empty
  1224 		LOG1( "CLocationRecord::FindLocationFromDBL(), Count - %d", iMediaItems.Count() );
  1196 		LOG1( "query is in progress or queue is empty. Count - %d", iMediaItems.Count() );
  1225         return;
  1197         return;
  1226         }
  1198         }
  1227      if ( (iMediaItems[0]->iFlag & KNetQueryBit) > 0 )
  1199      if ( (iMediaItems[0]->iFlag & KNetQueryBit) > 0 )
  1228          {
  1200          {
  1229 		 // n/w based.
  1201 		 // n/w based.
  1262      iLocationQuery = iMdeSession->NewObjectQueryL( *iNamespaceDef, *iLocationObjectDef, this );
  1234      iLocationQuery = iMdeSession->NewObjectQueryL( *iNamespaceDef, *iLocationObjectDef, this );
  1263                  
  1235                  
  1264      CMdELogicCondition& cond = iLocationQuery->Conditions();
  1236      CMdELogicCondition& cond = iLocationQuery->Conditions();
  1265      cond.SetOperator( ELogicConditionOperatorAnd );
  1237      cond.SetOperator( ELogicConditionOperatorAnd );
  1266             
  1238             
  1267      LOG1( "CLocationRecord::FindLocationFromDBL(), latitude: %f", latitude);
  1239      LOG1( "latitude: %f", latitude);
  1268      LOG1( "CLocationRecord::FindLocationFromDBL(), latdelta: %f", latDelta);
  1240      LOG1( "latdelta: %f", latDelta);
  1269      LOG1( "CLocationRecord::FindLocationFromDBL(), longitude: %f", longitude);
  1241      LOG1( "longitude: %f", longitude);
  1270      LOG1( "CLocationRecord::FindLocationFromDBL(), londelta: %f", lonDelta);
  1242      LOG1( "londelta: %f", lonDelta);
  1271             
  1243             
  1272      cond.AddPropertyConditionL( *iLatitudeDef, 
  1244      cond.AddPropertyConditionL( *iLatitudeDef, 
  1273                     TMdERealBetween( latitude - latDelta, latitude + latDelta ));
  1245                     TMdERealBetween( latitude - latDelta, latitude + latDelta ));
  1274      cond.AddPropertyConditionL( *iLongitudeDef, 
  1246      cond.AddPropertyConditionL( *iLongitudeDef, 
  1275                     TMdERealBetween( longitude - lonDelta, longitude + lonDelta ));
  1247                     TMdERealBetween( longitude - lonDelta, longitude + lonDelta ));
  1355 	locationObject->AddTimePropertyL( modifiedDef, timestamp );
  1327 	locationObject->AddTimePropertyL( modifiedDef, timestamp );
  1356 	locationObject->AddUint32PropertyL( sizeDef, 0 ); // always zero size for location objects
  1328 	locationObject->AddUint32PropertyL( sizeDef, 0 ); // always zero size for location objects
  1357 	locationObject->AddTextPropertyL( itemTypeDef, Location::KLocationItemType );
  1329 	locationObject->AddTextPropertyL( itemTypeDef, Location::KLocationItemType );
  1358 	locationObject->AddInt16PropertyL( offSetDef, timeOffset.Int() / 60 );
  1330 	locationObject->AddInt16PropertyL( offSetDef, timeOffset.Int() / 60 );
  1359 	
  1331 	
  1360 	LOG1( "CLocationRecord::DoCreateLocationL(), Location created with stamp: %Ld", timestamp.Int64() );
  1332 	LOG1( "Location created with stamp: %Ld", timestamp.Int64() );
  1361 	
  1333 	
  1362 	// location related properties
  1334 	// location related properties
  1363 	if ( !Math::IsNaN( aLocationData.iPosition.Latitude() ) && 
  1335 	if ( !Math::IsNaN( aLocationData.iPosition.Latitude() ) && 
  1364 		 !Math::IsNaN( aLocationData.iPosition.Longitude() ))
  1336 		 !Math::IsNaN( aLocationData.iPosition.Longitude() ))
  1365 		{
  1337 		{
  1366         LOG1("CLocationRecord::DoCreateLocationL(), Lan - %f", aLocationData.iPosition.Latitude());
  1338         LOG1("Lan - %f", aLocationData.iPosition.Latitude());
  1367         LOG1("CLocationRecord::DoCreateLocationL(), Lon - %f", aLocationData.iPosition.Longitude());
  1339         LOG1("Lon - %f", aLocationData.iPosition.Longitude());
  1368 		locationObject->AddReal64PropertyL( *iLatitudeDef, aLocationData.iPosition.Latitude() );
  1340 		locationObject->AddReal64PropertyL( *iLatitudeDef, aLocationData.iPosition.Latitude() );
  1369 		locationObject->AddReal64PropertyL( *iLongitudeDef, aLocationData.iPosition.Longitude() );
  1341 		locationObject->AddReal64PropertyL( *iLongitudeDef, aLocationData.iPosition.Longitude() );
  1370 
  1342 
  1371 		}
  1343 		}
  1372 	if ( !Math::IsNaN( aLocationData.iPosition.Altitude() ) )
  1344 	if ( !Math::IsNaN( aLocationData.iPosition.Altitude() ) )
  1387 		}
  1359 		}
  1388 
  1360 
  1389 	// network related properties
  1361 	// network related properties
  1390 	if ( aLocationData.iNetworkInfo.iAccess != CTelephony::ENetworkAccessUnknown )
  1362 	if ( aLocationData.iNetworkInfo.iAccess != CTelephony::ENetworkAccessUnknown )
  1391 		{
  1363 		{
  1392 		LOG1("CLocationRecord::DoCreateLocationL(), Cell id - %d", aLocationData.iNetworkInfo.iCellId);
  1364 		LOG1("Cell id - %d", aLocationData.iNetworkInfo.iCellId);
  1393 		locationObject->AddUint32PropertyL( cellIdDef, aLocationData.iNetworkInfo.iCellId );
  1365 		locationObject->AddUint32PropertyL( cellIdDef, aLocationData.iNetworkInfo.iCellId );
  1394 		}
  1366 		}
  1395 	if ( aLocationData.iNetworkInfo.iAreaKnown && 
  1367 	if ( aLocationData.iNetworkInfo.iAreaKnown && 
  1396         aLocationData.iNetworkInfo.iLocationAreaCode != 0 &&
  1368         aLocationData.iNetworkInfo.iLocationAreaCode != 0 &&
  1397 		aLocationData.iNetworkInfo.iAccess != CTelephony::ENetworkAccessUnknown )
  1369 		aLocationData.iNetworkInfo.iAccess != CTelephony::ENetworkAccessUnknown )
  1398 		{
  1370 		{
  1399 		LOG1("CLocationRecord::DoCreateLocationL(), Areacode - %d", aLocationData.iNetworkInfo.iLocationAreaCode);
  1371 		LOG1("Areacode - %d", aLocationData.iNetworkInfo.iLocationAreaCode);
  1400 		locationObject->AddUint32PropertyL( locationCodeDef, 
  1372 		locationObject->AddUint32PropertyL( locationCodeDef, 
  1401 				aLocationData.iNetworkInfo.iLocationAreaCode );
  1373 				aLocationData.iNetworkInfo.iLocationAreaCode );
  1402 		}
  1374 		}
  1403 #ifdef _DEBUG
  1375 #ifdef _DEBUG
  1404 	
  1376     TLex lexer( aLocationData.iNetworkInfo.iCountryCode );
  1405     if ( aLocationData.iNetworkInfo.iCountryCode.Length() > 0 )
  1377     TUint countryCode = 0;
  1406         {
  1378     
  1407         TLex lexer( aLocationData.iNetworkInfo.iCountryCode );
  1379     User::LeaveIfError( lexer.Val( countryCode, EDecimal) );
  1408         TUint countryCode = 0;    
  1380     LOG1("Country code - %d", countryCode);
  1409         TRAP_IGNORE(lexer.Val( countryCode, EDecimal));        
       
  1410         LOG1("CLocationRecord::DoCreateLocationL(), Country code - %d", countryCode);
       
  1411         }
       
  1412     else
       
  1413         {
       
  1414         LOG("CLocationRecord::DoCreateLocationL(), No Country code");
       
  1415         }
       
  1416     
  1381     
  1417     //Set mobile network code
  1382     //Set mobile network code
  1418     if ( aLocationData.iNetworkInfo.iNetworkId.Length() > 0 )
  1383     lexer = aLocationData.iNetworkInfo.iNetworkId;
  1419         {
  1384     TUint networkCode = 0;
  1420         TLex lexer = aLocationData.iNetworkInfo.iNetworkId;
  1385     User::LeaveIfError( lexer.Val( networkCode, EDecimal) );
  1421         TUint networkCode = 0;
  1386     LOG1("Network id - %d", networkCode);
  1422         TRAP_IGNORE(lexer.Val( networkCode, EDecimal));
       
  1423         LOG1("CLocationRecord::DoCreateLocationL(), Network id - %d", networkCode); 
       
  1424         }
       
  1425     else
       
  1426         {
       
  1427         LOG("CLocationRecord::DoCreateLocationL(), No network code");
       
  1428         }
       
  1429 
       
  1430 #endif
  1387 #endif
  1431 	if ( aLocationData.iNetworkInfo.iCountryCode.Length() > 0 )
  1388 	if ( aLocationData.iNetworkInfo.iCountryCode.Length() > 0 )
  1432 		{
  1389 		{
  1433 		locationObject->AddTextPropertyL( countryCodeDef, 
  1390 		locationObject->AddTextPropertyL( countryCodeDef, 
  1434 				aLocationData.iNetworkInfo.iCountryCode );
  1391 				aLocationData.iNetworkInfo.iCountryCode );
  1439 		locationObject->AddTextPropertyL(networkCodeDef, aLocationData.iNetworkInfo.iNetworkId);
  1396 		locationObject->AddTextPropertyL(networkCodeDef, aLocationData.iNetworkInfo.iNetworkId);
  1440 		}
  1397 		}
  1441 	        
  1398 	        
  1442 	// Add the location object to the database.
  1399 	// Add the location object to the database.
  1443 	locationObjectId = iMdeSession->AddObjectL( *locationObject );
  1400 	locationObjectId = iMdeSession->AddObjectL( *locationObject );
  1444     LOG1("CLocationRecord::DoCreateLocationL(), Location id - %d", locationObjectId);
  1401     LOG1("Location id - %d", locationObjectId);
  1445 	CleanupStack::PopAndDestroy( locationObject );
  1402 	CleanupStack::PopAndDestroy( locationObject );
  1446     LOG( "CLocationRecord::DoCreateLocationL(), end" );
  1403     LOG( "CLocationRecord::DoCreateLocationL(), end" );
  1447 
  1404 
  1448 	return locationObjectId;
  1405 	return locationObjectId;
  1449 	}
  1406 	}
  2238 
  2195 
  2239     CMdEObject* object = NULL;
  2196     CMdEObject* object = NULL;
  2240     CMdEProperty* property = NULL;
  2197     CMdEProperty* property = NULL;
  2241     
  2198     
  2242     object = iMdeSession->GetObjectL( aObjectId );
  2199     object = iMdeSession->GetObjectL( aObjectId );
  2243     if( !object )
       
  2244         {
       
  2245         User::Leave( KErrNotFound );
       
  2246         }
       
  2247     
       
  2248     CleanupStack::PushL( object );
  2200     CleanupStack::PushL( object );
  2249     object->Property( timeDef, property, 0 );
  2201     object->Property( timeDef, property, 0 );
  2250     if ( !property )
  2202     if ( !property )
  2251         {
  2203         {
  2252         User::Leave( KErrNotFound );
  2204         User::Leave( KErrNotFound );
  2253         }
  2205         }
  2254     
  2206     
  2255     const TTime timeValue( property->TimeValueL() );
  2207     const TTime timeValue( property->TimeValueL() );
  2256     CleanupStack::PopAndDestroy( object );
  2208     CleanupStack::PopAndDestroy( object );
  2257     
       
  2258     LOG( "CLocationRecord::GetMdeObjectTimeL(), end" );
       
  2259     return timeValue;
  2209     return timeValue;
  2260         
       
  2261     }
  2210     }
  2262 
  2211 
  2263 
  2212 
  2264 
  2213 
  2265 // --------------------------------------------------------------------------
  2214 // --------------------------------------------------------------------------