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