locationmanager/server/src/clocationmanagerserver.cpp
branchRCL_3
changeset 63 e538444823de
parent 47 b73252188534
--- a/locationmanager/server/src/clocationmanagerserver.cpp	Wed Sep 15 12:40:59 2010 +0300
+++ b/locationmanager/server/src/clocationmanagerserver.cpp	Wed Oct 13 15:02:02 2010 +0300
@@ -17,10 +17,6 @@
 
 #include <e32debug.h>
 #include <w32std.h>
-#include <ecom.h>
-#include <commsdattypesv1_1.h>
-#include <cdblen.h>
-#include <commsdat_partner.h>
 
 #include "clocationmanagerserver.h"
 #include "clocationmanagersession.h"
@@ -33,12 +29,8 @@
 #include "mdeobjectdef.h"
 #include "mdepropertydef.h"
 #include "mdcserializationbuffer.h"
-#include "clocationgeotagtimerao.h"
-#include "nwregistrationstatushandler.h"
 
 using namespace MdeConstants;
-using namespace CommsDat;
-
 
 // --------------------------------------------------------------------------
 // RunServerL
@@ -76,7 +68,6 @@
         {
         TRAP( ret, RunServerL() );
         delete cleanup;
-        cleanup = NULL;
         }
     return ret;
     }
@@ -100,10 +91,9 @@
 // --------------------------------------------------------------------------
 //
 CLocationManagerServer::CLocationManagerServer() 
-    : CPolicyServer( KLocManagerSessionPriority, 
+    : CPolicyServer( CActive::EPriorityStandard, 
                      KLocationManagerPolicy, 
                      ESharableSessions ),
-                     iASW(NULL),
                      iTimer( NULL ),
 			         iSessionReady( EFalse ),
                      iTagId( 0 ),
@@ -111,16 +101,7 @@
                      iLocManStopRemapDelay( 0 ),
                      iCaptureSetting( RLocationTrail::EOff ),
                      iRemoveLocation( EFalse ),
-                     iWaitForPositioningStopTimeout ( EFalse ),
-                     iTelServerIsOpen(EFalse),
-                     iPhoneIsOpen(EFalse),
-                     iNwRegistrationStatusHandler(NULL),
-                     iHomeNwInfoAvailableFlag(EFalse),
-                     iGeoTagTimer(NULL)
-#ifdef LOC_REVERSEGEOCODE
-					 ,iGeoTaggingPendingReqObj(NULL)
-					 ,iEcomSession(NULL)
-#endif //LOC_REVERSEGEOCODE
+                     iWaitForPositioningStopTimeout ( EFalse )
     {
     }
 
@@ -134,22 +115,18 @@
     LOG ("CLocationManagerServer::ConstructL() begin");
     
     StartL( KLocServerName );
-
-    // initialize etel
-    InitialisePhoneL();
+    
+    RProcess process;
+    process.SetPriority( EPriorityBackground );
+    process.Close();
     
-#ifdef LOC_REVERSEGEOCODE
-    iEcomSession = &(REComSession::OpenL());
-#endif //LOC_REVERSEGEOCODE
-
     iASW = new (ELeave) CActiveSchedulerWait();
+    iMdeSession = CMdESession::NewL( *this );
+    iLocationRecord = CLocationRecord::NewL();
+    iTrackLog = CTrackLog::NewL();
     
-    iNwRegistrationStatusHandler = CNwRegistrationStatusHandler::NewL(iPhone);
+    iASW->Start();
     
-    iLocationRecord = CLocationRecord::NewL(*this, iPhone);
-    iTrackLog = CTrackLog::NewL();
-    iMdeSession = CMdESession::NewL( *this );   
-
     iLocationRecord->SetObserver( this );
     
     iLocationRecord->SetAddObserver( iTrackLog );
@@ -157,55 +134,34 @@
     iTrackLog->AddGpxObserver( this );
     
     CRepository* repository = CRepository::NewLC( KRepositoryUid );
-    TInt err = repository->Get( KLocationTrailShutdownTimer, iLocManStopDelay );
-    
-    LOG1("iLocManStopDelay:%d", iLocManStopDelay);
+	TInt err = repository->Get( KLocationTrailShutdownTimer, iLocManStopDelay );
+	
+    LOG1("CLocationManagerServer::ConstructL, iLocManStopDelay:%d", iLocManStopDelay);
     
     if ( err != KErrNone )
-        {
-        LOG1("iLocManStopDelay err:%d", err);
+    	{
+        LOG1("CLocationManagerServer::ConstructL, iLocManStopDelay err:%d", err);
         iLocManStopDelay = KLocationTrailShutdownDelay;
-        }
+    	}
 
     err = repository->Get( KLocationTrailRemapShutdownTimer, iLocManStopRemapDelay );
     CleanupStack::PopAndDestroy( repository );
     
-    LOG1("iLocManStopRemapDelay:%d", iLocManStopRemapDelay);
+    LOG1("CLocationManagerServer::ConstructL, iLocManStopRemapDelay:%d", iLocManStopRemapDelay);
     
     if ( err != KErrNone )
         {
-        LOG1("iLocManStopRemapDelay err:%d", err);
+        LOG1("CLocationManagerServer::ConstructL, iLocManStopRemapDelay err:%d", err);
         iLocManStopRemapDelay = KLocationTrailRemapShutdownDelay;
         }
-
-    if( !iSessionReady )
-        {
-        iASW->Start();      
-        }
-
-    delete iASW;
-    iASW = NULL;   
-
-    if( iSessionReady )
+    
+    TRAPD( error, iTimer = CPeriodic::NewL( CActive::EPriorityUserInput ) );    
+    if ( error != KErrNone )
         {
-        LOG("Session is ready to give service");
-        //Create the instance of the geotagging timer object
-        // Create timer, if n/w or reverse geo code based feature flag is enabled
-#if defined(LOC_REVERSEGEOCODE) || defined(LOC_GEOTAGGING_CELLID)
-        iGeoTagTimer = CLocationGeoTagTimerAO::NewL(*iMdeSession, *this);
-        //Schedule a task for geotagging every day at 3.00 AM
-        iGeoTagTimer->StartTimer();
-#endif        
-        }
-    else
-        {
-        LOG("Unable to open MDE session. Closing..");
-        User::Leave( KErrCouldNotConnect );
-        }
-        
-    RProcess process;
-    process.SetPriority( EPriorityBackground );
-    process.Close();
+        LOG("CLocationManagerServer::ConstructL - iTimer not created");
+        iTimer = NULL;
+        }  
+    
     
     LOG ("CLocationManagerServer::ConstructL() end");
     }
