locationmanager/server/src/clocationmanagerserver.cpp
changeset 23 33ae025ac1e8
parent 21 50bf9db68373
child 25 8e4539ab1889
equal deleted inserted replaced
21:50bf9db68373 23:33ae025ac1e8
   153         {
   153         {
   154         LOG1("CLocationManagerServer::ConstructL, iLocManStopRemapDelay err:%d", err);
   154         LOG1("CLocationManagerServer::ConstructL, iLocManStopRemapDelay err:%d", err);
   155         iLocManStopRemapDelay = KLocationTrailRemapShutdownDelay;
   155         iLocManStopRemapDelay = KLocationTrailRemapShutdownDelay;
   156         }
   156         }
   157     
   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     
   158     LOG ("CLocationManagerServer::ConstructL() end");
   166     LOG ("CLocationManagerServer::ConstructL() end");
   159     }
   167     }
   160 
   168 
   161 // --------------------------------------------------------------------------
   169 // --------------------------------------------------------------------------
   162 // CLocationManagerServer::~CLocationManagerServer()
   170 // CLocationManagerServer::~CLocationManagerServer()
   324         User::Leave( KErrAlreadyExists );
   332         User::Leave( KErrAlreadyExists );
   325         }
   333         }
   326     
   334     
   327     if ( iTimer )
   335     if ( iTimer )
   328     	{
   336     	{
   329     	delete iTimer;
   337     	iTimer->Cancel();
   330     	iTimer = NULL;
       
   331     	}
   338     	}
   332     
   339     
   333     iLocationRecord->StartL( aCaptureSetting );
   340     iLocationRecord->StartL( aCaptureSetting );
   334     }
   341     }
   335 
   342 
   346     RLocationTrail::TTrailState state;
   353     RLocationTrail::TTrailState state;
   347     GetLocationTrailState( state );
   354     GetLocationTrailState( state );
   348      
   355      
   349     if( state != RLocationTrail::ETrailStopped && state != RLocationTrail::ETrailStopping )
   356     if( state != RLocationTrail::ETrailStopped && state != RLocationTrail::ETrailStopping )
   350         {
   357         {
   351         TRAPD( error, iTimer = CPeriodic::NewL( CActive::EPriorityUserInput ) );
   358         if(!iTimer)
   352         
       
   353         if ( error != KErrNone )
       
   354             {
   359             {
   355             // If timer can't be created we stop the location trail immediately.
   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 ) );
       
   372             }
       
   373         else
       
   374             {
   356             iLocationRecord->Stop();
   375             iLocationRecord->Stop();
   357             StopTrackLogL();
   376             }
   358             return;
   377         }
   359             }   
       
   360         
       
   361         iLocationRecord->SetStateToStopping();
       
   362         iTimer->Start( iLocManStopDelay * 1000000, 0, TCallBack( CheckForRemappingCallback, this ) );
       
   363     	}
       
   364     
   378     
   365     // Always stop tracklog.
   379     // Always stop tracklog.
   366     StopTrackLogL();
   380     StopTrackLogL();
   367     }
   381     }
   368 
   382 
   373 void CLocationManagerServer::StopRecording()
   387 void CLocationManagerServer::StopRecording()
   374 	{
   388 	{
   375     LOG( "CLocationManagerServer::StopRecording()" );    
   389     LOG( "CLocationManagerServer::StopRecording()" );    
   376     iWaitForPositioningStopTimeout = EFalse;
   390     iWaitForPositioningStopTimeout = EFalse;
   377     iLocationRecord->Stop();		
   391     iLocationRecord->Stop();		
   378 	delete iTimer;
   392 	if(iTimer)
   379 	iTimer = NULL;
   393 	    {
       
   394         iTimer->Cancel();
       
   395 	    }
       
   396 	
   380 	}
   397 	}
   381 
   398 
   382 // --------------------------------------------------------------------------
   399 // --------------------------------------------------------------------------
   383 // CLocationUtilityServer::PositioningStopTimeout
   400 // CLocationUtilityServer::PositioningStopTimeout
   384 // --------------------------------------------------------------------------
   401 // --------------------------------------------------------------------------