diff -r f727727520eb -r aa5a574040a4 locationmanager/server/src/clocationmanagerserver.cpp --- a/locationmanager/server/src/clocationmanagerserver.cpp Wed Jun 23 18:41:19 2010 +0300 +++ b/locationmanager/server/src/clocationmanagerserver.cpp Tue Jul 06 14:44:37 2010 +0300 @@ -17,6 +17,10 @@ #include #include +#include +#include +#include +#include #include "clocationmanagerserver.h" #include "clocationmanagersession.h" @@ -29,8 +33,14 @@ #include "mdeobjectdef.h" #include "mdepropertydef.h" #include "mdcserializationbuffer.h" +#ifdef LOC_REVERSEGEOCODE +#include "clocationgeotagtimerao.h" +#endif //LOC_REVERSEGEOCODE +#include "nwregistrationstatushandler.h" using namespace MdeConstants; +using namespace CommsDat; + // -------------------------------------------------------------------------- // RunServerL @@ -94,6 +104,7 @@ : CPolicyServer( CActive::EPriorityStandard, KLocationManagerPolicy, ESharableSessions ), + iASW(NULL), iTimer( NULL ), iSessionReady( EFalse ), iTagId( 0 ), @@ -101,7 +112,16 @@ iLocManStopRemapDelay( 0 ), iCaptureSetting( RLocationTrail::EOff ), iRemoveLocation( EFalse ), - iWaitForPositioningStopTimeout ( EFalse ) + iWaitForPositioningStopTimeout ( EFalse ), + iTelServerIsOpen(EFalse), + iPhoneIsOpen(EFalse), + iNwRegistrationStatusHandler(NULL), + iHomeNwInfoAvailableFlag(EFalse) +#ifdef LOC_REVERSEGEOCODE + ,iGeoTagTimer(NULL) + ,iGeoTaggingPendingReqObj(NULL) + ,iEcomSession(NULL) +#endif //LOC_REVERSEGEOCODE { } @@ -119,50 +139,69 @@ RProcess process; process.SetPriority( EPriorityBackground ); process.Close(); + + // initialize etel + InitialisePhoneL(); +#ifdef LOC_REVERSEGEOCODE + iEcomSession = &(REComSession::OpenL()); +#endif //LOC_REVERSEGEOCODE + iASW = new (ELeave) CActiveSchedulerWait(); + + iNwRegistrationStatusHandler = CNwRegistrationStatusHandler::NewL(iPhone); + iMdeSession = CMdESession::NewL( *this ); - iLocationRecord = CLocationRecord::NewL(); + iLocationRecord = CLocationRecord::NewL(*this, iPhone); iTrackLog = CTrackLog::NewL(); iASW->Start(); - - 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; - } + delete iASW; + 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; + 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 + iGeoTagTimer = CLocationGeoTagTimerAO::NewL(*iMdeSession, *this); + //Schedule a task for geotagging every day at 3.00 AM + iGeoTagTimer->StartTimer(); +#endif //LOC_REVERSEGEOCODE } - - TRAPD( error, iTimer = CPeriodic::NewL( CActive::EPriorityUserInput ) ); - if ( error != KErrNone ) + else { - LOG("CLocationManagerServer::ConstructL - iTimer not created"); - iTimer = NULL; - } - - + LOG("Unable to open MDE session. Closing.."); + User::Leave(KErrCouldNotConnect); + } LOG ("CLocationManagerServer::ConstructL() end"); } @@ -173,13 +212,19 @@ // CLocationManagerServer::~CLocationManagerServer() { + LOG("CLocationManagerServer::~CLocationManagerServer ,begin"); + +#ifdef LOC_REVERSEGEOCODE + delete iGeoTagTimer; + delete iGeoTaggingPendingReqObj; +#endif //LOC_REVERSEGEOCODE + delete iLocationRecord; delete iTrackLog; delete iTimer; - //delete iRelationQuery; delete iASW; delete iMdeSession; - + delete iNwRegistrationStatusHandler; iTargetObjectIds.Close(); CancelRequests(iNotifReqs); iNotifReqs.Close(); @@ -190,9 +235,115 @@ 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* globalSettingField = new(ELeave) CMDBField(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 // -------------------------------------------------------------------------- -// CLocationManagerServer::CompleteRequests() +// +void CLocationManagerServer::InitialisePhoneL() + { + LOG( "CLocationManagerServer::InitialisePhoneL(), begin" ); + User::LeaveIfError(iTelServer.Connect()); + iTelServerIsOpen = ETrue; + TBuf tsyName; + GetCommDbTSYnameL(tsyName); + + User::LeaveIfError(iTelServer.LoadPhoneModule(tsyName)); + + TInt numPhones; + User::LeaveIfError(iTelServer.EnumeratePhones(numPhones)); + + TInt phoneIndx; + TInt ret = KErrHardwareNotAvailable; + + for(phoneIndx=0; phoneIndx& aMessageList) @@ -211,6 +362,10 @@ aMessageList.Reset(); } +// -------------------------------------------------------------------------- +// CLocationManagerServer::CancelCopyRequests +// -------------------------------------------------------------------------- +// void CLocationManagerServer::CancelCopyRequests(RArray& aMessageList) { const TInt count = aMessageList.Count(); @@ -227,10 +382,14 @@ aMessageList.Reset(); } - +// -------------------------------------------------------------------------- +// CLocationManagerServer::HandleSessionOpened +// -------------------------------------------------------------------------- +// void CLocationManagerServer::HandleSessionOpened(CMdESession& /*aSession*/, TInt aError) { - if ( iASW->IsStarted() ) + LOG ("CLocationManagerServer::HandleSessionOpened() start"); + if ( iASW && iASW->IsStarted() ) { iASW->AsyncStop(); } @@ -249,18 +408,31 @@ } } -void CLocationManagerServer::HandleSessionError(CMdESession& /*aSession*/, TInt /*aError*/) + +// -------------------------------------------------------------------------- +// CLocationManagerServer::HandleSessionError +// -------------------------------------------------------------------------- +// +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->IsStarted() ) + if ( iASW && iASW->IsStarted() ) { iASW->AsyncStop(); } } + + +// -------------------------------------------------------------------------- +// CLocationManagerServer::IsSessionReady +// -------------------------------------------------------------------------- +// TBool CLocationManagerServer::IsSessionReady() { return iSessionReady; @@ -303,8 +475,11 @@ void CLocationManagerServer::RemoveSession() { iSessionCount--; - if ( !iSessionCount ) + if ( !iSessionCount + && iLocationRecord + && !iLocationRecord->TaggingInProgress()) { + // Nothing in progress. shutdown the server CActiveScheduler::Stop(); } } @@ -334,7 +509,8 @@ if ( iTimer ) { - iTimer->Cancel(); + delete iTimer; + iTimer = NULL; } iLocationRecord->StartL( aCaptureSetting ); @@ -355,24 +531,19 @@ if( state != RLocationTrail::ETrailStopped && state != RLocationTrail::ETrailStopping ) { - if(!iTimer) + if(iTimer == NULL) { - TRAPD( error, iTimer = CPeriodic::NewL( CActive::EPriorityUserInput ) ); - if ( error != KErrNone ) - { - LOG("CLocationManagerServer::StopGPSPositioningL() - iTimer not created"); - iTimer = NULL; - } - } - if(iTimer) + TRAP_IGNORE(iTimer = CLocationServerTimerHandler::NewL(*this)); + } + if ( iTimer == NULL) { - iTimer->Cancel(); - iLocationRecord->SetStateToStopping(); - iTimer->Start( iLocManStopDelay * 1000000, 0, TCallBack( CheckForRemappingCallback, this ) ); - } + // If timer can't be created we stop the location trail immediately. + iLocationRecord->Stop(); + } else { - iLocationRecord->Stop(); + iLocationRecord->SetStateToStopping(); + iTimer->StartTimer( iLocManStopDelay * 1000000, MLocationServerTimerObserver::EStopRecording); } } @@ -389,48 +560,61 @@ LOG( "CLocationManagerServer::StopRecording()" ); iWaitForPositioningStopTimeout = EFalse; iLocationRecord->Stop(); - if(iTimer) - { - iTimer->Cancel(); - } - + } + +// -------------------------------------------------------------------------- +// 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" ); } // -------------------------------------------------------------------------- // CLocationUtilityServer::PositioningStopTimeout // -------------------------------------------------------------------------- // -TInt CLocationManagerServer::PositioningStopTimeout( TAny* aAny ) +void CLocationManagerServer::PositioningStopTimeout() { LOG( "CLocationManagerServer::PositioningStopTimeout" ); - CLocationManagerServer* self = STATIC_CAST( CLocationManagerServer*, aAny ); - self->StopRecording(); - - return KErrNone; + StopRecording(); } // -------------------------------------------------------------------------- -// CLocationUtilityServer::PositioningStopTimeout +// CLocationUtilityServer::CheckForRemappingCallback // -------------------------------------------------------------------------- // -TInt CLocationManagerServer::CheckForRemappingCallback( TAny* aAny ) +void CLocationManagerServer::CheckForRemappingCallback() { - LOG( "CLocationManagerServer::CheckForRemappingCallback" ); - CLocationManagerServer* self = STATIC_CAST( CLocationManagerServer*, aAny ); - - self->iTimer->Cancel(); - - if ( self->iLocationRecord->RemappingNeeded() && !self->iLocationRecord->IsLowBattery()) + LOG( "CLocationManagerServer::CheckForRemappingCallback, begin" ); + if ( iLocationRecord->RemappingNeeded() && !iLocationRecord->IsLowBattery()) { - self->iTimer->Start( self->iLocManStopRemapDelay * 1000000, 0, TCallBack( PositioningStopTimeout, self ) ); - self->iWaitForPositioningStopTimeout = ETrue; + iTimer->StartTimer( iLocManStopRemapDelay * 1000000, MLocationServerTimerObserver::EPositioningStopTimeout); + iWaitForPositioningStopTimeout = ETrue; } else { - self->StopRecording(); + StopRecording(); } - - return KErrNone; + LOG( "CLocationManagerServer::CheckForRemappingCallback, end" ); } // -------------------------------------------------------------------------- @@ -548,7 +732,7 @@ } // -------------------------------------------------------------------------- -// CLocationManagerServer::GetCurrentCellId +// CLocationManagerServer::GetCurrentNetworkInfo // -------------------------------------------------------------------------- // void CLocationManagerServer::GetCurrentNetworkInfo( CTelephony::TNetworkInfoV1& aNetworkInfo ) @@ -630,6 +814,11 @@ LOG( "CLocationManagerServer::CurrentLocation(), end" ); } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::GPSSignalQualityChanged +// -------------------------------------------------------------------------- +// void CLocationManagerServer::GPSSignalQualityChanged( const TPositionSatelliteInfo& aSatelliteInfo ) { LOG( "CLocationManagerServer::GPSSignalQualityChanged" ); @@ -677,7 +866,10 @@ } - +// -------------------------------------------------------------------------- +// CLocationManagerServer::CancelTrackLogNotificationRequest +// -------------------------------------------------------------------------- +// void CLocationManagerServer::CancelTrackLogNotificationRequest( const TInt aHandle ) { LOG( "CLocationManagerServer::CancelTrackLogNotificationRequest(), begin" ); @@ -704,6 +896,11 @@ LOG( "CLocationManagerServer::CancelTrackLogNotificationRequest(), end" ); } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::CreateLocationObjectL +// -------------------------------------------------------------------------- +// void CLocationManagerServer::CreateLocationObjectL( const TLocationData& aLocationData, const TUint& aObjectId ) { @@ -715,13 +912,21 @@ 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" ); } // -------------------------------------------------------------------------- @@ -757,6 +962,11 @@ iRelationQuery->FindL( 1, 1 ); } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::CopyLocationObjectL +// -------------------------------------------------------------------------- +// void CLocationManagerServer::CopyLocationObjectL( TItemId aSource, const RArray& aTargets, TMessageQuery& aMessageQuery ) { @@ -818,6 +1028,11 @@ } } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::CopyLocationObjectL +// -------------------------------------------------------------------------- +// void CLocationManagerServer::CopyLocationObjectL( const TDesC& aSource, const RArray& aTargets, TMessageQuery& aQuery ) { @@ -839,13 +1054,24 @@ 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 ) @@ -889,6 +1115,11 @@ iTargetObjectIds.Reset(); } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::NewLC +// -------------------------------------------------------------------------- +// void CLocationManagerServer::CopyLocationL( CMdEQuery& aQuery ) { CMdEObjectDef& locationDef = aQuery.NamespaceDef().GetObjectDefL( Location::KLocationObject ); @@ -926,6 +1157,11 @@ } } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::InitCopyLocationByIdL +// -------------------------------------------------------------------------- +// void CLocationManagerServer::InitCopyLocationByIdL( const RMessage2& aMessage ) { const TInt KParamSourceId = 0; @@ -959,6 +1195,11 @@ CleanupStack::PopAndDestroy(&targetIds); } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::InitCopyLocationByURIL +// -------------------------------------------------------------------------- +// void CLocationManagerServer::InitCopyLocationByURIL( const RMessage2& aMessage ) { LOG( "CLocationManagerSession::CopyLocationDataByUriL begin" ); @@ -1008,8 +1249,14 @@ LOG( "CLocationManagerSession::CopyLocationDataByUriL end" ); } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::StartTrackLogL +// -------------------------------------------------------------------------- +// TItemId CLocationManagerServer::StartTrackLogL() { + LOG("CLocationManagerServer::StartTrackLogL"); if ( iTrackLog->IsRecording() ) { User::Leave( KErrInUse ); @@ -1026,8 +1273,14 @@ return iTagId; } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::StopTrackLogL +// -------------------------------------------------------------------------- +// void CLocationManagerServer::StopTrackLogL() { + LOG("CLocationManagerServer::StopTrackLogL"); if ( iTrackLog->IsRecording() ) { iTrackLog->StopRecordingL(); @@ -1040,8 +1293,14 @@ } } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::CompleteNotifyRequest +// -------------------------------------------------------------------------- +// void CLocationManagerServer::CompleteNotifyRequest( TEventTypes aEventType, TInt aError ) { + LOG("CLocationManagerServer::CompleteNotifyRequest"); const TInt KEventTypeParam = 2; TPckg wrapEventType( aEventType ); @@ -1059,19 +1318,35 @@ 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 ); @@ -1104,9 +1379,15 @@ 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 ); @@ -1153,6 +1434,11 @@ CleanupStack::PopAndDestroy( trackLog ); } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::GetTrackLogStatus +// -------------------------------------------------------------------------- +// TInt CLocationManagerServer::GetTrackLogStatus( TBool& aRecording, TPositionSatelliteInfo& aFixQuality) { if ( !iTrackLog ) @@ -1165,6 +1451,11 @@ return KErrNone; } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::DeleteTrackLogL +// -------------------------------------------------------------------------- +// TInt CLocationManagerServer::DeleteTrackLogL( const TDesC& aUri ) { LOG( "CLocationManagerServer::DeleteTrackLogL enter" ); @@ -1205,6 +1496,11 @@ return err; } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::TrackLogName +// -------------------------------------------------------------------------- +// TInt CLocationManagerServer::TrackLogName( TFileName& aFileName ) { if ( iTrackLog->IsRecording() ) @@ -1215,11 +1511,21 @@ return KErrNotFound; } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::GetCaptureSetting +// -------------------------------------------------------------------------- +// void CLocationManagerServer::GetCaptureSetting( RLocationTrail::TTrailCaptureSetting& aCaptureSetting ) { aCaptureSetting = iCaptureSetting; } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::HandleObjectNotification +// -------------------------------------------------------------------------- +// void CLocationManagerServer::HandleObjectNotification( CMdESession& /*aSession*/, TObserverNotificationType aType, const RArray& aObjectIdArray ) @@ -1234,6 +1540,11 @@ TRAP_IGNORE( LinkObjectToTrackLogTagL( aObjectIdArray ) ); } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::StartListeningTagRemovalsL +// -------------------------------------------------------------------------- +// void CLocationManagerServer::StartListeningTagRemovalsL() { if ( !IsSessionReady() ) @@ -1249,6 +1560,11 @@ CleanupStack::Pop( condition ); } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::StartListeningObjectCreationsL +// -------------------------------------------------------------------------- +// void CLocationManagerServer::StartListeningObjectCreationsL() { if ( !IsSessionReady() ) @@ -1271,6 +1587,11 @@ } + +// -------------------------------------------------------------------------- +// CLocationManagerServer::LinkObjectToTrackLogTagL +// -------------------------------------------------------------------------- +// void CLocationManagerServer::LinkObjectToTrackLogTagL( const RArray& aObjectIdArray ) { CMdERelationDef& containsRelDef = iMdeSession->GetDefaultNamespaceDefL() @@ -1288,21 +1609,279 @@ } } + +// -------------------------------------------------------------------------- +// 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 + // once geo tagging completed, check whether, we can terminate the server + if ( !iSessionCount + && iLocationRecord + && !iLocationRecord->TaggingInProgress()) + { + // Nothing in progress. shutdown the server + CActiveScheduler::Stop(); + } + LOG("CLocationManagerServer::GeoTaggingCompleted ,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 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