@@ -217,30 +173,13 @@
 //
 CLocationManagerServer::~CLocationManagerServer()
     {
-	LOG("CLocationManagerServer::~CLocationManagerServer ,begin");
-#if defined(LOC_REVERSEGEOCODE) || defined(LOC_GEOTAGGING_CELLID)
-    delete iGeoTagTimer;
-    iGeoTagTimer = NULL;
-#endif    
-#ifdef LOC_REVERSEGEOCODE
-    delete iGeoTaggingPendingReqObj;
-    iGeoTaggingPendingReqObj = NULL;
-#endif //LOC_REVERSEGEOCODE
+    delete iLocationRecord;    
+    delete iTrackLog;    
+    delete iTimer;
+    //delete iRelationQuery;
+    delete iASW;
+    delete iMdeSession;
     
-    delete iLocationRecord;    
-    iLocationRecord = NULL;
-    delete iTrackLog;    
-    iTrackLog = NULL;
-    delete iTimer;
-    iTimer = NULL;
-    delete iRelationQuery;
-    iRelationQuery = NULL;
-    delete iASW;
-    iASW = NULL;
-    delete iMdeSession;
-    iMdeSession = NULL;
-    delete iNwRegistrationStatusHandler;
-    iNwRegistrationStatusHandler = NULL;
     iTargetObjectIds.Close();
     CancelRequests(iNotifReqs);
     iNotifReqs.Close();
@@ -251,115 +190,9 @@
     CancelCopyRequests(iCopyReqs);
     iCopyReqs.Close();
     iSessionCount = 0;
-	if(iPhoneIsOpen)
-        {   
-        iPhoneIsOpen = EFalse; // not required
-        iPhone.Close();
-        }
-    if(iTelServerIsOpen)
-        {
-        iTelServerIsOpen = EFalse;
-        iTelServer.Close();
-        }
-#ifdef LOC_REVERSEGEOCODE
-	if(iEcomSession)
-        {
-        iEcomSession->Close();
-        }
-#endif //LOC_REVERSEGEOCODE
-	LOG("CLocationManagerServer::~CLocationManagerServer ,end");
     }
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::GetCommDbTSYnameL
-// --------------------------------------------------------------------------
-//    
-void CLocationManagerServer::GetCommDbTSYnameL(TDes& aTsyName)
-	{
-    LOG( "CLocationManagerServer::GetCommDbTSYnameL(), begin" );
-#ifdef SYMBIAN_NON_SEAMLESS_NETWORK_BEARER_MOBILITY
-	CMDBSession* db = CMDBSession::NewL(KCDVersion1_2);
-#else
-	CMDBSession* db = CMDBSession::NewL(KCDVersion1_1);
-#endif
-	CleanupStack::PushL(db);
-
-	CMDBField<TDesC>* globalSettingField = new(ELeave) CMDBField<TDesC>(KCDTIdBearerAvailabilityCheckTSY);
-	CleanupStack::PushL(globalSettingField);
-	globalSettingField->SetRecordId(1);
-	globalSettingField->SetMaxLengthL(KMaxTextLength);
-	globalSettingField->LoadL(*db);
-	aTsyName = *globalSettingField;
-	CleanupStack::PopAndDestroy(globalSettingField);
-
-	CleanupStack::PopAndDestroy(db);
-    LOG( "CLocationManagerServer::GetCommDbTSYnameL(), end" );
-	}
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::InitialisePhoneL
 // --------------------------------------------------------------------------
