diff -r aa5a574040a4 -r a93990e5815e locationmanager/server/src/clocationmanagerserver.cpp --- a/locationmanager/server/src/clocationmanagerserver.cpp Tue Jul 06 14:44:37 2010 +0300 +++ b/locationmanager/server/src/clocationmanagerserver.cpp Wed Aug 18 10:12:07 2010 +0300 @@ -33,9 +33,7 @@ #include "mdeobjectdef.h" #include "mdepropertydef.h" #include "mdcserializationbuffer.h" -#ifdef LOC_REVERSEGEOCODE #include "clocationgeotagtimerao.h" -#endif //LOC_REVERSEGEOCODE #include "nwregistrationstatushandler.h" using namespace MdeConstants; @@ -78,6 +76,7 @@ { TRAP( ret, RunServerL() ); delete cleanup; + cleanup = NULL; } return ret; } @@ -101,7 +100,7 @@ // -------------------------------------------------------------------------- // CLocationManagerServer::CLocationManagerServer() - : CPolicyServer( CActive::EPriorityStandard, + : CPolicyServer( KLocManagerSessionPriority, KLocationManagerPolicy, ESharableSessions ), iASW(NULL), @@ -116,9 +115,9 @@ iTelServerIsOpen(EFalse), iPhoneIsOpen(EFalse), iNwRegistrationStatusHandler(NULL), - iHomeNwInfoAvailableFlag(EFalse) + iHomeNwInfoAvailableFlag(EFalse), + iGeoTagTimer(NULL) #ifdef LOC_REVERSEGEOCODE - ,iGeoTagTimer(NULL) ,iGeoTaggingPendingReqObj(NULL) ,iEcomSession(NULL) #endif //LOC_REVERSEGEOCODE @@ -135,10 +134,6 @@ LOG ("CLocationManagerServer::ConstructL() begin"); StartL( KLocServerName ); - - RProcess process; - process.SetPriority( EPriorityBackground ); - process.Close(); // initialize etel InitialisePhoneL(); @@ -151,57 +146,67 @@ iNwRegistrationStatusHandler = CNwRegistrationStatusHandler::NewL(iPhone); - iMdeSession = CMdESession::NewL( *this ); iLocationRecord = CLocationRecord::NewL(*this, iPhone); iTrackLog = CTrackLog::NewL(); + iMdeSession = CMdESession::NewL( *this ); + + iLocationRecord->SetObserver( this ); - iASW->Start(); + iLocationRecord->SetAddObserver( iTrackLog ); + + iTrackLog->AddGpxObserver( this ); + + CRepository* repository = CRepository::NewLC( KRepositoryUid ); + TInt err = repository->Get( KLocationTrailShutdownTimer, iLocManStopDelay ); + + LOG1("iLocManStopDelay:%d", iLocManStopDelay); + + if ( err != KErrNone ) + { + LOG1("iLocManStopDelay err:%d", err); + iLocManStopDelay = KLocationTrailShutdownDelay; + } + + err = repository->Get( KLocationTrailRemapShutdownTimer, iLocManStopRemapDelay ); + CleanupStack::PopAndDestroy( repository ); + + LOG1("iLocManStopRemapDelay:%d", iLocManStopRemapDelay); + + if ( err != KErrNone ) + { + LOG1("iLocManStopRemapDelay err:%d", err); + iLocManStopRemapDelay = KLocationTrailRemapShutdownDelay; + } + + if( !iSessionReady ) + { + iASW->Start(); + } + delete iASW; - iASW = NULL; - if(iSessionReady) + iASW = NULL; + + if( iSessionReady ) { LOG("Session is ready to give service"); - - iLocationRecord->SetObserver( this ); - - iLocationRecord->SetAddObserver( iTrackLog ); - - iTrackLog->AddGpxObserver( this ); - - CRepository* repository = CRepository::NewLC( KRepositoryUid ); - TInt err = repository->Get( KLocationTrailShutdownTimer, iLocManStopDelay ); - - LOG1("CLocationManagerServer::ConstructL, iLocManStopDelay:%d", iLocManStopDelay); - - if ( err != KErrNone ) - { - LOG1("CLocationManagerServer::ConstructL, iLocManStopDelay err:%d", err); - iLocManStopDelay = KLocationTrailShutdownDelay; - } - - err = repository->Get( KLocationTrailRemapShutdownTimer, iLocManStopRemapDelay ); - CleanupStack::PopAndDestroy( repository ); - - LOG1("CLocationManagerServer::ConstructL, iLocManStopRemapDelay:%d", iLocManStopRemapDelay); - - if ( err != KErrNone ) - { - LOG1("CLocationManagerServer::ConstructL, iLocManStopRemapDelay err:%d", err); - iLocManStopRemapDelay = KLocationTrailRemapShutdownDelay; - } - -#ifdef LOC_REVERSEGEOCODE //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 //LOC_REVERSEGEOCODE +#endif } else { LOG("Unable to open MDE session. Closing.."); - User::Leave(KErrCouldNotConnect); + User::Leave( KErrCouldNotConnect ); } + + RProcess process; + process.SetPriority( EPriorityBackground ); + process.Close(); + LOG ("CLocationManagerServer::ConstructL() end"); } @@ -213,18 +218,29 @@ CLocationManagerServer::~CLocationManagerServer() { LOG("CLocationManagerServer::~CLocationManagerServer ,begin"); - +#if defined(LOC_REVERSEGEOCODE) || defined(LOC_GEOTAGGING_CELLID) + delete iGeoTagTimer; + iGeoTagTimer = NULL; +#endif #ifdef LOC_REVERSEGEOCODE - delete iGeoTagTimer; delete iGeoTaggingPendingReqObj; + iGeoTaggingPendingReqObj = NULL; #endif //LOC_REVERSEGEOCODE 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(); @@ -474,14 +490,9 @@ // void CLocationManagerServer::RemoveSession() { + LOG1( "CLocationManagerServer::RemoveSession. Session count - %d", iSessionCount); iSessionCount--; - if ( !iSessionCount - && iLocationRecord - && !iLocationRecord->TaggingInProgress()) - { - // Nothing in progress. shutdown the server - CActiveScheduler::Stop(); - } + StopServer(); } // -------------------------------------------------------------------------- @@ -1105,6 +1116,7 @@ } iCopyReqs[i].iMessage.Complete( aError ); delete iCopyReqs[i].iQuery; + iCopyReqs[i].iQuery = NULL; iCopyReqs.Remove( i ); break; } @@ -1151,6 +1163,7 @@ { iCopyReqs[i].iMessage.Complete( KErrNone ); delete iCopyReqs[i].iQuery; + iCopyReqs[i].iQuery = NULL; iCopyReqs.Remove( i ); break; } @@ -1657,18 +1670,38 @@ 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::GeoTaggingCompleted ,end"); + LOG("CLocationManagerServer::StopServer ,end"); } - // -------------------------------------------------------------------------- // CLocationManagerServer::PendingGeoTagReqComplete // -------------------------------------------------------------------------- @@ -1788,7 +1821,7 @@ } aMessage.Complete(KErrNone); #else - aMessage.Complete(KErrNotSupported); + aMessage.Complete(KErrNotSupported); #endif //LOC_REVERSEGEOCODE }