locationmanager/server/src/clocationmanagerserver.cpp
branchRCL_3
changeset 63 e538444823de
parent 47 b73252188534
equal deleted inserted replaced
57:2872ae438bf7 63:e538444823de
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #include <e32debug.h>
    18 #include <e32debug.h>
    19 #include <w32std.h>
    19 #include <w32std.h>
    20 #include <ecom.h>
       
    21 #include <commsdattypesv1_1.h>
       
    22 #include <cdblen.h>
       
    23 #include <commsdat_partner.h>
       
    24 
    20 
    25 #include "clocationmanagerserver.h"
    21 #include "clocationmanagerserver.h"
    26 #include "clocationmanagersession.h"
    22 #include "clocationmanagersession.h"
    27 
    23 
    28 #include "locationtraildefs.h"
    24 #include "locationtraildefs.h"
    31 #include "mdesession.h"
    27 #include "mdesession.h"
    32 #include "mdenamespacedef.h"
    28 #include "mdenamespacedef.h"
    33 #include "mdeobjectdef.h"
    29 #include "mdeobjectdef.h"
    34 #include "mdepropertydef.h"
    30 #include "mdepropertydef.h"
    35 #include "mdcserializationbuffer.h"
    31 #include "mdcserializationbuffer.h"
    36 #include "clocationgeotagtimerao.h"
       
    37 #include "nwregistrationstatushandler.h"
       
    38 
    32 
    39 using namespace MdeConstants;
    33 using namespace MdeConstants;
    40 using namespace CommsDat;
       
    41 
       
    42 
    34 
    43 // --------------------------------------------------------------------------
    35 // --------------------------------------------------------------------------
    44 // RunServerL
    36 // RunServerL
    45 // Initialize and run the server.
    37 // Initialize and run the server.
    46 // --------------------------------------------------------------------------
    38 // --------------------------------------------------------------------------
    74     TInt ret( KErrNoMemory );
    66     TInt ret( KErrNoMemory );
    75     if( cleanup )
    67     if( cleanup )
    76         {
    68         {
    77         TRAP( ret, RunServerL() );
    69         TRAP( ret, RunServerL() );
    78         delete cleanup;
    70         delete cleanup;
    79         cleanup = NULL;
       
    80         }
    71         }
    81     return ret;
    72     return ret;
    82     }
    73     }
    83 
    74 
    84 // --------------------------------------------------------------------------
    75 // --------------------------------------------------------------------------
    98 // CLocationManagerServer::CLocationManagerServer()
    89 // CLocationManagerServer::CLocationManagerServer()
    99 // C++ constructor.
    90 // C++ constructor.
   100 // --------------------------------------------------------------------------
    91 // --------------------------------------------------------------------------
   101 //
    92 //
   102 CLocationManagerServer::CLocationManagerServer() 
    93 CLocationManagerServer::CLocationManagerServer() 
   103     : CPolicyServer( KLocManagerSessionPriority, 
    94     : CPolicyServer( CActive::EPriorityStandard, 
   104                      KLocationManagerPolicy, 
    95                      KLocationManagerPolicy, 
   105                      ESharableSessions ),
    96                      ESharableSessions ),
   106                      iASW(NULL),
       
   107                      iTimer( NULL ),
    97                      iTimer( NULL ),
   108 			         iSessionReady( EFalse ),
    98 			         iSessionReady( EFalse ),
   109                      iTagId( 0 ),
    99                      iTagId( 0 ),
   110                      iLocManStopDelay( 0 ),
   100                      iLocManStopDelay( 0 ),
   111                      iLocManStopRemapDelay( 0 ),
   101                      iLocManStopRemapDelay( 0 ),
   112                      iCaptureSetting( RLocationTrail::EOff ),
   102                      iCaptureSetting( RLocationTrail::EOff ),
   113                      iRemoveLocation( EFalse ),
   103                      iRemoveLocation( EFalse ),
   114                      iWaitForPositioningStopTimeout ( EFalse ),
   104                      iWaitForPositioningStopTimeout ( EFalse )
   115                      iTelServerIsOpen(EFalse),
       
   116                      iPhoneIsOpen(EFalse),
       
   117                      iNwRegistrationStatusHandler(NULL),
       
   118                      iHomeNwInfoAvailableFlag(EFalse),
       
   119                      iGeoTagTimer(NULL)
       
   120 #ifdef LOC_REVERSEGEOCODE
       
   121 					 ,iGeoTaggingPendingReqObj(NULL)
       
   122 					 ,iEcomSession(NULL)
       
   123 #endif //LOC_REVERSEGEOCODE
       
   124     {
   105     {
   125     }
   106     }
   126 
   107 
   127 // --------------------------------------------------------------------------
   108 // --------------------------------------------------------------------------
   128 // CLocationManagerServer::ConstructL
   109 // CLocationManagerServer::ConstructL
   132 void CLocationManagerServer::ConstructL()
   113 void CLocationManagerServer::ConstructL()
   133     {
   114     {
   134     LOG ("CLocationManagerServer::ConstructL() begin");
   115     LOG ("CLocationManagerServer::ConstructL() begin");
   135     
   116     
   136     StartL( KLocServerName );
   117     StartL( KLocServerName );
   137 
   118     
   138     // initialize etel
       
   139     InitialisePhoneL();
       
   140     
       
   141 #ifdef LOC_REVERSEGEOCODE
       
   142     iEcomSession = &(REComSession::OpenL());
       
   143 #endif //LOC_REVERSEGEOCODE
       
   144 
       
   145     iASW = new (ELeave) CActiveSchedulerWait();
       
   146     
       
   147     iNwRegistrationStatusHandler = CNwRegistrationStatusHandler::NewL(iPhone);
       
   148     
       
   149     iLocationRecord = CLocationRecord::NewL(*this, iPhone);
       
   150     iTrackLog = CTrackLog::NewL();
       
   151     iMdeSession = CMdESession::NewL( *this );   
       
   152 
       
   153     iLocationRecord->SetObserver( this );
       
   154     
       
   155     iLocationRecord->SetAddObserver( iTrackLog );
       
   156     
       
   157     iTrackLog->AddGpxObserver( this );
       
   158     
       
   159     CRepository* repository = CRepository::NewLC( KRepositoryUid );
       
   160     TInt err = repository->Get( KLocationTrailShutdownTimer, iLocManStopDelay );
       
   161     
       
   162     LOG1("iLocManStopDelay:%d", iLocManStopDelay);
       
   163     
       
   164     if ( err != KErrNone )
       
   165         {
       
   166         LOG1("iLocManStopDelay err:%d", err);
       
   167         iLocManStopDelay = KLocationTrailShutdownDelay;
       
   168         }
       
   169 
       
   170     err = repository->Get( KLocationTrailRemapShutdownTimer, iLocManStopRemapDelay );
       
   171     CleanupStack::PopAndDestroy( repository );
       
   172     
       
   173     LOG1("iLocManStopRemapDelay:%d", iLocManStopRemapDelay);
       
   174     
       
   175     if ( err != KErrNone )
       
   176         {
       
   177         LOG1("iLocManStopRemapDelay err:%d", err);
       
   178         iLocManStopRemapDelay = KLocationTrailRemapShutdownDelay;
       
   179         }
       
   180 
       
   181     if( !iSessionReady )
       
   182         {
       
   183         iASW->Start();      
       
   184         }
       
   185 
       
   186     delete iASW;
       
   187     iASW = NULL;   
       
   188 
       
   189     if( iSessionReady )
       
   190         {
       
   191         LOG("Session is ready to give service");
       
   192         //Create the instance of the geotagging timer object
       
   193         // Create timer, if n/w or reverse geo code based feature flag is enabled
       
   194 #if defined(LOC_REVERSEGEOCODE) || defined(LOC_GEOTAGGING_CELLID)
       
   195         iGeoTagTimer = CLocationGeoTagTimerAO::NewL(*iMdeSession, *this);
       
   196         //Schedule a task for geotagging every day at 3.00 AM
       
   197         iGeoTagTimer->StartTimer();
       
   198 #endif        
       
   199         }
       
   200     else
       
   201         {
       
   202         LOG("Unable to open MDE session. Closing..");
       
   203         User::Leave( KErrCouldNotConnect );
       
   204         }
       
   205         
       
   206     RProcess process;
   119     RProcess process;
   207     process.SetPriority( EPriorityBackground );
   120     process.SetPriority( EPriorityBackground );
   208     process.Close();
   121     process.Close();
   209     
   122     
       
   123     iASW = new (ELeave) CActiveSchedulerWait();
       
   124     iMdeSession = CMdESession::NewL( *this );
       
   125     iLocationRecord = CLocationRecord::NewL();
       
   126     iTrackLog = CTrackLog::NewL();
       
   127     
       
   128     iASW->Start();
       
   129     
       
   130     iLocationRecord->SetObserver( this );
       
   131     
       
   132     iLocationRecord->SetAddObserver( iTrackLog );
       
   133     
       
   134     iTrackLog->AddGpxObserver( this );
       
   135     
       
   136     CRepository* repository = CRepository::NewLC( KRepositoryUid );
       
   137 	TInt err = repository->Get( KLocationTrailShutdownTimer, iLocManStopDelay );
       
   138 	
       
   139     LOG1("CLocationManagerServer::ConstructL, iLocManStopDelay:%d", iLocManStopDelay);
       
   140     
       
   141     if ( err != KErrNone )
       
   142     	{
       
   143         LOG1("CLocationManagerServer::ConstructL, iLocManStopDelay err:%d", err);
       
   144         iLocManStopDelay = KLocationTrailShutdownDelay;
       
   145     	}
       
   146 
       
   147     err = repository->Get( KLocationTrailRemapShutdownTimer, iLocManStopRemapDelay );
       
   148     CleanupStack::PopAndDestroy( repository );
       
   149     
       
   150     LOG1("CLocationManagerServer::ConstructL, iLocManStopRemapDelay:%d", iLocManStopRemapDelay);
       
   151     
       
   152     if ( err != KErrNone )
       
   153         {
       
   154         LOG1("CLocationManagerServer::ConstructL, iLocManStopRemapDelay err:%d", err);
       
   155         iLocManStopRemapDelay = KLocationTrailRemapShutdownDelay;
       
   156         }
       
   157     
       
   158     TRAPD( error, iTimer = CPeriodic::NewL( CActive::EPriorityUserInput ) );    
       
   159     if ( error != KErrNone )
       
   160         {
       
   161         LOG("CLocationManagerServer::ConstructL - iTimer not created");
       
   162         iTimer = NULL;
       
   163         }  
       
   164     
       
   165     
   210     LOG ("CLocationManagerServer::ConstructL() end");
   166     LOG ("CLocationManagerServer::ConstructL() end");
   211     }
   167     }
   212 
   168 
   213 // --------------------------------------------------------------------------
   169 // --------------------------------------------------------------------------
   214 // CLocationManagerServer::~CLocationManagerServer()
   170 // CLocationManagerServer::~CLocationManagerServer()
   215 // C++ destructor.
   171 // C++ destructor.
   216 // --------------------------------------------------------------------------
   172 // --------------------------------------------------------------------------
   217 //
   173 //
   218 CLocationManagerServer::~CLocationManagerServer()
   174 CLocationManagerServer::~CLocationManagerServer()
   219     {
   175     {
   220 	LOG("CLocationManagerServer::~CLocationManagerServer ,begin");
       
   221 #if defined(LOC_REVERSEGEOCODE) || defined(LOC_GEOTAGGING_CELLID)
       
   222     delete iGeoTagTimer;
       
   223     iGeoTagTimer = NULL;
       
   224 #endif    
       
   225 #ifdef LOC_REVERSEGEOCODE
       
   226     delete iGeoTaggingPendingReqObj;
       
   227     iGeoTaggingPendingReqObj = NULL;
       
   228 #endif //LOC_REVERSEGEOCODE
       
   229     
       
   230     delete iLocationRecord;    
   176     delete iLocationRecord;    
   231     iLocationRecord = NULL;
       
   232     delete iTrackLog;    
   177     delete iTrackLog;    
   233     iTrackLog = NULL;
       
   234     delete iTimer;
   178     delete iTimer;
   235     iTimer = NULL;
   179     //delete iRelationQuery;
   236     delete iRelationQuery;
       
   237     iRelationQuery = NULL;
       
   238     delete iASW;
   180     delete iASW;
   239     iASW = NULL;
       
   240     delete iMdeSession;
   181     delete iMdeSession;
   241     iMdeSession = NULL;
   182     
   242     delete iNwRegistrationStatusHandler;
       
   243     iNwRegistrationStatusHandler = NULL;
       
   244     iTargetObjectIds.Close();
   183     iTargetObjectIds.Close();
   245     CancelRequests(iNotifReqs);
   184     CancelRequests(iNotifReqs);
   246     iNotifReqs.Close();
   185     iNotifReqs.Close();
   247     CancelRequests(iLocationReqs);
   186     CancelRequests(iLocationReqs);
   248     iLocationReqs.Close();
   187     iLocationReqs.Close();
   249     CancelRequests(iTrackLogNotifyReqs);
   188     CancelRequests(iTrackLogNotifyReqs);
   250     iTrackLogNotifyReqs.Close();
   189     iTrackLogNotifyReqs.Close();
   251     CancelCopyRequests(iCopyReqs);
   190     CancelCopyRequests(iCopyReqs);
   252     iCopyReqs.Close();
   191     iCopyReqs.Close();
   253     iSessionCount = 0;
   192     iSessionCount = 0;
   254 	if(iPhoneIsOpen)
   193     }
   255         {   
   194 // --------------------------------------------------------------------------
   256         iPhoneIsOpen = EFalse; // not required
   195 // CLocationManagerServer::CompleteRequests()
   257         iPhone.Close();
       
   258         }
       
   259     if(iTelServerIsOpen)
       
   260         {
       
   261         iTelServerIsOpen = EFalse;
       
   262         iTelServer.Close();
       
   263         }
       
   264 #ifdef LOC_REVERSEGEOCODE
       
   265 	if(iEcomSession)
       
   266         {
       
   267         iEcomSession->Close();
       
   268         }
       
   269 #endif //LOC_REVERSEGEOCODE
       
   270 	LOG("CLocationManagerServer::~CLocationManagerServer ,end");
       
   271     }
       
   272 
       
   273 // --------------------------------------------------------------------------
       
   274 // CLocationManagerServer::GetCommDbTSYnameL
       
   275 // --------------------------------------------------------------------------
       
   276 //    
       
   277 void CLocationManagerServer::GetCommDbTSYnameL(TDes& aTsyName)
       
   278 	{
       
   279     LOG( "CLocationManagerServer::GetCommDbTSYnameL(), begin" );
       
   280 #ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
       
   281 	CMDBSession* db = CMDBSession::NewL(KCDVersion1_2);
       
   282 #else
       
   283 	CMDBSession* db = CMDBSession::NewL(KCDVersion1_1);
       
   284 #endif
       
   285 	CleanupStack::PushL(db);
       
   286 
       
   287 	CMDBField<TDesC>* globalSettingField = new(ELeave) CMDBField<TDesC>(KCDTIdBearerAvailabilityCheckTSY);
       
   288 	CleanupStack::PushL(globalSettingField);
       
   289 	globalSettingField->SetRecordId(1);
       
   290 	globalSettingField->SetMaxLengthL(KMaxTextLength);
       
   291 	globalSettingField->LoadL(*db);
       
   292 	aTsyName = *globalSettingField;
       
   293 	CleanupStack::PopAndDestroy(globalSettingField);
       
   294 
       
   295 	CleanupStack::PopAndDestroy(db);
       
   296     LOG( "CLocationManagerServer::GetCommDbTSYnameL(), end" );
       
   297 	}
       
   298 
       
   299 // --------------------------------------------------------------------------
       
   300 // CLocationManagerServer::InitialisePhoneL
       
   301 // --------------------------------------------------------------------------
       
   302 //    
       
   303 void CLocationManagerServer::InitialisePhoneL()
       
   304 	{
       
   305     LOG( "CLocationManagerServer::InitialisePhoneL(), begin" );
       
   306 	User::LeaveIfError(iTelServer.Connect());
       
   307 	iTelServerIsOpen = ETrue;
       
   308 	TBuf<KCommsDbSvrMaxFieldLength> tsyName;
       
   309 	GetCommDbTSYnameL(tsyName);
       
   310 
       
   311 	User::LeaveIfError(iTelServer.LoadPhoneModule(tsyName));
       
   312 
       
   313 	TInt numPhones;
       
   314 	User::LeaveIfError(iTelServer.EnumeratePhones(numPhones));
       
   315 
       
   316 	TInt phoneIndx;
       
   317 	TInt ret = KErrHardwareNotAvailable;
       
   318 
       
   319 	for(phoneIndx=0; phoneIndx<numPhones; phoneIndx++)
       
   320 		{
       
   321 		RTelServer::TPhoneInfo tInfo;
       
   322 		ret = iTelServer.GetPhoneInfo(phoneIndx, tInfo);
       
   323 		if(ret != KErrNone)
       
   324 			{
       
   325 			continue;
       
   326 			}
       
   327 		
       
   328 		ret = iPhone.Open(iTelServer, tInfo.iName);	
       
   329 		if(ret != KErrNone)
       
   330 			{
       
   331 			continue;
       
   332 			}
       
   333 
       
   334 		iPhoneIsOpen = ETrue;
       
   335 
       
   336 		RPhone::TStatus status;
       
   337 		User::LeaveIfError(iPhone.GetStatus(status));
       
   338 		if(status.iModemDetected!=RPhone::EDetectedPresent)
       
   339 			{
       
   340 			ret = iPhone.Initialise();
       
   341 			if(ret != KErrNone)
       
   342 				{
       
   343 				iPhone.Close();
       
   344 				iPhoneIsOpen = EFalse;
       
   345 				continue;
       
   346 				}
       
   347 			}
       
   348         // we found the correct phone
       
   349         break;
       
   350 		}
       
   351 
       
   352 	//
       
   353 	// ret will be KErrNone if a valid phone was found...
       
   354 	//
       
   355 	
       
   356     LOG1( "CLocationManagerServer::InitialisePhoneL(), end. Err - %d", ret );
       
   357 	User::LeaveIfError(ret);
       
   358 	}
       
   359 
       
   360 
       
   361 // --------------------------------------------------------------------------
       
   362 // CLocationManagerServer::CancelRequests()
       
   363 // --------------------------------------------------------------------------
   196 // --------------------------------------------------------------------------
   364 //
   197 //
   365 void CLocationManagerServer::CancelRequests(RArray<RMessage2>& aMessageList)
   198 void CLocationManagerServer::CancelRequests(RArray<RMessage2>& aMessageList)
   366 	{
   199 	{
   367 	const TInt count = aMessageList.Count();
   200 	const TInt count = aMessageList.Count();
   376         	}
   209         	}
   377         }
   210         }
   378     aMessageList.Reset();
   211     aMessageList.Reset();
   379 	}
   212 	}
   380 
   213 
   381 // --------------------------------------------------------------------------
       
   382 // CLocationManagerServer::CancelCopyRequests
       
   383 // --------------------------------------------------------------------------
       
   384 //
       
   385 void CLocationManagerServer::CancelCopyRequests(RArray<TMessageQuery>& aMessageList)
   214 void CLocationManagerServer::CancelCopyRequests(RArray<TMessageQuery>& aMessageList)
   386 	{
   215 	{
   387 	const TInt count = aMessageList.Count();
   216 	const TInt count = aMessageList.Count();
   388 
   217 
   389     for ( TInt i(0) ; i < count; i++ )
   218     for ( TInt i(0) ; i < count; i++ )
   396         	}
   225         	}
   397         }
   226         }
   398     aMessageList.Reset();
   227     aMessageList.Reset();
   399 	}
   228 	}
   400 
   229 
   401 // --------------------------------------------------------------------------
   230 
   402 // CLocationManagerServer::HandleSessionOpened
       
   403 // --------------------------------------------------------------------------
       
   404 //
       
   405 void CLocationManagerServer::HandleSessionOpened(CMdESession& /*aSession*/, TInt aError)
   231 void CLocationManagerServer::HandleSessionOpened(CMdESession& /*aSession*/, TInt aError)
   406 	{
   232 	{
   407 	LOG ("CLocationManagerServer::HandleSessionOpened() start");
   233 	if ( iASW->IsStarted() )
   408 	if ( iASW && iASW->IsStarted() )
       
   409 		{
   234 		{
   410 		iASW->AsyncStop();
   235 		iASW->AsyncStop();
   411 		}
   236 		}
   412 	
   237 	
   413 	if ( KErrNone == aError )
   238 	if ( KErrNone == aError )
   422 		delete iMdeSession;
   247 		delete iMdeSession;
   423 		iMdeSession = NULL;
   248 		iMdeSession = NULL;
   424 		}
   249 		}
   425 	}
   250 	}
   426 
   251 
   427 
   252 void CLocationManagerServer::HandleSessionError(CMdESession& /*aSession*/, TInt /*aError*/)
   428 // --------------------------------------------------------------------------
   253 	{
   429 // CLocationManagerServer::HandleSessionError
       
   430 // --------------------------------------------------------------------------
       
   431 //
       
   432 void CLocationManagerServer::HandleSessionError(CMdESession& /*aSession*/, TInt aError)
       
   433 	{
       
   434 	LOG1 ("CLocationManagerServer::HandleSessionError() start, Error - %d", aError);
       
   435     ARG_USED(aError);
       
   436 	iSessionReady = EFalse;
   254 	iSessionReady = EFalse;
   437 	delete iMdeSession;
   255 	delete iMdeSession;
   438 	iMdeSession = NULL;
   256 	iMdeSession = NULL;
   439 
   257 
   440 	if ( iASW && iASW->IsStarted() )
   258 	if ( iASW->IsStarted() )
   441 		{
   259 		{
   442 		iASW->AsyncStop();
   260 		iASW->AsyncStop();
   443 		}	
   261 		}	
   444 	}
   262 	}
   445 
   263 
   446 
       
   447 
       
   448 // --------------------------------------------------------------------------
       
   449 // CLocationManagerServer::IsSessionReady
       
   450 // --------------------------------------------------------------------------
       
   451 //
       
   452 TBool CLocationManagerServer::IsSessionReady()
   264 TBool CLocationManagerServer::IsSessionReady()
   453 	{
   265 	{
   454 	return iSessionReady;
   266 	return iSessionReady;
   455 	}
   267 	}
   456 
   268 
   488 // CLocationManagerServer::RemoveSession
   300 // CLocationManagerServer::RemoveSession
   489 // --------------------------------------------------------------------------
   301 // --------------------------------------------------------------------------
   490 //    
   302 //    
   491 void CLocationManagerServer::RemoveSession()
   303 void CLocationManagerServer::RemoveSession()
   492     {
   304     {
   493     LOG1( "CLocationManagerServer::RemoveSession. Session count - %d", iSessionCount);
       
   494     iSessionCount--;
   305     iSessionCount--;
   495     StopServer();
   306     if ( !iSessionCount )
       
   307         {
       
   308         CActiveScheduler::Stop();
       
   309         }
   496     }    
   310     }    
   497 
   311 
   498 // --------------------------------------------------------------------------
   312 // --------------------------------------------------------------------------
   499 // CLocationManagerServer::StartGPSPositioningL
   313 // CLocationManagerServer::StartGPSPositioningL
   500 // --------------------------------------------------------------------------
   314 // --------------------------------------------------------------------------
   518         User::Leave( KErrAlreadyExists );
   332         User::Leave( KErrAlreadyExists );
   519         }
   333         }
   520     
   334     
   521     if ( iTimer )
   335     if ( iTimer )
   522     	{
   336     	{
   523     	delete iTimer;
   337     	iTimer->Cancel();
   524     	iTimer = NULL;
       
   525     	}
   338     	}
   526     
   339     
   527     iLocationRecord->StartL( aCaptureSetting );
   340     iLocationRecord->StartL( aCaptureSetting );
   528     }
   341     }
   529 
   342 
   540     RLocationTrail::TTrailState state;
   353     RLocationTrail::TTrailState state;
   541     GetLocationTrailState( state );
   354     GetLocationTrailState( state );
   542      
   355      
   543     if( state != RLocationTrail::ETrailStopped && state != RLocationTrail::ETrailStopping )
   356     if( state != RLocationTrail::ETrailStopped && state != RLocationTrail::ETrailStopping )
   544         {
   357         {
   545         if(iTimer == NULL)
   358         if(!iTimer)
   546             {
   359             {
   547             TRAP_IGNORE(iTimer = CLocationServerTimerHandler::NewL(*this));
   360             TRAPD( error, iTimer = CPeriodic::NewL( CActive::EPriorityUserInput ) );    
       
   361             if ( error != KErrNone )
       
   362                 {
       
   363                 LOG("CLocationManagerServer::StopGPSPositioningL() - iTimer not created");
       
   364                 iTimer = NULL;
       
   365                 }
       
   366             }        
       
   367         if(iTimer)
       
   368             {
       
   369 			iTimer->Cancel();
       
   370             iLocationRecord->SetStateToStopping();
       
   371             iTimer->Start( iLocManStopDelay * 1000000, 0, TCallBack( CheckForRemappingCallback, this ) );
   548             }
   372             }
   549         if ( iTimer == NULL)
       
   550             {
       
   551             // If timer can't be created we stop the location trail immediately.
       
   552             iLocationRecord->Stop();
       
   553             }   
       
   554         else
   373         else
   555             {
   374             {
   556             iLocationRecord->SetStateToStopping();
   375             iLocationRecord->Stop();
   557             iTimer->StartTimer( iLocManStopDelay * 1000000, MLocationServerTimerObserver::EStopRecording);
       
   558             }
   376             }
   559         }
   377         }
   560     
   378     
   561     // Always stop tracklog.
   379     // Always stop tracklog.
   562     StopTrackLogL();
   380     StopTrackLogL();
   569 void CLocationManagerServer::StopRecording()
   387 void CLocationManagerServer::StopRecording()
   570 	{
   388 	{
   571     LOG( "CLocationManagerServer::StopRecording()" );    
   389     LOG( "CLocationManagerServer::StopRecording()" );    
   572     iWaitForPositioningStopTimeout = EFalse;
   390     iWaitForPositioningStopTimeout = EFalse;
   573     iLocationRecord->Stop();		
   391     iLocationRecord->Stop();		
   574 	}
   392 	if(iTimer)
   575 
   393 	    {
   576 // --------------------------------------------------------------------------
   394         iTimer->Cancel();
   577 // CLocationUtilityServer::LocationServerTimerCallBackL
   395 	    }
   578 // --------------------------------------------------------------------------
   396 	
   579 //
       
   580 void CLocationManagerServer::LocationServerTimerCallBackL
       
   581     (const TLocationServerTimerType aLocationServerTimerType, const TInt /*aErrorCode*/)
       
   582 	{
       
   583     LOG1( "CLocationManagerServer::LocationServerTimerCallBackL, begin, Type - %d",
       
   584                 aLocationServerTimerType);
       
   585 	switch(aLocationServerTimerType)
       
   586         {
       
   587         case MLocationServerTimerObserver::EStopRecording:
       
   588             CheckForRemappingCallback();
       
   589             break;
       
   590         case MLocationServerTimerObserver::EPositioningStopTimeout:
       
   591             PositioningStopTimeout();
       
   592             break;
       
   593         case MLocationServerTimerObserver::ELocGeneralPurpose:
       
   594         default:
       
   595             // execution shouldn't come over here.
       
   596             LOG("Invalid timer type");
       
   597             break;
       
   598         }
       
   599     LOG( "CLocationManagerServer::LocationServerTimerCallBackL, end" );
       
   600 	}
   397 	}
   601 
   398 
   602 // --------------------------------------------------------------------------
   399 // --------------------------------------------------------------------------
   603 // CLocationUtilityServer::PositioningStopTimeout
   400 // CLocationUtilityServer::PositioningStopTimeout
   604 // --------------------------------------------------------------------------
   401 // --------------------------------------------------------------------------
   605 //
   402 //
   606 void CLocationManagerServer::PositioningStopTimeout()
   403 TInt CLocationManagerServer::PositioningStopTimeout( TAny* aAny )
   607 	{
   404 	{
   608     LOG( "CLocationManagerServer::PositioningStopTimeout" );
   405     LOG( "CLocationManagerServer::PositioningStopTimeout" );
   609 	StopRecording();
   406 	CLocationManagerServer* self = STATIC_CAST( CLocationManagerServer*, aAny );
   610 	}
   407 	self->StopRecording();
   611 
   408 	
   612 // --------------------------------------------------------------------------
   409 	return KErrNone;
   613 // CLocationUtilityServer::CheckForRemappingCallback
   410 	}
   614 // --------------------------------------------------------------------------
   411 
   615 //
   412 // --------------------------------------------------------------------------
   616 void CLocationManagerServer::CheckForRemappingCallback()
   413 // CLocationUtilityServer::PositioningStopTimeout
   617     {
   414 // --------------------------------------------------------------------------
   618     LOG( "CLocationManagerServer::CheckForRemappingCallback, begin" );
   415 //
   619     if ( iLocationRecord->RemappingNeeded() && !iLocationRecord->IsLowBattery())
   416 TInt CLocationManagerServer::CheckForRemappingCallback( TAny* aAny )
       
   417     {
       
   418     LOG( "CLocationManagerServer::CheckForRemappingCallback" );
       
   419     CLocationManagerServer* self = STATIC_CAST( CLocationManagerServer*, aAny );
       
   420 
       
   421     self->iTimer->Cancel();    
       
   422     
       
   423     if ( self->iLocationRecord->RemappingNeeded() && !self->iLocationRecord->IsLowBattery())
   620         {     
   424         {     
   621         iTimer->StartTimer( iLocManStopRemapDelay * 1000000, MLocationServerTimerObserver::EPositioningStopTimeout);
   425         self->iTimer->Start( self->iLocManStopRemapDelay * 1000000, 0, TCallBack( PositioningStopTimeout, self ) );
   622         iWaitForPositioningStopTimeout = ETrue;
   426         self->iWaitForPositioningStopTimeout = ETrue;
   623         }
   427         }
   624     else
   428     else
   625         {        
   429         {        
   626         StopRecording();
   430         self->StopRecording();
   627         }
   431         }
   628     LOG( "CLocationManagerServer::CheckForRemappingCallback, end" );
   432     
       
   433     return KErrNone;
   629     }
   434     }
   630 
   435 
   631 // --------------------------------------------------------------------------
   436 // --------------------------------------------------------------------------
   632 // CLocationManagerServer::GetLocationTrailState
   437 // CLocationManagerServer::GetLocationTrailState
   633 // --------------------------------------------------------------------------
   438 // --------------------------------------------------------------------------
   741         }
   546         }
   742     LOG( "CLocationManagerServer::CancelLocationRequest(), end" );
   547     LOG( "CLocationManagerServer::CancelLocationRequest(), end" );
   743     }
   548     }
   744 
   549 
   745 // --------------------------------------------------------------------------
   550 // --------------------------------------------------------------------------
   746 // CLocationManagerServer::GetCurrentNetworkInfo
   551 // CLocationManagerServer::GetCurrentCellId
   747 // --------------------------------------------------------------------------
   552 // --------------------------------------------------------------------------
   748 //    
   553 //    
   749 void CLocationManagerServer::GetCurrentNetworkInfo( CTelephony::TNetworkInfoV1& aNetworkInfo )
   554 void CLocationManagerServer::GetCurrentNetworkInfo( CTelephony::TNetworkInfoV1& aNetworkInfo )
   750     {
   555     {
   751     iLocationRecord->GetNetworkInfo( aNetworkInfo );
   556     iLocationRecord->GetNetworkInfo( aNetworkInfo );
   823 	iLocationReqs.Reset();
   628 	iLocationReqs.Reset();
   824 
   629 
   825     LOG( "CLocationManagerServer::CurrentLocation(), end" );    
   630     LOG( "CLocationManagerServer::CurrentLocation(), end" );    
   826     }
   631     }
   827 
   632 
   828 
       
   829 // --------------------------------------------------------------------------
       
   830 // CLocationManagerServer::GPSSignalQualityChanged
       
   831 // --------------------------------------------------------------------------
       
   832 //
       
   833 void CLocationManagerServer::GPSSignalQualityChanged( const TPositionSatelliteInfo& aSatelliteInfo )
   633 void CLocationManagerServer::GPSSignalQualityChanged( const TPositionSatelliteInfo& aSatelliteInfo )
   834 	{
   634 	{
   835 	LOG( "CLocationManagerServer::GPSSignalQualityChanged" );
   635 	LOG( "CLocationManagerServer::GPSSignalQualityChanged" );
   836 	const TInt KFixParam = 0;
   636 	const TInt KFixParam = 0;
   837 	const TInt KPositionInfoParam = 1;
   637 	const TInt KPositionInfoParam = 1;
   875 		}
   675 		}
   876 	iTrackLogNotifyReqs.Reset();
   676 	iTrackLogNotifyReqs.Reset();
   877 	}
   677 	}
   878 
   678 
   879 
   679 
   880 // --------------------------------------------------------------------------
   680 
   881 // CLocationManagerServer::CancelTrackLogNotificationRequest
       
   882 // --------------------------------------------------------------------------
       
   883 //
       
   884 void CLocationManagerServer::CancelTrackLogNotificationRequest( const TInt aHandle )
   681 void CLocationManagerServer::CancelTrackLogNotificationRequest( const TInt aHandle )
   885 	{
   682 	{
   886 	LOG( "CLocationManagerServer::CancelTrackLogNotificationRequest(), begin" );
   683 	LOG( "CLocationManagerServer::CancelTrackLogNotificationRequest(), begin" );
   887     
   684     
   888     const TInt count = iTrackLogNotifyReqs.Count();
   685     const TInt count = iTrackLogNotifyReqs.Count();
   905         }
   702         }
   906 
   703 
   907     LOG( "CLocationManagerServer::CancelTrackLogNotificationRequest(), end" );
   704     LOG( "CLocationManagerServer::CancelTrackLogNotificationRequest(), end" );
   908 	}
   705 	}
   909 
   706 
   910 
       
   911 // --------------------------------------------------------------------------
       
   912 // CLocationManagerServer::CreateLocationObjectL
       
   913 // --------------------------------------------------------------------------
       
   914 //
       
   915 void CLocationManagerServer::CreateLocationObjectL( const TLocationData& aLocationData,
   707 void CLocationManagerServer::CreateLocationObjectL( const TLocationData& aLocationData,
   916 													const TUint& aObjectId )
   708 													const TUint& aObjectId )
   917 	{
   709 	{
   918 	if ( !IsSessionReady() )
   710 	if ( !IsSessionReady() )
   919 		{
   711 		{
   921 		}
   713 		}
   922 	
   714 	
   923 	iLocationRecord->CreateLocationObjectL( aLocationData, aObjectId );
   715 	iLocationRecord->CreateLocationObjectL( aLocationData, aObjectId );
   924 	}
   716 	}
   925 
   717 
   926 
       
   927 // --------------------------------------------------------------------------
       
   928 // CLocationManagerServer::LocationSnapshotL
       
   929 // --------------------------------------------------------------------------
       
   930 //
       
   931 void CLocationManagerServer::LocationSnapshotL( const TUint& aObjectId )
   718 void CLocationManagerServer::LocationSnapshotL( const TUint& aObjectId )
   932 	{
   719 	{
   933     LOG( "CLocationManagerServer::LocationSnapshotL(), begin" );
       
   934 	if ( !IsSessionReady() )
   720 	if ( !IsSessionReady() )
   935 		{
   721 		{
   936         LOG( "Session is not ready" );
       
   937 		User::Leave( KErrNotReady );
   722 		User::Leave( KErrNotReady );
   938 		}
   723 		}
   939 	iLocationRecord->LocationSnapshotL( aObjectId );
   724 	iLocationRecord->LocationSnapshotL( aObjectId );
   940     LOG( "CLocationManagerServer::LocationSnapshotL(), end" );
       
   941 	}
   725 	}
   942 
   726 
   943 // --------------------------------------------------------------------------
   727 // --------------------------------------------------------------------------
   944 // CLocationManagerServer::RemoveLocationObjectL
   728 // CLocationManagerServer::RemoveLocationObjectL
   945 // --------------------------------------------------------------------------
   729 // --------------------------------------------------------------------------
   971 	
   755 	
   972     iRemoveLocation = ETrue;
   756     iRemoveLocation = ETrue;
   973     iRelationQuery->FindL( 1, 1 );
   757     iRelationQuery->FindL( 1, 1 );
   974 	}
   758 	}
   975 
   759 
   976 
       
   977 // --------------------------------------------------------------------------
       
   978 // CLocationManagerServer::CopyLocationObjectL
       
   979 // --------------------------------------------------------------------------
       
   980 //
       
   981 void CLocationManagerServer::CopyLocationObjectL( TItemId aSource, 
   760 void CLocationManagerServer::CopyLocationObjectL( TItemId aSource, 
   982 		const RArray<TItemId>& aTargets, TMessageQuery& aMessageQuery )
   761 		const RArray<TItemId>& aTargets, TMessageQuery& aMessageQuery )
   983 	{
   762 	{
   984 	if( aTargets.Count() <= 0 )
   763 	if( aTargets.Count() <= 0 )
   985 		{
   764 		{
  1037     	aMessageQuery.iMessage.Complete( KErrNotFound );
   816     	aMessageQuery.iMessage.Complete( KErrNotFound );
  1038     	iCopyReqs.Remove( iCopyReqs.Find( aMessageQuery ) );
   817     	iCopyReqs.Remove( iCopyReqs.Find( aMessageQuery ) );
  1039     	}
   818     	}
  1040 	}
   819 	}
  1041 
   820 
  1042 
       
  1043 // --------------------------------------------------------------------------
       
  1044 // CLocationManagerServer::CopyLocationObjectL
       
  1045 // --------------------------------------------------------------------------
       
  1046 //
       
  1047 void CLocationManagerServer::CopyLocationObjectL( const TDesC& aSource, 
   821 void CLocationManagerServer::CopyLocationObjectL( const TDesC& aSource, 
  1048 		const RArray<TPtrC>& aTargets, TMessageQuery& aQuery )
   822 		const RArray<TPtrC>& aTargets, TMessageQuery& aQuery )
  1049 	{
   823 	{
  1050 	CMdENamespaceDef& namespaceDef = iMdeSession->GetDefaultNamespaceDefL();
   824 	CMdENamespaceDef& namespaceDef = iMdeSession->GetDefaultNamespaceDefL();
  1051 	TMdEObject obj;
   825 	TMdEObject obj;
  1063 		}
   837 		}
  1064 
   838 
  1065 	CopyLocationObjectL( source, iTargetObjectIds, aQuery );
   839 	CopyLocationObjectL( source, iTargetObjectIds, aQuery );
  1066 	}
   840 	}
  1067 
   841 
  1068 
       
  1069 // --------------------------------------------------------------------------
       
  1070 // CLocationManagerServer::HandleQueryNewResults
       
  1071 // --------------------------------------------------------------------------
       
  1072 //
       
  1073 void CLocationManagerServer::HandleQueryNewResults( CMdEQuery& /*aQuery*/, 
   842 void CLocationManagerServer::HandleQueryNewResults( CMdEQuery& /*aQuery*/, 
  1074 		TInt /*aFirstNewItemIndex*/, TInt /*aNewItemCount*/ )
   843 		TInt /*aFirstNewItemIndex*/, TInt /*aNewItemCount*/ )
  1075 	{
   844 	{
  1076 	}
   845 	}
  1077 
   846 
  1078 
       
  1079 // --------------------------------------------------------------------------
       
  1080 // CLocationManagerServer::HandleQueryCompleted
       
  1081 // --------------------------------------------------------------------------
       
  1082 //
       
  1083 void CLocationManagerServer::HandleQueryCompleted( CMdEQuery& aQuery, TInt aError )
   847 void CLocationManagerServer::HandleQueryCompleted( CMdEQuery& aQuery, TInt aError )
  1084 	{	
   848 	{	
  1085 	LOG("CLocationManagerServer::HandleQueryCompleted");
       
  1086 	if ( iRemoveLocation )
   849 	if ( iRemoveLocation )
  1087 		{
   850 		{
  1088 		if( aQuery.Count() > 0 && aError == KErrNone )
   851 		if( aQuery.Count() > 0 && aError == KErrNone )
  1089 			{
   852 			{
  1090 			TRAPD( err, iMdeSession->RemoveRelationL( aQuery.ResultId( 0 ), &aQuery.NamespaceDef() ) );			
   853 			TRAPD( err, iMdeSession->RemoveRelationL( aQuery.ResultId( 0 ), &aQuery.NamespaceDef() ) );			
  1114 						{
   877 						{
  1115 						aError = KErrNotFound;
   878 						aError = KErrNotFound;
  1116 						}
   879 						}
  1117 					iCopyReqs[i].iMessage.Complete( aError );
   880 					iCopyReqs[i].iMessage.Complete( aError );
  1118 					delete iCopyReqs[i].iQuery;
   881 					delete iCopyReqs[i].iQuery;
  1119 					iCopyReqs[i].iQuery = NULL;
       
  1120 					iCopyReqs.Remove( i );
   882 					iCopyReqs.Remove( i );
  1121 					break;
   883 					break;
  1122 					}
   884 					}
  1123 				}
   885 				}
  1124 			}
   886 			}
  1125 		}
   887 		}
  1126 
   888 
  1127 	iTargetObjectIds.Reset();
   889 	iTargetObjectIds.Reset();
  1128 	}
   890 	}
  1129 
   891 
  1130 
       
  1131 // --------------------------------------------------------------------------
       
  1132 // CLocationManagerServer::NewLC
       
  1133 // --------------------------------------------------------------------------
       
  1134 //
       
  1135 void CLocationManagerServer::CopyLocationL( CMdEQuery& aQuery )
   892 void CLocationManagerServer::CopyLocationL( CMdEQuery& aQuery )
  1136 	{
   893 	{
  1137 	CMdEObjectDef& locationDef = aQuery.NamespaceDef().GetObjectDefL( Location::KLocationObject );
   894 	CMdEObjectDef& locationDef = aQuery.NamespaceDef().GetObjectDefL( Location::KLocationObject );
  1138 
   895 
  1139     CMdERelation& result = static_cast<CMdERelation&>( aQuery.ResultItem( 0 ) );
   896     CMdERelation& result = static_cast<CMdERelation&>( aQuery.ResultItem( 0 ) );
  1161     	{
   918     	{
  1162     	if ( iCopyReqs[i].iQuery == &aQuery )
   919     	if ( iCopyReqs[i].iQuery == &aQuery )
  1163     		{
   920     		{
  1164     		iCopyReqs[i].iMessage.Complete( KErrNone );
   921     		iCopyReqs[i].iMessage.Complete( KErrNone );
  1165     		delete iCopyReqs[i].iQuery;
   922     		delete iCopyReqs[i].iQuery;
  1166     		iCopyReqs[i].iQuery = NULL;
       
  1167     		iCopyReqs.Remove( i );
   923     		iCopyReqs.Remove( i );
  1168     		break;
   924     		break;
  1169     		}
   925     		}
  1170     	}
   926     	}
  1171 	}
   927 	}
  1172 
   928 
  1173 
       
  1174 // --------------------------------------------------------------------------
       
  1175 // CLocationManagerServer::InitCopyLocationByIdL
       
  1176 // --------------------------------------------------------------------------
       
  1177 //
       
  1178 void CLocationManagerServer::InitCopyLocationByIdL( const RMessage2& aMessage )
   929 void CLocationManagerServer::InitCopyLocationByIdL( const RMessage2& aMessage )
  1179 	{
   930 	{
  1180 	const TInt KParamSourceId = 0;
   931 	const TInt KParamSourceId = 0;
  1181 	const TInt KParamTargetIds = 1;
   932 	const TInt KParamTargetIds = 1;
  1182 	TItemId sourceId = 0;
   933 	TItemId sourceId = 0;
  1206 	    CleanupStack::PopAndDestroy(paramBuf);
   957 	    CleanupStack::PopAndDestroy(paramBuf);
  1207 	    }
   958 	    }
  1208 	CleanupStack::PopAndDestroy(&targetIds);
   959 	CleanupStack::PopAndDestroy(&targetIds);
  1209 	}
   960 	}
  1210 
   961 
  1211 
       
  1212 // --------------------------------------------------------------------------
       
  1213 // CLocationManagerServer::InitCopyLocationByURIL
       
  1214 // --------------------------------------------------------------------------
       
  1215 //
       
  1216 void CLocationManagerServer::InitCopyLocationByURIL( const RMessage2& aMessage )
   962 void CLocationManagerServer::InitCopyLocationByURIL( const RMessage2& aMessage )
  1217 	{
   963 	{
  1218     LOG( "CLocationManagerSession::CopyLocationDataByUriL begin" );
   964     LOG( "CLocationManagerSession::CopyLocationDataByUriL begin" );
  1219     const TInt KParamSourceUri = 0;
   965     const TInt KParamSourceUri = 0;
  1220     const TInt KParamTargetUris = 1;
   966     const TInt KParamTargetUris = 1;
  1260     	}
  1006     	}
  1261     
  1007     
  1262     LOG( "CLocationManagerSession::CopyLocationDataByUriL end" );
  1008     LOG( "CLocationManagerSession::CopyLocationDataByUriL end" );
  1263 	}
  1009 	}
  1264 
  1010 
  1265 
       
  1266 // --------------------------------------------------------------------------
       
  1267 // CLocationManagerServer::StartTrackLogL
       
  1268 // --------------------------------------------------------------------------
       
  1269 //
       
  1270 TItemId CLocationManagerServer::StartTrackLogL()
  1011 TItemId CLocationManagerServer::StartTrackLogL()
  1271 	{
  1012 	{
  1272 	LOG("CLocationManagerServer::StartTrackLogL");
       
  1273 	if ( iTrackLog->IsRecording() )
  1013 	if ( iTrackLog->IsRecording() )
  1274 		{
  1014 		{
  1275 		User::Leave( KErrInUse );
  1015 		User::Leave( KErrInUse );
  1276 		}
  1016 		}
  1277 	
  1017 	
  1284 	CompleteNotifyRequest( EStarted, KErrNone );
  1024 	CompleteNotifyRequest( EStarted, KErrNone );
  1285 	
  1025 	
  1286 	return iTagId;
  1026 	return iTagId;
  1287 	}
  1027 	}
  1288 
  1028 
  1289 
       
  1290 // --------------------------------------------------------------------------
       
  1291 // CLocationManagerServer::StopTrackLogL
       
  1292 // --------------------------------------------------------------------------
       
  1293 //
       
  1294 void CLocationManagerServer::StopTrackLogL()
  1029 void CLocationManagerServer::StopTrackLogL()
  1295 	{
  1030 	{
  1296 	LOG("CLocationManagerServer::StopTrackLogL");
       
  1297 	if ( iTrackLog->IsRecording() )
  1031 	if ( iTrackLog->IsRecording() )
  1298 		{
  1032 		{
  1299 		iTrackLog->StopRecordingL();
  1033 		iTrackLog->StopRecordingL();
  1300 		
  1034 		
  1301 		CompleteNotifyRequest( EStopped, KErrNone );
  1035 		CompleteNotifyRequest( EStopped, KErrNone );
  1304 		TRAP_IGNORE( iMdeSession->RemoveObjectObserverL( *this, &iMdeSession->GetDefaultNamespaceDefL()) );
  1038 		TRAP_IGNORE( iMdeSession->RemoveObjectObserverL( *this, &iMdeSession->GetDefaultNamespaceDefL()) );
  1305 		TRAP_IGNORE( iMdeSession->RemoveObjectObserverL( *this, &iMdeSession->GetDefaultNamespaceDefL()) );
  1039 		TRAP_IGNORE( iMdeSession->RemoveObjectObserverL( *this, &iMdeSession->GetDefaultNamespaceDefL()) );
  1306 		}
  1040 		}
  1307 	}
  1041 	}
  1308 
  1042 
  1309 
       
  1310 // --------------------------------------------------------------------------
       
  1311 // CLocationManagerServer::CompleteNotifyRequest
       
  1312 // --------------------------------------------------------------------------
       
  1313 //
       
  1314 void CLocationManagerServer::CompleteNotifyRequest( TEventTypes aEventType, TInt aError )
  1043 void CLocationManagerServer::CompleteNotifyRequest( TEventTypes aEventType, TInt aError )
  1315 	{
  1044 	{
  1316 	LOG("CLocationManagerServer::CompleteNotifyRequest");
       
  1317 	const TInt KEventTypeParam = 2;
  1045 	const TInt KEventTypeParam = 2;
  1318 	TPckg<TEventTypes> wrapEventType( aEventType );
  1046 	TPckg<TEventTypes> wrapEventType( aEventType );
  1319 	
  1047 	
  1320 	const TInt count = iTrackLogNotifyReqs.Count();
  1048 	const TInt count = iTrackLogNotifyReqs.Count();
  1321 	for ( TInt i( count ); --i >= 0; )
  1049 	for ( TInt i( count ); --i >= 0; )
  1329 			}
  1057 			}
  1330 		}
  1058 		}
  1331 	iTrackLogNotifyReqs.Reset();
  1059 	iTrackLogNotifyReqs.Reset();
  1332 	}
  1060 	}
  1333 
  1061 
  1334 
       
  1335 // --------------------------------------------------------------------------
       
  1336 // CLocationManagerServer::IsTrackLogRecording
       
  1337 // --------------------------------------------------------------------------
       
  1338 //
       
  1339 void CLocationManagerServer::IsTrackLogRecording( TBool &aRec )
  1062 void CLocationManagerServer::IsTrackLogRecording( TBool &aRec )
  1340 	{
  1063 	{
  1341 	aRec = iTrackLog->IsRecording();
  1064 	aRec = iTrackLog->IsRecording();
  1342 	}
  1065 	}
  1343 
  1066 
  1344 
       
  1345 // --------------------------------------------------------------------------
       
  1346 // CLocationManagerServer::GpxFileCreated
       
  1347 // --------------------------------------------------------------------------
       
  1348 //
       
  1349 void CLocationManagerServer::GpxFileCreated( const TDesC& aFileName, TItemId aTagId,
  1067 void CLocationManagerServer::GpxFileCreated( const TDesC& aFileName, TItemId aTagId,
  1350 		TReal32 aLength, TTime aStart, TTime aEnd )
  1068 		TReal32 aLength, TTime aStart, TTime aEnd )
  1351 	{
  1069 	{
  1352 	TRAP_IGNORE( CreateTrackLogL( aTagId, aFileName, aLength, aStart, aEnd ) );
  1070 	TRAP_IGNORE( CreateTrackLogL( aTagId, aFileName, aLength, aStart, aEnd ) );
  1353 	}
  1071 	}
  1354 
  1072 
  1355 
       
  1356 // --------------------------------------------------------------------------
       
  1357 // CLocationManagerServer::CreateTrackLogTagL
       
  1358 // --------------------------------------------------------------------------
       
  1359 //
       
  1360 TItemId CLocationManagerServer::CreateTrackLogTagL()
  1073 TItemId CLocationManagerServer::CreateTrackLogTagL()
  1361 	{
  1074 	{
  1362 	LOG("CLocationManagerServer::CreateTrackLogTagL");
       
  1363 	if ( !IsSessionReady() )
  1075 	if ( !IsSessionReady() )
  1364 		{
  1076 		{
  1365 		User::Leave( KErrNotReady );
  1077 		User::Leave( KErrNotReady );
  1366 		}
  1078 		}
  1367 	
  1079 	
  1390 	CleanupStack::PopAndDestroy( trackLogTag );
  1102 	CleanupStack::PopAndDestroy( trackLogTag );
  1391 	
  1103 	
  1392 	return tagId;
  1104 	return tagId;
  1393 	}
  1105 	}
  1394 
  1106 
  1395 
       
  1396 // --------------------------------------------------------------------------
       
  1397 // CLocationManagerServer::CreateTrackLogL
       
  1398 // --------------------------------------------------------------------------
       
  1399 //
       
  1400 void CLocationManagerServer::CreateTrackLogL( TItemId aTagId, const TDesC& aUri, TReal32 aLength,
  1107 void CLocationManagerServer::CreateTrackLogL( TItemId aTagId, const TDesC& aUri, TReal32 aLength,
  1401 		TTime aStart, TTime aEnd )
  1108 		TTime aStart, TTime aEnd )
  1402 	{
  1109 	{
  1403 	LOG("CLocationManagerServer::CreateTrackLogL");
       
  1404 	if ( !IsSessionReady() )
  1110 	if ( !IsSessionReady() )
  1405 		{
  1111 		{
  1406 		User::Leave( KErrNotReady );
  1112 		User::Leave( KErrNotReady );
  1407 		}
  1113 		}
  1408 
  1114 
  1445     
  1151     
  1446     CleanupStack::PopAndDestroy( relationObject );
  1152     CleanupStack::PopAndDestroy( relationObject );
  1447     CleanupStack::PopAndDestroy( trackLog );
  1153     CleanupStack::PopAndDestroy( trackLog );
  1448 	}
  1154 	}
  1449 
  1155 
  1450 
       
  1451 // --------------------------------------------------------------------------
       
  1452 // CLocationManagerServer::GetTrackLogStatus
       
  1453 // --------------------------------------------------------------------------
       
  1454 //
       
  1455 TInt CLocationManagerServer::GetTrackLogStatus( TBool& aRecording, TPositionSatelliteInfo& aFixQuality)
  1156 TInt CLocationManagerServer::GetTrackLogStatus( TBool& aRecording, TPositionSatelliteInfo& aFixQuality)
  1456 	{
  1157 	{
  1457 	if ( !iTrackLog )
  1158 	if ( !iTrackLog )
  1458 		{
  1159 		{
  1459 		return KErrNotFound;
  1160 		return KErrNotFound;
  1462 	iTrackLog->GetStatus( aRecording, aFixQuality );
  1163 	iTrackLog->GetStatus( aRecording, aFixQuality );
  1463 	
  1164 	
  1464 	return KErrNone;
  1165 	return KErrNone;
  1465 	}
  1166 	}
  1466 
  1167 
  1467 
       
  1468 // --------------------------------------------------------------------------
       
  1469 // CLocationManagerServer::DeleteTrackLogL
       
  1470 // --------------------------------------------------------------------------
       
  1471 //
       
  1472 TInt CLocationManagerServer::DeleteTrackLogL( const TDesC& aUri )
  1168 TInt CLocationManagerServer::DeleteTrackLogL( const TDesC& aUri )
  1473 	{
  1169 	{
  1474     LOG( "CLocationManagerServer::DeleteTrackLogL enter" );
  1170     LOG( "CLocationManagerServer::DeleteTrackLogL enter" );
  1475     
  1171     
  1476     // remove tracklog mde object 
  1172     // remove tracklog mde object 
  1507     LOG( "CLocationManagerServer::DeleteTrackLogL return" );
  1203     LOG( "CLocationManagerServer::DeleteTrackLogL return" );
  1508 	
  1204 	
  1509     return err;
  1205     return err;
  1510 	}
  1206 	}
  1511 
  1207 
  1512 
       
  1513 // --------------------------------------------------------------------------
       
  1514 // CLocationManagerServer::TrackLogName
       
  1515 // --------------------------------------------------------------------------
       
  1516 //
       
  1517 TInt CLocationManagerServer::TrackLogName( TFileName& aFileName )
  1208 TInt CLocationManagerServer::TrackLogName( TFileName& aFileName )
  1518 	{
  1209 	{
  1519 	if ( iTrackLog->IsRecording() )
  1210 	if ( iTrackLog->IsRecording() )
  1520 		{
  1211 		{
  1521 		iTrackLog->GetTrackLogName(aFileName);
  1212 		iTrackLog->GetTrackLogName(aFileName);
  1522 		return KErrNone;
  1213 		return KErrNone;
  1523 		}
  1214 		}
  1524 	return KErrNotFound;
  1215 	return KErrNotFound;
  1525 	}
  1216 	}
  1526 
  1217 
  1527 
       
  1528 // --------------------------------------------------------------------------
       
  1529 // CLocationManagerServer::GetCaptureSetting
       
  1530 // --------------------------------------------------------------------------
       
  1531 //
       
  1532 void CLocationManagerServer::GetCaptureSetting( RLocationTrail::TTrailCaptureSetting& aCaptureSetting )
  1218 void CLocationManagerServer::GetCaptureSetting( RLocationTrail::TTrailCaptureSetting& aCaptureSetting )
  1533 	{
  1219 	{
  1534 	aCaptureSetting = iCaptureSetting;
  1220 	aCaptureSetting = iCaptureSetting;
  1535 	}
  1221 	}
  1536 
  1222 
  1537 
       
  1538 // --------------------------------------------------------------------------
       
  1539 // CLocationManagerServer::HandleObjectNotification
       
  1540 // --------------------------------------------------------------------------
       
  1541 //
       
  1542 void CLocationManagerServer::HandleObjectNotification( CMdESession& /*aSession*/,
  1223 void CLocationManagerServer::HandleObjectNotification( CMdESession& /*aSession*/,
  1543 		TObserverNotificationType aType,
  1224 		TObserverNotificationType aType,
  1544 		const RArray<TItemId>& aObjectIdArray )
  1225 		const RArray<TItemId>& aObjectIdArray )
  1545 	{
  1226 	{
  1546 	// If notification type is remove then someone has deleted a tracklog tag.
  1227 	// If notification type is remove then someone has deleted a tracklog tag.
  1551 		}
  1232 		}
  1552 	
  1233 	
  1553 	TRAP_IGNORE( LinkObjectToTrackLogTagL( aObjectIdArray ) );
  1234 	TRAP_IGNORE( LinkObjectToTrackLogTagL( aObjectIdArray ) );
  1554 	}
  1235 	}
  1555 
  1236 
  1556 
       
  1557 // --------------------------------------------------------------------------
       
  1558 // CLocationManagerServer::StartListeningTagRemovalsL
       
  1559 // --------------------------------------------------------------------------
       
  1560 //
       
  1561 void CLocationManagerServer::StartListeningTagRemovalsL()
  1237 void CLocationManagerServer::StartListeningTagRemovalsL()
  1562 	{
  1238 	{
  1563 	if ( !IsSessionReady() )
  1239 	if ( !IsSessionReady() )
  1564 		{
  1240 		{
  1565 		User::Leave( KErrNotReady );
  1241 		User::Leave( KErrNotReady );
  1571     iMdeSession->AddObjectObserverL( *this, condition, ENotifyRemove, 
  1247     iMdeSession->AddObjectObserverL( *this, condition, ENotifyRemove, 
  1572     		&iMdeSession->GetDefaultNamespaceDefL() );
  1248     		&iMdeSession->GetDefaultNamespaceDefL() );
  1573     CleanupStack::Pop( condition );
  1249     CleanupStack::Pop( condition );
  1574 	}
  1250 	}
  1575 
  1251 
  1576 
       
  1577 // --------------------------------------------------------------------------
       
  1578 // CLocationManagerServer::StartListeningObjectCreationsL
       
  1579 // --------------------------------------------------------------------------
       
  1580 //
       
  1581 void CLocationManagerServer::StartListeningObjectCreationsL()
  1252 void CLocationManagerServer::StartListeningObjectCreationsL()
  1582 	{
  1253 	{
  1583 	if ( !IsSessionReady() )
  1254 	if ( !IsSessionReady() )
  1584 		{
  1255 		{
  1585 		User::Leave( KErrNotReady );
  1256 		User::Leave( KErrNotReady );
  1598 	iMdeSession->AddObjectObserverL( *this, condition, ENotifyAdd | ENotifyModify,
  1269 	iMdeSession->AddObjectObserverL( *this, condition, ENotifyAdd | ENotifyModify,
  1599 			&iMdeSession->GetDefaultNamespaceDefL() );
  1270 			&iMdeSession->GetDefaultNamespaceDefL() );
  1600 	
  1271 	
  1601 	}
  1272 	}
  1602 
  1273 
  1603 
       
  1604 // --------------------------------------------------------------------------
       
  1605 // CLocationManagerServer::LinkObjectToTrackLogTagL
       
  1606 // --------------------------------------------------------------------------
       
  1607 //
       
  1608 void CLocationManagerServer::LinkObjectToTrackLogTagL( const RArray<TItemId>& aObjectIdArray )
  1274 void CLocationManagerServer::LinkObjectToTrackLogTagL( const RArray<TItemId>& aObjectIdArray )
  1609 	{
  1275 	{
  1610 	CMdERelationDef& containsRelDef = iMdeSession->GetDefaultNamespaceDefL()
  1276 	CMdERelationDef& containsRelDef = iMdeSession->GetDefaultNamespaceDefL()
  1611 		.GetRelationDefL( Relations::KContains );
  1277 		.GetRelationDefL( Relations::KContains );
  1612 
  1278 
  1620 
  1286 
  1621 		CleanupStack::PopAndDestroy( relationObject );
  1287 		CleanupStack::PopAndDestroy( relationObject );
  1622 		}
  1288 		}
  1623 	}
  1289 	}
  1624 
  1290 
  1625 
       
  1626 // --------------------------------------------------------------------------
       
  1627 // CLocationManagerServer::AddGpxObserver
       
  1628 // --------------------------------------------------------------------------
       
  1629 //
       
  1630 void CLocationManagerServer::AddGpxObserver( MGpxConversionObserver* aObserver )
  1291 void CLocationManagerServer::AddGpxObserver( MGpxConversionObserver* aObserver )
  1631 	{
  1292 	{
  1632 	iTrackLog->AddGpxObserver( aObserver );
  1293 	iTrackLog->AddGpxObserver( aObserver );
  1633 	}
  1294 	}
  1634 
  1295 
  1635 // --------------------------------------------------------------------------
       
  1636 // CLocationManagerServer::RemapedCompleted()
       
  1637 // --------------------------------------------------------------------------
       
  1638 //
       
  1639 void CLocationManagerServer::RemapedCompleted()
  1296 void CLocationManagerServer::RemapedCompleted()
  1640     {
  1297     {
  1641     LOG( "CLocationManagerServer::RemapedCompleted()" );
  1298     LOG( "CLocationManagerServer::RemapedCompleted()" );
  1642     StopRecording();
  1299     StopRecording();
  1643     }
  1300     }
  1644 
  1301 
  1645 // --------------------------------------------------------------------------
       
  1646 // CLocationManagerServer::WaitForPositioningStopTimeout()
       
  1647 // --------------------------------------------------------------------------
       
  1648 //
       
  1649 TBool CLocationManagerServer::WaitForPositioningStopTimeout()
  1302 TBool CLocationManagerServer::WaitForPositioningStopTimeout()
  1650     {
  1303     {
  1651     LOG( "CLocationManagerServer::WaitForPositioningStopTimeout()" );
  1304     LOG( "CLocationManagerServer::WaitForPositioningStopTimeout()" );
  1652     return iWaitForPositioningStopTimeout;
  1305     return iWaitForPositioningStopTimeout;
  1653     }
  1306     }
  1654 
  1307 
  1655 // --------------------------------------------------------------------------
       
  1656 // CLocationManagerServer::GeoTaggingCompleted
       
  1657 // --------------------------------------------------------------------------
       
  1658 //
       
  1659 
       
  1660 void CLocationManagerServer::GeoTaggingCompleted(  const TInt aError  )
       
  1661     {    
       
  1662     LOG("CLocationManagerServer::GeoTaggingCompleted ,begin");
       
  1663     ARG_USED(aError);
       
  1664     // do nothing  because we are only handling pending request for this object.    
       
  1665 #ifdef LOC_REVERSEGEOCODE
       
  1666     if(!iGeoTaggingMessage.IsNull())
       
  1667     	{
       
  1668 		LOG("Completing the request");
       
  1669 		iGeoTaggingMessage.Complete(aError);
       
  1670 		iGeoTaggingMessage = RMessage2 ();
       
  1671     	}
       
  1672 #endif //LOC_REVERSEGEOCODE
       
  1673     StopServer();
       
  1674 	LOG("CLocationManagerServer::GeoTaggingCompleted ,end");
       
  1675     }
       
  1676 
       
  1677 
       
  1678 // --------------------------------------------------------------------------
       
  1679 // CLocationManagerServer::StopServer
       
  1680 // --------------------------------------------------------------------------
       
  1681 //
       
  1682 
       
  1683 void CLocationManagerServer::StopServer()
       
  1684     {    
       
  1685     LOG("CLocationManagerServer::StopServer ,begin");
       
  1686     // once geo tagging completed, check whether, we can terminate the server
       
  1687     // dont't stop this process if
       
  1688     // 1. when client are connected.
       
  1689     // 2. 3AM timer is going on.
       
  1690     // 3. Tagging is in progress.
       
  1691     if ( !iSessionCount 
       
  1692 #if defined(LOC_REVERSEGEOCODE) || defined(LOC_GEOTAGGING_CELLID)
       
  1693         && iGeoTagTimer == NULL
       
  1694 #endif        
       
  1695         && iLocationRecord 
       
  1696         && !iLocationRecord->TaggingInProgress())
       
  1697         {
       
  1698         // Nothing in progress. shutdown the server
       
  1699         LOG("Stop the schedular");
       
  1700         CActiveScheduler::Stop();
       
  1701         }
       
  1702 	LOG("CLocationManagerServer::StopServer ,end");
       
  1703     }
       
  1704 
       
  1705 // --------------------------------------------------------------------------
       
  1706 // CLocationManagerServer::PendingGeoTagReqComplete
       
  1707 // --------------------------------------------------------------------------
       
  1708 //
       
  1709 void CLocationManagerServer::PendingGeoTagReqComplete(  const TInt aError  )
       
  1710     {
       
  1711     LOG("CLocationManagerServer::PendingGeoTagReqComplete ,begin");
       
  1712     ARG_USED(aError);
       
  1713 #ifdef LOC_REVERSEGEOCODE
       
  1714     if(!iTagPendingMessage.IsNull())
       
  1715     	{
       
  1716        
       
  1717 	    TGeoTaggingSatus pendingGeoTagEntry = EGeoTagCmpt;
       
  1718         switch(aError)
       
  1719             {
       
  1720             case KErrNotFound:
       
  1721                 pendingGeoTagEntry = EGeoTaggingPending;
       
  1722                 LOG("Geo tagging pending");
       
  1723                 break;
       
  1724             case KErrInUse:
       
  1725                 pendingGeoTagEntry = EGeoTaggingGoingOn;
       
  1726                 LOG("Geo tagging going on");
       
  1727                 break;
       
  1728             default:
       
  1729                 break;
       
  1730             }
       
  1731                     
       
  1732 	    TPckg<TGeoTaggingSatus> pendingGeoTagEntryPkg( pendingGeoTagEntry );    
       
  1733 	    TRAPD(err, iTagPendingMessage.WriteL( 0, pendingGeoTagEntryPkg ));
       
  1734 	    iTagPendingMessage.Complete((err == KErrNone) ? KErrNone : err);
       
  1735 	    iTagPendingMessage = RMessage2 ();
       
  1736     	}
       
  1737 #endif //LOC_REVERSEGEOCODE
       
  1738 	LOG("CLocationManagerServer::PendingGeoTagReqComplete ,end");
       
  1739     }
       
  1740 
       
  1741 
       
  1742 // --------------------------------------------------------------------------
       
  1743 // CLocationManagerServer::TagPendingRequestL
       
  1744 // --------------------------------------------------------------------------
       
  1745 //
       
  1746 void CLocationManagerServer::TagPendingRequestL( const RMessage2& aMessage )
       
  1747     {    
       
  1748     LOG("CLocationManagerServer::TagPendingRequestL ,begin");
       
  1749     // Only one request at a time
       
  1750 #ifdef LOC_REVERSEGEOCODE
       
  1751     if(iTagPendingMessage.IsNull() && iGeoTaggingMessage.IsNull())
       
  1752         {
       
  1753         iTagPendingMessage = RMessage2( aMessage );
       
  1754         // search for pending entry.
       
  1755         //Create the instance of geotagger class
       
  1756         TBool tagProgress = iLocationRecord->TaggingInProgress();
       
  1757         if(tagProgress)
       
  1758             {
       
  1759             LOG("Tagging is going on.\n");
       
  1760             // Let UI to send start geo tagging command.
       
  1761             PendingGeoTagReqComplete(KErrNotFound);
       
  1762             }
       
  1763         else
       
  1764             {
       
  1765             LOG("Tagging is not going on.\n");
       
  1766             if(iGeoTaggingPendingReqObj == NULL)
       
  1767                 {
       
  1768                 iGeoTaggingPendingReqObj = CGeoTagger::NewL( this, NULL );
       
  1769                 }
       
  1770             iGeoTaggingPendingReqObj->PendingGeoTagsL( tagProgress);
       
  1771     		}
       
  1772         }
       
  1773     else
       
  1774         {
       
  1775 		LOG("Server busy\n");
       
  1776         aMessage.Complete(KErrServerBusy);
       
  1777         }
       
  1778 #else
       
  1779     aMessage.Complete(KErrNotSupported);
       
  1780 #endif //LOC_REVERSEGEOCODE
       
  1781 	LOG("CLocationManagerServer::TagPendingRequestL ,end");
       
  1782     }
       
  1783 
       
  1784 
       
  1785 
       
  1786 // --------------------------------------------------------------------------
       
  1787 // CLocationManagerServer::CancelTagPendingRequest
       
  1788 // --------------------------------------------------------------------------
       
  1789 //
       
  1790 void CLocationManagerServer::CancelTagPendingRequest( const RMessage2& aMessage )
       
  1791     {    
       
  1792     LOG("CLocationManagerServer::CancelTagPendingRequest ,begin");
       
  1793     // Only one request at a time
       
  1794 #ifdef LOC_REVERSEGEOCODE
       
  1795     if(!iTagPendingMessage.IsNull())
       
  1796         {
       
  1797         iTagPendingMessage.Complete(KErrCancel);
       
  1798         iLocationRecord->CancelGeoTagging();
       
  1799         }
       
  1800     aMessage.Complete(KErrNone);
       
  1801 #else
       
  1802     aMessage.Complete(KErrNotSupported);
       
  1803 #endif //LOC_REVERSEGEOCODE
       
  1804     }
       
  1805 
       
  1806 
       
  1807 // --------------------------------------------------------------------------
       
  1808 // CLocationManagerServer::CancelGeoTaggingRequest
       
  1809 // --------------------------------------------------------------------------
       
  1810 //
       
  1811 void CLocationManagerServer::CancelGeoTaggingRequest( const RMessage2& aMessage )
       
  1812     {    
       
  1813     LOG("CLocationManagerServer::CancelGeoTaggingRequest ,begin");
       
  1814     // Only one request at a time
       
  1815 #ifdef LOC_REVERSEGEOCODE
       
  1816     if(!iGeoTaggingMessage.IsNull())
       
  1817         {
       
  1818         iGeoTaggingMessage.Complete(KErrCancel);
       
  1819         iGeoTaggingMessage = RMessage2 ();
       
  1820         iLocationRecord->CancelGeoTagging();
       
  1821         }
       
  1822     aMessage.Complete(KErrNone);
       
  1823 #else
       
  1824     aMessage.Complete(KErrNotSupported);
       
  1825 #endif //LOC_REVERSEGEOCODE
       
  1826     }
       
  1827 
       
  1828 
       
  1829 // --------------------------------------------------------------------------
       
  1830 // CLocationManagerServer::StartGeoTaggingL
       
  1831 // --------------------------------------------------------------------------
       
  1832 //
       
  1833 void CLocationManagerServer::StartGeoTaggingL( const RMessage2& aMessage )
       
  1834     {
       
  1835     LOG("CLocationManagerServer::StartGeoTaggingL ,begin");
       
  1836 #ifdef LOC_REVERSEGEOCODE
       
  1837     if(iGeoTaggingMessage.IsNull() && iTagPendingMessage.IsNull())
       
  1838         {
       
  1839         iGeoTaggingMessage = RMessage2( aMessage );
       
  1840         // search for pending entry.
       
  1841         //Create the instance of geotagger class
       
  1842         if(!iLocationRecord->StartGeoTagging(EInteractive))
       
  1843             {
       
  1844             if(iGeoTaggingPendingReqObj == NULL)
       
  1845                 {
       
  1846                 iGeoTaggingPendingReqObj = CGeoTagger::NewL( this, NULL );
       
  1847                 }
       
  1848     		iGeoTaggingPendingReqObj->CreateGeoTagsL((TConnectionOption)(aMessage.Int0()));
       
  1849     		}
       
  1850         }
       
  1851     else
       
  1852         {
       
  1853 		LOG("Server busy\n");
       
  1854         aMessage.Complete(KErrServerBusy);
       
  1855         }
       
  1856 #else
       
  1857     aMessage.Complete(KErrNotSupported);
       
  1858 #endif //LOC_REVERSEGEOCODE
       
  1859     }
       
  1860 
       
  1861 
       
  1862 // ----------------------------------------------------------------------------
       
  1863 // CLocationManagerServer::GetCurrentRegisterNw()
       
  1864 // ---------------------------------------------------------------------------- 
       
  1865 RMobilePhone::TMobilePhoneNetworkInfoV2& CLocationManagerServer::GetCurrentRegisterNw()
       
  1866     {
       
  1867     LOG( "CLocationManagerServer::GetCurrentRegisterNw ,begin" );
       
  1868     return iLocationRecord->GetCurrentRegisteredNw();
       
  1869     }
       
  1870 
       
  1871 // ----------------------------------------------------------------------------
       
  1872 // CLocationManagerServer::RetrieveHomeNetwork()
       
  1873 // ----------------------------------------------------------------------------
       
  1874 void CLocationManagerServer::RetrieveHomeNetwork()
       
  1875     {
       
  1876     LOG("CLocationManagerServer::RetrieveHomeNetwork ,begin");
       
  1877     if(iHomeNwInfoAvailableFlag)
       
  1878         {
       
  1879         RMobilePhone::TMobilePhoneNetworkInfoV1Pckg homeNetworkPckg( iHomeNetwork );
       
  1880         
       
  1881         TRequestStatus status( KErrNone );
       
  1882         
       
  1883         iPhone.GetHomeNetwork(status, homeNetworkPckg);
       
  1884         User::WaitForRequest( status );
       
  1885         if(status.Int() == KErrNone)
       
  1886             {
       
  1887             iHomeNwInfoAvailableFlag = ETrue;
       
  1888             }
       
  1889         }
       
  1890 	LOG("CLocationManagerServer::RetrieveHomeNetwork ,end");
       
  1891     }
       
  1892 
       
  1893 // ----------------------------------------------------------------------------
       
  1894 // CLocationManagerServer::GetHomeNetworkInfo()
       
  1895 // ----------------------------------------------------------------------------
       
  1896 const RMobilePhone::TMobilePhoneNetworkInfoV1& 
       
  1897         CLocationManagerServer::GetHomeNetworkInfo(TBool& aHomeNwInfoAvailableFlag)
       
  1898     {
       
  1899     LOG("CLocationManagerServer::RetrieveHomeNetwork ,begin");
       
  1900     if(!iHomeNwInfoAvailableFlag)
       
  1901         {
       
  1902         RetrieveHomeNetwork();
       
  1903         }
       
  1904     aHomeNwInfoAvailableFlag = iHomeNwInfoAvailableFlag;
       
  1905     return iHomeNetwork;
       
  1906     }
       
  1907 
       
  1908 
       
  1909 // ----------------------------------------------------------------------------
       
  1910 // CLocationManagerServer::IsRegisteredAtHomeNetwork()
       
  1911 // ---------------------------------------------------------------------------- 
       
  1912 TBool CLocationManagerServer::IsRegisteredAtHomeNetwork()
       
  1913     {
       
  1914     LOG( "CLocationManagerServer::IsRegisteredAtHomeNetwork" );
       
  1915     return (iNwRegistrationStatusHandler &&
       
  1916             (iNwRegistrationStatusHandler->GetNetworkRegistrationStatus() 
       
  1917                 == RMobilePhone::ERegisteredOnHomeNetwork));
       
  1918     }
       
  1919 
       
  1920 // End of file 
  1308 // End of file