-//    
-void CLocationManagerServer::InitialisePhoneL()
-	{
-    LOG( "CLocationManagerServer::InitialisePhoneL(), begin" );
-	User::LeaveIfError(iTelServer.Connect());
-	iTelServerIsOpen = ETrue;
-	TBuf<KCommsDbSvrMaxFieldLength> tsyName;
-	GetCommDbTSYnameL(tsyName);
-
-	User::LeaveIfError(iTelServer.LoadPhoneModule(tsyName));
-
-	TInt numPhones;
-	User::LeaveIfError(iTelServer.EnumeratePhones(numPhones));
-
-	TInt phoneIndx;
-	TInt ret = KErrHardwareNotAvailable;
-
-	for(phoneIndx=0; phoneIndx<numPhones; phoneIndx++)
-		{
-		RTelServer::TPhoneInfo tInfo;
-		ret = iTelServer.GetPhoneInfo(phoneIndx, tInfo);
-		if(ret != KErrNone)
-			{
-			continue;
-			}
-		
-		ret = iPhone.Open(iTelServer, tInfo.iName);	
-		if(ret != KErrNone)
-			{
-			continue;
-			}
-
-		iPhoneIsOpen = ETrue;
-
-		RPhone::TStatus status;
-		User::LeaveIfError(iPhone.GetStatus(status));
-		if(status.iModemDetected!=RPhone::EDetectedPresent)
-			{
-			ret = iPhone.Initialise();
-			if(ret != KErrNone)
-				{
-				iPhone.Close();
-				iPhoneIsOpen = EFalse;
-				continue;
-				}
-			}
-        // we found the correct phone
-        break;
-		}
-
-	//
-	// ret will be KErrNone if a valid phone was found...
-	//
-	
-    LOG1( "CLocationManagerServer::InitialisePhoneL(), end. Err - %d", ret );
-	User::LeaveIfError(ret);
-	}
-
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::CancelRequests()
+// CLocationManagerServer::CompleteRequests()
 // --------------------------------------------------------------------------
 //
 void CLocationManagerServer::CancelRequests(RArray<RMessage2>& aMessageList)
@@ -378,10 +211,6 @@
     aMessageList.Reset();
 	}
 
-// --------------------------------------------------------------------------
-// CLocationManagerServer::CancelCopyRequests
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::CancelCopyRequests(RArray<TMessageQuery>& aMessageList)
 	{
 	const TInt count = aMessageList.Count();
@@ -398,14 +227,10 @@
     aMessageList.Reset();
 	}
 
-// --------------------------------------------------------------------------
-// CLocationManagerServer::HandleSessionOpened
-// --------------------------------------------------------------------------
-//
+
 void CLocationManagerServer::HandleSessionOpened(CMdESession& /*aSession*/, TInt aError)
 	{
-	LOG ("CLocationManagerServer::HandleSessionOpened() start");
-	if ( iASW && iASW->IsStarted() )
+	if ( iASW->IsStarted() )
 		{
 		iASW->AsyncStop();
 		}
@@ -424,31 +249,18 @@
 		}
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::HandleSessionError
-// --------------------------------------------------------------------------
-//
-void CLocationManagerServer::HandleSessionError(CMdESession& /*aSession*/, TInt aError)
+void CLocationManagerServer::HandleSessionError(CMdESession& /*aSession*/, TInt /*aError*/)
 	{
-	LOG1 ("CLocationManagerServer::HandleSessionError() start, Error - %d", aError);
-    ARG_USED(aError);
 	iSessionReady = EFalse;
 	delete iMdeSession;
 	iMdeSession = NULL;
 
-	if ( iASW && iASW->IsStarted() )
+	if ( iASW->IsStarted() )
 		{
 		iASW->AsyncStop();
 		}	
 	}
 
