96 ESharableSessions ), |
96 ESharableSessions ), |
97 iTimer( NULL ), |
97 iTimer( NULL ), |
98 iSessionReady( EFalse ), |
98 iSessionReady( EFalse ), |
99 iTagId( 0 ), |
99 iTagId( 0 ), |
100 iLocManStopDelay( 0 ), |
100 iLocManStopDelay( 0 ), |
|
101 iLocManStopRemapDelay( 0 ), |
101 iCaptureSetting( RLocationTrail::EOff ), |
102 iCaptureSetting( RLocationTrail::EOff ), |
102 iRemoveLocation( EFalse ) |
103 iRemoveLocation( EFalse ) |
103 { |
104 { |
104 } |
105 } |
105 |
106 |
131 |
132 |
132 iTrackLog->AddGpxObserver( this ); |
133 iTrackLog->AddGpxObserver( this ); |
133 |
134 |
134 CRepository* repository = CRepository::NewLC( KRepositoryUid ); |
135 CRepository* repository = CRepository::NewLC( KRepositoryUid ); |
135 TInt err = repository->Get( KLocationTrailShutdownTimer, iLocManStopDelay ); |
136 TInt err = repository->Get( KLocationTrailShutdownTimer, iLocManStopDelay ); |
136 CleanupStack::PopAndDestroy( repository ); |
|
137 |
137 |
138 LOG1("CLocationManagerServer::ConstructL, iLocManStopDelay:%d", iLocManStopDelay); |
138 LOG1("CLocationManagerServer::ConstructL, iLocManStopDelay:%d", iLocManStopDelay); |
139 |
139 |
140 if ( err != KErrNone ) |
140 if ( err != KErrNone ) |
141 { |
141 { |
142 LOG1("CLocationManagerServer::ConstructL, iLocManStopDelay err:%d", err); |
142 LOG1("CLocationManagerServer::ConstructL, iLocManStopDelay err:%d", err); |
143 iLocManStopDelay = KLocationTrailShutdownDelay; |
143 iLocManStopDelay = KLocationTrailShutdownDelay; |
144 } |
144 } |
|
145 |
|
146 err = repository->Get( KLocationTrailRemapShutdownTimer, iLocManStopRemapDelay ); |
|
147 CleanupStack::PopAndDestroy( repository ); |
|
148 |
|
149 LOG1("CLocationManagerServer::ConstructL, iLocManStopRemapDelay:%d", iLocManStopRemapDelay); |
|
150 |
|
151 if ( err != KErrNone ) |
|
152 { |
|
153 LOG1("CLocationManagerServer::ConstructL, iLocManStopRemapDelay err:%d", err); |
|
154 iLocManStopRemapDelay = KLocationTrailRemapShutdownDelay; |
|
155 } |
145 |
156 |
146 LOG ("CLocationManagerServer::ConstructL() end"); |
157 LOG ("CLocationManagerServer::ConstructL() end"); |
147 } |
158 } |
148 |
159 |
149 // -------------------------------------------------------------------------- |
160 // -------------------------------------------------------------------------- |
327 |
339 |
328 RLocationTrail::TTrailState state; |
340 RLocationTrail::TTrailState state; |
329 GetLocationTrailState( state ); |
341 GetLocationTrailState( state ); |
330 if( state == RLocationTrail::ETrailStarted || state == RLocationTrail::ETrailStarting ) |
342 if( state == RLocationTrail::ETrailStarted || state == RLocationTrail::ETrailStarting ) |
331 { |
343 { |
332 iLocationRecord->Stop(); |
344 TRAPD( error, iTimer = CPeriodic::NewL( CActive::EPriorityStandard ) ); |
|
345 if ( error != KErrNone ) |
|
346 { |
|
347 // If timer can't be created we stop the location trail immediately. |
|
348 iLocationRecord->Stop(); |
|
349 StopTrackLogL(); |
|
350 return; |
|
351 } |
|
352 iLocationRecord->SetStateToStopping(); |
|
353 iTimer->Start( KLocationTrailRemappingCheckDelay * 1000000, 0, TCallBack( CheckForRemappingCallback, this ) ); |
333 } |
354 } |
334 else if ( state != RLocationTrail::ETrailStopped && state != RLocationTrail::ETrailStopping ) |
355 else if ( state != RLocationTrail::ETrailStopped && state != RLocationTrail::ETrailStopping ) |
335 { |
356 { |
|
357 TInt delay( iLocManStopDelay ); |
336 if ( iLocationRecord->RemappingNeeded() ) |
358 if ( iLocationRecord->RemappingNeeded() ) |
337 { |
359 { |
338 TRAPD( error, iTimer = CPeriodic::NewL( CActive::EPriorityStandard ) ); |
360 delay = iLocManStopRemapDelay; |
339 if ( error != KErrNone ) |
|
340 { |
|
341 // If timer can't be created we stop the location trail immediately. |
|
342 iLocationRecord->Stop(); |
|
343 StopTrackLogL(); |
|
344 return; |
|
345 } |
|
346 iLocationRecord->SetStateToStopping(); |
|
347 iTimer->Start( iLocManStopDelay * 1000000, 0, TCallBack( PositioningStopTimeout, this ) ); |
|
348 } |
361 } |
349 else |
362 |
|
363 TRAPD( error, iTimer = CPeriodic::NewL( CActive::EPriorityStandard ) ); |
|
364 if ( error != KErrNone ) |
350 { |
365 { |
|
366 // If timer can't be created we stop the location trail immediately. |
351 iLocationRecord->Stop(); |
367 iLocationRecord->Stop(); |
|
368 StopTrackLogL(); |
|
369 return; |
352 } |
370 } |
|
371 iLocationRecord->SetStateToStopping(); |
|
372 iTimer->Start( delay * 1000000, 0, TCallBack( PositioningStopTimeout, this ) ); |
353 } |
373 } |
354 |
374 |
355 // Always stop tracklog. |
375 // Always stop tracklog. |
356 StopTrackLogL(); |
376 StopTrackLogL(); |
357 } |
377 } |
376 CLocationManagerServer* self = STATIC_CAST( CLocationManagerServer*, aAny ); |
396 CLocationManagerServer* self = STATIC_CAST( CLocationManagerServer*, aAny ); |
377 self->StopRecording(); |
397 self->StopRecording(); |
378 |
398 |
379 return KErrNone; |
399 return KErrNone; |
380 } |
400 } |
|
401 |
|
402 // -------------------------------------------------------------------------- |
|
403 // CLocationUtilityServer::PositioningStopTimeout |
|
404 // -------------------------------------------------------------------------- |
|
405 // |
|
406 TInt CLocationManagerServer::CheckForRemappingCallback( TAny* aAny ) |
|
407 { |
|
408 CLocationManagerServer* self = STATIC_CAST( CLocationManagerServer*, aAny ); |
|
409 |
|
410 self->iTimer->Cancel(); |
|
411 |
|
412 TInt delay( self->iLocManStopDelay ); |
|
413 if ( self->iLocationRecord->RemappingNeeded() ) |
|
414 { |
|
415 delay = self->iLocManStopRemapDelay; |
|
416 self->iTimer->Start( delay * 1000000, 0, TCallBack( PositioningStopTimeout, self ) ); |
|
417 } |
|
418 else |
|
419 { |
|
420 delete self->iTimer; |
|
421 self->iTimer = NULL; |
|
422 self->iLocationRecord->Stop(); |
|
423 } |
|
424 |
|
425 return KErrNone; |
|
426 } |
381 |
427 |
382 // -------------------------------------------------------------------------- |
428 // -------------------------------------------------------------------------- |
383 // CLocationManagerServer::GetLocationTrailState |
429 // CLocationManagerServer::GetLocationTrailState |
384 // -------------------------------------------------------------------------- |
430 // -------------------------------------------------------------------------- |
385 // |
431 // |