locationmanager/server/src/clocationmanagerserver.cpp
branchRCL_3
changeset 7 3cebc1a84278
parent 6 646a02f170b9
child 8 50de4d668bb6
equal deleted inserted replaced
6:646a02f170b9 7:3cebc1a84278
    98 			         iSessionReady( EFalse ),
    98 			         iSessionReady( EFalse ),
    99                      iTagId( 0 ),
    99                      iTagId( 0 ),
   100                      iLocManStopDelay( 0 ),
   100                      iLocManStopDelay( 0 ),
   101                      iLocManStopRemapDelay( 0 ),
   101                      iLocManStopRemapDelay( 0 ),
   102                      iCaptureSetting( RLocationTrail::EOff ),
   102                      iCaptureSetting( RLocationTrail::EOff ),
   103                      iRemoveLocation( EFalse )
   103                      iRemoveLocation( EFalse ),
       
   104                      iWaitForPositioningStopTimeout ( EFalse )
   104     {
   105     {
   105     }
   106     }
   106 
   107 
   107 // --------------------------------------------------------------------------
   108 // --------------------------------------------------------------------------
   108 // CLocationManagerServer::ConstructL
   109 // CLocationManagerServer::ConstructL
   305 // --------------------------------------------------------------------------
   306 // --------------------------------------------------------------------------
   306 //
   307 //
   307 void CLocationManagerServer::StartGPSPositioningL( RLocationTrail::TTrailCaptureSetting aCaptureSetting )
   308 void CLocationManagerServer::StartGPSPositioningL( RLocationTrail::TTrailCaptureSetting aCaptureSetting )
   308     {
   309     {
   309     LOG( "CLocationManagerServer::StartGPSPositioningL" );
   310     LOG( "CLocationManagerServer::StartGPSPositioningL" );
       
   311     iWaitForPositioningStopTimeout = EFalse;
       
   312     
   310     if ( aCaptureSetting == RLocationTrail::EOff )
   313     if ( aCaptureSetting == RLocationTrail::EOff )
   311     	{
   314     	{
   312     	return;
   315     	return;
   313     	}
   316     	}
   314     
   317     
   336 //    
   339 //    
   337 void CLocationManagerServer::StopGPSPositioningL()
   340 void CLocationManagerServer::StopGPSPositioningL()
   338     {
   341     {
   339     LOG( "CLocationManagerServer::StopGPSPositioningL()" );
   342     LOG( "CLocationManagerServer::StopGPSPositioningL()" );
   340     iCaptureSetting = RLocationTrail::EOff;
   343     iCaptureSetting = RLocationTrail::EOff;
       
   344     iWaitForPositioningStopTimeout = EFalse;
   341     
   345     
   342     RLocationTrail::TTrailState state;
   346     RLocationTrail::TTrailState state;
   343     GetLocationTrailState( state );
   347     GetLocationTrailState( state );
   344     
   348     
   345     
   349     
   346     if( state != RLocationTrail::ETrailStopped && state != RLocationTrail::ETrailStopping )
   350     if( state != RLocationTrail::ETrailStopped && state != RLocationTrail::ETrailStopping )
   347         {
   351         {
   348         TRAPD( error, iTimer = CPeriodic::NewL( CActive::EPriorityHigh ) );
   352         TRAPD( error, iTimer = CPeriodic::NewL( CActive::EPriorityUserInput ) );
   349         
   353         
   350         if ( error != KErrNone )
   354         if ( error != KErrNone )
   351             {
   355             {
   352             // If timer can't be created we stop the location trail immediately.
   356             // If timer can't be created we stop the location trail immediately.
   353             iLocationRecord->Stop();
   357             iLocationRecord->Stop();
   367 // CLocationUtilityServer::StopRecording
   371 // CLocationUtilityServer::StopRecording
   368 // --------------------------------------------------------------------------
   372 // --------------------------------------------------------------------------
   369 //
   373 //
   370 void CLocationManagerServer::StopRecording()
   374 void CLocationManagerServer::StopRecording()
   371 	{
   375 	{
   372     LOG( "CLocationManagerServer::StopRecording()" );
   376     LOG( "CLocationManagerServer::StopRecording()" );    
   373 	iLocationRecord->Stop();
   377     iWaitForPositioningStopTimeout = EFalse;
       
   378     iLocationRecord->Stop();		
   374 	delete iTimer;
   379 	delete iTimer;
   375 	iTimer = NULL;
   380 	iTimer = NULL;
   376 	}
   381 	}
   377 
   382 
   378 // --------------------------------------------------------------------------
   383 // --------------------------------------------------------------------------
   400     self->iTimer->Cancel();    
   405     self->iTimer->Cancel();    
   401     
   406     
   402     if ( self->iLocationRecord->RemappingNeeded() )
   407     if ( self->iLocationRecord->RemappingNeeded() )
   403         {     
   408         {     
   404         self->iTimer->Start( self->iLocManStopRemapDelay * 1000000, 0, TCallBack( PositioningStopTimeout, self ) );
   409         self->iTimer->Start( self->iLocManStopRemapDelay * 1000000, 0, TCallBack( PositioningStopTimeout, self ) );
       
   410         self->iWaitForPositioningStopTimeout = ETrue;
   405         }
   411         }
   406     else
   412     else
   407         {        
   413         {        
   408         self->StopRecording();
   414         self->StopRecording();
   409         }
   415         }
   771     filterCondRight.RightL().AddObjectConditionL( rightObjDef );
   777     filterCondRight.RightL().AddObjectConditionL( rightObjDef );
   772 	
   778 	
   773     if( iTargetObjectIds.Count() <= 0 )
   779     if( iTargetObjectIds.Count() <= 0 )
   774     	{
   780     	{
   775     	TInt err = 0;
   781     	TInt err = 0;
   776 	    const TInt count = aTargets.Count();
   782 	    for( TInt i = aTargets.Count() - 1; i >=0; i-- )
   777 	    for( TInt i = 0 ; i < count ; i++ )
       
   778 	    	{
   783 	    	{
   779 	    	TRAP( err, iMdeSession->CheckObjectL( obj, aTargets[i], &namespaceDef ) );
   784 	    	TRAP( err, iMdeSession->CheckObjectL( obj, aTargets[i], &namespaceDef ) );
   780 	    	if ( err == KErrNone )
   785 	    	if ( err == KErrNone )
   781 	    		{
   786 	    		{
   782 		    	iTargetObjectIds.AppendL( aTargets[i] );
   787 		    	iTargetObjectIds.AppendL( aTargets[i] );
   879     
   884     
   880     // "contains" relation definition
   885     // "contains" relation definition
   881     CMdERelationDef& containsRelDef = aQuery.NamespaceDef().GetRelationDefL( 
   886     CMdERelationDef& containsRelDef = aQuery.NamespaceDef().GetRelationDefL( 
   882     		Relations::KContainsLocation );
   887     		Relations::KContainsLocation );
   883     
   888     
   884     const TInt count = iTargetObjectIds.Count();
   889     for( TInt i = iTargetObjectIds.Count() - 1; i >=0; i-- )
   885     for( TInt i=0;i<count;i++ )
       
   886     	{
   890     	{
   887         CMdERelation* relationObject = iMdeSession->NewRelationLC( containsRelDef, iTargetObjectIds[i],
   891         CMdERelation* relationObject = iMdeSession->NewRelationLC( containsRelDef, iTargetObjectIds[i],
   888         		rightId, 0 );
   892         		rightId, 0 );
   889         
   893         
   890         iMdeSession->AddRelationL( *relationObject );
   894         iMdeSession->AddRelationL( *relationObject );
   891         
   895         
   892         CleanupStack::PopAndDestroy( relationObject );
   896         CleanupStack::PopAndDestroy( relationObject );
   893     	}
   897     	}
       
   898     
   894     CleanupStack::PopAndDestroy( sourceLocation );
   899     CleanupStack::PopAndDestroy( sourceLocation );
   895     
   900     
   896     for ( TInt i = iCopyReqs.Count() - 1; i >= 0; --i  )
   901     for ( TInt i = iCopyReqs.Count() - 1; i >= 0; --i  )
   897     	{
   902     	{
   898     	if ( iCopyReqs[i].iQuery == &aQuery )
   903     	if ( iCopyReqs[i].iQuery == &aQuery )
   965 		    uriBuffer->ReceiveL( uriCount );
   970 		    uriBuffer->ReceiveL( uriCount );
   966 		    
   971 		    
   967 		    targetUris.ReserveL( uriCount );
   972 		    targetUris.ReserveL( uriCount );
   968 
   973 
   969 		    // deserialize URIs
   974 		    // deserialize URIs
   970 		    for( TInt i = 0; i < uriCount; i++ )
   975 		    for( TInt i = uriCount- 1; i >=0; i-- )
   971 		    	{
   976 		    	{
   972 		    	targetUris.Append( uriBuffer->ReceivePtr16L() );
   977 		    	targetUris.AppendL( uriBuffer->ReceivePtr16L() );
   973 		    	}
   978 		    	}
   974 		    
   979 		    
   975 	        LOG1("CLocationManagerSession::CopyLocationDataByUriL ID count:%d", targetUris.Count());
   980 	        LOG1("CLocationManagerSession::CopyLocationDataByUriL ID count:%d", targetUris.Count());
   976 	        
   981 	        
   977 	        TMessageQuery q( NULL, aMessage );
   982 	        TMessageQuery q( NULL, aMessage );
  1269 
  1274 
  1270 void CLocationManagerServer::AddGpxObserver( MGpxConversionObserver* aObserver )
  1275 void CLocationManagerServer::AddGpxObserver( MGpxConversionObserver* aObserver )
  1271 	{
  1276 	{
  1272 	iTrackLog->AddGpxObserver( aObserver );
  1277 	iTrackLog->AddGpxObserver( aObserver );
  1273 	}
  1278 	}
       
  1279 
       
  1280 void CLocationManagerServer::RemapedCompleted()
       
  1281     {
       
  1282     LOG( "CLocationManagerServer::RemapedCompleted()" );
       
  1283     StopRecording();
       
  1284     }
       
  1285 
       
  1286 TBool CLocationManagerServer::WaitForPositioningStopTimeout()
       
  1287     {
       
  1288     LOG( "CLocationManagerServer::WaitForPositioningStopTimeout()" );
       
  1289     return iWaitForPositioningStopTimeout;
       
  1290     }
       
  1291 
  1274 // End of file 
  1292 // End of file