-
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::IsSessionReady
-// --------------------------------------------------------------------------
-//
 TBool CLocationManagerServer::IsSessionReady()
 	{
 	return iSessionReady;
@@ -490,9 +302,11 @@
 //    
 void CLocationManagerServer::RemoveSession()
     {
-    LOG1( "CLocationManagerServer::RemoveSession. Session count - %d", iSessionCount);
     iSessionCount--;
-    StopServer();
+    if ( !iSessionCount )
+        {
+        CActiveScheduler::Stop();
+        }
     }    
 
 // --------------------------------------------------------------------------
@@ -520,8 +334,7 @@
     
     if ( iTimer )
     	{
-    	delete iTimer;
-    	iTimer = NULL;
+    	iTimer->Cancel();
     	}
     
     iLocationRecord->StartL( aCaptureSetting );
@@ -542,19 +355,24 @@
      
     if( state != RLocationTrail::ETrailStopped && state != RLocationTrail::ETrailStopping )
         {
-        if(iTimer == NULL)
+        if(!iTimer)
             {
-            TRAP_IGNORE(iTimer = CLocationServerTimerHandler::NewL(*this));
+            TRAPD( error, iTimer = CPeriodic::NewL( CActive::EPriorityUserInput ) );    
+            if ( error != KErrNone )
+                {
+                LOG("CLocationManagerServer::StopGPSPositioningL() - iTimer not created");
+                iTimer = NULL;
+                }
+            }        
+        if(iTimer)
+            {
+			iTimer->Cancel();
+            iLocationRecord->SetStateToStopping();
+            iTimer->Start( iLocManStopDelay * 1000000, 0, TCallBack( CheckForRemappingCallback, this ) );
             }
-        if ( iTimer == NULL)
-            {
-            // If timer can't be created we stop the location trail immediately.
-            iLocationRecord->Stop();
-            }   
         else
             {
-            iLocationRecord->SetStateToStopping();
-            iTimer->StartTimer( iLocManStopDelay * 1000000, MLocationServerTimerObserver::EStopRecording);
+            iLocationRecord->Stop();
             }
         }
     
@@ -571,61 +389,48 @@
     LOG( "CLocationManagerServer::StopRecording()" );    
     iWaitForPositioningStopTimeout = EFalse;
     iLocationRecord->Stop();		
-	}
-
-// --------------------------------------------------------------------------
-// CLocationUtilityServer::LocationServerTimerCallBackL
-// --------------------------------------------------------------------------
-//
-void CLocationManagerServer::LocationServerTimerCallBackL
-    (const TLocationServerTimerType aLocationServerTimerType, const TInt /*aErrorCode*/)
-	{
-    LOG1( "CLocationManagerServer::LocationServerTimerCallBackL, begin, Type - %d",
-                aLocationServerTimerType);
-	switch(aLocationServerTimerType)
-        {
-        case MLocationServerTimerObserver::EStopRecording:
-            CheckForRemappingCallback();
-            break;
-        case MLocationServerTimerObserver::EPositioningStopTimeout:
-            PositioningStopTimeout();
-            break;
-        case MLocationServerTimerObserver::ELocGeneralPurpose:
-        default:
-            // execution shouldn't come over here.
-            LOG("Invalid timer type");
-            break;
-        }
-    LOG( "CLocationManagerServer::LocationServerTimerCallBackL, end" );
+	if(iTimer)
+	    {
+        iTimer->Cancel();
+	    }
+	
 	}
 
 // --------------------------------------------------------------------------
 // CLocationUtilityServer::PositioningStopTimeout
 // --------------------------------------------------------------------------
 //
-void CLocationManagerServer::PositioningStopTimeout()
+TInt CLocationManagerServer::PositioningStopTimeout( TAny* aAny )
 	{
     LOG( "CLocationManagerServer::PositioningStopTimeout" );
-	StopRecording();
+	CLocationManagerServer* self = STATIC_CAST( CLocationManagerServer*, aAny );
+	self->StopRecording();
+	
+	return KErrNone;
 	}
 
 // --------------------------------------------------------------------------
-// CLocationUtilityServer::CheckForRemappingCallback
+// CLocationUtilityServer::PositioningStopTimeout
 // --------------------------------------------------------------------------
 //
-void CLocationManagerServer::CheckForRemappingCallback()
+TInt CLocationManagerServer::CheckForRemappingCallback( TAny* aAny )
     {
-    LOG( "CLocationManagerServer::CheckForRemappingCallback, begin" );
-    if ( iLocationRecord->RemappingNeeded() && !iLocationRecord->IsLowBattery())
+    LOG( "CLocationManagerServer::CheckForRemappingCallback" );
+    CLocationManagerServer* self = STATIC_CAST( CLocationManagerServer*, aAny );
+
+    self->iTimer->Cancel();    
+    
+    if ( self->iLocationRecord->RemappingNeeded() && !self->iLocationRecord->IsLowBattery())
         {     
-        iTimer->StartTimer( iLocManStopRemapDelay * 1000000, MLocationServerTimerObserver::EPositioningStopTimeout);
-        iWaitForPositioningStopTimeout = ETrue;
+        self->iTimer->Start( self->iLocManStopRemapDelay * 1000000, 0, TCallBack( PositioningStopTimeout, self ) );
+        self->iWaitForPositioningStopTimeout = ETrue;
         }
     else
         {        
-        StopRecording();
+        self->StopRecording();
         }
-    LOG( "CLocationManagerServer::CheckForRemappingCallback, end" );
+    
+    return KErrNone;
     }
 
 // --------------------------------------------------------------------------
@@ -743,7 +548,7 @@
     }
 
 // --------------------------------------------------------------------------
-// CLocationManagerServer::GetCurrentNetworkInfo
+// CLocationManagerServer::GetCurrentCellId
 // --------------------------------------------------------------------------
 //    
 void CLocationManagerServer::GetCurrentNetworkInfo( CTelephony::TNetworkInfoV1& aNetworkInfo )
@@ -825,11 +630,6 @@
     LOG( "CLocationManagerServer::CurrentLocation(), end" );    
     }
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::GPSSignalQualityChanged
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::GPSSignalQualityChanged( const TPositionSatelliteInfo& aSatelliteInfo )
 	{
 	LOG( "CLocationManagerServer::GPSSignalQualityChanged" );
@@ -877,10 +677,7 @@
 	}
 
 
-// --------------------------------------------------------------------------
-// CLocationManagerServer::CancelTrackLogNotificationRequest
-// --------------------------------------------------------------------------
-//
+
 void CLocationManagerServer::CancelTrackLogNotificationRequest( const TInt aHandle )
 	{
 	LOG( "CLocationManagerServer::CancelTrackLogNotificationRequest(), begin" );
@@ -907,11 +704,6 @@
     LOG( "CLocationManagerServer::CancelTrackLogNotificationRequest(), end" );
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::CreateLocationObjectL
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::CreateLocationObjectL( const TLocationData& aLocationData,
 													const TUint& aObjectId )
 	{
@@ -923,21 +715,13 @@
 	iLocationRecord->CreateLocationObjectL( aLocationData, aObjectId );
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::LocationSnapshotL
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::LocationSnapshotL( const TUint& aObjectId )
 	{
-    LOG( "CLocationManagerServer::LocationSnapshotL(), begin" );
 	if ( !IsSessionReady() )
 		{
-        LOG( "Session is not ready" );
 		User::Leave( KErrNotReady );
 		}
 	iLocationRecord->LocationSnapshotL( aObjectId );
-    LOG( "CLocationManagerServer::LocationSnapshotL(), end" );
 	}
 
 // --------------------------------------------------------------------------
@@ -973,11 +757,6 @@
     iRelationQuery->FindL( 1, 1 );
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::CopyLocationObjectL
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::CopyLocationObjectL( TItemId aSource, 
 		const RArray<TItemId>& aTargets, TMessageQuery& aMessageQuery )
 	{
@@ -1039,11 +818,6 @@
     	}
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::CopyLocationObjectL
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::CopyLocationObjectL( const TDesC& aSource, 
 		const RArray<TPtrC>& aTargets, TMessageQuery& aQuery )
 	{
@@ -1065,24 +839,13 @@
 	CopyLocationObjectL( source, iTargetObjectIds, aQuery );
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::HandleQueryNewResults
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::HandleQueryNewResults( CMdEQuery& /*aQuery*/, 
 		TInt /*aFirstNewItemIndex*/, TInt /*aNewItemCount*/ )
 	{
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::HandleQueryCompleted
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::HandleQueryCompleted( CMdEQuery& aQuery, TInt aError )
 	{	
-	LOG("CLocationManagerServer::HandleQueryCompleted");
 	if ( iRemoveLocation )
 		{
 		if( aQuery.Count() > 0 && aError == KErrNone )
@@ -1116,7 +879,6 @@
 						}
 					iCopyReqs[i].iMessage.Complete( aError );
 					delete iCopyReqs[i].iQuery;
-					iCopyReqs[i].iQuery = NULL;
 					iCopyReqs.Remove( i );
 					break;
 					}
@@ -1127,11 +889,6 @@
 	iTargetObjectIds.Reset();
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::NewLC
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::CopyLocationL( CMdEQuery& aQuery )
 	{
 	CMdEObjectDef& locationDef = aQuery.NamespaceDef().GetObjectDefL( Location::KLocationObject );
@@ -1163,18 +920,12 @@
     		{
     		iCopyReqs[i].iMessage.Complete( KErrNone );
     		delete iCopyReqs[i].iQuery;
-    		iCopyReqs[i].iQuery = NULL;
     		iCopyReqs.Remove( i );
     		break;
     		}
     	}
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::InitCopyLocationByIdL
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::InitCopyLocationByIdL( const RMessage2& aMessage )
 	{
 	const TInt KParamSourceId = 0;
@@ -1208,11 +959,6 @@
 	CleanupStack::PopAndDestroy(&targetIds);
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::InitCopyLocationByURIL
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::InitCopyLocationByURIL( const RMessage2& aMessage )
 	{
     LOG( "CLocationManagerSession::CopyLocationDataByUriL begin" );
@@ -1262,14 +1008,8 @@
     LOG( "CLocationManagerSession::CopyLocationDataByUriL end" );
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::StartTrackLogL
-// --------------------------------------------------------------------------
-//
 TItemId CLocationManagerServer::StartTrackLogL()
 	{
-	LOG("CLocationManagerServer::StartTrackLogL");
 	if ( iTrackLog->IsRecording() )
 		{
 		User::Leave( KErrInUse );
@@ -1286,14 +1026,8 @@
 	return iTagId;
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::StopTrackLogL
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::StopTrackLogL()
 	{
-	LOG("CLocationManagerServer::StopTrackLogL");
 	if ( iTrackLog->IsRecording() )
 		{
 		iTrackLog->StopRecordingL();
@@ -1306,14 +1040,8 @@
 		}
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::CompleteNotifyRequest
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::CompleteNotifyRequest( TEventTypes aEventType, TInt aError )
 	{
-	LOG("CLocationManagerServer::CompleteNotifyRequest");
 	const TInt KEventTypeParam = 2;
 	TPckg<TEventTypes> wrapEventType( aEventType );
 	
@@ -1331,35 +1059,19 @@
 	iTrackLogNotifyReqs.Reset();
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::IsTrackLogRecording
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::IsTrackLogRecording( TBool &aRec )
 	{
 	aRec = iTrackLog->IsRecording();
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::GpxFileCreated
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::GpxFileCreated( const TDesC& aFileName, TItemId aTagId,
 		TReal32 aLength, TTime aStart, TTime aEnd )
 	{
 	TRAP_IGNORE( CreateTrackLogL( aTagId, aFileName, aLength, aStart, aEnd ) );
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::CreateTrackLogTagL
-// --------------------------------------------------------------------------
-//
 TItemId CLocationManagerServer::CreateTrackLogTagL()
 	{
-	LOG("CLocationManagerServer::CreateTrackLogTagL");
 	if ( !IsSessionReady() )
 		{
 		User::Leave( KErrNotReady );
@@ -1392,15 +1104,9 @@
 	return tagId;
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::CreateTrackLogL
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::CreateTrackLogL( TItemId aTagId, const TDesC& aUri, TReal32 aLength,
 		TTime aStart, TTime aEnd )
 	{
-	LOG("CLocationManagerServer::CreateTrackLogL");
 	if ( !IsSessionReady() )
 		{
 		User::Leave( KErrNotReady );
@@ -1447,11 +1153,6 @@
     CleanupStack::PopAndDestroy( trackLog );
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::GetTrackLogStatus
-// --------------------------------------------------------------------------
-//
 TInt CLocationManagerServer::GetTrackLogStatus( TBool& aRecording, TPositionSatelliteInfo& aFixQuality)
 	{
 	if ( !iTrackLog )
@@ -1464,11 +1165,6 @@
 	return KErrNone;
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::DeleteTrackLogL
-// --------------------------------------------------------------------------
-//
 TInt CLocationManagerServer::DeleteTrackLogL( const TDesC& aUri )
 	{
     LOG( "CLocationManagerServer::DeleteTrackLogL enter" );
@@ -1509,11 +1205,6 @@
     return err;
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::TrackLogName
-// --------------------------------------------------------------------------
-//
 TInt CLocationManagerServer::TrackLogName( TFileName& aFileName )
 	{
 	if ( iTrackLog->IsRecording() )
@@ -1524,21 +1215,11 @@
 	return KErrNotFound;
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::GetCaptureSetting
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::GetCaptureSetting( RLocationTrail::TTrailCaptureSetting& aCaptureSetting )
 	{
 	aCaptureSetting = iCaptureSetting;
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::HandleObjectNotification
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::HandleObjectNotification( CMdESession& /*aSession*/,
 		TObserverNotificationType aType,
 		const RArray<TItemId>& aObjectIdArray )
@@ -1553,11 +1234,6 @@
 	TRAP_IGNORE( LinkObjectToTrackLogTagL( aObjectIdArray ) );
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::StartListeningTagRemovalsL
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::StartListeningTagRemovalsL()
 	{
 	if ( !IsSessionReady() )
@@ -1573,11 +1249,6 @@
     CleanupStack::Pop( condition );
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::StartListeningObjectCreationsL
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::StartListeningObjectCreationsL()
 	{
 	if ( !IsSessionReady() )
@@ -1600,11 +1271,6 @@
 	
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::LinkObjectToTrackLogTagL
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::LinkObjectToTrackLogTagL( const RArray<TItemId>& aObjectIdArray )
 	{
 	CMdERelationDef& containsRelDef = iMdeSession->GetDefaultNamespaceDefL()
@@ -1622,299 +1288,21 @@
 		}
 	}
 
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::AddGpxObserver
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::AddGpxObserver( MGpxConversionObserver* aObserver )
 	{
 	iTrackLog->AddGpxObserver( aObserver );
 	}
 
-// --------------------------------------------------------------------------
-// CLocationManagerServer::RemapedCompleted()
-// --------------------------------------------------------------------------
-//
 void CLocationManagerServer::RemapedCompleted()
     {
     LOG( "CLocationManagerServer::RemapedCompleted()" );
     StopRecording();
     }
 
-// --------------------------------------------------------------------------
-// CLocationManagerServer::WaitForPositioningStopTimeout()
-// --------------------------------------------------------------------------
-//
 TBool CLocationManagerServer::WaitForPositioningStopTimeout()
     {
     LOG( "CLocationManagerServer::WaitForPositioningStopTimeout()" );
     return iWaitForPositioningStopTimeout;
     }
 
-// --------------------------------------------------------------------------
-// CLocationManagerServer::GeoTaggingCompleted
-// --------------------------------------------------------------------------
-//
-
-void CLocationManagerServer::GeoTaggingCompleted(  const TInt aError  )
-    {    
-    LOG("CLocationManagerServer::GeoTaggingCompleted ,begin");
-    ARG_USED(aError);
-    // do nothing  because we are only handling pending request for this object.    
-#ifdef LOC_REVERSEGEOCODE
-    if(!iGeoTaggingMessage.IsNull())
-    	{
-		LOG("Completing the request");
-		iGeoTaggingMessage.Complete(aError);
-		iGeoTaggingMessage = RMessage2 ();
-    	}
-#endif //LOC_REVERSEGEOCODE
-    StopServer();
-	LOG("CLocationManagerServer::GeoTaggingCompleted ,end");
-    }
-
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::StopServer
-// --------------------------------------------------------------------------
-//
-
-void CLocationManagerServer::StopServer()
-    {    
-    LOG("CLocationManagerServer::StopServer ,begin");
-    // once geo tagging completed, check whether, we can terminate the server
-    // dont't stop this process if
-    // 1. when client are connected.
-    // 2. 3AM timer is going on.
-    // 3. Tagging is in progress.
-    if ( !iSessionCount 
-#if defined(LOC_REVERSEGEOCODE) || defined(LOC_GEOTAGGING_CELLID)
-        && iGeoTagTimer == NULL
-#endif        
-        && iLocationRecord 
-        && !iLocationRecord->TaggingInProgress())
-        {
-        // Nothing in progress. shutdown the server
-        LOG("Stop the schedular");
-        CActiveScheduler::Stop();
-        }
-	LOG("CLocationManagerServer::StopServer ,end");
-    }
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::PendingGeoTagReqComplete
-// --------------------------------------------------------------------------
-//
-void CLocationManagerServer::PendingGeoTagReqComplete(  const TInt aError  )
-    {
-    LOG("CLocationManagerServer::PendingGeoTagReqComplete ,begin");
-    ARG_USED(aError);
-#ifdef LOC_REVERSEGEOCODE
-    if(!iTagPendingMessage.IsNull())
-    	{
-       
-	    TGeoTaggingSatus pendingGeoTagEntry = EGeoTagCmpt;
-        switch(aError)
-            {
-            case KErrNotFound:
-                pendingGeoTagEntry = EGeoTaggingPending;
-                LOG("Geo tagging pending");
-                break;
-            case KErrInUse:
-                pendingGeoTagEntry = EGeoTaggingGoingOn;
-                LOG("Geo tagging going on");
-                break;
-            default:
-                break;
-            }
-                    
-	    TPckg<TGeoTaggingSatus> pendingGeoTagEntryPkg( pendingGeoTagEntry );    
-	    TRAPD(err, iTagPendingMessage.WriteL( 0, pendingGeoTagEntryPkg ));
-	    iTagPendingMessage.Complete((err == KErrNone) ? KErrNone : err);
-	    iTagPendingMessage = RMessage2 ();
-    	}
-#endif //LOC_REVERSEGEOCODE
-	LOG("CLocationManagerServer::PendingGeoTagReqComplete ,end");
-    }
-
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::TagPendingRequestL
-// --------------------------------------------------------------------------
-//
-void CLocationManagerServer::TagPendingRequestL( const RMessage2& aMessage )
-    {    
-    LOG("CLocationManagerServer::TagPendingRequestL ,begin");
-    // Only one request at a time
-#ifdef LOC_REVERSEGEOCODE
-    if(iTagPendingMessage.IsNull() && iGeoTaggingMessage.IsNull())
-        {
-        iTagPendingMessage = RMessage2( aMessage );
-        // search for pending entry.
-        //Create the instance of geotagger class
-        TBool tagProgress = iLocationRecord->TaggingInProgress();
-        if(tagProgress)
-            {
-            LOG("Tagging is going on.\n");
-            // Let UI to send start geo tagging command.
-            PendingGeoTagReqComplete(KErrNotFound);
-            }
-        else
-            {
-            LOG("Tagging is not going on.\n");
-            if(iGeoTaggingPendingReqObj == NULL)
-                {
-                iGeoTaggingPendingReqObj = CGeoTagger::NewL( this, NULL );
-                }
-            iGeoTaggingPendingReqObj->PendingGeoTagsL( tagProgress);
-    		}
-        }
-    else
-        {
-		LOG("Server busy\n");
-        aMessage.Complete(KErrServerBusy);
-        }
-#else
-    aMessage.Complete(KErrNotSupported);
-#endif //LOC_REVERSEGEOCODE
-	LOG("CLocationManagerServer::TagPendingRequestL ,end");
-    }
-
-
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::CancelTagPendingRequest
-// --------------------------------------------------------------------------
-//
-void CLocationManagerServer::CancelTagPendingRequest( const RMessage2& aMessage )
-    {    
-    LOG("CLocationManagerServer::CancelTagPendingRequest ,begin");
-    // Only one request at a time
-#ifdef LOC_REVERSEGEOCODE
-    if(!iTagPendingMessage.IsNull())
-        {
-        iTagPendingMessage.Complete(KErrCancel);
-        iLocationRecord->CancelGeoTagging();
-        }
-    aMessage.Complete(KErrNone);
-#else
-    aMessage.Complete(KErrNotSupported);
-#endif //LOC_REVERSEGEOCODE
-    }
-
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::CancelGeoTaggingRequest
-// --------------------------------------------------------------------------
-//
-void CLocationManagerServer::CancelGeoTaggingRequest( const RMessage2& aMessage )
-    {    
-    LOG("CLocationManagerServer::CancelGeoTaggingRequest ,begin");
-    // Only one request at a time
-#ifdef LOC_REVERSEGEOCODE
-    if(!iGeoTaggingMessage.IsNull())
-        {
-        iGeoTaggingMessage.Complete(KErrCancel);
-        iGeoTaggingMessage = RMessage2 ();
-        iLocationRecord->CancelGeoTagging();
-        }
-    aMessage.Complete(KErrNone);
-#else
-    aMessage.Complete(KErrNotSupported);
-#endif //LOC_REVERSEGEOCODE
-    }
-
-
-// --------------------------------------------------------------------------
-// CLocationManagerServer::StartGeoTaggingL
-// --------------------------------------------------------------------------
-//
-void CLocationManagerServer::StartGeoTaggingL( const RMessage2& aMessage )
-    {
-    LOG("CLocationManagerServer::StartGeoTaggingL ,begin");
-#ifdef LOC_REVERSEGEOCODE
-    if(iGeoTaggingMessage.IsNull() && iTagPendingMessage.IsNull())
-        {
-        iGeoTaggingMessage = RMessage2( aMessage );
-        // search for pending entry.
-        //Create the instance of geotagger class
-        if(!iLocationRecord->StartGeoTagging(EInteractive))
-            {
-            if(iGeoTaggingPendingReqObj == NULL)
-                {
-                iGeoTaggingPendingReqObj = CGeoTagger::NewL( this, NULL );
-                }
-    		iGeoTaggingPendingReqObj->CreateGeoTagsL((TConnectionOption)(aMessage.Int0()));
-    		}
-        }
-    else
-        {
-		LOG("Server busy\n");
-        aMessage.Complete(KErrServerBusy);
-        }
-#else
-    aMessage.Complete(KErrNotSupported);
-#endif //LOC_REVERSEGEOCODE
-    }
-
-
-// ----------------------------------------------------------------------------
-// CLocationManagerServer::GetCurrentRegisterNw()
-// ---------------------------------------------------------------------------- 
-RMobilePhone::TMobilePhoneNetworkInfoV2& CLocationManagerServer::GetCurrentRegisterNw()
-    {
-    LOG( "CLocationManagerServer::GetCurrentRegisterNw ,begin" );
-    return iLocationRecord->GetCurrentRegisteredNw();
-    }
-
-// ----------------------------------------------------------------------------
-// CLocationManagerServer::RetrieveHomeNetwork()
-// ----------------------------------------------------------------------------
-void CLocationManagerServer::RetrieveHomeNetwork()
-    {
-    LOG("CLocationManagerServer::RetrieveHomeNetwork ,begin");
-    if(iHomeNwInfoAvailableFlag)
-        {
-        RMobilePhone::TMobilePhoneNetworkInfoV1Pckg homeNetworkPckg( iHomeNetwork );
-        
-        TRequestStatus status( KErrNone );
-        
-        iPhone.GetHomeNetwork(status, homeNetworkPckg);
-        User::WaitForRequest( status );
-        if(status.Int() == KErrNone)
-            {
-            iHomeNwInfoAvailableFlag = ETrue;
-            }
-        }
-	LOG("CLocationManagerServer::RetrieveHomeNetwork ,end");
-    }
-
-// ----------------------------------------------------------------------------
-// CLocationManagerServer::GetHomeNetworkInfo()
-// ----------------------------------------------------------------------------
-const RMobilePhone::TMobilePhoneNetworkInfoV1& 
-        CLocationManagerServer::GetHomeNetworkInfo(TBool& aHomeNwInfoAvailableFlag)
-    {
-    LOG("CLocationManagerServer::RetrieveHomeNetwork ,begin");
-    if(!iHomeNwInfoAvailableFlag)
-        {
-        RetrieveHomeNetwork();
-        }
-    aHomeNwInfoAvailableFlag = iHomeNwInfoAvailableFlag;
-    return iHomeNetwork;
-    }
-
-
-// ----------------------------------------------------------------------------
-// CLocationManagerServer::IsRegisteredAtHomeNetwork()
-// ---------------------------------------------------------------------------- 
-TBool CLocationManagerServer::IsRegisteredAtHomeNetwork()
-    {
-    LOG( "CLocationManagerServer::IsRegisteredAtHomeNetwork" );
-    return (iNwRegistrationStatusHandler &&
-            (iNwRegistrationStatusHandler->GetNetworkRegistrationStatus() 
-                == RMobilePhone::ERegisteredOnHomeNetwork));
-    }
-
 // End of file